From 1a5d2cc8fc166b6c3153694f2fde25424e5a35ae Mon Sep 17 00:00:00 2001 From: leizi97 Date: Mon, 4 Nov 2024 22:38:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=98=E7=9B=98=E5=9B=BE=E6=A0=87=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=B8=BB=E9=A2=98=E5=88=87=E6=8D=A2=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E8=B0=83=E6=95=B4=E6=88=90=E5=91=98=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=BB=B6=E8=BF=9F=E8=87=B3=E5=89=8D=E6=96=B9=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0nat=E7=B1=BB=E5=9E=8B=E6=9F=A5=E7=9C=8B=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=AE=9A=E4=B9=89=E7=BD=91=E5=8D=A1?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E4=BF=9D=E5=AD=98=E4=BF=A1=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.vue | 7 +++++-- composables/theme.ts | 6 +++--- composables/tray.ts | 33 +++++++++++++++++++++++++++------ package.json | 2 +- pages/member.vue | 21 ++++++++++----------- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 4 ++-- stores/index.ts | 6 +++++- 9 files changed, 55 insertions(+), 28 deletions(-) diff --git a/app.vue b/app.vue index b8ce2cd..8dc6aff 100644 --- a/app.vue +++ b/app.vue @@ -4,6 +4,9 @@ diff --git a/composables/theme.ts b/composables/theme.ts index f2935b0..f9b16f6 100644 --- a/composables/theme.ts +++ b/composables/theme.ts @@ -1,6 +1,6 @@ import { useDark, useToggle, usePreferredDark } from "@vueuse/core"; import { isFunction } from "lodash-es"; -const isDark = usePreferredDark(); +// const isDark = usePreferredDark(); const darkConfig = useDark({ selector: "html", attribute: "class", @@ -8,9 +8,9 @@ const darkConfig = useDark({ valueLight: "", }); const toggleDark = useToggle(darkConfig); -export const initTheme = () => { +export const initTheme = (isDark: boolean) => { if (isDark && isFunction(toggleDark)) { - toggleDark(isDark.value); + toggleDark(isDark); } }; diff --git a/composables/tray.ts b/composables/tray.ts index 14a1d45..3aed2ca 100644 --- a/composables/tray.ts +++ b/composables/tray.ts @@ -2,6 +2,8 @@ import { Menu, MenuItem, PredefinedMenuItem } from "@tauri-apps/api/menu"; import { TrayIcon } from "@tauri-apps/api/tray"; import { getCurrentWindow } from "@tauri-apps/api/window"; import pkg from "@/package.json"; +import { setTheme } from "~/composables/theme"; +import useMainStore from "@/stores/index"; const DEFAULT_TRAY_NAME = "main"; @@ -20,8 +22,8 @@ export async function useTray(init: boolean = false, beforExit: Function) { tray = await TrayIcon.getById(DEFAULT_TRAY_NAME); if (!tray) { tray = await TrayIcon.new({ - tooltip: `EasyTier\n${pkg.version}`, - title: `EasyTier\n${pkg.version}`, + tooltip: `EasyTierGame\n${pkg.version}`, + title: `EasyTierGame\n${pkg.version}`, id: DEFAULT_TRAY_NAME, menu: await Menu.new({ id: "main", @@ -38,7 +40,7 @@ export async function useTray(init: boolean = false, beforExit: Function) { } if (init) { - tray.setTooltip(`EasyTier\n${pkg.version}`); + tray.setTooltip(`EasyTierGame\n${pkg.version}`); tray.setMenuOnLeftClick(false); tray.setMenu( await Menu.new({ @@ -52,7 +54,12 @@ export async function useTray(init: boolean = false, beforExit: Function) { } export async function generateMenuItem(beforExit: Function) { - return [await MenuItemShow("显示 / 隐藏"), await PredefinedMenuItem.new({ item: "Separator" }), await MenuItemExit("退出", beforExit)]; + return [ + await MenuItemShow("显示 / 隐藏"), + await MenuItemTheme(), + await PredefinedMenuItem.new({ item: "Separator" }), + await MenuItemExit("退出", beforExit), + ]; } export async function MenuItemExit(text: string, beforExit: Function) { @@ -78,6 +85,20 @@ export async function MenuItemShow(text: string) { }); } +export async function MenuItemTheme() { + return await MenuItem.new({ + id: "theme", + text: "主题切换", + action: async () => { + const mainStore = useMainStore(); + mainStore.theme = !mainStore.theme; + // const appWindow = getCurrentWindow(); + // appWindow.emitTo("main", "config", { theme: mainStore.theme }); + await setTheme(mainStore.theme); + }, + }); +} + // export async function setTrayMenu(items: (MenuItem | PredefinedMenuItem)[] | undefined = undefined) { // // const tray = await useTray() // const tray = await TrayIcon.getById(DEFAULT_TRAY_NAME) @@ -98,8 +119,8 @@ export async function setTrayRunState(tray: TrayIcon | null, isRunning: boolean export async function setTrayTooltip(tray: TrayIcon | null, tooltip?: string | null) { if (!tray) return; if (tooltip) { - await tray.setTooltip(`EasyTier\n${pkg.version}\n${tooltip}`); + await tray.setTooltip(`EasyTierGame\n${pkg.version}\n${tooltip}`); } else { - await tray.setTooltip(`EasyTier\n${pkg.version}`); + await tray.setTooltip(`EasyTierGame\n${pkg.version}`); } } diff --git a/package.json b/package.json index 69428c7..062c82a 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.1.2", + "version": "1.1.3", "scripts": { "dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0", "build": "nuxt generate --dotenv env/.env.prod" diff --git a/pages/member.vue b/pages/member.vue index 70307b5..0c3b370 100644 --- a/pages/member.vue +++ b/pages/member.vue @@ -5,13 +5,11 @@ + v-else> + :key="prop[0]"> @@ -35,22 +32,23 @@ import { reactive, onMounted, onBeforeUnmount } from "vue"; import { parsePeerInfo } from "@/utils"; const data = reactive<{ member: any[] }>({ - member: [] + member: [], }); const showTableHeader = [ - ["ipv4", "虚拟网IP"], ["hostname", "主机名"], - ["cost", "路由"], ["lat_ms", "延迟/ms"], + ["ipv4", "虚拟网IP"], + ["cost", "路由"], ["loss_rate", "丢包率"], - ["version", "版本"] + ["nat_type", "NAT类型"], + ["version", "版本"], ]; const listenOutput = async () => { const member = await invoke("get_members_by_cli"); const peerInfo = parsePeerInfo(member as string); - peerInfo.forEach(value => { + peerInfo.forEach((value) => { if (value.cost === "Local") { value.cost = "本机"; } @@ -58,6 +56,7 @@ value.ipv4 = value.ipv4.split("/")[0]; } }); + console.log(peerInfo); data.member = peerInfo; }; diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 22b78bd..7a89339 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1109,7 +1109,7 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" [[package]] name = "easytier-game" -version = "1.1.2" +version = "1.1.3" dependencies = [ "log", "planif", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 65b1f1b..2f25b53 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "easytier-game" -version = "1.1.2" +version = "1.1.3" 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 d147cbb..0f530fc 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.1.2", + "version": "1.1.3", "identifier": "com.tauri.easytier-game", "build": { @@ -13,7 +13,7 @@ "app": { "windows": [ { - "title": "easytier-game 1.1.2", + "title": "easytier-game 1.1.3", "width": 335, "height": 305, "resizable": false, diff --git a/stores/index.ts b/stores/index.ts index f8f97ec..f4ca36d 100644 --- a/stores/index.ts +++ b/stores/index.ts @@ -29,6 +29,7 @@ export default defineStore("main", { devName: false, //自定义网卡名 devNameValue: "", //自定义网卡名 }, + theme: false, //主题 false light true dark configStartEnable: false, //使用配置文件启动 configPath: "", //配置文件路径 cidrEnable: false, @@ -39,6 +40,7 @@ export default defineStore("main", { paths: [ "basePeers", "cidrEnable", + "theme", "config.proxyNetworks", "config.serverUrl", "config.networkName", @@ -60,7 +62,9 @@ export default defineStore("main", { "config.hostname", "config.dhcp", "config.saveErrorLog", - "config.logLevel" + "config.logLevel", + "config.devName", + "config.devNameValue", ], }, });