From aab8175ce392800f37e0a5c6f0995aeb36402e4b Mon Sep 17 00:00:00 2001 From: lurenjia1213 <30799041+lurenjia1213@users.noreply.github.com> Date: Sun, 15 Jun 2025 21:49:46 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=85=81=E8=AE=B8=E5=9C=A8=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=94=B5=E6=B1=A0=E6=97=B6=E8=87=AA=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/lib.rs | 49 +++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 2a0e2b5..2c0813d 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -322,7 +322,11 @@ async fn get_route_by_cli() -> String { } #[tauri::command(rename_all = "snake_case")] -async fn download_easytier_zip(app_handle: tauri::AppHandle ,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); @@ -355,14 +359,18 @@ async fn download_easytier_zip(app_handle: tauri::AppHandle ,download_url: Strin 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) => { + 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 + app_handle + .emit("download_core_progress_error", why.to_string()) + .expect("error to emit download_core_progress_error"); + return; } }; - } println!("下载完成"); unzip(path); @@ -661,11 +669,11 @@ fn ensure_task_folder_and_cleanup( 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); @@ -738,23 +746,23 @@ fn autostart(enabled: bool) -> std::result::Result<(), Box std::result::Result<(), Box std::result::Result<(), Box std::result::Result<(), Box Date: Fri, 6 Jun 2025 18:09:08 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E8=81=94=E6=9C=BA=E7=9A=84=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index.vue | 88 ++++++++++++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 33 deletions(-) diff --git a/pages/index.vue b/pages/index.vue index 7cdf8d6..a432925 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -272,21 +272,6 @@ {{ !data.isStart ? "启动联机" : "停止联机" }} @@ -1423,7 +1429,7 @@ }); } } - if(mainStore.config.privateMode) { + if (mainStore.config.privateMode) { args.push("--private-mode", "true"); } return args; @@ -1688,6 +1694,21 @@ } ); } + + if (command === "reconnect") { + if (data.isStart) { + ElMessage.info({ + message: "正在重新联机...", + duration: 2200 + }); + await handleConnection(); + setTimeout(() => { + handleConnection(); + }, 2000); + }else { + handleConnection(); + } + } }; const handleDeleteAdminConfig = async () => { @@ -1926,24 +1947,25 @@ }; 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(); + 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(); + } ); }; From 26f3f6fb3668154a89608203a4bc3d72ec4fb754 Mon Sep 17 00:00:00 2001 From: heixiansen Date: Fri, 6 Jun 2025 18:13:11 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=89=98=E7=9B=98=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E4=B9=9F=E5=A2=9E=E5=8A=A0=E9=87=8D=E6=96=B0=E8=81=94=E6=9C=BA?= =?UTF-8?q?=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composables/tray.ts | 19 +++++++++++++++---- pages/index.vue | 13 ++++++++++--- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/composables/tray.ts b/composables/tray.ts index 5e2ab16..95b5f82 100644 --- a/composables/tray.ts +++ b/composables/tray.ts @@ -22,7 +22,7 @@ async function toggleVisibility() { } } -export async function useTray(init: boolean = false, beforExit: Function, handleConnection: Function) { +export async function useTray(init: boolean = false, beforExit: Function, handleConnection: Function, handleReconnect: Function) { let tray; try { tray = await TrayIcon.getById(DEFAULT_TRAY_NAME); @@ -31,7 +31,7 @@ export async function useTray(init: boolean = false, beforExit: Function, handle tooltip: `EasyTierGame\n${pkg.version}`, title: `EasyTierGame\n${pkg.version}`, id: DEFAULT_TRAY_NAME, - menu: await Menu.new({ id: "main", items: await generateMenuItem(beforExit, handleConnection) }), + menu: await Menu.new({ id: "main", items: await generateMenuItem(beforExit, handleConnection, handleReconnect) }), action: async e => { toggleVisibility(); } @@ -45,16 +45,17 @@ 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, handleReconnect) })); } return tray; } -export async function generateMenuItem(beforExit: Function, handleConnection: Function) { +export async function generateMenuItem(beforExit: Function, handleConnection: Function, handleReconnect: Function) { return [ await MenuItemShow("显示 / 隐藏"), await MenuItemExchangeConnection("联机 / 断开", handleConnection), + await MenuItemReconnect("重新联机", handleReconnect), await MenuItemTheme(), await PredefinedMenuItem.new({ item: "Separator" }), await MenuItemPublicPeers(), @@ -63,6 +64,16 @@ export async function generateMenuItem(beforExit: Function, handleConnection: Fu ]; } +export async function MenuItemReconnect(text: string, handleReconnect: Function) { + return await MenuItem.new({ + id: "reconnect", + text, + action: async () => { + await handleReconnect(); + } + }); +} + export async function MenuItemExit(text: string, beforExit: Function) { return await MenuItem.new({ id: "quit", diff --git a/pages/index.vue b/pages/index.vue index a432925..1909777 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -752,6 +752,9 @@ async () => { await handleConnection(); return data.isStart; + }, + async () => { + await handleReconnect(); } ); @@ -1696,7 +1699,12 @@ } if (command === "reconnect") { - if (data.isStart) { + handleReconnect(); + } + }; + + const handleReconnect = async () => { + if (data.isStart) { ElMessage.info({ message: "正在重新联机...", duration: 2200 @@ -1708,8 +1716,7 @@ }else { handleConnection(); } - } - }; + } const handleDeleteAdminConfig = async () => { const path = configAdminData.fileName; From 60faa01769ab3713b6f71a49c3f277b0658dc390 Mon Sep 17 00:00:00 2001 From: heixiansen Date: Mon, 9 Jun 2025 15:49:43 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E7=9B=91=E5=90=AC=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E7=BC=A9=E6=94=BE=E6=AF=94=E4=BE=8B=EF=BC=8C=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=8C=89=E7=85=A7=E7=BC=A9=E6=94=BE=E8=AE=A1=E7=AE=97=E5=B9=B6?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=80=E6=AC=A1=E7=AA=97=E5=8F=A3=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composables/windows.ts | 13 ++++++---- pages/index.vue | 39 +++++++++++++++++++---------- src-tauri/capabilities/default.json | 1 + 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/composables/windows.ts b/composables/windows.ts index 106cd91..a4f5501 100644 --- a/composables/windows.ts +++ b/composables/windows.ts @@ -1,5 +1,5 @@ import { type UnlistenFn } from "@tauri-apps/api/event"; -import { getCurrentWindow, PhysicalPosition, type WindowOptions, Window, currentMonitor } from "@tauri-apps/api/window"; +import { getCurrentWindow, PhysicalPosition, type WindowOptions, Window, currentMonitor, PhysicalSize } from "@tauri-apps/api/window"; import { WebviewWindow } from "@tauri-apps/api/webviewWindow"; import type { WebviewLabel, WebviewOptions } from "@tauri-apps/api/webview"; import useMainStore from "@/stores/index"; @@ -44,18 +44,21 @@ export default async ( defaultOpts.parent = appWindow; // console.error(logicalPosition); if (defaultOpts.x == 0 && defaultOpts.y == 0) { - const appSize = await appWindow.outerSize(); + const logicalAppSize = { + width: 340, + height: 305 + } const factor = await appWindow.scaleFactor(); const appPosition = await appWindow.outerPosition(); - const logicalPosition = new PhysicalPosition(appPosition.x + appSize.width, appPosition.y).toLogical(factor); + const logicalPosition = new PhysicalPosition(appPosition.x + Math.ceil((logicalAppSize.width + 5) * factor), appPosition.y).toLogical(factor); defaultOpts.x = logicalPosition.x; defaultOpts.y = logicalPosition.y; } } dialog = new WebviewWindow(label, { ...defaultOpts, ...options }); await dealCloseListener(dialog, label, beforeCloseFunc); - afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow)); await dialog.show(); + afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow)); } else { const visible = await dialog.isVisible(); if (visible) { @@ -63,8 +66,8 @@ export default async ( } else { const appWindow = getCurrentWindow(); await dealCloseListener(dialog, label, beforeCloseFunc); - afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow)); await dialog.show(); + afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow)); } } }; diff --git a/pages/index.vue b/pages/index.vue index 1909777..3476b01 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -726,7 +726,7 @@ import { initStartWinIpBroadcast } from "~/composables/netcard"; import useMainStore from "@/stores/index"; import { ElMessage, ElMessageBox, ElTooltip } from "element-plus"; - import { getCurrentWindow, type Window } from "@tauri-apps/api/window"; + import { getCurrentWindow, PhysicalSize, type Window } from "@tauri-apps/api/window"; import { getAllWebviewWindows, WebviewWindow } from "@tauri-apps/api/webviewWindow"; import etWindows, { dataSubscribe } from "@/composables/windows"; import { resourceDir as getResourceDir, join } from "@tauri-apps/api/path"; @@ -1233,6 +1233,18 @@ await appWindow.show(); await appWindow.setFocus(); } + const appWindow = getCurrentWindow(); + const logicalAppSize = { + width: 340, + height: 305 + } + const scaleFactor = await appWindow.scaleFactor(); + const size = new PhysicalSize(Math.ceil(logicalAppSize.width * scaleFactor), Math.ceil(logicalAppSize.height * scaleFactor)); + appWindow.setSize(size); + appWindow.onScaleChanged(({ payload: { scaleFactor } }) => { + console.log("scaleFactor", scaleFactor); + appWindow.setSize(new PhysicalSize(Math.ceil(logicalAppSize.width * scaleFactor), Math.ceil(logicalAppSize.height * scaleFactor))); + }); }; let logsTimer: NodeJS.Timeout | null = null; @@ -1705,18 +1717,18 @@ const handleReconnect = async () => { if (data.isStart) { - ElMessage.info({ - message: "正在重新联机...", - duration: 2200 - }); - await handleConnection(); - setTimeout(() => { - handleConnection(); - }, 2000); - }else { + ElMessage.info({ + message: "正在重新联机...", + duration: 2200 + }); + await handleConnection(); + setTimeout(() => { handleConnection(); - } - } + }, 2000); + } else { + handleConnection(); + } + }; const handleDeleteAdminConfig = async () => { const path = configAdminData.fileName; @@ -1957,7 +1969,7 @@ await etWindows( "storage-listener", { - title: "自建服务器", + title: "存储监听", minWidth: 0, minHeight: 0, width: 0, @@ -1968,6 +1980,7 @@ transparent: true, hiddenTitle: true, alwaysOnBottom: true, + visible: false, url: "#/storage-listener" }, dialog => { diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 52f92bb..5f96aaf 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -26,6 +26,7 @@ "core:tray:allow-get-by-id", "core:tray:allow-set-icon", "core:tray:allow-new", + "core:window:allow-set-size", { "identifier": "shell:allow-spawn", "allow": [ From 84460409ed40f677e7a70fe2ec0e442375da3d3f Mon Sep 17 00:00:00 2001 From: heixiansen Date: Mon, 16 Jun 2025 11:43:54 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=AF=B9=E4=BA=8E=E4=B8=89=E5=B1=82tun?= =?UTF-8?q?=E8=80=8C=E8=A8=80=EF=BC=8Cwinipbroadcast=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E4=BD=9C=E7=94=A8=EF=BC=8C=E5=85=88=E7=A6=81=E7=94=A8=20#15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index.vue | 2 +- pages/tool.vue | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pages/index.vue b/pages/index.vue index 3476b01..615580a 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1255,7 +1255,7 @@ await initGuiJson(); await compatibleInitAutoStart(); // await initAutoStart(); - await initStartWinIpBroadcast(); + // await initStartWinIpBroadcast(); // 对于三层tun而言,winipbroadcast没有作用,先禁用 await compatibleIpv6Listener(); await getCoreVersion(); await listenObj.listenThreadId(); diff --git a/pages/tool.vue b/pages/tool.vue index 7352a4b..89da2fe 100644 --- a/pages/tool.vue +++ b/pages/tool.vue @@ -10,7 +10,7 @@ name="netcard" class="flex h-full flex-col" > -
+
- 方案2 + 方案1 @@ -131,7 +131,7 @@
- 方案3 + 方案2 @@ -502,7 +502,7 @@ onMounted(() => { data.pingIp = mainStore.config.ipv4; - initStartWinIpBroadcast(); + // initStartWinIpBroadcast(); getGuids(); });