From 4e3f1cbd892718ca3823442139bcdec630f4073d Mon Sep 17 00:00:00 2001 From: leizi97 Date: Thu, 21 Nov 2024 23:37:24 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=89=98=E7=9B=98=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=81=94=E6=9C=BA=E5=92=8C=E6=96=AD=E5=BC=80=E7=9A=84?= =?UTF-8?q?=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composables/tray.ts | 20 ++++++++++++++++---- package.json | 2 +- pages/index.vue | 3 +++ src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 4 ++-- 6 files changed, 24 insertions(+), 9 deletions(-) diff --git a/composables/tray.ts b/composables/tray.ts index 3128d32..1c04d2d 100644 --- a/composables/tray.ts +++ b/composables/tray.ts @@ -17,7 +17,7 @@ async function toggleVisibility() { } } -export async function useTray(init: boolean = false, beforExit: Function) { +export async function useTray(init: boolean = false, beforExit: Function, handleConnection: Function) { let tray; try { tray = await TrayIcon.getById(DEFAULT_TRAY_NAME); @@ -28,7 +28,7 @@ export async function useTray(init: boolean = false, beforExit: Function) { id: DEFAULT_TRAY_NAME, menu: await Menu.new({ id: "main", - items: await generateMenuItem(beforExit), + items: await generateMenuItem(beforExit, handleConnection), }), action: async (e) => { toggleVisibility(); @@ -46,7 +46,7 @@ export async function useTray(init: boolean = false, beforExit: Function) { tray.setMenu( await Menu.new({ id: "main", - items: await generateMenuItem(beforExit), + items: await generateMenuItem(beforExit, handleConnection), }) ); } @@ -54,9 +54,10 @@ export async function useTray(init: boolean = false, beforExit: Function) { return tray; } -export async function generateMenuItem(beforExit: Function) { +export async function generateMenuItem(beforExit: Function, handleConnection:Function) { return [ await MenuItemShow("显示 / 隐藏"), + await MenuItemExchangeConnection("联机 / 断开", handleConnection), await MenuItemTheme(), await PredefinedMenuItem.new({ item: "Separator" }), await MenuItemExit("退出", beforExit), @@ -86,6 +87,17 @@ export async function MenuItemShow(text: string) { }); } +export async function MenuItemExchangeConnection(text: string, handleConnection:Function) { + const menutItem = await MenuItem.new({ + id: "exchangeConnection", + text, + action: async () => { + const isStart = await handleConnection(); + }, + }); + return menutItem; +} + export async function MenuItemTheme() { return await MenuItem.new({ id: "theme", diff --git a/package.json b/package.json index af7877e..0281f2a 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "private": true, "author": "leizi97", "description": "A simple network initiator based on Easytier", - "version": "1.2.3", + "version": "1.2.4", "scripts": { "dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0", "build": "nuxt generate --dotenv env/.env.prod" diff --git a/pages/index.vue b/pages/index.vue index adb8ee9..c0828b1 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -508,6 +508,9 @@ is_close = true; await invoke("stop_command", { child_id: listenObj.thread_id || 0 }); await invoke("stop_command", { child_id: data.winipBcPid || 0 }); + }, async () => { + await handleConnection(); + return data.isStart }); const mainStore = useMainStore(); diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index d3530af..e607235 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1176,7 +1176,7 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" [[package]] name = "easytier-game" -version = "1.2.3" +version = "1.2.4" dependencies = [ "log", "planif", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 8cf88ed..b2e0d20 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "easytier-game" -version = "1.2.3" +version = "1.2.4" homepage = "https://github.com/EasyTier/EasyTier" repository = "https://github.com/EasyTier/EasytierGame" description = "A simple network initiator based on Easytier" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 37ff0e7..483afb9 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "productName": "easytier-game", - "version": "1.2.3", + "version": "1.2.4", "identifier": "com.tauri.easytier-game", "build": { @@ -13,7 +13,7 @@ "app": { "windows": [ { - "title": "easytier-game 1.2.3", + "title": "easytier-game 1.2.4", "label": "main", "minWidth": 340, "width": 340,