mirror of
https://github.com/EasyTier/EasytierGame.git
synced 2025-05-19 10:27:56 +00:00
新增配置文件启动,修复部分文本缺失
This commit is contained in:
Vendored
+1
@@ -0,0 +1 @@
|
||||
VITE_CONFIG_PATH=easytier/config/
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
VITE_CONFIG_PATH=easytier/config/
|
||||
+3
-1
@@ -5,6 +5,8 @@
|
||||
<script setup lang="tsx">
|
||||
//屏蔽右键菜单
|
||||
document.addEventListener("contextmenu", (e: MouseEvent) => {
|
||||
// e.preventDefault();
|
||||
if (import.meta.env.PROD) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
+3
-2
@@ -3,7 +3,7 @@
|
||||
"private": true,
|
||||
"author": "leizi97",
|
||||
"description": "A simple network initiator based on Easytier",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.9",
|
||||
"scripts": {
|
||||
"dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0",
|
||||
"build": "nuxt generate --dotenv env/.env.prod"
|
||||
@@ -38,6 +38,7 @@
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tauri-apps/plugin-autostart": "~2"
|
||||
"@tauri-apps/plugin-autostart": "~2",
|
||||
"@tauri-apps/plugin-fs": "~2"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
<div><ElCheckbox v-model="mainStore.config.latencyfirst">延迟优先模式,将尝试使用最低延迟路径转发流量,默认使用最短路径</ElCheckbox></div>
|
||||
<div><ElCheckbox v-model="mainStore.config.disableUdpHolePunching">禁用UDP打洞功能</ElCheckbox></div>
|
||||
<div>
|
||||
<ElCheckbox v-model="mainStore.config.relayAllPeerrpc">转发所有对等节点的RPC数据包,即使对等节点不在转发网络白名</ElCheckbox>
|
||||
<ElCheckbox v-model="mainStore.config.relayAllPeerrpc">转发所有对等节点的RPC数据包,即使对等节点不在转发网络白名单内</ElCheckbox>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
+130
-25
@@ -23,7 +23,7 @@
|
||||
<ElTag
|
||||
v-else
|
||||
type="info">
|
||||
core-{{ data.coreVersion }}
|
||||
{{ data.coreVersion }}
|
||||
</ElTag>
|
||||
<ElButton
|
||||
:disabled="data.isStart"
|
||||
@@ -150,19 +150,29 @@
|
||||
v-model="config.ipv4"></ElInput>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<div class="flex items-start gap-[0_30px]">
|
||||
<div class="w-[95px]">
|
||||
<div class="flex items-start gap-[0_12px]">
|
||||
<div class="w-[122px]">
|
||||
<div>
|
||||
<ElButton
|
||||
<ElDropdown
|
||||
@command="handleStartCommand"
|
||||
split-button
|
||||
size="default"
|
||||
:type="!data.isStart ? 'primary' : 'danger'"
|
||||
:disabled="data.startLoading || !data.coreVersion || data.update"
|
||||
@click="handleConnection"
|
||||
size="default">
|
||||
@click="handleConnection">
|
||||
{{ !data.isStart ? "启动联机" : "停止联机" }}
|
||||
</ElButton>
|
||||
<template #dropdown>
|
||||
<ElDropdownMenu>
|
||||
<ElDropdownItem
|
||||
command="toml"
|
||||
:disabled="data.isStart"
|
||||
>配置文件启动</ElDropdownItem
|
||||
>
|
||||
</ElDropdownMenu>
|
||||
</template>
|
||||
</ElDropdown>
|
||||
</div>
|
||||
<div class="mt-[6px] pl-[2px]">
|
||||
<!-- <ElButtonGroup> -->
|
||||
<ElTooltip
|
||||
placement="left"
|
||||
content="日志">
|
||||
@@ -183,7 +193,6 @@
|
||||
type="success"
|
||||
size="small"></ElButton>
|
||||
</ElTooltip>
|
||||
<!-- </ElButtonGroup> -->
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
@@ -192,24 +201,12 @@
|
||||
size="small">
|
||||
强制中转
|
||||
</ElCheckbox>
|
||||
<!-- <ElCheckbox
|
||||
v-model="config.disableIpv6"
|
||||
size="small"
|
||||
>
|
||||
禁用ipv6
|
||||
</ElCheckbox> -->
|
||||
<ElCheckbox
|
||||
@change="handleAutoStart"
|
||||
:model-value="config.autoStart"
|
||||
size="small">
|
||||
开机自启
|
||||
</ElCheckbox>
|
||||
<!-- <ElCheckbox
|
||||
v-model="config.disbleListenner"
|
||||
size="small"
|
||||
>
|
||||
禁用端口监听
|
||||
</ElCheckbox> -->
|
||||
<div>
|
||||
<ElButton
|
||||
@click="handleShowCidrDialog"
|
||||
@@ -254,20 +251,65 @@
|
||||
</div>
|
||||
</div>
|
||||
</ElForm>
|
||||
<ElDialog
|
||||
width="95%"
|
||||
top="10px"
|
||||
v-model="configStart.visible"
|
||||
:close-on-press-escape="false"
|
||||
title="配置文件启动">
|
||||
<div class="flex items-center gap-[0_4px]">
|
||||
<span>启用</span><ElSwitch v-model="mainStore.configStartEnable"></ElSwitch
|
||||
><ElTooltip content="启用后将完全使用选中的配置文件作为联机配置,其余界面配置不会生效">
|
||||
<ElIcon class="ml-[3px]"><QuestionFilled /></ElIcon> </ElTooltip
|
||||
><ElButton
|
||||
@click="openConfigDir"
|
||||
size="small"
|
||||
>打开配置目录</ElButton
|
||||
>
|
||||
<ElButton
|
||||
@click="handleStartCommand('toml')"
|
||||
type="primary"
|
||||
:icon="RefreshRight"
|
||||
size="small"
|
||||
>刷新</ElButton
|
||||
>
|
||||
</div>
|
||||
<div class="mt-[5px]">
|
||||
<ElSelect
|
||||
v-model="mainStore.configPath"
|
||||
no-data-text="目录没有配置文件"
|
||||
placeholder="选择配置文件">
|
||||
<ElOption
|
||||
v-for="item in configStart.list"
|
||||
:key="item.path"
|
||||
:value="item.path"
|
||||
:label="item.name"></ElOption>
|
||||
</ElSelect>
|
||||
</div>
|
||||
<div class="mt-[5px] text-right">
|
||||
<ElButton
|
||||
@click="configStart.visible = false"
|
||||
type="danger"
|
||||
>关闭</ElButton
|
||||
>
|
||||
</div>
|
||||
</ElDialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import { open, Command } from "@tauri-apps/plugin-shell";
|
||||
import { QuestionFilled, Delete, List, UserFilled, Setting, Share } from "@element-plus/icons-vue";
|
||||
import { QuestionFilled, Delete, List, UserFilled, Setting, Share, RefreshRight } from "@element-plus/icons-vue";
|
||||
import { reactive, onBeforeUnmount, onMounted } from "vue";
|
||||
import { useTray, setTrayRunState } from "~/composables/tray";
|
||||
import useMainStore from "@/stores/index";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { ElDropdownMenu, ElMessage } from "element-plus";
|
||||
import { getCurrentWindow, PhysicalPosition } from "@tauri-apps/api/window";
|
||||
import { getAllWebviewWindows } from "@tauri-apps/api/webviewWindow";
|
||||
import etWindows from "@/composables/windows";
|
||||
import * as tauriAutoStart from "@tauri-apps/plugin-autostart";
|
||||
import { resourceDir as getResourceDir, join } from '@tauri-apps/api/path';
|
||||
import { readDir, exists, mkdir, BaseDirectory } from "@tauri-apps/plugin-fs";
|
||||
|
||||
let is_close = false;
|
||||
|
||||
@@ -297,6 +339,12 @@
|
||||
isStart: false,
|
||||
});
|
||||
|
||||
const configStart = reactive({
|
||||
visible: false,
|
||||
loading: false,
|
||||
list: [], //配置文件列表
|
||||
});
|
||||
|
||||
const closePrevent = async () => {
|
||||
const appWindow = getCurrentWindow();
|
||||
if (appWindow.label == "main") {
|
||||
@@ -508,6 +556,7 @@
|
||||
await getCoreVersion();
|
||||
await listenObj.listenThreadId();
|
||||
await listenObj.listenConfigStart();
|
||||
await initConfigDir();
|
||||
closePrevent();
|
||||
});
|
||||
|
||||
@@ -518,9 +567,17 @@
|
||||
logsTimer && clearInterval(logsTimer);
|
||||
});
|
||||
|
||||
const getArgs = () => {
|
||||
const getArgs = async () => {
|
||||
// console.log(config.proxyNetworks);
|
||||
const args = [];
|
||||
if (mainStore.configStartEnable && mainStore.configPath) {
|
||||
// const resourceDir = await getResourceDir();
|
||||
// const configPath = await join(resourceDir, mainStore.configPath);
|
||||
// args.push("-c", configPath);
|
||||
|
||||
args.push("-c", mainStore.configPath);
|
||||
return args;
|
||||
}
|
||||
if (config.dhcp) {
|
||||
args.push("-d");
|
||||
}
|
||||
@@ -611,17 +668,65 @@
|
||||
if (data.isStart) {
|
||||
await reset();
|
||||
} else {
|
||||
const args = await getArgs();
|
||||
|
||||
if (!args || args.length <= 0) {
|
||||
return ElMessage.error("无配置");
|
||||
}
|
||||
data.log = ""; //清空日志
|
||||
data.startLoading = true;
|
||||
await unListenAll();
|
||||
await listenObj.listenOutput();
|
||||
const args = getArgs();
|
||||
|
||||
await invoke("run_command", {
|
||||
args,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//configStart
|
||||
const handleStartCommand = async (command: string | number | object) => {
|
||||
if (command === "toml") {
|
||||
configStart.visible = true;
|
||||
const path = import.meta.env.VITE_CONFIG_PATH;
|
||||
const isExists = await exists(path, { baseDir: BaseDirectory.Resource });
|
||||
if (isExists) {
|
||||
const entries = await readDir(path, { baseDir: BaseDirectory.Resource });
|
||||
configStart.list = entries
|
||||
.filter((item) => item.isFile)
|
||||
.map((item) => ({
|
||||
name: item.name,
|
||||
path: `${path}${item.name}`,
|
||||
})) as any;
|
||||
} else {
|
||||
mainStore.configStartEnable = false;
|
||||
mainStore.configPath = "";
|
||||
try {
|
||||
await mkdir(path, { baseDir: BaseDirectory.Resource });
|
||||
} catch (err) {}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const initConfigDir = async () => {
|
||||
const path = import.meta.env.VITE_CONFIG_PATH;
|
||||
const isExists = await exists(path, { baseDir: BaseDirectory.Resource });
|
||||
if (!isExists) {
|
||||
mainStore.configStartEnable = false;
|
||||
mainStore.configPath = "";
|
||||
try {
|
||||
await mkdir(path, { baseDir: BaseDirectory.Resource });
|
||||
} catch (err) {}
|
||||
}
|
||||
};
|
||||
|
||||
const openConfigDir = async () => {
|
||||
const resourceDir = await getResourceDir();
|
||||
const configPath = await join(resourceDir, import.meta.env.VITE_CONFIG_PATH);
|
||||
console.log(configPath)
|
||||
await Command.create("explorer", [configPath]).execute();
|
||||
};
|
||||
|
||||
const handleShowMemberDialog = async () => {
|
||||
if (!data.isStart) {
|
||||
return ElMessage.warning("请先开始联机");
|
||||
|
||||
Generated
+10
@@ -11,6 +11,9 @@ importers:
|
||||
'@tauri-apps/plugin-autostart':
|
||||
specifier: ~2
|
||||
version: 2.0.0
|
||||
'@tauri-apps/plugin-fs':
|
||||
specifier: ~2
|
||||
version: 2.0.1
|
||||
devDependencies:
|
||||
'@element-plus/icons-vue':
|
||||
specifier: ^2.3.1
|
||||
@@ -1008,6 +1011,9 @@ packages:
|
||||
'@tauri-apps/plugin-cli@2.0.0':
|
||||
resolution: {integrity: sha512-glQmlL1IiCGEa1FHYa/PTPSeYhfu56omLRgHXWlJECDt6DbJyRuJWVgtkQfUxtqnVdYnnU+DGIGeiInoEqtjLw==}
|
||||
|
||||
'@tauri-apps/plugin-fs@2.0.1':
|
||||
resolution: {integrity: sha512-PkeZG2WAob9Xpmr66aPvj+McDVgFjV2a7YBzYVZjiCvbGeMs6Yk09tlXhCe3EyZdT/pwWMSi8lXUace+hlsjsw==}
|
||||
|
||||
'@tauri-apps/plugin-http@2.0.0':
|
||||
resolution: {integrity: sha512-UfKAICL25ayluV/SjiEQujz8q/2uyAzp3u9uaHFkaIyKS5usBL8DoqSwi4eKz2mEjkbxTwldhDEXG4CEfTE0JQ==}
|
||||
|
||||
@@ -5363,6 +5369,10 @@ snapshots:
|
||||
dependencies:
|
||||
'@tauri-apps/api': 2.0.2
|
||||
|
||||
'@tauri-apps/plugin-fs@2.0.1':
|
||||
dependencies:
|
||||
'@tauri-apps/api': 2.0.2
|
||||
|
||||
'@tauri-apps/plugin-http@2.0.0':
|
||||
dependencies:
|
||||
'@tauri-apps/api': 2.0.2
|
||||
|
||||
Generated
+23
-1
@@ -1109,7 +1109,7 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
|
||||
|
||||
[[package]]
|
||||
name = "easytier-game"
|
||||
version = "1.0.8"
|
||||
version = "1.0.9"
|
||||
dependencies = [
|
||||
"log",
|
||||
"planif",
|
||||
@@ -1120,6 +1120,7 @@ dependencies = [
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
"tauri-plugin-autostart",
|
||||
"tauri-plugin-fs",
|
||||
"tauri-plugin-log",
|
||||
"tauri-plugin-shell",
|
||||
"tauri-plugin-single-instance",
|
||||
@@ -4387,6 +4388,27 @@ dependencies = [
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-fs"
|
||||
version = "2.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96ba7d46e86db8c830d143ef90ab5a453328365b0cc834c24edea4267b16aba0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"dunce",
|
||||
"glob",
|
||||
"percent-encoding",
|
||||
"schemars",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
"tauri",
|
||||
"tauri-plugin",
|
||||
"thiserror",
|
||||
"url",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-log"
|
||||
version = "2.0.1"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "easytier-game"
|
||||
version = "1.0.8"
|
||||
version = "1.0.9"
|
||||
homepage = "https://github.com/EasyTier/EasyTier"
|
||||
repository = "https://github.com/EasyTier/EasytierGame"
|
||||
description = "A simple network initiator based on Easytier"
|
||||
@@ -36,6 +36,7 @@ reqwest = { version = "0.12", features = ["json"] }
|
||||
zip = "2.2.0"
|
||||
sysinfo = '0.32.0'
|
||||
planif = { git = "https://github.com/mattrobineau/planif", tag = "1.0.1" }
|
||||
tauri-plugin-fs = "2"
|
||||
# prost = "0.13"
|
||||
# prost-types = "0.13"
|
||||
|
||||
|
||||
@@ -44,8 +44,19 @@
|
||||
"args": ["run"],
|
||||
"cmd": "easytier/tool/WinIPBroadcast",
|
||||
"name": "WinIPBroadcast"
|
||||
}
|
||||
},
|
||||
{
|
||||
"args": true,
|
||||
"cmd": "explorer",
|
||||
"name": "explorer"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"fs:default",
|
||||
"fs:allow-read-dir",
|
||||
"fs:allow-exists",
|
||||
"fs:allow-open",
|
||||
"fs:allow-resource-read",
|
||||
"fs:allow-resource-read-recursive"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
hostname = "Test1"
|
||||
instance_name = "default"
|
||||
instance_id = "8803362c-e4f1-4df1-93e8-721653945f77"
|
||||
dhcp = true
|
||||
listeners = [
|
||||
"tcp://0.0.0.0:11010",
|
||||
"udp://0.0.0.0:11010",
|
||||
"wg://0.0.0.0:11011",
|
||||
"ws://0.0.0.0:11011/",
|
||||
"wss://0.0.0.0:11012/",
|
||||
]
|
||||
exit_nodes = []
|
||||
rpc_portal = "0.0.0.0:15888"
|
||||
|
||||
[network_identity]
|
||||
network_name = "default"
|
||||
network_secret = ""
|
||||
|
||||
[[peer]]
|
||||
uri = "tcp://public.easytier.top:11010"
|
||||
|
||||
[[peer]]
|
||||
uri = "udp://public.easytier.top:11010"
|
||||
|
||||
[[proxy_network]]
|
||||
cidr = "192.168.1.0/24"
|
||||
@@ -209,7 +209,6 @@ fn run_command(
|
||||
args: Vec<String>,
|
||||
stop_signal: tauri::State<Arc<AtomicBool>>,
|
||||
) {
|
||||
|
||||
let (tx, rx) = mpsc::channel();
|
||||
stop_signal.store(false, Ordering::Relaxed);
|
||||
let app_handle1 = app_handle.clone();
|
||||
@@ -350,6 +349,7 @@ pub fn run() {
|
||||
let stop_signal_clone = Arc::clone(&stop_signal); // 创建一个原子布尔值的克隆,用于传递给命令
|
||||
let context = tauri::generate_context!();
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_fs::init())
|
||||
.plugin(tauri_plugin_autostart::init(
|
||||
MacosLauncher::LaunchAgent,
|
||||
Some(vec![AUTOSTART_ARG]),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "easytier-game",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.9",
|
||||
"identifier": "com.tauri.easytier-game",
|
||||
|
||||
"build": {
|
||||
@@ -33,6 +33,7 @@
|
||||
"active": false,
|
||||
"targets": "all",
|
||||
"resources": [
|
||||
"easytier/config/",
|
||||
"easytier/tool/WinIPBroadcast.exe",
|
||||
"easytier/icons/icon-inactive.ico",
|
||||
"easytier/icons/icon.ico",
|
||||
|
||||
@@ -24,6 +24,8 @@ export default defineStore("main", {
|
||||
disbleP2p: false, // 是否使用P2P
|
||||
dhcp: true, // 是否使用DHCP
|
||||
},
|
||||
configStartEnable: false, //使用配置文件启动
|
||||
configPath: "", //配置文件路径
|
||||
cidrEnable: false,
|
||||
basePeers: ["public.easytier.top:11010"],
|
||||
};
|
||||
|
||||
Vendored
+6
@@ -1 +1,7 @@
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_CONFIG_PATH: string;
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user