chore: 新增其他系统的二进制文件
This commit is contained in:
parent
7aefaa919f
commit
ae04f35bb1
@ -6,7 +6,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"web:dev": "vite",
|
"web:dev": "vite",
|
||||||
"web:preview": "vite preview",
|
"web:preview": "vite preview",
|
||||||
"web:build": "tsc && vite build",
|
"web:build": "vite build",
|
||||||
"sidecar:build": "node build-sidecar.mjs",
|
"sidecar:build": "node build-sidecar.mjs",
|
||||||
"tauri": "tauri"
|
"tauri": "tauri"
|
||||||
},
|
},
|
||||||
|
|||||||
34
src/App.tsx
34
src/App.tsx
@ -1,26 +1,28 @@
|
|||||||
import { useStartupCheck } from '@/hooks/useStartupCheck'
|
import { useStartupCheck } from "@/hooks/useStartupCheck";
|
||||||
import { usePreventDefault } from '@/hooks/usePreventDefaultEventListener'
|
import { usePreventDefault } from "@/hooks/usePreventDefaultEventListener";
|
||||||
import { useGlobalShortcut } from '@/hooks/useGlobalShortcut'
|
import { useGlobalShortcut } from "@/hooks/useGlobalShortcut";
|
||||||
import { useRecreateTheCircuit } from '@/hooks/useRecreateTheCircuit'
|
import { useRecreateTheCircuit } from "@/hooks/useRecreateTheCircuit";
|
||||||
import { useCoreConfig } from './hooks/useCoreConfig'
|
import { useCoreConfig } from "./hooks/useCoreConfig";
|
||||||
// import { commands } from '@/bindings'
|
// import { commands } from '@/bindings'
|
||||||
import Titlebar from '@/components/Titlebar'
|
import Titlebar from "@/components/Titlebar";
|
||||||
|
|
||||||
|
import Layout from "@/layout";
|
||||||
|
import Tray from "@/components/Tray";
|
||||||
|
|
||||||
import Layout from '@/layout'
|
|
||||||
import Tray from '@/components/Tray'
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
// 执行启动自检
|
// 执行启动自检
|
||||||
useStartupCheck()
|
useStartupCheck();
|
||||||
// 阻止默认事件
|
// 阻止默认事件
|
||||||
usePreventDefault()
|
usePreventDefault();
|
||||||
// 注册全局快捷方式
|
// 注册全局快捷方式
|
||||||
useGlobalShortcut()
|
useGlobalShortcut();
|
||||||
// 当核心启动时重新创建电路
|
// 当核心启动时重新创建电路
|
||||||
useRecreateTheCircuit()
|
useRecreateTheCircuit();
|
||||||
// 读取配置,若文件不存在则持久化到本地 `%APPDATA%/com.paw.paw-gui`
|
// 读取配置,若文件不存在则持久化到本地 `%APPDATA%/com.paw.paw-gui`
|
||||||
const { loadCoreConfig } = useCoreConfig()
|
const { loadCoreConfig } = useCoreConfig();
|
||||||
loadCoreConfig()
|
loadCoreConfig();
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main>
|
<main>
|
||||||
@ -28,7 +30,7 @@ function App() {
|
|||||||
<Layout />
|
<Layout />
|
||||||
<Tray />
|
<Tray />
|
||||||
</main>
|
</main>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default App
|
export default App;
|
||||||
|
|||||||
28
src/api/block.ts
Normal file
28
src/api/block.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import { CoreConfig } from "@/bindings";
|
||||||
|
import { api } from "@/utils/api";
|
||||||
|
|
||||||
|
// 区块链api 类
|
||||||
|
export class BlockChainApi {
|
||||||
|
public coreConfig: CoreConfig;
|
||||||
|
public baseUrl = "http://localhost:3000/api";
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.coreConfig = {} as CoreConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
// async initCoreConfig() {
|
||||||
|
// // 异步调用 loadCoreConfig 函数,获取核心配置信息
|
||||||
|
// this.coreConfig = await loadCoreConfig();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 获取最新的区块信息
|
||||||
|
async getLatestBlock() {
|
||||||
|
const res = await api.get(
|
||||||
|
this.baseUrl + "/cosmos/base/tendermint/v1beta1/blocks/latest",
|
||||||
|
);
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出一个异步函数 initBlockChinApi,用于初始化区块链API
|
||||||
|
export const blockChainApi = new BlockChainApi();
|
||||||
@ -31,14 +31,10 @@ const createConfigStore = async () => {
|
|||||||
return await load('core_config.json', { autoSave: true })
|
return await load('core_config.json', { autoSave: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useCoreConfig() {
|
|
||||||
/**
|
export const loadCoreConfig = async () => {
|
||||||
* 从本地存储加载配置,若没有则加载默认配置并存储到本地
|
|
||||||
*/
|
|
||||||
const loadCoreConfig = async () => {
|
|
||||||
const store = await createConfigStore()
|
const store = await createConfigStore()
|
||||||
const savedConfig = await store.get<CoreConfig>('core_config')
|
const savedConfig = await store.get<CoreConfig>('core_config')
|
||||||
console.log(savedConfig,'defaultConfig')
|
|
||||||
|
|
||||||
if (savedConfig) {
|
if (savedConfig) {
|
||||||
return savedConfig
|
return savedConfig
|
||||||
@ -50,6 +46,12 @@ export function useCoreConfig() {
|
|||||||
return defaultConfig
|
return defaultConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useCoreConfig() {
|
||||||
|
/**
|
||||||
|
* 从本地存储加载配置,若没有则加载默认配置并存储到本地
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存配置到本地存储
|
* 保存配置到本地存储
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import type { AppDispatch, RootState } from "@/store";
|
|||||||
import "./index.scss";
|
import "./index.scss";
|
||||||
import { DialogConfig, FormAlertDialog } from "./components/FormAlertDialog";
|
import { DialogConfig, FormAlertDialog } from "./components/FormAlertDialog";
|
||||||
import { ClearNodeDialog } from "./components/ClearNodeDialog";
|
import { ClearNodeDialog } from "./components/ClearNodeDialog";
|
||||||
|
import { blockChainApi } from "@/api/block";
|
||||||
|
|
||||||
export const DIALOGTYPE = {
|
export const DIALOGTYPE = {
|
||||||
ADDNode: {
|
ADDNode: {
|
||||||
@ -68,6 +69,8 @@ const NewHome = () => {
|
|||||||
NODEDIALOGTYPE.ClearFailNode
|
NODEDIALOGTYPE.ClearFailNode
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const [blockChain, setBlockChain] = useState<any>(null);
|
||||||
|
|
||||||
const [tooltipClosed, setTooltipClosed] = useState(false);
|
const [tooltipClosed, setTooltipClosed] = useState(false);
|
||||||
|
|
||||||
const [tooltipType, setTooltipType] = useState(
|
const [tooltipType, setTooltipType] = useState(
|
||||||
@ -170,9 +173,17 @@ const NewHome = () => {
|
|||||||
// return () => clearInterval(interval);
|
// return () => clearInterval(interval);
|
||||||
// }, [dispatch]);
|
// }, [dispatch]);
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
blockChainApi.getLatestBlock().then((res)=>{
|
||||||
|
console.log("res",res)
|
||||||
|
setBlockChain(res)
|
||||||
|
})
|
||||||
|
},[])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="decentralized w-full h-full flex flex-col relative">
|
<div className="decentralized w-full h-full flex flex-col relative">
|
||||||
<div className="box"></div>
|
<div className="box"></div>
|
||||||
|
<div className="text-red-300">{blockChain?.block_id?.hash || "111"}</div>
|
||||||
<div className="w-full flex items-center justify-center relative">
|
<div className="w-full flex items-center justify-center relative">
|
||||||
{/* <img
|
{/* <img
|
||||||
className="w-[1693px] h-[271px] absolute top-[160px] left-[50%] translate-x-[-50%] z-10"
|
className="w-[1693px] h-[271px] absolute top-[160px] left-[50%] translate-x-[-50%] z-10"
|
||||||
|
|||||||
34
src/utils/api.ts
Normal file
34
src/utils/api.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { type ClientOptions, fetch } from "@tauri-apps/plugin-http";
|
||||||
|
|
||||||
|
class FetchApi {
|
||||||
|
async sendRequest(
|
||||||
|
url: string,
|
||||||
|
method: string,
|
||||||
|
data?: any,
|
||||||
|
config: RequestInit & ClientOptions = {}
|
||||||
|
) {
|
||||||
|
const result = await fetch(url, {
|
||||||
|
method: method,
|
||||||
|
body: data ? JSON.stringify(data) : undefined,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
...config,
|
||||||
|
});
|
||||||
|
if (result.ok) {
|
||||||
|
return await result.json();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async get(url: string, config: RequestInit & ClientOptions = {}) {
|
||||||
|
return await this.sendRequest(url, "GET", undefined, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
async post(url: string, data: any, config: RequestInit & ClientOptions = {}) {
|
||||||
|
return await this.sendRequest(url, "POST", data, config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const api = new FetchApi();
|
||||||
Loading…
x
Reference in New Issue
Block a user