Compare commits

...
4 Commits
Author SHA1 Message Date
黑先森 8e6f8d602e readme修改 2024-11-13 16:50:53 +08:00
黑先森 92d25ab907 新增生成config.json界面基础配置的高级选项 2024-11-13 16:42:55 +08:00
黑先森 1c8314c6fa 更新pinia插件的使用 2024-11-12 20:23:45 +08:00
黑先森 b352d49e0b manage package 开发环境和生成环境正常运行
remove defu dayjs xlsx @pinia-plugin-persistedstate/nuxt vue qs @types/qs
add pinia-plugin-persistedstate
update nuxt pinia element-plus(/nuxt)  @vitejs/plugin-vue-jsx
修改nuxt.config.ts配置
2024-11-12 18:26:32 +08:00
23 changed files with 2850 additions and 4177 deletions
+5
View File
@@ -41,6 +41,11 @@ Releases [https://github.com/EasyTier/EasytierGame/releases](https://github.c
![game-step9](/assets/game-step9.png) ![game-step9](/assets/game-step9.png)
- 1.1.8 新增了 生成 easytier/config.json 的功能 会将一部分配置写入到 config.json 文件中,方便用户自定义配置,你可以在高级设置里启用和关闭这个功能(默认关闭)
**需要注意的是,如果config.json存在,每次启动easytierGame默认按照config.json的配置为准**
**解压zip后你可以查看 easytier/config_template.json 里的注释进行配置**
![game-step10](/assets/game-step10.png)
## 特性 ## 特性
- 基于easytier组网工具开发,界面清晰简单 - 基于easytier组网工具开发,界面清晰简单
Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

+16
View File
@@ -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失败`);
}
}
+27 -23
View File
@@ -1,38 +1,42 @@
import { type UnlistenFn } from "@tauri-apps/api/event"; 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 { 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 ( export default async (
label: WebviewLabel, label: WebviewLabel,
options?: Omit<WebviewOptions, "x" | "y" | "width" | "height"> & WindowOptions, options?: Omit<WebviewOptions, "x" | "y" | "width" | "height"> & WindowOptions,
afterCreatedFunc?: (webviewWindow: WebviewWindow, appWindow: Window) => void | null, afterCreatedFunc?: (webviewWindow: WebviewWindow, appWindow: Window) => void | null,
beforeCloseFunc?: () => 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 unListenlogClose: UnlistenFn | null = null;
let unlistenLogCreated: UnlistenFn | null = null; let unlistenLogCreated: UnlistenFn | null = null;
let dialog = await WebviewWindow.getByLabel(label); let dialog = await WebviewWindow.getByLabel(label);
if (!dialog) { 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 () => { unlistenLogCreated = await dialog.once("tauri://webview-created", async () => {
if (dialog) { if (dialog) {
afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow)); afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow));
+1
View File
@@ -1,3 +1,4 @@
VITE_CONFIG_PATH=easytier/config/ VITE_CONFIG_PATH=easytier/config/
VITE_CONFIG_FILE_NAME=easytier/config.json
VITE_LOG_PATH=easytier/logs/ VITE_LOG_PATH=easytier/logs/
VITE_AUTO_START_SERVICE_NAME=easytierGameAutoStart VITE_AUTO_START_SERVICE_NAME=easytierGameAutoStart
+1
View File
@@ -1,3 +1,4 @@
VITE_CONFIG_PATH=easytier/config/ VITE_CONFIG_PATH=easytier/config/
VITE_CONFIG_FILE_NAME=easytier/config.json
VITE_LOG_PATH=easytier/logs/ VITE_LOG_PATH=easytier/logs/
VITE_AUTO_START_SERVICE_NAME=easytierGameAutoStart VITE_AUTO_START_SERVICE_NAME=easytierGameAutoStart
+19 -18
View File
@@ -1,16 +1,7 @@
import { defineNuxtConfig } from "nuxt/config"; import { defineNuxtConfig } from "nuxt/config";
import fs from "fs";
import path from "path"; import path from "path";
import vueJSX from "@vitejs/plugin-vue-jsx"; import vueJSX from "@vitejs/plugin-vue-jsx";
const isDev = process?.argv?.[2] == "_dev" || process?.argv?.[2] == "dev";
const optimizeDepsElementPlusIncludes = ["element-plus/es"];
fs.readdirSync("node_modules/element-plus/es/components").map(dirname => {
fs.access(`node_modules/element-plus/es/components/${dirname}/style/css.mjs`, err => {
if (!err) {
optimizeDepsElementPlusIncludes.push(`element-plus/es/components/${dirname}/style/css`);
}
});
});
export default defineNuxtConfig({ export default defineNuxtConfig({
ssr: false, ssr: false,
@@ -22,8 +13,19 @@ export default defineNuxtConfig({
autoImport: false autoImport: false
}, },
css: ["~/assets/css/main.css", 'element-plus/theme-chalk/dark/css-vars.css'], css: ["~/assets/css/main.css", "element-plus/theme-chalk/dark/css-vars.css"],
modules: ["@element-plus/nuxt", "@pinia/nuxt", "@pinia-plugin-persistedstate/nuxt", "@nuxtjs/tailwindcss"], modules: [
"@element-plus/nuxt",
"@pinia/nuxt",
[
"pinia-plugin-persistedstate/nuxt",
{
key: "__glj_persisted_%id",
storage: "localStorage"
}
],
"@nuxtjs/tailwindcss"
],
alias: { alias: {
"@": path.resolve(__dirname, "./") "@": path.resolve(__dirname, "./")
@@ -44,12 +46,10 @@ export default defineNuxtConfig({
}, },
vite: { vite: {
plugins: [ plugins: [vueJSX({})],
vueJSX({}),
],
envDir: "env", envDir: "env",
optimizeDeps: { optimizeDeps: {
include: [...optimizeDepsElementPlusIncludes] // include: [...optimizeDepsElementPlusIncludes]
}, },
// prevent vite from obscuring rust errors // prevent vite from obscuring rust errors
clearScreen: false, clearScreen: false,
@@ -84,7 +84,7 @@ export default defineNuxtConfig({
app: { app: {
rootId: "__easytier", rootId: "__easytier",
cdnURL: "./", cdnURL: "./",
buildAssetsDir: "__easytier/", buildAssetsDir: "__easytier/",
head: { head: {
meta: [ meta: [
@@ -102,5 +102,6 @@ export default defineNuxtConfig({
// script: [], // script: [],
// noscript: [] // noscript: []
} }
} },
compatibilityDate: "2024-11-12"
}); });
+16 -25
View File
@@ -3,44 +3,35 @@
"private": true, "private": true,
"author": "leizi97", "author": "leizi97",
"description": "A simple network initiator based on Easytier", "description": "A simple network initiator based on Easytier",
"version": "1.1.7", "version": "1.1.8",
"scripts": { "scripts": {
"dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0", "dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0",
"build": "nuxt generate --dotenv env/.env.prod" "build": "nuxt generate --dotenv env/.env.prod"
}, },
"devDependencies": { "devDependencies": {
"@element-plus/icons-vue": "^2.3.1", "@element-plus/icons-vue": "^2.3.1",
"@element-plus/nuxt": "^1.0.9", "@element-plus/nuxt": "^1.1.0",
"@nuxtjs/tailwindcss": "^6.12.0", "@nuxtjs/tailwindcss": "^6.12.0",
"@pinia-plugin-persistedstate/nuxt": "^1.2.0", "@pinia/nuxt": "^0.7.0",
"@pinia/nuxt": "^0.5.1", "@tauri-apps/api": "^2.1.1",
"@tauri-apps/api": "^2.0.2", "@tauri-apps/cli": "^2.1.0",
"@tauri-apps/cli": "^2.0.2", "@tauri-apps/plugin-autostart": "~2",
"@tauri-apps/plugin-cli": "^2.0.0", "@tauri-apps/plugin-cli": "^2.0.0",
"@tauri-apps/plugin-http": "^2.0.0", "@tauri-apps/plugin-clipboard-manager": "^2.0.0",
"@tauri-apps/plugin-fs": "~2",
"@tauri-apps/plugin-http": "^2.0.1",
"@tauri-apps/plugin-shell": "~2", "@tauri-apps/plugin-shell": "~2",
"@tinymce/tinymce-vue": "^5.1.1",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/qs": "^6.9.15", "@vitejs/plugin-vue-jsx": "^4.1.0",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"@vueuse/core": "^11.2.0", "@vueuse/core": "^11.2.0",
"dayjs": "^1.11.10", "element-plus": "^2.8.7",
"defu": "^6.1.4",
"element-plus": "^2.8.6",
"less": "^4.2.0", "less": "^4.2.0",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"nuxt": "^3.11.2", "nuxt": "^3.13.2",
"pinia": "^2.1.7", "pinia": "^2.2.6",
"pinia-plugin-persistedstate": "^4.1.3",
"postcss": "^8.4.38", "postcss": "^8.4.38",
"qs": "^6.12.0", "typescript": "^5.6.3",
"typescript": "^5.4.5", "vue-clipboard3": "^2.0.0"
"vue": "^3.4.24",
"vue-clipboard3": "^2.0.0",
"xlsx": "^0.18.5"
},
"dependencies": {
"@tauri-apps/plugin-autostart": "~2",
"@tauri-apps/plugin-clipboard-manager": "^2.0.0",
"@tauri-apps/plugin-fs": "~2"
} }
} }
+38 -7
View File
@@ -3,30 +3,47 @@
<div><ElCheckbox v-model="mainStore.config.disableIpv6">不使用IPv6</ElCheckbox></div> <div><ElCheckbox v-model="mainStore.config.disableIpv6">不使用IPv6</ElCheckbox></div>
<div class="flex items-center gap-[10px]"> <div class="flex items-center gap-[10px]">
<ElCheckbox v-model="mainStore.config.devName">自定义网卡名</ElCheckbox> <ElCheckbox v-model="mainStore.config.devName">自定义网卡名</ElCheckbox>
<ElInput maxlength="10" v-model="mainStore.config.devNameValue" placeholder="请输入网卡名"/> <ElInput
maxlength="10"
v-model="mainStore.config.devNameValue"
placeholder="请输入网卡名"
/>
</div> </div>
<div><ElCheckbox v-model="mainStore.config.disbleListenner">不监听任何端口只连接到对等节点</ElCheckbox></div> <div><ElCheckbox v-model="mainStore.config.disbleListenner">不监听任何端口只连接到对等节点</ElCheckbox></div>
<div><ElCheckbox v-model="mainStore.config.coonectAfterStart">软件启动后自动"启动联机"(搭配开机自启无感联机)</ElCheckbox></div>
<div class="flex items-center gap-[15px] flex-nowrap"> <div class="flex items-center gap-[15px] flex-nowrap">
<ElCheckbox v-model="mainStore.config.saveErrorLog">输出日志到本地</ElCheckbox> <ElCheckbox v-model="mainStore.config.saveErrorLog">输出日志到本地</ElCheckbox>
<div class="w-[140px]"> <div class="w-[140px]">
<ElSelect <ElSelect
v-model="mainStore.config.logLevel" v-model="mainStore.config.logLevel"
placeholder="请选择日志等级" placeholder="请选择日志等级"
class="ml-[5px]"> class="ml-[5px]"
>
<ElOption <ElOption
v-for="item in data" v-for="item in data"
:key="item" :key="item"
:label="`level - ${item}`" :label="`level - ${item}`"
:value="item"></ElOption> :value="item"
></ElOption>
</ElSelect> </ElSelect>
</div> </div>
<ElButton <ElButton
@click="openLogDir" @click="openLogDir"
size="small"> size="small"
>
打开日志目录 打开日志目录
</ElButton> </ElButton>
</div> </div>
<div><ElCheckbox v-model="mainStore.config.coonectAfterStart">软件启动后自动"启动联机"(搭配开机自启无感联机)</ElCheckbox></div>
<div class="flex items-center gap-[15px] flex-nowrap">
<ElCheckbox v-model="mainStore.createConfigInEasytier">自动生成界面配置文件easytier/config.json</ElCheckbox>
<ElButton
@click="openConfigJsonDir"
size="small"
>
打开config.json目录
</ElButton>
</div>
<ElDivider /> <ElDivider />
<div><ElCheckbox v-model="mainStore.config.enablExitNode">允许此节点成为出口节点</ElCheckbox></div> <div><ElCheckbox v-model="mainStore.config.enablExitNode">允许此节点成为出口节点</ElCheckbox></div>
<div><ElCheckbox v-model="mainStore.config.disableEncryption">禁用对等节点通信的加密默认为false必须与对等节点相同</ElCheckbox></div> <div><ElCheckbox v-model="mainStore.config.disableEncryption">禁用对等节点通信的加密默认为false必须与对等节点相同</ElCheckbox></div>
@@ -47,6 +64,7 @@
import { resourceDir as getResourceDir, join } from "@tauri-apps/api/path"; import { resourceDir as getResourceDir, join } from "@tauri-apps/api/path";
import { Command } from "@tauri-apps/plugin-shell"; import { Command } from "@tauri-apps/plugin-shell";
import { exists, mkdir, BaseDirectory } from "@tauri-apps/plugin-fs"; import { exists, mkdir, BaseDirectory } from "@tauri-apps/plugin-fs";
import { ElMessage } from "element-plus";
const mainStore = useMainStore(); const mainStore = useMainStore();
const appWindow = getCurrentWindow(); const appWindow = getCurrentWindow();
@@ -63,8 +81,21 @@
} }
await Command.create("explorer", [logDirPath]).execute(); 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); // 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();
// }
}); });
</script> </script>
+235 -171
View File
@@ -9,179 +9,179 @@
:element-loading-spinner="'<path />'" :element-loading-spinner="'<path />'"
element-loading-text="-------已经启用配置文件,界面配置不再生效-------" --> element-loading-text="-------已经启用配置文件,界面配置不再生效-------" -->
<!-- <div> --> <!-- <div> -->
<ElFormItem <ElFormItem
label="服务器" label="服务器"
prop="serverUrl" prop="serverUrl"
> >
<template #label> <template #label>
<div class="flex items-center gap-[0_5px]"> <div class="flex items-center gap-[0_5px]">
<div>服务器</div> <div>服务器</div>
<span>-</span> <span>-</span>
<ElTag <ElTag
effect="dark" effect="dark"
:type="data.isSuccessGetIp ? 'success' : 'info'" :type="data.isSuccessGetIp ? 'success' : 'info'"
> >
{{ data.isSuccessGetIp ? "联机成功" : data.isStart && !data.isSuccessGetIp ? "联机中" : "未联机" }} {{ data.isSuccessGetIp ? "联机成功" : data.isStart && !data.isSuccessGetIp ? "联机中" : "未联机" }}
</ElTag> </ElTag>
<ElButton <ElButton
v-if="!data.coreVersion" v-if="!data.coreVersion"
@click="getCoreVersion(true)" @click="getCoreVersion(true)"
> >
获取内核版本 获取内核版本
</ElButton> </ElButton>
<ElTag <ElTag
v-else v-else
type="info" type="info"
> >
{{ data.coreVersion }} {{ data.coreVersion }}
</ElTag> </ElTag>
<ElPopconfirm <ElPopconfirm
width="325" width="325"
cancel-button-text="取消" cancel-button-text="取消"
confirm-button-text="继续" confirm-button-text="继续"
title="内核从github下载,需要出国工具,可能下载缓慢或失败,是否继续? title="内核从github下载,需要出国工具,可能下载缓慢或失败,是否继续?
也可以从官方群里手动下载后解压到easytier-game.exe同级目录下的easytier目录里,全部覆盖即可" 也可以从官方群里手动下载后解压到easytier-game.exe同级目录下的easytier目录里,全部覆盖即可"
@confirm="handleUpdateCore" @confirm="handleUpdateCore"
>
<template #reference>
<ElButton
:disabled="data.isStart"
:loading="data.update"
type="warning"
size="small"
>
{{ data.coreVersion ? "更新内核" : "下载内核" }}
</ElButton>
</template>
</ElPopconfirm>
</div>
</template>
<ElSelect
allow-create
filterable
default-first-option
v-model="config.serverUrl"
@change="handleServerUrlChange"
>
<template #prefix>
<div :class="config.protocol && config.protocol.length > 1 ? 'w-[120px]' : 'w-[80px]'">
<ElSelect
placeholder="协议"
multiple
collapse-tags
@click.stop
v-model="config.protocol"
@change="handleServerUrlChange"
> >
<template #reference> <ElOption
<ElButton v-for="item in protocols"
:disabled="data.isStart" :key="item"
:loading="data.update" :label="item"
type="warning" :value="item"
size="small" ></ElOption>
> </ElSelect>
{{ data.coreVersion ? "更新内核" : "下载内核" }}
</ElButton>
</template>
</ElPopconfirm>
</div> </div>
</template> </template>
<ElSelect <ElOption
allow-create v-for="item in mainStore.basePeers"
filterable :key="item"
default-first-option :label="item"
v-model="config.serverUrl" :value="item"
@change="handleServerUrlChange"
> >
<template #prefix> <div class="flex items-center justify-between">
<div :class="config.protocol && config.protocol.length > 1 ? 'w-[120px]' : 'w-[80px]'"> <span style="float: left">{{ item }}</span>
<ElSelect <ElButton
placeholder="协议" @click.stop="handleDeleteServerUrl(item)"
multiple round
collapse-tags :icon="Delete"
@click.stop type="danger"
v-model="config.protocol" ></ElButton>
@change="handleServerUrlChange" </div>
> </ElOption>
<ElOption </ElSelect>
v-for="item in protocols" </ElFormItem>
:key="item" <div class="flex flex-wrap gap-[0_10px] items-center">
:label="item" <div class="flex-1">
:value="item" <ElFormItem label="网络名">
></ElOption>
</ElSelect>
</div>
</template>
<ElOption
v-for="item in mainStore.basePeers"
:key="item"
:label="item"
:value="item"
>
<div class="flex items-center justify-between">
<span style="float: left">{{ item }}</span>
<ElButton
@click.stop="handleDeleteServerUrl(item)"
round
:icon="Delete"
type="danger"
></ElButton>
</div>
</ElOption>
</ElSelect>
</ElFormItem>
<div class="flex flex-wrap gap-[0_10px] items-center">
<div class="flex-1">
<ElFormItem label="网络名">
<template #label>
<div class="flex items-center">
网络名
<ElTooltip content="对应命令行参数 --network-name">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
</div>
</template>
<ElInput
maxlength="100"
placeholder="请输入网络名"
v-model="config.networkName"
></ElInput>
</ElFormItem>
</div>
<div class="flex-1">
<ElFormItem label="网络密码">
<template #label>
<div class="flex items-center">
网络密码
<ElTooltip content="对应命令行参数 --network-secret">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
</div>
</template>
<ElInput
show-password
maxlength="100"
placeholder="请输入网络密码"
v-model="config.networkPassword"
type="password"
></ElInput>
</ElFormItem>
</div>
</div>
<div class="flex gap-[0_10px]">
<ElFormItem label="主机名">
<template #label> <template #label>
<div class="flex items-center"> <div class="flex items-center">
主机 网络
<ElTooltip content="对应命令行参数 --hostname"> <ElTooltip content="对应命令行参数 --network-name">
<ElIcon><QuestionFilled /></ElIcon> <ElIcon><QuestionFilled /></ElIcon>
</ElTooltip> </ElTooltip>
</div> </div>
</template> </template>
<ElInput <ElInput
maxlength="100" maxlength="100"
placeholder="例如: Player1" placeholder="请输入网络名"
v-model="config.hostname" v-model="config.networkName"
></ElInput>
</ElFormItem>
<ElFormItem
class="w-[70%]"
label="局域网IP"
>
<template #label>
<div class="flex items-center h-[20px]">
虚拟网IP
<ElTooltip content="对应命令行参数 --ipv4">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
<ElSwitch
v-model="config.dhcp"
class="ml-[5px]"
inline-prompt
inactive-text="固定IP"
active-text="动态获取IP"
size="small"
></ElSwitch>
</div>
</template>
<ElInput
maxlength="100"
:disabled="config.dhcp"
:placeholder="data.isStart && config.dhcp ? '等待动态分配IP...' : '例如: 10.126.126.1'"
v-model="config.ipv4"
></ElInput> ></ElInput>
</ElFormItem> </ElFormItem>
</div> </div>
<div class="flex-1">
<ElFormItem label="网络密码">
<template #label>
<div class="flex items-center">
网络密码
<ElTooltip content="对应命令行参数 --network-secret">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
</div>
</template>
<ElInput
show-password
maxlength="100"
placeholder="请输入网络密码"
v-model="config.networkPassword"
type="password"
></ElInput>
</ElFormItem>
</div>
</div>
<div class="flex gap-[0_10px]">
<ElFormItem label="主机名">
<template #label>
<div class="flex items-center">
主机名
<ElTooltip content="对应命令行参数 --hostname">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
</div>
</template>
<ElInput
maxlength="100"
placeholder="例如: Player1"
v-model="config.hostname"
></ElInput>
</ElFormItem>
<ElFormItem
class="w-[70%]"
label="局域网IP"
>
<template #label>
<div class="flex items-center h-[20px]">
虚拟网IP
<ElTooltip content="对应命令行参数 --ipv4">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
<ElSwitch
v-model="config.dhcp"
class="ml-[5px]"
inline-prompt
inactive-text="固定IP"
active-text="动态获取IP"
size="small"
></ElSwitch>
</div>
</template>
<ElInput
maxlength="100"
:disabled="config.dhcp"
:placeholder="data.isStart && config.dhcp ? '等待动态分配IP...' : '例如: 10.126.126.1'"
v-model="config.ipv4"
></ElInput>
</ElFormItem>
</div>
<!-- </div> --> <!-- </div> -->
<div class="flex items-start"> <div class="flex items-start">
<div> <div>
@@ -189,6 +189,7 @@
<ElDropdown <ElDropdown
@command="handleStartCommand" @command="handleStartCommand"
split-button split-button
trigger="click"
size="default" size="default"
:type="!data.isStart ? 'primary' : 'danger'" :type="!data.isStart ? 'primary' : 'danger'"
:disabled="data.startLoading || !data.coreVersion || data.update" :disabled="data.startLoading || !data.coreVersion || data.update"
@@ -302,6 +303,8 @@
<ElDialog <ElDialog
width="95%" width="95%"
top="10px" top="10px"
append-to-body
:z-index="10"
class="!mb-0" class="!mb-0"
v-model="importConfigData.visible" v-model="importConfigData.visible"
:close-on-press-escape="false" :close-on-press-escape="false"
@@ -315,7 +318,7 @@
></ElInput> ></ElInput>
<template #footer> <template #footer>
<div> <div>
<el-text type="danger">导入成功后您当前的配置将被完全替换</el-text> <el-text type="danger">导入成功后您当前的部分配置将被替换</el-text>
</div> </div>
<div class="text-right"> <div class="text-right">
<ElButton <ElButton
@@ -331,6 +334,8 @@
<ElDialog <ElDialog
width="95%" width="95%"
top="30px" top="30px"
append-to-body
:z-index="10"
class="!mb-0" class="!mb-0"
v-model="configStart.visible" v-model="configStart.visible"
:close-on-press-escape="false" :close-on-press-escape="false"
@@ -393,14 +398,16 @@
import { useTray, setTrayRunState, setTrayTooltip } from "~/composables/tray"; import { useTray, setTrayRunState, setTrayTooltip } from "~/composables/tray";
import { initStartWinIpBroadcast } from "~/composables/netcard"; import { initStartWinIpBroadcast } from "~/composables/netcard";
import useMainStore from "@/stores/index"; import useMainStore from "@/stores/index";
import { ElDropdownMenu, ElMessage, ElMessageBox } from "element-plus"; import { ElMessage, ElMessageBox } from "element-plus";
import { getCurrentWindow } from "@tauri-apps/api/window"; import { getCurrentWindow } from "@tauri-apps/api/window";
import { getAllWebviewWindows } from "@tauri-apps/api/webviewWindow"; import { getAllWebviewWindows } from "@tauri-apps/api/webviewWindow";
import etWindows from "@/composables/windows"; import etWindows from "@/composables/windows";
import * as tauriAutoStart from "@tauri-apps/plugin-autostart"; import * as tauriAutoStart from "@tauri-apps/plugin-autostart";
import { resourceDir as getResourceDir, join } from "@tauri-apps/api/path"; import { resourceDir as getResourceDir, join } from "@tauri-apps/api/path";
import { readDir, exists, mkdir, BaseDirectory } from "@tauri-apps/plugin-fs"; import { readDir, exists, mkdir, BaseDirectory, readTextFile } from "@tauri-apps/plugin-fs";
import { updateConfigJson } from "~/composables/configJson";
import { writeText, readText } from "@tauri-apps/plugin-clipboard-manager"; import { writeText, readText } from "@tauri-apps/plugin-clipboard-manager";
import { bounce } from "~/utils";
let is_close = false; let is_close = false;
@@ -505,7 +512,6 @@
const start = logArr.length > 1000 ? logArr.length - 1000 : 0; const start = logArr.length > 1000 ? logArr.length - 1000 : 0;
data.log = logArr.slice(start).join("\n"); data.log = logArr.slice(start).join("\n");
data.log += (event.payload as string) + "\n"; data.log += (event.payload as string) + "\n";
}); });
this.unListenOutPut = unListen; this.unListenOutPut = unListen;
}, },
@@ -629,15 +635,15 @@
const compatibleInitAutoStart = async () => { const compatibleInitAutoStart = async () => {
try { try {
const is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean; // const is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean;
if (is_enable_by_task) { // if (is_enable_by_task) {
await tauriAutoStart.enable(); // await tauriAutoStart.enable();
await invoke("spawn_autostart", { enabled: false }); // await invoke("spawn_autostart", { enabled: false });
} // }
const is_enable = await tauriAutoStart.isEnabled(); const is_enable = await tauriAutoStart.isEnabled();
config.autoStart = is_enable; config.autoStart = is_enable;
} catch (err) { } catch (err) {
await invoke("spawn_autostart", { enabled: false }); // await invoke("spawn_autostart", { enabled: false });
await tauriAutoStart.disable(); await tauriAutoStart.disable();
config.autoStart = false; config.autoStart = false;
} }
@@ -650,10 +656,49 @@
} }
}; };
const initGuiJson = async () => {
const path = import.meta.env.VITE_CONFIG_FILE_NAME;
const isExists = await exists(path, { baseDir: BaseDirectory.Resource });
if (isExists) {
const guiJsonStr = await readTextFile(path, { baseDir: BaseDirectory.Resource });
if (guiJsonStr) {
try {
const regex = /^(\s*\/\/.*)/gm;
const regex2 = /(,?)\s*\/\/.*(?=\n|$|\r\n)/gm;
const resultStr = guiJsonStr.replace(regex, "").replace(regex2, "$1");
const guiJson = JSON.parse(resultStr);
mainStore.$patch({
config: {
...mainStore.config,
...guiJson
}
});
if (guiJson.serverUrl) {
mainStore.basePeers = [...new Set([guiJson.serverUrl, ...mainStore.basePeers])];
}
} catch (err) {
ElMessage.error(`config.json格式错误`);
}
}
}
const b = bounce(600);
mainStore.$subscribe(
(...a) => {
if (mainStore.createConfigInEasytier) {
b(async () => {
await updateConfigJson();
});
}
},
{ immediate: true }
);
};
let logsTimer: NodeJS.Timeout | null = null; let logsTimer: NodeJS.Timeout | null = null;
onMounted(async () => { onMounted(async () => {
// await handleUpdateCore(); //默认不自动更新 // await handleUpdateCore(); //默认不自动更新
await initGuiJson();
await compatibleInitAutoStart(); await compatibleInitAutoStart();
// await initAutoStart(); // await initAutoStart();
await initStartWinIpBroadcast(); await initStartWinIpBroadcast();
@@ -784,10 +829,10 @@
if (!args || args.length <= 0) { if (!args || args.length <= 0) {
return ElMessage.error("无配置"); return ElMessage.error("无配置");
} }
if(args[0] === "-c") { if (args[0] === "-c") {
ElMessage.warning({ ElMessage.warning({
message: "使用配置文件中.", message: "使用配置文件中.",
duration: 5000, duration: 5000
}); });
} }
data.log = ""; //清空日志 data.log = ""; //清空日志
@@ -825,7 +870,20 @@
} }
if (command === "share_config") { if (command === "share_config") {
try { try {
const WT = btoa(encodeURIComponent(JSON.stringify({ config: mainStore.config }))) const {
proxyNetworks,
autoStart,
coonectAfterStart,
multiThread,
hostname,
enablExitNode,
useSmoltcp,
saveErrorLog,
logLevel,
ipv4,
...otherConfig
} = mainStore.config;
const WT = btoa(encodeURIComponent(JSON.stringify({ config: otherConfig })));
await writeText(WT); await writeText(WT);
ElMessage.success("配置已复制"); ElMessage.success("配置已复制");
} catch (err) { } catch (err) {
@@ -846,11 +904,17 @@
cancelButtonText: "取消" cancelButtonText: "取消"
}); });
const payload = JSON.parse(decodeURIComponent(atob(importConfigData.data))); const payload = JSON.parse(decodeURIComponent(atob(importConfigData.data)));
mainStore.$patch(payload); mainStore.$patch({
config: {
...mainStore.config,
...payload.config
}
});
ElMessage.success("导入成功"); ElMessage.success("导入成功");
importConfigData.visible = false; importConfigData.visible = false;
mainStore.basePeers = [...new Set([config.serverUrl, ...mainStore.basePeers])]; mainStore.basePeers = [...new Set([config.serverUrl, ...mainStore.basePeers])];
} catch (err) { } catch (err) {
console.log(err);
if (err !== "cancel") { if (err !== "cancel") {
ElMessage.error("导入失败"); ElMessage.error("导入失败");
} }
-10
View File
@@ -1,10 +0,0 @@
import { createPersistedState } from "pinia-plugin-persistedstate";
import { defineNuxtPlugin } from "nuxt/app";
export default defineNuxtPlugin((nuxtApp: any) => {
nuxtApp.$pinia.use(
createPersistedState({
storage: localStorage,
key: id => `__glj_persisted_${id}`
})
);
});
+2444 -3865
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -2,4 +2,4 @@
# will have compiled files and executables # will have compiled files and executables
/target/ /target/
/gen/schemas /gen/schemas
/easytier/ /easytier/logs
+1 -1
View File
@@ -1176,7 +1176,7 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
[[package]] [[package]]
name = "easytier-game" name = "easytier-game"
version = "1.1.7" version = "1.1.8"
dependencies = [ dependencies = [
"log", "log",
"planif", "planif",
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "easytier-game" name = "easytier-game"
version = "1.1.7" version = "1.1.8"
homepage = "https://github.com/EasyTier/EasyTier" homepage = "https://github.com/EasyTier/EasyTier"
repository = "https://github.com/EasyTier/EasytierGame" repository = "https://github.com/EasyTier/EasytierGame"
description = "A simple network initiator based on Easytier" description = "A simple network initiator based on Easytier"
+2
View File
@@ -84,6 +84,8 @@
"fs:allow-open", "fs:allow-open",
"fs:allow-resource-read", "fs:allow-resource-read",
"fs:allow-resource-read-recursive", "fs:allow-resource-read-recursive",
"fs:allow-resource-write",
"fs:allow-resource-write-recursive",
"clipboard-manager:allow-clear", "clipboard-manager:allow-clear",
"clipboard-manager:allow-read-text", "clipboard-manager:allow-read-text",
"clipboard-manager:allow-write-text" "clipboard-manager:allow-write-text"
+22
View File
@@ -0,0 +1,22 @@
{
// 如果您的配置过于复杂,可以参考 使用配置文件进行联机的办法,以下是基础的界面配置,用于快速分享联机
"protocol": [
"tcp",
"udp"
], // 协议类型
"serverUrl": "public.easytier.top:11010", // easytier服务地址
"networkName": "", // 网络名
"networkPassword": "", // 网络密码
"hostname": "configTest", // 主机名
"ipv4": "10.126.126.1", // IP地址(选填,下面有dhcp)
"disableIpv6": false, // 禁用ipv6
"disbleListenner": true, // 禁用端口监听
"disableEncryption": false, // 禁用加密
"noTun": false, // 禁用tun
"latencyfirst": false, // 延迟优先
"disableUdpHolePunching": false, // 禁用udp打洞
"disbleP2p": false, // 禁用p2p, 强制中转
"dhcp": false, // 动态分配IP
"devName": false, // 是否启用自定义网卡名
"devNameValue": "" // 网卡名(启用devName之后才生效)
}
Binary file not shown.
+3 -2
View File
@@ -1,7 +1,7 @@
{ {
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "easytier-game", "productName": "easytier-game",
"version": "1.1.7", "version": "1.1.8",
"identifier": "com.tauri.easytier-game", "identifier": "com.tauri.easytier-game",
"build": { "build": {
@@ -13,7 +13,7 @@
"app": { "app": {
"windows": [ "windows": [
{ {
"title": "easytier-game 1.1.7", "title": "easytier-game 1.1.8",
"minWidth": 340, "minWidth": 340,
"width": 340, "width": 340,
"height": 305, "height": 305,
@@ -39,6 +39,7 @@
"resources": [ "resources": [
"easytier/config/", "easytier/config/",
"easytier/icons/", "easytier/icons/",
"easytier/config_template.json",
"easytier/tool/WinIPBroadcast.exe", "easytier/tool/WinIPBroadcast.exe",
"easytier/easytier-cli.exe", "easytier/easytier-cli.exe",
"easytier/easytier-core.exe", "easytier/easytier-core.exe",
+13 -38
View File
@@ -27,51 +27,26 @@ export default defineStore("main", {
saveErrorLog: true, // 是否保存错误日志 saveErrorLog: true, // 是否保存错误日志
logLevel: "error", //日志等级 logLevel: "error", //日志等级
devName: false, //自定义网卡名 devName: false, //自定义网卡名
devNameValue: "", //自定义网卡名 devNameValue: "" //自定义网卡名
}, },
cidrEnable: false,
basePeers: ["public.easytier.top:11010"],
theme: false, //主题 false light true dark theme: false, //主题 false light true dark
configStartEnable: false, //使用配置文件启动 configStartEnable: false, //使用配置文件启动
configPath: "", //配置文件路径 configPath: "", //配置文件路径
cidrEnable: false, winIpBcAutoStart: true,
createConfigInEasytier: false, //在easytier目录生成config.json文件吗
winipBcPid: 0, winipBcPid: 0,
winipBcStart: false, winipBcStart: false,
winIpBcAutoStart: true,
basePeers: ["public.easytier.top:11010"],
}; };
}, },
persist: { persist: {
paths: [ // 除了这些,其他都要存下来
"basePeers", omit: [
"cidrEnable", "winipBcPid",
"theme", "winipBcStart"
"configStartEnable", ]
"configPath", }
"winIpBcAutoStart",
"config.proxyNetworks",
"config.serverUrl",
"config.networkName",
"config.protocol",
"config.networkPassword",
"config.disbleP2p",
"config.autoStart",
"config.coonectAfterStart",
"config.disableIpv6",
"config.disbleListenner",
"config.disableEncryption",
"config.multiThread",
"config.enablExitNode",
"config.noTun",
"config.latencyfirst",
"config.useSmoltcp",
"config.disableUdpHolePunching",
"config.relayAllPeerrpc",
"config.hostname",
"config.ipv4",
"config.dhcp",
"config.saveErrorLog",
"config.logLevel",
"config.devName",
"config.devNameValue",
],
},
}); });
+4 -3
View File
@@ -6,6 +6,7 @@
"components/**/*.ts", "components/**/*.ts",
"components/**/*.js", "components/**/*.js",
"components/**/*.vue", "components/**/*.vue",
"composables/**/*.ts",
"app.vue", "app.vue",
"pages/**/*.ts", "pages/**/*.ts",
"pages/**/*.js", "pages/**/*.js",
@@ -28,16 +29,16 @@
"compilerOptions": { "compilerOptions": {
"target": "ESNext", "target": "ESNext",
"module": "ESNext", "module": "ESNext",
"moduleResolution": "Node",
// "types": ["element-plus/global"] // "types": ["element-plus/global"]
"resolveJsonModule": true, "resolveJsonModule": true,
// 从 Vue 3.4 开始,Vue 不再隐式注册全局 JSX 命名空间。要指示 TypeScript 使用 Vue 的 JSX 类型定义,请确保在你的 tsconfig.json 中包含以下内容 // 从 Vue 3.4 开始,Vue 不再隐式注册全局 JSX 命名空间。要指示 TypeScript 使用 Vue 的 JSX 类型定义,请确保在你的 tsconfig.json 中包含以下内容
"jsx": "preserve", "jsx": "preserve",
"jsxImportSource": "vue", "jsxImportSource": "vue",
"types": ["@pinia/nuxt", "vite/client", "element-plus/global"], "types": ["@pinia/nuxt", "vite/client", "element-plus/global", "pinia-plugin-persistedstate"],
"allowJs": true, // 允许编译器编译JSJSX文件 "allowJs": true, // 允许编译器编译JSJSX文件
"checkJs": true, // 允许在JS文件中报错,通常与allowJS一起使用 "checkJs": false, // 允许在JS文件中报错,通常与allowJS一起使用
"esModuleInterop": true, // 允许export=导出,由import from 导入 "esModuleInterop": true, // 允许export=导出,由import from 导入
"lib": ["DOM", "ESNext"], "lib": ["DOM", "ESNext"],
"allowSyntheticDefaultImports": true "allowSyntheticDefaultImports": true
} }
+1
View File
@@ -1,5 +1,6 @@
interface ImportMetaEnv { interface ImportMetaEnv {
readonly VITE_CONFIG_PATH: string; readonly VITE_CONFIG_PATH: string;
readonly VITE_CONFIG_FILE_NAME: string;
} }
interface ImportMeta { interface ImportMeta {
-12
View File
@@ -1,17 +1,5 @@
import { ElMessage } from "element-plus";
import Clipboard from "vue-clipboard3";
export const ENV = import.meta.env; export const ENV = import.meta.env;
export const clipBoardCopy = async (text: string) => {
const { toClipboard } = Clipboard();
try {
await toClipboard(text);
ElMessage.success("复制成功");
} catch (e) {
ElMessage.error("复制失败");
}
};
//防抖 //防抖
export const bounce = (time = 3000) => { export const bounce = (time = 3000) => {