mirror of
https://github.com/EasyTier/EasytierGame.git
synced 2026-09-20 19:22:55 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7853d3b2f5 | ||
|
|
aacf47b6f5 | ||
|
|
d9b01fc754 | ||
|
|
844fba8462 | ||
|
|
6bfe3860a8 | ||
|
|
a0b4071c49 | ||
|
|
8e9bb114d6 | ||
|
|
fb8e127198 | ||
|
|
3cd19ae42a | ||
|
|
5be1a681ca | ||
|
|
29464179f5 | ||
|
|
88f06fbeba | ||
|
|
ced035dc36 | ||
|
|
feea75dcb6 | ||
|
|
229fd31de6 | ||
|
|
db3acd0c32 | ||
|
|
6defb9e0ac | ||
|
|
7751c25e15 | ||
|
|
e598f3806b | ||
|
|
2383178a61 | ||
|
|
2a7f51ccde |
+3
-1
@@ -11,4 +11,6 @@ dist
|
||||
.vscode
|
||||
release
|
||||
|
||||
src-tauri/easytier/logs
|
||||
src-tauri/easytier/logs
|
||||
src-tauri/easytier/tool/ResourcesExtract.exe
|
||||
src-tauri/easytier/tool/ResourcesExtract.cfg
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
pnpm run build
|
||||
rustup default nightly
|
||||
rem 使用rust nightly构建支持win7的版本,请先将根目录的windows.0.48.5 放入以下目录
|
||||
rem C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\lib\x64
|
||||
rem C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\lib\x86
|
||||
rem C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\atlmfc\lib\x64
|
||||
rem C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\atlmfc\lib\x86
|
||||
@REM rem 使用rust nightly构建支持win7的版本,请先将根目录的windows.0.48.5 放入以下目录
|
||||
@REM rem C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\lib\x64
|
||||
@REM rem C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\lib\x86
|
||||
@REM rem C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\atlmfc\lib\x64
|
||||
@REM rem C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\atlmfc\lib\x86
|
||||
pnpm tauri build -- -Z build-std --target x86_64-win7-windows-msvc
|
||||
rustup default stable
|
||||
pnpm tauri build
|
||||
|
||||
+25
-11
@@ -2,7 +2,21 @@ import { BaseDirectory, writeTextFile } from "@tauri-apps/plugin-fs";
|
||||
import useMainStore from "@/stores/index";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { uniq, intersection, isNil } from "lodash-es";
|
||||
export const updateConfigJson = async (configJsonSeverUrl: Array<string> | string | null | undefined) => {
|
||||
import { bounce } from "~/utils";
|
||||
|
||||
const b = bounce(600);
|
||||
export type ConfigServerUrlType = Array<string> | string | null | undefined | null;
|
||||
|
||||
export const updateConfigJsonBounce = (configJsonSeverUrl?: ConfigServerUrlType) => {
|
||||
b(async () => {
|
||||
const mainStore = useMainStore();
|
||||
if (mainStore.createConfigInEasytier) {
|
||||
await updateConfigJson(configJsonSeverUrl);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const updateConfigJson = async (configJsonSeverUrl?: ConfigServerUrlType) => {
|
||||
const mainStore = useMainStore();
|
||||
const path = import.meta.env.VITE_CONFIG_FILE_NAME;
|
||||
if (isNil(configJsonSeverUrl)) {
|
||||
@@ -14,23 +28,19 @@ export const updateConfigJson = async (configJsonSeverUrl: Array<string> | strin
|
||||
const {
|
||||
proxyNetworks,
|
||||
autoStart,
|
||||
relayAllPeerrpc,
|
||||
connectAfterStart,
|
||||
multiThread,
|
||||
enablExitNode,
|
||||
useSmoltcp,
|
||||
saveErrorLog,
|
||||
logLevel,
|
||||
serverUrl,
|
||||
port,
|
||||
enableCustomListener,
|
||||
enablePreventSleep,
|
||||
customListenerData,
|
||||
customListenerV6Data,
|
||||
enableCustomListenerV6,
|
||||
bindDeviceEnable,
|
||||
acceptDNS,
|
||||
enablePortForward,
|
||||
portForwardData,
|
||||
...otherConfig
|
||||
} = mainStore.config;
|
||||
let writeServerUrl: Array<string> | string = serverUrl;
|
||||
let writeCustomListenerData: Array<string> = (customListenerData || "").split("\n");
|
||||
if (isArray) {
|
||||
writeServerUrl = intersection(
|
||||
uniq([serverUrl, ...configJsonSeverUrl]).filter(boolean => boolean),
|
||||
@@ -43,7 +53,11 @@ export const updateConfigJson = async (configJsonSeverUrl: Array<string> | strin
|
||||
mainStore.basePeers
|
||||
).join(",");
|
||||
}
|
||||
await writeTextFile(path, JSON.stringify({ serverUrl: writeServerUrl, ...otherConfig }, null, 4), { baseDir: BaseDirectory.Resource });
|
||||
await writeTextFile(
|
||||
path,
|
||||
JSON.stringify({ serverUrl: writeServerUrl, enableCustomListener, customListenerData: writeCustomListenerData, ...otherConfig }, null, 4),
|
||||
{ baseDir: BaseDirectory.Resource }
|
||||
);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
ElMessage.error(`更新config.json失败`);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
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;
|
||||
}
|
||||
};
|
||||
@@ -20,5 +20,8 @@ export const getServerArgs = () => {
|
||||
if (!whiteList && mainStore.serverConfig.enableWhiteList) {
|
||||
args.push("--relay-network-whitelist");
|
||||
}
|
||||
if (mainStore.serverConfig.privateMode) {
|
||||
args.push("--private-mode", "true");
|
||||
}
|
||||
return args;
|
||||
};
|
||||
|
||||
+37
-38
@@ -8,6 +8,7 @@ import { resourceDir as getResourceDir, join } from "@tauri-apps/api/path";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
// import { ElConfirmPrimary } from "~/utils/element";
|
||||
import { open } from "@tauri-apps/plugin-shell";
|
||||
import { computed } from "vue";
|
||||
|
||||
const DEFAULT_TRAY_NAME = "main";
|
||||
|
||||
@@ -30,13 +31,10 @@ export async function useTray(init: boolean = false, beforExit: Function, handle
|
||||
tooltip: `EasyTierGame\n${pkg.version}`,
|
||||
title: `EasyTierGame\n${pkg.version}`,
|
||||
id: DEFAULT_TRAY_NAME,
|
||||
menu: await Menu.new({
|
||||
id: "main",
|
||||
items: await generateMenuItem(beforExit, handleConnection),
|
||||
}),
|
||||
action: async (e) => {
|
||||
menu: await Menu.new({ id: "main", items: await generateMenuItem(beforExit, handleConnection) }),
|
||||
action: async e => {
|
||||
toggleVisibility();
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -47,18 +45,13 @@ export async function useTray(init: boolean = false, beforExit: Function, handle
|
||||
if (init) {
|
||||
tray.setTooltip(`EasyTierGame\n${pkg.version}`);
|
||||
tray.setShowMenuOnLeftClick(false);
|
||||
tray.setMenu(
|
||||
await Menu.new({
|
||||
id: "main",
|
||||
items: await generateMenuItem(beforExit, handleConnection),
|
||||
})
|
||||
);
|
||||
tray.setMenu(await Menu.new({ id: "main", items: await generateMenuItem(beforExit, handleConnection) }));
|
||||
}
|
||||
|
||||
return tray;
|
||||
}
|
||||
|
||||
export async function generateMenuItem(beforExit: Function, handleConnection:Function) {
|
||||
export async function generateMenuItem(beforExit: Function, handleConnection: Function) {
|
||||
return [
|
||||
await MenuItemShow("显示 / 隐藏"),
|
||||
await MenuItemExchangeConnection("联机 / 断开", handleConnection),
|
||||
@@ -66,7 +59,7 @@ export async function generateMenuItem(beforExit: Function, handleConnection:Fun
|
||||
await PredefinedMenuItem.new({ item: "Separator" }),
|
||||
await MenuItemPublicPeers(),
|
||||
await PredefinedMenuItem.new({ item: "Separator" }),
|
||||
await MenuItemExit("退出", beforExit),
|
||||
await MenuItemExit("退出", beforExit)
|
||||
];
|
||||
}
|
||||
|
||||
@@ -79,18 +72,17 @@ export async function MenuItemExit(text: string, beforExit: Function) {
|
||||
await beforExit();
|
||||
}
|
||||
await getCurrentWindow().close();
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export async function MenuItemPublicPeers() {
|
||||
|
||||
return await MenuItem.new({
|
||||
id: "publicPeers",
|
||||
text: "公共节点",
|
||||
action: async () => {
|
||||
await open(import.meta.env.VITE_PUBLIC_PEERS_URL)
|
||||
},
|
||||
await open(import.meta.env.VITE_PUBLIC_PEERS_URL);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -100,17 +92,17 @@ export async function MenuItemShow(text: string) {
|
||||
text,
|
||||
action: async () => {
|
||||
await toggleVisibility();
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export async function MenuItemExchangeConnection(text: string, handleConnection:Function) {
|
||||
const menutItem = await MenuItem.new({
|
||||
export async function MenuItemExchangeConnection(text: string, handleConnection: Function) {
|
||||
const menutItem = await MenuItem.new({
|
||||
id: "exchangeConnection",
|
||||
text,
|
||||
action: async () => {
|
||||
const isStart = await handleConnection();
|
||||
},
|
||||
}
|
||||
});
|
||||
return menutItem;
|
||||
}
|
||||
@@ -121,12 +113,10 @@ export async function MenuItemTheme() {
|
||||
text: "主题切换",
|
||||
action: async () => {
|
||||
const mainStore = useMainStore();
|
||||
mainStore.$patch({
|
||||
theme: !mainStore.theme
|
||||
});
|
||||
mainStore.$patch({ theme: !mainStore.theme });
|
||||
// mainStore.$persist();
|
||||
await setTheme(mainStore.theme);
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -159,18 +149,27 @@ 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 () => {
|
||||
const mainStore = useMainStore();
|
||||
// if(mainStore.latestTagName && mainStore.latestTagName == pkg.version) return;
|
||||
if (hasNewVersion.value) return;
|
||||
let [tagName, downloadUrl] = await invoke<string[]>("fetch_game_releases");
|
||||
if(tagName && pkg.version !== tagName) {
|
||||
return true; //有新版
|
||||
// const [err] = await ElConfirmPrimary("有新版本是否下载?", "发现新版本", {
|
||||
// confirmButtonText: "下载",
|
||||
// cancelButtonText: "取消",
|
||||
// })
|
||||
// if(!err) {
|
||||
// open(downloadUrl);
|
||||
// }
|
||||
}
|
||||
return false; //没有新版
|
||||
}
|
||||
mainStore.latestTagName = tagName;
|
||||
};
|
||||
|
||||
export const hasNewVersion = computed<boolean>(() => {
|
||||
const mainStore = useMainStore();
|
||||
return !!mainStore.latestTagName && versionDifference(pkg.version, mainStore.latestTagName) < 0 ;
|
||||
});
|
||||
|
||||
+50
-37
@@ -4,17 +4,29 @@ import { WebviewWindow } from "@tauri-apps/api/webviewWindow";
|
||||
import type { WebviewLabel, WebviewOptions } from "@tauri-apps/api/webview";
|
||||
import useMainStore from "@/stores/index";
|
||||
import { onBeforeUnmount } from "vue";
|
||||
import { updateConfigJsonBounce, type ConfigServerUrlType } from "./configJson";
|
||||
|
||||
const _listenersMaps: { [key: string]: [UnlistenFn | null, UnlistenFn | null] } = {};
|
||||
const _listenersMaps: { [key: string]: [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 (
|
||||
label: WebviewLabel,
|
||||
options?: Omit<WebviewOptions, "x" | "y" | "width" | "height"> & WindowOptions,
|
||||
afterCreatedFunc?: (webviewWindow: WebviewWindow, appWindow: Window) => void | null,
|
||||
beforeCloseFunc?: () => void | null
|
||||
) => {
|
||||
const unlistenFnList: [UnlistenFn | null, UnlistenFn | null] = _listenersMaps[label] || [null, null];
|
||||
let [unlistenLogCreated, unListenlogClose] = unlistenFnList;
|
||||
const unlistenFnList: [UnlistenFn | null] = _listenersMaps[label] || [null];
|
||||
let dialog = await WebviewWindow.getByLabel(label);
|
||||
if (!dialog) {
|
||||
let defaultOpts: { [key: string]: any; parent: Window | undefined } = {
|
||||
@@ -29,54 +41,55 @@ export default async (
|
||||
};
|
||||
const appWindow = getCurrentWindow();
|
||||
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;
|
||||
// console.error(logicalPosition);
|
||||
defaultOpts.x = logicalPosition.x;
|
||||
defaultOpts.y = logicalPosition.y;
|
||||
}
|
||||
unlistenLogCreated && (await (unlistenLogCreated as Function)());
|
||||
unListenlogClose && (await unListenlogClose());
|
||||
dialog = new WebviewWindow(label, { ...defaultOpts, ...options });
|
||||
unlistenLogCreated = await dialog.listen("tauri://webview-created", async () => {
|
||||
if (dialog) {
|
||||
afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow));
|
||||
await dialog.show();
|
||||
if (defaultOpts.x == 0 && defaultOpts.y == 0) {
|
||||
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.x = logicalPosition.x;
|
||||
defaultOpts.y = logicalPosition.y;
|
||||
}
|
||||
});
|
||||
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;
|
||||
}
|
||||
dialog = new WebviewWindow(label, { ...defaultOpts, ...options });
|
||||
await dealCloseListener(dialog, label, beforeCloseFunc);
|
||||
afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow));
|
||||
await dialog.show();
|
||||
} else {
|
||||
const visible = await dialog.isVisible();
|
||||
if (visible) {
|
||||
await dialog.close();
|
||||
unlistenLogCreated && (await (unlistenLogCreated as Function)());
|
||||
} else {
|
||||
const appWindow = getCurrentWindow();
|
||||
await dealCloseListener(dialog, label, beforeCloseFunc);
|
||||
afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow));
|
||||
await dialog.show();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const dataSubscribe = async (cb?: (...args: any) => any) => {
|
||||
if (!cb) return;
|
||||
export const dataSubscribe = async (cb?: any, getconfigServerUrl?: () => ConfigServerUrlType) => {
|
||||
const mainStore = useMainStore();
|
||||
const abort = new AbortController();
|
||||
window.addEventListener("storage", async () => {
|
||||
mainStore.$hydrate();
|
||||
if (cb && cb instanceof Function) {
|
||||
await cb();
|
||||
|
||||
window.addEventListener(
|
||||
"storage",
|
||||
async () => {
|
||||
// console.log("触发", {dhcp:mainStore.config.dhcp, c: mainStore.createConfigInEasytier})
|
||||
mainStore.$hydrate();
|
||||
const configServerUrl = getconfigServerUrl && getconfigServerUrl instanceof Function ? getconfigServerUrl() : null;
|
||||
updateConfigJsonBounce(configServerUrl);
|
||||
if (cb && cb instanceof Function) {
|
||||
await cb();
|
||||
}
|
||||
},
|
||||
{
|
||||
signal: abort.signal
|
||||
}
|
||||
}, {
|
||||
signal: abort.signal
|
||||
})
|
||||
);
|
||||
onBeforeUnmount(() => {
|
||||
console.log("取消监听");
|
||||
abort?.abort();
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
+93
-93
@@ -3,107 +3,107 @@ import path from "path";
|
||||
import vueJSX from "@vitejs/plugin-vue-jsx";
|
||||
|
||||
export default defineNuxtConfig({
|
||||
ssr: false,
|
||||
ssr: false,
|
||||
|
||||
devServer: {
|
||||
port: 5000
|
||||
},
|
||||
|
||||
telemetry: false,
|
||||
devServer: {
|
||||
port: 5000
|
||||
},
|
||||
|
||||
imports: {
|
||||
autoImport: false
|
||||
},
|
||||
telemetry: false,
|
||||
|
||||
css: ["~/assets/css/main.css", "element-plus/theme-chalk/dark/css-vars.css"],
|
||||
modules: [
|
||||
"@element-plus/nuxt",
|
||||
"@pinia/nuxt",
|
||||
[
|
||||
"pinia-plugin-persistedstate/nuxt",
|
||||
{
|
||||
key: "__glj_persisted_%id",
|
||||
storage: "localStorage"
|
||||
}
|
||||
],
|
||||
"@nuxtjs/tailwindcss"
|
||||
],
|
||||
imports: {
|
||||
autoImport: false
|
||||
},
|
||||
|
||||
alias: {
|
||||
"@": path.resolve(__dirname, "./")
|
||||
},
|
||||
css: ["~/assets/css/main.css", "element-plus/theme-chalk/dark/css-vars.css"],
|
||||
modules: [
|
||||
"@element-plus/nuxt",
|
||||
"@pinia/nuxt",
|
||||
[
|
||||
"pinia-plugin-persistedstate/nuxt",
|
||||
{
|
||||
key: "__glj_persisted_%id",
|
||||
storage: "localStorage"
|
||||
}
|
||||
],
|
||||
"@nuxtjs/tailwindcss"
|
||||
],
|
||||
|
||||
experimental: {
|
||||
payloadExtraction: false
|
||||
},
|
||||
alias: {
|
||||
"@": path.resolve(__dirname, "./")
|
||||
},
|
||||
|
||||
devtools: {
|
||||
enabled: false
|
||||
},
|
||||
experimental: {
|
||||
payloadExtraction: false
|
||||
},
|
||||
|
||||
router: {
|
||||
options: {
|
||||
hashMode: true
|
||||
}
|
||||
},
|
||||
devtools: {
|
||||
enabled: false
|
||||
},
|
||||
|
||||
vite: {
|
||||
plugins: [vueJSX({})],
|
||||
envDir: "env",
|
||||
optimizeDeps: {
|
||||
// include: [...optimizeDepsElementPlusIncludes]
|
||||
},
|
||||
// prevent vite from obscuring rust errors
|
||||
clearScreen: false,
|
||||
// Tauri expects a fixed port, fail if that port is not available
|
||||
server: {
|
||||
strictPort: true
|
||||
},
|
||||
// to access the Tauri environment variables set by the CLI with information about the current target
|
||||
envPrefix: ["VITE_", "TAURI_"],
|
||||
build: {
|
||||
// minify: "esbuild",
|
||||
chunkSizeWarningLimit: 1500,
|
||||
// Tauri uses Chromium on Windows and WebKit on macOS and Linux
|
||||
target: process.env.TAURI_PLATFORM == "windows" ? "chrome105" : "safari13",
|
||||
// don't minify for debug builds
|
||||
minify: !process.env.TAURI_DEBUG ? "esbuild" : false,
|
||||
// 为调试构建生成源代码映射 (sourcemap)
|
||||
sourcemap: !!process.env.TAURI_DEBUG
|
||||
},
|
||||
esbuild: {
|
||||
// pure: ["console.log"],
|
||||
drop: ["debugger"]
|
||||
}
|
||||
},
|
||||
router: {
|
||||
options: {
|
||||
hashMode: true
|
||||
}
|
||||
},
|
||||
|
||||
postcss: {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {}
|
||||
}
|
||||
},
|
||||
vite: {
|
||||
plugins: [vueJSX({})],
|
||||
envDir: "env",
|
||||
optimizeDeps: {
|
||||
// include: [...optimizeDepsElementPlusIncludes]
|
||||
},
|
||||
// prevent vite from obscuring rust errors
|
||||
clearScreen: false,
|
||||
// Tauri expects a fixed port, fail if that port is not available
|
||||
server: {
|
||||
strictPort: true
|
||||
},
|
||||
// to access the Tauri environment variables set by the CLI with information about the current target
|
||||
envPrefix: ["VITE_", "TAURI_"],
|
||||
build: {
|
||||
// minify: "esbuild",
|
||||
chunkSizeWarningLimit: 1500,
|
||||
// Tauri uses Chromium on Windows and WebKit on macOS and Linux
|
||||
target: process.env.TAURI_PLATFORM == "windows" ? "chrome105" : "safari13",
|
||||
// don't minify for debug builds
|
||||
minify: !process.env.TAURI_DEBUG ? "esbuild" : false,
|
||||
// 为调试构建生成源代码映射 (sourcemap)
|
||||
sourcemap: !!process.env.TAURI_DEBUG
|
||||
},
|
||||
esbuild: {
|
||||
// pure: ["console.log"],
|
||||
drop: ["debugger"]
|
||||
}
|
||||
},
|
||||
|
||||
app: {
|
||||
rootId: "__easytier",
|
||||
cdnURL: "./",
|
||||
buildAssetsDir: "__easytier/",
|
||||
head: {
|
||||
meta: [
|
||||
{
|
||||
name: "viewport",
|
||||
content: "width=device-width, initial-scale=1"
|
||||
},
|
||||
{
|
||||
charset: "utf-8"
|
||||
}
|
||||
],
|
||||
title: "easytier-game"
|
||||
// link: [],
|
||||
// style: [],
|
||||
// script: [],
|
||||
// noscript: []
|
||||
}
|
||||
},
|
||||
compatibilityDate: "2024-11-12"
|
||||
postcss: {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {}
|
||||
}
|
||||
},
|
||||
|
||||
app: {
|
||||
rootId: "__easytier",
|
||||
cdnURL: "./",
|
||||
buildAssetsDir: "__easytier/",
|
||||
head: {
|
||||
meta: [
|
||||
{
|
||||
name: "viewport",
|
||||
content: "width=device-width, initial-scale=1"
|
||||
},
|
||||
{
|
||||
charset: "utf-8"
|
||||
}
|
||||
],
|
||||
title: "easytier-game"
|
||||
// link: [],
|
||||
// style: [],
|
||||
// script: [],
|
||||
// noscript: []
|
||||
}
|
||||
},
|
||||
compatibilityDate: "2024-11-12"
|
||||
});
|
||||
|
||||
+19
-19
@@ -3,7 +3,7 @@
|
||||
"private": true,
|
||||
"author": "leizi97",
|
||||
"description": "A simple network initiator based on Easytier",
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.6",
|
||||
"scripts": {
|
||||
"dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0",
|
||||
"build": "nuxt generate --dotenv env/.env.prod",
|
||||
@@ -12,30 +12,30 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@element-plus/icons-vue": "^2.3.1",
|
||||
"@element-plus/nuxt": "^1.1.1",
|
||||
"@nuxtjs/tailwindcss": "6.13.1",
|
||||
"@pinia/nuxt": "0.9.0",
|
||||
"@tauri-apps/api": "^2.2.0",
|
||||
"@tauri-apps/cli": "2.2.7",
|
||||
"@element-plus/nuxt": "1.1.2",
|
||||
"@nuxtjs/tailwindcss": "6.13.2",
|
||||
"@pinia/nuxt": "0.11.0",
|
||||
"@tauri-apps/api": "2.5.0",
|
||||
"@tauri-apps/cli": "2.5.0",
|
||||
"@tauri-apps/plugin-cli": "^2.2.0",
|
||||
"@tauri-apps/plugin-clipboard-manager": "2.2.0",
|
||||
"@tauri-apps/plugin-dialog": "2.2.0",
|
||||
"@tauri-apps/plugin-fs": "^2.2.0",
|
||||
"@tauri-apps/plugin-log": "2.2.1",
|
||||
"@tauri-apps/plugin-shell": "^2.2.0",
|
||||
"@tauri-apps/plugin-window-state": "2.2.1",
|
||||
"@tauri-apps/plugin-clipboard-manager": "2.2.2",
|
||||
"@tauri-apps/plugin-dialog": "2.2.2",
|
||||
"@tauri-apps/plugin-fs": "2.3.0",
|
||||
"@tauri-apps/plugin-log": "2.4.0",
|
||||
"@tauri-apps/plugin-shell": "2.2.1",
|
||||
"@tauri-apps/plugin-window-state": "2.2.2",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@vitejs/plugin-vue-jsx": "^4.1.1",
|
||||
"@vueuse/core": "12.4.0",
|
||||
"@vitejs/plugin-vue-jsx": "4.1.2",
|
||||
"@vueuse/core": "12.7.0",
|
||||
"archiver": "^7.0.1",
|
||||
"element-plus": "2.9.4",
|
||||
"element-plus": "2.9.11",
|
||||
"less": "4.2.1",
|
||||
"lodash-es": "^4.17.21",
|
||||
"nuxt": "3.15.4",
|
||||
"pinia": "2.3.1",
|
||||
"pinia-plugin-persistedstate": "^4.2.0",
|
||||
"nuxt": "3.17.4",
|
||||
"pinia": "3.0.2",
|
||||
"pinia-plugin-persistedstate": "4.3.0",
|
||||
"postcss": "^8.4.38",
|
||||
"prettier": "3.4.2",
|
||||
"prettier": "3.5.2",
|
||||
"prettier-plugin-tailwindcss": "0.6.11"
|
||||
}
|
||||
}
|
||||
|
||||
+123
-33
@@ -2,8 +2,8 @@
|
||||
<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-[5px]">
|
||||
<ElCheckbox v-model="mainStore.config.enableCustomProtocol">默认直连(p2p)使用的协议</ElCheckbox>
|
||||
<ElTooltip content="如果没有支持该协议的节点地址,程序会自动处理,请放心使用">
|
||||
<ElCheckbox v-model="mainStore.config.enableCustomProtocol">直连(P2P)优先使用传输协议</ElCheckbox>
|
||||
<ElTooltip content="若无法建立指定的协议,会自动使用可建立连接的协议">
|
||||
<ElIcon><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</div>
|
||||
@@ -24,7 +24,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<ElCheckbox v-model="mainStore.config.relayAllPeerrpc">帮助对等节点建立直连(p2p)通信</ElCheckbox>
|
||||
<ElCheckbox v-model="mainStore.config.relayAllPeerrpc">帮助他人建立直连(P2P)连接</ElCheckbox>
|
||||
</div>
|
||||
<div><ElCheckbox v-model="mainStore.config.connectAfterStart">软件启动后,自动"启动联机"(搭配开机自启,无感联机)</ElCheckbox></div>
|
||||
<div class="flex flex-nowrap items-center gap-[15px]">
|
||||
@@ -38,8 +38,8 @@
|
||||
</div>
|
||||
<div><ElCheckbox v-model="mainStore.config.enablePreventSleep">防止系统休眠(比如:屏幕会一直亮着)</ElCheckbox></div>
|
||||
<div class="flex flex-nowrap items-center gap-[5px]">
|
||||
<ElCheckbox v-model="mainStore.config.latencyfirst">延迟优先模式,将尝试使用最低延迟路径转发流量</ElCheckbox>
|
||||
<ElTooltip content="视网络质量进行选择,可能会出现中转与直连(p2p)来回切换的情况">
|
||||
<ElCheckbox v-model="mainStore.config.latencyfirst">使用低延迟模式</ElCheckbox>
|
||||
<ElTooltip content="弱网环境下可能会导致网络延迟延迟忽高忽低">
|
||||
<ElIcon><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</div>
|
||||
@@ -59,6 +59,20 @@
|
||||
</div>
|
||||
<div><ElCheckbox v-model="mainStore.config.disableUdpHolePunching">禁用UDP打洞功能</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 />
|
||||
<div class="flex items-center gap-[10px]">
|
||||
<ElCheckbox v-model="mainStore.config.disbleListenner">不监听任何端口,只连接到对等节点</ElCheckbox>
|
||||
@@ -103,6 +117,7 @@
|
||||
class="!mb-0"
|
||||
v-model="listenerDialogData.visible"
|
||||
:close-on-press-escape="false"
|
||||
:close-on-click-modal="false"
|
||||
title="自定义监听地址"
|
||||
>
|
||||
<ElInput
|
||||
@@ -125,38 +140,74 @@
|
||||
</ElDialog>
|
||||
</div>
|
||||
<div class="flex items-center gap-[10px]">
|
||||
<ElCheckbox
|
||||
:disabled="mainStore.config.disbleListenner"
|
||||
v-model="mainStore.config.enableCustomListenerV6"
|
||||
<ElCheckbox v-model="mainStore.config.enablePortForward">端口转发</ElCheckbox>
|
||||
<ElTooltip
|
||||
:disabled="mainStore.config.enablePortForward"
|
||||
content="请先开启端口转发功能"
|
||||
>
|
||||
自定义IPV6监听地址
|
||||
</ElCheckbox>
|
||||
<div class="w-[200px]">
|
||||
<ElInput
|
||||
:disabled="mainStore.config.disbleListenner || mainStore.config.enableCustomListenerV6"
|
||||
<ElButton
|
||||
size="small"
|
||||
:maxlength="100"
|
||||
v-model="mainStore.config.customListenerV6Data"
|
||||
placeholder="请输入自定义IPV6监听地址"
|
||||
/>
|
||||
</div>
|
||||
<ElTooltip content="例如:tcp://[::]:11010,如果未设置,将在随机UDP端口上监听">
|
||||
:disabled="!mainStore.config.enablePortForward"
|
||||
@click="handlePortForwardDialog"
|
||||
>
|
||||
配置
|
||||
</ElButton>
|
||||
</ElTooltip>
|
||||
<ElTooltip content="将本地端口转发到虚拟网络中的远程端口.如:udp://0.0.0.0:12345/10.126.126.1:23456,表示将本地UDP端口12345转发到虚拟网络中的10.126.126.1:23456.可以指定多个">
|
||||
<ElIcon><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
<CoreVersionWarning version="2.1.0" />
|
||||
<CoreVersionWarning version="2.3.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>
|
||||
<ElDivider />
|
||||
<div class="flex items-center gap-[10px]">
|
||||
<ElCheckbox v-model="mainStore.config.devName">自定义网卡名</ElCheckbox>
|
||||
<ElCheckbox v-model="mainStore.config.devName">自定义虚拟网卡名称</ElCheckbox>
|
||||
<ElInput
|
||||
size="small"
|
||||
maxlength="10"
|
||||
v-model="mainStore.config.devNameValue"
|
||||
placeholder="请输入网卡名"
|
||||
placeholder="请输入虚拟网卡名称"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex items-center gap-[10px]">
|
||||
<ElCheckbox v-model="mainStore.config.enableNetCardMetric">自定义easytier网卡跃点</ElCheckbox>
|
||||
<ElCheckbox v-model="mainStore.config.enableNetCardMetric">自定义虚拟网卡优先级</ElCheckbox>
|
||||
<ElInputNumber
|
||||
controls-position="right"
|
||||
:min="1"
|
||||
@@ -166,9 +217,9 @@
|
||||
:precision="0"
|
||||
size="small"
|
||||
v-model="mainStore.config.netCardMetricValue"
|
||||
placeholder="请选择跃点数"
|
||||
placeholder="请输入优先级"
|
||||
/>
|
||||
<ElTooltip content="设置easytier网卡的跃点,提升网卡优先级,跃点越小,网卡优先级越高">
|
||||
<ElTooltip content="数值越小,优先级越高">
|
||||
<ElIcon><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</div>
|
||||
@@ -177,17 +228,43 @@
|
||||
size="small"
|
||||
type="warning"
|
||||
>
|
||||
(不使用自定义网卡名,那么联机时默认会生成一个名为 "et_xxx" 的网卡,也可以使用 “设置跃点” 功能,除非你启用了下面的功能)
|
||||
(不使用自定义虚拟网卡名称,那么联机时默认会生成一个名为 "et_xxx" 的网卡,也可以使用 “自定义虚拟网卡优先级”
|
||||
功能,除非你启用了下面的功能)
|
||||
</ElText>
|
||||
</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 />
|
||||
<div><ElCheckbox v-model="mainStore.config.enablExitNode">允许此节点成为出口节点</ElCheckbox></div>
|
||||
<div><ElCheckbox v-model="mainStore.config.disableEncryption">禁用对等节点通信的加密</ElCheckbox></div>
|
||||
<div><ElCheckbox v-model="mainStore.config.multiThread">启用多线程运行</ElCheckbox></div>
|
||||
<div class="flex items-center gap-[5px]">
|
||||
<ElCheckbox v-model="mainStore.config.disableEncryption">关闭信息加密</ElCheckbox>
|
||||
<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]">
|
||||
<ElText>压缩算法</ElText>
|
||||
<ElText>传输数据压缩算法</ElText>
|
||||
<div class="w-[160px]">
|
||||
<ElSelect
|
||||
size="small"
|
||||
@@ -210,8 +287,8 @@
|
||||
<ElDivider />
|
||||
|
||||
<div class="flex items-center gap-[10px]">
|
||||
<ElCheckbox v-model="mainStore.config.useSmoltcp">为子网代理启用smoltcp堆栈</ElCheckbox>
|
||||
<ElTooltip content="使用用户态TCP/IP协议栈smoltcp,避免操作系统防火墙问题导致无法子网代理">
|
||||
<ElCheckbox v-model="mainStore.config.useSmoltcp">为子网代理和 KCP 代理开启用户网络栈</ElCheckbox>
|
||||
<ElTooltip content="开启后会降低网络性能,但不需要配置防火墙">
|
||||
<ElIcon><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</div>
|
||||
@@ -261,6 +338,15 @@
|
||||
loading: false
|
||||
});
|
||||
|
||||
const portForwardDialogData = reactive<{ [key: string]: any }>({
|
||||
visible: false,
|
||||
loading: false
|
||||
});
|
||||
|
||||
const handlePortForwardDialog = () => {
|
||||
portForwardDialogData.visible = true;
|
||||
};
|
||||
|
||||
const handleListenerDialog = () => {
|
||||
listenerDialogData.visible = true;
|
||||
};
|
||||
@@ -269,6 +355,10 @@
|
||||
listenerDialogData.visible = false;
|
||||
};
|
||||
|
||||
const handleFinishInputPortForward = async () => {
|
||||
portForwardDialogData.visible = false;
|
||||
};
|
||||
|
||||
const mainStore = useMainStore();
|
||||
const data = ["trace", "debug", "info", "warn", "error", "off"];
|
||||
const guids = ref<string[][]>([]);
|
||||
@@ -297,7 +387,7 @@
|
||||
};
|
||||
|
||||
// 为bind_device功能增加改方法
|
||||
const _getGuids = async () => {
|
||||
const getGuids = async () => {
|
||||
const guidsValue = await invoke<string[][]>("get_network_adapter_guids");
|
||||
guids.value = guidsValue && guidsValue.length > 0 ? guidsValue : [];
|
||||
};
|
||||
|
||||
+15
-10
@@ -1,12 +1,18 @@
|
||||
<template>
|
||||
<div class="flex h-full flex-col gap-[10px]">
|
||||
<ElRadioGroup
|
||||
:disabled="!data.isSwitchEnable"
|
||||
v-model="mainStore.cidrEnable"
|
||||
>
|
||||
<ElRadioButton :value="true">开启</ElRadioButton>
|
||||
<ElRadioButton :value="false">关闭</ElRadioButton>
|
||||
</ElRadioGroup>
|
||||
<div class="flex items-center gap-[10px]">
|
||||
<ElRadioGroup
|
||||
:disabled="!data.isSwitchEnable"
|
||||
v-model="mainStore.cidrEnable"
|
||||
>
|
||||
<ElRadioButton :value="true">开启</ElRadioButton>
|
||||
<ElRadioButton :value="false">关闭</ElRadioButton>
|
||||
</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">
|
||||
<ElInput
|
||||
placeholder="例如: 192.168.1.0/24 一行一个"
|
||||
@@ -107,12 +113,11 @@
|
||||
|
||||
onMounted(async () => {
|
||||
unlistenStart = await listenStart();
|
||||
dataSubscribe();
|
||||
});
|
||||
|
||||
dataSubscribe();
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
unlistenStart && unlistenStart();
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
+165
-29
@@ -16,14 +16,14 @@
|
||||
class="mr-[5px]"
|
||||
@click="handleCreate"
|
||||
>
|
||||
新增本地游戏
|
||||
新增游戏
|
||||
</ElButton>
|
||||
<ElButton
|
||||
size="small"
|
||||
class="mr-[5px]"
|
||||
class="!ml-[0px] mr-[5px]"
|
||||
@click="openCoverDir"
|
||||
>
|
||||
打开封面目录
|
||||
封面目录
|
||||
</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
@@ -37,7 +37,7 @@
|
||||
<ElCard>
|
||||
<template #header>
|
||||
<div class="flex flex-nowrap gap-[0_8px]">
|
||||
<ElTooltip :content="item.name">
|
||||
<ElTooltip :content="item.name" placement="top">
|
||||
<p class="ml-auto flex-1 truncate">
|
||||
<ElText
|
||||
size="default"
|
||||
@@ -56,7 +56,7 @@
|
||||
/>
|
||||
</ElCard>
|
||||
<div
|
||||
class="absolute left-0 top-0 z-[1] hidden h-full w-full flex-col items-center justify-center rounded-[5px] bg-[var(--el-mask-color)] group-hover/card:flex"
|
||||
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"
|
||||
@@ -92,10 +92,13 @@
|
||||
@click.stop="handleCreate"
|
||||
shadow="hover"
|
||||
>
|
||||
<div class="group/plus flex cursor-pointer items-center justify-center py-[25px]">
|
||||
<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>
|
||||
@@ -148,7 +151,7 @@
|
||||
</ElFormItem>
|
||||
<ElFormItem
|
||||
label="游戏封面"
|
||||
prop="coverImg"
|
||||
prop="showImg"
|
||||
>
|
||||
<ElBadge :hidden="createGameData.form.showImg == defaultPng">
|
||||
<template #content="{ value }">
|
||||
@@ -162,7 +165,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<img
|
||||
@click.stop="handleBrowser('coverImg')"
|
||||
@click.stop="handleBrowser('showImg')"
|
||||
:src="showImgConvertFileSrc(createGameData.form.showImg)"
|
||||
class="aspect-[1] w-[120px] cursor-pointer object-cover"
|
||||
/>
|
||||
@@ -191,9 +194,9 @@
|
||||
<script lang="ts" setup>
|
||||
import { VideoPlay, DeleteFilled, EditPen, Plus, Delete } from "@element-plus/icons-vue";
|
||||
import { dataSubscribe } from "~/composables/windows";
|
||||
import { BaseDirectory, resourceDir as getResourceDir, join } from "@tauri-apps/api/path";
|
||||
import { convertFileSrc } from "@tauri-apps/api/core";
|
||||
import { computed, nextTick, reactive, ref, useTemplateRef } from "vue";
|
||||
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";
|
||||
@@ -202,6 +205,8 @@
|
||||
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");
|
||||
@@ -211,7 +216,7 @@
|
||||
const searchValue = ref("");
|
||||
const defaultPng = "/default.png";
|
||||
// const b = bounce(600);
|
||||
type gameItemType = { name: string; exePath: string; coverImg: string; id: string; showImg: string };
|
||||
type gameItemType = { name: string; exePath: string; id: string; showImg: string };
|
||||
const createGameData = reactive({
|
||||
visible: false,
|
||||
isEdit: false,
|
||||
@@ -219,7 +224,6 @@
|
||||
id: "",
|
||||
name: "",
|
||||
exePath: "",
|
||||
coverImg: "",
|
||||
showImg: defaultPng
|
||||
},
|
||||
rules: {
|
||||
@@ -241,29 +245,27 @@
|
||||
id: "",
|
||||
name: "",
|
||||
exePath: "",
|
||||
coverImg: "",
|
||||
showImg: defaultPng
|
||||
};
|
||||
await nextTick();
|
||||
createGameData.visible = true;
|
||||
};
|
||||
|
||||
const handleBrowser = async (type: "coverImg" | "exePath") => {
|
||||
const filters = type === "coverImg" ? [{ name: "", extensions: ["png", "jpg", "jpeg"] }] : [{ name: "", extensions: ["exe"] }];
|
||||
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 === "coverImg") {
|
||||
createGameData.form.coverImg = file;
|
||||
if (createGameData.form.coverImg) {
|
||||
if (type === "showImg") {
|
||||
if (file) {
|
||||
if (!createGameData.form.id) {
|
||||
const time = new Date().getTime();
|
||||
createGameData.form.id = uniqueId(`${time}`);
|
||||
}
|
||||
let coverImg = createGameData.form.coverImg;
|
||||
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) {
|
||||
@@ -272,14 +274,16 @@
|
||||
} catch (err) {}
|
||||
}
|
||||
const toPath = await join(gameListResourceDir, createGameData.form.id);
|
||||
const suffix = coverImg.split(".").pop();
|
||||
const suffix = showImg.split(".").pop();
|
||||
const toPathFileName = `${toPath}.${suffix}`;
|
||||
if (coverImg != toPathFileName) {
|
||||
await copyFile(coverImg, toPathFileName);
|
||||
if (showImg != toPathFileName) {
|
||||
await copyFile(showImg, toPathFileName);
|
||||
}
|
||||
// console.log(toPathFileName);
|
||||
const isExistsToPath = await exists(toPathFileName);
|
||||
if (isExistsToPath) {
|
||||
createGameData.form = { ...createGameData.form, showImg: `${toPathFileName}` }; // 如果复制正确,那就存储文件名即可
|
||||
const baseName = await basename(toPathFileName);
|
||||
createGameData.form = { ...createGameData.form, showImg: `${baseName}` }; // 如果复制正确,那就存储文件名即可
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -308,7 +312,6 @@
|
||||
if (createGameData.form.showImg == defaultPng) {
|
||||
//删除本地封面图
|
||||
// const toPath = await join(gameListResourceDir, createGameData.form.id);
|
||||
// const suffix = coverImg.split(".").pop();
|
||||
// const imgPath = `${toPath}.${suffix}`;
|
||||
// await remove(imgPath);
|
||||
}
|
||||
@@ -333,23 +336,27 @@
|
||||
|
||||
const handleBadgeDeleteCover = async () => {
|
||||
await removeFileById(createGameData.form.id);
|
||||
createGameData.form = { ...createGameData.form, coverImg: "", showImg: defaultPng };
|
||||
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 ({ coverImg, id }: gameItemType) => {
|
||||
const handleDeleteItem = async ({ id }: gameItemType) => {
|
||||
if (id) {
|
||||
const [error, _] = await ElConfirmDanger("确定要删除吗?");
|
||||
if (!error) {
|
||||
@@ -383,7 +390,6 @@
|
||||
|
||||
const handleImgError = (item: gameItemType, idx: number) => {
|
||||
item.showImg = defaultPng;
|
||||
item.coverImg = "";
|
||||
mainStore.gameList[idx] = { ...item };
|
||||
mainStore.$patch({
|
||||
gameList: [...mainStore.gameList]
|
||||
@@ -391,7 +397,137 @@
|
||||
};
|
||||
|
||||
const showImgConvertFileSrc = (showImg: string) => {
|
||||
return showImg != defaultPng ? `${convertFileSrc(showImg)}?${new Date().getTime()}` : defaultPng;
|
||||
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>
|
||||
|
||||
+215
-104
@@ -2,7 +2,7 @@
|
||||
<ElForm
|
||||
size="small"
|
||||
label-position="top"
|
||||
:model="config"
|
||||
:model="mainStore.config"
|
||||
>
|
||||
<ElFormItem
|
||||
label="服务器"
|
||||
@@ -70,18 +70,18 @@
|
||||
filterable
|
||||
placeholder="请选择服务器地址"
|
||||
default-first-option
|
||||
v-model="config.serverUrl"
|
||||
v-model="mainStore.config.serverUrl"
|
||||
no-data-text="无服务器地址"
|
||||
@change="handleServerUrlChange"
|
||||
>
|
||||
<template #prefix>
|
||||
<div :class="config.protocol && config.protocol.length > 1 ? 'w-[120px]' : 'w-[80px]'">
|
||||
<div :class="mainStore.config.protocol && mainStore.config.protocol.length > 1 ? 'w-[120px]' : 'w-[80px]'">
|
||||
<ElSelect
|
||||
placeholder="协议"
|
||||
multiple
|
||||
collapse-tags
|
||||
@click.stop
|
||||
v-model="config.protocol"
|
||||
v-model="mainStore.config.protocol"
|
||||
@change="handleServerUrlChange"
|
||||
>
|
||||
<ElOption
|
||||
@@ -98,7 +98,7 @@
|
||||
<ElLink
|
||||
type="primary"
|
||||
size="small"
|
||||
:underline="false"
|
||||
underline="never"
|
||||
@click.stop="open(publicPeersLink)"
|
||||
>
|
||||
其他公共服务器
|
||||
@@ -161,7 +161,7 @@
|
||||
<ElInput
|
||||
maxlength="100"
|
||||
placeholder="请输入房间名"
|
||||
v-model="config.networkName"
|
||||
v-model="mainStore.config.networkName"
|
||||
></ElInput>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
@@ -179,7 +179,7 @@
|
||||
show-password
|
||||
maxlength="100"
|
||||
placeholder="请输入房间密码"
|
||||
v-model="config.networkPassword"
|
||||
v-model="mainStore.config.networkPassword"
|
||||
type="password"
|
||||
></ElInput>
|
||||
</ElFormItem>
|
||||
@@ -198,7 +198,7 @@
|
||||
<ElInput
|
||||
maxlength="100"
|
||||
placeholder="例如: Player1"
|
||||
v-model="config.hostname"
|
||||
v-model="mainStore.config.hostname"
|
||||
></ElInput>
|
||||
</ElFormItem>
|
||||
<ElFormItem
|
||||
@@ -217,7 +217,7 @@
|
||||
:icon="CopyDocument"
|
||||
></ElButton>
|
||||
<ElSwitch
|
||||
v-model="config.dhcp"
|
||||
v-model="mainStore.config.dhcp"
|
||||
inline-prompt
|
||||
inactive-text="固定IP"
|
||||
active-text="动态获取"
|
||||
@@ -230,21 +230,21 @@
|
||||
</template>
|
||||
<ElInput
|
||||
maxlength="100"
|
||||
:readonly="config.dhcp"
|
||||
:placeholder="data.isStart && config.dhcp ? '等待动态分配IP...' : '例如: 10.126.126.1'"
|
||||
v-model="config.ipv4"
|
||||
:readonly="mainStore.config.dhcp"
|
||||
:placeholder="data.isStart && mainStore.config.dhcp ? '等待动态分配IP...' : '例如: 10.126.126.1'"
|
||||
v-model="mainStore.config.ipv4"
|
||||
>
|
||||
<template #prefix>
|
||||
<ElTooltip
|
||||
class="!text-[10px]"
|
||||
placement="top-end"
|
||||
:content="config.dhcp ? '动态获取无法手动填写' : '固定IP可以手动填写'"
|
||||
:content="mainStore.config.dhcp ? '动态获取无法手动填写' : '固定IP可以手动填写'"
|
||||
>
|
||||
<ElTag
|
||||
size="small"
|
||||
:type="config.dhcp ? 'info' : 'success'"
|
||||
:type="mainStore.config.dhcp ? 'info' : 'success'"
|
||||
>
|
||||
{{ config.dhcp ? "只读" : "可填" }}
|
||||
{{ mainStore.config.dhcp ? "只读" : "可填" }}
|
||||
</ElTag>
|
||||
</ElTooltip>
|
||||
</template>
|
||||
@@ -252,6 +252,10 @@
|
||||
</ElFormItem>
|
||||
</div>
|
||||
</ElForm>
|
||||
<!-- <div class="flex justify-center items-center gap-[5px]">
|
||||
<el-button>分享当前配置</el-button>
|
||||
<el-button>导入联机配置</el-button>
|
||||
</div> -->
|
||||
<div class="mt-auto flex items-start">
|
||||
<div>
|
||||
<div class="pt-[4px]">
|
||||
@@ -330,7 +334,7 @@
|
||||
</div>
|
||||
<div class="mt-[10px] pl-[2px]">
|
||||
<ElTooltip
|
||||
placement="left"
|
||||
placement="top"
|
||||
content="日志"
|
||||
>
|
||||
<ElButton
|
||||
@@ -359,7 +363,7 @@
|
||||
</div>
|
||||
<div class="ml-auto">
|
||||
<ElCheckbox
|
||||
v-model="config.disbleP2p"
|
||||
v-model="mainStore.config.disbleP2p"
|
||||
size="small"
|
||||
>
|
||||
强制中转
|
||||
@@ -370,7 +374,7 @@
|
||||
>
|
||||
<ElCheckbox
|
||||
@change="handleAutoStartByTask"
|
||||
:model-value="config.autoStart"
|
||||
:model-value="mainStore.config.autoStart"
|
||||
size="small"
|
||||
>
|
||||
开机自启
|
||||
@@ -407,7 +411,7 @@
|
||||
|
||||
<ElBadge
|
||||
badge-class="!text-[9px] cursor-pointer"
|
||||
:hidden="!data.hasNewVersion"
|
||||
:hidden="!hasNewVersion"
|
||||
:offset="[6, 7]"
|
||||
value="N"
|
||||
>
|
||||
@@ -415,7 +419,7 @@
|
||||
<ElLink
|
||||
class="ml-[8px] truncate pb-[2px] !text-[9px]"
|
||||
type="info"
|
||||
:underline="false"
|
||||
underline="never"
|
||||
@click="open('https://github.com/EasyTier/EasytierGame')"
|
||||
>
|
||||
EasytierGame主页
|
||||
@@ -437,8 +441,11 @@
|
||||
>
|
||||
<div>
|
||||
<ElText>当前版本: {{ data.coreVersion || "-" }}</ElText>
|
||||
<div v-if="data.update">
|
||||
<ElProgress :percentage="progress"></ElProgress>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-[10px] pb-[5px]">
|
||||
<div class="mt-[5px] pb-[5px]">
|
||||
<ElText class="!mr-[10px]">选择一个内核版本安装</ElText>
|
||||
<ElButton
|
||||
:loading="coreManagementData.loading"
|
||||
@@ -481,7 +488,13 @@
|
||||
<ElInput
|
||||
v-model="mainStore.githubFastUrl"
|
||||
placeholder="请输入github加速地址"
|
||||
></ElInput>
|
||||
>
|
||||
<template #append>
|
||||
<ElTooltip content="github加速链接的发布地址,当前地址失效后,访问它获取最新的地址">
|
||||
<ElButton @click="open('https://ghproxy.link/')">发布地址</ElButton>
|
||||
</ElTooltip>
|
||||
</template>
|
||||
</ElInput>
|
||||
<template #footer>
|
||||
<div class="text-right">
|
||||
<ElButton
|
||||
@@ -682,7 +695,7 @@
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
|
||||
import { open, Command } from "@tauri-apps/plugin-shell";
|
||||
import {
|
||||
QuestionFilled,
|
||||
@@ -702,7 +715,7 @@
|
||||
SwitchFilled
|
||||
} from "@element-plus/icons-vue";
|
||||
import { reactive, onBeforeUnmount, onMounted, ref, toRaw, computed } from "vue";
|
||||
import { useTray, setTrayRunState, setTrayTooltip, checkNewVersion } from "~/composables/tray";
|
||||
import { useTray, setTrayRunState, setTrayTooltip, checkNewVersion, hasNewVersion } from "~/composables/tray";
|
||||
import { getMatches } from "@tauri-apps/plugin-cli";
|
||||
import { initStartWinIpBroadcast } from "~/composables/netcard";
|
||||
import useMainStore from "@/stores/index";
|
||||
@@ -711,11 +724,11 @@
|
||||
import { getAllWebviewWindows, WebviewWindow } from "@tauri-apps/api/webviewWindow";
|
||||
import etWindows, { dataSubscribe } from "@/composables/windows";
|
||||
import { resourceDir as getResourceDir, join } from "@tauri-apps/api/path";
|
||||
import { readDir, exists, mkdir, BaseDirectory, readTextFile, readFile, writeFile, remove as removeFile } from "@tauri-apps/plugin-fs";
|
||||
import { updateConfigJson } from "~/composables/configJson";
|
||||
import { readDir, exists, mkdir, BaseDirectory, readTextFile, readFile, writeFile, remove as removeFile, stat } from "@tauri-apps/plugin-fs";
|
||||
import { updateConfigJson, updateConfigJsonBounce } from "~/composables/configJson";
|
||||
import { writeText, readText } from "@tauri-apps/plugin-clipboard-manager";
|
||||
import { sortedUniq, uniq } from "lodash-es";
|
||||
import { bounce, addQQGroup, supportProtocols, preventSleep, stopPreventSleep, ATJ, copyText, isValidWindowsFileName } from "~/utils";
|
||||
import { addQQGroup, supportProtocols, preventSleep, stopPreventSleep, ATJ, copyText, isValidWindowsFileName } from "~/utils";
|
||||
import { ElConfirmDanger, ElConfirmPrimary } from "~/utils/element";
|
||||
import { getServerArgs } from "@/composables/server";
|
||||
|
||||
@@ -737,11 +750,10 @@
|
||||
);
|
||||
|
||||
const mainStore = useMainStore();
|
||||
const config = mainStore.config;
|
||||
// console.error(config);
|
||||
|
||||
const protocols = supportProtocols();
|
||||
const data = reactive({
|
||||
hasNewVersion: false, //easytierGame有没有新版
|
||||
//easytierGame有没有新版
|
||||
logVisible: false,
|
||||
cidrVisible: false,
|
||||
advanceVisible: false,
|
||||
@@ -803,8 +815,8 @@
|
||||
};
|
||||
|
||||
const handleCopyIp = async () => {
|
||||
if (!config.ipv4?.trim()) return;
|
||||
if (data.isStart || !config.dhcp) {
|
||||
if (!mainStore.config.ipv4?.trim()) return;
|
||||
if (data.isStart || !mainStore.config.dhcp) {
|
||||
await copyText(mainStore.config.ipv4);
|
||||
} else {
|
||||
await copyText(mainStore.config.ipv4, "复制成功,联机后IP可能会变化");
|
||||
@@ -829,8 +841,8 @@
|
||||
const newBasePeers = [...mainStore.basePeers];
|
||||
const idx = newBasePeers.indexOf(url);
|
||||
if (idx >= 0) {
|
||||
if (config.serverUrl === url) {
|
||||
config.serverUrl = "";
|
||||
if (mainStore.config.serverUrl === url) {
|
||||
mainStore.config.serverUrl = "";
|
||||
}
|
||||
newBasePeers.splice(idx, 1);
|
||||
}
|
||||
@@ -843,7 +855,7 @@
|
||||
const handleServerUrlChange = () => {
|
||||
let inputProtocols: string | null = null;
|
||||
for (const p of protocols) {
|
||||
if (config.serverUrl.toLowerCase().startsWith(`${p}://`)) {
|
||||
if (mainStore.config.serverUrl.toLowerCase().startsWith(`${p}://`)) {
|
||||
inputProtocols = p;
|
||||
break;
|
||||
}
|
||||
@@ -1024,11 +1036,17 @@
|
||||
// await getReleaseList();
|
||||
};
|
||||
|
||||
let unlistenDownload: UnlistenFn | null = null;
|
||||
let unlistenDownloadError: UnlistenFn | null = null;
|
||||
let progress = ref<number>(0);
|
||||
let size = 0;
|
||||
const handleInstallCore = async () => {
|
||||
try {
|
||||
if (!coreManagementData.data) {
|
||||
return ElMessage.error("请选择一个内核");
|
||||
}
|
||||
progress.value = 0;
|
||||
size = 0;
|
||||
data.update = true;
|
||||
await getCoreVersion();
|
||||
const [isNeedUpdate, downloadUrl, latestVersionFileName] = await checkUpdate();
|
||||
@@ -1036,6 +1054,22 @@
|
||||
if (isNeedUpdate) {
|
||||
await reset();
|
||||
// console.error(downloadUrl);
|
||||
if (unlistenDownload) {
|
||||
await unlistenDownload();
|
||||
}
|
||||
if (unlistenDownloadError) {
|
||||
await unlistenDownloadError();
|
||||
}
|
||||
unlistenDownload = await listen<[number, number]>("download_core_progress", ({ payload }) => {
|
||||
size += payload[0];
|
||||
progress.value = Math.round((size / payload[1]) * 100);
|
||||
});
|
||||
unlistenDownloadError = await listen("download_core_progress_error", () => {
|
||||
data.update = false;
|
||||
progress.value = 0;
|
||||
size = 0;
|
||||
ElMessage.error("发生错误,请重试");
|
||||
});
|
||||
await invoke("download_easytier_zip", { download_url: downloadUrl, file_name: latestVersionFileName });
|
||||
}
|
||||
await getCoreVersion();
|
||||
@@ -1060,9 +1094,10 @@
|
||||
};
|
||||
|
||||
const handleAutoStartByTask = async () => {
|
||||
await invoke("spawn_autostart", { enabled: !config.autoStart });
|
||||
if (import.meta.env.DEV) return ElMessage.warning("开发环境不支持开机自启");
|
||||
await invoke("spawn_autostart", { enabled: !mainStore.config.autoStart });
|
||||
const is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean;
|
||||
config.autoStart = is_enable_by_task;
|
||||
mainStore.config.autoStart = is_enable_by_task;
|
||||
};
|
||||
|
||||
const compatibleInitAutoStart = async () => {
|
||||
@@ -1070,21 +1105,42 @@
|
||||
let is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean;
|
||||
if (is_enable_by_task) {
|
||||
// 每次打开Exe重新加载一次开机自启,因为可能路径变了
|
||||
if (import.meta.env.DEV) return ElMessage.warning("开发环境不支持开机自启");
|
||||
await invoke("spawn_autostart", { enabled: false });
|
||||
await invoke("spawn_autostart", { enabled: true });
|
||||
}
|
||||
is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean;
|
||||
config.autoStart = is_enable_by_task;
|
||||
mainStore.config.autoStart = is_enable_by_task;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
await invoke("spawn_autostart", { enabled: false });
|
||||
const is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean;
|
||||
config.autoStart = is_enable_by_task;
|
||||
mainStore.config.autoStart = is_enable_by_task;
|
||||
}
|
||||
};
|
||||
|
||||
const compatibleIpv6Listener = async () => {
|
||||
// ipv6监听在后续版本合并到customListenner里了,这里做兼容处理
|
||||
if (mainStore.config.enableCustomListenerV6 && mainStore.config.customListenerV6Data) {
|
||||
const customListener = mainStore.config.customListenerV6Data.trim();
|
||||
if (customListener) {
|
||||
const customListenerV4 = mainStore.config.customListenerData
|
||||
.trim()
|
||||
.split("\n")
|
||||
.map(el => el.trim())
|
||||
.filter(el => el);
|
||||
if (!customListenerV4.includes(customListener)) {
|
||||
mainStore.config.customListenerData += `\n${customListener}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mainStore.config.enableCustomListenerV6) {
|
||||
mainStore.config.enableCustomListenerV6 = false;
|
||||
}
|
||||
};
|
||||
|
||||
const initConnectAfterStart = async () => {
|
||||
if (config.connectAfterStart && data.coreVersion) {
|
||||
if (mainStore.config.connectAfterStart && data.coreVersion) {
|
||||
await reset();
|
||||
await handleConnection();
|
||||
}
|
||||
@@ -1099,10 +1155,12 @@
|
||||
try {
|
||||
const decoder = new TextDecoder("utf-8");
|
||||
const guiJsonStr = decoder.decode(guiJsonStrUint8);
|
||||
const regex = /^(\s*\/\/.*)/gm;
|
||||
const regex2 = /(,?)\s*\/\/.*(?=\n|$|\r\n)/gm;
|
||||
const resultStr = guiJsonStr.replace(regex, "").replace(regex2, "$1");
|
||||
const guiJson = JSON.parse(resultStr);
|
||||
// console.log(guiJsonStr);
|
||||
// const regex = /^(\s*\/\/.*)/gm;
|
||||
// const regex2 = /(,?)\s*\/\/.*(?=\n|$|\r\n)/gm;
|
||||
// const resultStr = guiJsonStr.replace(regex, "").replace(regex2, "$1");
|
||||
// console.log(resultStr);
|
||||
const guiJson = JSON.parse(guiJsonStr);
|
||||
let saveServerUrl = "";
|
||||
if (guiJson.serverUrl) {
|
||||
if (Array.isArray(guiJson.serverUrl)) {
|
||||
@@ -1120,6 +1178,7 @@
|
||||
config: {
|
||||
...mainStore.config,
|
||||
...guiJson,
|
||||
customListenerData: guiJson?.customListenerData.join("\n") || "",
|
||||
serverUrl: saveServerUrl
|
||||
}
|
||||
});
|
||||
@@ -1171,12 +1230,12 @@
|
||||
let serverLogsTimer: NodeJS.Timeout | null = null;
|
||||
let cidrTimer: NodeJS.Timeout | null = null;
|
||||
|
||||
const b = bounce(600);
|
||||
onMounted(async () => {
|
||||
await initGuiJson();
|
||||
await compatibleInitAutoStart();
|
||||
// await initAutoStart();
|
||||
await initStartWinIpBroadcast();
|
||||
await compatibleIpv6Listener();
|
||||
await getCoreVersion();
|
||||
await listenObj.listenThreadId();
|
||||
await listenObj.listenServerThreadId();
|
||||
@@ -1187,15 +1246,21 @@
|
||||
initPreventSleep();
|
||||
mountedShow(); // 不需要await
|
||||
closePrevent();
|
||||
data.hasNewVersion = await checkNewVersion();
|
||||
dataSubscribe(async () => {
|
||||
if (mainStore.createConfigInEasytier) {
|
||||
b(async () => {
|
||||
await updateConfigJson(data.configJsonSeverUrl);
|
||||
});
|
||||
}
|
||||
});
|
||||
getReleaseList();
|
||||
if (import.meta.env.PROD) {
|
||||
getReleaseList();
|
||||
checkNewVersion();
|
||||
}
|
||||
await storageDialog();
|
||||
});
|
||||
|
||||
// storageEventEmitter.addEventListener("localStorageChange", () => {
|
||||
// if(mainStore.createConfigInEasytier) {
|
||||
// updateConfigJsonBounce(data.configJsonSeverUrl)
|
||||
// }
|
||||
// })
|
||||
|
||||
dataSubscribe(null, () => {
|
||||
return data.configJsonSeverUrl;
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
@@ -1206,6 +1271,7 @@
|
||||
serverLogsTimer && clearInterval(serverLogsTimer);
|
||||
cidrTimer && clearInterval(cidrTimer);
|
||||
stopPreventSleep();
|
||||
// unListenStorage && unListenStorage();
|
||||
});
|
||||
|
||||
const getArgs = async () => {
|
||||
@@ -1238,42 +1304,42 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (config.dhcp) {
|
||||
if (mainStore.config.dhcp) {
|
||||
args.push("-d");
|
||||
}
|
||||
if (config.hostname) {
|
||||
args.push("--hostname", config.hostname);
|
||||
if (mainStore.config.hostname) {
|
||||
args.push("--hostname", mainStore.config.hostname);
|
||||
}
|
||||
if (config.networkName) {
|
||||
args.push("--network-name", config.networkName);
|
||||
if (mainStore.config.networkName) {
|
||||
args.push("--network-name", mainStore.config.networkName);
|
||||
}
|
||||
if (config.networkPassword) {
|
||||
args.push("--network-secret", config.networkPassword);
|
||||
if (mainStore.config.networkPassword) {
|
||||
args.push("--network-secret", mainStore.config.networkPassword);
|
||||
}
|
||||
if (config.ipv4) {
|
||||
args.push("--ipv4", config.ipv4.trim());
|
||||
if (mainStore.config.ipv4) {
|
||||
args.push("--ipv4", mainStore.config.ipv4.trim());
|
||||
}
|
||||
if (config.serverUrl) {
|
||||
const formatUrl = config.serverUrl.replace(/\\/g, "/");
|
||||
args.push("--peers", ...config.protocol.map(protocol => `${protocol}://${formatUrl}`));
|
||||
if (mainStore.config.serverUrl) {
|
||||
const formatUrl = mainStore.config.serverUrl.replace(/\\/g, "/");
|
||||
args.push("--peers", ...mainStore.config.protocol.map(protocol => `${protocol}://${formatUrl}`));
|
||||
}
|
||||
if (config.enableCustomProtocol) {
|
||||
const includes = config.protocol.includes(config.customProtocol);
|
||||
if (mainStore.config.enableCustomProtocol) {
|
||||
const includes = mainStore.config.protocol.includes(mainStore.config.customProtocol);
|
||||
if (includes) {
|
||||
args.push("--default-protocol", config.customProtocol);
|
||||
args.push("--default-protocol", mainStore.config.customProtocol);
|
||||
}
|
||||
}
|
||||
if (config.disbleP2p) {
|
||||
if (mainStore.config.disbleP2p) {
|
||||
args.push("--disable-p2p");
|
||||
}
|
||||
if (config.disableIpv6) {
|
||||
if (mainStore.config.disableIpv6) {
|
||||
args.push("--disable-ipv6");
|
||||
}
|
||||
if (config.disbleListenner) {
|
||||
if (mainStore.config.disbleListenner) {
|
||||
args.push("--no-listener");
|
||||
}
|
||||
if (!config.disbleListenner && config.enableCustomListener && config.customListenerData) {
|
||||
const customListener = config.customListenerData
|
||||
if (!mainStore.config.disbleListenner && mainStore.config.enableCustomListener && mainStore.config.customListenerData) {
|
||||
const customListener = mainStore.config.customListenerData
|
||||
.trim()
|
||||
.split("\n")
|
||||
.map(el => el.trim())
|
||||
@@ -1282,14 +1348,14 @@
|
||||
args.push("-l", ...customListener);
|
||||
}
|
||||
}
|
||||
if (!config.disbleListenner && config.enableCustomListenerV6 && config.customListenerV6Data) {
|
||||
args.push("--ipv6-listener", config.customListenerV6Data);
|
||||
if (!mainStore.config.disbleListenner && mainStore.config.enableCustomListenerV6 && mainStore.config.customListenerV6Data) {
|
||||
args.push("--ipv6-listener", mainStore.config.customListenerV6Data);
|
||||
}
|
||||
if (!config.disbleListenner && !config.enableCustomListener && config.port) {
|
||||
args.push("-l", config.port);
|
||||
if (!mainStore.config.disbleListenner && !mainStore.config.enableCustomListener && mainStore.config.port) {
|
||||
args.push("-l", mainStore.config.port);
|
||||
}
|
||||
if (mainStore.cidrEnable && config.proxyNetworks) {
|
||||
let formatProxyNetworks = config.proxyNetworks.trim().split("\n");
|
||||
if (mainStore.cidrEnable && mainStore.config.proxyNetworks) {
|
||||
let formatProxyNetworks = mainStore.config.proxyNetworks.trim().split("\n");
|
||||
const newformatProxyNetworks = formatProxyNetworks
|
||||
.map(el => el.trim())
|
||||
.filter(cidr => {
|
||||
@@ -1298,55 +1364,76 @@
|
||||
if (newformatProxyNetworks.length > 0) {
|
||||
args.push("--proxy-networks", ...newformatProxyNetworks);
|
||||
}
|
||||
config.proxyNetworks = formatProxyNetworks.join("\n");
|
||||
mainStore.config.proxyNetworks = formatProxyNetworks.join("\n");
|
||||
}
|
||||
if (config.disableEncryption) {
|
||||
if (mainStore.config.disableEncryption) {
|
||||
args.push("--disable-encryption");
|
||||
}
|
||||
if (config.multiThread) {
|
||||
if (mainStore.config.multiThread) {
|
||||
args.push("--multi-thread");
|
||||
}
|
||||
if (config.enablExitNode) {
|
||||
if (mainStore.config.enablExitNode) {
|
||||
args.push("--enable-exit-node");
|
||||
}
|
||||
if (config.noTun) {
|
||||
if (mainStore.config.noTun) {
|
||||
args.push("--no-tun");
|
||||
}
|
||||
if (config.latencyfirst) {
|
||||
if (mainStore.config.latencyfirst) {
|
||||
args.push("--latency-first");
|
||||
}
|
||||
if (config.useSmoltcp) {
|
||||
if (mainStore.config.useSmoltcp) {
|
||||
args.push("--use-smoltcp");
|
||||
}
|
||||
if (config.disableUdpHolePunching) {
|
||||
if (mainStore.config.disableUdpHolePunching) {
|
||||
args.push("--disable-udp-hole-punching");
|
||||
}
|
||||
if (config.relayAllPeerrpc) {
|
||||
if (mainStore.config.relayAllPeerrpc) {
|
||||
args.push("--relay-all-peer-rpc");
|
||||
}
|
||||
if (config.saveErrorLog) {
|
||||
args.push("--file-log-level", config.logLevel, "--file-log-dir", import.meta.env.VITE_LOG_PATH);
|
||||
if (mainStore.config.saveErrorLog) {
|
||||
args.push("--file-log-level", mainStore.config.logLevel, "--file-log-dir", import.meta.env.VITE_LOG_PATH);
|
||||
}
|
||||
if (config.devName && config.devNameValue) {
|
||||
args.push("--dev-name", config.devNameValue);
|
||||
if (mainStore.config.devName && mainStore.config.devNameValue) {
|
||||
args.push("--dev-name", mainStore.config.devNameValue);
|
||||
}
|
||||
if (config.compression && config.compression != "none") {
|
||||
args.push("--compression", config.compression);
|
||||
if (mainStore.config.compression && mainStore.config.compression != "none") {
|
||||
args.push("--compression", mainStore.config.compression);
|
||||
}
|
||||
if (config.enableKcpProxy) {
|
||||
if (mainStore.config.enableKcpProxy) {
|
||||
args.push("--enable-kcp-proxy");
|
||||
}
|
||||
if (config.disableKcpInput) {
|
||||
if (mainStore.config.disableKcpInput) {
|
||||
args.push("--disable-kcp-input");
|
||||
}
|
||||
if (mainStore.config.bindDeviceEnable) {
|
||||
args.push("--bind-device", "true");
|
||||
}
|
||||
if (mainStore.proxyForwardBySystem) {
|
||||
args.push("--proxy-forward-by-system");
|
||||
}
|
||||
if (mainStore.config.acceptDNS) {
|
||||
args.push("--accept-dns", "true");
|
||||
}
|
||||
if (mainStore.config.enablePortForward) {
|
||||
let formatPortForward = mainStore.config.portForwardData.trim().split("\n");
|
||||
const newformatPortForward = formatPortForward.map(el => el.trim()).filter(el => el);
|
||||
if (newformatPortForward.length > 0) {
|
||||
newformatPortForward.map(el => {
|
||||
args.push("--port-forward", el);
|
||||
});
|
||||
}
|
||||
}
|
||||
if(mainStore.config.privateMode) {
|
||||
args.push("--private-mode", "true");
|
||||
}
|
||||
return args;
|
||||
};
|
||||
|
||||
const reset = async () => {
|
||||
data.isStart = false;
|
||||
data.isSuccessGetIp = false;
|
||||
if (config.dhcp) {
|
||||
config.ipv4 = "";
|
||||
if (mainStore.config.dhcp) {
|
||||
mainStore.config.ipv4 = "";
|
||||
}
|
||||
const memberDialog = await getAllWebviewWindows();
|
||||
const memberDialogs = memberDialog.filter(item => item.label === "member");
|
||||
@@ -1447,7 +1534,8 @@
|
||||
compression,
|
||||
enablePreventSleep,
|
||||
enableKcpProxy,
|
||||
disableKcpInput
|
||||
disableKcpInput,
|
||||
privateMode
|
||||
} = mainStore.config;
|
||||
const WT = btoa(
|
||||
encodeURIComponent(
|
||||
@@ -1480,7 +1568,8 @@
|
||||
compression,
|
||||
enablePreventSleep,
|
||||
enableKcpProxy,
|
||||
disableKcpInput
|
||||
disableKcpInput,
|
||||
privateMode
|
||||
}
|
||||
})
|
||||
)
|
||||
@@ -1651,7 +1740,7 @@
|
||||
});
|
||||
if (!err) {
|
||||
const payload = JSON.parse(decodeURIComponent(atob(importConfigData.data)));
|
||||
payload.config.serverUrl = payload?.config?.serverUrl?.trim() || config.serverUrl;
|
||||
payload.config.serverUrl = payload?.config?.serverUrl?.trim() || mainStore.config.serverUrl;
|
||||
mainStore.$patch({
|
||||
config: {
|
||||
...mainStore.config,
|
||||
@@ -1660,7 +1749,7 @@
|
||||
});
|
||||
ElMessage.success("导入成功");
|
||||
importConfigData.visible = false;
|
||||
mainStore.basePeers = uniq([config.serverUrl, ...mainStore.basePeers].filter(el => el.trim()));
|
||||
mainStore.basePeers = uniq([mainStore.config.serverUrl, ...mainStore.basePeers].filter(el => el.trim()));
|
||||
} else {
|
||||
console.error(err);
|
||||
if (err !== "cancel") {
|
||||
@@ -1760,7 +1849,7 @@
|
||||
cidrTimer && clearInterval(cidrTimer);
|
||||
cidrTimer = setInterval(() => {
|
||||
appWindow.emitTo({ kind: "WebviewWindow", label: "cidr" }, "route", data.isStart);
|
||||
}, 1000);
|
||||
}, 650);
|
||||
},
|
||||
() => {
|
||||
cidrTimer && clearInterval(cidrTimer);
|
||||
@@ -1835,4 +1924,26 @@
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const storageDialog = async () => {
|
||||
await etWindows("storage-listener", {
|
||||
title: "自建服务器",
|
||||
minWidth: 0,
|
||||
minHeight: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
x: 9999,
|
||||
y: 9999,
|
||||
resizable: false,
|
||||
transparent: true,
|
||||
hiddenTitle: true,
|
||||
alwaysOnBottom: true,
|
||||
url: "#/storage-listener"
|
||||
},
|
||||
(dialog) => {
|
||||
dialog.hide();
|
||||
},
|
||||
|
||||
);
|
||||
};
|
||||
</script>
|
||||
|
||||
+154
-1
@@ -48,13 +48,21 @@
|
||||
width="120"
|
||||
prop="ipv4"
|
||||
label="虚拟网IP"
|
||||
:sort-method="sortIpv4"
|
||||
:sort-orders="['ascending', 'descending', null]"
|
||||
></ElTableColumn>
|
||||
<ElTableColumn
|
||||
sortable
|
||||
prop="lat_ms"
|
||||
width="100"
|
||||
label="延迟/ms"
|
||||
></ElTableColumn>
|
||||
:sort-method="sortLatMs"
|
||||
:sort-orders="['ascending', 'descending', null]"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ formatLatency(row.lat_ms) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
sortable
|
||||
width="100"
|
||||
@@ -92,11 +100,15 @@
|
||||
width="90"
|
||||
prop="rx_bytes"
|
||||
label="接收"
|
||||
:sort-method="sortBytes"
|
||||
:sort-orders="['ascending', 'descending', null]"
|
||||
></ElTableColumn>
|
||||
<ElTableColumn
|
||||
sortable
|
||||
prop="tx_bytes"
|
||||
label="传输"
|
||||
:sort-method="(a, b) => sortBytes(a, b, 'tx_bytes')"
|
||||
:sort-orders="['ascending', 'descending', null]"
|
||||
></ElTableColumn>
|
||||
</ElTable>
|
||||
</div>
|
||||
@@ -108,6 +120,7 @@
|
||||
import { ATJ, parseCliInfo } from "@/utils";
|
||||
import { ElConfirmDanger } from "~/utils/element";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import { isNaN } from "lodash-es";
|
||||
// enum NatType {
|
||||
// // has NAT; but own a single public IP, port is not changed
|
||||
// Unknown = 0;
|
||||
@@ -139,6 +152,146 @@
|
||||
member: []
|
||||
});
|
||||
|
||||
// 延迟排序函数
|
||||
const sortLatMs = (a: any, b: any): number => {
|
||||
const getLatencyValue = (row: any): 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);
|
||||
};
|
||||
|
||||
const _showTableHeader = [
|
||||
["hostname", "主机名"],
|
||||
["cost", "路由"],
|
||||
|
||||
@@ -27,6 +27,12 @@
|
||||
>
|
||||
<ElCheckbox v-model="mainStore.serverConfig.autoStart">自动启动</ElCheckbox>
|
||||
</ElTooltip>
|
||||
<ElTooltip
|
||||
placement="top"
|
||||
content="启用后,不允许使用了与本网络不同的房间名和密码的节点通过本节点进行握手或中转"
|
||||
>
|
||||
<ElCheckbox v-model="mainStore.serverConfig.privateMode">私有模式</ElCheckbox>
|
||||
</ElTooltip>
|
||||
<ElTooltip
|
||||
placement="top"
|
||||
content="帮助其他虚拟网建立P2P链接"
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<template></template>
|
||||
<script setup lang="ts">
|
||||
import { dataSubscribe } from "~/composables/windows";
|
||||
|
||||
dataSubscribe();
|
||||
</script>
|
||||
+28
-15
@@ -25,7 +25,7 @@
|
||||
<ElLink
|
||||
class="mr-[10px] !text-[15px]"
|
||||
type="info"
|
||||
:underline="false"
|
||||
underline="never"
|
||||
@click="open('https://github.com/dechamps/WinIPBroadcast/releases/tag/winipbroadcast-1.6')"
|
||||
>
|
||||
WinIPBroadcast
|
||||
@@ -55,7 +55,7 @@
|
||||
<ElLink
|
||||
class="!text-[15px]"
|
||||
type="info"
|
||||
:underline="false"
|
||||
underline="never"
|
||||
@click="open('https://r1ch.net/projects/forcebindip')"
|
||||
>
|
||||
ForceBindIP
|
||||
@@ -198,16 +198,10 @@
|
||||
<ElButton
|
||||
type="warning"
|
||||
size="small"
|
||||
@click.stop="handleCloseAllFireWall"
|
||||
>
|
||||
一键关闭防火墙
|
||||
</ElButton>
|
||||
<ElButton
|
||||
@click="handleCustomFireWall"
|
||||
type="danger"
|
||||
size="small"
|
||||
>
|
||||
自定义防火墙策略
|
||||
</ElButton>
|
||||
</div>
|
||||
<div class="mb-[10px]">
|
||||
<ElText class="!mx-[10px]">域防火墙</ElText>
|
||||
@@ -251,10 +245,17 @@
|
||||
<ElButton
|
||||
size="small"
|
||||
:disabled="data.isPing"
|
||||
@click="handleTestPing"
|
||||
@click="handleTestPing('v4')"
|
||||
>
|
||||
Ping一下
|
||||
</ElButton>
|
||||
<!-- <ElButton
|
||||
size="small"
|
||||
:disabled="data.isPing"
|
||||
@click="handleTestPing('v6')"
|
||||
>
|
||||
Ping一下(v6)
|
||||
</ElButton> -->
|
||||
</div>
|
||||
<div class="mt-[5px] flex-1 overflow-auto">
|
||||
<ElInput
|
||||
@@ -305,8 +306,18 @@
|
||||
forceBindStart: false
|
||||
});
|
||||
|
||||
const handleCustomFireWall = async () => {
|
||||
await open("wf.msc");
|
||||
|
||||
const handleCloseAllFireWall = async () => {
|
||||
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) => {
|
||||
@@ -341,14 +352,15 @@
|
||||
});
|
||||
};
|
||||
|
||||
const handleTestPing = async () => {
|
||||
const handleTestPing = async (type: 'v4' | 'v6' = 'v4') => {
|
||||
// const is = isValidIP(data.pingIp);
|
||||
if (data.pingIp) {
|
||||
data.pingLog = "";
|
||||
data.isPing = true;
|
||||
const args = type === 'v4' ? ["-n", "1", data.pingIp] : ["-6", '-n', "1", data.pingIp]
|
||||
try {
|
||||
for (let i = 0; i < data.pingNum; i++) {
|
||||
const output = await Command.create("ping", ["-n", "1", data.pingIp], {
|
||||
const output = await Command.create("ping", args, {
|
||||
encoding: "gb2312"
|
||||
}).execute();
|
||||
if (output.stdout) {
|
||||
@@ -492,6 +504,7 @@
|
||||
data.pingIp = mainStore.config.ipv4;
|
||||
initStartWinIpBroadcast();
|
||||
getGuids();
|
||||
dataSubscribe();
|
||||
});
|
||||
|
||||
dataSubscribe();
|
||||
</script>
|
||||
|
||||
Generated
+4266
-2032
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
/gen/schemas
|
||||
/easytier/logs
|
||||
/easytier/logs/*.*
|
||||
target/
|
||||
gen/schemas
|
||||
./easytier/logs
|
||||
easytier/logs
|
||||
Generated
+598
-451
File diff suppressed because it is too large
Load Diff
+21
-18
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "easytier-game"
|
||||
version = "1.4.0"
|
||||
version = "1.4.6"
|
||||
homepage = "https://github.com/EasyTier/EasyTier"
|
||||
repository = "https://github.com/EasyTier/EasytierGame"
|
||||
description = "A simple network initiator based on Easytier"
|
||||
@@ -18,41 +18,44 @@ name = "app_lib"
|
||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2.0.5", features = [] }
|
||||
tauri-build = { version = "2.2.0", features = [] }
|
||||
# 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]
|
||||
serde_json = "1.0.137"
|
||||
serde = { version = "1.0.217", features = ["derive"] }
|
||||
log = "0.4.25"
|
||||
tauri = { version = "2.2.5", features = [ "protocol-asset",
|
||||
log = "0.4.26"
|
||||
tauri = { version = "2.5.1", features = [ "protocol-asset",
|
||||
"tray-icon",
|
||||
"image-png",
|
||||
"image-ico",
|
||||
"devtools"
|
||||
"image-ico"
|
||||
] }
|
||||
|
||||
tauri-plugin-log = "2.2.1"
|
||||
tauri-plugin-shell = "2.2.0"
|
||||
tauri-plugin-log = "2.3.1"
|
||||
tauri-plugin-shell = "2.2.1"
|
||||
reqwest = { version = "0.12.12", features = ["json"] }
|
||||
zip = "2.2.2"
|
||||
zip = "2.2.3"
|
||||
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"
|
||||
tauri-plugin-fs = "2.2.0"
|
||||
tauri-plugin-clipboard-manager = "2.2.1"
|
||||
rand = "0.8.5"
|
||||
tokio = { version = "1.43.0", features = ["process"] }
|
||||
tauri-plugin-dialog = "2.2.0"
|
||||
tauri-plugin-fs = "2.3.0"
|
||||
tauri-plugin-clipboard-manager = "2.2.2"
|
||||
rand = "0.9.0"
|
||||
tokio = { version = "1.45.1", features = ["process"] }
|
||||
tauri-plugin-dialog = "2.2.2"
|
||||
# prost = "0.13"
|
||||
# prost-types = "0.13"
|
||||
hashbrown = "0.15.2"
|
||||
# futures-util = "0.3"
|
||||
|
||||
[dependencies.windows]
|
||||
version = "0.58.0"
|
||||
features = ["Win32_System_TaskScheduler", "Win32_System_Power", "Win32_NetworkManagement_IpHelper", "Win32_NetworkManagement_Ndis", "Win32_Networking_WinSock"]
|
||||
features = ["Win32_System_TaskScheduler", "Win32_System_Com", "Win32_System_Power", "Win32_NetworkManagement_IpHelper", "Win32_NetworkManagement_Ndis", "Win32_Networking_WinSock"]
|
||||
|
||||
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
|
||||
tauri-plugin-cli = "2.2.0"
|
||||
tauri-plugin-single-instance = "2.2.1"
|
||||
tauri-plugin-window-state = "2.2.1"
|
||||
tauri-plugin-single-instance = "2.2.4"
|
||||
tauri-plugin-window-state = "2.2.2"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
fn main() {
|
||||
thunk::thunk();
|
||||
let mut windows = tauri_build::WindowsAttributes::new();
|
||||
windows = windows.app_manifest(
|
||||
r#"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "default",
|
||||
"description": "enables the default permissions",
|
||||
"windows": ["main", "log", "member", "cidr", "advance", "tool", "server", "gameList"],
|
||||
"windows": ["main", "log", "member", "cidr", "advance", "tool", "server", "gameList", "storage-listener"],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"core:window:allow-minimize",
|
||||
@@ -88,11 +88,19 @@
|
||||
"args": true,
|
||||
"cmd": "ping",
|
||||
"name": "ping"
|
||||
},
|
||||
{
|
||||
"args": true,
|
||||
"cmd": "powershell",
|
||||
"name": "powershell"
|
||||
}
|
||||
]
|
||||
},
|
||||
"fs:default",
|
||||
"fs:allow-read-dir",
|
||||
{
|
||||
"identifier": "fs:allow-read-dir",
|
||||
"allow": [{ "path": "$DESKTOP" }, { "path": "$DESKTOP/*" }, { "path": "**/*" }, { "path": "**" }]
|
||||
},
|
||||
"fs:allow-exists",
|
||||
"fs:allow-open",
|
||||
"fs:allow-resource-read",
|
||||
|
||||
@@ -4,27 +4,38 @@
|
||||
"tcp",
|
||||
"udp"
|
||||
], // 协议类型
|
||||
|
||||
// easytier服务地址 - 可填写多个 方式1,逗号分隔,"xxxx.cn,yyyy.com" 方式2,数组 ["xxxx.cn","yyyy.com"] (默认选中第一个)
|
||||
"serverUrl": "public.easytier.top:11010",
|
||||
"networkName": "", // 网络名
|
||||
"networkPassword": "", // 网络密码
|
||||
"hostname": "configTest", // 主机名
|
||||
"ipv4": "10.126.126.1", // IP地址(选填,下面有dhcp)
|
||||
"disableIpv6": false, // 禁用ipv6
|
||||
"disbleListenner": true, // 禁用端口监听
|
||||
"serverUrl": "public.easytier.top:11010",
|
||||
"enableCustomListener": true,
|
||||
"customListenerData": [
|
||||
"tcp://0.0.0.0:11010",
|
||||
"udp://0.0.0.0:11010",
|
||||
"tcp://[::]:11010"
|
||||
],
|
||||
"networkName": "", //房间名
|
||||
"networkPassword": "", //房间密码
|
||||
"hostname": "", //主机名
|
||||
"ipv4": "", // 虚拟IP地址
|
||||
"disableIpv6": false, // 禁用ipv6
|
||||
"enableCustomListenerV6": true, // 启用ipv6监听
|
||||
"customListenerV6Data": "udp://[::]:11010", // ipv6监听地址
|
||||
"disbleListenner": false, // 禁用监听
|
||||
"disableEncryption": false, // 禁用加密
|
||||
"enablExitNode": false, // 启用出口节点
|
||||
"noTun": false, // 禁用tun
|
||||
"latencyfirst": false, // 延迟优先
|
||||
"disableUdpHolePunching": false, // 禁用udp打洞
|
||||
"disbleP2p": false, // 禁用p2p, 强制中转
|
||||
"dhcp": false, // 动态分配IP
|
||||
"devName": false, // 是否启用自定义网卡名
|
||||
"devNameValue": "", // 网卡名(启用devName之后才生效)
|
||||
"enableCustonProtocol": false, // 是否启用自定义协议
|
||||
"customProtocol": "tcp", // 自定义协议类型
|
||||
"enableNetCardMetric": false, // 自定义easytier每次生成的网卡跃点
|
||||
"netCardMetricValue": 1, // 网卡跃点数量(1-9999)
|
||||
"enableKcpProxy": false, // 启用kcp代理
|
||||
"disableKcpInput": false //禁用kcp输入
|
||||
"disableUdpHolePunching": false, // 禁用udp打洞
|
||||
"disbleP2p": false, // 禁用p2p 强制中转
|
||||
"dhcp": true, // 启用dhcp,动态获取IP
|
||||
"devName": true, // 启用自定义网卡名
|
||||
"devNameValue": "etgame", // 自定义网卡名
|
||||
"enableCustomProtocol": true, // 自定义p2p时默认协议
|
||||
"customProtocol": "tcp", // 自定义p2p时使用的协议类型
|
||||
"enableNetCardMetric": true, // 启用自定义网卡跃点
|
||||
"netCardMetricValue": 1, // 网卡跃点
|
||||
"enablePreventSleep": false, // 启用防止睡眠
|
||||
"compression": "none", // 压缩算法
|
||||
"enableKcpProxy": true, // 启用kcp代理
|
||||
"disableKcpInput": false, // 禁用kcp输入
|
||||
"privateMode": false // 启用私有模式
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
+132
-43
@@ -1,8 +1,5 @@
|
||||
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 futures_util::StreamExt;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use std::fs::{self, File};
|
||||
@@ -16,7 +13,7 @@ use sysinfo::System;
|
||||
use tauri::tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent};
|
||||
use tauri::Emitter;
|
||||
use tauri::Manager;
|
||||
use windows::core::{BSTR, VARIANT};
|
||||
use windows::core::{Interface, BSTR, VARIANT};
|
||||
use windows::Win32::Foundation::VARIANT_BOOL;
|
||||
use windows::Win32::NetworkManagement::IpHelper::{
|
||||
GetAdaptersAddresses, GAA_FLAG_INCLUDE_PREFIX, IP_ADAPTER_ADDRESSES_LH,
|
||||
@@ -91,13 +88,13 @@ fn generate_random_user_agent() -> String {
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:{version}) Gecko/20100101 Firefox/{version}",
|
||||
];
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
let template = user_agents[rng.gen_range(0..user_agents.len())];
|
||||
let mut rng = rand::rng();
|
||||
let template = user_agents[rng.random_range(0..user_agents.len())];
|
||||
|
||||
// 生成随机版本号
|
||||
let version_major: u8 = rng.gen_range(70..90);
|
||||
let version_minor: u8 = rng.gen_range(0..10);
|
||||
let version_patch: u8 = rng.gen_range(0..10);
|
||||
let version_major: u8 = rng.random_range(70..90);
|
||||
let version_minor: u8 = rng.random_range(0..10);
|
||||
let version_patch: u8 = rng.random_range(0..10);
|
||||
let version = format!("{}.{}.{}", version_major, version_minor, version_patch);
|
||||
|
||||
// 替换模板中的版本号占位符
|
||||
@@ -325,7 +322,7 @@ async fn get_route_by_cli() -> String {
|
||||
}
|
||||
|
||||
#[tauri::command(rename_all = "snake_case")]
|
||||
async fn download_easytier_zip(download_url: String, file_name: String) {
|
||||
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_file_name = format!("{}\\{}", cache_dir_path, file_name);
|
||||
let cache_file_name_path = path::Path::new(&cache_file_name);
|
||||
@@ -335,12 +332,12 @@ async fn download_easytier_zip(download_url: String, file_name: String) {
|
||||
}
|
||||
|
||||
let target = format!("{}", download_url);
|
||||
let response = reqwest::get(target)
|
||||
let mut response = reqwest::get(target)
|
||||
.await
|
||||
.expect("error to download easytier url");
|
||||
let easytier_path = get_tool_exe_path("\\easytier");
|
||||
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);
|
||||
if !easytier_dir.exists() {
|
||||
@@ -354,11 +351,20 @@ async fn download_easytier_zip(download_url: String, file_name: String) {
|
||||
Err(why) => panic!("couldn't create {}", why),
|
||||
Ok(file) => file,
|
||||
};
|
||||
|
||||
let content = response.bytes().await.expect("error to bytes easytier");
|
||||
println!("下载完成,开始写入");
|
||||
file.write_all(&content).expect("error to write easytier");
|
||||
println!("写入完成");
|
||||
let context_size: u64 = response.content_length().unwrap();
|
||||
while let Some(item) = response.chunk().await.unwrap() {
|
||||
match file.write_all(&item) {
|
||||
Ok(_) => {
|
||||
app_handle.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);
|
||||
|
||||
let cache_dir_path = path::Path::new(&cache_dir_path);
|
||||
@@ -646,6 +652,50 @@ fn autostart_is_enabled() -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
// 新增辅助函数
|
||||
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 TASKAUTOSTART_ARG: &str = "--task-auto-start";
|
||||
fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -680,33 +730,72 @@ fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error
|
||||
CoUninitialize();
|
||||
}
|
||||
} else {
|
||||
let ts = planIfTaskScheduler::new()?;
|
||||
let com = ts.get_com();
|
||||
let sb = ScheduleBuilder::new(&com).unwrap();
|
||||
unsafe {
|
||||
let task_service: ITaskService = CoCreateInstance(&TaskScheduler, None, CLSCTX_ALL)?;
|
||||
task_service.Connect(
|
||||
&VARIANT::default(),
|
||||
&VARIANT::default(),
|
||||
&VARIANT::default(),
|
||||
&VARIANT::default(),
|
||||
)?;
|
||||
|
||||
let folder_path = BSTR::from("\\easytierGame");
|
||||
let task_name = BSTR::from("auto start");
|
||||
|
||||
let task_definition = task_service.NewTask(0)?;
|
||||
|
||||
// 设置任务信息
|
||||
let registration_info = task_definition.RegistrationInfo()?;
|
||||
registration_info.SetDescription(&BSTR::from("EasytierGame auto start task"))?;
|
||||
registration_info.SetAuthor(&BSTR::from("EasytierGame"))?;
|
||||
|
||||
// 改为用户登录触发
|
||||
let triggers = task_definition.Triggers()?;
|
||||
let trigger = triggers.Create(TASK_TRIGGER_LOGON)?;
|
||||
let logon_trigger: ILogonTrigger = trigger.cast()?;
|
||||
logon_trigger.SetEnabled(VARIANT_BOOL::from(true))?;
|
||||
|
||||
// 设置动作
|
||||
let actions = task_definition.Actions()?;
|
||||
let action = actions.Create(TASK_ACTION_EXEC)?;
|
||||
let exec_action: IExecAction = action.cast()?;
|
||||
let exe = std::env::current_exe()?;
|
||||
let exe_path: &str = exe.to_str().unwrap();
|
||||
exec_action.SetPath(&BSTR::from(exe_path))?;
|
||||
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 exe = std::env::current_exe()?;
|
||||
let exe = exe.to_str().unwrap();
|
||||
|
||||
let settings = PrincipalSettings {
|
||||
display_name: "".to_string(),
|
||||
group_id: None,
|
||||
id: "".to_string(),
|
||||
logon_type: LogonType::InteractiveToken,
|
||||
run_level: RunLevel::Highest,
|
||||
user_id: Some(whoami::username()),
|
||||
};
|
||||
sb.create_logon()
|
||||
.author("heixiansen")?
|
||||
.trigger("trigger", enabled)?
|
||||
.action(Action::new("auto start", exe, "", &TASKAUTOSTART_ARG))?
|
||||
.in_folder("easytierGame")?
|
||||
.principal(settings)?
|
||||
.delay(Duration {
|
||||
seconds: Some(6),
|
||||
..Default::default()
|
||||
})?
|
||||
.build()?
|
||||
.register("auto start", TaskCreationFlags::CreateOrUpdate as i32)?;
|
||||
// 设置任务设置
|
||||
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"))?;
|
||||
|
||||
|
||||
|
||||
// 获取文件夹并注册任务
|
||||
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(())
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "easytier-game",
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.6",
|
||||
"identifier": "com.tauri.easytier-game",
|
||||
|
||||
"build": {
|
||||
@@ -12,7 +12,7 @@
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "easytier-game 1.4.0",
|
||||
"title": "easytier-game 1.4.6",
|
||||
"label": "main",
|
||||
"minWidth": 340,
|
||||
"width": 340,
|
||||
|
||||
+31
-7
@@ -1,4 +1,7 @@
|
||||
import { acceptHMRUpdate, defineStore } from "pinia";
|
||||
|
||||
|
||||
|
||||
const store = defineStore("main", {
|
||||
state() {
|
||||
return {
|
||||
@@ -15,8 +18,8 @@ const store = defineStore("main", {
|
||||
disableIpv6: false, // 是否禁用IPv6
|
||||
port: "11010", // 监听端口号
|
||||
enableCustomListener: true, // 是否自定义监听
|
||||
customListenerV6Data: "udp://[::]:11010", //自定义ipv6监听
|
||||
enableCustomListenerV6: true, // 是否自定义监听
|
||||
enableCustomListenerV6: true, // 是否自定义IPV6监听
|
||||
customListenerV6Data: "udp://[::]:11010", //自定义ipv6监
|
||||
customListenerData: "tcp://0.0.0.0:11010\nudp://0.0.0.0:11010\ntcp://[::]:11010", // 自定义监听地址
|
||||
disbleListenner: false, // 是否禁用监听
|
||||
disableEncryption: false, // 是否禁用加密
|
||||
@@ -41,6 +44,12 @@ const store = defineStore("main", {
|
||||
compression: "none", //加密算法
|
||||
enableKcpProxy: true, //启用kcp代理 默认开启
|
||||
disableKcpInput: false, //禁用kcp输入
|
||||
bindDeviceEnable: false, //是否绑定设备
|
||||
acceptDNS: false, //魔法dns
|
||||
privateMode: false, //是否启用私有模式
|
||||
|
||||
enablePortForward: false, //是否启用端口转发
|
||||
portForwardData: "", //端口转发数据
|
||||
},
|
||||
serverConfig: {
|
||||
enableWhiteList: true, // 是否启用白名单
|
||||
@@ -48,10 +57,12 @@ const store = defineStore("main", {
|
||||
serverWhiteList: "", // 服务器流量转发白名单
|
||||
// enableListener: true, // 是否启用监听
|
||||
autoStart: false, //随软件自启
|
||||
port: "11010" // 服务器端口
|
||||
port: "11010", // 服务器端口
|
||||
privateMode: false, //是否启用私有模式
|
||||
},
|
||||
cidrEnable: false,
|
||||
basePeers: ["public.easytier.top:11010","public.easytier.net:11010"],
|
||||
proxyForwardBySystem: false, // 是否通过系统内核转发子网代理数据包,禁用内置NAT
|
||||
basePeers: ["public.easytier.top:11010", "public.easytier.net:11010"],
|
||||
theme: false, //主题 false light true dark
|
||||
configStartEnable: false, //使用配置文件启动
|
||||
configPath: "", //配置文件路径
|
||||
@@ -67,8 +78,9 @@ const store = defineStore("main", {
|
||||
|
||||
winipBcPid: 0,
|
||||
winipBcStart: false,
|
||||
latestTagName: "",
|
||||
|
||||
gameList: [] as Array<{name: string, exePath: string, id: string, coverImg: string; showImg: string}>, // 游戏列表
|
||||
gameList: [] as Array<{ name: string; exePath: string; id: string; coverImg?: string; showImg: string }> // 游戏列表
|
||||
};
|
||||
},
|
||||
persist: {
|
||||
@@ -101,7 +113,10 @@ const store = defineStore("main", {
|
||||
"config.enableNetCardMetric",
|
||||
"config.netCardMetricValue",
|
||||
"config.port",
|
||||
|
||||
|
||||
"config.enablePortForward",
|
||||
"config.portForwardData",
|
||||
|
||||
"config.disbleListenner",
|
||||
"config.enableCustomListener",
|
||||
"config.customListenerData",
|
||||
@@ -116,14 +131,22 @@ const store = defineStore("main", {
|
||||
"config.enableKcpProxy",
|
||||
"config.disableKcpInput",
|
||||
|
||||
"config.bindDeviceEnable",
|
||||
|
||||
"config.acceptDNS",
|
||||
|
||||
"config.privateMode",
|
||||
|
||||
"serverConfig.autoStart",
|
||||
// 'serverConfig.enableListener',
|
||||
"serverConfig.enableWhiteList",
|
||||
"serverConfig.relayAllPeerrpc",
|
||||
"serverConfig.serverWhiteList",
|
||||
"serverConfig.port",
|
||||
"serverConfig.privateMode",
|
||||
|
||||
"cidrEnable",
|
||||
"proxyForwardBySystem",
|
||||
"basePeers",
|
||||
"theme",
|
||||
"configStartEnable",
|
||||
@@ -136,7 +159,8 @@ const store = defineStore("main", {
|
||||
"delayInjectDll",
|
||||
"forceBindInput",
|
||||
"forceBindFile",
|
||||
|
||||
"latestTagName",
|
||||
|
||||
"gameList"
|
||||
]
|
||||
// // 除了这些,其他都要存下来
|
||||
|
||||
Reference in New Issue
Block a user