mirror of
https://github.com/EasyTier/EasytierGame.git
synced 2026-09-20 03:21:59 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41f58f1df6 | ||
|
|
0a17c269ea |
+1
-4
@@ -10,8 +10,5 @@ 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.cfg
|
|
||||||
+5
-27
@@ -10,7 +10,7 @@
|
|||||||
}
|
}
|
||||||
} */
|
} */
|
||||||
html {
|
html {
|
||||||
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
|
font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;
|
||||||
}
|
}
|
||||||
html,
|
html,
|
||||||
body {
|
body {
|
||||||
@@ -39,7 +39,7 @@ html.dark body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.full-label .el-form-item__label {
|
.full-label .el-form-item__label {
|
||||||
width: 100%!important;
|
width: 100%;
|
||||||
padding-right: 0;
|
padding-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,32 +50,10 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-select-dropdown__wrap {
|
.el-select-dropdown__wrap {
|
||||||
max-height: 138px !important;
|
max-height: 150px!important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-popper:not(.is-pure) {
|
|
||||||
font-size: 10px !important;
|
|
||||||
line-height: 1.2em !important;
|
|
||||||
padding: 5px !important;
|
|
||||||
font-weight: lighter !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.el-message-box__content + .el-message-box__btns {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
justify-content: flex-start;
|
|
||||||
flex-direction: row-reverse;
|
|
||||||
gap: 0 10px;
|
|
||||||
}
|
|
||||||
@@ -1,20 +1,11 @@
|
|||||||
pnpm run build
|
|
||||||
rustup default nightly
|
rustup default nightly
|
||||||
|
@echo 使用rust nightly构建支持win7的版本,请先将根目录的windows.0.48.5 放入以下目录
|
||||||
|
@echo C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\lib\x64
|
||||||
|
@echo C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\lib\x86
|
||||||
|
@echo C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\atlmfc\lib\x64
|
||||||
|
@echo 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
|
||||||
+27
-36
@@ -2,57 +2,48 @@ import { BaseDirectory, writeTextFile } from "@tauri-apps/plugin-fs";
|
|||||||
import useMainStore from "@/stores/index";
|
import useMainStore from "@/stores/index";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import { uniq, intersection, isNil } from "lodash-es";
|
import { uniq, intersection, isNil } from "lodash-es";
|
||||||
import { bounce } from "~/utils";
|
export const updateConfigJson = async (configJsonSeverUrl: Array<string> | string | null | undefined) => {
|
||||||
|
|
||||||
const b = bounce(600);
|
|
||||||
export type ConfigServerUrlType = Array<string>;
|
|
||||||
|
|
||||||
export const updateConfigJsonBounce = (configJsonSeverUrl?: ConfigServerUrlType | null) => {
|
|
||||||
b(async () => {
|
|
||||||
const mainStore = useMainStore();
|
|
||||||
if (mainStore.createConfigInEasytier) {
|
|
||||||
await updateConfigJson(configJsonSeverUrl);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
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 = [];
|
||||||
}
|
}
|
||||||
if(typeof(configJsonSeverUrl) == 'string') {
|
const isArray = Array.isArray(configJsonSeverUrl);
|
||||||
configJsonSeverUrl = [configJsonSeverUrl];
|
const isString = typeof configJsonSeverUrl === "string";
|
||||||
}
|
|
||||||
configJsonSeverUrl = configJsonSeverUrl || [];
|
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
proxyNetworks,
|
proxyNetworks,
|
||||||
autoStart,
|
autoStart,
|
||||||
|
relayAllPeerrpc,
|
||||||
|
connectAfterStart,
|
||||||
|
multiThread,
|
||||||
|
enablExitNode,
|
||||||
|
useSmoltcp,
|
||||||
saveErrorLog,
|
saveErrorLog,
|
||||||
|
logLevel,
|
||||||
serverUrl,
|
serverUrl,
|
||||||
|
port,
|
||||||
enableCustomListener,
|
enableCustomListener,
|
||||||
|
enablePreventSleep,
|
||||||
customListenerData,
|
customListenerData,
|
||||||
bindDeviceEnable,
|
customListenerV6Data,
|
||||||
acceptDNS,
|
enableCustomListenerV6,
|
||||||
enablePortForward,
|
|
||||||
portForwardData,
|
|
||||||
...otherConfig
|
...otherConfig
|
||||||
} = mainStore.config;
|
} = mainStore.config;
|
||||||
let writeServerUrl: Array<string> = serverUrl;
|
let writeServerUrl: Array<string> | string = serverUrl;
|
||||||
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) {
|
||||||
await writeTextFile(
|
writeServerUrl = intersection(
|
||||||
path,
|
uniq([serverUrl, ...(configJsonSeverUrl as string).split(",")]).filter(boolean => boolean),
|
||||||
JSON.stringify({ serverUrl: writeServerUrl, enableCustomListener, customListenerData: writeCustomListenerData, ...otherConfig }, null, 4),
|
mainStore.basePeers
|
||||||
{ baseDir: BaseDirectory.Resource }
|
).join(",");
|
||||||
);
|
}
|
||||||
|
await writeTextFile(path, JSON.stringify({ serverUrl: writeServerUrl, ...otherConfig }, null, 4), { baseDir: BaseDirectory.Resource });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
ElMessage.error(`更新config.json失败`);
|
ElMessage.error(`更新config.json失败`);
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
import { basename, extname } from "@tauri-apps/api/path";
|
|
||||||
import { exists } from "@tauri-apps/plugin-fs";
|
|
||||||
import { Command } from "@tauri-apps/plugin-shell";
|
|
||||||
|
|
||||||
export const getIcon = async function (sourcePath: string, icoDirPath: string) {
|
|
||||||
if(sourcePath.endsWith(".url")) return false;
|
|
||||||
let res = await Command.create("ResourcesExtract", [
|
|
||||||
"/Source",
|
|
||||||
sourcePath,
|
|
||||||
"/DestFolder",
|
|
||||||
icoDirPath,
|
|
||||||
"/ExtractIcons",
|
|
||||||
"1",
|
|
||||||
"/ExtractCursors",
|
|
||||||
"0",
|
|
||||||
"/OpenDestFolder",
|
|
||||||
"0",
|
|
||||||
"/MultiFilesMode",
|
|
||||||
"1"
|
|
||||||
]).execute();
|
|
||||||
if (res.code == 0) {
|
|
||||||
let icoPath = icoDirPath + "\\" + (await basename(sourcePath));
|
|
||||||
icoPath = icoPath.replace(`.${await extname(sourcePath)}`, "_1.ico");
|
|
||||||
if (await exists(icoPath)) {
|
|
||||||
return icoPath;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
+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();
|
||||||
// }
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,17 +20,5 @@ export const getServerArgs = () => {
|
|||||||
if (!whiteList && mainStore.serverConfig.enableWhiteList) {
|
if (!whiteList && mainStore.serverConfig.enableWhiteList) {
|
||||||
args.push("--relay-network-whitelist");
|
args.push("--relay-network-whitelist");
|
||||||
}
|
}
|
||||||
if (mainStore.serverConfig.privateMode) {
|
|
||||||
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;
|
||||||
};
|
};
|
||||||
|
|||||||
+42
-53
@@ -8,7 +8,6 @@ import { resourceDir as getResourceDir, join } from "@tauri-apps/api/path";
|
|||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
// import { ElConfirmPrimary } from "~/utils/element";
|
// import { ElConfirmPrimary } from "~/utils/element";
|
||||||
import { open } from "@tauri-apps/plugin-shell";
|
import { open } from "@tauri-apps/plugin-shell";
|
||||||
import { computed } from "vue";
|
|
||||||
|
|
||||||
const DEFAULT_TRAY_NAME = "main";
|
const DEFAULT_TRAY_NAME = "main";
|
||||||
|
|
||||||
@@ -22,7 +21,7 @@ async function toggleVisibility() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function useTray(init: boolean = false, beforExit: Function, handleConnection: Function, handleReconnect: Function, handleNodesList: Function) {
|
export async function useTray(init: boolean = false, beforExit: Function, handleConnection: Function) {
|
||||||
let tray;
|
let tray;
|
||||||
try {
|
try {
|
||||||
tray = await TrayIcon.getById(DEFAULT_TRAY_NAME);
|
tray = await TrayIcon.getById(DEFAULT_TRAY_NAME);
|
||||||
@@ -31,10 +30,13 @@ 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, handleReconnect, handleNodesList) }),
|
menu: await Menu.new({
|
||||||
action: async e => {
|
id: "main",
|
||||||
|
items: await generateMenuItem(beforExit, handleConnection),
|
||||||
|
}),
|
||||||
|
action: async (e) => {
|
||||||
toggleVisibility();
|
toggleVisibility();
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -44,36 +46,30 @@ 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.setMenuOnLeftClick(false);
|
||||||
tray.setMenu(await Menu.new({ id: "main", items: await generateMenuItem(beforExit, handleConnection, handleReconnect, handleNodesList) }));
|
tray.setMenu(
|
||||||
|
await Menu.new({
|
||||||
|
id: "main",
|
||||||
|
items: await generateMenuItem(beforExit, handleConnection),
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return tray;
|
return tray;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function generateMenuItem(beforExit: Function, handleConnection: Function, handleReconnect: Function, handleNodesList: Function) {
|
export async function generateMenuItem(beforExit: Function, handleConnection: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(handleNodesList),
|
await MenuItemPublicPeers(),
|
||||||
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",
|
||||||
@@ -83,17 +79,18 @@ export async function MenuItemExit(text: string, beforExit: Function) {
|
|||||||
await beforExit();
|
await beforExit();
|
||||||
}
|
}
|
||||||
await getCurrentWindow().close();
|
await getCurrentWindow().close();
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function MenuItemPublicPeers(handleNodesList: Function) {
|
export async function MenuItemPublicPeers() {
|
||||||
|
|
||||||
return await MenuItem.new({
|
return await MenuItem.new({
|
||||||
id: "publicPeers",
|
id: "publicPeers",
|
||||||
text: "公共节点",
|
text: "公共节点",
|
||||||
action: async () => {
|
action: async () => {
|
||||||
await handleNodesList();
|
await open("https://easytier.gd.nkbpal.cn/status/easytier")
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,17 +100,17 @@ export async function MenuItemShow(text: string) {
|
|||||||
text,
|
text,
|
||||||
action: async () => {
|
action: async () => {
|
||||||
await toggleVisibility();
|
await toggleVisibility();
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function MenuItemExchangeConnection(text: string, handleConnection: Function) {
|
export async function MenuItemExchangeConnection(text: string, handleConnection:Function) {
|
||||||
const menutItem = await MenuItem.new({
|
const menutItem = await MenuItem.new({
|
||||||
id: "exchangeConnection",
|
id: "exchangeConnection",
|
||||||
text,
|
text,
|
||||||
action: async () => {
|
action: async () => {
|
||||||
const isStart = await handleConnection();
|
const isStart = await handleConnection();
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
return menutItem;
|
return menutItem;
|
||||||
}
|
}
|
||||||
@@ -124,10 +121,11 @@ export async function MenuItemTheme() {
|
|||||||
text: "主题切换",
|
text: "主题切换",
|
||||||
action: async () => {
|
action: async () => {
|
||||||
const mainStore = useMainStore();
|
const mainStore = useMainStore();
|
||||||
mainStore.$patch({ theme: !mainStore.theme });
|
mainStore.theme = !mainStore.theme;
|
||||||
// mainStore.$persist();
|
// const appWindow = getCurrentWindow();
|
||||||
|
// appWindow.emitTo("main", "config", { theme: mainStore.theme });
|
||||||
await setTheme(mainStore.theme);
|
await setTheme(mainStore.theme);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,27 +158,18 @@ export async function setTrayTooltip(tray: TrayIcon | null, tooltip?: string | n
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const versionWeight = (version: string) => {
|
|
||||||
version = version ? version.trim() : "";
|
|
||||||
const [major = "0", minor = "0", patch = "0"] = version.split(".");
|
|
||||||
return parseInt(major) * 10000 + parseInt(minor) * 100 + parseInt(patch);
|
|
||||||
};
|
|
||||||
|
|
||||||
const versionDifference = (current: string, latest: string) => {
|
|
||||||
const currentVersion = versionWeight(current);
|
|
||||||
const latestVersion = versionWeight(latest);
|
|
||||||
return currentVersion - latestVersion;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const checkNewVersion = async () => {
|
export const checkNewVersion = async () => {
|
||||||
const mainStore = useMainStore();
|
|
||||||
// if(mainStore.latestTagName && mainStore.latestTagName == pkg.version) return;
|
|
||||||
if (hasNewVersion.value) return;
|
|
||||||
let [tagName, downloadUrl] = await invoke<string[]>("fetch_game_releases");
|
let [tagName, downloadUrl] = await invoke<string[]>("fetch_game_releases");
|
||||||
mainStore.latestTagName = tagName;
|
if(tagName && pkg.version !== tagName) {
|
||||||
};
|
return true; //有新版
|
||||||
|
// const [err] = await ElConfirmPrimary("有新版本是否下载?", "发现新版本", {
|
||||||
export const hasNewVersion = computed<boolean>(() => {
|
// confirmButtonText: "下载",
|
||||||
const mainStore = useMainStore();
|
// cancelButtonText: "取消",
|
||||||
return !!mainStore.latestTagName && versionDifference(pkg.version, mainStore.latestTagName) < 0 ;
|
// })
|
||||||
});
|
// if(!err) {
|
||||||
|
// open(downloadUrl);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
return false; //没有新版
|
||||||
|
}
|
||||||
+45
-56
@@ -1,32 +1,20 @@
|
|||||||
import { type UnlistenFn } from "@tauri-apps/api/event";
|
import { type UnlistenFn } from "@tauri-apps/api/event";
|
||||||
import { getCurrentWindow, PhysicalPosition, type WindowOptions, Window, currentMonitor, PhysicalSize } from "@tauri-apps/api/window";
|
import { getCurrentWindow, PhysicalPosition, type WindowOptions, Window, currentMonitor } 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";
|
||||||
import { onBeforeUnmount } from "vue";
|
import { onBeforeUnmount } from "vue";
|
||||||
import { updateConfigJsonBounce, type ConfigServerUrlType } from "./configJson";
|
|
||||||
|
|
||||||
const _listenersMaps: { [key: string]: [UnlistenFn | null] } = {};
|
const _listenersMaps: { [key: string]: [UnlistenFn | null, UnlistenFn | null] } = {};
|
||||||
|
|
||||||
const dealCloseListener = async (dialog: WebviewWindow, label: string, beforeCloseFunc?: () => void | null) => {
|
|
||||||
const unlistenFnList: [UnlistenFn | null] = _listenersMaps[label] || [null];
|
|
||||||
let [unListenlogClose] = unlistenFnList;
|
|
||||||
|
|
||||||
unListenlogClose && (await unListenlogClose());
|
|
||||||
|
|
||||||
unListenlogClose = await dialog.onCloseRequested(async () => {
|
|
||||||
beforeCloseFunc && (await beforeCloseFunc());
|
|
||||||
unListenlogClose && (await unListenlogClose());
|
|
||||||
console.log("close");
|
|
||||||
});
|
|
||||||
};
|
|
||||||
export default async (
|
export default async (
|
||||||
label: WebviewLabel,
|
label: WebviewLabel,
|
||||||
options?: Omit<WebviewOptions, "x" | "y" | "width" | "height"> & WindowOptions,
|
options?: Omit<WebviewOptions, "x" | "y" | "width" | "height"> & WindowOptions,
|
||||||
afterCreatedFunc?: (webviewWindow: WebviewWindow, appWindow: Window) => void | null,
|
afterCreatedFunc?: (webviewWindow: WebviewWindow, appWindow: Window) => void | null,
|
||||||
beforeCloseFunc?: () => void | null
|
beforeCloseFunc?: () => void | null
|
||||||
) => {
|
) => {
|
||||||
const unlistenFnList: [UnlistenFn | null] = _listenersMaps[label] || [null];
|
const unlistenFnList: [UnlistenFn | null, UnlistenFn | null] = _listenersMaps[label] || [null, null];
|
||||||
|
let [unlistenLogCreated, unListenlogClose] = unlistenFnList;
|
||||||
let dialog = await WebviewWindow.getByLabel(label);
|
let dialog = await WebviewWindow.getByLabel(label);
|
||||||
if (!dialog) {
|
if (!dialog) {
|
||||||
let defaultOpts: { [key: string]: any; parent: Window | undefined } = {
|
let defaultOpts: { [key: string]: any; parent: Window | undefined } = {
|
||||||
@@ -41,58 +29,59 @@ export default async (
|
|||||||
};
|
};
|
||||||
const appWindow = getCurrentWindow();
|
const appWindow = getCurrentWindow();
|
||||||
if (appWindow) {
|
if (appWindow) {
|
||||||
|
const appSize = await appWindow.outerSize();
|
||||||
|
const factor = await appWindow.scaleFactor();
|
||||||
|
const appPosition = await appWindow.outerPosition();
|
||||||
|
const logicalPosition = new PhysicalPosition(appPosition.x + appSize.width, appPosition.y).toLogical(factor);
|
||||||
defaultOpts.parent = appWindow;
|
defaultOpts.parent = appWindow;
|
||||||
// console.error(logicalPosition);
|
// console.error(logicalPosition);
|
||||||
if (defaultOpts.x == 0 && defaultOpts.y == 0) {
|
defaultOpts.x = logicalPosition.x;
|
||||||
const logicalAppSize = {
|
defaultOpts.y = logicalPosition.y;
|
||||||
width: 340,
|
|
||||||
height: 305
|
|
||||||
}
|
|
||||||
const factor = await appWindow.scaleFactor();
|
|
||||||
const appPosition = await appWindow.outerPosition();
|
|
||||||
const logicalPosition = new PhysicalPosition(appPosition.x + Math.ceil((logicalAppSize.width + 5) * factor), appPosition.y).toLogical(factor);
|
|
||||||
defaultOpts.x = logicalPosition.x;
|
|
||||||
defaultOpts.y = logicalPosition.y;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
unlistenLogCreated && (await (unlistenLogCreated as Function)());
|
||||||
|
unListenlogClose && (await unListenlogClose());
|
||||||
dialog = new WebviewWindow(label, { ...defaultOpts, ...options });
|
dialog = new WebviewWindow(label, { ...defaultOpts, ...options });
|
||||||
await dealCloseListener(dialog, label, beforeCloseFunc);
|
unlistenLogCreated = await dialog.listen("tauri://webview-created", async () => {
|
||||||
await dialog.show();
|
if (dialog) {
|
||||||
afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow));
|
afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow));
|
||||||
|
await dialog.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
unlistenFnList[0] = unlistenLogCreated;
|
||||||
|
unListenlogClose = await dialog.onCloseRequested(async () => {
|
||||||
|
beforeCloseFunc && (await beforeCloseFunc());
|
||||||
|
unListenlogClose && (await unListenlogClose());
|
||||||
|
unlistenLogCreated && (await (unlistenLogCreated as Function)());
|
||||||
|
});
|
||||||
|
unlistenFnList[1] = unlistenLogCreated;
|
||||||
|
_listenersMaps[label] = unlistenFnList;
|
||||||
} else {
|
} else {
|
||||||
const visible = await dialog.isVisible();
|
const visible = await dialog.isVisible();
|
||||||
if (visible) {
|
if (visible) {
|
||||||
await dialog.close();
|
await dialog.close();
|
||||||
} else {
|
unlistenLogCreated && (await (unlistenLogCreated as Function)());
|
||||||
const appWindow = getCurrentWindow();
|
|
||||||
await dealCloseListener(dialog, label, beforeCloseFunc);
|
|
||||||
await dialog.show();
|
|
||||||
afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const dataSubscribe = async (cb?: any, getconfigServerUrl?: () => ConfigServerUrlType) => {
|
export const dataSubscribe = async (cb?: (...args: any) => any) => {
|
||||||
|
if (!cb) return;
|
||||||
const mainStore = useMainStore();
|
const mainStore = useMainStore();
|
||||||
const abort = new AbortController();
|
const currentWindow = getCurrentWindow();
|
||||||
|
let removeSubscribe = mainStore.$subscribe(async (...args) => {
|
||||||
window.addEventListener(
|
const emitData = await cb(args);
|
||||||
"storage",
|
await currentWindow.emitTo({ kind: "Window", label: "main" }, "config", emitData);
|
||||||
async () => {
|
});
|
||||||
// console.log("触发", {dhcp:mainStore.config.dhcp, c: mainStore.createConfigInEasytier})
|
const unlisten = currentWindow.listen<any>("global-main-store", event => {
|
||||||
mainStore.$hydrate();
|
removeSubscribe && removeSubscribe();
|
||||||
const configServerUrl = getconfigServerUrl && getconfigServerUrl instanceof Function ? getconfigServerUrl() : null;
|
mainStore.$patch({ ...event.payload.store }); // 更新全局状态
|
||||||
updateConfigJsonBounce(configServerUrl);
|
removeSubscribe = mainStore.$subscribe(async (...args) => {
|
||||||
if (cb && cb instanceof Function) {
|
const emitData = await cb(args);
|
||||||
await cb();
|
await currentWindow.emitTo({ kind: "Window", label: "main" }, "config", emitData);
|
||||||
}
|
});
|
||||||
},
|
});
|
||||||
{
|
onBeforeUnmount(async () => {
|
||||||
signal: abort.signal
|
unlisten && (await unlisten)();
|
||||||
}
|
removeSubscribe && removeSubscribe();
|
||||||
);
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
console.log("取消监听");
|
|
||||||
abort?.abort();
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Vendored
-3
@@ -1,8 +1,5 @@
|
|||||||
VITE_CONFIG_PATH=easytier/config/
|
VITE_CONFIG_PATH=easytier/config/
|
||||||
VITE_CONFIG_ADMIN_PATH=easytier/config/.admin/
|
|
||||||
VITE_CONFIG_FILE_NAME=easytier/config.json
|
VITE_CONFIG_FILE_NAME=easytier/config.json
|
||||||
VITE_LOG_PATH=easytier/logs/
|
VITE_LOG_PATH=easytier/logs/
|
||||||
VITE_CACHE_PATH=easytier/cache/
|
VITE_CACHE_PATH=easytier/cache/
|
||||||
VITE_GAME_LIST_PATH=easytier/gameList/
|
|
||||||
VITE_PUBLIC_PEERS_URL=https://easytier.gd.nkbpal.cn/status/easytier
|
|
||||||
VITE_AUTO_START_SERVICE_NAME=easytierGameAutoStart
|
VITE_AUTO_START_SERVICE_NAME=easytierGameAutoStart
|
||||||
Vendored
-3
@@ -1,8 +1,5 @@
|
|||||||
VITE_CONFIG_PATH=easytier/config/
|
VITE_CONFIG_PATH=easytier/config/
|
||||||
VITE_CONFIG_ADMIN_PATH=easytier/config/.admin/
|
|
||||||
VITE_CONFIG_FILE_NAME=easytier/config.json
|
VITE_CONFIG_FILE_NAME=easytier/config.json
|
||||||
VITE_LOG_PATH=easytier/logs/
|
VITE_LOG_PATH=easytier/logs/
|
||||||
VITE_CACHE_PATH=easytier/cache/
|
VITE_CACHE_PATH=easytier/cache/
|
||||||
VITE_GAME_LIST_PATH=easytier/gameList/
|
|
||||||
VITE_PUBLIC_PEERS_URL=https://easytier.gd.nkbpal.cn/status/easytier
|
|
||||||
VITE_AUTO_START_SERVICE_NAME=easytierGameAutoStart
|
VITE_AUTO_START_SERVICE_NAME=easytierGameAutoStart
|
||||||
+1
-2
@@ -6,8 +6,7 @@
|
|||||||
//屏蔽右键菜单
|
//屏蔽右键菜单
|
||||||
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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ export default defineNuxtConfig({
|
|||||||
devServer: {
|
devServer: {
|
||||||
port: 5000
|
port: 5000
|
||||||
},
|
},
|
||||||
|
|
||||||
telemetry: false,
|
telemetry: false,
|
||||||
|
|
||||||
imports: {
|
imports: {
|
||||||
|
|||||||
+23
-25
@@ -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.5.2",
|
"version": "1.3.7",
|
||||||
"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,34 +11,32 @@
|
|||||||
"release-win7": "node zip.js win7"
|
"release-win7": "node zip.js win7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@element-plus/icons-vue": "^2.3.2",
|
"@element-plus/icons-vue": "^2.3.1",
|
||||||
"@element-plus/nuxt": "1.1.4",
|
"@element-plus/nuxt": "^1.1.1",
|
||||||
"@nuxtjs/tailwindcss": "6.13.2",
|
"@nuxtjs/tailwindcss": "6.13.1",
|
||||||
"@pinia/nuxt": "0.11.2",
|
"@pinia/nuxt": "0.9.0",
|
||||||
"@tauri-apps/api": "2.9.0",
|
"@tauri-apps/api": "^2.2.0",
|
||||||
"@tauri-apps/cli": "2.9.1",
|
"@tauri-apps/cli": "2.2.4",
|
||||||
"@tauri-apps/plugin-cli": "2.4.0",
|
"@tauri-apps/plugin-cli": "^2.2.0",
|
||||||
"@tauri-apps/plugin-clipboard-manager": "2.3.0",
|
"@tauri-apps/plugin-clipboard-manager": "2.2.0",
|
||||||
"@tauri-apps/plugin-dialog": "2.4.0",
|
"@tauri-apps/plugin-fs": "^2.2.0",
|
||||||
"@tauri-apps/plugin-fs": "2.4.2",
|
"@tauri-apps/plugin-log": "^2.2.0",
|
||||||
"@tauri-apps/plugin-log": "2.7.0",
|
"@tauri-apps/plugin-shell": "^2.2.0",
|
||||||
"@tauri-apps/plugin-shell": "2.3.1",
|
"@tauri-apps/plugin-window-state": "^2.2.0",
|
||||||
"@tauri-apps/plugin-window-state": "2.4.0",
|
"@tauri-apps/plugin-dialog": "2.2.0",
|
||||||
"@types/lodash-es": "^4.17.12",
|
"@types/lodash-es": "^4.17.12",
|
||||||
"@vitejs/plugin-vue-jsx": "5.1.1",
|
"@vitejs/plugin-vue-jsx": "^4.1.1",
|
||||||
"@vueuse/core": "12.7.0",
|
"@vueuse/core": "12.4.0",
|
||||||
"archiver": "^7.0.1",
|
"archiver": "^7.0.1",
|
||||||
"element-plus": "2.11.7",
|
"element-plus": "2.9.3",
|
||||||
"less": "4.2.1",
|
"less": "4.2.1",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"nuxt": "3.19.2",
|
"nuxt": "3.15.2",
|
||||||
"pinia": "3.0.3",
|
"pinia": "^2.3.0",
|
||||||
"pinia-plugin-persistedstate": "4.5.0",
|
"pinia-plugin-persistedstate": "^4.2.0",
|
||||||
"postcss": "^8.4.38",
|
"postcss": "^8.4.38",
|
||||||
"prettier": "3.6.2",
|
"prettier": "3.4.2",
|
||||||
"prettier-plugin-tailwindcss": "0.6.14"
|
"prettier-plugin-tailwindcss": "0.6.10",
|
||||||
},
|
"vue-clipboard3": "^2.0.0"
|
||||||
"dependencies": {
|
|
||||||
"is-ip": "^5.0.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+38
-206
@@ -2,8 +2,8 @@
|
|||||||
<div class="flex h-full flex-col items-start overflow-auto px-[25px]">
|
<div class="flex h-full flex-col items-start overflow-auto px-[25px]">
|
||||||
<div class="flex flex-nowrap items-center gap-[15px]">
|
<div class="flex flex-nowrap items-center gap-[15px]">
|
||||||
<div class="flex flex-nowrap items-center gap-[5px]">
|
<div class="flex flex-nowrap items-center gap-[5px]">
|
||||||
<ElCheckbox v-model="mainStore.config.enableCustomProtocol">直连(P2P)优先使用传输协议</ElCheckbox>
|
<ElCheckbox v-model="mainStore.config.enableCustomProtocol">默认直连(p2p)使用的协议</ElCheckbox>
|
||||||
<ElTooltip content="若无法建立指定的协议,会自动使用可建立连接的协议">
|
<ElTooltip content="如果没有支持该协议的节点地址,程序会自动处理,请放心使用">
|
||||||
<ElIcon><QuestionFilled /></ElIcon>
|
<ElIcon><QuestionFilled /></ElIcon>
|
||||||
</ElTooltip>
|
</ElTooltip>
|
||||||
</div>
|
</div>
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<ElCheckbox v-model="mainStore.config.relayAllPeerrpc">帮助他人建立直连(P2P)连接</ElCheckbox>
|
<ElCheckbox v-model="mainStore.config.relayAllPeerrpc">帮助对等节点建立直连(p2p)通信</ElCheckbox>
|
||||||
</div>
|
</div>
|
||||||
<div><ElCheckbox v-model="mainStore.config.connectAfterStart">软件启动后,自动"启动联机"(搭配开机自启,无感联机)</ElCheckbox></div>
|
<div><ElCheckbox v-model="mainStore.config.connectAfterStart">软件启动后,自动"启动联机"(搭配开机自启,无感联机)</ElCheckbox></div>
|
||||||
<div class="flex flex-nowrap items-center gap-[15px]">
|
<div class="flex flex-nowrap items-center gap-[15px]">
|
||||||
@@ -38,76 +38,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div><ElCheckbox v-model="mainStore.config.enablePreventSleep">防止系统休眠(比如:屏幕会一直亮着)</ElCheckbox></div>
|
<div><ElCheckbox v-model="mainStore.config.enablePreventSleep">防止系统休眠(比如:屏幕会一直亮着)</ElCheckbox></div>
|
||||||
<div class="flex flex-nowrap items-center gap-[5px]">
|
<div class="flex flex-nowrap items-center gap-[5px]">
|
||||||
<ElCheckbox v-model="mainStore.config.latencyfirst">使用低延迟模式</ElCheckbox>
|
<ElCheckbox v-model="mainStore.config.latencyfirst">延迟优先模式,将尝试使用最低延迟路径转发流量</ElCheckbox>
|
||||||
<ElTooltip content="弱网环境下可能会导致网络延迟延迟忽高忽低">
|
<ElTooltip content="视网络质量进行选择,可能会出现中转与直连(p2p)来回切换的情况">
|
||||||
<ElIcon><QuestionFilled /></ElIcon>
|
<ElIcon><QuestionFilled /></ElIcon>
|
||||||
</ElTooltip>
|
</ElTooltip>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-nowrap items-center gap-[5px]">
|
|
||||||
<ElCheckbox
|
|
||||||
@change="handleKcpProxyChange"
|
|
||||||
v-model="mainStore.config.enableKcpProxy"
|
|
||||||
>
|
|
||||||
启用KCP代理
|
|
||||||
</ElCheckbox>
|
|
||||||
<ElTooltip content="(不可与QUIC代理同时开启)将TCP流量转为KCP流量,降低传输延迟,提升传输速度">
|
|
||||||
<ElIcon><QuestionFilled /></ElIcon>
|
|
||||||
</ElTooltip>
|
|
||||||
<CoreVersionWarning version="2.2.0" />
|
|
||||||
</div>
|
|
||||||
<div class="flex flex-nowrap items-center gap-[5px]">
|
|
||||||
<ElCheckbox v-model="mainStore.config.disableKcpInput">禁用KCP输入</ElCheckbox>
|
|
||||||
<ElTooltip content="不允许其他节点使用 KCP 代理 TCP 流到此节点。开启 KCP 代理的节点访问此节点时,依然使用原始 TCP 连接">
|
|
||||||
<ElIcon><QuestionFilled /></ElIcon>
|
|
||||||
</ElTooltip>
|
|
||||||
<CoreVersionWarning version="2.2.0" />
|
|
||||||
</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.disableIpv6">不使用IPv6</ElCheckbox></div>
|
<div><ElCheckbox v-model="mainStore.config.disableIpv6">不使用IPv6</ElCheckbox></div>
|
||||||
<div class="flex flex-nowrap items-center gap-[5px]">
|
|
||||||
<ElCheckbox v-model="mainStore.config.acceptDNS">魔法DNS</ElCheckbox>
|
|
||||||
<ElTooltip content="您可以使用域名访问其他节点,例如:<hostname>.et.net。魔法DNS将修改您的系统DNS设置,请谨慎启用">
|
|
||||||
<ElIcon><QuestionFilled /></ElIcon>
|
|
||||||
</ElTooltip>
|
|
||||||
<CoreVersionWarning version="2.3.0" />
|
|
||||||
</div>
|
|
||||||
<div class="flex flex-nowrap items-center gap-[5px]">
|
|
||||||
<ElCheckbox v-model="mainStore.config.privateMode">启用私有模式</ElCheckbox>
|
|
||||||
<ElTooltip content="启用后,不允许使用了与本网络不同的房间名和密码的节点通过本节点进行握手或中转">
|
|
||||||
<ElIcon><QuestionFilled /></ElIcon>
|
|
||||||
</ElTooltip>
|
|
||||||
<CoreVersionWarning version="2.3.1" />
|
|
||||||
</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="无法联机时,可以尝试开启这个选项">
|
||||||
@@ -151,7 +88,6 @@
|
|||||||
class="!mb-0"
|
class="!mb-0"
|
||||||
v-model="listenerDialogData.visible"
|
v-model="listenerDialogData.visible"
|
||||||
:close-on-press-escape="false"
|
:close-on-press-escape="false"
|
||||||
:close-on-click-modal="false"
|
|
||||||
title="自定义监听地址"
|
title="自定义监听地址"
|
||||||
>
|
>
|
||||||
<ElInput
|
<ElInput
|
||||||
@@ -174,76 +110,38 @@
|
|||||||
</ElDialog>
|
</ElDialog>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-[10px]">
|
<div class="flex items-center gap-[10px]">
|
||||||
<ElCheckbox v-model="mainStore.config.enablePortForward">端口转发</ElCheckbox>
|
<ElCheckbox
|
||||||
<ElTooltip
|
:disabled="mainStore.config.disbleListenner"
|
||||||
:disabled="mainStore.config.enablePortForward"
|
v-model="mainStore.config.enableCustomListenerV6"
|
||||||
content="请先开启端口转发功能"
|
|
||||||
>
|
>
|
||||||
<ElButton
|
自定义IPV6监听地址
|
||||||
|
</ElCheckbox>
|
||||||
|
<div class="w-[200px]">
|
||||||
|
<ElInput
|
||||||
|
:disabled="mainStore.config.disbleListenner || mainStore.config.enableCustomListenerV6"
|
||||||
size="small"
|
size="small"
|
||||||
:disabled="!mainStore.config.enablePortForward"
|
:maxlength="100"
|
||||||
@click="handlePortForwardDialog"
|
v-model="mainStore.config.customListenerV6Data"
|
||||||
>
|
placeholder="请输入自定义IPV6监听地址"
|
||||||
配置
|
/>
|
||||||
</ElButton>
|
</div>
|
||||||
</ElTooltip>
|
<ElTooltip content="例如:tcp://[::]:11010,如果未设置,将在随机UDP端口上监听">
|
||||||
<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.1.0" />
|
||||||
<ElDialog
|
|
||||||
width="95%"
|
|
||||||
top="5px"
|
|
||||||
append-to-body
|
|
||||||
:z-index="10"
|
|
||||||
class="!mb-0"
|
|
||||||
v-model="portForwardDialogData.visible"
|
|
||||||
:close-on-press-escape="false"
|
|
||||||
:close-on-click-modal="false"
|
|
||||||
title="端口转发配置"
|
|
||||||
>
|
|
||||||
<div class="mb-4">
|
|
||||||
<ElText
|
|
||||||
size="small"
|
|
||||||
type="info"
|
|
||||||
>
|
|
||||||
<div>• 每行一个转发规则</div>
|
|
||||||
<div>• 格式:协议://本地地址:本地端口/目标地址:目标端口</div>
|
|
||||||
<div class="flex items-center">
|
|
||||||
<span class="mr-auto">• 例如:udp://0.0.0.0:12345/10.126.126.1:23456</span>
|
|
||||||
<ElButton
|
|
||||||
size="default"
|
|
||||||
type="primary"
|
|
||||||
@click.stop="handleFinishInputPortForward"
|
|
||||||
>
|
|
||||||
填写完毕
|
|
||||||
</ElButton>
|
|
||||||
</div>
|
|
||||||
</ElText>
|
|
||||||
</div>
|
|
||||||
<ElInput
|
|
||||||
type="textarea"
|
|
||||||
:rows="10"
|
|
||||||
placeholder="请输入端口转发规则,每行一个 例如: udp://0.0.0.0:12345/10.126.126.1:23456 tcp://0.0.0.0:8080/192.168.1.100:80"
|
|
||||||
v-model="mainStore.config.portForwardData"
|
|
||||||
></ElInput>
|
|
||||||
<!-- -->
|
|
||||||
</ElDialog>
|
|
||||||
</div>
|
</div>
|
||||||
<ElDivider />
|
<ElDivider />
|
||||||
<div class="flex items-center gap-[10px]">
|
<div class="flex items-center gap-[10px]">
|
||||||
<ElCheckbox v-model="mainStore.config.devName">自定义虚拟网卡名称</ElCheckbox>
|
<ElCheckbox v-model="mainStore.config.devName">自定义网卡名</ElCheckbox>
|
||||||
<ElInput
|
<ElInput
|
||||||
size="small"
|
size="small"
|
||||||
maxlength="10"
|
maxlength="10"
|
||||||
v-model="mainStore.config.devNameValue"
|
v-model="mainStore.config.devNameValue"
|
||||||
placeholder="请输入虚拟网卡名称"
|
placeholder="请输入网卡名"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-[10px]">
|
<div class="flex items-center gap-[10px]">
|
||||||
<ElCheckbox v-model="mainStore.config.enableNetCardMetric">自定义虚拟网卡优先级</ElCheckbox>
|
<ElCheckbox v-model="mainStore.config.enableNetCardMetric">自定义easytier网卡跃点</ElCheckbox>
|
||||||
<ElInputNumber
|
<ElInputNumber
|
||||||
controls-position="right"
|
controls-position="right"
|
||||||
:min="1"
|
:min="1"
|
||||||
@@ -253,9 +151,9 @@
|
|||||||
:precision="0"
|
:precision="0"
|
||||||
size="small"
|
size="small"
|
||||||
v-model="mainStore.config.netCardMetricValue"
|
v-model="mainStore.config.netCardMetricValue"
|
||||||
placeholder="请输入优先级"
|
placeholder="请选择跃点数"
|
||||||
/>
|
/>
|
||||||
<ElTooltip content="数值越小,优先级越高">
|
<ElTooltip content="设置easytier网卡的跃点,提升网卡优先级,跃点越小,网卡优先级越高">
|
||||||
<ElIcon><QuestionFilled /></ElIcon>
|
<ElIcon><QuestionFilled /></ElIcon>
|
||||||
</ElTooltip>
|
</ElTooltip>
|
||||||
</div>
|
</div>
|
||||||
@@ -264,43 +162,17 @@
|
|||||||
size="small"
|
size="small"
|
||||||
type="warning"
|
type="warning"
|
||||||
>
|
>
|
||||||
(不使用自定义虚拟网卡名称,那么联机时默认会生成一个名为 "et_xxx" 的网卡,也可以使用 “自定义虚拟网卡优先级”
|
(不使用自定义网卡名,那么联机时默认会生成一个名为 "et_xxx" 的网卡,也可以使用 “设置跃点” 功能,除非你启用了下面的功能)
|
||||||
功能,除非你启用了下面的功能)
|
|
||||||
</ElText>
|
</ElText>
|
||||||
</div>
|
</div>
|
||||||
|
<div><ElCheckbox v-model="mainStore.config.noTun">不创建TUN设备(网卡),可以使用子网代理访问节点</ElCheckbox></div>
|
||||||
<div class="flex items-center gap-[5px]">
|
|
||||||
<ElCheckbox v-model="mainStore.config.noTun">不创建TUN虚拟网卡</ElCheckbox>
|
|
||||||
|
|
||||||
<ElTooltip content="开启后该节点无法主动访问其他节点">
|
|
||||||
<ElIcon><QuestionFilled /></ElIcon>
|
|
||||||
</ElTooltip>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex items-center gap-[5px]">
|
|
||||||
<div><ElCheckbox v-model="mainStore.config.bindDeviceEnable">绑定物理网卡</ElCheckbox></div>
|
|
||||||
<ElTooltip content="将连接器的套接字绑定到物理设备以避免路由问题。比如子网代理网段与某节点的网段冲突,绑定物理设备后可以与该节点正常通信">
|
|
||||||
<ElIcon><QuestionFilled /></ElIcon>
|
|
||||||
</ElTooltip>
|
|
||||||
<CoreVersionWarning version="2.2.3" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<ElDivider />
|
<ElDivider />
|
||||||
<div><ElCheckbox v-model="mainStore.config.enablExitNode">允许此节点成为出口节点</ElCheckbox></div>
|
<div><ElCheckbox v-model="mainStore.config.enablExitNode">允许此节点成为出口节点</ElCheckbox></div>
|
||||||
<div class="flex items-center gap-[5px]">
|
<div><ElCheckbox v-model="mainStore.config.disableEncryption">禁用对等节点通信的加密</ElCheckbox></div>
|
||||||
<ElCheckbox v-model="mainStore.config.disableEncryption">关闭信息加密</ElCheckbox>
|
<div><ElCheckbox v-model="mainStore.config.multiThread">启用多线程运行</ElCheckbox></div>
|
||||||
<ElTooltip content="关闭后通信数据将在互联网上明文传输,如房间名和密码">
|
|
||||||
<ElIcon><QuestionFilled /></ElIcon>
|
|
||||||
</ElTooltip>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center gap-[5px]">
|
|
||||||
<ElCheckbox v-model="mainStore.config.multiThread">开启多线程</ElCheckbox>
|
|
||||||
<ElTooltip content="开启后可能会提高网络性能">
|
|
||||||
<ElIcon><QuestionFilled /></ElIcon>
|
|
||||||
</ElTooltip>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center gap-[10px]">
|
<div class="flex items-center gap-[10px]">
|
||||||
<ElText>传输数据压缩算法</ElText>
|
<ElText>压缩算法</ElText>
|
||||||
<div class="w-[160px]">
|
<div class="w-[160px]">
|
||||||
<ElSelect
|
<ElSelect
|
||||||
size="small"
|
size="small"
|
||||||
@@ -322,12 +194,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<ElDivider />
|
<ElDivider />
|
||||||
|
|
||||||
<div class="flex items-center gap-[10px]">
|
<div><ElCheckbox v-model="mainStore.config.useSmoltcp">为子网代理启用smoltcp堆栈</ElCheckbox></div>
|
||||||
<ElCheckbox v-model="mainStore.config.useSmoltcp">为子网代理和 KCP 代理开启用户网络栈</ElCheckbox>
|
<div><ElCheckbox v-model="mainStore.config.disableUdpHolePunching">禁用UDP打洞功能</ElCheckbox></div>
|
||||||
<ElTooltip content="开启后会降低网络性能,但不需要配置防火墙">
|
|
||||||
<ElIcon><QuestionFilled /></ElIcon>
|
|
||||||
</ElTooltip>
|
|
||||||
</div>
|
|
||||||
<div class="flex flex-nowrap items-center gap-[15px]">
|
<div class="flex flex-nowrap items-center gap-[15px]">
|
||||||
<ElCheckbox v-model="mainStore.config.saveErrorLog">输出日志到本地</ElCheckbox>
|
<ElCheckbox v-model="mainStore.config.saveErrorLog">输出日志到本地</ElCheckbox>
|
||||||
<div class="w-[140px]">
|
<div class="w-[140px]">
|
||||||
@@ -361,12 +229,11 @@
|
|||||||
import { Command } from "@tauri-apps/plugin-shell";
|
import { Command } from "@tauri-apps/plugin-shell";
|
||||||
import { exists, mkdir, BaseDirectory, remove } from "@tauri-apps/plugin-fs";
|
import { exists, mkdir, BaseDirectory, remove } from "@tauri-apps/plugin-fs";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import { reactive, ref } from "vue";
|
import { reactive } from "vue";
|
||||||
import { dataSubscribe } from "@/composables/windows";
|
import { dataSubscribe } from "@/composables/windows";
|
||||||
import { ATJ, supportProtocols } from "~/utils";
|
import { ATJ, supportProtocols } from "~/utils";
|
||||||
import CoreVersionWarning from "@/components/CoreVersionWarning.vue";
|
import CoreVersionWarning from "@/components/CoreVersionWarning.vue";
|
||||||
import { ElConfirmDanger } from "~/utils/element";
|
import { ElConfirmDanger } from "~/utils/element";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
|
||||||
|
|
||||||
const protocols = supportProtocols();
|
const protocols = supportProtocols();
|
||||||
const listenerDialogData = reactive<{ [key: string]: any }>({
|
const listenerDialogData = reactive<{ [key: string]: any }>({
|
||||||
@@ -374,15 +241,6 @@
|
|||||||
loading: false
|
loading: false
|
||||||
});
|
});
|
||||||
|
|
||||||
const portForwardDialogData = reactive<{ [key: string]: any }>({
|
|
||||||
visible: false,
|
|
||||||
loading: false
|
|
||||||
});
|
|
||||||
|
|
||||||
const handlePortForwardDialog = () => {
|
|
||||||
portForwardDialogData.visible = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleListenerDialog = () => {
|
const handleListenerDialog = () => {
|
||||||
listenerDialogData.visible = true;
|
listenerDialogData.visible = true;
|
||||||
};
|
};
|
||||||
@@ -391,13 +249,8 @@
|
|||||||
listenerDialogData.visible = false;
|
listenerDialogData.visible = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleFinishInputPortForward = async () => {
|
|
||||||
portForwardDialogData.visible = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
const mainStore = useMainStore();
|
const mainStore = useMainStore();
|
||||||
const data = ["trace", "debug", "info", "warn", "error", "off"];
|
const data = ["trace", "debug", "info", "warn", "error", "off"];
|
||||||
const guids = ref<string[][]>([]);
|
|
||||||
const openLogDir = async () => {
|
const openLogDir = async () => {
|
||||||
const resourceDir = await getResourceDir();
|
const resourceDir = await getResourceDir();
|
||||||
const logPath = import.meta.env.VITE_LOG_PATH;
|
const logPath = import.meta.env.VITE_LOG_PATH;
|
||||||
@@ -410,7 +263,6 @@
|
|||||||
}
|
}
|
||||||
await Command.create("explorer", [logDirPath]).execute();
|
await Command.create("explorer", [logDirPath]).execute();
|
||||||
};
|
};
|
||||||
|
|
||||||
const openConfigJsonDir = async () => {
|
const openConfigJsonDir = async () => {
|
||||||
const resourceDir = await getResourceDir();
|
const resourceDir = await getResourceDir();
|
||||||
const easytierDir = await join(resourceDir, "easytier/");
|
const easytierDir = await join(resourceDir, "easytier/");
|
||||||
@@ -422,31 +274,7 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleKcpProxyChange = () => {
|
dataSubscribe(async (...a) => {
|
||||||
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功能增加改方法
|
|
||||||
const getGuids = async () => {
|
|
||||||
const guidsValue = await invoke<string[][]>("get_network_adapter_guids");
|
|
||||||
guids.value = guidsValue && guidsValue.length > 0 ? guidsValue : [];
|
|
||||||
};
|
|
||||||
|
|
||||||
dataSubscribe(async () => {
|
|
||||||
if (!mainStore.createConfigInEasytier) {
|
if (!mainStore.createConfigInEasytier) {
|
||||||
// 考虑删除本地config.json文件
|
// 考虑删除本地config.json文件
|
||||||
const configJsonPath = import.meta.env.VITE_CONFIG_FILE_NAME;
|
const configJsonPath = import.meta.env.VITE_CONFIG_FILE_NAME;
|
||||||
@@ -466,5 +294,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return {
|
||||||
|
config: { ...mainStore.config },
|
||||||
|
createConfigInEasytier: mainStore.createConfigInEasytier
|
||||||
|
};
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
+22
-17
@@ -1,18 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex h-full flex-col gap-[10px]">
|
<div class="flex h-full flex-col gap-[10px]">
|
||||||
<div class="flex items-center gap-[10px]">
|
<ElRadioGroup
|
||||||
<ElRadioGroup
|
:disabled="!data.isSwitchEnable"
|
||||||
:disabled="!data.isSwitchEnable"
|
v-model="mainStore.cidrEnable"
|
||||||
v-model="mainStore.cidrEnable"
|
>
|
||||||
>
|
<ElRadioButton :value="true">开启</ElRadioButton>
|
||||||
<ElRadioButton :value="true">开启</ElRadioButton>
|
<ElRadioButton :value="false">关闭</ElRadioButton>
|
||||||
<ElRadioButton :value="false">关闭</ElRadioButton>
|
</ElRadioGroup>
|
||||||
</ElRadioGroup>
|
|
||||||
<div class="flex items-center gap-[10px]">
|
|
||||||
<ElCheckbox v-model="mainStore.proxyForwardBySystem">通过系统内核转发子网代理数据包,禁用内置NAT</ElCheckbox>
|
|
||||||
<CoreVersionWarning version="2.2.3" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex-1 overflow-auto">
|
<div class="flex-1 overflow-auto">
|
||||||
<ElInput
|
<ElInput
|
||||||
placeholder="例如: 192.168.1.0/24 一行一个"
|
placeholder="例如: 192.168.1.0/24 一行一个"
|
||||||
@@ -69,7 +63,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,7 +73,16 @@
|
|||||||
await listenOutput();
|
await listenOutput();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data.route = JSON.parse(member);
|
const routeInfo = parseCliInfo(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 () => {
|
||||||
@@ -106,9 +109,11 @@
|
|||||||
unlistenStart = await listenStart();
|
unlistenStart = await listenStart();
|
||||||
});
|
});
|
||||||
|
|
||||||
dataSubscribe();
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
unlistenStart && unlistenStart();
|
unlistenStart && unlistenStart();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
dataSubscribe(async (...a) => {
|
||||||
|
return { cidrEnable: mainStore.cidrEnable, config: { ...mainStore.config } };
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,533 +0,0 @@
|
|||||||
<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_5px]">
|
|
||||||
<div class="ml-[5px] mr-auto flex flex-1">
|
|
||||||
<ElInput
|
|
||||||
size="small"
|
|
||||||
v-model="searchValue"
|
|
||||||
placeholder="请输入游戏名进行查询"
|
|
||||||
></ElInput>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<ElButton
|
|
||||||
:icon="Plus"
|
|
||||||
size="small"
|
|
||||||
type="primary"
|
|
||||||
class="mr-[5px]"
|
|
||||||
@click="handleCreate"
|
|
||||||
>
|
|
||||||
新增游戏
|
|
||||||
</ElButton>
|
|
||||||
<ElButton
|
|
||||||
size="small"
|
|
||||||
class="!ml-[0px] mr-[5px]"
|
|
||||||
@click="openCoverDir"
|
|
||||||
>
|
|
||||||
封面目录
|
|
||||||
</ElButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex flex-1 flex-wrap gap-[0] overflow-auto">
|
|
||||||
<div
|
|
||||||
v-for="(item, idx) in computedGameList"
|
|
||||||
:key="item.id"
|
|
||||||
class="w-[25%] p-[4px]"
|
|
||||||
>
|
|
||||||
<div class="group/card relative">
|
|
||||||
<ElCard>
|
|
||||||
<template #header>
|
|
||||||
<div class="flex flex-nowrap gap-[0_8px]">
|
|
||||||
<ElTooltip :content="item.name" placement="top">
|
|
||||||
<p class="ml-auto flex-1 truncate">
|
|
||||||
<ElText
|
|
||||||
size="default"
|
|
||||||
type="info"
|
|
||||||
>
|
|
||||||
{{ item.name }}
|
|
||||||
</ElText>
|
|
||||||
</p>
|
|
||||||
</ElTooltip>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<img
|
|
||||||
:src="showImgConvertFileSrc(item.showImg)"
|
|
||||||
@error="handleImgError(item, idx)"
|
|
||||||
class="aspect-[1] w-full object-cover"
|
|
||||||
/>
|
|
||||||
</ElCard>
|
|
||||||
<div
|
|
||||||
class="absolute left-0 top-[61px] z-[1] hidden h-[calc(100%-61px)] w-full flex-col items-center justify-center rounded-[5px] bg-[var(--el-mask-color)] group-hover/card:flex"
|
|
||||||
>
|
|
||||||
<ElButton
|
|
||||||
size="large"
|
|
||||||
type="success"
|
|
||||||
:icon="VideoPlay"
|
|
||||||
@click.stop="handleStartGame(item)"
|
|
||||||
>
|
|
||||||
启动游戏
|
|
||||||
</ElButton>
|
|
||||||
<div class="pt-[5px]">
|
|
||||||
<ElButton
|
|
||||||
size="small"
|
|
||||||
type="info"
|
|
||||||
:icon="EditPen"
|
|
||||||
title="修改"
|
|
||||||
@click.stop="handleEditItem(item)"
|
|
||||||
/>
|
|
||||||
<ElButton
|
|
||||||
size="small"
|
|
||||||
type="danger"
|
|
||||||
:icon="DeleteFilled"
|
|
||||||
title="删除"
|
|
||||||
@click.stop="handleDeleteItem(item)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="w-[25%] p-[4px]">
|
|
||||||
<ElTooltip content="新增本地游戏">
|
|
||||||
<ElCard
|
|
||||||
@click.stop="handleCreate"
|
|
||||||
shadow="hover"
|
|
||||||
>
|
|
||||||
<div class="group/plus flex cursor-pointer flex-col items-center justify-center py-[25px]">
|
|
||||||
<ElIcon class="!text-[80px] transition-all group-hover/plus:text-[color:var(--el-color-primary)]">
|
|
||||||
<Plus></Plus>
|
|
||||||
</ElIcon>
|
|
||||||
<div>
|
|
||||||
<ElText>支持从桌面拖放新增</ElText>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</ElCard>
|
|
||||||
</ElTooltip>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<ElDialog
|
|
||||||
width="95%"
|
|
||||||
top="30px"
|
|
||||||
append-to-body
|
|
||||||
:z-index="10"
|
|
||||||
class="!mb-0"
|
|
||||||
v-model="createGameData.visible"
|
|
||||||
:close-on-press-escape="false"
|
|
||||||
:title="`${createGameData.isEdit ? '编辑' : '新建'}本地游戏`"
|
|
||||||
>
|
|
||||||
<ElForm
|
|
||||||
hide-required-asterisk
|
|
||||||
label-position="left"
|
|
||||||
:model="createGameData.form"
|
|
||||||
:rules="createGameData.rules"
|
|
||||||
ref="formRef"
|
|
||||||
>
|
|
||||||
<ElFormItem
|
|
||||||
label="游戏名字"
|
|
||||||
prop="name"
|
|
||||||
>
|
|
||||||
<ElInput
|
|
||||||
v-model="createGameData.form.name"
|
|
||||||
placeholder="请输入游戏名字"
|
|
||||||
></ElInput>
|
|
||||||
</ElFormItem>
|
|
||||||
<ElFormItem
|
|
||||||
label="执行文件"
|
|
||||||
prop="exePath"
|
|
||||||
>
|
|
||||||
<ElInput
|
|
||||||
v-model="createGameData.form.exePath"
|
|
||||||
placeholder="请选择游戏执行文件"
|
|
||||||
>
|
|
||||||
<template #append>
|
|
||||||
<ElButton
|
|
||||||
size="small"
|
|
||||||
type="primary"
|
|
||||||
@click.stop="handleBrowser('exePath')"
|
|
||||||
>
|
|
||||||
浏览
|
|
||||||
</ElButton>
|
|
||||||
</template>
|
|
||||||
</ElInput>
|
|
||||||
</ElFormItem>
|
|
||||||
<ElFormItem
|
|
||||||
label="游戏封面"
|
|
||||||
prop="showImg"
|
|
||||||
>
|
|
||||||
<ElBadge :hidden="createGameData.form.showImg == defaultPng">
|
|
||||||
<template #content="{ value }">
|
|
||||||
<div
|
|
||||||
class="cursor-pointer"
|
|
||||||
@click.stop="handleBadgeDeleteCover"
|
|
||||||
>
|
|
||||||
<ElIcon>
|
|
||||||
<DeleteFilled />
|
|
||||||
</ElIcon>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<img
|
|
||||||
@click.stop="handleBrowser('showImg')"
|
|
||||||
:src="showImgConvertFileSrc(createGameData.form.showImg)"
|
|
||||||
class="aspect-[1] w-[120px] cursor-pointer object-cover"
|
|
||||||
/>
|
|
||||||
</ElBadge>
|
|
||||||
</ElFormItem>
|
|
||||||
</ElForm>
|
|
||||||
<template #footer>
|
|
||||||
<div><ElText type="warning">除了默认封面以外,自定义封面会集中保存在封面目录里</ElText></div>
|
|
||||||
<ElButton
|
|
||||||
size="default"
|
|
||||||
type="primary"
|
|
||||||
@click="handleSave"
|
|
||||||
>
|
|
||||||
保存
|
|
||||||
</ElButton>
|
|
||||||
<ElButton
|
|
||||||
size="default"
|
|
||||||
@click="createGameData.visible = false"
|
|
||||||
>
|
|
||||||
关闭
|
|
||||||
</ElButton>
|
|
||||||
</template>
|
|
||||||
</ElDialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { VideoPlay, DeleteFilled, EditPen, Plus, Delete } from "@element-plus/icons-vue";
|
|
||||||
import { dataSubscribe } from "~/composables/windows";
|
|
||||||
import { BaseDirectory, basename, extname, resourceDir as getResourceDir, join } from "@tauri-apps/api/path";
|
|
||||||
import { convertFileSrc, Resource } from "@tauri-apps/api/core";
|
|
||||||
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, useTemplateRef } from "vue";
|
|
||||||
import useMainStore from "@/stores/index";
|
|
||||||
import { uniqueId } from "lodash-es";
|
|
||||||
import { open as dialogOpen } from "@tauri-apps/plugin-dialog";
|
|
||||||
import { ElMessage, type FormInstance } from "element-plus";
|
|
||||||
import { ATJ, bounce } from "~/utils";
|
|
||||||
import { ElConfirmDanger } from "~/utils/element";
|
|
||||||
import { copyFile, exists, mkdir, readDir, remove } from "@tauri-apps/plugin-fs";
|
|
||||||
import { Command, open } from "@tauri-apps/plugin-shell";
|
|
||||||
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
|
|
||||||
|
|
||||||
const resourceDir = await getResourceDir();
|
|
||||||
const gameListResourceDir = await join(resourceDir, import.meta.env.VITE_GAME_LIST_PATH);
|
|
||||||
// const defaultLocalIconPath = await join(configPath, "icon.png");
|
|
||||||
// const tauriPath = convertFileSrc(defaultLocalIconPath);
|
|
||||||
const mainStore = useMainStore();
|
|
||||||
const formEl = useTemplateRef<FormInstance>("formRef");
|
|
||||||
const searchValue = ref("");
|
|
||||||
const defaultPng = "/default.png";
|
|
||||||
// const b = bounce(600);
|
|
||||||
type gameItemType = { name: string; exePath: string; id: string; showImg: string };
|
|
||||||
const createGameData = reactive({
|
|
||||||
visible: false,
|
|
||||||
isEdit: false,
|
|
||||||
form: {
|
|
||||||
id: "",
|
|
||||||
name: "",
|
|
||||||
exePath: "",
|
|
||||||
showImg: defaultPng
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
name: [{ required: true, message: "请输入游戏名", trigger: "blur" }],
|
|
||||||
exePath: [{ required: true, message: "请选择游戏执行文件", trigger: "blur" }]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const computedGameList = computed(() => {
|
|
||||||
if (!searchValue.value.trim()) return mainStore.gameList;
|
|
||||||
return mainStore.gameList.filter(item => {
|
|
||||||
return item.name.includes(searchValue.value); // 过滤
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleCreate = async () => {
|
|
||||||
createGameData.isEdit = false;
|
|
||||||
createGameData.form = {
|
|
||||||
id: "",
|
|
||||||
name: "",
|
|
||||||
exePath: "",
|
|
||||||
showImg: defaultPng
|
|
||||||
};
|
|
||||||
await nextTick();
|
|
||||||
createGameData.visible = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleBrowser = async (type: "showImg" | "exePath") => {
|
|
||||||
const filters = type === "showImg" ? [{ name: "", extensions: ["png", "jpg", "jpeg"] }] : [{ name: "", extensions: ["exe"] }];
|
|
||||||
const file = await dialogOpen({
|
|
||||||
multiple: false,
|
|
||||||
directory: false,
|
|
||||||
filters
|
|
||||||
});
|
|
||||||
if (file) {
|
|
||||||
if (type === "showImg") {
|
|
||||||
if (file) {
|
|
||||||
if (!createGameData.form.id) {
|
|
||||||
const time = new Date().getTime();
|
|
||||||
createGameData.form.id = uniqueId(`${time}`);
|
|
||||||
}
|
|
||||||
let showImg = file;
|
|
||||||
const game_list_path = import.meta.env.VITE_GAME_LIST_PATH;
|
|
||||||
const isExists = await exists(game_list_path, { baseDir: BaseDirectory.Resource });
|
|
||||||
if (!isExists) {
|
|
||||||
try {
|
|
||||||
await mkdir(game_list_path, { baseDir: BaseDirectory.Resource });
|
|
||||||
} catch (err) {}
|
|
||||||
}
|
|
||||||
const toPath = await join(gameListResourceDir, createGameData.form.id);
|
|
||||||
const suffix = showImg.split(".").pop();
|
|
||||||
const toPathFileName = `${toPath}.${suffix}`;
|
|
||||||
if (showImg != toPathFileName) {
|
|
||||||
await copyFile(showImg, toPathFileName);
|
|
||||||
}
|
|
||||||
// console.log(toPathFileName);
|
|
||||||
const isExistsToPath = await exists(toPathFileName);
|
|
||||||
if (isExistsToPath) {
|
|
||||||
const baseName = await basename(toPathFileName);
|
|
||||||
createGameData.form = { ...createGameData.form, showImg: `${baseName}` }; // 如果复制正确,那就存储文件名即可
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (type === "exePath") {
|
|
||||||
createGameData.form.exePath = file;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ElMessage.error("获取文件路径失败");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const openCoverDir = async () => {
|
|
||||||
const game_list_path = import.meta.env.VITE_GAME_LIST_PATH;
|
|
||||||
const isExists = await exists(game_list_path, { baseDir: BaseDirectory.Resource });
|
|
||||||
if (!isExists) {
|
|
||||||
try {
|
|
||||||
await mkdir(game_list_path, { baseDir: BaseDirectory.Resource });
|
|
||||||
} catch (err) {}
|
|
||||||
}
|
|
||||||
await Command.create("explorer", [gameListResourceDir]).execute();
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSave = async () => {
|
|
||||||
const [error, _] = await ATJ(formEl.value?.validate() as Promise<boolean>);
|
|
||||||
if (!error) {
|
|
||||||
if (createGameData.form.showImg == defaultPng) {
|
|
||||||
//删除本地封面图
|
|
||||||
// const toPath = await join(gameListResourceDir, createGameData.form.id);
|
|
||||||
// const imgPath = `${toPath}.${suffix}`;
|
|
||||||
// await remove(imgPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
const idx = mainStore.gameList.findIndex(i => i.id == createGameData.form.id);
|
|
||||||
if (idx >= 0) {
|
|
||||||
mainStore.gameList[idx] = { ...createGameData.form };
|
|
||||||
mainStore.$patch({
|
|
||||||
gameList: [...mainStore.gameList]
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
mainStore.$patch({
|
|
||||||
gameList: [...mainStore.gameList, createGameData.form]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ElMessage.success("保存成功");
|
|
||||||
createGameData.visible = false;
|
|
||||||
// await Command.create("explorer", [gameListResourceDir]).execute();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleBadgeDeleteCover = async () => {
|
|
||||||
await removeFileById(createGameData.form.id);
|
|
||||||
createGameData.form = { ...createGameData.form, showImg: defaultPng };
|
|
||||||
};
|
|
||||||
|
|
||||||
const removeFileById = async (id: string) => {
|
|
||||||
if (!id) return;
|
|
||||||
const isExists = await exists(gameListResourceDir);
|
|
||||||
if (!isExists) return;
|
|
||||||
const entries = await readDir(gameListResourceDir);
|
|
||||||
if (entries.length > 0) {
|
|
||||||
for (const entry of entries) {
|
|
||||||
if (entry.name.includes(id + ".")) {
|
|
||||||
const imgPath = await join(gameListResourceDir, entry.name);
|
|
||||||
const isExists = await exists(imgPath);
|
|
||||||
if (!isExists) continue;
|
|
||||||
await remove(imgPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDeleteItem = async ({ id }: gameItemType) => {
|
|
||||||
if (id) {
|
|
||||||
const [error, _] = await ElConfirmDanger("确定要删除吗?");
|
|
||||||
if (!error) {
|
|
||||||
await removeFileById(id);
|
|
||||||
mainStore.$patch({
|
|
||||||
gameList: mainStore.gameList.filter(i => i.id !== id)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleEditItem = async (item: gameItemType) => {
|
|
||||||
createGameData.isEdit = true;
|
|
||||||
createGameData.form = { ...item };
|
|
||||||
createGameData.visible = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleStartGame = async (item: gameItemType) => {
|
|
||||||
try {
|
|
||||||
const isExists = await exists(item.exePath);
|
|
||||||
if (!isExists) {
|
|
||||||
return ElMessage.error("执行文件不存在");
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
return ElMessage.error("执行文件不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
ElMessage.info("正在启动游戏,请稍后...");
|
|
||||||
const _child = await open(item.exePath);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleImgError = (item: gameItemType, idx: number) => {
|
|
||||||
item.showImg = defaultPng;
|
|
||||||
mainStore.gameList[idx] = { ...item };
|
|
||||||
mainStore.$patch({
|
|
||||||
gameList: [...mainStore.gameList]
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const showImgConvertFileSrc = (showImg: string) => {
|
|
||||||
if (showImg == defaultPng) return defaultPng;
|
|
||||||
showImg = /^[a-z]\:/g.test(showImg.toLowerCase())
|
|
||||||
? `${convertFileSrc(showImg)}?${new Date().getTime()}`
|
|
||||||
: `${convertFileSrc(`${gameListResourceDir}\\${showImg}`)}?${new Date().getTime()}`;
|
|
||||||
return showImg;
|
|
||||||
};
|
|
||||||
|
|
||||||
let unlistenDragDrop: UnlistenFn | null = null;
|
|
||||||
const listenDragDrop = async () => {
|
|
||||||
unlistenDragDrop = await listen<{ paths: string[]; position: { x: number; y: number } }>("tauri://drag-drop", async e => {
|
|
||||||
const AllFiles = e.payload.paths;
|
|
||||||
let result: Array<gameItemType> = [];
|
|
||||||
const date = new Date().getTime();
|
|
||||||
const showImg = defaultPng;
|
|
||||||
const extUrls = [];
|
|
||||||
const lnkFiles = [];
|
|
||||||
for (const item of AllFiles) {
|
|
||||||
if (item.endsWith(".url")) {
|
|
||||||
extUrls.push(item);
|
|
||||||
} else {
|
|
||||||
lnkFiles.push(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lnkFiles.length > 0) {
|
|
||||||
// console.log(lnkFiles)
|
|
||||||
let lnkFilesstr = "$lnkFiles = @(";
|
|
||||||
for (let i = 0; i < lnkFiles.length; i++) {
|
|
||||||
lnkFilesstr = lnkFilesstr + `\"${lnkFiles[i]}\"`;
|
|
||||||
if (i == lnkFiles.length - 1) {
|
|
||||||
lnkFilesstr = lnkFilesstr + ");";
|
|
||||||
} else {
|
|
||||||
lnkFilesstr = lnkFilesstr + ",";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let forstr =
|
|
||||||
lnkFilesstr +
|
|
||||||
`
|
|
||||||
$shell = New-Object -ComObject WScript.Shell;
|
|
||||||
$results = @();
|
|
||||||
foreach ($lnkFile in $lnkFiles) {
|
|
||||||
$shortcut = $shell.CreateShortcut($lnkFile);
|
|
||||||
$targetPath = $shortcut.TargetPath;
|
|
||||||
$iconLocation = $shortcut.IconLocation;
|
|
||||||
$results += [PSCustomObject]@{
|
|
||||||
TargetPath = $targetPath
|
|
||||||
LinkFile = $lnkFile
|
|
||||||
};
|
|
||||||
};
|
|
||||||
$results | ConvertTo-Json
|
|
||||||
`;
|
|
||||||
let outputtarget = await Command.create("powershell", [`${forstr}`], {
|
|
||||||
encoding: "GBK"
|
|
||||||
}).execute();
|
|
||||||
let res: {
|
|
||||||
TargetPath: string;
|
|
||||||
LinkFile: string;
|
|
||||||
}[] = JSON.parse(outputtarget.stdout);
|
|
||||||
if (res && !Array.isArray(res)) {
|
|
||||||
res = [res];
|
|
||||||
}
|
|
||||||
if (res.length > 0) {
|
|
||||||
for (const idx in res) {
|
|
||||||
const item = res[idx];
|
|
||||||
// console.log(item);
|
|
||||||
const id = `${date}-${idx}`;
|
|
||||||
const exePath = item.TargetPath || item.LinkFile;
|
|
||||||
const namePath = item.LinkFile || item.TargetPath;
|
|
||||||
const allName = await basename(namePath);
|
|
||||||
const extName = await extname(namePath);
|
|
||||||
result.push({
|
|
||||||
exePath: exePath,
|
|
||||||
name: allName.replace(`.${extName}`, ""),
|
|
||||||
id,
|
|
||||||
showImg
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (extUrls.length > 0) {
|
|
||||||
for (const idx in extUrls) {
|
|
||||||
const TargetPath = extUrls[idx];
|
|
||||||
const id = `${date}-${idx}-url`;
|
|
||||||
const allName = await basename(TargetPath);
|
|
||||||
const extName = await extname(TargetPath);
|
|
||||||
result.push({
|
|
||||||
exePath: TargetPath,
|
|
||||||
name: allName.replace(`.${extName}`, ""),
|
|
||||||
id,
|
|
||||||
showImg
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.length > 0) {
|
|
||||||
mainStore.$patch({
|
|
||||||
gameList: [...mainStore.gameList, ...result]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 兼容新的存储方式
|
|
||||||
const compatibleGameList = async () => {
|
|
||||||
const gameList = [...mainStore.gameList];
|
|
||||||
if(gameList.length <= 0) return;
|
|
||||||
const newGameList = [];
|
|
||||||
for(const item of gameList) {
|
|
||||||
const newItem = {...item}
|
|
||||||
if(newItem.showImg != defaultPng && /^[a-z]\:/g.test(newItem.showImg.toLowerCase())) {
|
|
||||||
newItem.showImg = await basename(item.showImg);
|
|
||||||
if(Reflect.has(newItem, "coverImg")) {
|
|
||||||
delete newItem['coverImg'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newGameList.push(newItem);
|
|
||||||
}
|
|
||||||
mainStore.$patch({
|
|
||||||
gameList: newGameList
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
await compatibleGameList();
|
|
||||||
listenDragDrop(); //监听拖放
|
|
||||||
});
|
|
||||||
|
|
||||||
onBeforeUnmount(() =>{
|
|
||||||
unlistenDragDrop && unlistenDragDrop();
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
dataSubscribe();
|
|
||||||
</script>
|
|
||||||
+263
-993
File diff suppressed because it is too large
Load Diff
+8
-126
@@ -1,145 +1,27 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- <ElInput
|
<ElInput
|
||||||
type="textarea"
|
type="textarea"
|
||||||
:rows="17"
|
:rows="17"
|
||||||
v-model="data.originLog"
|
v-model="data.log"
|
||||||
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, useTemplateRef, nextTick } from "vue";
|
import { reactive, onMounted, onBeforeUnmount } from "vue";
|
||||||
import { copyText } from "~/utils";
|
const data = reactive({
|
||||||
type LogItem = { id: string; text: string; type: "danger" | "info" | "warning" | "primary" };
|
log: ""
|
||||||
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", async event => {
|
const unListen = await listen<string>("logs", event => {
|
||||||
const payload = event.payload || "";
|
data.log = 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();
|
||||||
|
|||||||
+52
-322
@@ -10,36 +10,21 @@
|
|||||||
<ElTable
|
<ElTable
|
||||||
stripe
|
stripe
|
||||||
border
|
border
|
||||||
:data="computedMember"
|
:data="data.member"
|
||||||
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">
|
{{
|
||||||
<div>
|
(row.hostname || "").toLowerCase().includes("publicserver")
|
||||||
{{
|
? (row.hostname || "").replace("PublicServer", "服务器")
|
||||||
(row.hostname || "").toLowerCase().includes("publicserver")
|
: row.hostname || "-"
|
||||||
? (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
|
||||||
@@ -54,7 +39,7 @@
|
|||||||
effect="dark"
|
effect="dark"
|
||||||
:type="row.cost == 'p2p' ? 'success' : 'info'"
|
:type="row.cost == 'p2p' ? 'success' : 'info'"
|
||||||
>
|
>
|
||||||
{{ row.cost ? row.cost.replace("relay", "中转").replace("p2p", "直连") : row.cost }}
|
{{ row.cost ? row.cost.replace("relay", "中转") : row.cost }}
|
||||||
</ElTag>
|
</ElTag>
|
||||||
</template>
|
</template>
|
||||||
</ElTableColumn>
|
</ElTableColumn>
|
||||||
@@ -63,39 +48,13 @@
|
|||||||
width="120"
|
width="120"
|
||||||
prop="ipv4"
|
prop="ipv4"
|
||||||
label="虚拟网IP"
|
label="虚拟网IP"
|
||||||
:sort-method="sortIpv4"
|
></ElTableColumn>
|
||||||
:sort-orders="['ascending', 'descending', null]"
|
|
||||||
>
|
|
||||||
<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="100"
|
||||||
label="延迟/ms"
|
label="延迟/ms"
|
||||||
:sort-method="sortLatMs"
|
></ElTableColumn>
|
||||||
:sort-orders="['ascending', 'descending', null]"
|
|
||||||
>
|
|
||||||
<template #default="{ row }">
|
|
||||||
{{ formatLatency(row.lat_ms) }}
|
|
||||||
</template>
|
|
||||||
</ElTableColumn>
|
|
||||||
<ElTableColumn
|
<ElTableColumn
|
||||||
sortable
|
sortable
|
||||||
width="100"
|
width="100"
|
||||||
@@ -103,13 +62,7 @@
|
|||||||
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
|
||||||
@@ -139,15 +92,11 @@
|
|||||||
width="90"
|
width="90"
|
||||||
prop="rx_bytes"
|
prop="rx_bytes"
|
||||||
label="接收"
|
label="接收"
|
||||||
:sort-method="sortBytes"
|
|
||||||
:sort-orders="['ascending', 'descending', null]"
|
|
||||||
></ElTableColumn>
|
></ElTableColumn>
|
||||||
<ElTableColumn
|
<ElTableColumn
|
||||||
sortable
|
sortable
|
||||||
prop="tx_bytes"
|
prop="tx_bytes"
|
||||||
label="传输"
|
label="传输"
|
||||||
:sort-method="(a: any, b: any) => sortBytes(a, b, 'tx_bytes')"
|
|
||||||
:sort-orders="['ascending', 'descending', null]"
|
|
||||||
></ElTableColumn>
|
></ElTableColumn>
|
||||||
</ElTable>
|
</ElTable>
|
||||||
</div>
|
</div>
|
||||||
@@ -155,67 +104,23 @@
|
|||||||
</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, computed } from "vue";
|
import { reactive, onMounted, onBeforeUnmount } from "vue";
|
||||||
import { ATJ, parseCliInfo } from "@/utils";
|
import { ATJ, parseCliInfo } 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 { endsWith, isNaN } from "lodash-es";
|
// enum NatType {
|
||||||
|
// // has NAT; but own a single public IP, port is not changed
|
||||||
type Member = {
|
// Unknown = 0;
|
||||||
cidr: string;
|
// OpenInternet = 1;
|
||||||
ipv4: string;
|
// NoPAT = 2;
|
||||||
hostname: string;
|
// FullCone = 3;
|
||||||
cost: string;
|
// Restricted = 4;
|
||||||
lat_ms: string;
|
// PortRestricted = 5;
|
||||||
loss_rate: string;
|
// Symmetric = 6;
|
||||||
rx_bytes: string;
|
// SymUdpFirewall = 7;
|
||||||
tx_bytes: string;
|
// SymmetricEasyInc = 8;
|
||||||
tunnel_proto: string;
|
// SymmetricEasyDec = 9;
|
||||||
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;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}[];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const natMaps = {
|
const natMaps = {
|
||||||
unknown: "未知",
|
unknown: "未知",
|
||||||
OpenInternet: "nat0-openinternet",
|
OpenInternet: "nat0-openinternet",
|
||||||
@@ -228,181 +133,30 @@
|
|||||||
symmetriceasyinc: "nat4-easyinc",
|
symmetriceasyinc: "nat4-easyinc",
|
||||||
symUdpfirewall: "nat4-udpfirewall"
|
symUdpfirewall: "nat4-udpfirewall"
|
||||||
};
|
};
|
||||||
|
|
||||||
type Proxy = {
|
|
||||||
src: string;
|
|
||||||
dst: string;
|
|
||||||
start_time: string;
|
|
||||||
state: "Connected" | "Closed";
|
|
||||||
transport_type: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
type natKyes = keyof typeof natMaps;
|
type natKyes = keyof typeof natMaps;
|
||||||
|
|
||||||
const data = reactive<{ member: Member[]; proxy: Proxy[] }>({
|
const data = reactive<{ member: { hostname: string; cost: string; ipv4: string; lat_msg: string; loss_rate: string; nat_type: string }[] }>({
|
||||||
member: [],
|
member: []
|
||||||
proxy: []
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const computedMember = computed(() => {
|
const _showTableHeader = [
|
||||||
const localMember = data.member.find(member => member?.cost == "Local");
|
["hostname", "主机名"],
|
||||||
if (!localMember) return data.member;
|
["cost", "路由"],
|
||||||
const ipv4 = localMember.ipv4;
|
["ipv4", "虚拟网IP"],
|
||||||
const proxyMember = data.proxy?.filter(proxy => proxy.src.startsWith(`${ipv4}:`));
|
["lat_ms", "延迟/ms"],
|
||||||
const proxyObj: Record<string, [string, "Connected" | "Closed"]> = {};
|
["loss_rate", "丢包率"],
|
||||||
for (const proxy of proxyMember) {
|
["nat_type", "NAT类型"],
|
||||||
proxyObj[proxy.dst.split(":")[0]] = [proxy.transport_type, proxy.state];
|
["version", "版本"],
|
||||||
}
|
["tunnel_proto", "隧道协议"],
|
||||||
return data.member.map(m => {
|
["rx_bytes", "接收"],
|
||||||
m.proxy = proxyObj?.[m.ipv4.split(":")?.[0]] || m?.proxy || ["", "Closed"];
|
["tx_bytes", "传输"]
|
||||||
return m;
|
];
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// 延迟排序函数
|
let timer: NodeJS.Timeout | null = null;
|
||||||
const sortLatMs = (a: Member, b: Member): number => {
|
|
||||||
const getLatencyValue = (row: Member): number => {
|
|
||||||
const latMs = row.lat_ms;
|
|
||||||
|
|
||||||
if (latMs === null || latMs === undefined || latMs === "") {
|
|
||||||
return Infinity;
|
|
||||||
}
|
|
||||||
|
|
||||||
const num = Number(latMs);
|
|
||||||
if (isNaN(num) || num < 0) {
|
|
||||||
return Infinity;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Math.floor(num);
|
|
||||||
};
|
|
||||||
|
|
||||||
const valueA = getLatencyValue(a);
|
|
||||||
const valueB = getLatencyValue(b);
|
|
||||||
|
|
||||||
if (valueA === Infinity && valueB === Infinity) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return valueA - valueB;
|
|
||||||
};
|
|
||||||
|
|
||||||
// IP地址排序函数
|
|
||||||
const sortIpv4 = (a: any, b: any): number => {
|
|
||||||
const ipToNumber = (ip: string): number => {
|
|
||||||
if (!ip || ip === "-" || ip === "") {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理可能包含端口号或子网掩码的情况
|
|
||||||
const cleanIp = ip.split("/")[0].split(":")[0];
|
|
||||||
const parts = cleanIp.split(".");
|
|
||||||
|
|
||||||
if (parts.length !== 4) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const nums = parts.map(part => {
|
|
||||||
const num = parseInt(part, 10);
|
|
||||||
return isNaN(num) || num < 0 || num > 255 ? 0 : num;
|
|
||||||
});
|
|
||||||
|
|
||||||
// 将IP地址转换为32位数字进行比较
|
|
||||||
return (nums[0] << 24) + (nums[1] << 16) + (nums[2] << 8) + nums[3];
|
|
||||||
} catch {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const numA = ipToNumber(a.ipv4);
|
|
||||||
const numB = ipToNumber(b.ipv4);
|
|
||||||
|
|
||||||
return numA - numB;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 字节数据排序函数
|
|
||||||
const sortBytes = (a: any, b: any, field: string = "rx_bytes"): number => {
|
|
||||||
const parseBytes = (bytesStr: string): number => {
|
|
||||||
if (!bytesStr || bytesStr === "-" || bytesStr === "") {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 统一转换为小写并去除空格
|
|
||||||
const cleanStr = bytesStr.toLowerCase().trim();
|
|
||||||
|
|
||||||
// 使用正则表达式匹配数字和单位
|
|
||||||
const match = cleanStr.match(/^(\d+(?:\.\d+)?)\s*([a-z]*)$/);
|
|
||||||
if (!match) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const value = parseFloat(match[1]);
|
|
||||||
const unit = match[2];
|
|
||||||
|
|
||||||
if (isNaN(value)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据单位转换为字节数
|
|
||||||
switch (unit) {
|
|
||||||
case "b":
|
|
||||||
case "byte":
|
|
||||||
case "bytes":
|
|
||||||
case "":
|
|
||||||
return value;
|
|
||||||
case "k":
|
|
||||||
case "kb":
|
|
||||||
case "kib":
|
|
||||||
return value * 1024;
|
|
||||||
case "m":
|
|
||||||
case "mb":
|
|
||||||
case "mib":
|
|
||||||
return value * 1024 * 1024;
|
|
||||||
case "g":
|
|
||||||
case "gb":
|
|
||||||
case "gib":
|
|
||||||
return value * 1024 * 1024 * 1024;
|
|
||||||
case "t":
|
|
||||||
case "tb":
|
|
||||||
case "tib":
|
|
||||||
return value * 1024 * 1024 * 1024 * 1024;
|
|
||||||
case "p":
|
|
||||||
case "pb":
|
|
||||||
case "pib":
|
|
||||||
return value * 1024 * 1024 * 1024 * 1024 * 1024;
|
|
||||||
default:
|
|
||||||
return value; // 未知单位当作字节处理
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const bytesA = parseBytes(a[field]);
|
|
||||||
const bytesB = parseBytes(b[field]);
|
|
||||||
|
|
||||||
return bytesA - bytesB;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 格式化延迟显示
|
|
||||||
const formatLatency = (latMs: any): string => {
|
|
||||||
if (latMs === null || latMs === undefined || latMs === "") {
|
|
||||||
return "-";
|
|
||||||
}
|
|
||||||
|
|
||||||
const num = Number(latMs);
|
|
||||||
if (isNaN(num)) {
|
|
||||||
return "-";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (num < 0) {
|
|
||||||
return "-";
|
|
||||||
}
|
|
||||||
|
|
||||||
return num.toFixed(0);
|
|
||||||
};
|
|
||||||
|
|
||||||
let timer: number | 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 "";
|
||||||
@@ -422,44 +176,20 @@
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const [errorConnections, connections] = await ATJ(invoke<string>("get_members_connections_cli"));
|
const peerInfo = parseCliInfo(member);
|
||||||
const memberConnections: ConnectionsType[] = JSON.parse(connections) as ConnectionsType[];
|
peerInfo.forEach(value => {
|
||||||
|
if (value.cost === "Local") {
|
||||||
if (errorConnections != "_EasytierGameCliFailedToGetConnections_") {
|
value.cost = "本机";
|
||||||
data.member = (JSON.parse(member) as Member[]).map(member => {
|
}
|
||||||
const connection = memberConnections.find(conn => String(conn.route.peer_id) === member.id);
|
if (value.ipv4 && value.ipv4.includes("/")) {
|
||||||
if (connection) {
|
value.ipv4 = value.ipv4.split("/")[0];
|
||||||
member.connections_addrs = connection?.peer?.conns?.map(conn => conn?.tunnel?.remote_addr?.url || "") || [];
|
}
|
||||||
} else {
|
});
|
||||||
member.connections_addrs = [];
|
// console.log(peerInfo)
|
||||||
}
|
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(() => {
|
||||||
|
|||||||
@@ -1,389 +0,0 @@
|
|||||||
<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>
|
|
||||||
+8
-90
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex h-full flex-col gap-[10px]">
|
<div class="flex flex-col gap-[10px] h-full">
|
||||||
<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 !mb-[0] !flex h-full flex-col overflow-hidden"
|
class="full-label full-content overflow-hidden !flex flex-col h-full !mb-[0]"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
<div class="flex items-center gap-[10px]">
|
<div class="flex items-center gap-[10px]">
|
||||||
@@ -27,17 +27,6 @@
|
|||||||
>
|
>
|
||||||
<ElCheckbox v-model="mainStore.serverConfig.autoStart">自动启动</ElCheckbox>
|
<ElCheckbox v-model="mainStore.serverConfig.autoStart">自动启动</ElCheckbox>
|
||||||
</ElTooltip>
|
</ElTooltip>
|
||||||
<ElTooltip
|
|
||||||
placement="top"
|
|
||||||
content="启用后,不允许使用了与本网络不同的房间名和密码的节点通过本节点进行握手或中转"
|
|
||||||
>
|
|
||||||
<ElCheckbox
|
|
||||||
@click.stop="handlePrivateModeClick"
|
|
||||||
:model-value="mainStore.serverConfig.privateMode"
|
|
||||||
>
|
|
||||||
私有模式
|
|
||||||
</ElCheckbox>
|
|
||||||
</ElTooltip>
|
|
||||||
<ElTooltip
|
<ElTooltip
|
||||||
placement="top"
|
placement="top"
|
||||||
content="帮助其他虚拟网建立P2P链接"
|
content="帮助其他虚拟网建立P2P链接"
|
||||||
@@ -47,7 +36,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<div class="flex h-full w-full flex-col overflow-hidden">
|
<div class="h-full w-full flex 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"
|
||||||
@@ -81,58 +70,6 @@
|
|||||||
</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"
|
||||||
@@ -144,14 +81,13 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import useMainStore from "@/stores/index";
|
import useMainStore from "@/stores/index";
|
||||||
import { reactive, onMounted, onBeforeUnmount, useTemplateRef, nextTick } from "vue";
|
import { reactive, onMounted, onBeforeUnmount } 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: "",
|
||||||
@@ -183,30 +119,12 @@
|
|||||||
|
|
||||||
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 });
|
||||||
};
|
};
|
||||||
|
|
||||||
// const privateModeDialogFormEl = useTemplateRef<FormInstance>("privateModeDialogFormRef");
|
dataSubscribe(async (...a) => {
|
||||||
|
return { serverConfig: { ...mainStore.serverConfig }};
|
||||||
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>
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
<template></template>
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { dataSubscribe } from "~/composables/windows";
|
|
||||||
|
|
||||||
dataSubscribe();
|
|
||||||
</script>
|
|
||||||
+33
-34
@@ -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="找不到游戏房间时,就开启它后再尝试搜索房间(默认开启)
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
<ElLink
|
<ElLink
|
||||||
class="mr-[10px] !text-[15px]"
|
class="mr-[10px] !text-[15px]"
|
||||||
type="info"
|
type="info"
|
||||||
underline="never"
|
:underline="false"
|
||||||
@click="open('https://github.com/dechamps/WinIPBroadcast/releases/tag/winipbroadcast-1.6')"
|
@click="open('https://github.com/dechamps/WinIPBroadcast/releases/tag/winipbroadcast-1.6')"
|
||||||
>
|
>
|
||||||
WinIPBroadcast
|
WinIPBroadcast
|
||||||
@@ -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>
|
||||||
方案1
|
方案2
|
||||||
<ElIcon class="ml-[3px]"><QuestionFilled /></ElIcon>
|
<ElIcon class="ml-[3px]"><QuestionFilled /></ElIcon>
|
||||||
</ElText>
|
</ElText>
|
||||||
</ElTooltip>
|
</ElTooltip>
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
<ElLink
|
<ElLink
|
||||||
class="!text-[15px]"
|
class="!text-[15px]"
|
||||||
type="info"
|
type="info"
|
||||||
underline="never"
|
:underline="false"
|
||||||
@click="open('https://r1ch.net/projects/forcebindip')"
|
@click="open('https://r1ch.net/projects/forcebindip')"
|
||||||
>
|
>
|
||||||
ForceBindIP
|
ForceBindIP
|
||||||
@@ -131,7 +131,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<ElTooltip content="设置网卡的跃点,提升网卡优先级,尝试将您联机使用的网卡跃点设置为最小,请先查询网卡信息">
|
<ElTooltip content="设置网卡的跃点,提升网卡优先级,尝试将您联机使用的网卡跃点设置为最小,请先查询网卡信息">
|
||||||
<ElText>
|
<ElText>
|
||||||
方案2
|
方案3
|
||||||
<ElIcon class="ml-[3px]"><QuestionFilled /></ElIcon>
|
<ElIcon class="ml-[3px]"><QuestionFilled /></ElIcon>
|
||||||
</ElText>
|
</ElText>
|
||||||
</ElTooltip>
|
</ElTooltip>
|
||||||
@@ -198,10 +198,16 @@
|
|||||||
<ElButton
|
<ElButton
|
||||||
type="warning"
|
type="warning"
|
||||||
size="small"
|
size="small"
|
||||||
@click.stop="handleCloseAllFireWall"
|
|
||||||
>
|
>
|
||||||
一键关闭防火墙
|
一键关闭防火墙
|
||||||
</ElButton>
|
</ElButton>
|
||||||
|
<ElButton
|
||||||
|
@click="handleCustomFireWall"
|
||||||
|
type="danger"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
自定义防火墙策略
|
||||||
|
</ElButton>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-[10px]">
|
<div class="mb-[10px]">
|
||||||
<ElText class="!mx-[10px]">域防火墙</ElText>
|
<ElText class="!mx-[10px]">域防火墙</ElText>
|
||||||
@@ -245,17 +251,10 @@
|
|||||||
<ElButton
|
<ElButton
|
||||||
size="small"
|
size="small"
|
||||||
:disabled="data.isPing"
|
:disabled="data.isPing"
|
||||||
@click="handleTestPing('v4')"
|
@click="handleTestPing"
|
||||||
>
|
>
|
||||||
Ping一下
|
Ping一下
|
||||||
</ElButton>
|
</ElButton>
|
||||||
<!-- <ElButton
|
|
||||||
size="small"
|
|
||||||
:disabled="data.isPing"
|
|
||||||
@click="handleTestPing('v6')"
|
|
||||||
>
|
|
||||||
Ping一下(v6)
|
|
||||||
</ElButton> -->
|
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-[5px] flex-1 overflow-auto">
|
<div class="mt-[5px] flex-1 overflow-auto">
|
||||||
<ElInput
|
<ElInput
|
||||||
@@ -306,18 +305,8 @@
|
|||||||
forceBindStart: false
|
forceBindStart: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const handleCustomFireWall = async () => {
|
||||||
const handleCloseAllFireWall = async () => {
|
await open("wf.msc");
|
||||||
try {
|
|
||||||
const output = await Command.create("netsh", ["advfirewall", "set", "allprofiles", "state", "off"], {
|
|
||||||
encoding: "gb2312"
|
|
||||||
}).execute();
|
|
||||||
ElMessage.success("关闭成功");
|
|
||||||
await initFirewall();
|
|
||||||
} catch (err) {
|
|
||||||
ElMessage.error(`关闭失败${err}`);
|
|
||||||
console.error(err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleTabsChange = async (tabPaneName: TabPaneName) => {
|
const handleTabsChange = async (tabPaneName: TabPaneName) => {
|
||||||
@@ -352,15 +341,14 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTestPing = async (type: 'v4' | 'v6' = 'v4') => {
|
const handleTestPing = async () => {
|
||||||
// const is = isValidIP(data.pingIp);
|
// const is = isValidIP(data.pingIp);
|
||||||
if (data.pingIp) {
|
if (data.pingIp) {
|
||||||
data.pingLog = "";
|
data.pingLog = "";
|
||||||
data.isPing = true;
|
data.isPing = true;
|
||||||
const args = type === 'v4' ? ["-n", "1", data.pingIp] : ["-6", '-n', "1", data.pingIp]
|
|
||||||
try {
|
try {
|
||||||
for (let i = 0; i < data.pingNum; i++) {
|
for (let i = 0; i < data.pingNum; i++) {
|
||||||
const output = await Command.create("ping", args, {
|
const output = await Command.create("ping", ["-n", "1", data.pingIp], {
|
||||||
encoding: "gb2312"
|
encoding: "gb2312"
|
||||||
}).execute();
|
}).execute();
|
||||||
if (output.stdout) {
|
if (output.stdout) {
|
||||||
@@ -489,6 +477,19 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dataSubscribe(async (...a) => {
|
||||||
|
return {
|
||||||
|
winIpBcAutoStart: mainStore.winIpBcAutoStart,
|
||||||
|
winipBcStart: mainStore.winipBcStart,
|
||||||
|
winipBcPid: mainStore.winipBcPid,
|
||||||
|
forceBindIpBit: mainStore.forceBindIpBit,
|
||||||
|
delayInjectDll: mainStore.delayInjectDll,
|
||||||
|
forceBindInput: mainStore.forceBindInput,
|
||||||
|
forceBindFile: mainStore.forceBindFile,
|
||||||
|
config: { ...mainStore.config }
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
const getGuids = async () => {
|
const getGuids = async () => {
|
||||||
const guids = await invoke<string[][]>("get_network_adapter_guids");
|
const guids = await invoke<string[][]>("get_network_adapter_guids");
|
||||||
data.guids = guids && guids.length > 0 ? guids : [];
|
data.guids = guids && guids.length > 0 ? guids : [];
|
||||||
@@ -502,9 +503,7 @@
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
data.pingIp = mainStore.config.ipv4;
|
data.pingIp = mainStore.config.ipv4;
|
||||||
// initStartWinIpBroadcast();
|
initStartWinIpBroadcast();
|
||||||
getGuids();
|
getGuids();
|
||||||
});
|
});
|
||||||
|
|
||||||
dataSubscribe();
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Generated
+3061
-3916
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 130 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
@@ -1,6 +1,6 @@
|
|||||||
# Generated by Cargo
|
# Generated by Cargo
|
||||||
# will have compiled files and executables
|
# will have compiled files and executables
|
||||||
target/
|
/target/
|
||||||
gen/schemas
|
/gen/schemas
|
||||||
./easytier/logs
|
/easytier/logs
|
||||||
easytier/logs
|
/easytier/logs/*.*
|
||||||
Generated
+1537
-1727
File diff suppressed because it is too large
Load Diff
+21
-24
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "easytier-game"
|
name = "easytier-game"
|
||||||
version = "1.5.2"
|
version = "1.3.7"
|
||||||
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,44 +18,41 @@ name = "app_lib"
|
|||||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-build = { version = "2.5.1", features = [] }
|
tauri-build = { version = "2.0.5", features = [] }
|
||||||
# prost-build = "0.13.2"
|
# prost-build = "0.13.2"
|
||||||
|
|
||||||
[target.x86_64-pc-windows-msvc.build-dependencies]
|
|
||||||
thunk-rs = { git = "https://github.com/easytier/thunk.git", default-features = false, features = ["win7"] } # 需要安装curl和7zip,并添加他们的路径到环境变量
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde_json = "1.0.137"
|
serde_json = "1.0.135"
|
||||||
serde = { version = "1.0.217", features = ["derive"] }
|
serde = { version = "1.0.217", features = ["derive"] }
|
||||||
log = "0.4.26"
|
log = "0.4.25"
|
||||||
tauri = { version = "2.9.1", features = [ "protocol-asset",
|
tauri = { version = "2.2.2", features = [
|
||||||
"tray-icon",
|
"tray-icon",
|
||||||
"image-png",
|
"image-png",
|
||||||
"image-ico"
|
"image-ico",
|
||||||
|
"devtools"
|
||||||
] }
|
] }
|
||||||
|
|
||||||
tauri-plugin-log = "2.7.0"
|
tauri-plugin-log = "2.2.0"
|
||||||
tauri-plugin-shell = "2.3.1"
|
tauri-plugin-shell = "2.2.0"
|
||||||
reqwest = { version = "0.12.12", features = ["json"] }
|
reqwest = { version = "0.12.12", features = ["json"] }
|
||||||
zip = "2.2.3"
|
zip = "2.2.2"
|
||||||
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.4.2"
|
tauri-plugin-fs = "2.2.0"
|
||||||
tauri-plugin-clipboard-manager = "2.3.0"
|
tauri-plugin-clipboard-manager = "2.2.0"
|
||||||
rand = "0.9.0"
|
rand = "0.8.5"
|
||||||
tokio = { version = "1.45.1", features = ["process"] }
|
tokio = { version = "1.43.0", features = ["process"] }
|
||||||
tauri-plugin-dialog = "2.4.0"
|
tauri-plugin-dialog = "2.2.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"
|
|
||||||
|
|
||||||
[dependencies.windows]
|
[dependencies.windows]
|
||||||
version = "0.61.3"
|
version = "0.58.0"
|
||||||
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_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.4.0"
|
tauri-plugin-cli = "2.2.0"
|
||||||
tauri-plugin-single-instance = "2.3.4"
|
tauri-plugin-single-instance = "2.2.1"
|
||||||
tauri-plugin-window-state = "2.4.0"
|
tauri-plugin-window-state = "2.2.0"
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
thunk::thunk();
|
|
||||||
let mut windows = tauri_build::WindowsAttributes::new();
|
let mut windows = tauri_build::WindowsAttributes::new();
|
||||||
windows = windows.app_manifest(
|
windows = windows.app_manifest(
|
||||||
r#"
|
r#"
|
||||||
|
|||||||
@@ -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", "nodesList", "cidr", "advance", "tool", "server", "gameList", "storage-listener"],
|
"windows": ["main", "log", "member", "cidr", "advance", "tool", "server"],
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"core:default",
|
"core:default",
|
||||||
"core:window:allow-minimize",
|
"core:window:allow-minimize",
|
||||||
@@ -26,7 +26,6 @@
|
|||||||
"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": [
|
||||||
@@ -89,19 +88,11 @@
|
|||||||
"args": true,
|
"args": true,
|
||||||
"cmd": "ping",
|
"cmd": "ping",
|
||||||
"name": "ping"
|
"name": "ping"
|
||||||
},
|
|
||||||
{
|
|
||||||
"args": true,
|
|
||||||
"cmd": "powershell",
|
|
||||||
"name": "powershell"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"fs:default",
|
"fs:default",
|
||||||
{
|
"fs:allow-read-dir",
|
||||||
"identifier": "fs:allow-read-dir",
|
|
||||||
"allow": [{ "path": "$DESKTOP" }, { "path": "$DESKTOP/*" }, { "path": "**/*" }, { "path": "**" }]
|
|
||||||
},
|
|
||||||
"fs:allow-exists",
|
"fs:allow-exists",
|
||||||
"fs:allow-open",
|
"fs:allow-open",
|
||||||
"fs:allow-resource-read",
|
"fs:allow-resource-read",
|
||||||
|
|||||||
@@ -4,43 +4,25 @@
|
|||||||
"tcp",
|
"tcp",
|
||||||
"udp"
|
"udp"
|
||||||
], // 协议类型
|
], // 协议类型
|
||||||
|
|
||||||
// easytier服务地址 - 可填写多个 方式1,逗号分隔,"xxxx.cn,yyyy.com" 方式2,数组 ["xxxx.cn","yyyy.com"] (默认选中第一个)
|
// easytier服务地址 - 可填写多个 方式1,逗号分隔,"xxxx.cn,yyyy.com" 方式2,数组 ["xxxx.cn","yyyy.com"] (默认选中第一个)
|
||||||
"serverUrl": "public.easytier.top:11010",
|
"serverUrl": "public.easytier.top:11010",
|
||||||
"enableCustomListener": true,
|
"networkName": "", // 网络名
|
||||||
"customListenerData": [
|
"networkPassword": "", // 网络密码
|
||||||
"tcp://0.0.0.0:11010",
|
"hostname": "configTest", // 主机名
|
||||||
"udp://0.0.0.0:11010"
|
"ipv4": "10.126.126.1", // IP地址(选填,下面有dhcp)
|
||||||
],
|
"disableIpv6": false, // 禁用ipv6
|
||||||
"networkName": "", //房间名
|
"disbleListenner": true, // 禁用端口监听
|
||||||
"networkPassword": "", //房间密码
|
|
||||||
"hostname": "", //主机名
|
|
||||||
"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
|
|
||||||
"disbleListenner": false, // 禁用监听
|
|
||||||
"disableEncryption": false, // 禁用加密
|
"disableEncryption": false, // 禁用加密
|
||||||
"enablExitNode": false, // 启用出口节点
|
|
||||||
"noTun": false, // 禁用tun
|
"noTun": false, // 禁用tun
|
||||||
"latencyfirst": false, // 延迟优先
|
"latencyfirst": false, // 延迟优先
|
||||||
"disableUdpHolePunching": false, // 禁用udp打洞
|
"disableUdpHolePunching": false, // 禁用udp打洞
|
||||||
"disbleP2p": false, // 禁用p2p 强制中转
|
"disbleP2p": false, // 禁用p2p, 强制中转
|
||||||
"dhcp": true, // 启用dhcp,动态获取IP
|
"dhcp": false, // 动态分配IP
|
||||||
"devName": true, // 启用自定义网卡名
|
"devName": false, // 是否启用自定义网卡名
|
||||||
"devNameValue": "etgame", // 自定义网卡名
|
"devNameValue": "", // 网卡名(启用devName之后才生效)
|
||||||
"enableCustomProtocol": true, // 自定义p2p时默认协议
|
"enableCustonProtocol": false, // 是否启用自定义协议
|
||||||
"customProtocol": "tcp", // 自定义p2p时使用的协议类型
|
"customProtocol": "tcp", // 自定义协议类型
|
||||||
"enableNetCardMetric": true, // 启用自定义网卡跃点
|
"enableNetCardMetric": false, // 自定义easytier每次生成的网卡跃点
|
||||||
"netCardMetricValue": 1, // 网卡跃点
|
"netCardMetricValue": 1 // 网卡跃点数量(1-9999)
|
||||||
"enablePreventSleep": false, // 启用防止睡眠
|
|
||||||
"compression": "none", // 压缩算法
|
|
||||||
"enableKcpProxy": true, // 启用kcp代理,就不能启用quic代理
|
|
||||||
"disableKcpInput": false, // 禁用kcp输入
|
|
||||||
"enableQuicProxy": false, // 启用quic代理,就不能启用kcp代理
|
|
||||||
"disableQuicInput": false, // 禁用quic输入
|
|
||||||
"privateMode": false // 启用私有模式
|
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
+49
-250
@@ -1,5 +1,8 @@
|
|||||||
|
use planif::enums::TaskCreationFlags;
|
||||||
|
use planif::schedule::TaskScheduler as planIfTaskScheduler;
|
||||||
|
use planif::schedule_builder::{Action, ScheduleBuilder};
|
||||||
|
use planif::settings::{Duration, LogonType, PrincipalSettings, RunLevel};
|
||||||
use reqwest::{Client, Error};
|
use reqwest::{Client, Error};
|
||||||
// use futures_util::StreamExt;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
@@ -13,7 +16,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};
|
use windows::core::{BSTR, VARIANT};
|
||||||
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,7 +24,6 @@ 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;
|
||||||
@@ -89,13 +91,13 @@ fn generate_random_user_agent() -> String {
|
|||||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:{version}) Gecko/20100101 Firefox/{version}",
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:{version}) Gecko/20100101 Firefox/{version}",
|
||||||
];
|
];
|
||||||
|
|
||||||
let mut rng = rand::rng();
|
let mut rng = rand::thread_rng();
|
||||||
let template = user_agents[rng.random_range(0..user_agents.len())];
|
let template = user_agents[rng.gen_range(0..user_agents.len())];
|
||||||
|
|
||||||
// 生成随机版本号
|
// 生成随机版本号
|
||||||
let version_major: u8 = rng.random_range(70..90);
|
let version_major: u8 = rng.gen_range(70..90);
|
||||||
let version_minor: u8 = rng.random_range(0..10);
|
let version_minor: u8 = rng.gen_range(0..10);
|
||||||
let version_patch: u8 = rng.random_range(0..10);
|
let version_patch: u8 = rng.gen_range(0..10);
|
||||||
let version = format!("{}.{}.{}", version_major, version_minor, version_patch);
|
let version = format!("{}.{}.{}", version_major, version_minor, version_patch);
|
||||||
|
|
||||||
// 替换模板中的版本号占位符
|
// 替换模板中的版本号占位符
|
||||||
@@ -269,13 +271,10 @@ struct MyResponse {
|
|||||||
response: PeerRoute,
|
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)
|
||||||
@@ -299,69 +298,10 @@ 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()
|
||||||
@@ -385,44 +325,7 @@ async fn get_route_by_cli() -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command(rename_all = "snake_case")]
|
#[tauri::command(rename_all = "snake_case")]
|
||||||
async fn fetch_nodes_list(page: u64, limit: u64) -> String {
|
async fn download_easytier_zip(download_url: String, file_name: 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);
|
||||||
@@ -432,12 +335,12 @@ async fn download_easytier_zip(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let target = format!("{}", download_url);
|
let target = format!("{}", download_url);
|
||||||
let mut response = reqwest::get(target)
|
let response = reqwest::get(target)
|
||||||
.await
|
.await
|
||||||
.expect("error to download easytier url");
|
.expect("error to download easytier url");
|
||||||
let easytier_path = get_tool_exe_path("\\easytier");
|
let easytier_path = get_tool_exe_path("\\easytier");
|
||||||
let file_path = format!("{}\\{}", easytier_path, file_name);
|
let file_path = format!("{}\\{}", easytier_path, file_name);
|
||||||
// println!("download easytier to {}", file_path);
|
println!("download easytier to {}", file_path);
|
||||||
|
|
||||||
let easytier_dir = path::Path::new(&easytier_path);
|
let easytier_dir = path::Path::new(&easytier_path);
|
||||||
if !easytier_dir.exists() {
|
if !easytier_dir.exists() {
|
||||||
@@ -446,35 +349,16 @@ async fn download_easytier_zip(
|
|||||||
|
|
||||||
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),
|
||||||
Ok(file) => file,
|
Ok(file) => file,
|
||||||
};
|
};
|
||||||
let context_size: u64 = response.content_length().unwrap();
|
|
||||||
while let Some(item) = response.chunk().await.unwrap() {
|
let content = response.bytes().await.expect("error to bytes easytier");
|
||||||
match file.write_all(&item) {
|
println!("下载完成,开始写入");
|
||||||
Ok(_) => {
|
file.write_all(&content).expect("error to write easytier");
|
||||||
app_handle
|
println!("写入完成");
|
||||||
.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);
|
|
||||||
app_handle
|
|
||||||
.emit("download_core_progress_error", why.to_string())
|
|
||||||
.expect("error to emit download_core_progress_error");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
println!("下载完成");
|
|
||||||
unzip(path);
|
unzip(path);
|
||||||
|
|
||||||
let cache_dir_path = path::Path::new(&cache_dir_path);
|
let cache_dir_path = path::Path::new(&cache_dir_path);
|
||||||
@@ -622,19 +506,18 @@ 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; 4]>> {
|
async fn fetch_easytier_list() -> Vec<Vec<[String; 3]>> {
|
||||||
// 获取release列表
|
// 获取release列表
|
||||||
if let Ok(release) = fetch_releases().await {
|
if let Ok(release) = fetch_releases().await {
|
||||||
let mut release_list: Vec<Vec<[String; 4]>> = Vec::new();
|
let mut release_list = Vec::new();
|
||||||
for re in release {
|
for re in release {
|
||||||
let mut assets_list: Vec<[String; 4]> = Vec::new();
|
let mut assets_list = 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(),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -753,60 +636,16 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增辅助函数
|
|
||||||
fn ensure_task_folder_and_cleanup(
|
|
||||||
task_service: &ITaskService,
|
|
||||||
folder_path: &BSTR,
|
|
||||||
task_name: &BSTR,
|
|
||||||
) -> Result<ITaskFolder, Box<dyn std::error::Error>> {
|
|
||||||
unsafe {
|
|
||||||
let root = BSTR::from("\\");
|
|
||||||
let root_folder: ITaskFolder = task_service.GetFolder(&root)?;
|
|
||||||
|
|
||||||
match task_service.GetFolder(folder_path) {
|
|
||||||
Ok(existing_folder) => {
|
|
||||||
println!("任务文件夹已存在: {}", folder_path);
|
|
||||||
|
|
||||||
// 检查并清理现有任务
|
|
||||||
if let Ok(_existing_task) = existing_folder.GetTask(task_name) {
|
|
||||||
println!("发现同名任务: {},准备删除", task_name);
|
|
||||||
match existing_folder.DeleteTask(task_name, 0) {
|
|
||||||
Ok(_) => println!("成功删除现有任务"),
|
|
||||||
Err(e) => {
|
|
||||||
log::error!("删除现有任务失败: {}", e);
|
|
||||||
// 继续执行,尝试覆盖
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(existing_folder)
|
|
||||||
}
|
|
||||||
Err(_) => {
|
|
||||||
println!("创建新的任务文件夹: {}", folder_path);
|
|
||||||
match root_folder.CreateFolder(folder_path, &VARIANT::default()) {
|
|
||||||
Ok(new_folder) => {
|
|
||||||
println!("成功创建任务文件夹");
|
|
||||||
Ok(new_folder)
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
log::error!("创建任务文件夹失败: {}", e);
|
|
||||||
Err(e.into())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// pub const AUTOSTART_ARG: &str = "--autostart";
|
// pub const AUTOSTART_ARG: &str = "--autostart";
|
||||||
pub const TASKAUTOSTART_ARG: &str = "--task-auto-start";
|
pub const TASKAUTOSTART_ARG: &str = "--task-auto-start";
|
||||||
fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error>> {
|
fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error>> {
|
||||||
@@ -841,70 +680,33 @@ fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error
|
|||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unsafe {
|
let ts = planIfTaskScheduler::new()?;
|
||||||
let task_service: ITaskService = CoCreateInstance(&TaskScheduler, None, CLSCTX_ALL)?;
|
let com = ts.get_com();
|
||||||
task_service.Connect(
|
let sb = ScheduleBuilder::new(&com).unwrap();
|
||||||
&VARIANT::default(),
|
|
||||||
&VARIANT::default(),
|
|
||||||
&VARIANT::default(),
|
|
||||||
&VARIANT::default(),
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let folder_path = BSTR::from("\\easytierGame");
|
let exe = std::env::current_exe()?;
|
||||||
let task_name = BSTR::from("auto start");
|
let exe = exe.to_str().unwrap();
|
||||||
|
|
||||||
let task_definition = task_service.NewTask(0)?;
|
let settings = PrincipalSettings {
|
||||||
|
display_name: "".to_string(),
|
||||||
// 设置任务信息
|
group_id: None,
|
||||||
let registration_info = task_definition.RegistrationInfo()?;
|
id: "".to_string(),
|
||||||
registration_info.SetDescription(&BSTR::from("EasytierGame auto start task"))?;
|
logon_type: LogonType::InteractiveToken,
|
||||||
registration_info.SetAuthor(&BSTR::from("EasytierGame"))?;
|
run_level: RunLevel::Highest,
|
||||||
|
user_id: Some(whoami::username()),
|
||||||
// 改为用户登录触发
|
};
|
||||||
let triggers = task_definition.Triggers()?;
|
sb.create_logon()
|
||||||
let trigger = triggers.Create(TASK_TRIGGER_LOGON)?;
|
.author("heixiansen")?
|
||||||
let logon_trigger: ILogonTrigger = trigger.cast()?;
|
.trigger("trigger", enabled)?
|
||||||
logon_trigger.SetEnabled(VARIANT_BOOL::from(true))?;
|
.action(Action::new("auto start", exe, "", &TASKAUTOSTART_ARG))?
|
||||||
|
.in_folder("easytierGame")?
|
||||||
// 设置动作
|
.principal(settings)?
|
||||||
let actions = task_definition.Actions()?;
|
.delay(Duration {
|
||||||
let action = actions.Create(TASK_ACTION_EXEC)?;
|
seconds: Some(6),
|
||||||
let exec_action: IExecAction = action.cast()?;
|
..Default::default()
|
||||||
let exe = std::env::current_exe()?;
|
})?
|
||||||
let exe_path: &str = exe.to_str().unwrap();
|
.build()?
|
||||||
exec_action.SetPath(&BSTR::from(exe_path))?;
|
.register("auto start", TaskCreationFlags::CreateOrUpdate as i32)?;
|
||||||
exec_action.SetArguments(&BSTR::from("--task-auto-start"))?;
|
|
||||||
|
|
||||||
let principal = task_definition.Principal()?;
|
|
||||||
principal.SetUserId(&BSTR::from(whoami::username().as_str()))?;
|
|
||||||
principal.SetLogonType(TASK_LOGON_INTERACTIVE_TOKEN)?;
|
|
||||||
principal.SetRunLevel(TASK_RUNLEVEL_HIGHEST)?;
|
|
||||||
|
|
||||||
// 设置任务设置
|
|
||||||
let settings = task_definition.Settings()?;
|
|
||||||
settings.SetEnabled(VARIANT_BOOL::from(true))?;
|
|
||||||
settings.SetCompatibility(TASK_COMPATIBILITY_V2)?; // Windows 7
|
|
||||||
settings.SetStartWhenAvailable(VARIANT_BOOL::from(true))?;
|
|
||||||
// settings.SetHidden(VARIANT_BOOL::from(true))?; // 注释掉让任务可见
|
|
||||||
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 _auto_task = task_folder.RegisterTaskDefinition(
|
|
||||||
&task_name,
|
|
||||||
&task_definition,
|
|
||||||
TASK_CREATE_OR_UPDATE.0,
|
|
||||||
&VARIANT::default(),
|
|
||||||
&VARIANT::default(),
|
|
||||||
TASK_LOGON_INTERACTIVE_TOKEN,
|
|
||||||
&VARIANT::default(),
|
|
||||||
)?;
|
|
||||||
|
|
||||||
CoUninitialize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -987,10 +789,7 @@ 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,25 +1,26 @@
|
|||||||
{
|
{
|
||||||
"$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.5.2",
|
"version": "1.3.7",
|
||||||
"identifier": "com.tauri.easytier-game",
|
"identifier": "com.tauri.easytier-game",
|
||||||
|
|
||||||
"build": {
|
"build": {
|
||||||
"frontendDist": "../dist",
|
"frontendDist": "../dist",
|
||||||
"devUrl": "http://localhost:5000",
|
"devUrl": "http://localhost:5000",
|
||||||
|
"beforeBuildCommand": "pnpm build",
|
||||||
"beforeDevCommand": "pnpm dev"
|
"beforeDevCommand": "pnpm dev"
|
||||||
},
|
},
|
||||||
"app": {
|
"app": {
|
||||||
"windows": [
|
"windows": [
|
||||||
{
|
{
|
||||||
"title": "easytier-game 1.5.2",
|
"title": "easytier-game 1.3.7",
|
||||||
"label": "main",
|
"label": "main",
|
||||||
"minWidth": 340,
|
"minWidth": 340,
|
||||||
"width": 340,
|
"width": 340,
|
||||||
"height": 305,
|
"height": 305,
|
||||||
"minHeight": 305,
|
"minHeight": 305,
|
||||||
"maxHeight": 405,
|
"maxHeight": 305,
|
||||||
"maxWidth": 460,
|
"maxWidth": 360,
|
||||||
"resizable": true,
|
"resizable": true,
|
||||||
"fullscreen": false,
|
"fullscreen": false,
|
||||||
"decorations": true,
|
"decorations": true,
|
||||||
@@ -30,11 +31,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"security": {
|
"security": {
|
||||||
"csp": null,
|
"csp": null
|
||||||
"assetProtocol": {
|
|
||||||
"enable": true,
|
|
||||||
"scope": ["**"]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"plugins": {
|
"plugins": {
|
||||||
@@ -72,9 +69,7 @@
|
|||||||
"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"]
|
||||||
|
|||||||
+1
-3
@@ -8,14 +8,12 @@
|
|||||||
|
|
||||||
|
|
||||||
[如果想彻底删除easytierGame]
|
[如果想彻底删除easytierGame]
|
||||||
--
|
|
||||||
1. 关闭easytierGame
|
1. 关闭easytierGame
|
||||||
|
|
||||||
2. 运行easytier-game安装目录下的 easytier/clear_local_data.bat (需要管理员权限) 输入y确认,清除本地存储数据
|
2. 运行easytier-game安装目录下的 easytier/clear_local_data.bat (需要管理员权限) 输入y确认,清除本地存储数据
|
||||||
|
|
||||||
3. 删除easytierGame文件夹
|
3. 删除easytierGame文件夹
|
||||||
--
|
|
||||||
或者直接使用uninstall.exe
|
|
||||||
|
|
||||||
|
|
||||||
[没有服务器,怎么自建服务]
|
[没有服务器,怎么自建服务]
|
||||||
|
|||||||
+13
-61
@@ -1,29 +1,23 @@
|
|||||||
import { acceptHMRUpdate, defineStore } from "pinia";
|
import { acceptHMRUpdate, defineStore } from "pinia";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const store = defineStore("main", {
|
const store = defineStore("main", {
|
||||||
state() {
|
state() {
|
||||||
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: "0", // 监听端口号
|
port: "11010", // 监听端口号
|
||||||
enableCustomListener: true, // 是否自定义监听
|
enableCustomListener: true, // 是否自定义监听
|
||||||
customListenerData: "tcp://0.0.0.0:11010\nudp://0.0.0.0:11010", // 自定义监听地址
|
customListenerV6Data: "udp://[::]:11010", //自定义ipv6监听
|
||||||
|
enableCustomListenerV6: true, // 是否自定义监听
|
||||||
|
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, //使用多线程
|
||||||
@@ -45,16 +39,6 @@ const store = defineStore("main", {
|
|||||||
netCardMetricValue: 1, //自定义网卡跃点值
|
netCardMetricValue: 1, //自定义网卡跃点值
|
||||||
enablePreventSleep: false, //组织系统休眠
|
enablePreventSleep: false, //组织系统休眠
|
||||||
compression: "none", //加密算法
|
compression: "none", //加密算法
|
||||||
enableKcpProxy: true, //启用kcp代理 默认开启
|
|
||||||
disableKcpInput: false, //禁用kcp输入
|
|
||||||
enableQuicProxy: false, //启用quic代理 默认开启
|
|
||||||
disableQuicInput: false, //禁用quic输入
|
|
||||||
bindDeviceEnable: false, //是否绑定设备
|
|
||||||
acceptDNS: false, //魔法dns
|
|
||||||
privateMode: false, //是否启用私有模式
|
|
||||||
|
|
||||||
enablePortForward: false, //是否启用端口转发
|
|
||||||
portForwardData: "", //端口转发数据
|
|
||||||
},
|
},
|
||||||
serverConfig: {
|
serverConfig: {
|
||||||
enableWhiteList: true, // 是否启用白名单
|
enableWhiteList: true, // 是否启用白名单
|
||||||
@@ -62,20 +46,16 @@ const store = defineStore("main", {
|
|||||||
serverWhiteList: "", // 服务器流量转发白名单
|
serverWhiteList: "", // 服务器流量转发白名单
|
||||||
// enableListener: true, // 是否启用监听
|
// enableListener: true, // 是否启用监听
|
||||||
autoStart: false, //随软件自启
|
autoStart: false, //随软件自启
|
||||||
port: "11010", // 服务器端口
|
port: "11010" // 服务器端口
|
||||||
privateMode: false, //是否启用私有模式
|
|
||||||
privateNetworkName: "", // 私有模式房间名
|
|
||||||
privateNetworkPassword: "", // 私有模式密码
|
|
||||||
},
|
},
|
||||||
cidrEnable: false,
|
cidrEnable: false,
|
||||||
proxyForwardBySystem: false, // 是否通过系统内核转发子网代理数据包,禁用内置NAT
|
basePeers: ["public.easytier.top:11010","public.easytier.net:11010"],
|
||||||
basePeers: ["public.easytier.top:11010", "public.easytier.net:11010"],
|
|
||||||
theme: false, //主题 false light true dark
|
theme: false, //主题 false light true dark
|
||||||
configStartEnable: false, //使用配置文件启动
|
configStartEnable: false, //使用配置文件启动
|
||||||
configPath: "", //配置文件路径
|
configPath: "", //配置文件路径
|
||||||
winIpBcAutoStart: true,
|
winIpBcAutoStart: true,
|
||||||
createConfigInEasytier: false, //在easytier目录生成config.json文件吗
|
createConfigInEasytier: false, //在easytier目录生成config.json文件吗
|
||||||
githubFastUrl: "https://ghfast.top/",
|
githubFastUrl: "https://ghproxy.cc/",
|
||||||
|
|
||||||
// forceBindIp配置
|
// forceBindIp配置
|
||||||
forceBindIpBit: "64",
|
forceBindIpBit: "64",
|
||||||
@@ -84,10 +64,7 @@ const store = defineStore("main", {
|
|||||||
forceBindFile: "",
|
forceBindFile: "",
|
||||||
|
|
||||||
winipBcPid: 0,
|
winipBcPid: 0,
|
||||||
winipBcStart: false,
|
winipBcStart: false
|
||||||
latestTagName: "",
|
|
||||||
|
|
||||||
gameList: [] as Array<{ name: string; exePath: string; id: string; coverImg?: string; showImg: string }> // 游戏列表
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
persist: {
|
persist: {
|
||||||
@@ -99,7 +76,6 @@ 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",
|
||||||
@@ -121,47 +97,26 @@ 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.portForwardData",
|
|
||||||
|
|
||||||
"config.disbleListenner",
|
"config.disbleListenner",
|
||||||
"config.enableCustomListener",
|
"config.enableCustomListener",
|
||||||
"config.customListenerData",
|
"config.customListenerData",
|
||||||
|
"config.enableCustomListenerV6",
|
||||||
|
"config.customListenerV6Data",
|
||||||
|
|
||||||
"config.enableCustomProtocol",
|
"config.enableCustomProtocol",
|
||||||
"config.customProtocol",
|
"config.customProtocol",
|
||||||
"config.enablePreventSleep",
|
"config.enablePreventSleep",
|
||||||
"config.compression",
|
"config.compression",
|
||||||
|
|
||||||
"config.enableKcpProxy",
|
|
||||||
"config.disableKcpInput",
|
|
||||||
"config.enableQuicProxy",
|
|
||||||
"config.disableQuicInput",
|
|
||||||
|
|
||||||
|
|
||||||
"config.bindDeviceEnable",
|
|
||||||
|
|
||||||
"config.acceptDNS",
|
|
||||||
|
|
||||||
"config.privateMode",
|
|
||||||
|
|
||||||
"serverConfig.autoStart",
|
"serverConfig.autoStart",
|
||||||
// 'serverConfig.enableListener',
|
// 'serverConfig.enableListener',
|
||||||
"serverConfig.enableWhiteList",
|
"serverConfig.enableWhiteList",
|
||||||
"serverConfig.relayAllPeerrpc",
|
"serverConfig.relayAllPeerrpc",
|
||||||
"serverConfig.serverWhiteList",
|
"serverConfig.serverWhiteList",
|
||||||
"serverConfig.port",
|
"serverConfig.port",
|
||||||
"serverConfig.privateMode",
|
|
||||||
"serverConfig.privateNetworkName",
|
|
||||||
"serverConfig.privateNetworkPassword",
|
|
||||||
|
|
||||||
"cidrEnable",
|
"cidrEnable",
|
||||||
"proxyForwardBySystem",
|
|
||||||
"basePeers",
|
"basePeers",
|
||||||
"theme",
|
"theme",
|
||||||
"configStartEnable",
|
"configStartEnable",
|
||||||
@@ -173,10 +128,7 @@ const store = defineStore("main", {
|
|||||||
"forceBindIpBit",
|
"forceBindIpBit",
|
||||||
"delayInjectDll",
|
"delayInjectDll",
|
||||||
"forceBindInput",
|
"forceBindInput",
|
||||||
"forceBindFile",
|
"forceBindFile"
|
||||||
"latestTagName",
|
|
||||||
|
|
||||||
"gameList"
|
|
||||||
]
|
]
|
||||||
// // 除了这些,其他都要存下来
|
// // 除了这些,其他都要存下来
|
||||||
// omit: ["winipBcPid", "winipBcStart"]
|
// omit: ["winipBcPid", "winipBcStart"]
|
||||||
|
|||||||
Vendored
-48
@@ -4,56 +4,8 @@ interface ImportMetaEnv {
|
|||||||
readonly VITE_LOG_PATH: string;
|
readonly VITE_LOG_PATH: string;
|
||||||
readonly VITE_CACHE_PATH: string;
|
readonly VITE_CACHE_PATH: string;
|
||||||
readonly VITE_AUTO_START_SERVICE_NAME: string;
|
readonly VITE_AUTO_START_SERVICE_NAME: string;
|
||||||
readonly VITE_GAME_LIST_PATH: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|||||||
+3
-3
@@ -4,7 +4,7 @@ import { h, type VNode } from "vue";
|
|||||||
type Opt = { action?: string; confirmButtonText?: string; cancelButtonText?: string; VNode?: VNode | null, showCancelButton?:boolean }
|
type Opt = { action?: string; confirmButtonText?: string; cancelButtonText?: string; VNode?: VNode | null, showCancelButton?:boolean }
|
||||||
export const ElConfirmDanger = (
|
export const ElConfirmDanger = (
|
||||||
content: string,
|
content: string,
|
||||||
title: string = "提示",
|
title: string,
|
||||||
opt: Opt = {
|
opt: Opt = {
|
||||||
action: "",
|
action: "",
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
@@ -40,7 +40,7 @@ export const ElConfirmDanger = (
|
|||||||
|
|
||||||
export const ElConfirmSucces = (
|
export const ElConfirmSucces = (
|
||||||
content: string,
|
content: string,
|
||||||
title: string = "提示",
|
title: string,
|
||||||
opt: Opt = {
|
opt: Opt = {
|
||||||
action: "",
|
action: "",
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
@@ -76,7 +76,7 @@ export const ElConfirmSucces = (
|
|||||||
|
|
||||||
export const ElConfirmPrimary = (
|
export const ElConfirmPrimary = (
|
||||||
content: string,
|
content: string,
|
||||||
title: string = "提示",
|
title: string,
|
||||||
opt: Opt = {
|
opt: Opt = {
|
||||||
action: "",
|
action: "",
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
|
|||||||
+13
-85
@@ -1,19 +1,10 @@
|
|||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
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 { 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: number | null = null;
|
let bounceTimer: NodeJS.Timeout | null = null;
|
||||||
return (cb: Function) => {
|
return (cb: Function) => {
|
||||||
bounceTimer && clearTimeout(bounceTimer);
|
bounceTimer && clearTimeout(bounceTimer);
|
||||||
bounceTimer = setTimeout(() => {
|
bounceTimer = setTimeout(() => {
|
||||||
@@ -22,26 +13,6 @@ 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
|
||||||
@@ -80,8 +51,8 @@ export const numRemoveZero = (num: Number) => {
|
|||||||
// await-to-js
|
// await-to-js
|
||||||
export const ATJ = (promise: Promise<any>, errorExt: string | undefined = undefined) => {
|
export const ATJ = (promise: Promise<any>, errorExt: string | undefined = undefined) => {
|
||||||
return promise
|
return promise
|
||||||
.then(data => [null, data])
|
.then((data) => [null, data])
|
||||||
.catch(err => {
|
.catch((err) => {
|
||||||
if (errorExt) {
|
if (errorExt) {
|
||||||
if (typeof errorExt !== "object") {
|
if (typeof errorExt !== "object") {
|
||||||
return [errorExt, undefined];
|
return [errorExt, undefined];
|
||||||
@@ -94,30 +65,30 @@ export const ATJ = (promise: Promise<any>, errorExt: string | undefined = undefi
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const _supportProtocols = ["tcp", "udp", "ws", "wss", "srv", "schema"];
|
const _supportProtocols = ["tcp", "udp", "ws", "wss", "quic"];
|
||||||
|
|
||||||
export const supportProtocols = () => {
|
export const supportProtocols = () => {
|
||||||
return _supportProtocols.slice();
|
return _supportProtocols.slice();
|
||||||
};
|
}
|
||||||
|
|
||||||
let _prevent_timer: number | null = null;
|
let _prevent_timer: NodeJS.Timeout| 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);
|
||||||
_prevent_timer = setInterval(async () => {
|
_prevent_timer = setInterval(async () => {
|
||||||
const result = await invoke("prevent_sleep");
|
const result = await invoke('prevent_sleep');
|
||||||
// console.log(`trigger prevent sleep ${result}`);
|
// console.log(`trigger prevent sleep ${result}`);
|
||||||
}, _prevent_timer_count * 1000);
|
}, _prevent_timer_count * 1000);
|
||||||
};
|
}
|
||||||
|
|
||||||
export const stopPreventSleep = async () => {
|
export const stopPreventSleep = async () => {
|
||||||
_prevent_timer && clearInterval(_prevent_timer);
|
_prevent_timer && clearInterval(_prevent_timer);
|
||||||
_prevent_timer = null;
|
_prevent_timer = null;
|
||||||
const _result = await invoke("allow_sleep");
|
const _result = await invoke('allow_sleep');
|
||||||
};
|
}
|
||||||
|
|
||||||
export const parseCliInfo = (content: string) => {
|
export const parseCliInfo = (content: string) => {
|
||||||
if (!content) return [];
|
if(!content) return [];
|
||||||
// 将表格字符串分割成行
|
// 将表格字符串分割成行
|
||||||
const lines = content.split("\n");
|
const lines = content.split("\n");
|
||||||
|
|
||||||
@@ -125,7 +96,7 @@ export const parseCliInfo = (content: string) => {
|
|||||||
const headers = lines[1]
|
const headers = lines[1]
|
||||||
.split("│")
|
.split("│")
|
||||||
.slice(1, -1)
|
.slice(1, -1)
|
||||||
.map(h => h.trim());
|
.map((h) => h.trim());
|
||||||
|
|
||||||
// 初始化结果数组
|
// 初始化结果数组
|
||||||
const result: any[] = [];
|
const result: any[] = [];
|
||||||
@@ -138,7 +109,7 @@ export const parseCliInfo = (content: string) => {
|
|||||||
const values = lines[i]
|
const values = lines[i]
|
||||||
.split("│")
|
.split("│")
|
||||||
.slice(1, -1)
|
.slice(1, -1)
|
||||||
.map(v => v.trim());
|
.map((v) => v.trim());
|
||||||
|
|
||||||
// 创建对象并添加到结果数组
|
// 创建对象并添加到结果数组
|
||||||
const obj: any = {};
|
const obj: any = {};
|
||||||
@@ -153,38 +124,6 @@ export const parseCliInfo = (content: string) => {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function isValidWindowsFileName(name: string) {
|
|
||||||
if (name.length > 255) return false;
|
|
||||||
const reserved_names = [
|
|
||||||
"CON",
|
|
||||||
"PRN",
|
|
||||||
"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())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return /^[^<>:"/\\|?*\x00-\x1F]+[^<>:"/\\|?*\x00-\x1F .]$/g.test(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
export const addQQGroup = () => {
|
export const addQQGroup = () => {
|
||||||
open("https://qm.qq.com/q/Yo3HmaEIWC");
|
open("https://qm.qq.com/q/Yo3HmaEIWC");
|
||||||
};
|
};
|
||||||
@@ -195,14 +134,3 @@ export function isValidIP(ip: string) {
|
|||||||
const ipv6Pattern = /^(?:[A-Fa-f0-9]{1,4}:){7}[A-Fa-f0-9]{1,4}$/;
|
const ipv6Pattern = /^(?:[A-Fa-f0-9]{1,4}:){7}[A-Fa-f0-9]{1,4}$/;
|
||||||
return ipv4Pattern.test(ip) || ipv6Pattern.test(ip);
|
return ipv4Pattern.test(ip) || ipv6Pattern.test(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const copyText = async (text: string, message: string = "复制成功") => {
|
|
||||||
const [err, _] = await ATJ(writeText(text));
|
|
||||||
|
|
||||||
if (!err) {
|
|
||||||
ElMessage.success(message);
|
|
||||||
} else {
|
|
||||||
console.error(err);
|
|
||||||
ElMessage.success("复制失败");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|||||||
Reference in New Issue
Block a user