Compare commits

...
12 Commits
25 changed files with 3111 additions and 2662 deletions
+3 -1
View File
@@ -11,4 +11,6 @@ dist
.vscode .vscode
release release
src-tauri/easytier/logs src-tauri/easytier/logs
src-tauri/easytier/tool/ResourcesExtract.exe
src-tauri/easytier/tool/ResourcesExtract.cfg
+1 -1
View File
@@ -1 +1 @@
20.18.1 20.18.3
+8 -8
View File
@@ -1,12 +1,12 @@
pnpm run build pnpm run build
rustup default nightly @REM rustup default nightly
rem 使用rust nightly构建支持win7的版本,请先将根目录的windows.0.48.5 放入以下目录 @REM rem 使用rust nightly构建支持win7的版本,请先将根目录的windows.0.48.5 放入以下目录
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\x64
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\你自己的版本\lib\x86
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\x64
rem C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\atlmfc\lib\x86 @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 @REM pnpm tauri build -- -Z build-std --target x86_64-win7-windows-msvc
rustup default stable rustup default stable
pnpm tauri build pnpm tauri build
pnpm run release pnpm run release
pnpm run release-win7 @REM pnpm run release-win7
+7 -10
View File
@@ -14,23 +14,16 @@ export const updateConfigJson = async (configJsonSeverUrl: Array<string> | strin
const { const {
proxyNetworks, proxyNetworks,
autoStart, autoStart,
relayAllPeerrpc,
connectAfterStart, connectAfterStart,
multiThread,
enablExitNode,
useSmoltcp,
saveErrorLog, saveErrorLog,
logLevel,
serverUrl, serverUrl,
port,
enableCustomListener, enableCustomListener,
enablePreventSleep,
customListenerData, customListenerData,
customListenerV6Data, bindDeviceEnable,
enableCustomListenerV6,
...otherConfig ...otherConfig
} = mainStore.config; } = mainStore.config;
let writeServerUrl: Array<string> | string = serverUrl; let writeServerUrl: Array<string> | string = serverUrl;
let writeCustomListenerData: Array<string> = (customListenerData || "").split("\n");
if (isArray) { if (isArray) {
writeServerUrl = intersection( writeServerUrl = intersection(
uniq([serverUrl, ...configJsonSeverUrl]).filter(boolean => boolean), uniq([serverUrl, ...configJsonSeverUrl]).filter(boolean => boolean),
@@ -43,7 +36,11 @@ export const updateConfigJson = async (configJsonSeverUrl: Array<string> | strin
mainStore.basePeers mainStore.basePeers
).join(","); ).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) { } catch (err) {
console.error(err); console.error(err);
ElMessage.error(`更新config.json失败`); ElMessage.error(`更新config.json失败`);
+33
View File
@@ -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;
}
};
+37 -38
View File
@@ -8,6 +8,7 @@ import { resourceDir as getResourceDir, join } from "@tauri-apps/api/path";
import { invoke } from "@tauri-apps/api/core"; import { invoke } from "@tauri-apps/api/core";
// import { ElConfirmPrimary } from "~/utils/element"; // import { ElConfirmPrimary } from "~/utils/element";
import { open } from "@tauri-apps/plugin-shell"; import { open } from "@tauri-apps/plugin-shell";
import { computed } from "vue";
const DEFAULT_TRAY_NAME = "main"; const DEFAULT_TRAY_NAME = "main";
@@ -30,13 +31,10 @@ export async function useTray(init: boolean = false, beforExit: Function, handle
tooltip: `EasyTierGame\n${pkg.version}`, tooltip: `EasyTierGame\n${pkg.version}`,
title: `EasyTierGame\n${pkg.version}`, title: `EasyTierGame\n${pkg.version}`,
id: DEFAULT_TRAY_NAME, id: DEFAULT_TRAY_NAME,
menu: await Menu.new({ menu: await Menu.new({ id: "main", items: await generateMenuItem(beforExit, handleConnection) }),
id: "main", action: async e => {
items: await generateMenuItem(beforExit, handleConnection),
}),
action: async (e) => {
toggleVisibility(); toggleVisibility();
}, }
}); });
} }
} catch (error) { } catch (error) {
@@ -47,18 +45,13 @@ export async function useTray(init: boolean = false, beforExit: Function, handle
if (init) { if (init) {
tray.setTooltip(`EasyTierGame\n${pkg.version}`); tray.setTooltip(`EasyTierGame\n${pkg.version}`);
tray.setShowMenuOnLeftClick(false); tray.setShowMenuOnLeftClick(false);
tray.setMenu( tray.setMenu(await Menu.new({ id: "main", items: await generateMenuItem(beforExit, handleConnection) }));
await Menu.new({
id: "main",
items: await generateMenuItem(beforExit, handleConnection),
})
);
} }
return tray; return tray;
} }
export async function generateMenuItem(beforExit: Function, handleConnection:Function) { export async function generateMenuItem(beforExit: Function, handleConnection: Function) {
return [ return [
await MenuItemShow("显示 / 隐藏"), await MenuItemShow("显示 / 隐藏"),
await MenuItemExchangeConnection("联机 / 断开", handleConnection), await MenuItemExchangeConnection("联机 / 断开", handleConnection),
@@ -66,7 +59,7 @@ export async function generateMenuItem(beforExit: Function, handleConnection:Fun
await PredefinedMenuItem.new({ item: "Separator" }), await PredefinedMenuItem.new({ item: "Separator" }),
await MenuItemPublicPeers(), await MenuItemPublicPeers(),
await PredefinedMenuItem.new({ item: "Separator" }), 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 beforExit();
} }
await getCurrentWindow().close(); await getCurrentWindow().close();
}, }
}); });
} }
export async function MenuItemPublicPeers() { export async function MenuItemPublicPeers() {
return await MenuItem.new({ return await MenuItem.new({
id: "publicPeers", id: "publicPeers",
text: "公共节点", text: "公共节点",
action: async () => { action: async () => {
await open(import.meta.env.VITE_PUBLIC_PEERS_URL) await open(import.meta.env.VITE_PUBLIC_PEERS_URL);
}, }
}); });
} }
@@ -100,17 +92,17 @@ export async function MenuItemShow(text: string) {
text, text,
action: async () => { action: async () => {
await toggleVisibility(); await toggleVisibility();
}, }
}); });
} }
export async function MenuItemExchangeConnection(text: string, handleConnection:Function) { export async function MenuItemExchangeConnection(text: string, handleConnection: Function) {
const menutItem = await MenuItem.new({ const menutItem = await MenuItem.new({
id: "exchangeConnection", id: "exchangeConnection",
text, text,
action: async () => { action: async () => {
const isStart = await handleConnection(); const isStart = await handleConnection();
}, }
}); });
return menutItem; return menutItem;
} }
@@ -121,12 +113,10 @@ export async function MenuItemTheme() {
text: "主题切换", text: "主题切换",
action: async () => { action: async () => {
const mainStore = useMainStore(); const mainStore = useMainStore();
mainStore.$patch({ mainStore.$patch({ theme: !mainStore.theme });
theme: !mainStore.theme
});
// mainStore.$persist(); // mainStore.$persist();
await setTheme(mainStore.theme); 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 () => { export const checkNewVersion = async () => {
const mainStore = useMainStore();
// if(mainStore.latestTagName && mainStore.latestTagName == pkg.version) return;
if (hasNewVersion.value) return;
let [tagName, downloadUrl] = await invoke<string[]>("fetch_game_releases"); let [tagName, downloadUrl] = await invoke<string[]>("fetch_game_releases");
if(tagName && pkg.version !== tagName) { mainStore.latestTagName = tagName;
return true; //有新版 };
// const [err] = await ElConfirmPrimary("有新版本是否下载?", "发现新版本", {
// confirmButtonText: "下载", export const hasNewVersion = computed<boolean>(() => {
// cancelButtonText: "取消", const mainStore = useMainStore();
// }) return !!mainStore.latestTagName && versionDifference(pkg.version, mainStore.latestTagName) < 0 ;
// if(!err) { });
// open(downloadUrl);
// }
}
return false; //没有新版
}
+39 -28
View File
@@ -5,16 +5,31 @@ import type { WebviewLabel, WebviewOptions } from "@tauri-apps/api/webview";
import useMainStore from "@/stores/index"; import useMainStore from "@/stores/index";
import { onBeforeUnmount } from "vue"; import { onBeforeUnmount } from "vue";
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 ( export default async (
label: WebviewLabel, label: WebviewLabel,
options?: Omit<WebviewOptions, "x" | "y" | "width" | "height"> & WindowOptions, options?: Omit<WebviewOptions, "x" | "y" | "width" | "height"> & WindowOptions,
afterCreatedFunc?: (webviewWindow: WebviewWindow, appWindow: Window) => void | null, afterCreatedFunc?: (webviewWindow: WebviewWindow, appWindow: Window) => void | null,
beforeCloseFunc?: () => void | null beforeCloseFunc?: () => void | null
) => { ) => {
const unlistenFnList: [UnlistenFn | null, UnlistenFn | null] = _listenersMaps[label] || [null, null]; const unlistenFnList: [UnlistenFn | null] = _listenersMaps[label] || [null];
let [unlistenLogCreated, unListenlogClose] = unlistenFnList;
let dialog = await WebviewWindow.getByLabel(label); let dialog = await WebviewWindow.getByLabel(label);
if (!dialog) { if (!dialog) {
let defaultOpts: { [key: string]: any; parent: Window | undefined } = { let defaultOpts: { [key: string]: any; parent: Window | undefined } = {
@@ -38,28 +53,20 @@ export default async (
defaultOpts.x = logicalPosition.x; defaultOpts.x = logicalPosition.x;
defaultOpts.y = logicalPosition.y; defaultOpts.y = logicalPosition.y;
} }
unlistenLogCreated && (await (unlistenLogCreated as Function)());
unListenlogClose && (await unListenlogClose());
dialog = new WebviewWindow(label, { ...defaultOpts, ...options }); dialog = new WebviewWindow(label, { ...defaultOpts, ...options });
unlistenLogCreated = await dialog.listen("tauri://webview-created", async () => { await dealCloseListener(dialog, label, beforeCloseFunc);
if (dialog) { afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow));
afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow)); await dialog.show();
await dialog.show();
}
});
unlistenFnList[0] = unlistenLogCreated;
unListenlogClose = await dialog.onCloseRequested(async () => {
beforeCloseFunc && (await beforeCloseFunc());
unListenlogClose && (await unListenlogClose());
unlistenLogCreated && (await (unlistenLogCreated as Function)());
});
unlistenFnList[1] = unlistenLogCreated;
_listenersMaps[label] = unlistenFnList;
} else { } else {
const visible = await dialog.isVisible(); const visible = await dialog.isVisible();
if (visible) { if (visible) {
await dialog.close(); await dialog.close();
unlistenLogCreated && (await (unlistenLogCreated as Function)()); } else {
const appWindow = getCurrentWindow();
await dealCloseListener(dialog, label, beforeCloseFunc);
afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow));
await dialog.show();
} }
} }
}; };
@@ -68,15 +75,19 @@ export const dataSubscribe = async (cb?: (...args: any) => any) => {
if (!cb) return; if (!cb) return;
const mainStore = useMainStore(); const mainStore = useMainStore();
const abort = new AbortController(); const abort = new AbortController();
window.addEventListener("storage", async () => { window.addEventListener(
mainStore.$hydrate(); "storage",
if (cb && cb instanceof Function) { async () => {
await cb(); mainStore.$hydrate();
if (cb && cb instanceof Function) {
await cb();
}
},
{
signal: abort.signal
} }
}, { );
signal: abort.signal
})
onBeforeUnmount(() => { onBeforeUnmount(() => {
abort?.abort(); abort?.abort();
}) });
}; };
+93 -93
View File
@@ -3,107 +3,107 @@ import path from "path";
import vueJSX from "@vitejs/plugin-vue-jsx"; import vueJSX from "@vitejs/plugin-vue-jsx";
export default defineNuxtConfig({ export default defineNuxtConfig({
ssr: false, ssr: false,
devServer: { devServer: {
port: 5000 port: 5000
}, },
telemetry: false,
imports: { telemetry: false,
autoImport: false
},
css: ["~/assets/css/main.css", "element-plus/theme-chalk/dark/css-vars.css"], imports: {
modules: [ autoImport: false
"@element-plus/nuxt", },
"@pinia/nuxt",
[
"pinia-plugin-persistedstate/nuxt",
{
key: "__glj_persisted_%id",
storage: "localStorage"
}
],
"@nuxtjs/tailwindcss"
],
alias: { css: ["~/assets/css/main.css", "element-plus/theme-chalk/dark/css-vars.css"],
"@": path.resolve(__dirname, "./") modules: [
}, "@element-plus/nuxt",
"@pinia/nuxt",
[
"pinia-plugin-persistedstate/nuxt",
{
key: "__glj_persisted_%id",
storage: "localStorage"
}
],
"@nuxtjs/tailwindcss"
],
experimental: { alias: {
payloadExtraction: false "@": path.resolve(__dirname, "./")
}, },
devtools: { experimental: {
enabled: false payloadExtraction: false
}, },
router: { devtools: {
options: { enabled: false
hashMode: true },
}
},
vite: { router: {
plugins: [vueJSX({})], options: {
envDir: "env", hashMode: true
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"]
}
},
postcss: { vite: {
plugins: { plugins: [vueJSX({})],
tailwindcss: {}, envDir: "env",
autoprefixer: {} 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: { postcss: {
rootId: "__easytier", plugins: {
cdnURL: "./", tailwindcss: {},
buildAssetsDir: "__easytier/", autoprefixer: {}
head: { }
meta: [ },
{
name: "viewport", app: {
content: "width=device-width, initial-scale=1" rootId: "__easytier",
}, cdnURL: "./",
{ buildAssetsDir: "__easytier/",
charset: "utf-8" head: {
} meta: [
], {
title: "easytier-game" name: "viewport",
// link: [], content: "width=device-width, initial-scale=1"
// style: [], },
// script: [], {
// noscript: [] charset: "utf-8"
} }
}, ],
compatibilityDate: "2024-11-12" title: "easytier-game"
// link: [],
// style: [],
// script: [],
// noscript: []
}
},
compatibilityDate: "2024-11-12"
}); });
+17 -17
View File
@@ -3,7 +3,7 @@
"private": true, "private": true,
"author": "leizi97", "author": "leizi97",
"description": "A simple network initiator based on Easytier", "description": "A simple network initiator based on Easytier",
"version": "1.4.0", "version": "1.4.4",
"scripts": { "scripts": {
"dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0", "dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0",
"build": "nuxt generate --dotenv env/.env.prod", "build": "nuxt generate --dotenv env/.env.prod",
@@ -13,29 +13,29 @@
"devDependencies": { "devDependencies": {
"@element-plus/icons-vue": "^2.3.1", "@element-plus/icons-vue": "^2.3.1",
"@element-plus/nuxt": "^1.1.1", "@element-plus/nuxt": "^1.1.1",
"@nuxtjs/tailwindcss": "6.13.1", "@nuxtjs/tailwindcss": "6.13.2",
"@pinia/nuxt": "0.9.0", "@pinia/nuxt": "0.11.0",
"@tauri-apps/api": "^2.2.0", "@tauri-apps/api": "2.5.0",
"@tauri-apps/cli": "2.2.7", "@tauri-apps/cli": "2.5.0",
"@tauri-apps/plugin-cli": "^2.2.0", "@tauri-apps/plugin-cli": "^2.2.0",
"@tauri-apps/plugin-clipboard-manager": "2.2.0", "@tauri-apps/plugin-clipboard-manager": "2.2.2",
"@tauri-apps/plugin-dialog": "2.2.0", "@tauri-apps/plugin-dialog": "2.2.1",
"@tauri-apps/plugin-fs": "^2.2.0", "@tauri-apps/plugin-fs": "2.2.1",
"@tauri-apps/plugin-log": "2.2.1", "@tauri-apps/plugin-log": "2.3.1",
"@tauri-apps/plugin-shell": "^2.2.0", "@tauri-apps/plugin-shell": "2.2.1",
"@tauri-apps/plugin-window-state": "2.2.1", "@tauri-apps/plugin-window-state": "2.2.2",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@vitejs/plugin-vue-jsx": "^4.1.1", "@vitejs/plugin-vue-jsx": "4.1.2",
"@vueuse/core": "12.4.0", "@vueuse/core": "12.7.0",
"archiver": "^7.0.1", "archiver": "^7.0.1",
"element-plus": "2.9.4", "element-plus": "2.9.7",
"less": "4.2.1", "less": "4.2.1",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"nuxt": "3.15.4", "nuxt": "3.16.2",
"pinia": "2.3.1", "pinia": "3.0.2",
"pinia-plugin-persistedstate": "^4.2.0", "pinia-plugin-persistedstate": "^4.2.0",
"postcss": "^8.4.38", "postcss": "^8.4.38",
"prettier": "3.4.2", "prettier": "3.5.2",
"prettier-plugin-tailwindcss": "0.6.11" "prettier-plugin-tailwindcss": "0.6.11"
} }
} }
+79 -22
View File
@@ -2,8 +2,8 @@
<div class="flex h-full flex-col items-start overflow-auto px-[25px]"> <div class="flex h-full flex-col items-start overflow-auto px-[25px]">
<div class="flex flex-nowrap items-center gap-[15px]"> <div class="flex flex-nowrap items-center gap-[15px]">
<div class="flex flex-nowrap items-center gap-[5px]"> <div class="flex flex-nowrap items-center gap-[5px]">
<ElCheckbox v-model="mainStore.config.enableCustomProtocol">默认直连(p2p)使用的协议</ElCheckbox> <ElCheckbox v-model="mainStore.config.enableCustomProtocol">直连(P2P)优先使用传输协议</ElCheckbox>
<ElTooltip content="如果没有支持该协议的节点地址,程序会自动处理,请放心使用"> <ElTooltip content="若无法建立指定的协议,会自动使用可建立连接的协议">
<ElIcon><QuestionFilled /></ElIcon> <ElIcon><QuestionFilled /></ElIcon>
</ElTooltip> </ElTooltip>
</div> </div>
@@ -24,7 +24,7 @@
</div> </div>
</div> </div>
<div> <div>
<ElCheckbox v-model="mainStore.config.relayAllPeerrpc">帮助对等节点建立直连(p2p)通信</ElCheckbox> <ElCheckbox v-model="mainStore.config.relayAllPeerrpc">帮助他人建立直连(P2P)连接</ElCheckbox>
</div> </div>
<div><ElCheckbox v-model="mainStore.config.connectAfterStart">软件启动后自动"启动联机"(搭配开机自启无感联机)</ElCheckbox></div> <div><ElCheckbox v-model="mainStore.config.connectAfterStart">软件启动后自动"启动联机"(搭配开机自启无感联机)</ElCheckbox></div>
<div class="flex flex-nowrap items-center gap-[15px]"> <div class="flex flex-nowrap items-center gap-[15px]">
@@ -38,8 +38,8 @@
</div> </div>
<div><ElCheckbox v-model="mainStore.config.enablePreventSleep">防止系统休眠(比如:屏幕会一直亮着)</ElCheckbox></div> <div><ElCheckbox v-model="mainStore.config.enablePreventSleep">防止系统休眠(比如:屏幕会一直亮着)</ElCheckbox></div>
<div class="flex flex-nowrap items-center gap-[5px]"> <div class="flex flex-nowrap items-center gap-[5px]">
<ElCheckbox v-model="mainStore.config.latencyfirst">延迟优先模式将尝试使用低延迟路径转发流量</ElCheckbox> <ElCheckbox v-model="mainStore.config.latencyfirst">使用低延迟模式</ElCheckbox>
<ElTooltip content="视网络质量进行选择,可能会出现中转与直连(p2p)来回切换的情况"> <ElTooltip content="弱网环境下可能会导致网络延迟延迟忽高忽低">
<ElIcon><QuestionFilled /></ElIcon> <ElIcon><QuestionFilled /></ElIcon>
</ElTooltip> </ElTooltip>
</div> </div>
@@ -124,10 +124,11 @@
</template> </template>
</ElDialog> </ElDialog>
</div> </div>
<div class="flex items-center gap-[10px]"> <!-- <div class="flex items-center gap-[10px]">
<ElCheckbox <ElCheckbox
:disabled="mainStore.config.disbleListenner" :disabled="mainStore.config.disbleListenner"
v-model="mainStore.config.enableCustomListenerV6" :model-value="mainStore.config.enableCustomListenerV6"
@change="handleCustomListenerV6Change"
> >
自定义IPV6监听地址 自定义IPV6监听地址
</ElCheckbox> </ElCheckbox>
@@ -140,23 +141,23 @@
placeholder="请输入自定义IPV6监听地址" placeholder="请输入自定义IPV6监听地址"
/> />
</div> </div>
<ElTooltip content="例如:tcp://[::]:11010,如果未设置,将在随机UDP端口上监听"> <ElTooltip content="例如:tcp://[::]:11010,如果未设置,将在随机UDP端口上监听(内核版本2.2.3之后,ipv6监听被移除并合并到'自定义监听')">
<ElIcon><QuestionFilled /></ElIcon> <ElIcon><QuestionFilled /></ElIcon>
</ElTooltip> </ElTooltip>
<CoreVersionWarning version="2.1.0" /> <CoreVersionWarning version="2.1.0" />
</div> </div> -->
<ElDivider /> <ElDivider />
<div class="flex items-center gap-[10px]"> <div class="flex items-center gap-[10px]">
<ElCheckbox v-model="mainStore.config.devName">自定义网卡名</ElCheckbox> <ElCheckbox v-model="mainStore.config.devName">自定义虚拟网卡名</ElCheckbox>
<ElInput <ElInput
size="small" size="small"
maxlength="10" maxlength="10"
v-model="mainStore.config.devNameValue" v-model="mainStore.config.devNameValue"
placeholder="请输入网卡名" placeholder="请输入虚拟网卡名"
/> />
</div> </div>
<div class="flex items-center gap-[10px]"> <div class="flex items-center gap-[10px]">
<ElCheckbox v-model="mainStore.config.enableNetCardMetric">自定义easytier网卡跃点</ElCheckbox> <ElCheckbox v-model="mainStore.config.enableNetCardMetric">自定义虚拟网卡优先级</ElCheckbox>
<ElInputNumber <ElInputNumber
controls-position="right" controls-position="right"
:min="1" :min="1"
@@ -166,9 +167,9 @@
:precision="0" :precision="0"
size="small" size="small"
v-model="mainStore.config.netCardMetricValue" v-model="mainStore.config.netCardMetricValue"
placeholder="请选择跃点数" placeholder="请输入优先级"
/> />
<ElTooltip content="设置easytier网卡的跃点,提升网卡优先级,跃点越小,网卡优先级越高"> <ElTooltip content="数值越小,优先级越高">
<ElIcon><QuestionFilled /></ElIcon> <ElIcon><QuestionFilled /></ElIcon>
</ElTooltip> </ElTooltip>
</div> </div>
@@ -177,17 +178,59 @@
size="small" size="small"
type="warning" type="warning"
> >
(不使用自定义网卡名,那么联机时默认会生成一个名为 "et_xxx" 的网卡也可以使用 设置跃点 功能除非你启用了下面的功能) (不使用自定义虚拟网卡名,那么联机时默认会生成一个名为 "et_xxx" 的网卡也可以使用 自定义虚拟网卡优先级
功能除非你启用了下面的功能)
</ElText> </ElText>
</div> </div>
<div><ElCheckbox v-model="mainStore.config.noTun">不创建TUN设备(网卡)可以使用子网代理访问节点</ElCheckbox></div>
<div class="flex items-center gap-[5px]">
<ElCheckbox v-model="mainStore.config.noTun">不创建TUN虚拟网卡</ElCheckbox>
<ElTooltip content="开启后该节点无法主动访问其他节点">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
</div>
<div class="flex items-center gap-[5px]">
<div><ElCheckbox v-model="mainStore.config.bindDeviceEnable">绑定物理网卡</ElCheckbox></div>
<!-- <div class="flex items-center gap-[5px]"> -->
<!-- <ElSelect
placeholder="选择设备"
v-model="mainStore.config.bindDevice"
filterable
no-data-text="暂无网卡设备数据请刷新"
>
<ElOption
v-for="guid in guids"
:key="guid[0]"
:label="guid[1]"
:value="guid[0]"
></ElOption>
</ElSelect> -->
<!-- <ElButton @click="getGuids">刷新</ElButton> -->
<ElTooltip content="将连接器的套接字绑定到物理设备以避免路由问题。比如子网代理网段与某节点的网段冲突,绑定物理设备后可以与该节点正常通信">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
<!-- </div> -->
<CoreVersionWarning version="2.2.3" />
</div>
<ElDivider /> <ElDivider />
<div><ElCheckbox v-model="mainStore.config.enablExitNode">允许此节点成为出口节点</ElCheckbox></div> <div><ElCheckbox v-model="mainStore.config.enablExitNode">允许此节点成为出口节点</ElCheckbox></div>
<div><ElCheckbox v-model="mainStore.config.disableEncryption">禁用对等节点通信的加密</ElCheckbox></div> <div class="flex items-center gap-[5px]">
<div><ElCheckbox v-model="mainStore.config.multiThread">启用多线程运行</ElCheckbox></div> <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]"> <div class="flex items-center gap-[10px]">
<ElText>压缩算法</ElText> <ElText>传输数据压缩算法</ElText>
<div class="w-[160px]"> <div class="w-[160px]">
<ElSelect <ElSelect
size="small" size="small"
@@ -210,8 +253,8 @@
<ElDivider /> <ElDivider />
<div class="flex items-center gap-[10px]"> <div class="flex items-center gap-[10px]">
<ElCheckbox v-model="mainStore.config.useSmoltcp">为子网代理启用smoltcp堆栈</ElCheckbox> <ElCheckbox v-model="mainStore.config.useSmoltcp">为子网代理和 KCP 代理开启用户网络栈</ElCheckbox>
<ElTooltip content="使用用户态TCP/IP协议栈smoltcp,避免操作系统防火墙问题导致无法子网代理"> <ElTooltip content="开启后会降低网络性能,但不需要配置防火墙">
<ElIcon><QuestionFilled /></ElIcon> <ElIcon><QuestionFilled /></ElIcon>
</ElTooltip> </ElTooltip>
</div> </div>
@@ -269,6 +312,20 @@
listenerDialogData.visible = false; listenerDialogData.visible = false;
}; };
// const handleCustomListenerV6Change = async (value: boolean) => {
// if (value) {
// const [error, _] = await ElConfirmDanger("内核版本2.2.3之后,ipv6监听被移除并合并到'自定义监听',请谨慎使用", "警告", {
// confirmButtonText: "继续使用",
// cancelButtonText: "取消"
// });
// if (!error) {
// mainStore.config.enableCustomListenerV6 = value;
// }
// } else {
// mainStore.config.enableCustomListenerV6 = value;
// }
// };
const mainStore = useMainStore(); const mainStore = useMainStore();
const data = ["trace", "debug", "info", "warn", "error", "off"]; const data = ["trace", "debug", "info", "warn", "error", "off"];
const guids = ref<string[][]>([]); const guids = ref<string[][]>([]);
@@ -297,7 +354,7 @@
}; };
// 为bind_device功能增加改方法 // 为bind_device功能增加改方法
const _getGuids = async () => { const getGuids = async () => {
const guidsValue = await invoke<string[][]>("get_network_adapter_guids"); const guidsValue = await invoke<string[][]>("get_network_adapter_guids");
guids.value = guidsValue && guidsValue.length > 0 ? guidsValue : []; guids.value = guidsValue && guidsValue.length > 0 ? guidsValue : [];
}; };
+13 -9
View File
@@ -1,12 +1,18 @@
<template> <template>
<div class="flex h-full flex-col gap-[10px]"> <div class="flex h-full flex-col gap-[10px]">
<ElRadioGroup <div class="flex items-center gap-[10px]">
:disabled="!data.isSwitchEnable" <ElRadioGroup
v-model="mainStore.cidrEnable" :disabled="!data.isSwitchEnable"
> v-model="mainStore.cidrEnable"
<ElRadioButton :value="true">开启</ElRadioButton> >
<ElRadioButton :value="false">关闭</ElRadioButton> <ElRadioButton :value="true">开启</ElRadioButton>
</ElRadioGroup> <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"> <div class="flex-1 overflow-auto">
<ElInput <ElInput
placeholder="例如: 192.168.1.0/24 一行一个" placeholder="例如: 192.168.1.0/24 一行一个"
@@ -113,6 +119,4 @@
onBeforeUnmount(() => { onBeforeUnmount(() => {
unlistenStart && unlistenStart(); unlistenStart && unlistenStart();
}); });
</script> </script>
+165 -29
View File
@@ -16,14 +16,14 @@
class="mr-[5px]" class="mr-[5px]"
@click="handleCreate" @click="handleCreate"
> >
新增本地游戏 新增游戏
</ElButton> </ElButton>
<ElButton <ElButton
size="small" size="small"
class="mr-[5px]" class="!ml-[0px] mr-[5px]"
@click="openCoverDir" @click="openCoverDir"
> >
打开封面目录 封面目录
</ElButton> </ElButton>
</div> </div>
</div> </div>
@@ -37,7 +37,7 @@
<ElCard> <ElCard>
<template #header> <template #header>
<div class="flex flex-nowrap gap-[0_8px]"> <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"> <p class="ml-auto flex-1 truncate">
<ElText <ElText
size="default" size="default"
@@ -56,7 +56,7 @@
/> />
</ElCard> </ElCard>
<div <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 <ElButton
size="large" size="large"
@@ -92,10 +92,13 @@
@click.stop="handleCreate" @click.stop="handleCreate"
shadow="hover" 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)]"> <ElIcon class="!text-[80px] transition-all group-hover/plus:text-[color:var(--el-color-primary)]">
<Plus></Plus> <Plus></Plus>
</ElIcon> </ElIcon>
<div>
<ElText>支持从桌面拖放新增</ElText>
</div>
</div> </div>
</ElCard> </ElCard>
</ElTooltip> </ElTooltip>
@@ -148,7 +151,7 @@
</ElFormItem> </ElFormItem>
<ElFormItem <ElFormItem
label="游戏封面" label="游戏封面"
prop="coverImg" prop="showImg"
> >
<ElBadge :hidden="createGameData.form.showImg == defaultPng"> <ElBadge :hidden="createGameData.form.showImg == defaultPng">
<template #content="{ value }"> <template #content="{ value }">
@@ -162,7 +165,7 @@
</div> </div>
</template> </template>
<img <img
@click.stop="handleBrowser('coverImg')" @click.stop="handleBrowser('showImg')"
:src="showImgConvertFileSrc(createGameData.form.showImg)" :src="showImgConvertFileSrc(createGameData.form.showImg)"
class="aspect-[1] w-[120px] cursor-pointer object-cover" class="aspect-[1] w-[120px] cursor-pointer object-cover"
/> />
@@ -191,9 +194,9 @@
<script lang="ts" setup> <script lang="ts" setup>
import { VideoPlay, DeleteFilled, EditPen, Plus, Delete } from "@element-plus/icons-vue"; import { VideoPlay, DeleteFilled, EditPen, Plus, Delete } from "@element-plus/icons-vue";
import { dataSubscribe } from "~/composables/windows"; import { dataSubscribe } from "~/composables/windows";
import { BaseDirectory, resourceDir as getResourceDir, join } from "@tauri-apps/api/path"; import { BaseDirectory, basename, extname, resourceDir as getResourceDir, join } from "@tauri-apps/api/path";
import { convertFileSrc } from "@tauri-apps/api/core"; import { convertFileSrc, Resource } from "@tauri-apps/api/core";
import { computed, nextTick, reactive, ref, useTemplateRef } from "vue"; import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, useTemplateRef } from "vue";
import useMainStore from "@/stores/index"; import useMainStore from "@/stores/index";
import { uniqueId } from "lodash-es"; import { uniqueId } from "lodash-es";
import { open as dialogOpen } from "@tauri-apps/plugin-dialog"; import { open as dialogOpen } from "@tauri-apps/plugin-dialog";
@@ -202,6 +205,8 @@
import { ElConfirmDanger } from "~/utils/element"; import { ElConfirmDanger } from "~/utils/element";
import { copyFile, exists, mkdir, readDir, remove } from "@tauri-apps/plugin-fs"; import { copyFile, exists, mkdir, readDir, remove } from "@tauri-apps/plugin-fs";
import { Command, open } from "@tauri-apps/plugin-shell"; import { Command, open } from "@tauri-apps/plugin-shell";
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
const resourceDir = await getResourceDir(); const resourceDir = await getResourceDir();
const gameListResourceDir = await join(resourceDir, import.meta.env.VITE_GAME_LIST_PATH); const gameListResourceDir = await join(resourceDir, import.meta.env.VITE_GAME_LIST_PATH);
// const defaultLocalIconPath = await join(configPath, "icon.png"); // const defaultLocalIconPath = await join(configPath, "icon.png");
@@ -211,7 +216,7 @@
const searchValue = ref(""); const searchValue = ref("");
const defaultPng = "/default.png"; const defaultPng = "/default.png";
// const b = bounce(600); // 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({ const createGameData = reactive({
visible: false, visible: false,
isEdit: false, isEdit: false,
@@ -219,7 +224,6 @@
id: "", id: "",
name: "", name: "",
exePath: "", exePath: "",
coverImg: "",
showImg: defaultPng showImg: defaultPng
}, },
rules: { rules: {
@@ -241,29 +245,27 @@
id: "", id: "",
name: "", name: "",
exePath: "", exePath: "",
coverImg: "",
showImg: defaultPng showImg: defaultPng
}; };
await nextTick(); await nextTick();
createGameData.visible = true; createGameData.visible = true;
}; };
const handleBrowser = async (type: "coverImg" | "exePath") => { const handleBrowser = async (type: "showImg" | "exePath") => {
const filters = type === "coverImg" ? [{ name: "", extensions: ["png", "jpg", "jpeg"] }] : [{ name: "", extensions: ["exe"] }]; const filters = type === "showImg" ? [{ name: "", extensions: ["png", "jpg", "jpeg"] }] : [{ name: "", extensions: ["exe"] }];
const file = await dialogOpen({ const file = await dialogOpen({
multiple: false, multiple: false,
directory: false, directory: false,
filters filters
}); });
if (file) { if (file) {
if (type === "coverImg") { if (type === "showImg") {
createGameData.form.coverImg = file; if (file) {
if (createGameData.form.coverImg) {
if (!createGameData.form.id) { if (!createGameData.form.id) {
const time = new Date().getTime(); const time = new Date().getTime();
createGameData.form.id = uniqueId(`${time}`); 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 game_list_path = import.meta.env.VITE_GAME_LIST_PATH;
const isExists = await exists(game_list_path, { baseDir: BaseDirectory.Resource }); const isExists = await exists(game_list_path, { baseDir: BaseDirectory.Resource });
if (!isExists) { if (!isExists) {
@@ -272,14 +274,16 @@
} catch (err) {} } catch (err) {}
} }
const toPath = await join(gameListResourceDir, createGameData.form.id); const toPath = await join(gameListResourceDir, createGameData.form.id);
const suffix = coverImg.split(".").pop(); const suffix = showImg.split(".").pop();
const toPathFileName = `${toPath}.${suffix}`; const toPathFileName = `${toPath}.${suffix}`;
if (coverImg != toPathFileName) { if (showImg != toPathFileName) {
await copyFile(coverImg, toPathFileName); await copyFile(showImg, toPathFileName);
} }
// console.log(toPathFileName);
const isExistsToPath = await exists(toPathFileName); const isExistsToPath = await exists(toPathFileName);
if (isExistsToPath) { 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) { if (createGameData.form.showImg == defaultPng) {
//删除本地封面图 //删除本地封面图
// const toPath = await join(gameListResourceDir, createGameData.form.id); // const toPath = await join(gameListResourceDir, createGameData.form.id);
// const suffix = coverImg.split(".").pop();
// const imgPath = `${toPath}.${suffix}`; // const imgPath = `${toPath}.${suffix}`;
// await remove(imgPath); // await remove(imgPath);
} }
@@ -333,23 +336,27 @@
const handleBadgeDeleteCover = async () => { const handleBadgeDeleteCover = async () => {
await removeFileById(createGameData.form.id); await removeFileById(createGameData.form.id);
createGameData.form = { ...createGameData.form, coverImg: "", showImg: defaultPng }; createGameData.form = { ...createGameData.form, showImg: defaultPng };
}; };
const removeFileById = async (id: string) => { const removeFileById = async (id: string) => {
if (!id) return; if (!id) return;
const isExists = await exists(gameListResourceDir);
if (!isExists) return;
const entries = await readDir(gameListResourceDir); const entries = await readDir(gameListResourceDir);
if (entries.length > 0) { if (entries.length > 0) {
for (const entry of entries) { for (const entry of entries) {
if (entry.name.includes(id + ".")) { if (entry.name.includes(id + ".")) {
const imgPath = await join(gameListResourceDir, entry.name); const imgPath = await join(gameListResourceDir, entry.name);
const isExists = await exists(imgPath);
if (!isExists) continue;
await remove(imgPath); await remove(imgPath);
} }
} }
} }
}; };
const handleDeleteItem = async ({ coverImg, id }: gameItemType) => { const handleDeleteItem = async ({ id }: gameItemType) => {
if (id) { if (id) {
const [error, _] = await ElConfirmDanger("确定要删除吗?"); const [error, _] = await ElConfirmDanger("确定要删除吗?");
if (!error) { if (!error) {
@@ -383,7 +390,6 @@
const handleImgError = (item: gameItemType, idx: number) => { const handleImgError = (item: gameItemType, idx: number) => {
item.showImg = defaultPng; item.showImg = defaultPng;
item.coverImg = "";
mainStore.gameList[idx] = { ...item }; mainStore.gameList[idx] = { ...item };
mainStore.$patch({ mainStore.$patch({
gameList: [...mainStore.gameList] gameList: [...mainStore.gameList]
@@ -391,7 +397,137 @@
}; };
const showImgConvertFileSrc = (showImg: string) => { 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(); dataSubscribe();
</script> </script>
+80 -13
View File
@@ -252,6 +252,10 @@
</ElFormItem> </ElFormItem>
</div> </div>
</ElForm> </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 class="mt-auto flex items-start">
<div> <div>
<div class="pt-[4px]"> <div class="pt-[4px]">
@@ -330,7 +334,7 @@
</div> </div>
<div class="mt-[10px] pl-[2px]"> <div class="mt-[10px] pl-[2px]">
<ElTooltip <ElTooltip
placement="left" placement="top"
content="日志" content="日志"
> >
<ElButton <ElButton
@@ -407,7 +411,7 @@
<ElBadge <ElBadge
badge-class="!text-[9px] cursor-pointer" badge-class="!text-[9px] cursor-pointer"
:hidden="!data.hasNewVersion" :hidden="!hasNewVersion"
:offset="[6, 7]" :offset="[6, 7]"
value="N" value="N"
> >
@@ -437,8 +441,11 @@
> >
<div> <div>
<ElText>当前版本: {{ data.coreVersion || "-" }}</ElText> <ElText>当前版本: {{ data.coreVersion || "-" }}</ElText>
<div v-if="data.update">
<ElProgress :percentage="progress"></ElProgress>
</div>
</div> </div>
<div class="mt-[10px] pb-[5px]"> <div class="mt-[5px] pb-[5px]">
<ElText class="!mr-[10px]">选择一个内核版本安装</ElText> <ElText class="!mr-[10px]">选择一个内核版本安装</ElText>
<ElButton <ElButton
:loading="coreManagementData.loading" :loading="coreManagementData.loading"
@@ -481,7 +488,13 @@
<ElInput <ElInput
v-model="mainStore.githubFastUrl" v-model="mainStore.githubFastUrl"
placeholder="请输入github加速地址" placeholder="请输入github加速地址"
></ElInput> >
<template #append>
<ElTooltip content="github加速链接的发布地址,当前地址失效后,访问它获取最新的地址">
<ElButton @click="open('https://ghproxy.link/')">发布地址</ElButton>
</ElTooltip>
</template>
</ElInput>
<template #footer> <template #footer>
<div class="text-right"> <div class="text-right">
<ElButton <ElButton
@@ -682,7 +695,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { invoke } from "@tauri-apps/api/core"; import { invoke } from "@tauri-apps/api/core";
import { listen } from "@tauri-apps/api/event"; import { listen, type UnlistenFn } from "@tauri-apps/api/event";
import { open, Command } from "@tauri-apps/plugin-shell"; import { open, Command } from "@tauri-apps/plugin-shell";
import { import {
QuestionFilled, QuestionFilled,
@@ -702,7 +715,7 @@
SwitchFilled SwitchFilled
} from "@element-plus/icons-vue"; } from "@element-plus/icons-vue";
import { reactive, onBeforeUnmount, onMounted, ref, toRaw, computed } from "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 { getMatches } from "@tauri-apps/plugin-cli";
import { initStartWinIpBroadcast } from "~/composables/netcard"; import { initStartWinIpBroadcast } from "~/composables/netcard";
import useMainStore from "@/stores/index"; import useMainStore from "@/stores/index";
@@ -741,7 +754,7 @@
// console.error(config); // console.error(config);
const protocols = supportProtocols(); const protocols = supportProtocols();
const data = reactive({ const data = reactive({
hasNewVersion: false, //easytierGame有没有新版 //easytierGame有没有新版
logVisible: false, logVisible: false,
cidrVisible: false, cidrVisible: false,
advanceVisible: false, advanceVisible: false,
@@ -1024,11 +1037,17 @@
// await getReleaseList(); // await getReleaseList();
}; };
let unlistenDownload: UnlistenFn | null = null;
let unlistenDownloadError: UnlistenFn | null = null;
let progress = ref<number>(0);
let size = 0;
const handleInstallCore = async () => { const handleInstallCore = async () => {
try { try {
if (!coreManagementData.data) { if (!coreManagementData.data) {
return ElMessage.error("请选择一个内核"); return ElMessage.error("请选择一个内核");
} }
progress.value = 0;
size = 0;
data.update = true; data.update = true;
await getCoreVersion(); await getCoreVersion();
const [isNeedUpdate, downloadUrl, latestVersionFileName] = await checkUpdate(); const [isNeedUpdate, downloadUrl, latestVersionFileName] = await checkUpdate();
@@ -1036,6 +1055,22 @@
if (isNeedUpdate) { if (isNeedUpdate) {
await reset(); await reset();
// console.error(downloadUrl); // 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 invoke("download_easytier_zip", { download_url: downloadUrl, file_name: latestVersionFileName });
} }
await getCoreVersion(); await getCoreVersion();
@@ -1060,6 +1095,7 @@
}; };
const handleAutoStartByTask = async () => { const handleAutoStartByTask = async () => {
if (import.meta.env.DEV) return ElMessage.warning("开发环境不支持开机自启");
await invoke("spawn_autostart", { enabled: !config.autoStart }); await invoke("spawn_autostart", { enabled: !config.autoStart });
const is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean; const is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean;
config.autoStart = is_enable_by_task; config.autoStart = is_enable_by_task;
@@ -1070,6 +1106,7 @@
let is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean; let is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean;
if (is_enable_by_task) { if (is_enable_by_task) {
// 每次打开Exe重新加载一次开机自启,因为可能路径变了 // 每次打开Exe重新加载一次开机自启,因为可能路径变了
if (import.meta.env.DEV) return ElMessage.warning("开发环境不支持开机自启");
await invoke("spawn_autostart", { enabled: false }); await invoke("spawn_autostart", { enabled: false });
await invoke("spawn_autostart", { enabled: true }); await invoke("spawn_autostart", { enabled: true });
} }
@@ -1083,6 +1120,26 @@
} }
}; };
const compatibleIpv6Listener = async () => {
// ipv6监听在后续版本合并到customListenner里了,这里做兼容处理
if (config.enableCustomListenerV6 && config.customListenerV6Data) {
const customListener = config.customListenerV6Data.trim();
if (customListener) {
const customListenerV4 = config.customListenerData
.trim()
.split("\n")
.map(el => el.trim())
.filter(el => el);
if (!customListenerV4.includes(customListener)) {
config.customListenerData += `\n${customListener}`;
}
}
}
if (config.enableCustomListenerV6) {
config.enableCustomListenerV6 = false;
}
};
const initConnectAfterStart = async () => { const initConnectAfterStart = async () => {
if (config.connectAfterStart && data.coreVersion) { if (config.connectAfterStart && data.coreVersion) {
await reset(); await reset();
@@ -1099,10 +1156,12 @@
try { try {
const decoder = new TextDecoder("utf-8"); const decoder = new TextDecoder("utf-8");
const guiJsonStr = decoder.decode(guiJsonStrUint8); const guiJsonStr = decoder.decode(guiJsonStrUint8);
const regex = /^(\s*\/\/.*)/gm; // console.log(guiJsonStr);
const regex2 = /(,?)\s*\/\/.*(?=\n|$|\r\n)/gm; // const regex = /^(\s*\/\/.*)/gm;
const resultStr = guiJsonStr.replace(regex, "").replace(regex2, "$1"); // const regex2 = /(,?)\s*\/\/.*(?=\n|$|\r\n)/gm;
const guiJson = JSON.parse(resultStr); // const resultStr = guiJsonStr.replace(regex, "").replace(regex2, "$1");
// console.log(resultStr);
const guiJson = JSON.parse(guiJsonStr);
let saveServerUrl = ""; let saveServerUrl = "";
if (guiJson.serverUrl) { if (guiJson.serverUrl) {
if (Array.isArray(guiJson.serverUrl)) { if (Array.isArray(guiJson.serverUrl)) {
@@ -1120,6 +1179,7 @@
config: { config: {
...mainStore.config, ...mainStore.config,
...guiJson, ...guiJson,
customListenerData: guiJson?.customListenerData.join("\n") || "",
serverUrl: saveServerUrl serverUrl: saveServerUrl
} }
}); });
@@ -1177,6 +1237,7 @@
await compatibleInitAutoStart(); await compatibleInitAutoStart();
// await initAutoStart(); // await initAutoStart();
await initStartWinIpBroadcast(); await initStartWinIpBroadcast();
await compatibleIpv6Listener();
await getCoreVersion(); await getCoreVersion();
await listenObj.listenThreadId(); await listenObj.listenThreadId();
await listenObj.listenServerThreadId(); await listenObj.listenServerThreadId();
@@ -1187,7 +1248,6 @@
initPreventSleep(); initPreventSleep();
mountedShow(); // 不需要await mountedShow(); // 不需要await
closePrevent(); closePrevent();
data.hasNewVersion = await checkNewVersion();
dataSubscribe(async () => { dataSubscribe(async () => {
if (mainStore.createConfigInEasytier) { if (mainStore.createConfigInEasytier) {
b(async () => { b(async () => {
@@ -1196,6 +1256,7 @@
} }
}); });
getReleaseList(); getReleaseList();
checkNewVersion();
}); });
onBeforeUnmount(() => { onBeforeUnmount(() => {
@@ -1339,6 +1400,12 @@
if (config.disableKcpInput) { if (config.disableKcpInput) {
args.push("--disable-kcp-input"); args.push("--disable-kcp-input");
} }
if (config.bindDeviceEnable) {
args.push("--bind-device", "true");
}
if (mainStore.proxyForwardBySystem) {
args.push("--proxy-forward-by-system");
}
return args; return args;
}; };
@@ -1760,7 +1827,7 @@
cidrTimer && clearInterval(cidrTimer); cidrTimer && clearInterval(cidrTimer);
cidrTimer = setInterval(() => { cidrTimer = setInterval(() => {
appWindow.emitTo({ kind: "WebviewWindow", label: "cidr" }, "route", data.isStart); appWindow.emitTo({ kind: "WebviewWindow", label: "cidr" }, "route", data.isStart);
}, 1000); }, 650);
}, },
() => { () => {
cidrTimer && clearInterval(cidrTimer); cidrTimer && clearInterval(cidrTimer);
+6 -1
View File
@@ -54,7 +54,11 @@
prop="lat_ms" prop="lat_ms"
width="100" width="100"
label="延迟/ms" label="延迟/ms"
></ElTableColumn> >
<template #default="{ row }">
{{ row.lat_ms && !isNaN(Number(row.lat_ms)) ? Number(row.lat_ms).toFixed(0) : row.lat_ms || "-" }}
</template>
</ElTableColumn>
<ElTableColumn <ElTableColumn
sortable sortable
width="100" width="100"
@@ -108,6 +112,7 @@
import { ATJ, parseCliInfo } from "@/utils"; import { ATJ, parseCliInfo } from "@/utils";
import { ElConfirmDanger } from "~/utils/element"; import { ElConfirmDanger } from "~/utils/element";
import { getCurrentWindow } from "@tauri-apps/api/window"; import { getCurrentWindow } from "@tauri-apps/api/window";
import { isNaN } from "lodash-es";
// enum NatType { // enum NatType {
// // has NAT; but own a single public IP, port is not changed // // has NAT; but own a single public IP, port is not changed
// Unknown = 0; // Unknown = 0;
+1838 -1905
View File
File diff suppressed because it is too large Load Diff
+596 -430
View File
File diff suppressed because it is too large Load Diff
+19 -16
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "easytier-game" name = "easytier-game"
version = "1.4.0" version = "1.4.4"
homepage = "https://github.com/EasyTier/EasyTier" homepage = "https://github.com/EasyTier/EasyTier"
repository = "https://github.com/EasyTier/EasytierGame" repository = "https://github.com/EasyTier/EasytierGame"
description = "A simple network initiator based on Easytier" description = "A simple network initiator based on Easytier"
@@ -18,41 +18,44 @@ name = "app_lib"
crate-type = ["staticlib", "cdylib", "rlib"] crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies] [build-dependencies]
tauri-build = { version = "2.0.5", features = [] } tauri-build = { version = "2.2.0", features = [] }
# prost-build = "0.13.2" # prost-build = "0.13.2"
[target.x86_64-pc-windows-msvc.build-dependencies]
thunk-rs = { git = "https://github.com/easytier/thunk.git", default-features = false, features = ["win7"] } # 需要安装curl和7zip,并添加他们的路径到环境变量
[dependencies] [dependencies]
serde_json = "1.0.137" serde_json = "1.0.137"
serde = { version = "1.0.217", features = ["derive"] } serde = { version = "1.0.217", features = ["derive"] }
log = "0.4.25" log = "0.4.26"
tauri = { version = "2.2.5", features = [ "protocol-asset", tauri = { version = "2.5.0", features = [ "protocol-asset",
"tray-icon", "tray-icon",
"image-png", "image-png",
"image-ico", "image-ico"
"devtools"
] } ] }
tauri-plugin-log = "2.2.1" tauri-plugin-log = "2.3.1"
tauri-plugin-shell = "2.2.0" tauri-plugin-shell = "2.2.1"
reqwest = { version = "0.12.12", features = ["json"] } reqwest = { version = "0.12.12", features = ["json"] }
zip = "2.2.2" zip = "2.2.3"
sysinfo = '0.33.1' sysinfo = '0.33.1'
planif = { git = "https://github.com/mattrobineau/planif", tag = "1.0.1" } planif = { git = "https://github.com/mattrobineau/planif", tag = "1.0.1" }
whoami = "1.5.2" whoami = "1.5.2"
tauri-plugin-fs = "2.2.0" tauri-plugin-fs = "2.2.1"
tauri-plugin-clipboard-manager = "2.2.1" tauri-plugin-clipboard-manager = "2.2.2"
rand = "0.8.5" rand = "0.9.0"
tokio = { version = "1.43.0", features = ["process"] } tokio = { version = "1.43.0", features = ["process"] }
tauri-plugin-dialog = "2.2.0" tauri-plugin-dialog = "2.2.1"
# prost = "0.13" # prost = "0.13"
# prost-types = "0.13" # prost-types = "0.13"
hashbrown = "0.15.2" hashbrown = "0.15.2"
# futures-util = "0.3"
[dependencies.windows] [dependencies.windows]
version = "0.58.0" 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] [target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
tauri-plugin-cli = "2.2.0" tauri-plugin-cli = "2.2.0"
tauri-plugin-single-instance = "2.2.1" tauri-plugin-single-instance = "2.2.3"
tauri-plugin-window-state = "2.2.1" tauri-plugin-window-state = "2.2.2"
+1
View File
@@ -1,4 +1,5 @@
fn main() { fn main() {
thunk::thunk();
let mut windows = tauri_build::WindowsAttributes::new(); let mut windows = tauri_build::WindowsAttributes::new();
windows = windows.app_manifest( windows = windows.app_manifest(
r#" r#"
+9 -1
View File
@@ -88,11 +88,19 @@
"args": true, "args": true,
"cmd": "ping", "cmd": "ping",
"name": "ping" "name": "ping"
},
{
"args": true,
"cmd": "powershell",
"name": "powershell"
} }
] ]
}, },
"fs:default", "fs:default",
"fs:allow-read-dir", {
"identifier": "fs:allow-read-dir",
"allow": [{ "path": "$DESKTOP" }, { "path": "$DESKTOP/*" }, { "path": "**/*" }, { "path": "**" }]
},
"fs:allow-exists", "fs:allow-exists",
"fs:allow-open", "fs:allow-open",
"fs:allow-resource-read", "fs:allow-resource-read",
+29 -19
View File
@@ -4,27 +4,37 @@
"tcp", "tcp",
"udp" "udp"
], // 协议类型 ], // 协议类型
// easytier服务地址 - 可填写多个 方式1,逗号分隔,"xxxx.cn,yyyy.com" 方式2,数组 ["xxxx.cn","yyyy.com"] (默认选中第一个) // easytier服务地址 - 可填写多个 方式1,逗号分隔,"xxxx.cn,yyyy.com" 方式2,数组 ["xxxx.cn","yyyy.com"] (默认选中第一个)
"serverUrl": "public.easytier.top:11010", "serverUrl": "public.easytier.top:11010",
"networkName": "", // 网络名 "enableCustomListener": true,
"networkPassword": "", // 网络密码 "customListenerData": [
"hostname": "configTest", // 主机名 "tcp://0.0.0.0:11010",
"ipv4": "10.126.126.1", // IP地址(选填,下面有dhcp) "udp://0.0.0.0:11010",
"disableIpv6": false, // 禁用ipv6 "tcp://[::]:11010"
"disbleListenner": true, // 禁用端口监听 ],
"networkName": "", //房间名
"networkPassword": "", //房间密码
"hostname": "", //主机名
"ipv4": "", // 虚拟IP地址
"disableIpv6": false, // 禁用ipv6
"enableCustomListenerV6": true, // 启用ipv6监听
"customListenerV6Data": "udp://[::]:11010", // ipv6监听地址
"disbleListenner": false, // 禁用监听
"disableEncryption": false, // 禁用加密 "disableEncryption": false, // 禁用加密
"enablExitNode": false, // 启用出口节点
"noTun": false, // 禁用tun "noTun": false, // 禁用tun
"latencyfirst": false, // 延迟优先 "latencyfirst": false, // 延迟优先
"disableUdpHolePunching": false, // 禁用udp打洞 "disableUdpHolePunching": false, // 禁用udp打洞
"disbleP2p": false, // 禁用p2p, 强制中转 "disbleP2p": false, // 禁用p2p 强制中转
"dhcp": false, // 动态分配IP "dhcp": true, // 启用dhcp,动态获取IP
"devName": false, // 是否启用自定义网卡名 "devName": true, // 启用自定义网卡名
"devNameValue": "", // 网卡名(启用devName之后才生效) "devNameValue": "etgame", // 自定义网卡名
"enableCustonProtocol": false, // 是否启用自定义协议 "enableCustomProtocol": true, // 自定义p2p时默认协议
"customProtocol": "tcp", // 自定义协议类型 "customProtocol": "tcp", // 自定义p2p时使用的协议类型
"enableNetCardMetric": false, // 自定义easytier每次生成的网卡跃点 "enableNetCardMetric": true, // 启用自定义网卡跃点
"netCardMetricValue": 1, // 网卡跃点数量(1-9999) "netCardMetricValue": 1, // 网卡跃点
"enableKcpProxy": false, // 启用kcp代理 "enablePreventSleep": false, // 启用防止睡眠
"disableKcpInput": false //禁用kcp输入 "compression": "none", // 压缩算法
"enableKcpProxy": true, // 启用kcp代理
"disableKcpInput": false // 禁用kcp输入
} }
Binary file not shown.
Binary file not shown.
+23 -13
View File
@@ -3,6 +3,7 @@ use planif::schedule::TaskScheduler as planIfTaskScheduler;
use planif::schedule_builder::{Action, ScheduleBuilder}; use planif::schedule_builder::{Action, ScheduleBuilder};
use planif::settings::{Duration, LogonType, PrincipalSettings, RunLevel}; use planif::settings::{Duration, LogonType, PrincipalSettings, RunLevel};
use reqwest::{Client, Error}; use reqwest::{Client, Error};
// use futures_util::StreamExt;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashMap; use std::collections::HashMap;
use std::fs::{self, File}; use std::fs::{self, File};
@@ -91,13 +92,13 @@ fn generate_random_user_agent() -> String {
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:{version}) Gecko/20100101 Firefox/{version}", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:{version}) Gecko/20100101 Firefox/{version}",
]; ];
let mut rng = rand::thread_rng(); let mut rng = rand::rng();
let template = user_agents[rng.gen_range(0..user_agents.len())]; let template = user_agents[rng.random_range(0..user_agents.len())];
// 生成随机版本号 // 生成随机版本号
let version_major: u8 = rng.gen_range(70..90); let version_major: u8 = rng.random_range(70..90);
let version_minor: u8 = rng.gen_range(0..10); let version_minor: u8 = rng.random_range(0..10);
let version_patch: u8 = rng.gen_range(0..10); let version_patch: u8 = rng.random_range(0..10);
let version = format!("{}.{}.{}", version_major, version_minor, version_patch); let version = format!("{}.{}.{}", version_major, version_minor, version_patch);
// 替换模板中的版本号占位符 // 替换模板中的版本号占位符
@@ -325,7 +326,7 @@ async fn get_route_by_cli() -> String {
} }
#[tauri::command(rename_all = "snake_case")] #[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_dir_path = get_tool_exe_path("\\easytier\\cache");
let cache_file_name = format!("{}\\{}", cache_dir_path, file_name); let cache_file_name = format!("{}\\{}", cache_dir_path, file_name);
let cache_file_name_path = path::Path::new(&cache_file_name); let cache_file_name_path = path::Path::new(&cache_file_name);
@@ -335,12 +336,12 @@ async fn download_easytier_zip(download_url: String, file_name: String) {
} }
let target = format!("{}", download_url); let target = format!("{}", download_url);
let response = reqwest::get(target) let mut response = reqwest::get(target)
.await .await
.expect("error to download easytier url"); .expect("error to download easytier url");
let easytier_path = get_tool_exe_path("\\easytier"); let easytier_path = get_tool_exe_path("\\easytier");
let file_path = format!("{}\\{}", easytier_path, file_name); let file_path = format!("{}\\{}", easytier_path, file_name);
println!("download easytier to {}", file_path); // println!("download easytier to {}", file_path);
let easytier_dir = path::Path::new(&easytier_path); let easytier_dir = path::Path::new(&easytier_path);
if !easytier_dir.exists() { if !easytier_dir.exists() {
@@ -354,11 +355,20 @@ async fn download_easytier_zip(download_url: String, file_name: String) {
Err(why) => panic!("couldn't create {}", why), Err(why) => panic!("couldn't create {}", why),
Ok(file) => file, Ok(file) => file,
}; };
let context_size: u64 = response.content_length().unwrap();
let content = response.bytes().await.expect("error to bytes easytier"); while let Some(item) = response.chunk().await.unwrap() {
println!("下载完成,开始写入"); match file.write_all(&item) {
file.write_all(&content).expect("error to write easytier"); Ok(_) => {
println!("写入完成"); 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); unzip(path);
let cache_dir_path = path::Path::new(&cache_dir_path); let cache_dir_path = path::Path::new(&cache_dir_path);
+2 -2
View File
@@ -1,7 +1,7 @@
{ {
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "easytier-game", "productName": "easytier-game",
"version": "1.4.0", "version": "1.4.4",
"identifier": "com.tauri.easytier-game", "identifier": "com.tauri.easytier-game",
"build": { "build": {
@@ -12,7 +12,7 @@
"app": { "app": {
"windows": [ "windows": [
{ {
"title": "easytier-game 1.4.0", "title": "easytier-game 1.4.4",
"label": "main", "label": "main",
"minWidth": 340, "minWidth": 340,
"width": 340, "width": 340,
+13 -6
View File
@@ -15,8 +15,8 @@ const store = defineStore("main", {
disableIpv6: false, // 是否禁用IPv6 disableIpv6: false, // 是否禁用IPv6
port: "11010", // 监听端口号 port: "11010", // 监听端口号
enableCustomListener: true, // 是否自定义监听 enableCustomListener: true, // 是否自定义监听
customListenerV6Data: "udp://[::]:11010", //自定义ipv6监听 enableCustomListenerV6: true, // 是否自定义IPV6监听
enableCustomListenerV6: true, // 是否自定义监听 customListenerV6Data: "udp://[::]:11010", //自定义ipv6监
customListenerData: "tcp://0.0.0.0:11010\nudp://0.0.0.0:11010\ntcp://[::]:11010", // 自定义监听地址 customListenerData: "tcp://0.0.0.0:11010\nudp://0.0.0.0:11010\ntcp://[::]:11010", // 自定义监听地址
disbleListenner: false, // 是否禁用监听 disbleListenner: false, // 是否禁用监听
disableEncryption: false, // 是否禁用加密 disableEncryption: false, // 是否禁用加密
@@ -41,6 +41,7 @@ const store = defineStore("main", {
compression: "none", //加密算法 compression: "none", //加密算法
enableKcpProxy: true, //启用kcp代理 默认开启 enableKcpProxy: true, //启用kcp代理 默认开启
disableKcpInput: false, //禁用kcp输入 disableKcpInput: false, //禁用kcp输入
bindDeviceEnable: false, //是否绑定设备
}, },
serverConfig: { serverConfig: {
enableWhiteList: true, // 是否启用白名单 enableWhiteList: true, // 是否启用白名单
@@ -51,7 +52,8 @@ const store = defineStore("main", {
port: "11010" // 服务器端口 port: "11010" // 服务器端口
}, },
cidrEnable: 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 theme: false, //主题 false light true dark
configStartEnable: false, //使用配置文件启动 configStartEnable: false, //使用配置文件启动
configPath: "", //配置文件路径 configPath: "", //配置文件路径
@@ -67,8 +69,9 @@ const store = defineStore("main", {
winipBcPid: 0, winipBcPid: 0,
winipBcStart: false, 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: { persist: {
@@ -101,7 +104,7 @@ const store = defineStore("main", {
"config.enableNetCardMetric", "config.enableNetCardMetric",
"config.netCardMetricValue", "config.netCardMetricValue",
"config.port", "config.port",
"config.disbleListenner", "config.disbleListenner",
"config.enableCustomListener", "config.enableCustomListener",
"config.customListenerData", "config.customListenerData",
@@ -116,6 +119,8 @@ const store = defineStore("main", {
"config.enableKcpProxy", "config.enableKcpProxy",
"config.disableKcpInput", "config.disableKcpInput",
"config.bindDeviceEnable",
"serverConfig.autoStart", "serverConfig.autoStart",
// 'serverConfig.enableListener', // 'serverConfig.enableListener',
"serverConfig.enableWhiteList", "serverConfig.enableWhiteList",
@@ -124,6 +129,7 @@ const store = defineStore("main", {
"serverConfig.port", "serverConfig.port",
"cidrEnable", "cidrEnable",
"proxyForwardBySystem",
"basePeers", "basePeers",
"theme", "theme",
"configStartEnable", "configStartEnable",
@@ -136,7 +142,8 @@ const store = defineStore("main", {
"delayInjectDll", "delayInjectDll",
"forceBindInput", "forceBindInput",
"forceBindFile", "forceBindFile",
"latestTagName",
"gameList" "gameList"
] ]
// // 除了这些,其他都要存下来 // // 除了这些,其他都要存下来