diff --git a/README.md b/README.md index 6c73d46..e40e518 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ Releases: [https://github.com/EasyTier/EasytierGame/releases](https://github.c ![game-step9](/assets/game-step9.png) +- 1.1.8 新增了 生成 easytier/config.json 的功能 会将一部分配置写入到 config.json 文件中,方便用户自定义配置,你可以在高级设置里启用和关闭这个功能(默认关闭) +**需要注意的是,如果config.json存在,每次启动easytierGame默认按照config.json的配置为准** +**你可以查看 config_template.json 里的注释进行配置** +![game-step10](/assets/game-step10.png) + ## 特性 - 基于easytier组网工具开发,界面清晰简单 diff --git a/assets/game-step10.png b/assets/game-step10.png new file mode 100644 index 0000000..348931e Binary files /dev/null and b/assets/game-step10.png differ diff --git a/composables/configJson.ts b/composables/configJson.ts new file mode 100644 index 0000000..06d9349 --- /dev/null +++ b/composables/configJson.ts @@ -0,0 +1,16 @@ +import { BaseDirectory, writeTextFile } from "@tauri-apps/plugin-fs"; +import useMainStore from "@/stores/index"; +import { ElMessage } from "element-plus"; +export const updateConfigJson = async () => { + + const mainStore = useMainStore(); + const path = import.meta.env.VITE_CONFIG_FILE_NAME; + try { + const { proxyNetworks, autoStart, relayAllPeerrpc, coonectAfterStart, multiThread, enablExitNode, useSmoltcp, saveErrorLog, logLevel, ...otherConfig } = + mainStore.config; + await writeTextFile(path, JSON.stringify(otherConfig, null, 4), { baseDir: BaseDirectory.Resource }); + } catch (err) { + console.log(err); + ElMessage.error(`更新config.json失败`); + } +} diff --git a/composables/windows.ts b/composables/windows.ts index 507be60..0d0b424 100644 --- a/composables/windows.ts +++ b/composables/windows.ts @@ -1,38 +1,42 @@ import { type UnlistenFn } from "@tauri-apps/api/event"; -import { getCurrentWindow, PhysicalPosition, type WindowOptions, Window } from "@tauri-apps/api/window"; +import { getCurrentWindow, PhysicalPosition, type WindowOptions, Window, currentMonitor } from "@tauri-apps/api/window"; import { WebviewWindow } from "@tauri-apps/api/webviewWindow"; -import type { WebviewLabel, WebviewOptions, } from "@tauri-apps/api/webview"; +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}); + let defaultOpts: {[key:string]: any, parent: Window | undefined} = { + 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 monitor = await currentMonitor(); + // console.log(monitor) + const factor = await appWindow.scaleFactor(); + const appPosition = await appWindow.outerPosition(); + // console.log((appPosition.x + appSize.width) / 1.25); + const logicalPosition = new PhysicalPosition(appPosition.x + appSize.width, appPosition.y).toLogical(factor); + defaultOpts.parent = appWindow; + // console.log(logicalPosition); + defaultOpts.x = logicalPosition.x; + defaultOpts.y = logicalPosition.y; + } + dialog = new WebviewWindow(label, { ...defaultOpts, ...options }); unlistenLogCreated = await dialog.once("tauri://webview-created", async () => { if (dialog) { afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow)); diff --git a/env/.env.dev b/env/.env.dev index e4d5eba..719cd46 100644 --- a/env/.env.dev +++ b/env/.env.dev @@ -1,3 +1,4 @@ VITE_CONFIG_PATH=easytier/config/ +VITE_CONFIG_FILE_NAME=easytier/config.json VITE_LOG_PATH=easytier/logs/ VITE_AUTO_START_SERVICE_NAME=easytierGameAutoStart \ No newline at end of file diff --git a/env/.env.prod b/env/.env.prod index e4d5eba..719cd46 100644 --- a/env/.env.prod +++ b/env/.env.prod @@ -1,3 +1,4 @@ VITE_CONFIG_PATH=easytier/config/ +VITE_CONFIG_FILE_NAME=easytier/config.json VITE_LOG_PATH=easytier/logs/ VITE_AUTO_START_SERVICE_NAME=easytierGameAutoStart \ No newline at end of file diff --git a/package.json b/package.json index c85cfb9..0e19b27 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.7", + "version": "1.1.8", "scripts": { "dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0", "build": "nuxt generate --dotenv env/.env.prod" diff --git a/pages/advance.vue b/pages/advance.vue index 1a39ec1..5f05d40 100644 --- a/pages/advance.vue +++ b/pages/advance.vue @@ -3,30 +3,47 @@
不使用IPv6
自定义网卡名 - +
不监听任何端口,只连接到对等节点
-
软件启动后,自动"启动联机"(搭配开机自启,无感联机)
输出日志到本地
+ class="ml-[5px]" + > + :value="item" + >
+ size="small" + > 打开日志目录
+
软件启动后,自动"启动联机"(搭配开机自启,无感联机)
+
+ 自动生成界面配置文件easytier/config.json + + 打开config.json目录 + +
+
允许此节点成为出口节点
禁用对等节点通信的加密,默认为false,必须与对等节点相同
@@ -47,6 +64,7 @@ import { resourceDir as getResourceDir, join } from "@tauri-apps/api/path"; import { Command } from "@tauri-apps/plugin-shell"; import { exists, mkdir, BaseDirectory } from "@tauri-apps/plugin-fs"; + import { ElMessage } from "element-plus"; const mainStore = useMainStore(); const appWindow = getCurrentWindow(); @@ -63,8 +81,21 @@ } await Command.create("explorer", [logDirPath]).execute(); }; - mainStore.$subscribe((...a) => { + const openConfigJsonDir = async () => { + const resourceDir = await getResourceDir(); + const easytierDir = await join(resourceDir, "easytier/"); + const isExists = await exists("easytier/", { baseDir: BaseDirectory.Resource }); + if (isExists) { + await Command.create("explorer", [easytierDir]).execute(); + } else { + ElMessage.error("config.json的目录不存在"); + } + }; + mainStore.$subscribe(async (...a) => { // console.log("subscribe", a); - appWindow.emitTo("main", "config", { config: { ...mainStore.config } }); + await appWindow.emitTo("main", "config", { config: { ...mainStore.config }, createConfigInEasytier: mainStore.createConfigInEasytier }); + // if(mainStore.createConfigInEasytier) { + // updateConfigJson(); + // } }); diff --git a/pages/index.vue b/pages/index.vue index 6d997f1..dd90f2d 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -9,179 +9,179 @@ :element-loading-spinner="''" element-loading-text="-------已经启用配置文件,界面配置不再生效-------" --> - -