mirror of
https://github.com/EasyTier/EasytierGame.git
synced 2026-09-25 03:35:55 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70c3217ab5 | ||
|
|
e91bd07ce8 | ||
|
|
9f63d9bf2e | ||
|
|
94968401fc | ||
|
|
86adc2c40b | ||
|
|
6b373a3ed6 | ||
|
|
fa480a8162 | ||
|
|
0da1ab85cd | ||
|
|
b1d1144e78 | ||
|
|
d71b93c1a8 | ||
|
|
9e83ca7d91 | ||
|
|
c10a3ae22f | ||
|
|
6f5e0a85f8 | ||
|
|
ae42baa73a | ||
|
|
05fe46858d | ||
|
|
a438c48fdc | ||
|
|
777ec9b982 | ||
|
|
167002691c | ||
|
|
434014f690 | ||
|
|
0d0901de94 | ||
|
|
18f6c54a4f | ||
|
|
ad0f252dfd | ||
|
|
6bf4d54361 | ||
|
|
8f2c800380 | ||
|
|
8b2ce406d8 | ||
|
|
10dde939cb | ||
|
|
84460409ed | ||
|
|
60faa01769 | ||
|
|
26f3f6fb36 | ||
|
|
494087820a | ||
|
|
87f4d98518 | ||
|
|
30a2c3430b | ||
|
|
aab8175ce3 | ||
|
|
136ce06c33 | ||
|
|
bdeda8bebd | ||
|
|
3ee09f7d60 |
@@ -10,6 +10,7 @@ dist
|
|||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
release
|
release
|
||||||
|
target
|
||||||
|
|
||||||
src-tauri/easytier/logs
|
src-tauri/easytier/logs
|
||||||
src-tauri/easytier/tool/ResourcesExtract.exe
|
src-tauri/easytier/tool/ResourcesExtract.exe
|
||||||
|
|||||||
+8
-1
@@ -39,7 +39,7 @@ html.dark body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.full-label .el-form-item__label {
|
.full-label .el-form-item__label {
|
||||||
width: 100%;
|
width: 100%!important;
|
||||||
padding-right: 0;
|
padding-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,6 +50,13 @@ html.dark body {
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.el-select__selection {
|
||||||
|
/* display: none!important; */
|
||||||
|
min-height: 20px!important;
|
||||||
|
flex-wrap: nowrap!important;
|
||||||
|
overflow: hidden!important;
|
||||||
|
}
|
||||||
|
|
||||||
.el-table {
|
.el-table {
|
||||||
font-size: 12px !important;
|
font-size: 12px !important;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,20 @@
|
|||||||
pnpm run build
|
pnpm run build
|
||||||
rustup default nightly
|
rustup default nightly
|
||||||
@REM rem 使用rust nightly构建支持win7的版本,请先将根目录的windows.0.48.5 放入以下目录
|
|
||||||
@REM rem C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\lib\x64
|
|
||||||
@REM rem C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\lib\x86
|
|
||||||
@REM rem C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\atlmfc\lib\x64
|
|
||||||
@REM rem C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\atlmfc\lib\x86
|
|
||||||
pnpm tauri build -- -Z build-std --target x86_64-win7-windows-msvc
|
pnpm tauri build -- -Z build-std --target x86_64-win7-windows-msvc
|
||||||
rustup default stable
|
rustup default stable
|
||||||
pnpm tauri build
|
pnpm tauri build
|
||||||
|
|
||||||
|
@REM 复制文件夹src-tauri\easytier 到 src-tauri\target\release目录下 覆盖目录下同名目录
|
||||||
|
xcopy /s /y /i src-tauri\easytier src-tauri\target\release\easytier
|
||||||
|
@REM 复制 src-tauri\帮助.txt 和 src-tauri\uninstall.exe 到 src-tauri\target\release目录下 覆盖目录下同名文件
|
||||||
|
xcopy /y src-tauri\帮助.txt src-tauri\target\release\帮助.txt
|
||||||
|
xcopy /y src-tauri\uninstall.exe src-tauri\target\release\uninstall.exe
|
||||||
|
@REM 复制文件夹src-tauri\easytier到 src-tauri\target\x86_64-win7-windows-msvc\release目录下 覆盖目录下同名目录
|
||||||
|
@REM 复制 src-tauri\帮助.txt 和 src-tauri\uninstall.exe 到 src-tauri\target\x86_64-win7-windows-msvc\release目录下 覆盖目录下同名文件
|
||||||
|
xcopy /y src-tauri\帮助.txt src-tauri\target\x86_64-win7-windows-msvc\release\帮助.txt
|
||||||
|
xcopy /y src-tauri\uninstall.exe src-tauri\target\x86_64-win7-windows-msvc\release\uninstall.exe
|
||||||
|
xcopy /s /y /i src-tauri\easytier src-tauri\target\x86_64-win7-windows-msvc\release\easytier
|
||||||
|
|
||||||
pnpm run release
|
pnpm run release
|
||||||
pnpm run release-win7
|
pnpm run release-win7
|
||||||
+14
-19
@@ -5,9 +5,9 @@ import { uniq, intersection, isNil } from "lodash-es";
|
|||||||
import { bounce } from "~/utils";
|
import { bounce } from "~/utils";
|
||||||
|
|
||||||
const b = bounce(600);
|
const b = bounce(600);
|
||||||
export type ConfigServerUrlType = Array<string> | string | null | undefined | null;
|
export type ConfigServerUrlType = Array<string>;
|
||||||
|
|
||||||
export const updateConfigJsonBounce = (configJsonSeverUrl?: ConfigServerUrlType) => {
|
export const updateConfigJsonBounce = (configJsonSeverUrl?: ConfigServerUrlType | null) => {
|
||||||
b(async () => {
|
b(async () => {
|
||||||
const mainStore = useMainStore();
|
const mainStore = useMainStore();
|
||||||
if (mainStore.createConfigInEasytier) {
|
if (mainStore.createConfigInEasytier) {
|
||||||
@@ -16,19 +16,20 @@ export const updateConfigJsonBounce = (configJsonSeverUrl?: ConfigServerUrlType)
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateConfigJson = async (configJsonSeverUrl?: ConfigServerUrlType) => {
|
export const updateConfigJson = async (configJsonSeverUrl?: ConfigServerUrlType | null) => {
|
||||||
const mainStore = useMainStore();
|
const mainStore = useMainStore();
|
||||||
const path = import.meta.env.VITE_CONFIG_FILE_NAME;
|
const path = import.meta.env.VITE_CONFIG_FILE_NAME;
|
||||||
if (isNil(configJsonSeverUrl)) {
|
if (isNil(configJsonSeverUrl)) {
|
||||||
configJsonSeverUrl = [];
|
configJsonSeverUrl = [];
|
||||||
}
|
}
|
||||||
const isArray = Array.isArray(configJsonSeverUrl);
|
if(typeof(configJsonSeverUrl) == 'string') {
|
||||||
const isString = typeof configJsonSeverUrl === "string";
|
configJsonSeverUrl = [configJsonSeverUrl];
|
||||||
|
}
|
||||||
|
configJsonSeverUrl = configJsonSeverUrl || [];
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
proxyNetworks,
|
proxyNetworks,
|
||||||
autoStart,
|
autoStart,
|
||||||
connectAfterStart,
|
|
||||||
saveErrorLog,
|
saveErrorLog,
|
||||||
serverUrl,
|
serverUrl,
|
||||||
enableCustomListener,
|
enableCustomListener,
|
||||||
@@ -39,20 +40,14 @@ export const updateConfigJson = async (configJsonSeverUrl?: ConfigServerUrlType)
|
|||||||
portForwardData,
|
portForwardData,
|
||||||
...otherConfig
|
...otherConfig
|
||||||
} = mainStore.config;
|
} = mainStore.config;
|
||||||
let writeServerUrl: Array<string> | string = serverUrl;
|
let writeServerUrl: Array<string> = serverUrl;
|
||||||
let writeCustomListenerData: Array<string> = (customListenerData || "").split("\n");
|
let writeCustomListenerData: Array<string> = (customListenerData || "").split("\n");
|
||||||
if (isArray) {
|
|
||||||
writeServerUrl = intersection(
|
writeServerUrl = intersection(
|
||||||
uniq([serverUrl, ...configJsonSeverUrl]).filter(boolean => boolean),
|
uniq([...serverUrl, ...configJsonSeverUrl]).filter(boolean => boolean),
|
||||||
mainStore.basePeers
|
mainStore.basePeers
|
||||||
);
|
);
|
||||||
}
|
|
||||||
if (isString && configJsonSeverUrl) {
|
|
||||||
writeServerUrl = intersection(
|
|
||||||
uniq([serverUrl, ...(configJsonSeverUrl as string).split(",")]).filter(boolean => boolean),
|
|
||||||
mainStore.basePeers
|
|
||||||
).join(",");
|
|
||||||
}
|
|
||||||
await writeTextFile(
|
await writeTextFile(
|
||||||
path,
|
path,
|
||||||
JSON.stringify({ serverUrl: writeServerUrl, enableCustomListener, customListenerData: writeCustomListenerData, ...otherConfig }, null, 4),
|
JSON.stringify({ serverUrl: writeServerUrl, enableCustomListener, customListenerData: writeCustomListenerData, ...otherConfig }, null, 4),
|
||||||
|
|||||||
+44
-44
@@ -6,55 +6,55 @@ import { BaseDirectory } from "@tauri-apps/api/path";
|
|||||||
import { exists } from "@tauri-apps/plugin-fs";
|
import { exists } from "@tauri-apps/plugin-fs";
|
||||||
|
|
||||||
const getWinIpBroadcastPid = async () => {
|
const getWinIpBroadcastPid = async () => {
|
||||||
const mainStore = useMainStore();
|
// const mainStore = useMainStore();
|
||||||
const pid = await invoke("search_pid_by_pname", { target_process_name: "WinIPBroadcast" });
|
// const pid = await invoke("search_pid_by_pname", { target_process_name: "WinIPBroadcast" });
|
||||||
mainStore.winipBcPid = (pid as number) || 0;
|
// mainStore.winipBcPid = (pid as number) || 0;
|
||||||
mainStore.$patch({
|
// mainStore.$patch({
|
||||||
winipBcStart: !!(mainStore.winipBcPid && mainStore.winipBcPid > 0)
|
// winipBcStart: !!(mainStore.winipBcPid && mainStore.winipBcPid > 0)
|
||||||
});
|
// });
|
||||||
};
|
};
|
||||||
|
|
||||||
export const handleWinipBcStart = async () => {
|
export const handleWinipBcStart = async () => {
|
||||||
const mainStore = useMainStore();
|
// const mainStore = useMainStore();
|
||||||
if (!mainStore.winipBcStart) {
|
// if (!mainStore.winipBcStart) {
|
||||||
try {
|
// try {
|
||||||
await invoke("stop_command", { child_id: mainStore.winipBcPid || 0 });
|
// await invoke("stop_command", { child_id: mainStore.winipBcPid || 0 });
|
||||||
const isExists = await exists("easytier/tool/WinIPBroadcast.exe", { baseDir: BaseDirectory.Resource });
|
// const isExists = await exists("easytier/tool/WinIPBroadcast.exe", { baseDir: BaseDirectory.Resource });
|
||||||
if (!isExists) {
|
// if (!isExists) {
|
||||||
ElMessage.error(`WinipBc不存在`);
|
// ElMessage.error(`WinipBc不存在`);
|
||||||
console.error(`WinipBc不存在`);
|
// console.error(`WinipBc不存在`);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
const child = await Command.create("WinIPBroadcast", ["run"]).spawn();
|
// const child = await Command.create("WinIPBroadcast", ["run"]).spawn();
|
||||||
mainStore.winipBcPid = child.pid || 0;
|
// mainStore.winipBcPid = child.pid || 0;
|
||||||
await getWinIpBroadcastPid();
|
// await getWinIpBroadcastPid();
|
||||||
if (mainStore.winipBcPid) {
|
// if (mainStore.winipBcPid) {
|
||||||
mainStore.$patch({
|
// mainStore.$patch({
|
||||||
winIpBcAutoStart: true
|
// winIpBcAutoStart: true
|
||||||
});
|
// });
|
||||||
} else {
|
// } else {
|
||||||
ElMessage.error(`WinipBc失败`);
|
// ElMessage.error(`WinipBc失败`);
|
||||||
}
|
// }
|
||||||
} catch (err) {
|
// } catch (err) {
|
||||||
ElMessage.error(`WinipBc失败`);
|
// ElMessage.error(`WinipBc失败`);
|
||||||
console.error(err);
|
// console.error(err);
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
await invoke("stop_command", { child_id: mainStore.winipBcPid || 0 });
|
// await invoke("stop_command", { child_id: mainStore.winipBcPid || 0 });
|
||||||
await getWinIpBroadcastPid();
|
// await getWinIpBroadcastPid();
|
||||||
if (mainStore.winipBcPid <= 0) {
|
// if (mainStore.winipBcPid <= 0) {
|
||||||
mainStore.$patch({
|
// mainStore.$patch({
|
||||||
winIpBcAutoStart: false
|
// winIpBcAutoStart: false
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
export const initStartWinIpBroadcast = async () => {
|
export const initStartWinIpBroadcast = async () => {
|
||||||
const mainStore = useMainStore();
|
// const mainStore = useMainStore();
|
||||||
await getWinIpBroadcastPid();
|
// await getWinIpBroadcastPid();
|
||||||
// console.error(mainStore.winipBcStart, mainStore.winIpBcAutoStart)
|
// console.error(mainStore.winipBcStart, mainStore.winIpBcAutoStart)
|
||||||
if (mainStore.winIpBcAutoStart && !mainStore.winipBcStart) {
|
// if (mainStore.winIpBcAutoStart && !mainStore.winipBcStart) {
|
||||||
await handleWinipBcStart();
|
// await handleWinipBcStart();
|
||||||
}
|
// }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,5 +23,14 @@ export const getServerArgs = () => {
|
|||||||
if (mainStore.serverConfig.privateMode) {
|
if (mainStore.serverConfig.privateMode) {
|
||||||
args.push("--private-mode", "true");
|
args.push("--private-mode", "true");
|
||||||
}
|
}
|
||||||
|
const networkName = mainStore.serverConfig.privateNetworkName.trim();
|
||||||
|
if (networkName) {
|
||||||
|
args.push("--network-name", networkName);
|
||||||
|
}
|
||||||
|
const networkSecret = mainStore.serverConfig.privateNetworkPassword.trim();
|
||||||
|
if (networkSecret) {
|
||||||
|
args.push("--network-secret", networkSecret);
|
||||||
|
}
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
};
|
};
|
||||||
|
|||||||
+18
-7
@@ -22,7 +22,7 @@ async function toggleVisibility() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function useTray(init: boolean = false, beforExit: Function, handleConnection: Function) {
|
export async function useTray(init: boolean = false, beforExit: Function, handleConnection: Function, handleReconnect: Function, handleNodesList: Function) {
|
||||||
let tray;
|
let tray;
|
||||||
try {
|
try {
|
||||||
tray = await TrayIcon.getById(DEFAULT_TRAY_NAME);
|
tray = await TrayIcon.getById(DEFAULT_TRAY_NAME);
|
||||||
@@ -31,7 +31,7 @@ export async function useTray(init: boolean = false, beforExit: Function, handle
|
|||||||
tooltip: `EasyTierGame\n${pkg.version}`,
|
tooltip: `EasyTierGame\n${pkg.version}`,
|
||||||
title: `EasyTierGame\n${pkg.version}`,
|
title: `EasyTierGame\n${pkg.version}`,
|
||||||
id: DEFAULT_TRAY_NAME,
|
id: DEFAULT_TRAY_NAME,
|
||||||
menu: await Menu.new({ id: "main", items: await generateMenuItem(beforExit, handleConnection) }),
|
menu: await Menu.new({ id: "main", items: await generateMenuItem(beforExit, handleConnection, handleReconnect, handleNodesList) }),
|
||||||
action: async e => {
|
action: async e => {
|
||||||
toggleVisibility();
|
toggleVisibility();
|
||||||
}
|
}
|
||||||
@@ -45,24 +45,35 @@ export async function useTray(init: boolean = false, beforExit: Function, handle
|
|||||||
if (init) {
|
if (init) {
|
||||||
tray.setTooltip(`EasyTierGame\n${pkg.version}`);
|
tray.setTooltip(`EasyTierGame\n${pkg.version}`);
|
||||||
tray.setShowMenuOnLeftClick(false);
|
tray.setShowMenuOnLeftClick(false);
|
||||||
tray.setMenu(await Menu.new({ id: "main", items: await generateMenuItem(beforExit, handleConnection) }));
|
tray.setMenu(await Menu.new({ id: "main", items: await generateMenuItem(beforExit, handleConnection, handleReconnect, handleNodesList) }));
|
||||||
}
|
}
|
||||||
|
|
||||||
return tray;
|
return tray;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function generateMenuItem(beforExit: Function, handleConnection: Function) {
|
export async function generateMenuItem(beforExit: Function, handleConnection: Function, handleReconnect: Function, handleNodesList: Function) {
|
||||||
return [
|
return [
|
||||||
await MenuItemShow("显示 / 隐藏"),
|
await MenuItemShow("显示 / 隐藏"),
|
||||||
await MenuItemExchangeConnection("联机 / 断开", handleConnection),
|
await MenuItemExchangeConnection("联机 / 断开", handleConnection),
|
||||||
|
await MenuItemReconnect("重新联机", handleReconnect),
|
||||||
await MenuItemTheme(),
|
await MenuItemTheme(),
|
||||||
await PredefinedMenuItem.new({ item: "Separator" }),
|
await PredefinedMenuItem.new({ item: "Separator" }),
|
||||||
await MenuItemPublicPeers(),
|
await MenuItemPublicPeers(handleNodesList),
|
||||||
await PredefinedMenuItem.new({ item: "Separator" }),
|
await PredefinedMenuItem.new({ item: "Separator" }),
|
||||||
await MenuItemExit("退出", beforExit)
|
await MenuItemExit("退出", beforExit)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function MenuItemReconnect(text: string, handleReconnect: Function) {
|
||||||
|
return await MenuItem.new({
|
||||||
|
id: "reconnect",
|
||||||
|
text,
|
||||||
|
action: async () => {
|
||||||
|
await handleReconnect();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export async function MenuItemExit(text: string, beforExit: Function) {
|
export async function MenuItemExit(text: string, beforExit: Function) {
|
||||||
return await MenuItem.new({
|
return await MenuItem.new({
|
||||||
id: "quit",
|
id: "quit",
|
||||||
@@ -76,12 +87,12 @@ export async function MenuItemExit(text: string, beforExit: Function) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function MenuItemPublicPeers() {
|
export async function MenuItemPublicPeers(handleNodesList: Function) {
|
||||||
return await MenuItem.new({
|
return await MenuItem.new({
|
||||||
id: "publicPeers",
|
id: "publicPeers",
|
||||||
text: "公共节点",
|
text: "公共节点",
|
||||||
action: async () => {
|
action: async () => {
|
||||||
await open(import.meta.env.VITE_PUBLIC_PEERS_URL);
|
await handleNodesList();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { type UnlistenFn } from "@tauri-apps/api/event";
|
import { type UnlistenFn } from "@tauri-apps/api/event";
|
||||||
import { getCurrentWindow, PhysicalPosition, type WindowOptions, Window, currentMonitor } from "@tauri-apps/api/window";
|
import { getCurrentWindow, PhysicalPosition, type WindowOptions, Window, currentMonitor, PhysicalSize } from "@tauri-apps/api/window";
|
||||||
import { WebviewWindow } from "@tauri-apps/api/webviewWindow";
|
import { WebviewWindow } from "@tauri-apps/api/webviewWindow";
|
||||||
import type { WebviewLabel, WebviewOptions } from "@tauri-apps/api/webview";
|
import type { WebviewLabel, WebviewOptions } from "@tauri-apps/api/webview";
|
||||||
import useMainStore from "@/stores/index";
|
import useMainStore from "@/stores/index";
|
||||||
@@ -44,18 +44,21 @@ export default async (
|
|||||||
defaultOpts.parent = appWindow;
|
defaultOpts.parent = appWindow;
|
||||||
// console.error(logicalPosition);
|
// console.error(logicalPosition);
|
||||||
if (defaultOpts.x == 0 && defaultOpts.y == 0) {
|
if (defaultOpts.x == 0 && defaultOpts.y == 0) {
|
||||||
const appSize = await appWindow.outerSize();
|
const logicalAppSize = {
|
||||||
|
width: 340,
|
||||||
|
height: 305
|
||||||
|
}
|
||||||
const factor = await appWindow.scaleFactor();
|
const factor = await appWindow.scaleFactor();
|
||||||
const appPosition = await appWindow.outerPosition();
|
const appPosition = await appWindow.outerPosition();
|
||||||
const logicalPosition = new PhysicalPosition(appPosition.x + appSize.width, appPosition.y).toLogical(factor);
|
const logicalPosition = new PhysicalPosition(appPosition.x + Math.ceil((logicalAppSize.width + 5) * factor), appPosition.y).toLogical(factor);
|
||||||
defaultOpts.x = logicalPosition.x;
|
defaultOpts.x = logicalPosition.x;
|
||||||
defaultOpts.y = logicalPosition.y;
|
defaultOpts.y = logicalPosition.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dialog = new WebviewWindow(label, { ...defaultOpts, ...options });
|
dialog = new WebviewWindow(label, { ...defaultOpts, ...options });
|
||||||
await dealCloseListener(dialog, label, beforeCloseFunc);
|
await dealCloseListener(dialog, label, beforeCloseFunc);
|
||||||
afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow));
|
|
||||||
await dialog.show();
|
await dialog.show();
|
||||||
|
afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow));
|
||||||
} else {
|
} else {
|
||||||
const visible = await dialog.isVisible();
|
const visible = await dialog.isVisible();
|
||||||
if (visible) {
|
if (visible) {
|
||||||
@@ -63,8 +66,8 @@ export default async (
|
|||||||
} else {
|
} else {
|
||||||
const appWindow = getCurrentWindow();
|
const appWindow = getCurrentWindow();
|
||||||
await dealCloseListener(dialog, label, beforeCloseFunc);
|
await dealCloseListener(dialog, label, beforeCloseFunc);
|
||||||
afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow));
|
|
||||||
await dialog.show();
|
await dialog.show();
|
||||||
|
afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+2
-1
@@ -6,7 +6,8 @@
|
|||||||
//屏蔽右键菜单
|
//屏蔽右键菜单
|
||||||
document.addEventListener("contextmenu", (e: MouseEvent) => {
|
document.addEventListener("contextmenu", (e: MouseEvent) => {
|
||||||
const el = (e.target as HTMLElement);
|
const el = (e.target as HTMLElement);
|
||||||
if (import.meta.env.PROD && !el.classList.contains("el-input__inner") && !el.classList.contains("el-textarea__inner")) { // 所有输入框不禁用右键
|
if (import.meta.env.PROD && !el.classList.contains("el-input__inner") && !el.classList.contains("el-textarea__inner")
|
||||||
|
&& !el.classList.contains("allow-contextmenu")) { // 所有输入框不禁用右键
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+30
-24
@@ -3,7 +3,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"author": "leizi97",
|
"author": "leizi97",
|
||||||
"description": "A simple network initiator based on Easytier",
|
"description": "A simple network initiator based on Easytier",
|
||||||
"version": "1.4.6",
|
"version": "1.5.3",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0",
|
"dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0",
|
||||||
"build": "nuxt generate --dotenv env/.env.prod",
|
"build": "nuxt generate --dotenv env/.env.prod",
|
||||||
@@ -11,31 +11,37 @@
|
|||||||
"release-win7": "node zip.js win7"
|
"release-win7": "node zip.js win7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@element-plus/icons-vue": "^2.3.1",
|
"@element-plus/icons-vue": "2.3.2",
|
||||||
"@element-plus/nuxt": "1.1.2",
|
"@element-plus/nuxt": "1.1.4",
|
||||||
"@nuxtjs/tailwindcss": "6.13.2",
|
"@nuxtjs/tailwindcss": "6.13.2",
|
||||||
"@pinia/nuxt": "0.11.0",
|
"@oxc-minify/binding-win32-x64-msvc": "^0.107.0",
|
||||||
"@tauri-apps/api": "2.5.0",
|
"@oxc-parser/binding-win32-x64-msvc": "^0.107.0",
|
||||||
"@tauri-apps/cli": "2.5.0",
|
"@oxc-transform/binding-win32-x64-msvc": "^0.107.0",
|
||||||
"@tauri-apps/plugin-cli": "^2.2.0",
|
"@pinia/nuxt": "0.11.2",
|
||||||
"@tauri-apps/plugin-clipboard-manager": "2.2.2",
|
"@tauri-apps/api": "2.9.1",
|
||||||
"@tauri-apps/plugin-dialog": "2.2.2",
|
"@tauri-apps/cli": "2.9.6",
|
||||||
"@tauri-apps/plugin-fs": "2.3.0",
|
"@tauri-apps/plugin-cli": "2.4.1",
|
||||||
"@tauri-apps/plugin-log": "2.4.0",
|
"@tauri-apps/plugin-clipboard-manager": "2.3.2",
|
||||||
"@tauri-apps/plugin-shell": "2.2.1",
|
"@tauri-apps/plugin-dialog": "2.4.2",
|
||||||
"@tauri-apps/plugin-window-state": "2.2.2",
|
"@tauri-apps/plugin-fs": "2.4.4",
|
||||||
"@types/lodash-es": "^4.17.12",
|
"@tauri-apps/plugin-log": "2.7.1",
|
||||||
"@vitejs/plugin-vue-jsx": "4.1.2",
|
"@tauri-apps/plugin-shell": "2.3.3",
|
||||||
|
"@tauri-apps/plugin-window-state": "2.4.1",
|
||||||
|
"@types/lodash-es": "4.17.12",
|
||||||
|
"@vitejs/plugin-vue-jsx": "5.1.1",
|
||||||
"@vueuse/core": "12.7.0",
|
"@vueuse/core": "12.7.0",
|
||||||
"archiver": "^7.0.1",
|
"archiver": "7.0.1",
|
||||||
"element-plus": "2.9.11",
|
"element-plus": "2.13.0",
|
||||||
"less": "4.2.1",
|
"less": "4.2.1",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "4.17.21",
|
||||||
"nuxt": "3.17.4",
|
"nuxt": "3.20.2",
|
||||||
"pinia": "3.0.2",
|
"pinia": "3.0.4",
|
||||||
"pinia-plugin-persistedstate": "4.3.0",
|
"pinia-plugin-persistedstate": "4.7.1",
|
||||||
"postcss": "^8.4.38",
|
"postcss": "8.4.49",
|
||||||
"prettier": "3.5.2",
|
"prettier": "3.7.4",
|
||||||
"prettier-plugin-tailwindcss": "0.6.11"
|
"prettier-plugin-tailwindcss": "0.7.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"is-ip": "^5.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+58
-4
@@ -44,19 +44,43 @@
|
|||||||
</ElTooltip>
|
</ElTooltip>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-nowrap items-center gap-[5px]">
|
<div class="flex flex-nowrap items-center gap-[5px]">
|
||||||
<ElCheckbox v-model="mainStore.config.enableKcpProxy">启用KCP代理</ElCheckbox>
|
<ElCheckbox
|
||||||
<ElTooltip content="将TCP流量转为KCP流量,降低传输延迟,提升传输速度">
|
@change="handleKcpProxyChange"
|
||||||
|
v-model="mainStore.config.enableKcpProxy"
|
||||||
|
>
|
||||||
|
启用KCP代理
|
||||||
|
</ElCheckbox>
|
||||||
|
<ElTooltip content="(不可与QUIC代理同时开启)将TCP流量转为KCP流量,降低传输延迟,提升传输速度">
|
||||||
<ElIcon><QuestionFilled /></ElIcon>
|
<ElIcon><QuestionFilled /></ElIcon>
|
||||||
</ElTooltip>
|
</ElTooltip>
|
||||||
<CoreVersionWarning version="2.2.0" />
|
<CoreVersionWarning version="2.2.0" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-nowrap items-center gap-[5px]">
|
<div class="flex flex-nowrap items-center gap-[5px]">
|
||||||
<ElCheckbox v-model="mainStore.config.disableKcpInput">禁用KCP输入</ElCheckbox>
|
<ElCheckbox v-model="mainStore.config.disableKcpInput">禁用KCP输入</ElCheckbox>
|
||||||
<ElTooltip content="禁用KCP入站流量,其他开启KCP代理的节点无法连接到本节点">
|
<ElTooltip content="不允许其他节点使用 KCP 代理 TCP 流到此节点。开启 KCP 代理的节点访问此节点时,依然使用原始 TCP 连接">
|
||||||
<ElIcon><QuestionFilled /></ElIcon>
|
<ElIcon><QuestionFilled /></ElIcon>
|
||||||
</ElTooltip>
|
</ElTooltip>
|
||||||
<CoreVersionWarning version="2.2.0" />
|
<CoreVersionWarning version="2.2.0" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex flex-nowrap items-center gap-[5px]">
|
||||||
|
<ElCheckbox
|
||||||
|
@change="handleQuicProxyChange"
|
||||||
|
v-model="mainStore.config.enableQuicProxy"
|
||||||
|
>
|
||||||
|
启用QUIC代理
|
||||||
|
</ElCheckbox>
|
||||||
|
<ElTooltip content="(不可与KCP代理同时开启)使用 QUIC 代理 TCP 流,提高在 UDP 丢包网络上的延迟和吞吐量">
|
||||||
|
<ElIcon><QuestionFilled /></ElIcon>
|
||||||
|
</ElTooltip>
|
||||||
|
<CoreVersionWarning version="2.3.2" />
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-nowrap items-center gap-[5px]">
|
||||||
|
<ElCheckbox v-model="mainStore.config.disableQuicInput">禁用QUIC输入</ElCheckbox>
|
||||||
|
<ElTooltip content="不允许其他节点使用 QUIC 代理 TCP 流到此节点。开启 QUIC 代理的节点访问此节点时,依然使用原始 TCP 连接">
|
||||||
|
<ElIcon><QuestionFilled /></ElIcon>
|
||||||
|
</ElTooltip>
|
||||||
|
<CoreVersionWarning version="2.3.2" />
|
||||||
|
</div>
|
||||||
<div><ElCheckbox v-model="mainStore.config.disableUdpHolePunching">禁用UDP打洞功能</ElCheckbox></div>
|
<div><ElCheckbox v-model="mainStore.config.disableUdpHolePunching">禁用UDP打洞功能</ElCheckbox></div>
|
||||||
<div><ElCheckbox v-model="mainStore.config.disableIpv6">不使用IPv6</ElCheckbox></div>
|
<div><ElCheckbox v-model="mainStore.config.disableIpv6">不使用IPv6</ElCheckbox></div>
|
||||||
<div class="flex flex-nowrap items-center gap-[5px]">
|
<div class="flex flex-nowrap items-center gap-[5px]">
|
||||||
@@ -74,6 +98,16 @@
|
|||||||
<CoreVersionWarning version="2.3.1" />
|
<CoreVersionWarning version="2.3.1" />
|
||||||
</div>
|
</div>
|
||||||
<ElDivider />
|
<ElDivider />
|
||||||
|
<div class="flex w-full flex-nowrap items-center gap-[5px] mb-[3px]">
|
||||||
|
<ElCheckbox v-model="mainStore.config.tcpWhitelistEnable">TCP端口白名单</ElCheckbox>
|
||||||
|
<ElInput class="flex-1" v-model="mainStore.config.tcpWhitelist" placeholder="支持单个端口(80)和范围(8000-9000)" />
|
||||||
|
<CoreVersionWarning version="2.4.2" />
|
||||||
|
</div>
|
||||||
|
<div class="flex w-full flex-nowrap items-center gap-[5px]">
|
||||||
|
<ElCheckbox v-model="mainStore.config.udpWhitelistEnable">UDP端口白名单</ElCheckbox>
|
||||||
|
<ElInput class="flex-1" v-model="mainStore.config.udpWhitelist" placeholder="支持单个端口(53)和范围(5000-6000)" />
|
||||||
|
<CoreVersionWarning version="2.4.2" />
|
||||||
|
</div>
|
||||||
<div class="flex items-center gap-[10px]">
|
<div class="flex items-center gap-[10px]">
|
||||||
<ElCheckbox v-model="mainStore.config.disbleListenner">不监听任何端口,只连接到对等节点</ElCheckbox>
|
<ElCheckbox v-model="mainStore.config.disbleListenner">不监听任何端口,只连接到对等节点</ElCheckbox>
|
||||||
<ElTooltip content="无法联机时,可以尝试开启这个选项">
|
<ElTooltip content="无法联机时,可以尝试开启这个选项">
|
||||||
@@ -153,7 +187,9 @@
|
|||||||
配置
|
配置
|
||||||
</ElButton>
|
</ElButton>
|
||||||
</ElTooltip>
|
</ElTooltip>
|
||||||
<ElTooltip content="将本地端口转发到虚拟网络中的远程端口.如:udp://0.0.0.0:12345/10.126.126.1:23456,表示将本地UDP端口12345转发到虚拟网络中的10.126.126.1:23456.可以指定多个">
|
<ElTooltip
|
||||||
|
content="将本地端口转发到虚拟网络中的远程端口.如:udp://0.0.0.0:12345/10.126.126.1:23456,表示将本地UDP端口12345转发到虚拟网络中的10.126.126.1:23456.可以指定多个"
|
||||||
|
>
|
||||||
<ElIcon><QuestionFilled /></ElIcon>
|
<ElIcon><QuestionFilled /></ElIcon>
|
||||||
</ElTooltip>
|
</ElTooltip>
|
||||||
<CoreVersionWarning version="2.3.0" />
|
<CoreVersionWarning version="2.3.0" />
|
||||||
@@ -386,6 +422,24 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleKcpProxyChange = () => {
|
||||||
|
if (mainStore.config.enableKcpProxy) {
|
||||||
|
if (mainStore.config.enableQuicProxy) {
|
||||||
|
ElMessage.warning("KCP代理和QUIC代理不能同时开启");
|
||||||
|
}
|
||||||
|
mainStore.config.enableQuicProxy = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleQuicProxyChange = () => {
|
||||||
|
if (mainStore.config.enableQuicProxy) {
|
||||||
|
if (mainStore.config.enableKcpProxy) {
|
||||||
|
ElMessage.warning("KCP代理和QUIC代理不能同时开启");
|
||||||
|
}
|
||||||
|
mainStore.config.enableKcpProxy = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 为bind_device功能增加改方法
|
// 为bind_device功能增加改方法
|
||||||
const getGuids = async () => {
|
const getGuids = async () => {
|
||||||
const guidsValue = await invoke<string[][]>("get_network_adapter_guids");
|
const guidsValue = await invoke<string[][]>("get_network_adapter_guids");
|
||||||
|
|||||||
+2
-11
@@ -69,7 +69,7 @@
|
|||||||
data.isRunning = true;
|
data.isRunning = true;
|
||||||
const [error, member] = await ATJ(invoke<string>("get_route_by_cli"));
|
const [error, member] = await ATJ(invoke<string>("get_route_by_cli"));
|
||||||
data.isRunning = false;
|
data.isRunning = false;
|
||||||
// if(!member) return;
|
if(!member) return;
|
||||||
if (error) {
|
if (error) {
|
||||||
data.route = [];
|
data.route = [];
|
||||||
return "";
|
return "";
|
||||||
@@ -79,16 +79,7 @@
|
|||||||
await listenOutput();
|
await listenOutput();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const routeInfo = parseCliInfo(member);
|
data.route = JSON.parse(member);
|
||||||
routeInfo.forEach(value => {
|
|
||||||
if (value.cost === "Local") {
|
|
||||||
value.cost = "本机";
|
|
||||||
}
|
|
||||||
if (value.ipv4 && value.ipv4.includes("/")) {
|
|
||||||
value.ipv4 = value.ipv4.split("/")[0];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
data.route = routeInfo;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const listenStart = async () => {
|
const listenStart = async () => {
|
||||||
|
|||||||
+401
-160
@@ -45,7 +45,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<ElTooltip content="请先停止自建服务和联机后再使用,否则内核被占用的情况下,无法进行内核更换">
|
<ElTooltip content="请先停止自建服务和联机后再使用,否则内核被占用的情况下,无法进行内核更换">
|
||||||
<ElBadge
|
<ElBadge
|
||||||
badge-class="!text-[9px] cursor-pointer"
|
badge-class="!text-[9px] cursor-pointer ml-auto"
|
||||||
:hidden="!haveNewCoreVersion"
|
:hidden="!haveNewCoreVersion"
|
||||||
:offset="[-5, 6]"
|
:offset="[-5, 6]"
|
||||||
@click.stop="handleCoreManagement"
|
@click.stop="handleCoreManagement"
|
||||||
@@ -67,7 +67,11 @@
|
|||||||
</template>
|
</template>
|
||||||
<ElSelect
|
<ElSelect
|
||||||
allow-create
|
allow-create
|
||||||
|
:reserve-keyword="false"
|
||||||
filterable
|
filterable
|
||||||
|
multiple
|
||||||
|
collapse-tags
|
||||||
|
collapse-tags-tooltip
|
||||||
placeholder="请选择服务器地址"
|
placeholder="请选择服务器地址"
|
||||||
default-first-option
|
default-first-option
|
||||||
v-model="mainStore.config.serverUrl"
|
v-model="mainStore.config.serverUrl"
|
||||||
@@ -75,14 +79,13 @@
|
|||||||
@change="handleServerUrlChange"
|
@change="handleServerUrlChange"
|
||||||
>
|
>
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<div :class="mainStore.config.protocol && mainStore.config.protocol.length > 1 ? 'w-[120px]' : 'w-[80px]'">
|
<div :class="mainStore.config.protocol && mainStore.config.protocol.length > 1 ? 'w-[110px]' : 'w-[80px]'">
|
||||||
<ElSelect
|
<ElSelect
|
||||||
placeholder="协议"
|
placeholder="协议"
|
||||||
multiple
|
multiple
|
||||||
collapse-tags
|
collapse-tags
|
||||||
@click.stop
|
@click.stop
|
||||||
v-model="mainStore.config.protocol"
|
v-model="mainStore.config.protocol"
|
||||||
@change="handleServerUrlChange"
|
|
||||||
>
|
>
|
||||||
<ElOption
|
<ElOption
|
||||||
v-for="item in protocols"
|
v-for="item in protocols"
|
||||||
@@ -99,7 +102,7 @@
|
|||||||
type="primary"
|
type="primary"
|
||||||
size="small"
|
size="small"
|
||||||
underline="never"
|
underline="never"
|
||||||
@click.stop="open(publicPeersLink)"
|
@click.stop="handleShowPublicServersDialog"
|
||||||
>
|
>
|
||||||
其他公共服务器
|
其他公共服务器
|
||||||
</ElLink>
|
</ElLink>
|
||||||
@@ -206,23 +209,40 @@
|
|||||||
label="局域网IP"
|
label="局域网IP"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
<div class="flex h-[20px] items-center gap-[3px]">
|
<div class="flex h-[22px] items-center gap-[3px]">
|
||||||
虚拟网IP
|
<div class="mr-[8px]">IP</div>
|
||||||
|
<ElSwitch
|
||||||
|
v-model="mainStore.config.dhcp"
|
||||||
|
inline-prompt
|
||||||
|
inactive-text="固定V4"
|
||||||
|
active-text="动态V4"
|
||||||
|
size="small"
|
||||||
|
></ElSwitch>
|
||||||
|
<ElTooltip>
|
||||||
|
<template #content>
|
||||||
|
<div>选填V6地址,可与IPv4一起使用以进行双栈操作</div>
|
||||||
|
<div>----------------------------------------</div>
|
||||||
|
<div>当前V6地址: {{ mainStore.config.ipv6 || "-" }}</div>
|
||||||
|
</template>
|
||||||
|
<ElButton
|
||||||
|
text
|
||||||
|
size="small"
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click="handleDealIpv6"
|
||||||
|
:type="mainStore.config.ipv6 ? 'success' : 'info'"
|
||||||
|
>
|
||||||
|
V6
|
||||||
|
</ElButton>
|
||||||
|
</ElTooltip>
|
||||||
|
<ElDivider direction="vertical" />
|
||||||
<ElButton
|
<ElButton
|
||||||
@click.stop="handleCopyIp"
|
@click.stop="handleCopyIp"
|
||||||
type="primary"
|
type="primary"
|
||||||
text
|
text
|
||||||
size="small"
|
size="small"
|
||||||
title="复制IP"
|
title="复制V4"
|
||||||
:icon="CopyDocument"
|
:icon="CopyDocument"
|
||||||
></ElButton>
|
></ElButton>
|
||||||
<ElSwitch
|
|
||||||
v-model="mainStore.config.dhcp"
|
|
||||||
inline-prompt
|
|
||||||
inactive-text="固定IP"
|
|
||||||
active-text="动态获取"
|
|
||||||
size="small"
|
|
||||||
></ElSwitch>
|
|
||||||
<!-- <ElTooltip content="对应命令行参数 --ipv4">
|
<!-- <ElTooltip content="对应命令行参数 --ipv4">
|
||||||
<ElIcon><QuestionFilled /></ElIcon>
|
<ElIcon><QuestionFilled /></ElIcon>
|
||||||
</ElTooltip> -->
|
</ElTooltip> -->
|
||||||
@@ -272,21 +292,6 @@
|
|||||||
{{ !data.isStart ? "启动联机" : "停止联机" }}
|
{{ !data.isStart ? "启动联机" : "停止联机" }}
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<ElDropdownMenu>
|
<ElDropdownMenu>
|
||||||
<ElDropdownItem
|
|
||||||
command="import_config"
|
|
||||||
:icon="Link"
|
|
||||||
>
|
|
||||||
导入联机配置
|
|
||||||
</ElDropdownItem>
|
|
||||||
<ElDropdownItem
|
|
||||||
command="share_config"
|
|
||||||
:icon="Share"
|
|
||||||
>
|
|
||||||
分享联机配置
|
|
||||||
</ElDropdownItem>
|
|
||||||
<ElDropdownItem disabled>
|
|
||||||
<ElDivider class="!m-0 !h-[2px]" />
|
|
||||||
</ElDropdownItem>
|
|
||||||
<ElDropdownItem
|
<ElDropdownItem
|
||||||
:icon="SetUp"
|
:icon="SetUp"
|
||||||
command="create_server"
|
command="create_server"
|
||||||
@@ -328,6 +333,33 @@
|
|||||||
>
|
>
|
||||||
本地游戏列表
|
本地游戏列表
|
||||||
</ElDropdownItem>
|
</ElDropdownItem>
|
||||||
|
<ElDropdownItem disabled>
|
||||||
|
<ElDivider class="!m-0 !h-[2px]" />
|
||||||
|
</ElDropdownItem>
|
||||||
|
<ElDropdownItem
|
||||||
|
command="cidr"
|
||||||
|
:icon="Share"
|
||||||
|
>
|
||||||
|
子网代理
|
||||||
|
</ElDropdownItem>
|
||||||
|
<!-- <ElDropdownItem
|
||||||
|
command="import_config"
|
||||||
|
:icon="Link"
|
||||||
|
>
|
||||||
|
导入联机配置
|
||||||
|
</ElDropdownItem>
|
||||||
|
<ElDropdownItem
|
||||||
|
command="share_config"
|
||||||
|
:icon="Share"
|
||||||
|
>
|
||||||
|
分享联机配置
|
||||||
|
</ElDropdownItem> -->
|
||||||
|
<ElDropdownItem
|
||||||
|
command="reconnect"
|
||||||
|
:icon="RefreshRight"
|
||||||
|
>
|
||||||
|
重新联机
|
||||||
|
</ElDropdownItem>
|
||||||
</ElDropdownMenu>
|
</ElDropdownMenu>
|
||||||
</template>
|
</template>
|
||||||
</ElDropdown>
|
</ElDropdown>
|
||||||
@@ -380,21 +412,32 @@
|
|||||||
开机自启
|
开机自启
|
||||||
</ElCheckbox>
|
</ElCheckbox>
|
||||||
</ElTooltip>
|
</ElTooltip>
|
||||||
<div>
|
<div class="flex items-center gap-[0_2px]">
|
||||||
<ElButton
|
<ElDropdown
|
||||||
@click="handleShowCidrDialog"
|
@command="handleStartCommand"
|
||||||
:icon="Share"
|
trigger="click"
|
||||||
size="small"
|
:show-arrow="false"
|
||||||
>
|
>
|
||||||
子网代理
|
<ElButton
|
||||||
</ElButton>
|
:icon="Share"
|
||||||
<ElButton
|
size="small"
|
||||||
@click="handleShowAdvanceDialog"
|
>
|
||||||
:icon="Setting"
|
分享/导入
|
||||||
size="small"
|
</ElButton>
|
||||||
>
|
<template #dropdown>
|
||||||
高级选项
|
<el-dropdown-item command="share_config">分享联机配置</el-dropdown-item>
|
||||||
</ElButton>
|
<el-dropdown-item command="import_config">导入联机配置</el-dropdown-item>
|
||||||
|
</template>
|
||||||
|
</ElDropdown>
|
||||||
|
<div>
|
||||||
|
<ElButton
|
||||||
|
@click="handleShowAdvanceDialog"
|
||||||
|
:icon="Setting"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
高级选项
|
||||||
|
</ElButton>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-[0_5px]">
|
<div class="flex items-center gap-[0_5px]">
|
||||||
<div>
|
<div>
|
||||||
@@ -692,6 +735,35 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</ElDialog>
|
</ElDialog>
|
||||||
|
<ElDialog
|
||||||
|
width="95%"
|
||||||
|
top="30px"
|
||||||
|
append-to-body
|
||||||
|
:z-index="10"
|
||||||
|
class="!mb-0"
|
||||||
|
title="IPV6地址填写"
|
||||||
|
:close-on-press-escape="false"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:show-close="false"
|
||||||
|
v-model="ipv6InputDialog.visible"
|
||||||
|
>
|
||||||
|
<ElInput
|
||||||
|
v-model="mainStore.config.ipv6"
|
||||||
|
clearable
|
||||||
|
placeholder="请输入IPV6地址"
|
||||||
|
></ElInput>
|
||||||
|
<template #footer>
|
||||||
|
<div class="text-right">
|
||||||
|
<ElButton
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
@click="handleValidateIpv6"
|
||||||
|
>
|
||||||
|
确定
|
||||||
|
</ElButton>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</ElDialog>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
@@ -720,7 +792,7 @@
|
|||||||
import { initStartWinIpBroadcast } from "~/composables/netcard";
|
import { initStartWinIpBroadcast } from "~/composables/netcard";
|
||||||
import useMainStore from "@/stores/index";
|
import useMainStore from "@/stores/index";
|
||||||
import { ElMessage, ElMessageBox, ElTooltip } from "element-plus";
|
import { ElMessage, ElMessageBox, ElTooltip } from "element-plus";
|
||||||
import { getCurrentWindow, type Window } from "@tauri-apps/api/window";
|
import { getCurrentWindow, PhysicalSize, type Window } from "@tauri-apps/api/window";
|
||||||
import { getAllWebviewWindows, WebviewWindow } from "@tauri-apps/api/webviewWindow";
|
import { getAllWebviewWindows, WebviewWindow } from "@tauri-apps/api/webviewWindow";
|
||||||
import etWindows, { dataSubscribe } from "@/composables/windows";
|
import etWindows, { dataSubscribe } from "@/composables/windows";
|
||||||
import { resourceDir as getResourceDir, join } from "@tauri-apps/api/path";
|
import { resourceDir as getResourceDir, join } from "@tauri-apps/api/path";
|
||||||
@@ -728,9 +800,10 @@
|
|||||||
import { updateConfigJson, updateConfigJsonBounce } from "~/composables/configJson";
|
import { updateConfigJson, updateConfigJsonBounce } from "~/composables/configJson";
|
||||||
import { writeText, readText } from "@tauri-apps/plugin-clipboard-manager";
|
import { writeText, readText } from "@tauri-apps/plugin-clipboard-manager";
|
||||||
import { sortedUniq, uniq } from "lodash-es";
|
import { sortedUniq, uniq } from "lodash-es";
|
||||||
import { addQQGroup, supportProtocols, preventSleep, stopPreventSleep, ATJ, copyText, isValidWindowsFileName } from "~/utils";
|
import { addQQGroup, supportProtocols, preventSleep, stopPreventSleep, ATJ, copyText, isValidWindowsFileName, mixedArray } from "~/utils";
|
||||||
import { ElConfirmDanger, ElConfirmPrimary } from "~/utils/element";
|
import { ElConfirmDanger, ElConfirmPrimary } from "~/utils/element";
|
||||||
import { getServerArgs } from "@/composables/server";
|
import { getServerArgs } from "@/composables/server";
|
||||||
|
import { isIPv6 } from "is-ip";
|
||||||
|
|
||||||
let is_close = false;
|
let is_close = false;
|
||||||
const publicPeersLink = import.meta.env.VITE_PUBLIC_PEERS_URL;
|
const publicPeersLink = import.meta.env.VITE_PUBLIC_PEERS_URL;
|
||||||
@@ -746,6 +819,12 @@
|
|||||||
async () => {
|
async () => {
|
||||||
await handleConnection();
|
await handleConnection();
|
||||||
return data.isStart;
|
return data.isStart;
|
||||||
|
},
|
||||||
|
async () => {
|
||||||
|
await handleReconnect();
|
||||||
|
},
|
||||||
|
async () => {
|
||||||
|
await handleShowPublicServersDialog();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -759,6 +838,7 @@
|
|||||||
advanceVisible: false,
|
advanceVisible: false,
|
||||||
toolVisible: false,
|
toolVisible: false,
|
||||||
gameListVisible: false,
|
gameListVisible: false,
|
||||||
|
nodesListVisible: false,
|
||||||
serverVisible: false,
|
serverVisible: false,
|
||||||
winipBcPid: 0, //WinIPBroadcast进程id
|
winipBcPid: 0, //WinIPBroadcast进程id
|
||||||
winipBcStart: false,
|
winipBcStart: false,
|
||||||
@@ -772,7 +852,7 @@
|
|||||||
startLoading: false,
|
startLoading: false,
|
||||||
isStart: false,
|
isStart: false,
|
||||||
connectionSuccess: false,
|
connectionSuccess: false,
|
||||||
configJsonSeverUrl: "" // 本地保存一次,用于回填config.json
|
configJsonSeverUrl: [] // 本地保存一次,用于回填config.json
|
||||||
});
|
});
|
||||||
|
|
||||||
const configStart = reactive<{ list: Array<{ path: string; name: string }>; [key: string]: any }>({
|
const configStart = reactive<{ list: Array<{ path: string; name: string }>; [key: string]: any }>({
|
||||||
@@ -814,12 +894,54 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ipv6InputDialog = reactive<{ visible: boolean; [key: string]: any }>({
|
||||||
|
visible: false
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleDealIpv6 = async () => {
|
||||||
|
ipv6InputDialog.visible = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleValidateIpv6 = () => {
|
||||||
|
mainStore.config.ipv6 = mainStore.config.ipv6?.trim() || "";
|
||||||
|
if (mainStore.config.ipv6 && !isIPv6(mainStore.config.ipv6)) {
|
||||||
|
ElMessage.error("请输入正确的IPV6地址");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ipv6InputDialog.visible = false;
|
||||||
|
};
|
||||||
|
|
||||||
const handleCopyIp = async () => {
|
const handleCopyIp = async () => {
|
||||||
if (!mainStore.config.ipv4?.trim()) return;
|
const v6 = mainStore.config.ipv6?.trim();
|
||||||
if (data.isStart || !mainStore.config.dhcp) {
|
const v4 = mainStore.config.ipv4?.trim();
|
||||||
await copyText(mainStore.config.ipv4);
|
if (v6) {
|
||||||
|
const [err] = await ElConfirmPrimary("检测到您填写了IPV6地址,是否复制IPV6地址?", "提示", {
|
||||||
|
confirmButtonText: "复制IPV6",
|
||||||
|
cancelButtonText: "复制IPV4"
|
||||||
|
});
|
||||||
|
if (!err) {
|
||||||
|
await copyText(v6);
|
||||||
|
} else {
|
||||||
|
if (!v4) {
|
||||||
|
ElMessage.error("没有IPV4地址,无法复制");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (data.isStart || !mainStore.config.dhcp) {
|
||||||
|
await copyText(v4);
|
||||||
|
} else {
|
||||||
|
await copyText(v4, "复制成功,联机后IP可能会变化");
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
await copyText(mainStore.config.ipv4, "复制成功,联机后IP可能会变化");
|
if (!v4) {
|
||||||
|
ElMessage.error("没有IPV4地址,无法复制");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (data.isStart || !mainStore.config.dhcp) {
|
||||||
|
await copyText(v4);
|
||||||
|
} else {
|
||||||
|
await copyText(v4, "复制成功,联机后IP可能会变化");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -841,32 +963,43 @@
|
|||||||
const newBasePeers = [...mainStore.basePeers];
|
const newBasePeers = [...mainStore.basePeers];
|
||||||
const idx = newBasePeers.indexOf(url);
|
const idx = newBasePeers.indexOf(url);
|
||||||
if (idx >= 0) {
|
if (idx >= 0) {
|
||||||
if (mainStore.config.serverUrl === url) {
|
const selectIdx = mainStore.config.serverUrl.indexOf(url);
|
||||||
mainStore.config.serverUrl = "";
|
if (selectIdx >= 0) {
|
||||||
|
mainStore.config.serverUrl.splice(selectIdx, 1);
|
||||||
}
|
}
|
||||||
newBasePeers.splice(idx, 1);
|
newBasePeers.splice(idx, 1);
|
||||||
}
|
}
|
||||||
mainStore.basePeers = uniq([...newBasePeers]);
|
mainStore.basePeers = uniq([...newBasePeers]);
|
||||||
if (mainStore.basePeers.length > 0) {
|
if (mainStore.basePeers.length > 0 && mainStore.config.serverUrl.length <= 0) {
|
||||||
mainStore.config.serverUrl = mainStore.basePeers[0];
|
mainStore.config.serverUrl = [mainStore.basePeers[0]];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleServerUrlChange = () => {
|
const handleServerUrlChange = () => {
|
||||||
let inputProtocols: string | null = null;
|
let inputProtocols: string[] = [];
|
||||||
|
// console.log(mainStore.config.serverUrl);
|
||||||
for (const p of protocols) {
|
for (const p of protocols) {
|
||||||
if (mainStore.config.serverUrl.toLowerCase().startsWith(`${p}://`)) {
|
for (const url of mainStore.config.serverUrl) {
|
||||||
inputProtocols = p;
|
if (url.replace(/\\/g, "/").toLowerCase().startsWith(`${p}://`)) {
|
||||||
break;
|
inputProtocols.push(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (inputProtocols) {
|
if (inputProtocols) {
|
||||||
mainStore.config.protocol = [inputProtocols];
|
mainStore.config.protocol = uniq([...mainStore.config.protocol, ...inputProtocols]);
|
||||||
mainStore.config.serverUrl = mainStore.config.serverUrl.slice(inputProtocols.length + 3);
|
mainStore.config.serverUrl = (mainStore.config.serverUrl || []).map(url => {
|
||||||
|
for (const p of protocols) {
|
||||||
|
if (url.replace(/\\/g, "/").toLowerCase().startsWith(`${p}://`)) {
|
||||||
|
return url.slice(p.length + 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
mainStore.basePeers = uniq([mainStore.config.serverUrl, ...mainStore.basePeers]);
|
mainStore.basePeers = uniq([...mainStore.config.serverUrl, ...mainStore.basePeers]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let getMemeberTimer: number | null = null;
|
||||||
const listenObj: { [key: string]: any } = {
|
const listenObj: { [key: string]: any } = {
|
||||||
unListenOutPut: null,
|
unListenOutPut: null,
|
||||||
unListenThreadId: null,
|
unListenThreadId: null,
|
||||||
@@ -877,31 +1010,34 @@
|
|||||||
server_thread_id: ref(null),
|
server_thread_id: ref(null),
|
||||||
async listenOutput() {
|
async listenOutput() {
|
||||||
// const appWindow = getCurrentWindow();
|
// const appWindow = getCurrentWindow();
|
||||||
const unListen = await listen<string>("command-output", async event => {
|
getMemeberTimer && clearInterval(getMemeberTimer);
|
||||||
data.isStart = true;
|
getMemeberTimer = setInterval(async () => {
|
||||||
// console.error(event.payload);
|
const [error, member] = await ATJ(invoke<string>("get_members_by_cli"));
|
||||||
if (event.payload) {
|
if(!data.isStart) {
|
||||||
data.startLoading = false;
|
getMemeberTimer && clearInterval(getMemeberTimer);
|
||||||
let ipv4 = /dhcp ip changed. old: None, new: Some\((\d+\.\d+\.\d+\.\d+).*\)/g.exec(event.payload as string)?.[1];
|
getMemeberTimer = null;
|
||||||
let devName = /tun device ready. dev: (.*)/g.exec(event.payload as string)?.[1];
|
ipReset();
|
||||||
if (mainStore.configStartEnable || mainStore.config.dhcp) {
|
return;
|
||||||
let configIpv4 = /ipv4\s.*=\s.*[\'\"](\d+\.\d+\.\d+\.\d+).*[\'\"]/g.exec(event.payload as string)?.[1];
|
}
|
||||||
if (configIpv4) {
|
if (!error && member !== "_EasytierGameCliFailedToConnect_") {
|
||||||
mainStore.config.ipv4 = configIpv4;
|
const memberJson = JSON.parse(member) as Member[];
|
||||||
}
|
const localData = memberJson.find(member => member?.cost == "Local");
|
||||||
}
|
const ipv4 = localData?.ipv4;
|
||||||
// if (event.payload.includes("peer connection removed")) {
|
if (localData && ipv4) {
|
||||||
// data.isSuccessGetIp = false;
|
mainStore.config.ipv4 = ipv4;
|
||||||
// }
|
|
||||||
if (event.payload.includes("new peer connection added") && !data.isSuccessGetIp) {
|
|
||||||
await setTrayRunState(tray, true);
|
await setTrayRunState(tray, true);
|
||||||
data.isSuccessGetIp = true;
|
data.isSuccessGetIp = true;
|
||||||
await setTrayTooltip(tray, `IP: ${mainStore.config.ipv4}`);
|
await setTrayTooltip(tray, `IP: ${mainStore.config.ipv4}`);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (ipv4) {
|
ipReset();
|
||||||
mainStore.config.ipv4 = ipv4;
|
}
|
||||||
await setTrayTooltip(tray, `IP: ${ipv4}`);
|
}, 1000);
|
||||||
}
|
const unListen = await listen<string>("command-output", async event => {
|
||||||
|
data.isStart = true;
|
||||||
|
if (event.payload) {
|
||||||
|
data.startLoading = false;
|
||||||
|
let devName = /tun device ready. dev: (.*)/g.exec(event.payload as string)?.[1];
|
||||||
if (
|
if (
|
||||||
devName &&
|
devName &&
|
||||||
mainStore.config.enableNetCardMetric &&
|
mainStore.config.enableNetCardMetric &&
|
||||||
@@ -928,7 +1064,10 @@
|
|||||||
data.log = logArr.slice(start).join("\n");
|
data.log = logArr.slice(start).join("\n");
|
||||||
data.log += (event.payload as string) + "\n";
|
data.log += (event.payload as string) + "\n";
|
||||||
});
|
});
|
||||||
this.unListenOutPut = unListen;
|
this.unListenOutPut = () => {
|
||||||
|
getMemeberTimer && clearInterval(getMemeberTimer);
|
||||||
|
unListen();
|
||||||
|
};
|
||||||
},
|
},
|
||||||
async listenThreadId() {
|
async listenThreadId() {
|
||||||
const unListen = await listen("thread-id", event => {
|
const unListen = await listen("thread-id", event => {
|
||||||
@@ -1036,6 +1175,27 @@
|
|||||||
// await getReleaseList();
|
// await getReleaseList();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleShowPublicServersDialog = async () => {
|
||||||
|
await etWindows(
|
||||||
|
"nodesList",
|
||||||
|
{
|
||||||
|
title: "公共服务器节点",
|
||||||
|
width: 1000,
|
||||||
|
height: 600,
|
||||||
|
minWidth: 800,
|
||||||
|
minHeight: 500,
|
||||||
|
resizable: true,
|
||||||
|
url: "#/nodesList"
|
||||||
|
},
|
||||||
|
(_, appWindow) => {
|
||||||
|
data.nodesListVisible = true;
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
data.nodesListVisible = false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
let unlistenDownload: UnlistenFn | null = null;
|
let unlistenDownload: UnlistenFn | null = null;
|
||||||
let unlistenDownloadError: UnlistenFn | null = null;
|
let unlistenDownloadError: UnlistenFn | null = null;
|
||||||
let progress = ref<number>(0);
|
let progress = ref<number>(0);
|
||||||
@@ -1085,8 +1245,8 @@
|
|||||||
const list = await invoke<string[][][]>("fetch_easytier_list");
|
const list = await invoke<string[][][]>("fetch_easytier_list");
|
||||||
data.releaseList = [
|
data.releaseList = [
|
||||||
...list.flat().filter(el => {
|
...list.flat().filter(el => {
|
||||||
// console.log(el, el[0], el[2]);
|
// console.log(el, el[0], el[2], el[3]); // el[3] 是prerelease bool值
|
||||||
return el && el[0] && el[2] && !el[2].includes("gui");
|
return el && el[0] && el[2] && !el[2].includes("gui") && (el[3] != "true" || !el[3]);
|
||||||
})
|
})
|
||||||
] as any;
|
] as any;
|
||||||
coreManagementData.loading = false;
|
coreManagementData.loading = false;
|
||||||
@@ -1119,25 +1279,23 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const compatibleIpv6Listener = async () => {
|
// const compatibleIpv6Listener = async () => {
|
||||||
// ipv6监听在后续版本合并到customListenner里了,这里做兼容处理
|
// // ipv6监听在后续版本合并到customListenner里了,这里做兼容处理,去掉IPV6监听
|
||||||
if (mainStore.config.enableCustomListenerV6 && mainStore.config.customListenerV6Data) {
|
// const customListenerV4 = mainStore.config.customListenerData
|
||||||
const customListener = mainStore.config.customListenerV6Data.trim();
|
// .trim()
|
||||||
if (customListener) {
|
// .split("\n")
|
||||||
const customListenerV4 = mainStore.config.customListenerData
|
// .map(el => el.trim())
|
||||||
.trim()
|
// .filter(el => el);
|
||||||
.split("\n")
|
// const udpv6 = customListenerV4.indexOf("udp://[::]:11010")
|
||||||
.map(el => el.trim())
|
// const tcpv6 = customListenerV4.indexOf("tcp://[::]:11010")
|
||||||
.filter(el => el);
|
// if (udpv6 != -1) {
|
||||||
if (!customListenerV4.includes(customListener)) {
|
// customListenerV4.splice(udpv6, 1);
|
||||||
mainStore.config.customListenerData += `\n${customListener}`;
|
// }
|
||||||
}
|
// if (tcpv6 != -1) {
|
||||||
}
|
// customListenerV4.splice(tcpv6, 1);
|
||||||
}
|
// }
|
||||||
if (mainStore.config.enableCustomListenerV6) {
|
// mainStore.config.customListenerData = customListenerV4.join("\n");
|
||||||
mainStore.config.enableCustomListenerV6 = false;
|
// };
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const initConnectAfterStart = async () => {
|
const initConnectAfterStart = async () => {
|
||||||
if (mainStore.config.connectAfterStart && data.coreVersion) {
|
if (mainStore.config.connectAfterStart && data.coreVersion) {
|
||||||
@@ -1146,6 +1304,13 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 多选serverUrl兼容
|
||||||
|
const compatibleInitServerUrl = async () => {
|
||||||
|
if (typeof mainStore.config.serverUrl == "string") {
|
||||||
|
mainStore.config.serverUrl = [mainStore.config.serverUrl || ""];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const initGuiJson = async () => {
|
const initGuiJson = async () => {
|
||||||
const path = import.meta.env.VITE_CONFIG_FILE_NAME;
|
const path = import.meta.env.VITE_CONFIG_FILE_NAME;
|
||||||
const isExists = await exists(path, { baseDir: BaseDirectory.Resource });
|
const isExists = await exists(path, { baseDir: BaseDirectory.Resource });
|
||||||
@@ -1161,19 +1326,25 @@
|
|||||||
// const resultStr = guiJsonStr.replace(regex, "").replace(regex2, "$1");
|
// const resultStr = guiJsonStr.replace(regex, "").replace(regex2, "$1");
|
||||||
// console.log(resultStr);
|
// console.log(resultStr);
|
||||||
const guiJson = JSON.parse(guiJsonStr);
|
const guiJson = JSON.parse(guiJsonStr);
|
||||||
let saveServerUrl = "";
|
let saveServerUrl = [];
|
||||||
if (guiJson.serverUrl) {
|
if (guiJson.serverUrl) {
|
||||||
if (Array.isArray(guiJson.serverUrl)) {
|
if (Array.isArray(guiJson.serverUrl)) {
|
||||||
mainStore.basePeers = uniq([...guiJson.serverUrl, ...mainStore.basePeers]);
|
mainStore.basePeers = uniq([...guiJson.serverUrl, ...mainStore.basePeers]);
|
||||||
|
saveServerUrl = uniq([...guiJson.serverUrl]);
|
||||||
}
|
}
|
||||||
if (typeof guiJson.serverUrl === "string") {
|
if (typeof guiJson.serverUrl === "string") {
|
||||||
mainStore.basePeers = uniq([...guiJson.serverUrl.split(","), ...mainStore.basePeers]);
|
mainStore.basePeers = uniq([...guiJson.serverUrl.split(","), ...mainStore.basePeers]);
|
||||||
|
saveServerUrl = [mainStore.basePeers[0] || ""];
|
||||||
|
guiJson.serverUrl = guiJson.serverUrl ? guiJson.serverUrl.split(",") : [];
|
||||||
}
|
}
|
||||||
saveServerUrl = mainStore.basePeers[0] || "";
|
|
||||||
} else {
|
} else {
|
||||||
saveServerUrl = mainStore.basePeers.length > 0 ? mainStore.basePeers[0] || "" : "";
|
saveServerUrl = [mainStore.basePeers.length > 0 ? mainStore.basePeers[0] || "" : ""];
|
||||||
|
}
|
||||||
|
data.configJsonSeverUrl = [...guiJson.serverUrl] as any;
|
||||||
|
if (guiJson.enableKcpProxy && guiJson.enableQuicProxy) {
|
||||||
|
// 如果同时开启kcp代理和quic代理,则禁用quic代理
|
||||||
|
guiJson.enableQuicProxy = false;
|
||||||
}
|
}
|
||||||
data.configJsonSeverUrl = guiJson.serverUrl;
|
|
||||||
mainStore.$patch({
|
mainStore.$patch({
|
||||||
config: {
|
config: {
|
||||||
...mainStore.config,
|
...mainStore.config,
|
||||||
@@ -1224,18 +1395,30 @@
|
|||||||
await appWindow.show();
|
await appWindow.show();
|
||||||
await appWindow.setFocus();
|
await appWindow.setFocus();
|
||||||
}
|
}
|
||||||
|
const appWindow = getCurrentWindow();
|
||||||
|
const logicalAppSize = {
|
||||||
|
width: 340,
|
||||||
|
height: 305
|
||||||
|
};
|
||||||
|
const scaleFactor = await appWindow.scaleFactor();
|
||||||
|
const size = new PhysicalSize(Math.ceil(logicalAppSize.width * scaleFactor), Math.ceil(logicalAppSize.height * scaleFactor));
|
||||||
|
appWindow.setSize(size);
|
||||||
|
appWindow.onScaleChanged(({ payload: { scaleFactor } }) => {
|
||||||
|
console.log("scaleFactor", scaleFactor);
|
||||||
|
appWindow.setSize(new PhysicalSize(Math.ceil(logicalAppSize.width * scaleFactor), Math.ceil(logicalAppSize.height * scaleFactor)));
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
let logsTimer: NodeJS.Timeout | null = null;
|
let logsTimer: number | null = null;
|
||||||
let serverLogsTimer: NodeJS.Timeout | null = null;
|
let serverLogsTimer: number | null = null;
|
||||||
let cidrTimer: NodeJS.Timeout | null = null;
|
let cidrTimer: number | null = null;
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
await compatibleInitServerUrl();
|
||||||
await initGuiJson();
|
await initGuiJson();
|
||||||
await compatibleInitAutoStart();
|
await compatibleInitAutoStart();
|
||||||
// await initAutoStart();
|
// await initAutoStart();
|
||||||
await initStartWinIpBroadcast();
|
// await initStartWinIpBroadcast(); // 对于三层tun而言,winipbroadcast没有作用,先禁用
|
||||||
await compatibleIpv6Listener();
|
|
||||||
await getCoreVersion();
|
await getCoreVersion();
|
||||||
await listenObj.listenThreadId();
|
await listenObj.listenThreadId();
|
||||||
await listenObj.listenServerThreadId();
|
await listenObj.listenServerThreadId();
|
||||||
@@ -1303,7 +1486,16 @@
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (mainStore.config.serverUrl?.length <= 0) {
|
||||||
|
ElMessage.warning(`请至少选择一个服务器`);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
// lodash-es 如何将两个数组的值混合 比如["tcp","udp"] [1,2]
|
||||||
|
// 混合后["tcp1","tcp2","udp1","udp2"]
|
||||||
|
if (mainStore.config.protocol?.length <= 0) {
|
||||||
|
ElMessage.warning(`请至少选择一个协议`);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
if (mainStore.config.dhcp) {
|
if (mainStore.config.dhcp) {
|
||||||
args.push("-d");
|
args.push("-d");
|
||||||
}
|
}
|
||||||
@@ -1320,8 +1512,8 @@
|
|||||||
args.push("--ipv4", mainStore.config.ipv4.trim());
|
args.push("--ipv4", mainStore.config.ipv4.trim());
|
||||||
}
|
}
|
||||||
if (mainStore.config.serverUrl) {
|
if (mainStore.config.serverUrl) {
|
||||||
const formatUrl = mainStore.config.serverUrl.replace(/\\/g, "/");
|
const formatUrlArr = mainStore.config.serverUrl.map((url: string) => url.replace(/\\/g, "/"));
|
||||||
args.push("--peers", ...mainStore.config.protocol.map(protocol => `${protocol}://${formatUrl}`));
|
args.push("--peers", ...mixedArray(mainStore.config.protocol, formatUrlArr, "://"));
|
||||||
}
|
}
|
||||||
if (mainStore.config.enableCustomProtocol) {
|
if (mainStore.config.enableCustomProtocol) {
|
||||||
const includes = mainStore.config.protocol.includes(mainStore.config.customProtocol);
|
const includes = mainStore.config.protocol.includes(mainStore.config.customProtocol);
|
||||||
@@ -1333,7 +1525,7 @@
|
|||||||
args.push("--disable-p2p");
|
args.push("--disable-p2p");
|
||||||
}
|
}
|
||||||
if (mainStore.config.disableIpv6) {
|
if (mainStore.config.disableIpv6) {
|
||||||
args.push("--disable-ipv6");
|
args.push("--disable-ipv6", "true");
|
||||||
}
|
}
|
||||||
if (mainStore.config.disbleListenner) {
|
if (mainStore.config.disbleListenner) {
|
||||||
args.push("--no-listener");
|
args.push("--no-listener");
|
||||||
@@ -1348,9 +1540,7 @@
|
|||||||
args.push("-l", ...customListener);
|
args.push("-l", ...customListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!mainStore.config.disbleListenner && mainStore.config.enableCustomListenerV6 && mainStore.config.customListenerV6Data) {
|
|
||||||
args.push("--ipv6-listener", mainStore.config.customListenerV6Data);
|
|
||||||
}
|
|
||||||
if (!mainStore.config.disbleListenner && !mainStore.config.enableCustomListener && mainStore.config.port) {
|
if (!mainStore.config.disbleListenner && !mainStore.config.enableCustomListener && mainStore.config.port) {
|
||||||
args.push("-l", mainStore.config.port);
|
args.push("-l", mainStore.config.port);
|
||||||
}
|
}
|
||||||
@@ -1367,28 +1557,28 @@
|
|||||||
mainStore.config.proxyNetworks = formatProxyNetworks.join("\n");
|
mainStore.config.proxyNetworks = formatProxyNetworks.join("\n");
|
||||||
}
|
}
|
||||||
if (mainStore.config.disableEncryption) {
|
if (mainStore.config.disableEncryption) {
|
||||||
args.push("--disable-encryption");
|
args.push("--disable-encryption", "true");
|
||||||
}
|
}
|
||||||
if (mainStore.config.multiThread) {
|
if (mainStore.config.multiThread) {
|
||||||
args.push("--multi-thread");
|
args.push("--multi-thread", "true");
|
||||||
}
|
}
|
||||||
if (mainStore.config.enablExitNode) {
|
if (mainStore.config.enablExitNode) {
|
||||||
args.push("--enable-exit-node");
|
args.push("--enable-exit-node", "true");
|
||||||
}
|
}
|
||||||
if (mainStore.config.noTun) {
|
if (mainStore.config.noTun) {
|
||||||
args.push("--no-tun");
|
args.push("--no-tun", "true");
|
||||||
}
|
}
|
||||||
if (mainStore.config.latencyfirst) {
|
if (mainStore.config.latencyfirst) {
|
||||||
args.push("--latency-first");
|
args.push("--latency-first", "true");
|
||||||
}
|
}
|
||||||
if (mainStore.config.useSmoltcp) {
|
if (mainStore.config.useSmoltcp) {
|
||||||
args.push("--use-smoltcp");
|
args.push("--use-smoltcp", "true");
|
||||||
}
|
}
|
||||||
if (mainStore.config.disableUdpHolePunching) {
|
if (mainStore.config.disableUdpHolePunching) {
|
||||||
args.push("--disable-udp-hole-punching");
|
args.push("--disable-udp-hole-punching", "true");
|
||||||
}
|
}
|
||||||
if (mainStore.config.relayAllPeerrpc) {
|
if (mainStore.config.relayAllPeerrpc) {
|
||||||
args.push("--relay-all-peer-rpc");
|
args.push("--relay-all-peer-rpc", "true");
|
||||||
}
|
}
|
||||||
if (mainStore.config.saveErrorLog) {
|
if (mainStore.config.saveErrorLog) {
|
||||||
args.push("--file-log-level", mainStore.config.logLevel, "--file-log-dir", import.meta.env.VITE_LOG_PATH);
|
args.push("--file-log-level", mainStore.config.logLevel, "--file-log-dir", import.meta.env.VITE_LOG_PATH);
|
||||||
@@ -1400,16 +1590,22 @@
|
|||||||
args.push("--compression", mainStore.config.compression);
|
args.push("--compression", mainStore.config.compression);
|
||||||
}
|
}
|
||||||
if (mainStore.config.enableKcpProxy) {
|
if (mainStore.config.enableKcpProxy) {
|
||||||
args.push("--enable-kcp-proxy");
|
args.push("--enable-kcp-proxy", "true");
|
||||||
}
|
}
|
||||||
if (mainStore.config.disableKcpInput) {
|
if (mainStore.config.disableKcpInput) {
|
||||||
args.push("--disable-kcp-input");
|
args.push("--disable-kcp-input", "true");
|
||||||
|
}
|
||||||
|
if (mainStore.config.enableQuicProxy) {
|
||||||
|
args.push("--enable-quic-proxy", "true");
|
||||||
|
}
|
||||||
|
if (mainStore.config.disableQuicInput) {
|
||||||
|
args.push("--disable-quic-input", "true");
|
||||||
}
|
}
|
||||||
if (mainStore.config.bindDeviceEnable) {
|
if (mainStore.config.bindDeviceEnable) {
|
||||||
args.push("--bind-device", "true");
|
args.push("--bind-device", "true");
|
||||||
}
|
}
|
||||||
if (mainStore.proxyForwardBySystem) {
|
if (mainStore.proxyForwardBySystem) {
|
||||||
args.push("--proxy-forward-by-system");
|
args.push("--proxy-forward-by-system", "true");
|
||||||
}
|
}
|
||||||
if (mainStore.config.acceptDNS) {
|
if (mainStore.config.acceptDNS) {
|
||||||
args.push("--accept-dns", "true");
|
args.push("--accept-dns", "true");
|
||||||
@@ -1423,18 +1619,34 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(mainStore.config.privateMode) {
|
if (mainStore.config.privateMode) {
|
||||||
args.push("--private-mode", "true");
|
args.push("--private-mode", "true");
|
||||||
}
|
}
|
||||||
|
if (mainStore.config.ipv6 && !mainStore.config.disableIpv6) {
|
||||||
|
args.push("--ipv6", mainStore.config.ipv6.trim());
|
||||||
|
}
|
||||||
|
const tcpWhitelist = mainStore.config.tcpWhitelist.trim();
|
||||||
|
if (mainStore.config.tcpWhitelistEnable && tcpWhitelist) {
|
||||||
|
args.push("--tcp-whitelist", tcpWhitelist);
|
||||||
|
}
|
||||||
|
const udpWhitelist = mainStore.config.udpWhitelist.trim();
|
||||||
|
if (mainStore.config.udpWhitelistEnable && udpWhitelist) {
|
||||||
|
args.push("--udp-whitelist", udpWhitelist);
|
||||||
|
}
|
||||||
return args;
|
return args;
|
||||||
};
|
};
|
||||||
|
|
||||||
const reset = async () => {
|
const ipReset = async () => {
|
||||||
data.isStart = false;
|
|
||||||
data.isSuccessGetIp = false;
|
data.isSuccessGetIp = false;
|
||||||
if (mainStore.config.dhcp) {
|
if (mainStore.config.dhcp) {
|
||||||
mainStore.config.ipv4 = "";
|
mainStore.config.ipv4 = "";
|
||||||
}
|
}
|
||||||
|
await setTrayRunState(tray, false);
|
||||||
|
await setTrayTooltip(tray);
|
||||||
|
};
|
||||||
|
|
||||||
|
const reset = async () => {
|
||||||
|
data.isStart = false;
|
||||||
const memberDialog = await getAllWebviewWindows();
|
const memberDialog = await getAllWebviewWindows();
|
||||||
const memberDialogs = memberDialog.filter(item => item.label === "member");
|
const memberDialogs = memberDialog.filter(item => item.label === "member");
|
||||||
if (memberDialogs && memberDialogs.length > 0) {
|
if (memberDialogs && memberDialogs.length > 0) {
|
||||||
@@ -1446,9 +1658,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await setTrayRunState(tray, false);
|
|
||||||
await setTrayTooltip(tray);
|
|
||||||
await unListenAll();
|
await unListenAll();
|
||||||
|
await ipReset();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleConnection = async () => {
|
const handleConnection = async () => {
|
||||||
@@ -1520,8 +1731,6 @@
|
|||||||
port,
|
port,
|
||||||
enableCustomListener,
|
enableCustomListener,
|
||||||
customListenerData,
|
customListenerData,
|
||||||
enableCustomListenerV6,
|
|
||||||
customListenerV6Data,
|
|
||||||
devName,
|
devName,
|
||||||
devNameValue,
|
devNameValue,
|
||||||
enableNetCardMetric,
|
enableNetCardMetric,
|
||||||
@@ -1535,6 +1744,8 @@
|
|||||||
enablePreventSleep,
|
enablePreventSleep,
|
||||||
enableKcpProxy,
|
enableKcpProxy,
|
||||||
disableKcpInput,
|
disableKcpInput,
|
||||||
|
enableQuicProxy,
|
||||||
|
disableQuicInput,
|
||||||
privateMode
|
privateMode
|
||||||
} = mainStore.config;
|
} = mainStore.config;
|
||||||
const WT = btoa(
|
const WT = btoa(
|
||||||
@@ -1554,8 +1765,6 @@
|
|||||||
port,
|
port,
|
||||||
enableCustomListener,
|
enableCustomListener,
|
||||||
customListenerData,
|
customListenerData,
|
||||||
enableCustomListenerV6,
|
|
||||||
customListenerV6Data,
|
|
||||||
devName,
|
devName,
|
||||||
devNameValue,
|
devNameValue,
|
||||||
enableNetCardMetric,
|
enableNetCardMetric,
|
||||||
@@ -1569,6 +1778,8 @@
|
|||||||
enablePreventSleep,
|
enablePreventSleep,
|
||||||
enableKcpProxy,
|
enableKcpProxy,
|
||||||
disableKcpInput,
|
disableKcpInput,
|
||||||
|
enableQuicProxy,
|
||||||
|
disableQuicInput,
|
||||||
privateMode
|
privateMode
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -1597,6 +1808,9 @@
|
|||||||
if (command === "create_server") {
|
if (command === "create_server") {
|
||||||
await handleShowServerDialog();
|
await handleShowServerDialog();
|
||||||
}
|
}
|
||||||
|
if (command === "cidr") {
|
||||||
|
await handleShowCidrDialog();
|
||||||
|
}
|
||||||
if (command === "config_admin") {
|
if (command === "config_admin") {
|
||||||
configAdminData.visible = true;
|
configAdminData.visible = true;
|
||||||
const path = import.meta.env.VITE_CONFIG_ADMIN_PATH;
|
const path = import.meta.env.VITE_CONFIG_ADMIN_PATH;
|
||||||
@@ -1688,6 +1902,25 @@
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (command === "reconnect") {
|
||||||
|
handleReconnect();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleReconnect = async () => {
|
||||||
|
if (data.isStart) {
|
||||||
|
ElMessage.info({
|
||||||
|
message: "正在重新联机...",
|
||||||
|
duration: 2200
|
||||||
|
});
|
||||||
|
await handleConnection();
|
||||||
|
setTimeout(() => {
|
||||||
|
handleConnection();
|
||||||
|
}, 2000);
|
||||||
|
} else {
|
||||||
|
handleConnection();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteAdminConfig = async () => {
|
const handleDeleteAdminConfig = async () => {
|
||||||
@@ -1740,7 +1973,13 @@
|
|||||||
});
|
});
|
||||||
if (!err) {
|
if (!err) {
|
||||||
const payload = JSON.parse(decodeURIComponent(atob(importConfigData.data)));
|
const payload = JSON.parse(decodeURIComponent(atob(importConfigData.data)));
|
||||||
payload.config.serverUrl = payload?.config?.serverUrl?.trim() || mainStore.config.serverUrl;
|
payload.config.serverUrl = Array.isArray(payload?.config?.serverUrl)
|
||||||
|
? payload?.config?.serverUrl
|
||||||
|
: typeof payload?.config?.serverUrl == "string"
|
||||||
|
? [payload?.config?.serverUrl.split(",")]
|
||||||
|
: typeof mainStore.config.serverUrl == "string"
|
||||||
|
? [mainStore.config.serverUrl]
|
||||||
|
: [];
|
||||||
mainStore.$patch({
|
mainStore.$patch({
|
||||||
config: {
|
config: {
|
||||||
...mainStore.config,
|
...mainStore.config,
|
||||||
@@ -1749,7 +1988,7 @@
|
|||||||
});
|
});
|
||||||
ElMessage.success("导入成功");
|
ElMessage.success("导入成功");
|
||||||
importConfigData.visible = false;
|
importConfigData.visible = false;
|
||||||
mainStore.basePeers = uniq([mainStore.config.serverUrl, ...mainStore.basePeers].filter(el => el.trim()));
|
mainStore.basePeers = uniq([...(mainStore.config.serverUrl || []), ...mainStore.basePeers].filter(el => el.trim()));
|
||||||
} else {
|
} else {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
if (err !== "cancel") {
|
if (err !== "cancel") {
|
||||||
@@ -1787,7 +2026,7 @@
|
|||||||
|
|
||||||
const handleShowMemberDialog = async () => {
|
const handleShowMemberDialog = async () => {
|
||||||
if (!data.isStart) {
|
if (!data.isStart) {
|
||||||
return ElMessage.warning("请先开始联机");
|
return ElMessage.warning("请先启动联机");
|
||||||
}
|
}
|
||||||
// if (!mainStore.config.ipv4) {
|
// if (!mainStore.config.ipv4) {
|
||||||
// return ElMessage.warning("请等待获取IP");
|
// return ElMessage.warning("请等待获取IP");
|
||||||
@@ -1926,24 +2165,26 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const storageDialog = async () => {
|
const storageDialog = async () => {
|
||||||
await etWindows("storage-listener", {
|
await etWindows(
|
||||||
title: "自建服务器",
|
"storage-listener",
|
||||||
minWidth: 0,
|
{
|
||||||
minHeight: 0,
|
title: "存储监听",
|
||||||
width: 0,
|
minWidth: 0,
|
||||||
height: 0,
|
minHeight: 0,
|
||||||
x: 9999,
|
width: 0,
|
||||||
y: 9999,
|
height: 0,
|
||||||
resizable: false,
|
x: 9999,
|
||||||
transparent: true,
|
y: 9999,
|
||||||
hiddenTitle: true,
|
resizable: false,
|
||||||
alwaysOnBottom: true,
|
transparent: true,
|
||||||
url: "#/storage-listener"
|
hiddenTitle: true,
|
||||||
},
|
alwaysOnBottom: true,
|
||||||
(dialog) => {
|
visible: false,
|
||||||
dialog.hide();
|
url: "#/storage-listener"
|
||||||
},
|
},
|
||||||
|
dialog => {
|
||||||
|
dialog.hide();
|
||||||
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
+126
-8
@@ -1,27 +1,145 @@
|
|||||||
<template>
|
<template>
|
||||||
<ElInput
|
<!-- <ElInput
|
||||||
type="textarea"
|
type="textarea"
|
||||||
:rows="17"
|
:rows="17"
|
||||||
v-model="data.log"
|
v-model="data.originLog"
|
||||||
resize="none"
|
resize="none"
|
||||||
readonly
|
readonly
|
||||||
placeholder="等待日志中,请先'启动联机'..."
|
placeholder="等待日志中,请先'启动联机'..."
|
||||||
/>
|
/> -->
|
||||||
|
<div
|
||||||
|
ref="logRef"
|
||||||
|
@scroll="handleScroll"
|
||||||
|
class="overflow-auto"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-if="!data.log || data.log.length <= 0"
|
||||||
|
class="p-[5px]"
|
||||||
|
>
|
||||||
|
<ElText type="info">等待日志中,请先'启动联机'...</ElText>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
v-for="item in data.log"
|
||||||
|
:key="item.id"
|
||||||
|
class="p-[5px]"
|
||||||
|
>
|
||||||
|
<div class="group/item flex items-center justify-start leading-[26px]">
|
||||||
|
<ElText
|
||||||
|
:closable="false"
|
||||||
|
:type="item.type"
|
||||||
|
>
|
||||||
|
{{ item.text }}
|
||||||
|
<ElTooltip
|
||||||
|
placement="right"
|
||||||
|
content="复制"
|
||||||
|
>
|
||||||
|
<ElButton
|
||||||
|
class="ml-[3px] !hidden w-fit group-hover/item:!inline-flex"
|
||||||
|
@click.stop="handleCopyLog(item.text)"
|
||||||
|
type="success"
|
||||||
|
size="small"
|
||||||
|
circle
|
||||||
|
plain
|
||||||
|
:icon="CopyDocument"
|
||||||
|
></ElButton>
|
||||||
|
</ElTooltip>
|
||||||
|
</ElText>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ElAffix
|
||||||
|
v-if="data.originLog"
|
||||||
|
class="w-full"
|
||||||
|
position="bottom"
|
||||||
|
:offset="10"
|
||||||
|
>
|
||||||
|
<div class="bg-(var(--el-color-primary)) mr-[10px] flex items-center justify-end">
|
||||||
|
<ElTooltip
|
||||||
|
content="复制全部"
|
||||||
|
placement="top"
|
||||||
|
>
|
||||||
|
<ElButton
|
||||||
|
@click.stop="handleCopyLog(data.originLog)"
|
||||||
|
type="info"
|
||||||
|
size="large"
|
||||||
|
circle
|
||||||
|
:icon="CopyDocument"
|
||||||
|
></ElButton>
|
||||||
|
</ElTooltip>
|
||||||
|
</div>
|
||||||
|
</ElAffix>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { CopyDocument } from "@element-plus/icons-vue";
|
||||||
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
|
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
|
||||||
import { reactive, onMounted, onBeforeUnmount } from "vue";
|
import { reactive, onMounted, onBeforeUnmount, useTemplateRef, nextTick } from "vue";
|
||||||
const data = reactive({
|
import { copyText } from "~/utils";
|
||||||
log: ""
|
type LogItem = { id: string; text: string; type: "danger" | "info" | "warning" | "primary" };
|
||||||
|
const data = reactive<{ log: LogItem[]; originLog: string; autoScrollToBottom: boolean }>({
|
||||||
|
log: [],
|
||||||
|
originLog: "", // 原始日志
|
||||||
|
autoScrollToBottom: true // 是否允许自动滚动到底部
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const logEl = useTemplateRef<HTMLDivElement>("logRef");
|
||||||
|
|
||||||
|
const scrollToBottom = () => {
|
||||||
|
if (data.autoScrollToBottom) {
|
||||||
|
logEl.value?.scrollTo({
|
||||||
|
top: logEl.value?.scrollHeight,
|
||||||
|
behavior: "smooth"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleScroll = () => {
|
||||||
|
if (logEl.value) {
|
||||||
|
const autoScrollToBottom = logEl.value.scrollTop + logEl.value.clientHeight >= logEl.value.scrollHeight;
|
||||||
|
data.autoScrollToBottom = autoScrollToBottom;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const listenStart = async () => {
|
const listenStart = async () => {
|
||||||
const unListen = await listen<string>("logs", event => {
|
const unListen = await listen<string>("logs", async event => {
|
||||||
data.log = event.payload || "";
|
const payload = event.payload || "";
|
||||||
|
if (data.originLog === payload) return;
|
||||||
|
data.originLog = payload;
|
||||||
|
data.log = payload
|
||||||
|
.split("\n")
|
||||||
|
.filter(text => text.trim())
|
||||||
|
.map((text, idx) => {
|
||||||
|
if (idx === 0) {
|
||||||
|
return { id: `${text}-${idx}`, text, type: "primary" };
|
||||||
|
}
|
||||||
|
const toLowerCaseText = text.toLocaleLowerCase();
|
||||||
|
return {
|
||||||
|
id: `${text}-${idx}`,
|
||||||
|
text,
|
||||||
|
type:
|
||||||
|
toLowerCaseText.includes("error") ||
|
||||||
|
toLowerCaseText.includes("fail") ||
|
||||||
|
toLowerCaseText.includes("failed") ||
|
||||||
|
toLowerCaseText.includes("exception") ||
|
||||||
|
toLowerCaseText.includes("err")
|
||||||
|
? "danger"
|
||||||
|
: toLowerCaseText.includes("warn")
|
||||||
|
? "warning"
|
||||||
|
: toLowerCaseText.includes("new peer connection")
|
||||||
|
? "primary"
|
||||||
|
: "info"
|
||||||
|
};
|
||||||
|
});
|
||||||
|
await nextTick();
|
||||||
|
scrollToBottom();
|
||||||
});
|
});
|
||||||
return unListen;
|
return unListen;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCopyLog = async (text: string) => {
|
||||||
|
await copyText(text, "复制记录成功");
|
||||||
|
};
|
||||||
|
|
||||||
let unlistenStart: UnlistenFn | null = null;
|
let unlistenStart: UnlistenFn | null = null;
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
unlistenStart = await listenStart();
|
unlistenStart = await listenStart();
|
||||||
|
|||||||
+137
-83
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="h-full overflow-auto">
|
<div class="h-full overflow-auto">
|
||||||
<div class="w-[1200px]">
|
<div class="max-w-[2000px]">
|
||||||
<ElText
|
<ElText
|
||||||
size="small"
|
size="small"
|
||||||
v-if="!data.member || data.member.length <= 0"
|
v-if="!data.member || data.member.length <= 0"
|
||||||
@@ -10,26 +10,41 @@
|
|||||||
<ElTable
|
<ElTable
|
||||||
stripe
|
stripe
|
||||||
border
|
border
|
||||||
:data="data.member"
|
:data="computedMember"
|
||||||
v-else
|
v-else
|
||||||
>
|
>
|
||||||
<ElTableColumn
|
<ElTableColumn
|
||||||
sortable
|
sortable
|
||||||
width="140"
|
|
||||||
label="成员名"
|
label="成员名"
|
||||||
prop="hostname"
|
prop="hostname"
|
||||||
>
|
>
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
{{
|
<div :class="`whitespace-pre-wrap`">
|
||||||
(row.hostname || "").toLowerCase().includes("publicserver")
|
<div>
|
||||||
? (row.hostname || "").replace("PublicServer", "服务器")
|
{{
|
||||||
: row.hostname || "-"
|
(row.hostname || "").toLowerCase().includes("publicserver")
|
||||||
}}
|
? (row.hostname || "").replace("PublicServer", "服务器")
|
||||||
|
: row.hostname || "-"
|
||||||
|
}}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="space-y-1"
|
||||||
|
v-if="row?.connections_addrs?.length > 0"
|
||||||
|
>
|
||||||
|
<ElTag
|
||||||
|
:key="url"
|
||||||
|
v-for="url in row.connections_addrs"
|
||||||
|
class="!flex !h-auto !whitespace-pre-wrap !break-all !py-[5px]"
|
||||||
|
>
|
||||||
|
{{ url }}
|
||||||
|
</ElTag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</ElTableColumn>
|
</ElTableColumn>
|
||||||
<ElTableColumn
|
<ElTableColumn
|
||||||
sortable
|
sortable
|
||||||
width="90"
|
width="70"
|
||||||
prop="cost"
|
prop="cost"
|
||||||
label="方式"
|
label="方式"
|
||||||
>
|
>
|
||||||
@@ -50,11 +65,29 @@
|
|||||||
label="虚拟网IP"
|
label="虚拟网IP"
|
||||||
:sort-method="sortIpv4"
|
:sort-method="sortIpv4"
|
||||||
:sort-orders="['ascending', 'descending', null]"
|
:sort-orders="['ascending', 'descending', null]"
|
||||||
></ElTableColumn>
|
>
|
||||||
|
<template #default="{ row }">
|
||||||
|
<div class="space-y-[5px]">
|
||||||
|
<div>
|
||||||
|
{{ row.ipv4 || "-" }}
|
||||||
|
</div>
|
||||||
|
<div v-if="row.proxy?.[0]">
|
||||||
|
<ElTooltip :content="row.proxy?.[1] == 'Connected' ? '已连接' : '已断开'">
|
||||||
|
<ElTag
|
||||||
|
size="small"
|
||||||
|
:type="row.proxy?.[1] == 'Connected' ? 'success' : 'danger'"
|
||||||
|
>
|
||||||
|
{{ row.proxy?.[0] || "-" }}代理
|
||||||
|
</ElTag>
|
||||||
|
</ElTooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</ElTableColumn>
|
||||||
<ElTableColumn
|
<ElTableColumn
|
||||||
sortable
|
sortable
|
||||||
prop="lat_ms"
|
prop="lat_ms"
|
||||||
width="100"
|
width="80"
|
||||||
label="延迟/ms"
|
label="延迟/ms"
|
||||||
:sort-method="sortLatMs"
|
:sort-method="sortLatMs"
|
||||||
:sort-orders="['ascending', 'descending', null]"
|
:sort-orders="['ascending', 'descending', null]"
|
||||||
@@ -65,22 +98,28 @@
|
|||||||
</ElTableColumn>
|
</ElTableColumn>
|
||||||
<ElTableColumn
|
<ElTableColumn
|
||||||
sortable
|
sortable
|
||||||
width="100"
|
width="70"
|
||||||
prop="loss_rate"
|
prop="loss_rate"
|
||||||
label="丢包率"
|
label="丢包率"
|
||||||
>
|
>
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
{{ row.loss_rate && row.loss_rate != "-" ? Number(row.loss_rate * 100).toFixed(2) + "%" : row.loss_rate }}
|
{{
|
||||||
|
row.loss_rate && row.loss_rate != "-"
|
||||||
|
? row.loss_rate.endsWith("%")
|
||||||
|
? row.loss_rate
|
||||||
|
: Number(row.loss_rate * 100).toFixed(2) + "%"
|
||||||
|
: row.loss_rate
|
||||||
|
}}
|
||||||
</template>
|
</template>
|
||||||
</ElTableColumn>
|
</ElTableColumn>
|
||||||
<ElTableColumn
|
<ElTableColumn
|
||||||
sortable
|
sortable
|
||||||
width="110"
|
width="100"
|
||||||
label="NAT类型"
|
label="NAT类型"
|
||||||
prop="nat_type"
|
prop="nat_type"
|
||||||
>
|
>
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
{{ natMaps[row.nat_type.toLowerCase() as natKyes] || row.nat_type || "-" }}
|
{{ natMaps[row.nat_type.toLowerCase() as NATKyes] || row.nat_type || "-" }}
|
||||||
</template>
|
</template>
|
||||||
</ElTableColumn>
|
</ElTableColumn>
|
||||||
<ElTableColumn
|
<ElTableColumn
|
||||||
@@ -107,7 +146,7 @@
|
|||||||
sortable
|
sortable
|
||||||
prop="tx_bytes"
|
prop="tx_bytes"
|
||||||
label="传输"
|
label="传输"
|
||||||
:sort-method="(a, b) => sortBytes(a, b, 'tx_bytes')"
|
:sort-method="(a: any, b: any) => sortBytes(a, b, 'tx_bytes')"
|
||||||
:sort-orders="['ascending', 'descending', null]"
|
:sort-orders="['ascending', 'descending', null]"
|
||||||
></ElTableColumn>
|
></ElTableColumn>
|
||||||
</ElTable>
|
</ElTable>
|
||||||
@@ -116,24 +155,12 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { reactive, onMounted, onBeforeUnmount } from "vue";
|
import { reactive, onMounted, onBeforeUnmount, computed } from "vue";
|
||||||
import { ATJ, parseCliInfo } from "@/utils";
|
import { ATJ } from "@/utils";
|
||||||
import { ElConfirmDanger } from "~/utils/element";
|
import { ElConfirmDanger } from "~/utils/element";
|
||||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||||
import { isNaN } from "lodash-es";
|
import { isNaN } from "lodash-es";
|
||||||
// enum NatType {
|
|
||||||
// // has NAT; but own a single public IP, port is not changed
|
|
||||||
// Unknown = 0;
|
|
||||||
// OpenInternet = 1;
|
|
||||||
// NoPAT = 2;
|
|
||||||
// FullCone = 3;
|
|
||||||
// Restricted = 4;
|
|
||||||
// PortRestricted = 5;
|
|
||||||
// Symmetric = 6;
|
|
||||||
// SymUdpFirewall = 7;
|
|
||||||
// SymmetricEasyInc = 8;
|
|
||||||
// SymmetricEasyDec = 9;
|
|
||||||
// }
|
|
||||||
const natMaps = {
|
const natMaps = {
|
||||||
unknown: "未知",
|
unknown: "未知",
|
||||||
OpenInternet: "nat0-openinternet",
|
OpenInternet: "nat0-openinternet",
|
||||||
@@ -146,15 +173,32 @@
|
|||||||
symmetriceasyinc: "nat4-easyinc",
|
symmetriceasyinc: "nat4-easyinc",
|
||||||
symUdpfirewall: "nat4-udpfirewall"
|
symUdpfirewall: "nat4-udpfirewall"
|
||||||
};
|
};
|
||||||
type natKyes = keyof typeof natMaps;
|
|
||||||
|
|
||||||
const data = reactive<{ member: { hostname: string; cost: string; ipv4: string; lat_msg: string; loss_rate: string; nat_type: string }[] }>({
|
type NATKyes = keyof typeof natMaps;
|
||||||
member: []
|
|
||||||
|
const data = reactive<{ member: Member[]; proxy: Proxy[] }>({
|
||||||
|
member: [],
|
||||||
|
proxy: []
|
||||||
|
});
|
||||||
|
|
||||||
|
const computedMember = computed(() => {
|
||||||
|
const localMember = data.member.find(member => member?.cost == "Local");
|
||||||
|
if (!localMember) return data.member;
|
||||||
|
const ipv4 = localMember.ipv4;
|
||||||
|
const proxyMember = data.proxy?.filter(proxy => proxy.src.startsWith(`${ipv4}:`));
|
||||||
|
const proxyObj: Record<string, [string, "Connected" | "Closed"]> = {};
|
||||||
|
for (const proxy of proxyMember) {
|
||||||
|
proxyObj[proxy.dst.split(":")[0]] = [proxy.transport_type, proxy.state];
|
||||||
|
}
|
||||||
|
return data.member.map(m => {
|
||||||
|
m.proxy = proxyObj?.[m.ipv4.split(":")?.[0]] || m?.proxy || ["", "Closed"];
|
||||||
|
return m;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// 延迟排序函数
|
// 延迟排序函数
|
||||||
const sortLatMs = (a: any, b: any): number => {
|
const sortLatMs = (a: Member, b: Member): number => {
|
||||||
const getLatencyValue = (row: any): number => {
|
const getLatencyValue = (row: Member): number => {
|
||||||
const latMs = row.lat_ms;
|
const latMs = row.lat_ms;
|
||||||
|
|
||||||
if (latMs === null || latMs === undefined || latMs === "") {
|
if (latMs === null || latMs === undefined || latMs === "") {
|
||||||
@@ -214,7 +258,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 字节数据排序函数
|
// 字节数据排序函数
|
||||||
const sortBytes = (a: any, b: any, field: string = 'rx_bytes'): number => {
|
const sortBytes = (a: any, b: any, field: string = "rx_bytes"): number => {
|
||||||
const parseBytes = (bytesStr: string): number => {
|
const parseBytes = (bytesStr: string): number => {
|
||||||
if (!bytesStr || bytesStr === "-" || bytesStr === "") {
|
if (!bytesStr || bytesStr === "-" || bytesStr === "") {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -222,7 +266,7 @@
|
|||||||
|
|
||||||
// 统一转换为小写并去除空格
|
// 统一转换为小写并去除空格
|
||||||
const cleanStr = bytesStr.toLowerCase().trim();
|
const cleanStr = bytesStr.toLowerCase().trim();
|
||||||
|
|
||||||
// 使用正则表达式匹配数字和单位
|
// 使用正则表达式匹配数字和单位
|
||||||
const match = cleanStr.match(/^(\d+(?:\.\d+)?)\s*([a-z]*)$/);
|
const match = cleanStr.match(/^(\d+(?:\.\d+)?)\s*([a-z]*)$/);
|
||||||
if (!match) {
|
if (!match) {
|
||||||
@@ -238,30 +282,30 @@
|
|||||||
|
|
||||||
// 根据单位转换为字节数
|
// 根据单位转换为字节数
|
||||||
switch (unit) {
|
switch (unit) {
|
||||||
case 'b':
|
case "b":
|
||||||
case 'byte':
|
case "byte":
|
||||||
case 'bytes':
|
case "bytes":
|
||||||
case '':
|
case "":
|
||||||
return value;
|
return value;
|
||||||
case 'k':
|
case "k":
|
||||||
case 'kb':
|
case "kb":
|
||||||
case 'kib':
|
case "kib":
|
||||||
return value * 1024;
|
return value * 1024;
|
||||||
case 'm':
|
case "m":
|
||||||
case 'mb':
|
case "mb":
|
||||||
case 'mib':
|
case "mib":
|
||||||
return value * 1024 * 1024;
|
return value * 1024 * 1024;
|
||||||
case 'g':
|
case "g":
|
||||||
case 'gb':
|
case "gb":
|
||||||
case 'gib':
|
case "gib":
|
||||||
return value * 1024 * 1024 * 1024;
|
return value * 1024 * 1024 * 1024;
|
||||||
case 't':
|
case "t":
|
||||||
case 'tb':
|
case "tb":
|
||||||
case 'tib':
|
case "tib":
|
||||||
return value * 1024 * 1024 * 1024 * 1024;
|
return value * 1024 * 1024 * 1024 * 1024;
|
||||||
case 'p':
|
case "p":
|
||||||
case 'pb':
|
case "pb":
|
||||||
case 'pib':
|
case "pib":
|
||||||
return value * 1024 * 1024 * 1024 * 1024 * 1024;
|
return value * 1024 * 1024 * 1024 * 1024 * 1024;
|
||||||
default:
|
default:
|
||||||
return value; // 未知单位当作字节处理
|
return value; // 未知单位当作字节处理
|
||||||
@@ -292,24 +336,10 @@
|
|||||||
return num.toFixed(0);
|
return num.toFixed(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
const _showTableHeader = [
|
let timer: number | null = null;
|
||||||
["hostname", "主机名"],
|
|
||||||
["cost", "路由"],
|
|
||||||
["ipv4", "虚拟网IP"],
|
|
||||||
["lat_ms", "延迟/ms"],
|
|
||||||
["loss_rate", "丢包率"],
|
|
||||||
["nat_type", "NAT类型"],
|
|
||||||
["version", "版本"],
|
|
||||||
["tunnel_proto", "隧道协议"],
|
|
||||||
["rx_bytes", "接收"],
|
|
||||||
["tx_bytes", "传输"]
|
|
||||||
];
|
|
||||||
|
|
||||||
let timer: NodeJS.Timeout | null = null;
|
|
||||||
|
|
||||||
const listenOutput = async () => {
|
const listenOutput = async () => {
|
||||||
const [error, member] = await ATJ(invoke<string>("get_members_by_cli"));
|
const [error, member] = await ATJ(invoke<string>("get_members_by_cli"));
|
||||||
// if(!member) return;
|
|
||||||
if (error) {
|
if (error) {
|
||||||
data.member = [];
|
data.member = [];
|
||||||
return "";
|
return "";
|
||||||
@@ -329,20 +359,44 @@
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const peerInfo = parseCliInfo(member);
|
const [errorConnections, connections] = await ATJ(invoke<string>("get_members_connections_cli"));
|
||||||
peerInfo.forEach(value => {
|
const memberConnections: ConnectionsType[] = JSON.parse(connections) as ConnectionsType[];
|
||||||
if (value.cost === "Local") {
|
|
||||||
value.cost = "本机";
|
if (errorConnections != "_EasytierGameCliFailedToGetConnections_") {
|
||||||
}
|
data.member = (JSON.parse(member) as Member[]).map(member => {
|
||||||
if (value.ipv4 && value.ipv4.includes("/")) {
|
const connection = memberConnections.find(conn => String(conn.route.peer_id) === member.id);
|
||||||
value.ipv4 = value.ipv4.split("/")[0];
|
if (connection) {
|
||||||
}
|
member.connections_addrs = connection?.peer?.conns?.map(conn => conn?.tunnel?.remote_addr?.url || "") || [];
|
||||||
});
|
} else {
|
||||||
// console.log(peerInfo)
|
member.connections_addrs = [];
|
||||||
data.member = peerInfo;
|
}
|
||||||
|
return member;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
data.member = JSON.parse(member) as Member[];
|
||||||
|
}
|
||||||
|
// console.log(data.member);
|
||||||
|
getMembersProxy();
|
||||||
startTimer();
|
startTimer();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getMembersProxy = async () => {
|
||||||
|
const [error, proxy] = await ATJ(invoke<string>("get_members_proxy"));
|
||||||
|
if (error) {
|
||||||
|
data.proxy = [];
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (proxy === "_EasytierGameCliFailedToGetProxy_") {
|
||||||
|
data.proxy = [];
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
data.proxy = JSON.parse(proxy) as Proxy[];
|
||||||
|
} catch (error) {
|
||||||
|
data.proxy = [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const startTimer = () => {
|
const startTimer = () => {
|
||||||
timer && clearTimeout(timer);
|
timer && clearTimeout(timer);
|
||||||
timer = setTimeout(() => {
|
timer = setTimeout(() => {
|
||||||
|
|||||||
@@ -0,0 +1,389 @@
|
|||||||
|
<template>
|
||||||
|
<div class="relative flex h-full flex-col flex-wrap gap-[0] overflow-hidden">
|
||||||
|
<div class="flex h-[40px] w-full flex-nowrap items-center gap-[0_8px]">
|
||||||
|
<div class="ml-[5px] mr-auto flex">
|
||||||
|
<ElText class="text-lg font-semibold">公共服务器节点列表</ElText>
|
||||||
|
</div>
|
||||||
|
<div class="flex w-fit flex-nowrap items-center gap-[0_8px]">
|
||||||
|
<div>
|
||||||
|
<ElInput
|
||||||
|
placeholder="搜索名称/地址"
|
||||||
|
v-model="searchName"
|
||||||
|
clearable
|
||||||
|
></ElInput>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<ElButton
|
||||||
|
size="small"
|
||||||
|
type="primary"
|
||||||
|
@click="refreshNodes"
|
||||||
|
>
|
||||||
|
刷新
|
||||||
|
</ElButton>
|
||||||
|
<ElButton
|
||||||
|
:disabled="selectedNodes.length === 0"
|
||||||
|
size="small"
|
||||||
|
type="success"
|
||||||
|
class="mr-[8px]"
|
||||||
|
@click="addSelectedToServerList"
|
||||||
|
>
|
||||||
|
添加选中 ({{ selectedNodes.length }})
|
||||||
|
</ElButton>
|
||||||
|
<ElTag
|
||||||
|
size="small"
|
||||||
|
type="info"
|
||||||
|
>
|
||||||
|
最后更新: {{ lastUpdateTime || "00:00:00" }}
|
||||||
|
</ElTag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex w-full flex-1 flex-wrap gap-[0] overflow-auto">
|
||||||
|
<ElTable
|
||||||
|
:data="computedNodes"
|
||||||
|
stripe
|
||||||
|
height="100%"
|
||||||
|
ref="tableRef"
|
||||||
|
:empty-text="loading ? '加载中...' : '暂无可用服务器'"
|
||||||
|
:default-sort="{ prop: 'last_response_time', order: 'ascending' }"
|
||||||
|
@select-all="handleSelectChange"
|
||||||
|
@select="handleSelectChange"
|
||||||
|
@row-click="handleRowClick"
|
||||||
|
>
|
||||||
|
<ElTableColumn
|
||||||
|
type="selection"
|
||||||
|
width="55"
|
||||||
|
/>
|
||||||
|
<ElTableColumn
|
||||||
|
prop="name"
|
||||||
|
label="服务器名称"
|
||||||
|
width="200"
|
||||||
|
show-overflow-tooltip
|
||||||
|
sortable
|
||||||
|
/>
|
||||||
|
<ElTableColumn
|
||||||
|
prop="protocol"
|
||||||
|
label="协议"
|
||||||
|
width="80"
|
||||||
|
sortable
|
||||||
|
>
|
||||||
|
<template #default="{ row }">
|
||||||
|
<ElTag
|
||||||
|
:type="row.protocol === 'tcp' ? 'success' : 'warning'"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
{{ row.protocol.toUpperCase() }}
|
||||||
|
</ElTag>
|
||||||
|
</template>
|
||||||
|
</ElTableColumn>
|
||||||
|
<ElTableColumn
|
||||||
|
prop="address"
|
||||||
|
label="地址"
|
||||||
|
width="200"
|
||||||
|
show-overflow-tooltip
|
||||||
|
sortable
|
||||||
|
/>
|
||||||
|
<ElTableColumn
|
||||||
|
prop="last_response_time"
|
||||||
|
label="响应时间"
|
||||||
|
width="100"
|
||||||
|
sortable
|
||||||
|
>
|
||||||
|
<template #default="{ row }">
|
||||||
|
<ElTag
|
||||||
|
:type="getResponseTimeType(row.last_response_time)"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
{{ Number(row.last_response_time / 1000).toFixed(2) }}ms
|
||||||
|
</ElTag>
|
||||||
|
</template>
|
||||||
|
</ElTableColumn>
|
||||||
|
<ElTableColumn
|
||||||
|
prop="current_health_status"
|
||||||
|
label="状态/健康率"
|
||||||
|
width="120"
|
||||||
|
sortable
|
||||||
|
>
|
||||||
|
<template #default="{ row }">
|
||||||
|
<div class="flex flex-col gap-1">
|
||||||
|
<ElTag
|
||||||
|
:type="row.current_health_status === 'healthy' ? 'success' : 'danger'"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
{{ row.current_health_status === "healthy" ? "健康" : "异常" }}
|
||||||
|
</ElTag>
|
||||||
|
<ElTag
|
||||||
|
:type="getHealthType(row.health_percentage_24h)"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
{{ Number(row.health_percentage_24h).toFixed(1) }}%
|
||||||
|
</ElTag>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</ElTableColumn>
|
||||||
|
<ElTableColumn
|
||||||
|
prop="usage_percentage"
|
||||||
|
label="使用率"
|
||||||
|
width="100"
|
||||||
|
sortable
|
||||||
|
>
|
||||||
|
<template #default="{ row }">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<ElProgress
|
||||||
|
:percentage="row.usage_percentage"
|
||||||
|
:stroke-width="6"
|
||||||
|
:show-text="false"
|
||||||
|
:color="getUsageColor(row.usage_percentage)"
|
||||||
|
class="mr-2 flex-1"
|
||||||
|
/>
|
||||||
|
<span class="text-xs">{{ row.usage_percentage.toFixed(1) }}%</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</ElTableColumn>
|
||||||
|
<ElTableColumn
|
||||||
|
prop="description"
|
||||||
|
label="描述"
|
||||||
|
sortable
|
||||||
|
>
|
||||||
|
<template #default="{ row }">
|
||||||
|
<div class="whitespace-pre-wrap">{{ row.description }}</div>
|
||||||
|
</template>
|
||||||
|
</ElTableColumn>
|
||||||
|
</ElTable>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import useMainStore from "@/stores/index";
|
||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
import { reactive, onMounted, onBeforeUnmount, ref, useTemplateRef, computed, nextTick } from "vue";
|
||||||
|
import { ElMessage, type TableInstance } from "element-plus";
|
||||||
|
import { dataSubscribe } from "~/composables/windows";
|
||||||
|
import { inputBounceRef } from "@/utils";
|
||||||
|
import { uniq } from "lodash-es";
|
||||||
|
|
||||||
|
const mainStore = useMainStore();
|
||||||
|
// 节点数据
|
||||||
|
const nodes = reactive<NodeItem[]>([]);
|
||||||
|
const loading = ref(false);
|
||||||
|
const lastUpdateTime = ref("");
|
||||||
|
const selectedNodes = ref<NodeItem[]>([]);
|
||||||
|
const searchName = ref<string>("");
|
||||||
|
const computedNodes = computed(() => {
|
||||||
|
const v = searchName.value.trim();
|
||||||
|
let result = nodes;
|
||||||
|
if (v) {
|
||||||
|
result = nodes.filter(node => node.name.includes(v) || node.address.includes(v));
|
||||||
|
}
|
||||||
|
nextTick(() => {
|
||||||
|
for (const node of selectedNodes.value) {
|
||||||
|
const nodeItem = nodes?.find(n => n.id === node.id);
|
||||||
|
tableRef.value?.toggleRowSelection(nodeItem, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
const tableRef = useTemplateRef<TableInstance>("tableRef");
|
||||||
|
|
||||||
|
// 定时器
|
||||||
|
let refreshTimer: number | null = null;
|
||||||
|
|
||||||
|
// 获取使用率颜色
|
||||||
|
const getUsageColor = (percentage: number) => {
|
||||||
|
if (percentage < 50) return "#67c23a";
|
||||||
|
if (percentage < 80) return "#e6a23c";
|
||||||
|
return "#f56c6c";
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取响应时间类型
|
||||||
|
const getResponseTimeType = (responseTime: number) => {
|
||||||
|
if (responseTime < 60 * 1000) return "success";
|
||||||
|
if (responseTime < 100 * 1000) return "warning";
|
||||||
|
return "danger";
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取健康率类型
|
||||||
|
const getHealthType = (health: number) => {
|
||||||
|
if (health >= 95) return "success";
|
||||||
|
if (health >= 90) return "warning";
|
||||||
|
return "danger";
|
||||||
|
};
|
||||||
|
|
||||||
|
// 刷新节点数据
|
||||||
|
const refreshNodes = async () => {
|
||||||
|
loading.value = true;
|
||||||
|
let nodesList = await invoke<string>("fetch_nodes_list", { page: 1, limit: 1000 });
|
||||||
|
try {
|
||||||
|
if (nodesList === "_EasytierGameFetchNodesError_") {
|
||||||
|
nodesList = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (nodesList) {
|
||||||
|
const nodesListData: NodesResponse = JSON.parse(nodesList);
|
||||||
|
// console.log(nodesListData);
|
||||||
|
if (nodesListData.success && nodesListData.data.items) {
|
||||||
|
// 过滤可用节点
|
||||||
|
const availableNodes = filterAvailableNodes(nodesListData.data.items);
|
||||||
|
// 按优先级排序
|
||||||
|
const sortedNodes = sortNodesByPriority(availableNodes);
|
||||||
|
|
||||||
|
// 更新节点数据
|
||||||
|
nodes.splice(0, nodes.length, ...sortedNodes);
|
||||||
|
|
||||||
|
// 更新最后更新时间
|
||||||
|
lastUpdateTime.value = new Date().toLocaleTimeString();
|
||||||
|
|
||||||
|
// console.log(`已更新 ${sortedNodes.length} 个可用节点`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log(nodesList);
|
||||||
|
console.error("获取节点数据失败:", err);
|
||||||
|
ElMessage.error("获取节点数据失败");
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 过滤可用节点的函数
|
||||||
|
const filterAvailableNodes = (nodes: NodeItem[]): NodeItem[] => {
|
||||||
|
return nodes.filter(node => {
|
||||||
|
// 基本条件:节点必须激活且被批准
|
||||||
|
if (!node.is_active || !node.is_approved) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 健康状态检查
|
||||||
|
if (node.current_health_status !== "healthy") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用率检查:使用率不能超过95%
|
||||||
|
if (node.usage_percentage > 95) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 24小时健康率检查:必须大于90%
|
||||||
|
if (node.health_percentage_24h < 90) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 响应时间检查:响应时间不能超过60秒
|
||||||
|
if (node.last_response_time > 60000) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 连接数检查:当前连接数不能超过最大连接数的90%
|
||||||
|
if (node.current_connections > node.max_connections * 0.9) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 必须有有效的地址
|
||||||
|
if (!node.address || !node.host || !node.port) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 按优先级排序节点的函数
|
||||||
|
const sortNodesByPriority = (nodes: NodeItem[]): NodeItem[] => {
|
||||||
|
return nodes.sort((a, b) => {
|
||||||
|
// 优先级排序规则:
|
||||||
|
// 1. 响应时间越短越好
|
||||||
|
// 2. 使用率越低越好
|
||||||
|
// 3. 24小时健康率越高越好
|
||||||
|
// 4. 当前连接数越少越好
|
||||||
|
|
||||||
|
// 响应时间权重最高
|
||||||
|
const responseTimeDiff = a.last_response_time - b.last_response_time;
|
||||||
|
if (Math.abs(responseTimeDiff) > 1000) {
|
||||||
|
// 如果响应时间差异超过1秒
|
||||||
|
return responseTimeDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用率权重次之
|
||||||
|
const usageDiff = a.usage_percentage - b.usage_percentage;
|
||||||
|
if (Math.abs(usageDiff) > 5) {
|
||||||
|
// 如果使用率差异超过5%
|
||||||
|
return usageDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 24小时健康率
|
||||||
|
const healthDiff = b.health_percentage_24h - a.health_percentage_24h;
|
||||||
|
if (Math.abs(healthDiff) > 1) {
|
||||||
|
// 如果健康率差异超过1%
|
||||||
|
return healthDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 当前连接数
|
||||||
|
return a.current_connections - b.current_connections;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 启动定时器
|
||||||
|
const startRefreshTimer = () => {
|
||||||
|
refreshTimer = setInterval(() => {
|
||||||
|
refreshNodes();
|
||||||
|
}, 60000); // 10秒刷新一次
|
||||||
|
};
|
||||||
|
|
||||||
|
// 停止定时器
|
||||||
|
const stopRefreshTimer = () => {
|
||||||
|
if (refreshTimer) {
|
||||||
|
clearInterval(refreshTimer);
|
||||||
|
refreshTimer = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 处理选择变化
|
||||||
|
const handleSelectChange = (selection: NodeItem[]) => {
|
||||||
|
selectedNodes.value = selection;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleRowClick = (row: NodeItem) => {
|
||||||
|
tableRef.value?.toggleRowSelection(row);
|
||||||
|
selectedNodes.value = tableRef.value?.getSelectionRows() || [];
|
||||||
|
};
|
||||||
|
|
||||||
|
// 添加选中的服务器到主页面服务器列表
|
||||||
|
const addSelectedToServerList = async () => {
|
||||||
|
if (selectedNodes.value.length === 0) {
|
||||||
|
ElMessage.warning("请先选择要添加的服务器");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 提取服务器地址(去掉协议前缀)
|
||||||
|
const protocols = selectedNodes.value.map(node => node.protocol.toLowerCase());
|
||||||
|
const serverAddresses = selectedNodes.value.map(node => node.address.replace(`${node.protocol}://`, ""));
|
||||||
|
mainStore.basePeers = uniq([...mainStore.basePeers, ...serverAddresses]);
|
||||||
|
mainStore.config.serverUrl = uniq([...serverAddresses, ...mainStore.config.serverUrl]);
|
||||||
|
mainStore.config.protocol = uniq([...protocols, ...mainStore.config.protocol]);
|
||||||
|
ElMessage.success(`${selectedNodes.value.length} 个服务器,添加成功`);
|
||||||
|
|
||||||
|
// 清空选择
|
||||||
|
tableRef.value?.clearSelection();
|
||||||
|
selectedNodes.value = [];
|
||||||
|
} catch (err) {
|
||||||
|
console.error("处理选中服务器失败:", err);
|
||||||
|
ElMessage.error("处理选中服务器失败");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
// 初始加载数据
|
||||||
|
await refreshNodes();
|
||||||
|
// 启动定时器
|
||||||
|
startRefreshTimer();
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
// 清理定时器
|
||||||
|
stopRefreshTimer();
|
||||||
|
});
|
||||||
|
|
||||||
|
dataSubscribe();
|
||||||
|
</script>
|
||||||
+86
-8
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col gap-[10px] h-full">
|
<div class="flex h-full flex-col gap-[10px]">
|
||||||
<ElForm
|
<ElForm
|
||||||
size="small"
|
size="small"
|
||||||
label-position="top"
|
label-position="top"
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
<ElFormItem
|
<ElFormItem
|
||||||
label="白名单"
|
label="白名单"
|
||||||
prop="ServerWhiteList"
|
prop="ServerWhiteList"
|
||||||
class="full-label full-content overflow-hidden !flex flex-col h-full !mb-[0]"
|
class="full-label full-content !mb-[0] !flex h-full flex-col overflow-hidden"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
<div class="flex items-center gap-[10px]">
|
<div class="flex items-center gap-[10px]">
|
||||||
@@ -31,7 +31,12 @@
|
|||||||
placement="top"
|
placement="top"
|
||||||
content="启用后,不允许使用了与本网络不同的房间名和密码的节点通过本节点进行握手或中转"
|
content="启用后,不允许使用了与本网络不同的房间名和密码的节点通过本节点进行握手或中转"
|
||||||
>
|
>
|
||||||
<ElCheckbox v-model="mainStore.serverConfig.privateMode">私有模式</ElCheckbox>
|
<ElCheckbox
|
||||||
|
@click.stop="handlePrivateModeClick"
|
||||||
|
:model-value="mainStore.serverConfig.privateMode"
|
||||||
|
>
|
||||||
|
私有模式
|
||||||
|
</ElCheckbox>
|
||||||
</ElTooltip>
|
</ElTooltip>
|
||||||
<ElTooltip
|
<ElTooltip
|
||||||
placement="top"
|
placement="top"
|
||||||
@@ -42,7 +47,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<div class="h-full w-full flex flex-col overflow-hidden">
|
<div class="flex h-full w-full flex-col overflow-hidden">
|
||||||
<div class="flex-1 overflow-auto">
|
<div class="flex-1 overflow-auto">
|
||||||
<ElInput
|
<ElInput
|
||||||
:disabled="!mainStore.serverConfig.enableWhiteList"
|
:disabled="!mainStore.serverConfig.enableWhiteList"
|
||||||
@@ -76,6 +81,58 @@
|
|||||||
</ElButton>
|
</ElButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<ElDialog
|
||||||
|
v-model="privateModeDialogData.visible"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:close-on-press-escape="false"
|
||||||
|
title="私有模式"
|
||||||
|
:show-close="false"
|
||||||
|
width="300px"
|
||||||
|
>
|
||||||
|
<ElAlert
|
||||||
|
type="primary"
|
||||||
|
:closable="false"
|
||||||
|
>
|
||||||
|
建议为服务器设置一个房间名和密码
|
||||||
|
</ElAlert>
|
||||||
|
<div class="h-[15px]"></div>
|
||||||
|
<ElForm
|
||||||
|
:model="mainStore.serverConfig"
|
||||||
|
label-position="top"
|
||||||
|
>
|
||||||
|
<ElFormItem
|
||||||
|
label="房间名"
|
||||||
|
prop="privateNetworkName"
|
||||||
|
>
|
||||||
|
<ElInput
|
||||||
|
clearable
|
||||||
|
placeholder="请输入房间名 (默认为default)"
|
||||||
|
v-model="mainStore.serverConfig.privateNetworkName"
|
||||||
|
></ElInput>
|
||||||
|
</ElFormItem>
|
||||||
|
<ElFormItem
|
||||||
|
label="密码"
|
||||||
|
prop="privateNetworkPassword"
|
||||||
|
>
|
||||||
|
<ElInput
|
||||||
|
clearable
|
||||||
|
type="password"
|
||||||
|
show-password
|
||||||
|
placeholder="请输入密码 (可选)"
|
||||||
|
v-model="mainStore.serverConfig.privateNetworkPassword"
|
||||||
|
></ElInput>
|
||||||
|
</ElFormItem>
|
||||||
|
</ElForm>
|
||||||
|
<template #footer>
|
||||||
|
<ElButton
|
||||||
|
type="primary"
|
||||||
|
@click="handlePrivateModeDialogConfirm"
|
||||||
|
>
|
||||||
|
继续启用
|
||||||
|
</ElButton>
|
||||||
|
</template>
|
||||||
|
</ElDialog>
|
||||||
|
|
||||||
<ElInput
|
<ElInput
|
||||||
placeholder="服务器日志"
|
placeholder="服务器日志"
|
||||||
:model-value="data.log"
|
:model-value="data.log"
|
||||||
@@ -87,13 +144,14 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import useMainStore from "@/stores/index";
|
import useMainStore from "@/stores/index";
|
||||||
import { reactive, onMounted, onBeforeUnmount } from "vue";
|
import { reactive, onMounted, onBeforeUnmount, useTemplateRef, nextTick } from "vue";
|
||||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||||
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
|
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
|
||||||
import { getServerArgs } from "@/composables/server";
|
import { getServerArgs } from "@/composables/server";
|
||||||
import { dataSubscribe } from "@/composables/windows";
|
import { dataSubscribe } from "@/composables/windows";
|
||||||
|
import { ElMessage, type FormInstance } from "element-plus";
|
||||||
|
|
||||||
const appWindow = getCurrentWindow();
|
const appWindow = getCurrentWindow();
|
||||||
const mainStore = useMainStore();
|
const mainStore = useMainStore();
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
log: "",
|
log: "",
|
||||||
@@ -125,10 +183,30 @@
|
|||||||
|
|
||||||
const hanldeClickStart = async () => {
|
const hanldeClickStart = async () => {
|
||||||
data.loading = true;
|
data.loading = true;
|
||||||
const args = getServerArgs();
|
const args = getServerArgs();
|
||||||
await appWindow.emitTo("main", "startStopServer", { args });
|
await appWindow.emitTo("main", "startStopServer", { args });
|
||||||
};
|
};
|
||||||
|
|
||||||
dataSubscribe();
|
// const privateModeDialogFormEl = useTemplateRef<FormInstance>("privateModeDialogFormRef");
|
||||||
|
|
||||||
|
const privateModeDialogData = reactive({
|
||||||
|
visible: false
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const handlePrivateModeClick = async () => {
|
||||||
|
if (mainStore.serverConfig.privateMode) {
|
||||||
|
mainStore.serverConfig.privateMode = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
privateModeDialogData.visible = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePrivateModeDialogConfirm = async () => {
|
||||||
|
privateModeDialogData.visible = false;
|
||||||
|
mainStore.serverConfig.privateMode = true;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
dataSubscribe();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
+5
-5
@@ -10,7 +10,7 @@
|
|||||||
name="netcard"
|
name="netcard"
|
||||||
class="flex h-full flex-col"
|
class="flex h-full flex-col"
|
||||||
>
|
>
|
||||||
<div>
|
<!-- <div>
|
||||||
<div>
|
<div>
|
||||||
<ElTooltip
|
<ElTooltip
|
||||||
content="找不到游戏房间时,就开启它后再尝试搜索房间(默认开启)
|
content="找不到游戏房间时,就开启它后再尝试搜索房间(默认开启)
|
||||||
@@ -39,13 +39,13 @@
|
|||||||
active-text="已开启"
|
active-text="已开启"
|
||||||
inactive-text="已关闭"
|
inactive-text="已关闭"
|
||||||
></ElSwitch>
|
></ElSwitch>
|
||||||
</div>
|
</div> -->
|
||||||
<div>
|
<div>
|
||||||
<ElTooltip
|
<ElTooltip
|
||||||
content="使用ForceBindIP启动应用 (强制绑定IP或者网卡),如果还没有启动联机,请先启动联机,联机成功后,点击刷新获取easytier生成的网卡"
|
content="使用ForceBindIP启动应用 (强制绑定IP或者网卡),如果还没有启动联机,请先启动联机,联机成功后,点击刷新获取easytier生成的网卡"
|
||||||
>
|
>
|
||||||
<ElText>
|
<ElText>
|
||||||
方案2
|
方案1
|
||||||
<ElIcon class="ml-[3px]"><QuestionFilled /></ElIcon>
|
<ElIcon class="ml-[3px]"><QuestionFilled /></ElIcon>
|
||||||
</ElText>
|
</ElText>
|
||||||
</ElTooltip>
|
</ElTooltip>
|
||||||
@@ -131,7 +131,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<ElTooltip content="设置网卡的跃点,提升网卡优先级,尝试将您联机使用的网卡跃点设置为最小,请先查询网卡信息">
|
<ElTooltip content="设置网卡的跃点,提升网卡优先级,尝试将您联机使用的网卡跃点设置为最小,请先查询网卡信息">
|
||||||
<ElText>
|
<ElText>
|
||||||
方案3
|
方案2
|
||||||
<ElIcon class="ml-[3px]"><QuestionFilled /></ElIcon>
|
<ElIcon class="ml-[3px]"><QuestionFilled /></ElIcon>
|
||||||
</ElText>
|
</ElText>
|
||||||
</ElTooltip>
|
</ElTooltip>
|
||||||
@@ -502,7 +502,7 @@
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
data.pingIp = mainStore.config.ipv4;
|
data.pingIp = mainStore.config.ipv4;
|
||||||
initStartWinIpBroadcast();
|
// initStartWinIpBroadcast();
|
||||||
getGuids();
|
getGuids();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Generated
+3209
-4974
File diff suppressed because it is too large
Load Diff
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "../.nuxt/tsconfig.server.json"
|
|
||||||
}
|
|
||||||
Generated
+1523
-1687
File diff suppressed because it is too large
Load Diff
+12
-12
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "easytier-game"
|
name = "easytier-game"
|
||||||
version = "1.4.6"
|
version = "1.5.3"
|
||||||
homepage = "https://github.com/EasyTier/EasyTier"
|
homepage = "https://github.com/EasyTier/EasyTier"
|
||||||
repository = "https://github.com/EasyTier/EasytierGame"
|
repository = "https://github.com/EasyTier/EasytierGame"
|
||||||
description = "A simple network initiator based on Easytier"
|
description = "A simple network initiator based on Easytier"
|
||||||
@@ -18,7 +18,7 @@ name = "app_lib"
|
|||||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-build = { version = "2.2.0", features = [] }
|
tauri-build = { version = "2.5.3", features = [] }
|
||||||
# prost-build = "0.13.2"
|
# prost-build = "0.13.2"
|
||||||
|
|
||||||
[target.x86_64-pc-windows-msvc.build-dependencies]
|
[target.x86_64-pc-windows-msvc.build-dependencies]
|
||||||
@@ -28,34 +28,34 @@ thunk-rs = { git = "https://github.com/easytier/thunk.git", default-features = f
|
|||||||
serde_json = "1.0.137"
|
serde_json = "1.0.137"
|
||||||
serde = { version = "1.0.217", features = ["derive"] }
|
serde = { version = "1.0.217", features = ["derive"] }
|
||||||
log = "0.4.26"
|
log = "0.4.26"
|
||||||
tauri = { version = "2.5.1", features = [ "protocol-asset",
|
tauri = { version = "2.9.5", features = [ "protocol-asset",
|
||||||
"tray-icon",
|
"tray-icon",
|
||||||
"image-png",
|
"image-png",
|
||||||
"image-ico"
|
"image-ico"
|
||||||
] }
|
] }
|
||||||
|
|
||||||
tauri-plugin-log = "2.3.1"
|
tauri-plugin-log = "2.7.1"
|
||||||
tauri-plugin-shell = "2.2.1"
|
tauri-plugin-shell = "2.3.3"
|
||||||
reqwest = { version = "0.12.12", features = ["json"] }
|
reqwest = { version = "0.12.12", features = ["json"] }
|
||||||
zip = "2.2.3"
|
zip = "2.2.3"
|
||||||
sysinfo = '0.33.1'
|
sysinfo = '0.33.1'
|
||||||
# planif = { git = "https://github.com/mattrobineau/planif", tag = "1.0.1" }
|
# planif = { git = "https://github.com/mattrobineau/planif", tag = "1.0.1" }
|
||||||
whoami = "1.5.2"
|
whoami = "1.5.2"
|
||||||
tauri-plugin-fs = "2.3.0"
|
tauri-plugin-fs = "2.4.4"
|
||||||
tauri-plugin-clipboard-manager = "2.2.2"
|
tauri-plugin-clipboard-manager = "2.3.2"
|
||||||
rand = "0.9.0"
|
rand = "0.9.0"
|
||||||
tokio = { version = "1.45.1", features = ["process"] }
|
tokio = { version = "1.45.1", features = ["process"] }
|
||||||
tauri-plugin-dialog = "2.2.2"
|
tauri-plugin-dialog = "2.4.0"
|
||||||
# prost = "0.13"
|
# prost = "0.13"
|
||||||
# prost-types = "0.13"
|
# prost-types = "0.13"
|
||||||
hashbrown = "0.15.2"
|
hashbrown = "0.15.2"
|
||||||
# futures-util = "0.3"
|
# futures-util = "0.3"
|
||||||
|
|
||||||
[dependencies.windows]
|
[dependencies.windows]
|
||||||
version = "0.58.0"
|
version = "0.61.3"
|
||||||
features = ["Win32_System_TaskScheduler", "Win32_System_Com", "Win32_System_Power", "Win32_NetworkManagement_IpHelper", "Win32_NetworkManagement_Ndis", "Win32_Networking_WinSock"]
|
features = ["Win32_System_TaskScheduler", "Win32_System_Com", "Win32_System_Power", "Win32_NetworkManagement_IpHelper", "Win32_NetworkManagement_Ndis", "Win32_Networking_WinSock"]
|
||||||
|
|
||||||
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
|
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
|
||||||
tauri-plugin-cli = "2.2.0"
|
tauri-plugin-cli = "2.4.1"
|
||||||
tauri-plugin-single-instance = "2.2.4"
|
tauri-plugin-single-instance = "2.3.6"
|
||||||
tauri-plugin-window-state = "2.2.2"
|
tauri-plugin-window-state = "2.4.1"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "../gen/schemas/desktop-schema.json",
|
"$schema": "../gen/schemas/desktop-schema.json",
|
||||||
"identifier": "default",
|
"identifier": "default",
|
||||||
"description": "enables the default permissions",
|
"description": "enables the default permissions",
|
||||||
"windows": ["main", "log", "member", "cidr", "advance", "tool", "server", "gameList", "storage-listener"],
|
"windows": ["main", "log", "member", "nodesList", "cidr", "advance", "tool", "server", "gameList", "storage-listener"],
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"core:default",
|
"core:default",
|
||||||
"core:window:allow-minimize",
|
"core:window:allow-minimize",
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
"core:tray:allow-get-by-id",
|
"core:tray:allow-get-by-id",
|
||||||
"core:tray:allow-set-icon",
|
"core:tray:allow-set-icon",
|
||||||
"core:tray:allow-new",
|
"core:tray:allow-new",
|
||||||
|
"core:window:allow-set-size",
|
||||||
{
|
{
|
||||||
"identifier": "shell:allow-spawn",
|
"identifier": "shell:allow-spawn",
|
||||||
"allow": [
|
"allow": [
|
||||||
|
|||||||
@@ -9,16 +9,19 @@
|
|||||||
"enableCustomListener": true,
|
"enableCustomListener": true,
|
||||||
"customListenerData": [
|
"customListenerData": [
|
||||||
"tcp://0.0.0.0:11010",
|
"tcp://0.0.0.0:11010",
|
||||||
"udp://0.0.0.0:11010",
|
"udp://0.0.0.0:11010"
|
||||||
"tcp://[::]:11010"
|
|
||||||
],
|
],
|
||||||
"networkName": "", //房间名
|
"networkName": "", //房间名
|
||||||
"networkPassword": "", //房间密码
|
"networkPassword": "", //房间密码
|
||||||
"hostname": "", //主机名
|
"hostname": "", //主机名
|
||||||
"ipv4": "", // 虚拟IP地址
|
"ipv4": "", // 虚拟IPv4地址
|
||||||
|
"ipv6": "", // 虚拟IPv6地址
|
||||||
|
"tcpWhitelistEnable": false, // 启用TCP白名单
|
||||||
|
"udpWhitelistEnable": false, // 启用UDP白名单
|
||||||
|
"tcpWhitelist": "", // TCP端口白名单,格式为 "80" 或者 范围 "8000-9000"
|
||||||
|
"udpWhitelist": "", // UDP端口白名单,格式为 "53" 或者 范围 "5000-6000"
|
||||||
|
"connectAfterStart": false, // 启动后自动连接
|
||||||
"disableIpv6": false, // 禁用ipv6
|
"disableIpv6": false, // 禁用ipv6
|
||||||
"enableCustomListenerV6": true, // 启用ipv6监听
|
|
||||||
"customListenerV6Data": "udp://[::]:11010", // ipv6监听地址
|
|
||||||
"disbleListenner": false, // 禁用监听
|
"disbleListenner": false, // 禁用监听
|
||||||
"disableEncryption": false, // 禁用加密
|
"disableEncryption": false, // 禁用加密
|
||||||
"enablExitNode": false, // 启用出口节点
|
"enablExitNode": false, // 启用出口节点
|
||||||
@@ -35,7 +38,9 @@
|
|||||||
"netCardMetricValue": 1, // 网卡跃点
|
"netCardMetricValue": 1, // 网卡跃点
|
||||||
"enablePreventSleep": false, // 启用防止睡眠
|
"enablePreventSleep": false, // 启用防止睡眠
|
||||||
"compression": "none", // 压缩算法
|
"compression": "none", // 压缩算法
|
||||||
"enableKcpProxy": true, // 启用kcp代理
|
"enableKcpProxy": true, // 启用kcp代理,就不能启用quic代理
|
||||||
"disableKcpInput": false, // 禁用kcp输入
|
"disableKcpInput": false, // 禁用kcp输入
|
||||||
|
"enableQuicProxy": false, // 启用quic代理,就不能启用kcp代理
|
||||||
|
"disableQuicInput": false, // 禁用quic输入
|
||||||
"privateMode": false // 启用私有模式
|
"privateMode": false // 启用私有模式
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
+144
-63
@@ -1,7 +1,7 @@
|
|||||||
use reqwest::{Client, Error};
|
use reqwest::{Client, Error};
|
||||||
// use futures_util::StreamExt;
|
// use futures_util::StreamExt;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize};
|
||||||
use std::collections::HashMap;
|
// use std::collections::HashMap;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io::{BufRead, BufReader, Write};
|
use std::io::{BufRead, BufReader, Write};
|
||||||
use std::os::windows::process::CommandExt;
|
use std::os::windows::process::CommandExt;
|
||||||
@@ -13,7 +13,7 @@ use sysinfo::System;
|
|||||||
use tauri::tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent};
|
use tauri::tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent};
|
||||||
use tauri::Emitter;
|
use tauri::Emitter;
|
||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
use windows::core::{Interface, BSTR, VARIANT};
|
use windows::core::{Interface, BSTR};
|
||||||
use windows::Win32::Foundation::VARIANT_BOOL;
|
use windows::Win32::Foundation::VARIANT_BOOL;
|
||||||
use windows::Win32::NetworkManagement::IpHelper::{
|
use windows::Win32::NetworkManagement::IpHelper::{
|
||||||
GetAdaptersAddresses, GAA_FLAG_INCLUDE_PREFIX, IP_ADAPTER_ADDRESSES_LH,
|
GetAdaptersAddresses, GAA_FLAG_INCLUDE_PREFIX, IP_ADAPTER_ADDRESSES_LH,
|
||||||
@@ -21,6 +21,7 @@ use windows::Win32::NetworkManagement::IpHelper::{
|
|||||||
use windows::Win32::Networking::WinSock::AF_UNSPEC;
|
use windows::Win32::Networking::WinSock::AF_UNSPEC;
|
||||||
use windows::Win32::System::Com::*;
|
use windows::Win32::System::Com::*;
|
||||||
use windows::Win32::System::TaskScheduler::*;
|
use windows::Win32::System::TaskScheduler::*;
|
||||||
|
use windows::Win32::System::Variant::VARIANT;
|
||||||
// use std::ffi::CStr;
|
// use std::ffi::CStr;
|
||||||
|
|
||||||
use windows::Win32::System::Power::SetThreadExecutionState;
|
use windows::Win32::System::Power::SetThreadExecutionState;
|
||||||
@@ -236,42 +237,13 @@ fn get_tool_exe_path(path: &str) -> String {
|
|||||||
return tool_path;
|
return tool_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
|
||||||
struct RoutePeerInfo {
|
|
||||||
peer_id: u64,
|
|
||||||
cost: u64,
|
|
||||||
hostname: Option<String>,
|
|
||||||
udp_stun_info: String,
|
|
||||||
easytier_version: String,
|
|
||||||
network_length: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
|
||||||
struct RouteTable {
|
|
||||||
peer_infos: HashMap<u32, RoutePeerInfo>,
|
|
||||||
ipv4_peer_id_map: HashMap<String, u64>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
|
||||||
struct PeerRouteServiceImpl {
|
|
||||||
route_table_with_cost: RouteTable,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
|
||||||
struct PeerRoute {
|
|
||||||
my_peer_id: u64,
|
|
||||||
service_impl: PeerRouteServiceImpl,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
|
||||||
struct MyResponse {
|
|
||||||
response: PeerRoute,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tauri::command(rename_all = "snake_case")]
|
#[tauri::command(rename_all = "snake_case")]
|
||||||
async fn get_members_by_cli() -> String {
|
async fn get_members_by_cli() -> String {
|
||||||
let cli_path = get_tool_exe_path("\\easytier\\easytier-cli.exe");
|
let cli_path = get_tool_exe_path("\\easytier\\easytier-cli.exe");
|
||||||
match tokioCommand::new(&cli_path)
|
match tokioCommand::new(&cli_path)
|
||||||
|
.arg("-o")
|
||||||
|
.arg("json")
|
||||||
.arg("peer")
|
.arg("peer")
|
||||||
.arg("list")
|
.arg("list")
|
||||||
.creation_flags(0x08000000)
|
.creation_flags(0x08000000)
|
||||||
@@ -295,10 +267,69 @@ async fn get_members_by_cli() -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command(rename_all = "snake_case")]
|
||||||
|
async fn get_members_proxy() -> String {
|
||||||
|
let cli_path = get_tool_exe_path("\\easytier\\easytier-cli.exe");
|
||||||
|
match tokioCommand::new(&cli_path)
|
||||||
|
.arg("-o")
|
||||||
|
.arg("json")
|
||||||
|
.arg("proxy")
|
||||||
|
.creation_flags(0x08000000)
|
||||||
|
.output()
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(output) => {
|
||||||
|
if output.status.success() {
|
||||||
|
let output_str = String::from_utf8_lossy(&output.stdout);
|
||||||
|
return output_str.trim().to_string();
|
||||||
|
} else {
|
||||||
|
let output_str = String::from_utf8_lossy(&output.stderr);
|
||||||
|
log::error!("{}", output_str.trim().to_string());
|
||||||
|
return "_EasytierGameCliFailedToGetProxy_".to_string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(_e) => {
|
||||||
|
log::error!("get member list error");
|
||||||
|
return "".to_string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command(rename_all = "snake_case")]
|
||||||
|
async fn get_members_connections_cli() -> String {
|
||||||
|
let cli_path = get_tool_exe_path("\\easytier\\easytier-cli.exe");
|
||||||
|
match tokioCommand::new(&cli_path)
|
||||||
|
.arg("-v")
|
||||||
|
.arg("-o")
|
||||||
|
.arg("json")
|
||||||
|
.arg("peer")
|
||||||
|
.creation_flags(0x08000000)
|
||||||
|
.output()
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(output) => {
|
||||||
|
if output.status.success() {
|
||||||
|
let output_str = String::from_utf8_lossy(&output.stdout);
|
||||||
|
return output_str.trim().to_string();
|
||||||
|
} else {
|
||||||
|
let output_str = String::from_utf8_lossy(&output.stderr);
|
||||||
|
log::error!("{}", output_str.trim().to_string());
|
||||||
|
return "_EasytierGameCliFailedToGetConnections_".to_string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(_e) => {
|
||||||
|
log::error!("get member list error");
|
||||||
|
return "".to_string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command(rename_all = "snake_case")]
|
#[tauri::command(rename_all = "snake_case")]
|
||||||
async fn get_route_by_cli() -> String {
|
async fn get_route_by_cli() -> String {
|
||||||
let cli_path = get_tool_exe_path("\\easytier\\easytier-cli.exe");
|
let cli_path = get_tool_exe_path("\\easytier\\easytier-cli.exe");
|
||||||
match tokioCommand::new(&cli_path)
|
match tokioCommand::new(&cli_path)
|
||||||
|
.arg("-o")
|
||||||
|
.arg("json")
|
||||||
.arg("route")
|
.arg("route")
|
||||||
.creation_flags(0x08000000)
|
.creation_flags(0x08000000)
|
||||||
.output()
|
.output()
|
||||||
@@ -322,7 +353,44 @@ async fn get_route_by_cli() -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command(rename_all = "snake_case")]
|
#[tauri::command(rename_all = "snake_case")]
|
||||||
async fn download_easytier_zip(app_handle: tauri::AppHandle ,download_url: String, file_name: String) {
|
async fn fetch_nodes_list(page: u64, limit: u64) -> String {
|
||||||
|
let client = Client::new();
|
||||||
|
let url = format!("https://uptime.easytier.cn/api/nodes?page={}&per_page={}", page, limit);
|
||||||
|
let user_agent = generate_random_user_agent();
|
||||||
|
|
||||||
|
match client
|
||||||
|
.get(url)
|
||||||
|
.header("User-Agent", user_agent)
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(response) => {
|
||||||
|
if response.status().is_success() {
|
||||||
|
match response.text().await {
|
||||||
|
Ok(text) => text,
|
||||||
|
Err(e) => {
|
||||||
|
log::error!("Failed to get response text: {}", e);
|
||||||
|
format!("_EasytierGameFetchNodesError_: {}", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log::error!("HTTP request failed with status: {}", response.status());
|
||||||
|
format!("_EasytierGameFetchNodesError_: HTTP request failed with status: {}", response.status())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::error!("Failed to fetch nodes list: {}", e);
|
||||||
|
format!("_EasytierGameFetchNodesError_: {}", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command(rename_all = "snake_case")]
|
||||||
|
async fn download_easytier_zip(
|
||||||
|
app_handle: tauri::AppHandle,
|
||||||
|
download_url: String,
|
||||||
|
file_name: String,
|
||||||
|
) {
|
||||||
let cache_dir_path = get_tool_exe_path("\\easytier\\cache");
|
let cache_dir_path = get_tool_exe_path("\\easytier\\cache");
|
||||||
let cache_file_name = format!("{}\\{}", cache_dir_path, file_name);
|
let cache_file_name = format!("{}\\{}", cache_dir_path, file_name);
|
||||||
let cache_file_name_path = path::Path::new(&cache_file_name);
|
let cache_file_name_path = path::Path::new(&cache_file_name);
|
||||||
@@ -346,6 +414,12 @@ async fn download_easytier_zip(app_handle: tauri::AppHandle ,download_url: Strin
|
|||||||
|
|
||||||
let path = path::Path::new(&file_path);
|
let path = path::Path::new(&file_path);
|
||||||
println!("download easytier to {}", path.display());
|
println!("download easytier to {}", path.display());
|
||||||
|
if path.exists() {
|
||||||
|
match fs::remove_file(path) {
|
||||||
|
Ok(_) => println!("删除上次下载的Zip文件成功"),
|
||||||
|
Err(_) => log::error!("删除上次下载Zip的文件失败"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut file = match File::create(&path) {
|
let mut file = match File::create(&path) {
|
||||||
Err(why) => panic!("couldn't create {}", why),
|
Err(why) => panic!("couldn't create {}", why),
|
||||||
@@ -355,14 +429,18 @@ async fn download_easytier_zip(app_handle: tauri::AppHandle ,download_url: Strin
|
|||||||
while let Some(item) = response.chunk().await.unwrap() {
|
while let Some(item) = response.chunk().await.unwrap() {
|
||||||
match file.write_all(&item) {
|
match file.write_all(&item) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
app_handle.emit("download_core_progress", [item.len() as u64, context_size]).expect("error to emit download_core_progress");
|
app_handle
|
||||||
},Err(why) => {
|
.emit("download_core_progress", [item.len() as u64, context_size])
|
||||||
|
.expect("error to emit download_core_progress");
|
||||||
|
}
|
||||||
|
Err(why) => {
|
||||||
log::error!("error to write file: {}", why);
|
log::error!("error to write file: {}", why);
|
||||||
app_handle.emit("download_core_progress_error", why.to_string()).expect("error to emit download_core_progress_error");
|
app_handle
|
||||||
return
|
.emit("download_core_progress_error", why.to_string())
|
||||||
|
.expect("error to emit download_core_progress_error");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
println!("下载完成");
|
println!("下载完成");
|
||||||
unzip(path);
|
unzip(path);
|
||||||
@@ -512,18 +590,19 @@ fn stop_command(child_id: u32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command(rename_all = "snake_case")]
|
#[tauri::command(rename_all = "snake_case")]
|
||||||
async fn fetch_easytier_list() -> Vec<Vec<[String; 3]>> {
|
async fn fetch_easytier_list() -> Vec<Vec<[String; 4]>> {
|
||||||
// 获取release列表
|
// 获取release列表
|
||||||
if let Ok(release) = fetch_releases().await {
|
if let Ok(release) = fetch_releases().await {
|
||||||
let mut release_list = Vec::new();
|
let mut release_list: Vec<Vec<[String; 4]>> = Vec::new();
|
||||||
for re in release {
|
for re in release {
|
||||||
let mut assets_list = Vec::new();
|
let mut assets_list: Vec<[String; 4]> = Vec::new();
|
||||||
for asset in re.assets {
|
for asset in re.assets {
|
||||||
if asset.name.contains("windows-x86_64") {
|
if asset.name.contains("windows-x86_64") {
|
||||||
assets_list.push([
|
assets_list.push([
|
||||||
re.tag_name.clone(),
|
re.tag_name.clone(),
|
||||||
asset.name.clone(),
|
asset.name.clone(),
|
||||||
asset.browser_download_url.clone(),
|
asset.browser_download_url.clone(),
|
||||||
|
re.prerelease.to_string(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -642,11 +721,11 @@ fn autostart_enabled() -> Result<bool, Box<dyn std::error::Error>> {
|
|||||||
fn autostart_is_enabled() -> bool {
|
fn autostart_is_enabled() -> bool {
|
||||||
match autostart_enabled() {
|
match autostart_enabled() {
|
||||||
Ok(enabled) => {
|
Ok(enabled) => {
|
||||||
println!("autostart enabled: {}", enabled);
|
// println!("autostart enabled: {}", enabled);
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(_e) => {
|
||||||
log::error!("autostart enabled: false -> {}", e);
|
// log::error!("autostart enabled: false -> {}", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -661,11 +740,11 @@ fn ensure_task_folder_and_cleanup(
|
|||||||
unsafe {
|
unsafe {
|
||||||
let root = BSTR::from("\\");
|
let root = BSTR::from("\\");
|
||||||
let root_folder: ITaskFolder = task_service.GetFolder(&root)?;
|
let root_folder: ITaskFolder = task_service.GetFolder(&root)?;
|
||||||
|
|
||||||
match task_service.GetFolder(folder_path) {
|
match task_service.GetFolder(folder_path) {
|
||||||
Ok(existing_folder) => {
|
Ok(existing_folder) => {
|
||||||
println!("任务文件夹已存在: {}", folder_path);
|
println!("任务文件夹已存在: {}", folder_path);
|
||||||
|
|
||||||
// 检查并清理现有任务
|
// 检查并清理现有任务
|
||||||
if let Ok(_existing_task) = existing_folder.GetTask(task_name) {
|
if let Ok(_existing_task) = existing_folder.GetTask(task_name) {
|
||||||
println!("发现同名任务: {},准备删除", task_name);
|
println!("发现同名任务: {},准备删除", task_name);
|
||||||
@@ -738,23 +817,23 @@ fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error
|
|||||||
&VARIANT::default(),
|
&VARIANT::default(),
|
||||||
&VARIANT::default(),
|
&VARIANT::default(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let folder_path = BSTR::from("\\easytierGame");
|
let folder_path = BSTR::from("\\easytierGame");
|
||||||
let task_name = BSTR::from("auto start");
|
let task_name = BSTR::from("auto start");
|
||||||
|
|
||||||
let task_definition = task_service.NewTask(0)?;
|
let task_definition = task_service.NewTask(0)?;
|
||||||
|
|
||||||
// 设置任务信息
|
// 设置任务信息
|
||||||
let registration_info = task_definition.RegistrationInfo()?;
|
let registration_info = task_definition.RegistrationInfo()?;
|
||||||
registration_info.SetDescription(&BSTR::from("EasytierGame auto start task"))?;
|
registration_info.SetDescription(&BSTR::from("EasytierGame auto start task"))?;
|
||||||
registration_info.SetAuthor(&BSTR::from("EasytierGame"))?;
|
registration_info.SetAuthor(&BSTR::from("EasytierGame"))?;
|
||||||
|
|
||||||
// 改为用户登录触发
|
// 改为用户登录触发
|
||||||
let triggers = task_definition.Triggers()?;
|
let triggers = task_definition.Triggers()?;
|
||||||
let trigger = triggers.Create(TASK_TRIGGER_LOGON)?;
|
let trigger = triggers.Create(TASK_TRIGGER_LOGON)?;
|
||||||
let logon_trigger: ILogonTrigger = trigger.cast()?;
|
let logon_trigger: ILogonTrigger = trigger.cast()?;
|
||||||
logon_trigger.SetEnabled(VARIANT_BOOL::from(true))?;
|
logon_trigger.SetEnabled(VARIANT_BOOL::from(true))?;
|
||||||
|
|
||||||
// 设置动作
|
// 设置动作
|
||||||
let actions = task_definition.Actions()?;
|
let actions = task_definition.Actions()?;
|
||||||
let action = actions.Create(TASK_ACTION_EXEC)?;
|
let action = actions.Create(TASK_ACTION_EXEC)?;
|
||||||
@@ -763,27 +842,26 @@ fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error
|
|||||||
let exe_path: &str = exe.to_str().unwrap();
|
let exe_path: &str = exe.to_str().unwrap();
|
||||||
exec_action.SetPath(&BSTR::from(exe_path))?;
|
exec_action.SetPath(&BSTR::from(exe_path))?;
|
||||||
exec_action.SetArguments(&BSTR::from("--task-auto-start"))?;
|
exec_action.SetArguments(&BSTR::from("--task-auto-start"))?;
|
||||||
|
|
||||||
// 使用当前用户运行
|
// 设置任务权限为当前用户
|
||||||
let principal = task_definition.Principal()?;
|
let principal = task_definition.Principal()?;
|
||||||
principal.SetUserId(&BSTR::from(whoami::username().as_str()))?;
|
principal.SetUserId(&BSTR::from(whoami::username().as_str()))?;
|
||||||
principal.SetLogonType(TASK_LOGON_INTERACTIVE_TOKEN)?;
|
principal.SetLogonType(TASK_LOGON_INTERACTIVE_TOKEN)?;
|
||||||
principal.SetRunLevel(TASK_RUNLEVEL_HIGHEST)?;
|
principal.SetRunLevel(TASK_RUNLEVEL_HIGHEST)?;
|
||||||
|
|
||||||
|
|
||||||
// 设置任务设置
|
// 设置任务设置
|
||||||
let settings = task_definition.Settings()?;
|
let settings = task_definition.Settings()?;
|
||||||
settings.SetEnabled(VARIANT_BOOL::from(true))?;
|
settings.SetEnabled(VARIANT_BOOL::from(true))?;
|
||||||
settings.SetCompatibility(TASK_COMPATIBILITY_V2)?; // Windows 7
|
settings.SetCompatibility(TASK_COMPATIBILITY_V2_1)?; // Windows 7
|
||||||
settings.SetStartWhenAvailable(VARIANT_BOOL::from(true))?;
|
settings.SetStartWhenAvailable(VARIANT_BOOL::from(true))?;
|
||||||
// settings.SetHidden(VARIANT_BOOL::from(true))?; // 注释掉让任务可见
|
// settings.SetHidden(VARIANT_BOOL::from(true))?; // 注释掉让任务可见
|
||||||
settings.SetExecutionTimeLimit(&BSTR::from("PT0S"))?;
|
settings.SetExecutionTimeLimit(&BSTR::from("PT0S"))?;
|
||||||
|
settings.SetDisallowStartIfOnBatteries(VARIANT_BOOL(0))?; // 允许在电池供电时启动
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 获取文件夹并注册任务
|
// 获取文件夹并注册任务
|
||||||
let task_folder = ensure_task_folder_and_cleanup(&task_service, &folder_path, &task_name)?;
|
let task_folder =
|
||||||
|
ensure_task_folder_and_cleanup(&task_service, &folder_path, &task_name)?;
|
||||||
|
|
||||||
let _auto_task = task_folder.RegisterTaskDefinition(
|
let _auto_task = task_folder.RegisterTaskDefinition(
|
||||||
&task_name,
|
&task_name,
|
||||||
&task_definition,
|
&task_definition,
|
||||||
@@ -791,9 +869,9 @@ fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error
|
|||||||
&VARIANT::default(),
|
&VARIANT::default(),
|
||||||
&VARIANT::default(),
|
&VARIANT::default(),
|
||||||
TASK_LOGON_INTERACTIVE_TOKEN,
|
TASK_LOGON_INTERACTIVE_TOKEN,
|
||||||
&VARIANT::default()
|
&VARIANT::default(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -878,7 +956,10 @@ pub fn run() {
|
|||||||
fetch_game_releases,
|
fetch_game_releases,
|
||||||
download_easytier_zip,
|
download_easytier_zip,
|
||||||
get_members_by_cli,
|
get_members_by_cli,
|
||||||
|
get_members_connections_cli,
|
||||||
|
get_members_proxy,
|
||||||
get_route_by_cli,
|
get_route_by_cli,
|
||||||
|
fetch_nodes_list,
|
||||||
search_pid_by_pname,
|
search_pid_by_pname,
|
||||||
get_exe_directory,
|
get_exe_directory,
|
||||||
spawn_autostart,
|
spawn_autostart,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||||
"productName": "easytier-game",
|
"productName": "easytier-game",
|
||||||
"version": "1.4.6",
|
"version": "1.5.3",
|
||||||
"identifier": "com.tauri.easytier-game",
|
"identifier": "com.tauri.easytier-game",
|
||||||
|
|
||||||
"build": {
|
"build": {
|
||||||
@@ -12,14 +12,14 @@
|
|||||||
"app": {
|
"app": {
|
||||||
"windows": [
|
"windows": [
|
||||||
{
|
{
|
||||||
"title": "easytier-game 1.4.6",
|
"title": "easytier-game 1.5.3",
|
||||||
"label": "main",
|
"label": "main",
|
||||||
"minWidth": 340,
|
"minWidth": 340,
|
||||||
"width": 340,
|
"width": 340,
|
||||||
"height": 305,
|
"height": 305,
|
||||||
"minHeight": 305,
|
"minHeight": 305,
|
||||||
"maxHeight": 305,
|
"maxHeight": 405,
|
||||||
"maxWidth": 360,
|
"maxWidth": 460,
|
||||||
"resizable": true,
|
"resizable": true,
|
||||||
"fullscreen": false,
|
"fullscreen": false,
|
||||||
"decorations": true,
|
"decorations": true,
|
||||||
@@ -72,7 +72,9 @@
|
|||||||
"windows": {
|
"windows": {
|
||||||
"webviewInstallMode": {
|
"webviewInstallMode": {
|
||||||
"type": "embedBootstrapper"
|
"type": "embedBootstrapper"
|
||||||
}
|
},
|
||||||
|
"wix": null,
|
||||||
|
"nsis": null
|
||||||
},
|
},
|
||||||
"createUpdaterArtifacts": false,
|
"createUpdaterArtifacts": false,
|
||||||
"icon": ["icons/icon.png", "icons/icon.rgba", "icons/icon.icns", "icons/icon.ico"]
|
"icon": ["icons/icon.png", "icons/icon.rgba", "icons/icon.icns", "icons/icon.ico"]
|
||||||
|
|||||||
+22
-7
@@ -7,20 +7,23 @@ const store = defineStore("main", {
|
|||||||
return {
|
return {
|
||||||
config: {
|
config: {
|
||||||
protocol: ["tcp"], // 网络协议
|
protocol: ["tcp"], // 网络协议
|
||||||
serverUrl: "public.easytier.top:11010",
|
serverUrl: ["public.easytier.top:11010"],
|
||||||
networkName: "",
|
networkName: "",
|
||||||
networkPassword: "",
|
networkPassword: "",
|
||||||
hostname: "",
|
hostname: "",
|
||||||
ipv4: "",
|
ipv4: "",
|
||||||
|
ipv6:"",
|
||||||
|
tcpWhitelistEnable: false, // tcp端口白名单
|
||||||
|
udpWhitelistEnable: false, // udp端口白名单
|
||||||
|
tcpWhitelist: "", // tcp端口白名单
|
||||||
|
udpWhitelist: "", // udp端口白名单
|
||||||
proxyNetworks: "", // 子网代理
|
proxyNetworks: "", // 子网代理
|
||||||
autoStart: false, // 是否自动启动
|
autoStart: false, // 是否自动启动
|
||||||
connectAfterStart: false, //软件打开后,是否自动连接
|
connectAfterStart: false, //软件打开后,是否自动连接
|
||||||
disableIpv6: false, // 是否禁用IPv6
|
disableIpv6: false, // 是否禁用IPv6
|
||||||
port: "11010", // 监听端口号
|
port: "0", // 监听端口号
|
||||||
enableCustomListener: true, // 是否自定义监听
|
enableCustomListener: true, // 是否自定义监听
|
||||||
enableCustomListenerV6: true, // 是否自定义IPV6监听
|
customListenerData: "tcp://0.0.0.0:11010\nudp://0.0.0.0:11010", // 自定义监听地址
|
||||||
customListenerV6Data: "udp://[::]:11010", //自定义ipv6监
|
|
||||||
customListenerData: "tcp://0.0.0.0:11010\nudp://0.0.0.0:11010\ntcp://[::]:11010", // 自定义监听地址
|
|
||||||
disbleListenner: false, // 是否禁用监听
|
disbleListenner: false, // 是否禁用监听
|
||||||
disableEncryption: false, // 是否禁用加密
|
disableEncryption: false, // 是否禁用加密
|
||||||
multiThread: false, //使用多线程
|
multiThread: false, //使用多线程
|
||||||
@@ -44,6 +47,8 @@ const store = defineStore("main", {
|
|||||||
compression: "none", //加密算法
|
compression: "none", //加密算法
|
||||||
enableKcpProxy: true, //启用kcp代理 默认开启
|
enableKcpProxy: true, //启用kcp代理 默认开启
|
||||||
disableKcpInput: false, //禁用kcp输入
|
disableKcpInput: false, //禁用kcp输入
|
||||||
|
enableQuicProxy: false, //启用quic代理 默认开启
|
||||||
|
disableQuicInput: false, //禁用quic输入
|
||||||
bindDeviceEnable: false, //是否绑定设备
|
bindDeviceEnable: false, //是否绑定设备
|
||||||
acceptDNS: false, //魔法dns
|
acceptDNS: false, //魔法dns
|
||||||
privateMode: false, //是否启用私有模式
|
privateMode: false, //是否启用私有模式
|
||||||
@@ -59,6 +64,8 @@ const store = defineStore("main", {
|
|||||||
autoStart: false, //随软件自启
|
autoStart: false, //随软件自启
|
||||||
port: "11010", // 服务器端口
|
port: "11010", // 服务器端口
|
||||||
privateMode: false, //是否启用私有模式
|
privateMode: false, //是否启用私有模式
|
||||||
|
privateNetworkName: "", // 私有模式房间名
|
||||||
|
privateNetworkPassword: "", // 私有模式密码
|
||||||
},
|
},
|
||||||
cidrEnable: false,
|
cidrEnable: false,
|
||||||
proxyForwardBySystem: false, // 是否通过系统内核转发子网代理数据包,禁用内置NAT
|
proxyForwardBySystem: false, // 是否通过系统内核转发子网代理数据包,禁用内置NAT
|
||||||
@@ -92,6 +99,7 @@ const store = defineStore("main", {
|
|||||||
"config.networkPassword",
|
"config.networkPassword",
|
||||||
"config.hostname",
|
"config.hostname",
|
||||||
"config.ipv4",
|
"config.ipv4",
|
||||||
|
"config.ipv6",
|
||||||
"config.proxyNetworks",
|
"config.proxyNetworks",
|
||||||
"config.autoStart",
|
"config.autoStart",
|
||||||
"config.connectAfterStart",
|
"config.connectAfterStart",
|
||||||
@@ -113,6 +121,10 @@ const store = defineStore("main", {
|
|||||||
"config.enableNetCardMetric",
|
"config.enableNetCardMetric",
|
||||||
"config.netCardMetricValue",
|
"config.netCardMetricValue",
|
||||||
"config.port",
|
"config.port",
|
||||||
|
"config.tcpWhitelist",
|
||||||
|
"config.udpWhitelist",
|
||||||
|
"config.tcpWhitelistEnable",
|
||||||
|
"config.udpWhitelistEnable",
|
||||||
|
|
||||||
"config.enablePortForward",
|
"config.enablePortForward",
|
||||||
"config.portForwardData",
|
"config.portForwardData",
|
||||||
@@ -120,8 +132,6 @@ const store = defineStore("main", {
|
|||||||
"config.disbleListenner",
|
"config.disbleListenner",
|
||||||
"config.enableCustomListener",
|
"config.enableCustomListener",
|
||||||
"config.customListenerData",
|
"config.customListenerData",
|
||||||
"config.enableCustomListenerV6",
|
|
||||||
"config.customListenerV6Data",
|
|
||||||
|
|
||||||
"config.enableCustomProtocol",
|
"config.enableCustomProtocol",
|
||||||
"config.customProtocol",
|
"config.customProtocol",
|
||||||
@@ -130,6 +140,9 @@ const store = defineStore("main", {
|
|||||||
|
|
||||||
"config.enableKcpProxy",
|
"config.enableKcpProxy",
|
||||||
"config.disableKcpInput",
|
"config.disableKcpInput",
|
||||||
|
"config.enableQuicProxy",
|
||||||
|
"config.disableQuicInput",
|
||||||
|
|
||||||
|
|
||||||
"config.bindDeviceEnable",
|
"config.bindDeviceEnable",
|
||||||
|
|
||||||
@@ -144,6 +157,8 @@ const store = defineStore("main", {
|
|||||||
"serverConfig.serverWhiteList",
|
"serverConfig.serverWhiteList",
|
||||||
"serverConfig.port",
|
"serverConfig.port",
|
||||||
"serverConfig.privateMode",
|
"serverConfig.privateMode",
|
||||||
|
"serverConfig.privateNetworkName",
|
||||||
|
"serverConfig.privateNetworkPassword",
|
||||||
|
|
||||||
"cidrEnable",
|
"cidrEnable",
|
||||||
"proxyForwardBySystem",
|
"proxyForwardBySystem",
|
||||||
|
|||||||
Vendored
+109
@@ -10,3 +10,112 @@ interface ImportMetaEnv {
|
|||||||
interface ImportMeta {
|
interface ImportMeta {
|
||||||
readonly env: ImportMetaEnv;
|
readonly env: ImportMetaEnv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 节点数据类型定义
|
||||||
|
interface NodeItem {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
host: string;
|
||||||
|
port: number;
|
||||||
|
protocol: string;
|
||||||
|
version: string;
|
||||||
|
description: string;
|
||||||
|
max_connections: number;
|
||||||
|
current_connections: number;
|
||||||
|
is_active: boolean;
|
||||||
|
is_approved: boolean;
|
||||||
|
allow_relay: boolean;
|
||||||
|
network_name: string | null;
|
||||||
|
network_secret: string | null;
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
address: string;
|
||||||
|
usage_percentage: number;
|
||||||
|
current_health_status: string;
|
||||||
|
last_check_time: string;
|
||||||
|
last_response_time: number;
|
||||||
|
health_percentage_24h: number;
|
||||||
|
health_record_total_counter_ring: number[];
|
||||||
|
health_record_healthy_counter_ring: number[];
|
||||||
|
ring_granularity: number;
|
||||||
|
qq_number: string | null;
|
||||||
|
wechat: string | null;
|
||||||
|
mail: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface NodesData {
|
||||||
|
items: NodeItem[];
|
||||||
|
total: number;
|
||||||
|
page: number;
|
||||||
|
per_page: number;
|
||||||
|
total_pages: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface NodesResponse {
|
||||||
|
success: boolean;
|
||||||
|
data: NodesData;
|
||||||
|
error: string | null;
|
||||||
|
message: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
type Member = {
|
||||||
|
cidr: string;
|
||||||
|
ipv4: string;
|
||||||
|
hostname: string;
|
||||||
|
cost: string;
|
||||||
|
lat_ms: string;
|
||||||
|
loss_rate: string;
|
||||||
|
rx_bytes: string;
|
||||||
|
tx_bytes: string;
|
||||||
|
tunnel_proto: string;
|
||||||
|
nat_type: string;
|
||||||
|
id: string;
|
||||||
|
version: string;
|
||||||
|
connections_addrs: string[];
|
||||||
|
proxy?: [string, "Connected" | "Closed"];
|
||||||
|
};
|
||||||
|
|
||||||
|
type ConnectionsType = {
|
||||||
|
route: {
|
||||||
|
peer_id: number;
|
||||||
|
ipv4_addr: string | null;
|
||||||
|
next_hop_peer_id: number;
|
||||||
|
cost: number;
|
||||||
|
path_latency: number;
|
||||||
|
proxy_cidrs: string[];
|
||||||
|
hostname: string;
|
||||||
|
stun_info: {
|
||||||
|
udp_nat_type: number;
|
||||||
|
tcp_nat_type: number;
|
||||||
|
last_update_time: number;
|
||||||
|
public_ip: string[];
|
||||||
|
min_port: number;
|
||||||
|
max_port: number;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
peer: {
|
||||||
|
peer_id: number;
|
||||||
|
conns: {
|
||||||
|
conn_id: string;
|
||||||
|
my_peer_id: number;
|
||||||
|
peer_id: number;
|
||||||
|
features: string[];
|
||||||
|
tunnel: {
|
||||||
|
tunnel_type: string;
|
||||||
|
local_addr: {
|
||||||
|
url: string;
|
||||||
|
};
|
||||||
|
remote_addr: {
|
||||||
|
url: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}[];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
type Proxy = {
|
||||||
|
src: string;
|
||||||
|
dst: string;
|
||||||
|
start_time: string;
|
||||||
|
state: "Connected" | "Closed";
|
||||||
|
transport_type: string;
|
||||||
|
};
|
||||||
|
|||||||
+54
-9
@@ -2,11 +2,18 @@ import { invoke } from "@tauri-apps/api/core";
|
|||||||
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
||||||
import { open } from "@tauri-apps/plugin-shell";
|
import { open } from "@tauri-apps/plugin-shell";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
|
import { flatMap, map } from "lodash-es";
|
||||||
|
import { customRef, ref } from "vue";
|
||||||
|
|
||||||
export const ENV = import.meta.env;
|
export const ENV = import.meta.env;
|
||||||
|
|
||||||
|
export const mixedArray = (a: Array<string>, b: Array<string>, split: string = "") => {
|
||||||
|
return flatMap(a, protocol => map(b, port => `${protocol}${split}${port}`));
|
||||||
|
};
|
||||||
|
|
||||||
//防抖
|
//防抖
|
||||||
export const bounce = (time = 3000) => {
|
export const bounce = (time = 3000) => {
|
||||||
let bounceTimer: NodeJS.Timeout | null = null;
|
let bounceTimer: number | null = null;
|
||||||
return (cb: Function) => {
|
return (cb: Function) => {
|
||||||
bounceTimer && clearTimeout(bounceTimer);
|
bounceTimer && clearTimeout(bounceTimer);
|
||||||
bounceTimer = setTimeout(() => {
|
bounceTimer = setTimeout(() => {
|
||||||
@@ -15,6 +22,26 @@ export const bounce = (time = 3000) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const inputBounceRef = (value: string, cb?: Function, delay = 650) => {
|
||||||
|
let timeout: number | null = null;
|
||||||
|
return customRef((track, trigger) => {
|
||||||
|
return {
|
||||||
|
get() {
|
||||||
|
track();
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
set(newValue) {
|
||||||
|
value = newValue;
|
||||||
|
trigger();
|
||||||
|
timeout && clearTimeout(timeout);
|
||||||
|
timeout = setTimeout(() => {
|
||||||
|
cb?.(newValue);
|
||||||
|
}, delay);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {number} size byte number
|
* @param {number} size byte number
|
||||||
@@ -67,13 +94,13 @@ export const ATJ = (promise: Promise<any>, errorExt: string | undefined = undefi
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const _supportProtocols = ["tcp", "udp", "ws", "wss", "quic"];
|
const _supportProtocols = ["tcp", "udp", "ws", "wss", "srv", "schema", "txt"];
|
||||||
|
|
||||||
export const supportProtocols = () => {
|
export const supportProtocols = () => {
|
||||||
return _supportProtocols.slice();
|
return _supportProtocols.slice();
|
||||||
};
|
};
|
||||||
|
|
||||||
let _prevent_timer: NodeJS.Timeout | null = null;
|
let _prevent_timer: number | null = null;
|
||||||
let _prevent_timer_count = 15; // 秒
|
let _prevent_timer_count = 15; // 秒
|
||||||
export const preventSleep = () => {
|
export const preventSleep = () => {
|
||||||
_prevent_timer && clearInterval(_prevent_timer);
|
_prevent_timer && clearInterval(_prevent_timer);
|
||||||
@@ -127,17 +154,35 @@ export const parseCliInfo = (content: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function isValidWindowsFileName(name: string) {
|
export function isValidWindowsFileName(name: string) {
|
||||||
if(name.length > 255) return false;
|
if (name.length > 255) return false;
|
||||||
const reserved_names = [
|
const reserved_names = [
|
||||||
"CON", "PRN", "AUX", "NUL",
|
"CON",
|
||||||
"COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
|
"PRN",
|
||||||
"LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"
|
"AUX",
|
||||||
|
"NUL",
|
||||||
|
"COM1",
|
||||||
|
"COM2",
|
||||||
|
"COM3",
|
||||||
|
"COM4",
|
||||||
|
"COM5",
|
||||||
|
"COM6",
|
||||||
|
"COM7",
|
||||||
|
"COM8",
|
||||||
|
"COM9",
|
||||||
|
"LPT1",
|
||||||
|
"LPT2",
|
||||||
|
"LPT3",
|
||||||
|
"LPT4",
|
||||||
|
"LPT5",
|
||||||
|
"LPT6",
|
||||||
|
"LPT7",
|
||||||
|
"LPT8",
|
||||||
|
"LPT9"
|
||||||
];
|
];
|
||||||
if(reserved_names.includes(name.toUpperCase())) {
|
if (reserved_names.includes(name.toUpperCase())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return /^[^<>:"/\\|?*\x00-\x1F]+[^<>:"/\\|?*\x00-\x1F .]$/g.test(name);
|
return /^[^<>:"/\\|?*\x00-\x1F]+[^<>:"/\\|?*\x00-\x1F .]$/g.test(name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const addQQGroup = () => {
|
export const addQQGroup = () => {
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user