refactor:重构请求配置
This commit is contained in:
parent
064973aaf0
commit
9f09e8ba61
1
.env
1
.env
@ -4,3 +4,4 @@ NODE_SECRET="aHVnZSBjb21wYW55IHBob25lIHdlc3QgcGxhY2Ugc2VtaW5hciBtaXJhY2xlIGxlbmQ
|
|||||||
IS_DEBUG="true"
|
IS_DEBUG="true"
|
||||||
ACCOUNT_NAME="de1"
|
ACCOUNT_NAME="de1"
|
||||||
VITE_BASE_URL="http://10.66.66.234:6060"
|
VITE_BASE_URL="http://10.66.66.234:6060"
|
||||||
|
VITE_BLOCK_URL="http://localhost:3001"
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { api } from "@/utils/api";
|
|||||||
// 区块链api 类
|
// 区块链api 类
|
||||||
export class BlockChainApi {
|
export class BlockChainApi {
|
||||||
public coreConfig: CoreConfig;
|
public coreConfig: CoreConfig;
|
||||||
public baseUrl = "http://localhost:3000/api";
|
public baseUrl = import.meta.env.VITE_BLOCK_URL;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.coreConfig = {} as CoreConfig;
|
this.coreConfig = {} as CoreConfig;
|
||||||
|
|||||||
@ -4,24 +4,24 @@ const baseUrl = import.meta.env.VITE_BASE_URL;
|
|||||||
|
|
||||||
// 通行认证
|
// 通行认证
|
||||||
export const getPassAuthentication = async () => {
|
export const getPassAuthentication = async () => {
|
||||||
return await api.get(`${baseUrl}/step/pass_authentication`);
|
return (await api.get(`${baseUrl}/step/pass_authentication`)).data;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 流量混淆
|
// 流量混淆
|
||||||
export const getTrafficObfuscation = async () => {
|
export const getTrafficObfuscation = async () => {
|
||||||
return await api.get(`${baseUrl}/step/traffic_obfuscation`);
|
return (await api.get(`${baseUrl}/step/traffic_obfuscation`)).data;
|
||||||
}
|
};
|
||||||
|
|
||||||
// 嵌套加密
|
// 嵌套加密
|
||||||
export const getNestedEncryption = async () => {
|
export const getNestedEncryption = async () => {
|
||||||
return await api.get(`${baseUrl}/step/nested_encryption`);
|
return (await api.get(`${baseUrl}/step/nested_encryption`)).data;
|
||||||
}
|
};
|
||||||
// 动态路由生成
|
// 动态路由生成
|
||||||
export const getDynamicRouteGeneration = async () => {
|
export const getDynamicRouteGeneration = async () => {
|
||||||
return await api.get(`${baseUrl}/step/dynamic_route_generator`);
|
return (await api.get(`${baseUrl}/step/dynamic_route_generator`)).data;
|
||||||
}
|
};
|
||||||
|
|
||||||
// 应用分流
|
// 应用分流
|
||||||
export const getApplicationDiversion = async () => {
|
export const getApplicationDiversion = async () => {
|
||||||
return await api.get(`${baseUrl}/step/app_diversion`);
|
return (await api.get(`${baseUrl}/step/app_diversion`)).data;
|
||||||
}
|
};
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
export const TRAFFIC_OBFUSCATION = {
|
export const TRAFFIC_OBFUSCATION = {
|
||||||
type: "NESTED_ENCRYPTION",
|
type: "NESTED_ENCRYPTION",
|
||||||
name: "流量混淆",
|
name: "流量混淆",
|
||||||
code: "BR",
|
code: "ZA",
|
||||||
data: [
|
data: [
|
||||||
{
|
{
|
||||||
country_code: "gl",
|
country_code: "gl",
|
||||||
@ -404,6 +404,8 @@ export const APP_DIVERSION = [
|
|||||||
export const PASS_AUTHENTICATION = {
|
export const PASS_AUTHENTICATION = {
|
||||||
type: "PASS_AUTHENTICATION",
|
type: "PASS_AUTHENTICATION",
|
||||||
name: "通行认证",
|
name: "通行认证",
|
||||||
|
startPoint: "GL",
|
||||||
|
endPoint: "CA",
|
||||||
authenticationPoint: [
|
authenticationPoint: [
|
||||||
[-103.346771, 54.130366],
|
[-103.346771, 54.130366],
|
||||||
[-120.346771, 52.130366],
|
[-120.346771, 52.130366],
|
||||||
@ -444,4 +446,4 @@ export const PASS_AUTHENTICATION = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
isLine: true,
|
isLine: true,
|
||||||
};
|
}
|
||||||
|
|||||||
@ -100,13 +100,13 @@ const NodeForm = ({ form }: { form: FormInstance }) => {
|
|||||||
{/* <Form.Item name="uid" className="hidden">
|
{/* <Form.Item name="uid" className="hidden">
|
||||||
<div className="hidden">uid</div>
|
<div className="hidden">uid</div>
|
||||||
</Form.Item> */}
|
</Form.Item> */}
|
||||||
<Form.Item name="nodePublicKey" label="节点身份公钥">
|
<Form.Item name="public_key" label="节点身份公钥">
|
||||||
<Input
|
<Input
|
||||||
className="link_name_input placeholder:text-base placeholder:text-zinc-400 text-[16px]"
|
className="link_name_input placeholder:text-base placeholder:text-zinc-400 text-[16px]"
|
||||||
placeholder="节点身份公钥*"
|
placeholder="节点身份公钥*"
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="nodeMetadata" label="节点元数据">
|
<Form.Item name="private_key" label="节点元数据">
|
||||||
<Input
|
<Input
|
||||||
className="link_name_input placeholder:text-base placeholder:text-zinc-400 text-[16px]"
|
className="link_name_input placeholder:text-base placeholder:text-zinc-400 text-[16px]"
|
||||||
placeholder="请输入TLS Pubkey*"
|
placeholder="请输入TLS Pubkey*"
|
||||||
|
|||||||
@ -73,6 +73,7 @@ const DecentralizedElasticNetwork = () => {
|
|||||||
await form.validateFields();
|
await form.validateFields();
|
||||||
const formValue: any = form.getFieldsValue();
|
const formValue: any = form.getFieldsValue();
|
||||||
if (type.title === DIALOGTYPE.ADDNode.title) {
|
if (type.title === DIALOGTYPE.ADDNode.title) {
|
||||||
|
console.log(formValue,"formValue")
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
} else {
|
} else {
|
||||||
const { inbound, outbound } = formValue || {};
|
const { inbound, outbound } = formValue || {};
|
||||||
|
|||||||
@ -168,7 +168,6 @@ export const WorldGeo = memo(
|
|||||||
// 定位自定义提示框 - 优化版本
|
// 定位自定义提示框 - 优化版本
|
||||||
const positionCustomTooltip = () => {
|
const positionCustomTooltip = () => {
|
||||||
if (!customTooltipRef.current || !proxyGeoRef.current) return;
|
if (!customTooltipRef.current || !proxyGeoRef.current) return;
|
||||||
console.log(dataInfo.nestedEncryption?.[0]?.code, "sssss");
|
|
||||||
// 找到US点
|
// 找到US点
|
||||||
const coords = geoCoordMap[dataInfo.nestedEncryption?.[0]?.code ?? "GL"];
|
const coords = geoCoordMap[dataInfo.nestedEncryption?.[0]?.code ?? "GL"];
|
||||||
if (!coords) return;
|
if (!coords) return;
|
||||||
@ -1159,7 +1158,6 @@ export const WorldGeo = memo(
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log(tooltipClosed, "tooltipClosedtooltipClosed");
|
|
||||||
if (tooltipClosed) {
|
if (tooltipClosed) {
|
||||||
createCustomTooltip();
|
createCustomTooltip();
|
||||||
createCustomTooltip2();
|
createCustomTooltip2();
|
||||||
|
|||||||
@ -22,7 +22,6 @@ 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";
|
|
||||||
import {
|
import {
|
||||||
getPassAuthentication,
|
getPassAuthentication,
|
||||||
getTrafficObfuscation,
|
getTrafficObfuscation,
|
||||||
@ -30,6 +29,7 @@ import {
|
|||||||
getDynamicRouteGeneration,
|
getDynamicRouteGeneration,
|
||||||
getApplicationDiversion,
|
getApplicationDiversion,
|
||||||
} from "@/api/flying-line";
|
} from "@/api/flying-line";
|
||||||
|
import { blockChainApi } from "@/api/block";
|
||||||
|
|
||||||
export const DIALOGTYPE = {
|
export const DIALOGTYPE = {
|
||||||
ADDNode: {
|
ADDNode: {
|
||||||
@ -58,7 +58,7 @@ export const NODEDIALOGTYPE = {
|
|||||||
};
|
};
|
||||||
const NewHome = () => {
|
const NewHome = () => {
|
||||||
const dispatch = useDispatch<AppDispatch>();
|
const dispatch = useDispatch<AppDispatch>();
|
||||||
const { web3List, web3List2, } = useSelector(
|
const { web3List, web3List2 } = useSelector(
|
||||||
(state: RootState) => state.web3Reducer
|
(state: RootState) => state.web3Reducer
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -242,10 +242,9 @@ const NewHome = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// blockChainApi.getLatestBlock().then((res) => {
|
blockChainApi.getLatestBlock().then((res) => {
|
||||||
// console.log("res", res);
|
console.log("res", res);
|
||||||
// setBlockChain(res);
|
});
|
||||||
// });
|
|
||||||
initData();
|
initData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ export const router = createBrowserRouter([
|
|||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
index: true, // 默认路由
|
index: true, // 默认路由
|
||||||
element: <Navigate to="/home" replace />, // 重定向到 /home
|
element: <Navigate to="/new-home" replace />, // 重定向到 /home
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/new-home',
|
path: '/new-home',
|
||||||
|
|||||||
@ -16,9 +16,15 @@ class FetchApi {
|
|||||||
...config,
|
...config,
|
||||||
});
|
});
|
||||||
if (result.ok) {
|
if (result.ok) {
|
||||||
return await result.json();
|
return {
|
||||||
|
success: true,
|
||||||
|
data: await result.json(),
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return {
|
||||||
|
success: false,
|
||||||
|
data: await result.text(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
9
src/vite-env.d.ts
vendored
9
src/vite-env.d.ts
vendored
@ -1,2 +1,11 @@
|
|||||||
/// <reference types="vite/client" />
|
/// <reference types="vite/client" />
|
||||||
/// <reference types="vite-plugin-svgr/client" />
|
/// <reference types="vite-plugin-svgr/client" />
|
||||||
|
interface ImportMetaEnv {
|
||||||
|
// 定义你的环境变量,例如:
|
||||||
|
readonly VITE_BASE_URL: string
|
||||||
|
readonly VITE_BLOCK_URL: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ImportMeta {
|
||||||
|
readonly env: ImportMetaEnv
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user