From a4d6fe6e9563a02906938f537f88ec71a436cc93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=91=E5=85=88=E6=A3=AE?= Date: Wed, 23 Oct 2024 18:37:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=81=E8=A3=85=E4=BA=8C=E7=BA=A7=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E6=96=B9=E6=B3=95=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=AD=90?= =?UTF-8?q?=E7=BD=91=E4=BB=A3=E7=90=86=E5=92=8C=E9=AB=98=E7=BA=A7=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=8C=89=E9=92=AE=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=AD=90?= =?UTF-8?q?=E7=BD=91=E4=BB=A3=E7=90=86=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composables/windows.ts | 53 ++++++++++++ pages/cidr.vue | 6 ++ pages/index.vue | 177 +++++++++++++++++------------------------ pages/log.vue | 2 +- pages/member.vue | 4 +- src-tauri/Cargo.lock | 80 ++++++++++++++----- src-tauri/Cargo.toml | 5 +- 7 files changed, 200 insertions(+), 127 deletions(-) create mode 100644 composables/windows.ts create mode 100644 pages/cidr.vue diff --git a/composables/windows.ts b/composables/windows.ts new file mode 100644 index 0000000..507be60 --- /dev/null +++ b/composables/windows.ts @@ -0,0 +1,53 @@ +import { type UnlistenFn } from "@tauri-apps/api/event"; +import { getCurrentWindow, PhysicalPosition, type WindowOptions, Window } from "@tauri-apps/api/window"; +import { WebviewWindow } from "@tauri-apps/api/webviewWindow"; +import type { WebviewLabel, WebviewOptions, } from "@tauri-apps/api/webview"; +export default async ( + label: WebviewLabel, + options?: Omit & WindowOptions, + afterCreatedFunc?: (webviewWindow: WebviewWindow, appWindow: Window) => void | null, + beforeCloseFunc?: () => void | null +) => { + let defaultOpts = { + parent: undefined, + closable: true, + resizable: true, + decorations: true, + maximizable: false, + minimizable: false, + x: 0, + y: 0 + }; + 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 as any; + defaultOpts.x = logicalPosition.x; + defaultOpts.y = logicalPosition.y; + } + let unListenlogClose: UnlistenFn | null = null; + let unlistenLogCreated: UnlistenFn | null = null; + let dialog = await WebviewWindow.getByLabel(label); + if (!dialog) { + dialog = new WebviewWindow(label, {...defaultOpts, ...options}); + unlistenLogCreated = await dialog.once("tauri://webview-created", async () => { + if (dialog) { + afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow)); + await dialog.show(); + } + }); + unListenlogClose = await dialog.onCloseRequested(async () => { + beforeCloseFunc && (await beforeCloseFunc()); + unListenlogClose && (await unListenlogClose()); + }); + } else { + const visible = await dialog.isVisible(); + if (visible) { + await dialog.close(); + unlistenLogCreated && (await (unlistenLogCreated as Function)()); + } + } +}; diff --git a/pages/cidr.vue b/pages/cidr.vue new file mode 100644 index 0000000..14a60e8 --- /dev/null +++ b/pages/cidr.vue @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/pages/index.vue b/pages/index.vue index 808c413..9b5329a 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -16,7 +16,7 @@ effect="dark" :type="data.isSuccessGetIp ? 'success' : 'info'" > - {{ data.isSuccessGetIp ? "联机成功" : "联机中" }} + {{ data.isSuccessGetIp ? "联机成功" : data.isStart && !data.isSuccessGetIp ? "联机中" : "未联机" }} -
+
+ +
@@ -211,14 +213,14 @@ v-model="config.disbleP2p" size="small" > - 禁用p2p + 强制中转 - 禁用ipv6 - + --> 开机自启 - 禁用端口监听 - + --> +
+ 子网代理 + 高级配置 +
diff --git a/pages/log.vue b/pages/log.vue index 02b482d..cd39490 100644 --- a/pages/log.vue +++ b/pages/log.vue @@ -1,7 +1,7 @@