mirror of
https://github.com/EasyTier/EasytierGame.git
synced 2025-05-19 10:27:56 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf351b8708 | ||
|
|
ddf4c32ae6 | ||
|
|
3adf64e251 | ||
|
|
4e4ebf1246 | ||
|
|
4296f4a338 | ||
|
|
60078f00f7 | ||
|
|
d0567e96b5 | ||
|
|
8c911f47f9 |
@@ -4,4 +4,6 @@
|
|||||||
</NuxtLayout>
|
</NuxtLayout>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { initTheme } from "~/composables/theme";
|
||||||
|
initTheme();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
+9
-4
@@ -1,14 +1,14 @@
|
|||||||
@tailwind base;
|
/* @tailwind base; */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
用于进行主题更换,如果要更换elemenet-plus-ui的主题记得加上!important,不然更换会失败
|
用于进行主题更换,如果要更换elemenet-plus-ui的主题记得加上!important,不然更换会失败
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@layer base {
|
/* @layer base {
|
||||||
html {
|
html {
|
||||||
font-family: "Helvetica Neue", "Luxi Sans", "DejaVu Sans", Tahoma, "Hiragino Sans GB", STHeiti, "Microsoft YaHei";
|
font-family: "Helvetica Neue", "Luxi Sans", "DejaVu Sans", Tahoma, "Hiragino Sans GB", STHeiti, "Microsoft YaHei";
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
|
|
||||||
html,
|
html,
|
||||||
body {
|
body {
|
||||||
@@ -19,11 +19,16 @@ body {
|
|||||||
* {
|
* {
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
body {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
html.dark body {
|
||||||
|
background-color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
#__easytier {
|
#__easytier {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background-color: #fff;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 3px 5px;
|
padding: 3px 5px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { useDark, useToggle, usePreferredDark } from "@vueuse/core";
|
||||||
|
import { isFunction } from "lodash-es";
|
||||||
|
const isDark = usePreferredDark();
|
||||||
|
const darkConfig = useDark({
|
||||||
|
selector: "html",
|
||||||
|
attribute: "class",
|
||||||
|
valueDark: "dark",
|
||||||
|
valueLight: "",
|
||||||
|
});
|
||||||
|
const toggleDark = useToggle(darkConfig);
|
||||||
|
export const initTheme = () => {
|
||||||
|
if (isDark && isFunction(toggleDark)) {
|
||||||
|
toggleDark(isDark.value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const setTheme = (dark: boolean) => {
|
||||||
|
if (isFunction(toggleDark)) {
|
||||||
|
toggleDark(dark);
|
||||||
|
}
|
||||||
|
}
|
||||||
+16
-17
@@ -25,11 +25,11 @@ export async function useTray(init: boolean = false, beforExit: Function) {
|
|||||||
id: DEFAULT_TRAY_NAME,
|
id: DEFAULT_TRAY_NAME,
|
||||||
menu: await Menu.new({
|
menu: await Menu.new({
|
||||||
id: "main",
|
id: "main",
|
||||||
items: await generateMenuItem(beforExit)
|
items: await generateMenuItem(beforExit),
|
||||||
}),
|
}),
|
||||||
action: async e => {
|
action: async (e) => {
|
||||||
toggleVisibility();
|
toggleVisibility();
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -43,7 +43,7 @@ export async function useTray(init: boolean = false, beforExit: Function) {
|
|||||||
tray.setMenu(
|
tray.setMenu(
|
||||||
await Menu.new({
|
await Menu.new({
|
||||||
id: "main",
|
id: "main",
|
||||||
items: await generateMenuItem(beforExit)
|
items: await generateMenuItem(beforExit),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ export async function useTray(init: boolean = false, beforExit: Function) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function generateMenuItem(beforExit: Function) {
|
export async function generateMenuItem(beforExit: Function) {
|
||||||
return [await MenuItemExit("退出", beforExit), await PredefinedMenuItem.new({ item: "Separator" }), await MenuItemShow("显示 / 隐藏")];
|
return [await MenuItemShow("显示 / 隐藏"), await PredefinedMenuItem.new({ item: "Separator" }), await MenuItemExit("退出", beforExit)];
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function MenuItemExit(text: string, beforExit: Function) {
|
export async function MenuItemExit(text: string, beforExit: Function) {
|
||||||
@@ -64,7 +64,7 @@ export async function MenuItemExit(text: string, beforExit: Function) {
|
|||||||
await beforExit();
|
await beforExit();
|
||||||
}
|
}
|
||||||
await getCurrentWindow().close();
|
await getCurrentWindow().close();
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ export async function MenuItemShow(text: string) {
|
|||||||
text,
|
text,
|
||||||
action: async () => {
|
action: async () => {
|
||||||
await toggleVisibility();
|
await toggleVisibility();
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,15 +92,14 @@ export async function MenuItemShow(text: string) {
|
|||||||
|
|
||||||
export async function setTrayRunState(tray: TrayIcon | null, isRunning: boolean = false) {
|
export async function setTrayRunState(tray: TrayIcon | null, isRunning: boolean = false) {
|
||||||
if (!tray) return;
|
if (!tray) return;
|
||||||
tray.setIcon(isRunning ? "icons/icon-inactive.ico" : "icons/icon.ico");
|
await tray.setIcon(isRunning ? "easytier/icons/icon-inactive.ico" : "easytier/icons/icon.ico");
|
||||||
}
|
}
|
||||||
|
|
||||||
// export async function setTrayTooltip(tooltip: string) {
|
export async function setTrayTooltip(tray: TrayIcon | null, tooltip?: string | null) {
|
||||||
// if (tooltip) {
|
if (!tray) return;
|
||||||
// const tray = await useTray()
|
if (tooltip) {
|
||||||
// if (!tray)
|
await tray.setTooltip(`EasyTier\n${pkg.version}\n${tooltip}`);
|
||||||
// return
|
} else {
|
||||||
// tray.setTooltip(`EasyTier\n${pkg.version}\n${tooltip}`)
|
await tray.setTooltip(`EasyTier\n${pkg.version}`);
|
||||||
// tray.setTitle(`EasyTier\n${pkg.version}\n${tooltip}`)
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
|
|||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
VITE_CONFIG_PATH=easytier/config/
|
||||||
|
VITE_LOG_PATH=easytier/logs/
|
||||||
|
VITE_AUTO_START_SERVICE_NAME=easytierGameAutoStart
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
VITE_CONFIG_PATH=easytier/config/
|
||||||
|
VITE_LOG_PATH=easytier/logs/
|
||||||
|
VITE_AUTO_START_SERVICE_NAME=easytierGameAutoStart
|
||||||
+3
-1
@@ -5,6 +5,8 @@
|
|||||||
<script setup lang="tsx">
|
<script setup lang="tsx">
|
||||||
//屏蔽右键菜单
|
//屏蔽右键菜单
|
||||||
document.addEventListener("contextmenu", (e: MouseEvent) => {
|
document.addEventListener("contextmenu", (e: MouseEvent) => {
|
||||||
// e.preventDefault();
|
if (import.meta.env.PROD) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ export default defineNuxtConfig({
|
|||||||
autoImport: false
|
autoImport: false
|
||||||
},
|
},
|
||||||
|
|
||||||
css: ["~/assets/css/main.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", "@nuxtjs/tailwindcss"],
|
||||||
|
|
||||||
alias: {
|
alias: {
|
||||||
|
|||||||
+4
-2
@@ -3,7 +3,7 @@
|
|||||||
"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.0.7",
|
"version": "1.1.2",
|
||||||
"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"
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
"@types/lodash-es": "^4.17.12",
|
"@types/lodash-es": "^4.17.12",
|
||||||
"@types/qs": "^6.9.15",
|
"@types/qs": "^6.9.15",
|
||||||
"@vitejs/plugin-vue-jsx": "^3.1.0",
|
"@vitejs/plugin-vue-jsx": "^3.1.0",
|
||||||
|
"@vueuse/core": "^11.2.0",
|
||||||
"dayjs": "^1.11.10",
|
"dayjs": "^1.11.10",
|
||||||
"defu": "^6.1.4",
|
"defu": "^6.1.4",
|
||||||
"element-plus": "^2.8.6",
|
"element-plus": "^2.8.6",
|
||||||
@@ -38,6 +39,7 @@
|
|||||||
"xlsx": "^0.18.5"
|
"xlsx": "^0.18.5"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tauri-apps/plugin-autostart": "~2"
|
"@tauri-apps/plugin-autostart": "~2",
|
||||||
|
"@tauri-apps/plugin-fs": "~2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+45
-3
@@ -1,26 +1,68 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="h-full overflow-auto flex flex-col items-start px-[25px]">
|
<div class="h-full overflow-auto flex flex-col items-start px-[25px]">
|
||||||
<div>
|
<div><ElCheckbox v-model="mainStore.config.disableIpv6">不使用IPv6</ElCheckbox></div>
|
||||||
<ElCheckbox v-model="mainStore.config.disableIpv6">不使用IPv6</ElCheckbox>
|
<div class="flex items-center gap-[10px]">
|
||||||
|
<ElCheckbox v-model="mainStore.config.devName">自定义网卡名</ElCheckbox>
|
||||||
|
<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">
|
||||||
|
<ElCheckbox v-model="mainStore.config.saveErrorLog">输出日志到本地</ElCheckbox>
|
||||||
|
<div class="w-[140px]">
|
||||||
|
<ElSelect
|
||||||
|
v-model="mainStore.config.logLevel"
|
||||||
|
placeholder="请选择日志等级"
|
||||||
|
class="ml-[5px]">
|
||||||
|
<ElOption
|
||||||
|
v-for="item in data"
|
||||||
|
:key="item"
|
||||||
|
:label="`level - ${item}`"
|
||||||
|
:value="item"></ElOption>
|
||||||
|
</ElSelect>
|
||||||
|
</div>
|
||||||
|
<ElButton
|
||||||
|
@click="openLogDir"
|
||||||
|
size="small">
|
||||||
|
打开日志目录
|
||||||
|
</ElButton>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
<div><ElCheckbox v-model="mainStore.config.multiThread">使用多线程运行时,默认为单线程</ElCheckbox></div>
|
<div><ElCheckbox v-model="mainStore.config.multiThread">使用多线程运行时,默认为单线程</ElCheckbox></div>
|
||||||
|
<ElDivider />
|
||||||
<div><ElCheckbox v-model="mainStore.config.noTun">不创建TUN设备,可以使用子网代理访问节点</ElCheckbox></div>
|
<div><ElCheckbox v-model="mainStore.config.noTun">不创建TUN设备,可以使用子网代理访问节点</ElCheckbox></div>
|
||||||
<div><ElCheckbox v-model="mainStore.config.useSmoltcp">为子网代理启用smoltcp堆栈</ElCheckbox></div>
|
<div><ElCheckbox v-model="mainStore.config.useSmoltcp">为子网代理启用smoltcp堆栈</ElCheckbox></div>
|
||||||
<div><ElCheckbox v-model="mainStore.config.latencyfirst">延迟优先模式,将尝试使用最低延迟路径转发流量,默认使用最短路径</ElCheckbox></div>
|
<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.disableUdpHolePunching">禁用UDP打洞功能</ElCheckbox></div>
|
||||||
<div>
|
<div>
|
||||||
<ElCheckbox v-model="mainStore.config.relayAllPeerrpc">转发所有对等节点的RPC数据包,即使对等节点不在转发网络白名</ElCheckbox>
|
<ElCheckbox v-model="mainStore.config.relayAllPeerrpc">转发所有对等节点的RPC数据包,即使对等节点不在转发网络白名单内</ElCheckbox>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import useMainStore from "@/stores/index";
|
import useMainStore from "@/stores/index";
|
||||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||||
|
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";
|
||||||
|
|
||||||
const mainStore = useMainStore();
|
const mainStore = useMainStore();
|
||||||
const appWindow = getCurrentWindow();
|
const appWindow = getCurrentWindow();
|
||||||
|
const data = ["trace", "debug", "info", "warn", "error", "off"];
|
||||||
|
const openLogDir = async () => {
|
||||||
|
const resourceDir = await getResourceDir();
|
||||||
|
const logPath = import.meta.env.VITE_LOG_PATH;
|
||||||
|
const logDirPath = await join(resourceDir, logPath);
|
||||||
|
const isExists = await exists(logPath, { baseDir: BaseDirectory.Resource });
|
||||||
|
if (!isExists) {
|
||||||
|
try {
|
||||||
|
await mkdir(logPath, { baseDir: BaseDirectory.Resource });
|
||||||
|
} catch (err) {}
|
||||||
|
}
|
||||||
|
await Command.create("explorer", [logDirPath]).execute();
|
||||||
|
};
|
||||||
mainStore.$subscribe((...a) => {
|
mainStore.$subscribe((...a) => {
|
||||||
// console.log("subscribe", a);
|
// console.log("subscribe", a);
|
||||||
appWindow.emitTo("main", "config", { config: { ...mainStore.config } });
|
appWindow.emitTo("main", "config", { config: { ...mainStore.config } });
|
||||||
|
|||||||
+258
-75
@@ -2,36 +2,42 @@
|
|||||||
<ElForm
|
<ElForm
|
||||||
size="small"
|
size="small"
|
||||||
label-position="top"
|
label-position="top"
|
||||||
:model="config">
|
:model="config"
|
||||||
|
>
|
||||||
<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"
|
||||||
core-{{ data.coreVersion }}
|
>
|
||||||
|
{{ data.coreVersion }}
|
||||||
</ElTag>
|
</ElTag>
|
||||||
<ElButton
|
<ElButton
|
||||||
:disabled="data.isStart"
|
:disabled="data.isStart"
|
||||||
:loading="data.update"
|
:loading="data.update"
|
||||||
type="warning"
|
type="warning"
|
||||||
@click="handleUpdateCore"
|
@click="handleUpdateCore"
|
||||||
size="small">
|
size="small"
|
||||||
{{ data.coreVersion ? "更新" : "下载" }}
|
>
|
||||||
|
{{ data.coreVersion ? "更新插件" : "下载插件" }}
|
||||||
</ElButton>
|
</ElButton>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -40,7 +46,8 @@
|
|||||||
filterable
|
filterable
|
||||||
default-first-option
|
default-first-option
|
||||||
v-model="config.serverUrl"
|
v-model="config.serverUrl"
|
||||||
@change="handleServerUrlChange">
|
@change="handleServerUrlChange"
|
||||||
|
>
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<div :class="config.protocol && config.protocol.length > 1 ? 'w-[120px]' : 'w-[80px]'">
|
<div :class="config.protocol && config.protocol.length > 1 ? 'w-[120px]' : 'w-[80px]'">
|
||||||
<ElSelect
|
<ElSelect
|
||||||
@@ -49,12 +56,14 @@
|
|||||||
collapse-tags
|
collapse-tags
|
||||||
@click.stop
|
@click.stop
|
||||||
v-model="config.protocol"
|
v-model="config.protocol"
|
||||||
@change="handleServerUrlChange">
|
@change="handleServerUrlChange"
|
||||||
|
>
|
||||||
<ElOption
|
<ElOption
|
||||||
v-for="item in protocols"
|
v-for="item in protocols"
|
||||||
:key="item"
|
:key="item"
|
||||||
:label="item"
|
:label="item"
|
||||||
:value="item"></ElOption>
|
:value="item"
|
||||||
|
></ElOption>
|
||||||
</ElSelect>
|
</ElSelect>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -62,14 +71,16 @@
|
|||||||
v-for="item in mainStore.basePeers"
|
v-for="item in mainStore.basePeers"
|
||||||
:key="item"
|
:key="item"
|
||||||
:label="item"
|
:label="item"
|
||||||
:value="item">
|
:value="item"
|
||||||
|
>
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<span style="float: left">{{ item }}</span>
|
<span style="float: left">{{ item }}</span>
|
||||||
<ElButton
|
<ElButton
|
||||||
@click.stop="handleDeleteServerUrl(item)"
|
@click.stop="handleDeleteServerUrl(item)"
|
||||||
round
|
round
|
||||||
:icon="Delete"
|
:icon="Delete"
|
||||||
type="danger"></ElButton>
|
type="danger"
|
||||||
|
></ElButton>
|
||||||
</div>
|
</div>
|
||||||
</ElOption>
|
</ElOption>
|
||||||
</ElSelect>
|
</ElSelect>
|
||||||
@@ -88,7 +99,8 @@
|
|||||||
<ElInput
|
<ElInput
|
||||||
maxlength="100"
|
maxlength="100"
|
||||||
placeholder="请输入网络名"
|
placeholder="请输入网络名"
|
||||||
v-model="config.networkName"></ElInput>
|
v-model="config.networkName"
|
||||||
|
></ElInput>
|
||||||
</ElFormItem>
|
</ElFormItem>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-1">
|
<div class="flex-1">
|
||||||
@@ -106,7 +118,8 @@
|
|||||||
maxlength="100"
|
maxlength="100"
|
||||||
placeholder="请输入网络密码"
|
placeholder="请输入网络密码"
|
||||||
v-model="config.networkPassword"
|
v-model="config.networkPassword"
|
||||||
type="password"></ElInput>
|
type="password"
|
||||||
|
></ElInput>
|
||||||
</ElFormItem>
|
</ElFormItem>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -123,11 +136,13 @@
|
|||||||
<ElInput
|
<ElInput
|
||||||
maxlength="100"
|
maxlength="100"
|
||||||
placeholder="例如: Player1"
|
placeholder="例如: Player1"
|
||||||
v-model="config.hostname"></ElInput>
|
v-model="config.hostname"
|
||||||
|
></ElInput>
|
||||||
</ElFormItem>
|
</ElFormItem>
|
||||||
<ElFormItem
|
<ElFormItem
|
||||||
class="w-[70%]"
|
class="w-[70%]"
|
||||||
label="局域网IP">
|
label="局域网IP"
|
||||||
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
<div class="flex items-center h-[20px]">
|
<div class="flex items-center h-[20px]">
|
||||||
虚拟网IP
|
虚拟网IP
|
||||||
@@ -140,87 +155,96 @@
|
|||||||
inline-prompt
|
inline-prompt
|
||||||
inactive-text="固定IP"
|
inactive-text="固定IP"
|
||||||
active-text="动态获取IP"
|
active-text="动态获取IP"
|
||||||
size="small"></ElSwitch>
|
size="small"
|
||||||
|
></ElSwitch>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<ElInput
|
<ElInput
|
||||||
maxlength="100"
|
maxlength="100"
|
||||||
:disabled="config.dhcp"
|
:disabled="config.dhcp"
|
||||||
:placeholder="data.isStart ? '等待动态分配IP...' : '例如: 10.126.126.1'"
|
:placeholder="data.isStart ? '等待动态分配IP...' : '例如: 10.126.126.1'"
|
||||||
v-model="config.ipv4"></ElInput>
|
v-model="config.ipv4"
|
||||||
|
></ElInput>
|
||||||
</ElFormItem>
|
</ElFormItem>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-start gap-[0_30px]">
|
<div class="flex items-start gap-[0_10px]">
|
||||||
<div class="w-[95px]">
|
<div class="w-[122px]">
|
||||||
<div>
|
<div>
|
||||||
<ElButton
|
<ElDropdown
|
||||||
|
@command="handleStartCommand"
|
||||||
|
split-button
|
||||||
|
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"
|
||||||
@click="handleConnection"
|
@click="handleConnection"
|
||||||
size="default">
|
>
|
||||||
{{ !data.isStart ? "启动联机" : "停止联机" }}
|
{{ !data.isStart ? "启动联机" : "停止联机" }}
|
||||||
</ElButton>
|
<template #dropdown>
|
||||||
|
<ElDropdownMenu>
|
||||||
|
<ElDropdownItem
|
||||||
|
command="toml"
|
||||||
|
:disabled="data.isStart"
|
||||||
|
>
|
||||||
|
配置文件启动
|
||||||
|
</ElDropdownItem>
|
||||||
|
</ElDropdownMenu>
|
||||||
|
</template>
|
||||||
|
</ElDropdown>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-[6px] pl-[2px]">
|
<div class="mt-[6px] pl-[2px]">
|
||||||
<!-- <ElButtonGroup> -->
|
|
||||||
<ElTooltip
|
<ElTooltip
|
||||||
placement="left"
|
placement="left"
|
||||||
content="日志">
|
content="日志"
|
||||||
|
>
|
||||||
<ElButton
|
<ElButton
|
||||||
:type="!data.logVisible ? 'info' : 'warning'"
|
:type="!data.logVisible ? 'info' : 'warning'"
|
||||||
@click="handleShowLogDialog"
|
@click="handleShowLogDialog"
|
||||||
:icon="List"
|
:icon="List"
|
||||||
size="small"
|
size="small"
|
||||||
plain></ElButton>
|
plain
|
||||||
|
></ElButton>
|
||||||
</ElTooltip>
|
</ElTooltip>
|
||||||
<ElTooltip
|
<ElTooltip
|
||||||
placement="left"
|
placement="left"
|
||||||
content="成员">
|
content="成员"
|
||||||
|
>
|
||||||
<ElButton
|
<ElButton
|
||||||
@click="handleShowMemberDialog"
|
@click="handleShowMemberDialog"
|
||||||
:icon="UserFilled"
|
:icon="UserFilled"
|
||||||
plain
|
plain
|
||||||
type="success"
|
type="success"
|
||||||
size="small"></ElButton>
|
size="small"
|
||||||
|
></ElButton>
|
||||||
</ElTooltip>
|
</ElTooltip>
|
||||||
<!-- </ElButtonGroup> -->
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<ElCheckbox
|
<ElCheckbox
|
||||||
v-model="config.disbleP2p"
|
v-model="config.disbleP2p"
|
||||||
size="small">
|
|
||||||
强制中转
|
|
||||||
</ElCheckbox>
|
|
||||||
<!-- <ElCheckbox
|
|
||||||
v-model="config.disableIpv6"
|
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
禁用ipv6
|
强制中转
|
||||||
</ElCheckbox> -->
|
</ElCheckbox>
|
||||||
<ElCheckbox
|
<ElCheckbox
|
||||||
@change="handleAutoStart"
|
@change="handleAutoStart"
|
||||||
:model-value="config.autoStart"
|
:model-value="config.autoStart"
|
||||||
size="small">
|
|
||||||
开机自启
|
|
||||||
</ElCheckbox>
|
|
||||||
<!-- <ElCheckbox
|
|
||||||
v-model="config.disbleListenner"
|
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
禁用端口监听
|
开机自启
|
||||||
</ElCheckbox> -->
|
</ElCheckbox>
|
||||||
<div>
|
<div>
|
||||||
<ElButton
|
<ElButton
|
||||||
@click="handleShowCidrDialog"
|
@click="handleShowCidrDialog"
|
||||||
:icon="Share"
|
:icon="Share"
|
||||||
>子网代理</ElButton
|
|
||||||
>
|
>
|
||||||
|
子网代理
|
||||||
|
</ElButton>
|
||||||
<ElButton
|
<ElButton
|
||||||
@click="handleShowAdvanceDialog"
|
@click="handleShowAdvanceDialog"
|
||||||
:icon="Setting"
|
:icon="Setting"
|
||||||
>高级选项</ElButton
|
|
||||||
>
|
>
|
||||||
|
高级选项
|
||||||
|
</ElButton>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-[0_5px]">
|
<div class="flex items-center gap-[0_5px]">
|
||||||
<div>
|
<div>
|
||||||
@@ -228,7 +252,8 @@
|
|||||||
class="!text-[11px]"
|
class="!text-[11px]"
|
||||||
type="info"
|
type="info"
|
||||||
:underline="false"
|
:underline="false"
|
||||||
@click="open('https://github.com/dechamps/WinIPBroadcast/releases/tag/winipbroadcast-1.6')">
|
@click="open('https://github.com/dechamps/WinIPBroadcast/releases/tag/winipbroadcast-1.6')"
|
||||||
|
>
|
||||||
WinIPBroadcast
|
WinIPBroadcast
|
||||||
<ElTooltip content="找不到游戏房间时,就开启它后再刷新尝试(默认开启)">
|
<ElTooltip content="找不到游戏房间时,就开启它后再刷新尝试(默认开启)">
|
||||||
<ElIcon class="ml-[3px]"><QuestionFilled /></ElIcon>
|
<ElIcon class="ml-[3px]"><QuestionFilled /></ElIcon>
|
||||||
@@ -241,33 +266,88 @@
|
|||||||
size="small"
|
size="small"
|
||||||
label="WinIPBroadcast"
|
label="WinIPBroadcast"
|
||||||
active-text="开启"
|
active-text="开启"
|
||||||
inactive-text="关闭"></ElSwitch>
|
inactive-text="关闭"
|
||||||
|
></ElSwitch>
|
||||||
</div>
|
</div>
|
||||||
<ElLink
|
<ElLink
|
||||||
class="!text-[11px] pb-[2px] ml-[15px]"
|
class="!text-[11px] pb-[2px] ml-[15px]"
|
||||||
type="info"
|
type="info"
|
||||||
:underline="false"
|
:underline="false"
|
||||||
@click="open('https://github.com/EasyTier/EasytierGame')">
|
@click="open('https://github.com/EasyTier/EasytierGame')"
|
||||||
|
>
|
||||||
主页
|
主页
|
||||||
</ElLink>
|
</ElLink>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ElForm>
|
</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>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { listen } from "@tauri-apps/api/event";
|
import { listen } from "@tauri-apps/api/event";
|
||||||
import { open, Command } from "@tauri-apps/plugin-shell";
|
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 { reactive, onBeforeUnmount, onMounted } from "vue";
|
||||||
import { useTray, setTrayRunState } from "~/composables/tray";
|
import { useTray, setTrayRunState, setTrayTooltip } from "~/composables/tray";
|
||||||
import useMainStore from "@/stores/index";
|
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 { 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 { readDir, exists, mkdir, BaseDirectory } from "@tauri-apps/plugin-fs";
|
||||||
|
|
||||||
let is_close = false;
|
let is_close = false;
|
||||||
|
|
||||||
@@ -294,15 +374,22 @@
|
|||||||
coreVersion: "",
|
coreVersion: "",
|
||||||
isSuccessGetIp: false,
|
isSuccessGetIp: false,
|
||||||
startLoading: false,
|
startLoading: false,
|
||||||
isStart: false,
|
isStart: false
|
||||||
|
});
|
||||||
|
|
||||||
|
const configStart = reactive<{ list: Array<{ path: string; name: string }>; [key: string]: any }>({
|
||||||
|
visible: false,
|
||||||
|
loading: false,
|
||||||
|
list: [] //配置文件列表
|
||||||
});
|
});
|
||||||
|
|
||||||
const closePrevent = async () => {
|
const closePrevent = async () => {
|
||||||
const appWindow = getCurrentWindow();
|
const appWindow = getCurrentWindow();
|
||||||
if (appWindow.label == "main") {
|
if (appWindow.label == "main") {
|
||||||
appWindow.onCloseRequested(async (event) => {
|
appWindow.onCloseRequested(async event => {
|
||||||
console.log(appWindow.label);
|
// console.log(appWindow.label);
|
||||||
if (!is_close) {
|
if (!is_close) {
|
||||||
|
// console.log(1);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
appWindow.hide();
|
appWindow.hide();
|
||||||
}
|
}
|
||||||
@@ -333,7 +420,7 @@
|
|||||||
thread_id: null,
|
thread_id: null,
|
||||||
async listenOutput() {
|
async listenOutput() {
|
||||||
const appWindow = getCurrentWindow();
|
const appWindow = getCurrentWindow();
|
||||||
const unListen = await listen("command-output", async (event) => {
|
const unListen = await listen("command-output", async event => {
|
||||||
data.isStart = true;
|
data.isStart = true;
|
||||||
if (event.payload) {
|
if (event.payload) {
|
||||||
data.startLoading = false;
|
data.startLoading = false;
|
||||||
@@ -342,6 +429,7 @@
|
|||||||
data.isSuccessGetIp = true;
|
data.isSuccessGetIp = true;
|
||||||
await setTrayRunState(tray, true);
|
await setTrayRunState(tray, true);
|
||||||
config.ipv4 = ipv4;
|
config.ipv4 = ipv4;
|
||||||
|
await setTrayTooltip(tray, `IP: ${ipv4}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
appWindow.emitTo("log", "logs", data.log);
|
appWindow.emitTo("log", "logs", data.log);
|
||||||
@@ -350,7 +438,7 @@
|
|||||||
this.unListenOutPut = unListen;
|
this.unListenOutPut = unListen;
|
||||||
},
|
},
|
||||||
async listenThreadId() {
|
async listenThreadId() {
|
||||||
const unListen = await listen("thread-id", (event) => {
|
const unListen = await listen("thread-id", event => {
|
||||||
if (event.payload) {
|
if (event.payload) {
|
||||||
this.thread_id = event.payload;
|
this.thread_id = event.payload;
|
||||||
}
|
}
|
||||||
@@ -358,14 +446,14 @@
|
|||||||
this.unListenThreadId = unListen;
|
this.unListenThreadId = unListen;
|
||||||
},
|
},
|
||||||
async listenConfigStart() {
|
async listenConfigStart() {
|
||||||
const unListen = await listen("config", (event) => {
|
const unListen = await listen("config", event => {
|
||||||
// console.log("config", event.payload);
|
// console.log("config", event.payload);
|
||||||
const ipv4 = config.ipv4;
|
const ipv4 = config.ipv4;
|
||||||
mainStore.$patch(event.payload);
|
mainStore.$patch(event.payload as any);
|
||||||
config.ipv4 = ipv4;
|
config.ipv4 = ipv4;
|
||||||
});
|
});
|
||||||
this.unListenConfigStart = unListen;
|
this.unListenConfigStart = unListen;
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const unListenAll = async () => {
|
const unListenAll = async () => {
|
||||||
@@ -499,15 +587,47 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleAutoStartByTask = async () => {
|
||||||
|
await invoke("spawn_autostart", { enabled: !config.autoStart });
|
||||||
|
const is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean;
|
||||||
|
config.autoStart = is_enable_by_task;
|
||||||
|
};
|
||||||
|
|
||||||
|
const compatibleInitAutoStart = async () => {
|
||||||
|
try {
|
||||||
|
const is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean;
|
||||||
|
if (is_enable_by_task) {
|
||||||
|
await tauriAutoStart.enable();
|
||||||
|
await invoke("spawn_autostart", { enabled: false });
|
||||||
|
}
|
||||||
|
const is_enable = await tauriAutoStart.isEnabled();
|
||||||
|
config.autoStart = is_enable;
|
||||||
|
} catch (err) {
|
||||||
|
await invoke("spawn_autostart", { enabled: false });
|
||||||
|
await tauriAutoStart.disable();
|
||||||
|
config.autoStart = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const initConnectAfterStart = async () => {
|
||||||
|
if (config.coonectAfterStart && data.coreVersion) {
|
||||||
|
await reset();
|
||||||
|
await handleConnection();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let logsTimer: NodeJS.Timeout | null = null;
|
let logsTimer: NodeJS.Timeout | null = null;
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// await handleUpdateCore(); //默认不自动更新
|
// await handleUpdateCore(); //默认不自动更新
|
||||||
await initAutoStart();
|
await compatibleInitAutoStart();
|
||||||
|
// await initAutoStart();
|
||||||
await initStartWinIpBroadcast();
|
await initStartWinIpBroadcast();
|
||||||
await getCoreVersion();
|
await getCoreVersion();
|
||||||
await listenObj.listenThreadId();
|
await listenObj.listenThreadId();
|
||||||
await listenObj.listenConfigStart();
|
await listenObj.listenConfigStart();
|
||||||
|
await initConfigDir();
|
||||||
|
await initConnectAfterStart();
|
||||||
closePrevent();
|
closePrevent();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -518,9 +638,17 @@
|
|||||||
logsTimer && clearInterval(logsTimer);
|
logsTimer && clearInterval(logsTimer);
|
||||||
});
|
});
|
||||||
|
|
||||||
const getArgs = () => {
|
const getArgs = async () => {
|
||||||
// console.log(config.proxyNetworks);
|
// console.log(config.proxyNetworks);
|
||||||
const args = [];
|
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) {
|
if (config.dhcp) {
|
||||||
args.push("-d");
|
args.push("-d");
|
||||||
}
|
}
|
||||||
@@ -538,7 +666,7 @@
|
|||||||
}
|
}
|
||||||
if (config.serverUrl) {
|
if (config.serverUrl) {
|
||||||
const formatUrl = config.serverUrl.replace(/\\/g, "/");
|
const formatUrl = config.serverUrl.replace(/\\/g, "/");
|
||||||
args.push("--peers", ...config.protocol.map((protocol) => `${protocol}://${formatUrl}`));
|
args.push("--peers", ...config.protocol.map(protocol => `${protocol}://${formatUrl}`));
|
||||||
}
|
}
|
||||||
if (config.disbleP2p) {
|
if (config.disbleP2p) {
|
||||||
args.push("--disable-p2p");
|
args.push("--disable-p2p");
|
||||||
@@ -554,8 +682,8 @@
|
|||||||
const reg = /\d+\.\d+\.\d+\.\d+\/\d+/g;
|
const reg = /\d+\.\d+\.\d+\.\d+\/\d+/g;
|
||||||
const formatProxyNetworks = config.proxyNetworks
|
const formatProxyNetworks = config.proxyNetworks
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.map((item) => item.trim())
|
.map(item => item.trim())
|
||||||
.filter((item) => item && reg.test(item));
|
.filter(item => item && reg.test(item));
|
||||||
args.push("--proxy-networks", ...formatProxyNetworks);
|
args.push("--proxy-networks", ...formatProxyNetworks);
|
||||||
config.proxyNetworks = formatProxyNetworks.join("\n");
|
config.proxyNetworks = formatProxyNetworks.join("\n");
|
||||||
}
|
}
|
||||||
@@ -583,6 +711,12 @@
|
|||||||
if (config.relayAllPeerrpc) {
|
if (config.relayAllPeerrpc) {
|
||||||
args.push("--relay-all-peer-rpc");
|
args.push("--relay-all-peer-rpc");
|
||||||
}
|
}
|
||||||
|
if (config.saveErrorLog) {
|
||||||
|
args.push("--file-log-level", config.logLevel, "--file-log-dir", import.meta.env.VITE_LOG_PATH);
|
||||||
|
}
|
||||||
|
if(config.devName && config.devNameValue) {
|
||||||
|
args.push("--dev-name", config.devNameValue);
|
||||||
|
}
|
||||||
return args;
|
return args;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -593,7 +727,7 @@
|
|||||||
config.ipv4 = "";
|
config.ipv4 = "";
|
||||||
}
|
}
|
||||||
const memberDialog = await getAllWebviewWindows();
|
const memberDialog = await getAllWebviewWindows();
|
||||||
const memberDialogs = memberDialog.filter((item) => item.label === "member");
|
const memberDialogs = memberDialog.filter(item => item.label === "member");
|
||||||
if (memberDialogs && memberDialogs.length > 0) {
|
if (memberDialogs && memberDialogs.length > 0) {
|
||||||
data.memberVisible = false;
|
data.memberVisible = false;
|
||||||
for (const memberDialog of memberDialogs) {
|
for (const memberDialog of memberDialogs) {
|
||||||
@@ -604,6 +738,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
await setTrayRunState(tray, false);
|
await setTrayRunState(tray, false);
|
||||||
|
await setTrayTooltip(tray);
|
||||||
await unListenAll();
|
await unListenAll();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -611,17 +746,65 @@
|
|||||||
if (data.isStart) {
|
if (data.isStart) {
|
||||||
await reset();
|
await reset();
|
||||||
} else {
|
} else {
|
||||||
|
const args = await getArgs();
|
||||||
|
|
||||||
|
if (!args || args.length <= 0) {
|
||||||
|
return ElMessage.error("无配置");
|
||||||
|
}
|
||||||
data.log = ""; //清空日志
|
data.log = ""; //清空日志
|
||||||
data.startLoading = true;
|
data.startLoading = true;
|
||||||
await unListenAll();
|
await unListenAll();
|
||||||
await listenObj.listenOutput();
|
await listenObj.listenOutput();
|
||||||
const args = getArgs();
|
|
||||||
await invoke("run_command", {
|
await invoke("run_command", {
|
||||||
args,
|
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 () => {
|
const handleShowMemberDialog = async () => {
|
||||||
if (!data.isStart) {
|
if (!data.isStart) {
|
||||||
return ElMessage.warning("请先开始联机");
|
return ElMessage.warning("请先开始联机");
|
||||||
@@ -636,7 +819,7 @@
|
|||||||
title: "成员列表",
|
title: "成员列表",
|
||||||
width: 470,
|
width: 470,
|
||||||
height: 380,
|
height: 380,
|
||||||
url: "#/member",
|
url: "#/member"
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
data.memberVisible = true;
|
data.memberVisible = true;
|
||||||
@@ -651,18 +834,18 @@
|
|||||||
await etWindows(
|
await etWindows(
|
||||||
"log",
|
"log",
|
||||||
{
|
{
|
||||||
title: "日志",
|
title: "联机日志",
|
||||||
width: 600,
|
width: 600,
|
||||||
height: 380,
|
height: 380,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
url: "#/log",
|
url: "#/log"
|
||||||
},
|
},
|
||||||
(_, appWindow) => {
|
(_, appWindow) => {
|
||||||
data.logVisible = true;
|
data.logVisible = true;
|
||||||
logsTimer && clearInterval(logsTimer);
|
logsTimer && clearInterval(logsTimer);
|
||||||
logsTimer = setInterval(() => {
|
logsTimer = setInterval(() => {
|
||||||
appWindow.emitTo("log", "logs", data.log);
|
appWindow.emitTo("log", "logs", data.log);
|
||||||
}, 3000);
|
}, 600);
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
data.logVisible = false;
|
data.logVisible = false;
|
||||||
@@ -678,7 +861,7 @@
|
|||||||
width: 600,
|
width: 600,
|
||||||
height: 380,
|
height: 380,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
url: "#/cidr",
|
url: "#/cidr"
|
||||||
},
|
},
|
||||||
(_, appWindow) => {
|
(_, appWindow) => {
|
||||||
data.cidrVisible = true;
|
data.cidrVisible = true;
|
||||||
@@ -697,7 +880,7 @@
|
|||||||
width: 600,
|
width: 600,
|
||||||
height: 380,
|
height: 380,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
url: "#/advance",
|
url: "#/advance"
|
||||||
},
|
},
|
||||||
(_, appWindow) => {
|
(_, appWindow) => {
|
||||||
data.advanceVisible = true;
|
data.advanceVisible = true;
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
v-model="data.log"
|
v-model="data.log"
|
||||||
resize="none"
|
resize="none"
|
||||||
readonly
|
readonly
|
||||||
placeholder="等待日志中..."
|
placeholder="等待日志中,请先'启动联机'..."
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|||||||
+11
-128
@@ -33,6 +33,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { reactive, onMounted, onBeforeUnmount } from "vue";
|
import { reactive, onMounted, onBeforeUnmount } from "vue";
|
||||||
|
import { parsePeerInfo } from "@/utils";
|
||||||
const data = reactive<{ member: any[] }>({
|
const data = reactive<{ member: any[] }>({
|
||||||
member: []
|
member: []
|
||||||
});
|
});
|
||||||
@@ -45,137 +46,19 @@
|
|||||||
["loss_rate", "丢包率"],
|
["loss_rate", "丢包率"],
|
||||||
["version", "版本"]
|
["version", "版本"]
|
||||||
];
|
];
|
||||||
const headers = [
|
|
||||||
"ipv4",
|
|
||||||
"hostname",
|
|
||||||
"cost",
|
|
||||||
"lat_ms",
|
|
||||||
"loss_rate",
|
|
||||||
"rx_bytes",
|
|
||||||
"rx_unit",
|
|
||||||
"tx_bytes",
|
|
||||||
"tx_unit",
|
|
||||||
"tunnel_proto",
|
|
||||||
"nat_type",
|
|
||||||
"id",
|
|
||||||
"version"
|
|
||||||
];
|
|
||||||
|
|
||||||
const formatData = (data: any[]) => {
|
|
||||||
if (!data) return [];
|
|
||||||
const result = [];
|
|
||||||
let obj: any = {};
|
|
||||||
let length = data.length;
|
|
||||||
for (let idx = 0; idx < length; idx++) {
|
|
||||||
let headersIdx = idx % headers.length;
|
|
||||||
if (headersIdx === 0) {
|
|
||||||
// console.log(idx, [...data]);
|
|
||||||
obj = {};
|
|
||||||
result.push(obj);
|
|
||||||
}
|
|
||||||
if (["ipv4"].includes(headers[headersIdx]) && !/\d+\.\d+\.\d+\.\d\/\d+/.test(data[idx]) && data[idx]) {
|
|
||||||
const next = data[idx];
|
|
||||||
data[idx] = "-";
|
|
||||||
const head = data.slice(0, idx);
|
|
||||||
const latest = data.slice(idx);
|
|
||||||
data = [...head, next, ...latest];
|
|
||||||
length = data.length;
|
|
||||||
} else if (["rx_bytes", "tx_bytes"].includes(headers[headersIdx]) && data[idx] == "-") {
|
|
||||||
const head = data.slice(0, idx);
|
|
||||||
const latest = data.slice(idx);
|
|
||||||
data = [...head, "-", ...latest];
|
|
||||||
length = data.length;
|
|
||||||
} else if (
|
|
||||||
["tunnel_proto"].includes(headers[headersIdx]) &&
|
|
||||||
![
|
|
||||||
"tcp",
|
|
||||||
"udp",
|
|
||||||
"ws",
|
|
||||||
"wss",
|
|
||||||
"wg",
|
|
||||||
"-",
|
|
||||||
"tcp,udp",
|
|
||||||
"ws,wss",
|
|
||||||
"tcp,udp,ws,wss,wg",
|
|
||||||
"tcp,ws,wss,wg",
|
|
||||||
"udp,ws,wss,wg",
|
|
||||||
"tcp,wg",
|
|
||||||
"udp,wg",
|
|
||||||
"tcp,ws",
|
|
||||||
"tcp,wss",
|
|
||||||
"udp,ws",
|
|
||||||
"udp,wss",
|
|
||||||
"tcp,udp,ws",
|
|
||||||
"tcp,udp,wss",
|
|
||||||
"tcp,udp,ws,wss",
|
|
||||||
"tcp,udp,ws,wss,wg",
|
|
||||||
"tcp,udp,wg",
|
|
||||||
"tcp,udp,ws,wg",
|
|
||||||
"udp,tcp",
|
|
||||||
"udp,tcp,ws",
|
|
||||||
"udp,tcp,wss",
|
|
||||||
"udp,tcp,ws,wss",
|
|
||||||
"udp,tcp,ws,wss,wg",
|
|
||||||
"udp,tcp,wg",
|
|
||||||
"udp,tcp,ws,wg",
|
|
||||||
"tcp,udp,wss,wg",
|
|
||||||
"tcp,udp,ws,wg",
|
|
||||||
"tcp,udp,wss,wg",
|
|
||||||
"ws,tcp",
|
|
||||||
"ws,udp",
|
|
||||||
"ws,tcp,udp",
|
|
||||||
"ws,tcp,udp,ws",
|
|
||||||
"ws,tcp,udp,wss",
|
|
||||||
"ws,tcp,udp,ws,wss",
|
|
||||||
"ws,tcp,udp,ws,wss,wg",
|
|
||||||
"ws,tcp,udp,wg",
|
|
||||||
"ws,tcp,udp,ws,wg",
|
|
||||||
"ws,udp,tcp",
|
|
||||||
"ws,udp,tcp,ws",
|
|
||||||
"ws,udp,tcp,wss",
|
|
||||||
"ws,udp,tcp,ws,wss",
|
|
||||||
"wss,tcp",
|
|
||||||
"wss,udp",
|
|
||||||
"wss,tcp,udp",
|
|
||||||
"wss,tcp,udp,ws",
|
|
||||||
"wss,tcp,udp,wss",
|
|
||||||
"wss,tcp,udp,ws,wss",
|
|
||||||
"wss,tcp,udp,ws,wss,wg",
|
|
||||||
"wss,tcp,udp,wg",
|
|
||||||
"wg,tcp",
|
|
||||||
"wg,udp",
|
|
||||||
"wg,tcp,udp",
|
|
||||||
"wg,tcp,udp,ws",
|
|
||||||
"wg,tcp,udp,wss",
|
|
||||||
"wg,tcp,udp,ws,wss",
|
|
||||||
"wg,tcp,udp,ws,wss,wg",
|
|
||||||
"wg,tcp,udp,wg",
|
|
||||||
"wg,udp,tcp"
|
|
||||||
].includes(data[idx])
|
|
||||||
) {
|
|
||||||
const head = data.slice(0, idx);
|
|
||||||
const latest = data.slice(idx);
|
|
||||||
data = [...head, "-", ...latest];
|
|
||||||
length = data.length;
|
|
||||||
}
|
|
||||||
obj[headers[headersIdx]] = data[idx];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
const listenOutput = async () => {
|
const listenOutput = async () => {
|
||||||
const member = await invoke("get_members_by_cli");
|
const member = await invoke("get_members_by_cli");
|
||||||
let memberData = ((member as string) || "")
|
const peerInfo = parsePeerInfo(member as string);
|
||||||
.replace(/[\│\├\┌\└\─\┬\┴\┼\┤\┐\┘]+/g, "")
|
peerInfo.forEach(value => {
|
||||||
.split(" ")
|
if (value.cost === "Local") {
|
||||||
.filter(el => el && !["\n", "\n\n"].includes(el))
|
value.cost = "本机";
|
||||||
.slice(11);
|
}
|
||||||
if (memberData.length <= 0) {
|
if (value.ipv4 && value.ipv4.includes("/")) {
|
||||||
return;
|
value.ipv4 = value.ipv4.split("/")[0];
|
||||||
}
|
}
|
||||||
const result = formatData(memberData);
|
});
|
||||||
data.member = result;
|
data.member = peerInfo;
|
||||||
// console.log({ member: data.member });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let timer: NodeJS.Timeout | null = null;
|
let timer: NodeJS.Timeout | null = null;
|
||||||
|
|||||||
Generated
+56
@@ -11,6 +11,9 @@ importers:
|
|||||||
'@tauri-apps/plugin-autostart':
|
'@tauri-apps/plugin-autostart':
|
||||||
specifier: ~2
|
specifier: ~2
|
||||||
version: 2.0.0
|
version: 2.0.0
|
||||||
|
'@tauri-apps/plugin-fs':
|
||||||
|
specifier: ~2
|
||||||
|
version: 2.0.1
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@element-plus/icons-vue':
|
'@element-plus/icons-vue':
|
||||||
specifier: ^2.3.1
|
specifier: ^2.3.1
|
||||||
@@ -54,6 +57,9 @@ importers:
|
|||||||
'@vitejs/plugin-vue-jsx':
|
'@vitejs/plugin-vue-jsx':
|
||||||
specifier: ^3.1.0
|
specifier: ^3.1.0
|
||||||
version: 3.1.0(vite@5.2.10(@types/node@20.12.7)(less@4.2.0)(terser@5.30.4))(vue@3.4.24(typescript@5.4.5))
|
version: 3.1.0(vite@5.2.10(@types/node@20.12.7)(less@4.2.0)(terser@5.30.4))(vue@3.4.24(typescript@5.4.5))
|
||||||
|
'@vueuse/core':
|
||||||
|
specifier: ^11.2.0
|
||||||
|
version: 11.2.0(vue@3.4.24(typescript@5.4.5))
|
||||||
dayjs:
|
dayjs:
|
||||||
specifier: ^1.11.10
|
specifier: ^1.11.10
|
||||||
version: 1.11.10
|
version: 1.11.10
|
||||||
@@ -1008,6 +1014,9 @@ packages:
|
|||||||
'@tauri-apps/plugin-cli@2.0.0':
|
'@tauri-apps/plugin-cli@2.0.0':
|
||||||
resolution: {integrity: sha512-glQmlL1IiCGEa1FHYa/PTPSeYhfu56omLRgHXWlJECDt6DbJyRuJWVgtkQfUxtqnVdYnnU+DGIGeiInoEqtjLw==}
|
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':
|
'@tauri-apps/plugin-http@2.0.0':
|
||||||
resolution: {integrity: sha512-UfKAICL25ayluV/SjiEQujz8q/2uyAzp3u9uaHFkaIyKS5usBL8DoqSwi4eKz2mEjkbxTwldhDEXG4CEfTE0JQ==}
|
resolution: {integrity: sha512-UfKAICL25ayluV/SjiEQujz8q/2uyAzp3u9uaHFkaIyKS5usBL8DoqSwi4eKz2mEjkbxTwldhDEXG4CEfTE0JQ==}
|
||||||
|
|
||||||
@@ -1282,6 +1291,9 @@ packages:
|
|||||||
'@vueuse/core@10.9.0':
|
'@vueuse/core@10.9.0':
|
||||||
resolution: {integrity: sha512-/1vjTol8SXnx6xewDEKfS0Ra//ncg4Hb0DaZiwKf7drgfMsKFExQ+FnnENcN6efPen+1kIzhLQoGSy0eDUVOMg==}
|
resolution: {integrity: sha512-/1vjTol8SXnx6xewDEKfS0Ra//ncg4Hb0DaZiwKf7drgfMsKFExQ+FnnENcN6efPen+1kIzhLQoGSy0eDUVOMg==}
|
||||||
|
|
||||||
|
'@vueuse/core@11.2.0':
|
||||||
|
resolution: {integrity: sha512-JIUwRcOqOWzcdu1dGlfW04kaJhW3EXnnjJJfLTtddJanymTL7lF1C0+dVVZ/siLfc73mWn+cGP1PE1PKPruRSA==}
|
||||||
|
|
||||||
'@vueuse/core@9.13.0':
|
'@vueuse/core@9.13.0':
|
||||||
resolution: {integrity: sha512-pujnclbeHWxxPRqXWmdkKV5OX4Wk4YeK7wusHqRwU0Q7EFusHoqNA/aPhB6KCh9hEqJkLAJo7bb0Lh9b+OIVzw==}
|
resolution: {integrity: sha512-pujnclbeHWxxPRqXWmdkKV5OX4Wk4YeK7wusHqRwU0Q7EFusHoqNA/aPhB6KCh9hEqJkLAJo7bb0Lh9b+OIVzw==}
|
||||||
|
|
||||||
@@ -1329,12 +1341,18 @@ packages:
|
|||||||
'@vueuse/metadata@10.9.0':
|
'@vueuse/metadata@10.9.0':
|
||||||
resolution: {integrity: sha512-iddNbg3yZM0X7qFY2sAotomgdHK7YJ6sKUvQqbvwnf7TmaVPxS4EJydcNsVejNdS8iWCtDk+fYXr7E32nyTnGA==}
|
resolution: {integrity: sha512-iddNbg3yZM0X7qFY2sAotomgdHK7YJ6sKUvQqbvwnf7TmaVPxS4EJydcNsVejNdS8iWCtDk+fYXr7E32nyTnGA==}
|
||||||
|
|
||||||
|
'@vueuse/metadata@11.2.0':
|
||||||
|
resolution: {integrity: sha512-L0ZmtRmNx+ZW95DmrgD6vn484gSpVeRbgpWevFKXwqqQxW9hnSi2Ppuh2BzMjnbv4aJRiIw8tQatXT9uOB23dQ==}
|
||||||
|
|
||||||
'@vueuse/metadata@9.13.0':
|
'@vueuse/metadata@9.13.0':
|
||||||
resolution: {integrity: sha512-gdU7TKNAUVlXXLbaF+ZCfte8BjRJQWPCa2J55+7/h+yDtzw3vOoGQDRXzI6pyKyo6bXFT5/QoPE4hAknExjRLQ==}
|
resolution: {integrity: sha512-gdU7TKNAUVlXXLbaF+ZCfte8BjRJQWPCa2J55+7/h+yDtzw3vOoGQDRXzI6pyKyo6bXFT5/QoPE4hAknExjRLQ==}
|
||||||
|
|
||||||
'@vueuse/shared@10.9.0':
|
'@vueuse/shared@10.9.0':
|
||||||
resolution: {integrity: sha512-Uud2IWncmAfJvRaFYzv5OHDli+FbOzxiVEQdLCKQKLyhz94PIyFC3CHcH7EDMwIn8NPtD06+PNbC/PiO0LGLtw==}
|
resolution: {integrity: sha512-Uud2IWncmAfJvRaFYzv5OHDli+FbOzxiVEQdLCKQKLyhz94PIyFC3CHcH7EDMwIn8NPtD06+PNbC/PiO0LGLtw==}
|
||||||
|
|
||||||
|
'@vueuse/shared@11.2.0':
|
||||||
|
resolution: {integrity: sha512-VxFjie0EanOudYSgMErxXfq6fo8vhr5ICI+BuE3I9FnX7ePllEsVrRQ7O6Q1TLgApeLuPKcHQxAXpP+KnlrJsg==}
|
||||||
|
|
||||||
'@vueuse/shared@9.13.0':
|
'@vueuse/shared@9.13.0':
|
||||||
resolution: {integrity: sha512-UrnhU+Cnufu4S6JLCPZnkWh0WwZGUp72ktOF2DFptMlOs3TOdVv8xJN53zhHGARmVOsz5KqOls09+J1NR6sBKw==}
|
resolution: {integrity: sha512-UrnhU+Cnufu4S6JLCPZnkWh0WwZGUp72ktOF2DFptMlOs3TOdVv8xJN53zhHGARmVOsz5KqOls09+J1NR6sBKw==}
|
||||||
|
|
||||||
@@ -4127,6 +4145,17 @@ packages:
|
|||||||
vue-clipboard3@2.0.0:
|
vue-clipboard3@2.0.0:
|
||||||
resolution: {integrity: sha512-Q9S7dzWGax7LN5iiSPcu/K1GGm2gcBBlYwmMsUc5/16N6w90cbKow3FnPmPs95sungns4yvd9/+JhbAznECS2A==}
|
resolution: {integrity: sha512-Q9S7dzWGax7LN5iiSPcu/K1GGm2gcBBlYwmMsUc5/16N6w90cbKow3FnPmPs95sungns4yvd9/+JhbAznECS2A==}
|
||||||
|
|
||||||
|
vue-demi@0.14.10:
|
||||||
|
resolution: {integrity: sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==}
|
||||||
|
engines: {node: '>=12'}
|
||||||
|
hasBin: true
|
||||||
|
peerDependencies:
|
||||||
|
'@vue/composition-api': ^1.0.0-rc.1
|
||||||
|
vue: ^3.0.0-0 || ^2.6.0
|
||||||
|
peerDependenciesMeta:
|
||||||
|
'@vue/composition-api':
|
||||||
|
optional: true
|
||||||
|
|
||||||
vue-demi@0.14.7:
|
vue-demi@0.14.7:
|
||||||
resolution: {integrity: sha512-EOG8KXDQNwkJILkx/gPcoL/7vH+hORoBaKgGe+6W7VFMvCYJfmF2dGbvgDroVnI8LU7/kTu8mbjRZGBU1z9NTA==}
|
resolution: {integrity: sha512-EOG8KXDQNwkJILkx/gPcoL/7vH+hORoBaKgGe+6W7VFMvCYJfmF2dGbvgDroVnI8LU7/kTu8mbjRZGBU1z9NTA==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
@@ -5363,6 +5392,10 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@tauri-apps/api': 2.0.2
|
'@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':
|
'@tauri-apps/plugin-http@2.0.0':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tauri-apps/api': 2.0.2
|
'@tauri-apps/api': 2.0.2
|
||||||
@@ -5848,6 +5881,16 @@ snapshots:
|
|||||||
- '@vue/composition-api'
|
- '@vue/composition-api'
|
||||||
- vue
|
- vue
|
||||||
|
|
||||||
|
'@vueuse/core@11.2.0(vue@3.4.24(typescript@5.4.5))':
|
||||||
|
dependencies:
|
||||||
|
'@types/web-bluetooth': 0.0.20
|
||||||
|
'@vueuse/metadata': 11.2.0
|
||||||
|
'@vueuse/shared': 11.2.0(vue@3.4.24(typescript@5.4.5))
|
||||||
|
vue-demi: 0.14.10(vue@3.4.24(typescript@5.4.5))
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- '@vue/composition-api'
|
||||||
|
- vue
|
||||||
|
|
||||||
'@vueuse/core@9.13.0(vue@3.4.24(typescript@5.4.5))':
|
'@vueuse/core@9.13.0(vue@3.4.24(typescript@5.4.5))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/web-bluetooth': 0.0.16
|
'@types/web-bluetooth': 0.0.16
|
||||||
@@ -5872,6 +5915,8 @@ snapshots:
|
|||||||
|
|
||||||
'@vueuse/metadata@10.9.0': {}
|
'@vueuse/metadata@10.9.0': {}
|
||||||
|
|
||||||
|
'@vueuse/metadata@11.2.0': {}
|
||||||
|
|
||||||
'@vueuse/metadata@9.13.0': {}
|
'@vueuse/metadata@9.13.0': {}
|
||||||
|
|
||||||
'@vueuse/shared@10.9.0(vue@3.4.24(typescript@5.4.5))':
|
'@vueuse/shared@10.9.0(vue@3.4.24(typescript@5.4.5))':
|
||||||
@@ -5881,6 +5926,13 @@ snapshots:
|
|||||||
- '@vue/composition-api'
|
- '@vue/composition-api'
|
||||||
- vue
|
- vue
|
||||||
|
|
||||||
|
'@vueuse/shared@11.2.0(vue@3.4.24(typescript@5.4.5))':
|
||||||
|
dependencies:
|
||||||
|
vue-demi: 0.14.10(vue@3.4.24(typescript@5.4.5))
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- '@vue/composition-api'
|
||||||
|
- vue
|
||||||
|
|
||||||
'@vueuse/shared@9.13.0(vue@3.4.24(typescript@5.4.5))':
|
'@vueuse/shared@9.13.0(vue@3.4.24(typescript@5.4.5))':
|
||||||
dependencies:
|
dependencies:
|
||||||
vue-demi: 0.14.7(vue@3.4.24(typescript@5.4.5))
|
vue-demi: 0.14.7(vue@3.4.24(typescript@5.4.5))
|
||||||
@@ -8999,6 +9051,10 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
clipboard: 2.0.11
|
clipboard: 2.0.11
|
||||||
|
|
||||||
|
vue-demi@0.14.10(vue@3.4.24(typescript@5.4.5)):
|
||||||
|
dependencies:
|
||||||
|
vue: 3.4.24(typescript@5.4.5)
|
||||||
|
|
||||||
vue-demi@0.14.7(vue@3.4.24(typescript@5.4.5)):
|
vue-demi@0.14.7(vue@3.4.24(typescript@5.4.5)):
|
||||||
dependencies:
|
dependencies:
|
||||||
vue: 3.4.24(typescript@5.4.5)
|
vue: 3.4.24(typescript@5.4.5)
|
||||||
|
|||||||
@@ -2,5 +2,4 @@
|
|||||||
# will have compiled files and executables
|
# will have compiled files and executables
|
||||||
/target/
|
/target/
|
||||||
/gen/schemas
|
/gen/schemas
|
||||||
/easytier-windows-x86_64-v2.0.3.zip
|
/easytier/
|
||||||
/easytier-windows-x86_64/
|
|
||||||
Generated
+44
-3
@@ -97,9 +97,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.89"
|
version = "1.0.92"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6"
|
checksum = "74f37166d7d48a0284b99dd824694c26119c700b53bf0d1540cdb147dbdaaf13"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arbitrary"
|
name = "arbitrary"
|
||||||
@@ -1109,7 +1109,7 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "easytier-game"
|
name = "easytier-game"
|
||||||
version = "1.0.7"
|
version = "1.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"planif",
|
"planif",
|
||||||
@@ -1120,9 +1120,12 @@ dependencies = [
|
|||||||
"tauri",
|
"tauri",
|
||||||
"tauri-build",
|
"tauri-build",
|
||||||
"tauri-plugin-autostart",
|
"tauri-plugin-autostart",
|
||||||
|
"tauri-plugin-fs",
|
||||||
"tauri-plugin-log",
|
"tauri-plugin-log",
|
||||||
"tauri-plugin-shell",
|
"tauri-plugin-shell",
|
||||||
"tauri-plugin-single-instance",
|
"tauri-plugin-single-instance",
|
||||||
|
"whoami",
|
||||||
|
"windows 0.58.0",
|
||||||
"zip",
|
"zip",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -4387,6 +4390,27 @@ dependencies = [
|
|||||||
"thiserror",
|
"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]]
|
[[package]]
|
||||||
name = "tauri-plugin-log"
|
name = "tauri-plugin-log"
|
||||||
version = "2.0.1"
|
version = "2.0.1"
|
||||||
@@ -5024,6 +5048,12 @@ version = "0.11.0+wasi-snapshot-preview1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasite"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen"
|
name = "wasm-bindgen"
|
||||||
version = "0.2.93"
|
version = "0.2.93"
|
||||||
@@ -5194,6 +5224,17 @@ dependencies = [
|
|||||||
"windows-core 0.58.0",
|
"windows-core 0.58.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "whoami"
|
||||||
|
version = "1.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "372d5b87f58ec45c384ba03563b03544dc5fadc3983e434b286913f5b4a9bb6d"
|
||||||
|
dependencies = [
|
||||||
|
"redox_syscall",
|
||||||
|
"wasite",
|
||||||
|
"web-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "easytier-game"
|
name = "easytier-game"
|
||||||
version = "1.0.7"
|
version = "1.1.2"
|
||||||
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"
|
||||||
@@ -36,9 +36,15 @@ reqwest = { version = "0.12", features = ["json"] }
|
|||||||
zip = "2.2.0"
|
zip = "2.2.0"
|
||||||
sysinfo = '0.32.0'
|
sysinfo = '0.32.0'
|
||||||
planif = { git = "https://github.com/mattrobineau/planif", tag = "1.0.1" }
|
planif = { git = "https://github.com/mattrobineau/planif", tag = "1.0.1" }
|
||||||
|
whoami = "1.5.2"
|
||||||
|
tauri-plugin-fs = "2"
|
||||||
# prost = "0.13"
|
# prost = "0.13"
|
||||||
# prost-types = "0.13"
|
# prost-types = "0.13"
|
||||||
|
|
||||||
|
[dependencies.windows]
|
||||||
|
version = "0.58.0"
|
||||||
|
features = ["Win32_System_TaskScheduler"]
|
||||||
|
|
||||||
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
|
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
|
||||||
tauri-plugin-autostart = "2.0.1"
|
tauri-plugin-autostart = "2.0.1"
|
||||||
tauri-plugin-single-instance = "2.0.1"
|
tauri-plugin-single-instance = "2.0.1"
|
||||||
|
|||||||
Binary file not shown.
@@ -32,7 +32,7 @@
|
|||||||
"allow": [
|
"allow": [
|
||||||
{
|
{
|
||||||
"args": ["run"],
|
"args": ["run"],
|
||||||
"cmd": "WinIPBroadcast",
|
"cmd": "easytier/tool/WinIPBroadcast",
|
||||||
"name": "WinIPBroadcast"
|
"name": "WinIPBroadcast"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -42,10 +42,26 @@
|
|||||||
"allow": [
|
"allow": [
|
||||||
{
|
{
|
||||||
"args": ["run"],
|
"args": ["run"],
|
||||||
"cmd": "WinIPBroadcast",
|
"cmd": "easytier/tool/WinIPBroadcast",
|
||||||
"name": "WinIPBroadcast"
|
"name": "WinIPBroadcast"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"args": true,
|
||||||
|
"cmd": "easytier/tool/nssm",
|
||||||
|
"name": "nssm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
这里存放每次打包需要用到的最新版本的easytier 和 相关工具
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
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"
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 68 KiB |
Binary file not shown.
+193
-12
@@ -1,3 +1,7 @@
|
|||||||
|
use planif::enums::TaskCreationFlags;
|
||||||
|
use planif::schedule::TaskScheduler as planIfTaskScheduler;
|
||||||
|
use planif::schedule_builder::{Action, ScheduleBuilder};
|
||||||
|
use planif::settings::{Duration, LogonType, PrincipalSettings, RunLevel};
|
||||||
use reqwest::{Client, Error};
|
use reqwest::{Client, Error};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
@@ -15,6 +19,10 @@ use tauri::tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent}
|
|||||||
use tauri::Emitter;
|
use tauri::Emitter;
|
||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
use tauri_plugin_autostart::MacosLauncher;
|
use tauri_plugin_autostart::MacosLauncher;
|
||||||
|
use windows::core::{BSTR, VARIANT};
|
||||||
|
use windows::Win32::Foundation::VARIANT_BOOL;
|
||||||
|
use windows::Win32::System::Com::*;
|
||||||
|
use windows::Win32::System::TaskScheduler::*;
|
||||||
|
|
||||||
// 定义GitHub Release的结构体
|
// 定义GitHub Release的结构体
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
@@ -52,7 +60,7 @@ pub async fn fetch_releases() -> Result<Vec<Release>, Error> {
|
|||||||
|
|
||||||
#[tauri::command(rename_all = "snake_case")]
|
#[tauri::command(rename_all = "snake_case")]
|
||||||
fn get_core_version() -> String {
|
fn get_core_version() -> String {
|
||||||
match Command::new("easytier-core.exe")
|
match Command::new("easytier/easytier-core.exe")
|
||||||
.arg("--version")
|
.arg("--version")
|
||||||
.creation_flags(0x08000000)
|
.creation_flags(0x08000000)
|
||||||
.output()
|
.output()
|
||||||
@@ -67,7 +75,7 @@ fn get_core_version() -> String {
|
|||||||
|
|
||||||
#[tauri::command(rename_all = "snake_case")]
|
#[tauri::command(rename_all = "snake_case")]
|
||||||
fn get_cli_version() -> String {
|
fn get_cli_version() -> String {
|
||||||
match Command::new("easytier-cli.exe")
|
match Command::new("easytier/easytier-cli.exe")
|
||||||
.arg("--version")
|
.arg("--version")
|
||||||
.creation_flags(0x08000000)
|
.creation_flags(0x08000000)
|
||||||
.output()
|
.output()
|
||||||
@@ -114,7 +122,7 @@ struct MyResponse {
|
|||||||
|
|
||||||
#[tauri::command(rename_all = "snake_case")]
|
#[tauri::command(rename_all = "snake_case")]
|
||||||
fn get_members_by_cli() -> String {
|
fn get_members_by_cli() -> String {
|
||||||
match Command::new("easytier-cli.exe")
|
match Command::new("easytier/easytier-cli.exe")
|
||||||
.arg("peer")
|
.arg("peer")
|
||||||
.arg("list")
|
.arg("list")
|
||||||
.creation_flags(0x08000000)
|
.creation_flags(0x08000000)
|
||||||
@@ -130,11 +138,17 @@ fn get_members_by_cli() -> String {
|
|||||||
|
|
||||||
#[tauri::command(rename_all = "snake_case")]
|
#[tauri::command(rename_all = "snake_case")]
|
||||||
async fn download_easytier_zip(download_url: String, file_name: String) {
|
async fn download_easytier_zip(download_url: String, file_name: String) {
|
||||||
let target = format!("https://ghp.ci/{}", download_url);
|
let target = format!("{}", download_url);
|
||||||
let response = reqwest::get(target)
|
let response = reqwest::get(target)
|
||||||
.await
|
.await
|
||||||
.expect("error to download easytier url");
|
.expect("error to download easytier url");
|
||||||
let file_path = format!("./{}", file_name);
|
let file_path = format!("./easytier/{}", file_name);
|
||||||
|
|
||||||
|
let easytier_dir = path::Path::new("./easytier");
|
||||||
|
if !easytier_dir.exists() {
|
||||||
|
fs::create_dir_all(&easytier_dir).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
let path = path::Path::new(&file_path);
|
let path = path::Path::new(&file_path);
|
||||||
|
|
||||||
let mut file = match File::create(&path) {
|
let mut file = match File::create(&path) {
|
||||||
@@ -183,7 +197,14 @@ fn unzip(fname: &path::Path) {
|
|||||||
// fs::create_dir_all(p).unwrap();
|
// fs::create_dir_all(p).unwrap();
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
let out_file_path = path::Path::new("./").join(outpath.file_name().clone().unwrap());
|
|
||||||
|
let easytier_dir = path::Path::new("./easytier");
|
||||||
|
// if !easytier_dir.exists() {
|
||||||
|
// fs::create_dir_all(&easytier_dir).unwrap();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// let out_file_path = path::Path::new("./").join(outpath.file_name().clone().unwrap());
|
||||||
|
let out_file_path = easytier_dir.join(outpath.file_name().clone().unwrap());
|
||||||
println!("outFilePath: {}", out_file_path.display());
|
println!("outFilePath: {}", out_file_path.display());
|
||||||
let mut outfile = fs::File::create(&out_file_path).unwrap();
|
let mut outfile = fs::File::create(&out_file_path).unwrap();
|
||||||
std::io::copy(&mut file, &mut outfile).unwrap();
|
std::io::copy(&mut file, &mut outfile).unwrap();
|
||||||
@@ -196,10 +217,6 @@ fn run_command(
|
|||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
stop_signal: tauri::State<Arc<AtomicBool>>,
|
stop_signal: tauri::State<Arc<AtomicBool>>,
|
||||||
) {
|
) {
|
||||||
// if !path::Path::new("easytier-core.exe").exists() {
|
|
||||||
// app_handle.emit("command-output", "easytier-core.exe 不存在");
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
let (tx, rx) = mpsc::channel();
|
let (tx, rx) = mpsc::channel();
|
||||||
stop_signal.store(false, Ordering::Relaxed);
|
stop_signal.store(false, Ordering::Relaxed);
|
||||||
let app_handle1 = app_handle.clone();
|
let app_handle1 = app_handle.clone();
|
||||||
@@ -208,7 +225,8 @@ fn run_command(
|
|||||||
let stop_signal2 = Arc::clone(&stop_signal);
|
let stop_signal2 = Arc::clone(&stop_signal);
|
||||||
let args2 = args.clone();
|
let args2 = args.clone();
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let mut child = Command::new("easytier-core.exe")
|
// trace, debug, info, warn, error, off
|
||||||
|
let mut child = Command::new("easytier/easytier-core.exe")
|
||||||
.args(args)
|
.args(args)
|
||||||
.creation_flags(0x08000000)
|
.creation_flags(0x08000000)
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
@@ -332,6 +350,165 @@ fn search_pid_by_pname(target_process_name: String) -> u32 {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn get_exe_directory() -> Vec<String> {
|
||||||
|
let mut ret_vec: Vec<String> = Vec::new();
|
||||||
|
match std::env::current_exe() {
|
||||||
|
Ok(exe_path) => {
|
||||||
|
println!("Path of this executable is: {}", exe_path.display());
|
||||||
|
ret_vec.push(exe_path.display().to_string());
|
||||||
|
ret_vec.push(exe_path.parent().unwrap().display().to_string());
|
||||||
|
return ret_vec;
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
println!("failed to get current exe path: {e}");
|
||||||
|
ret_vec.push("".to_string());
|
||||||
|
ret_vec.push("".to_string());
|
||||||
|
return ret_vec;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn spawn_autostart(enabled: bool) {
|
||||||
|
let (tx, rx) = mpsc::channel();
|
||||||
|
|
||||||
|
thread::spawn(move || match autostart(enabled) {
|
||||||
|
Ok(_) => {
|
||||||
|
let _ = tx.send(true);
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
println!("Error: {}", e);
|
||||||
|
let _ = tx.send(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
match rx.recv() {
|
||||||
|
Ok(_) => {
|
||||||
|
// println!("autostart enabled: {}", enabled);
|
||||||
|
}
|
||||||
|
Err(_e) => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn autostart_enabled() -> Result<bool, Box<dyn std::error::Error>> {
|
||||||
|
unsafe {
|
||||||
|
let task_service: ITaskService = CoCreateInstance(&TaskScheduler, None, CLSCTX_ALL)?;
|
||||||
|
task_service
|
||||||
|
.Connect(
|
||||||
|
&VARIANT::default(),
|
||||||
|
&VARIANT::default(),
|
||||||
|
&VARIANT::default(),
|
||||||
|
&VARIANT::default(),
|
||||||
|
)
|
||||||
|
?;
|
||||||
|
|
||||||
|
// 指定要删除的任务文件夹路径
|
||||||
|
let folder_path = BSTR::from("\\easytierGame");
|
||||||
|
// let root = BSTR::from("\\");
|
||||||
|
let task_name = BSTR::from("auto start");
|
||||||
|
let mut penabled = VARIANT_BOOL::from(false);
|
||||||
|
let bool_ptr: *mut VARIANT_BOOL = &mut penabled;
|
||||||
|
|
||||||
|
// 获取任务文件夹F
|
||||||
|
let task_folder: ITaskFolder = task_service
|
||||||
|
.GetFolder(&folder_path)
|
||||||
|
?;
|
||||||
|
let task = task_folder
|
||||||
|
.GetTask(&task_name)
|
||||||
|
?;
|
||||||
|
task.Definition()
|
||||||
|
?
|
||||||
|
.Triggers()
|
||||||
|
?
|
||||||
|
.get_Item(1)
|
||||||
|
?
|
||||||
|
.Enabled(bool_ptr)
|
||||||
|
?;
|
||||||
|
// 释放 COM 库
|
||||||
|
CoUninitialize();
|
||||||
|
// return penabled.as_bool();
|
||||||
|
Ok(penabled.as_bool())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn autostart_is_enabled() -> bool {
|
||||||
|
match autostart_enabled() {
|
||||||
|
Ok(enabled) => {
|
||||||
|
println!("autostart enabled: {}", enabled);
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
println!("autostart enabled: false -> {}", e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error>> {
|
||||||
|
if !enabled {
|
||||||
|
unsafe {
|
||||||
|
let task_service: ITaskService = CoCreateInstance(&TaskScheduler, None, CLSCTX_ALL)?;
|
||||||
|
task_service.Connect(
|
||||||
|
&VARIANT::default(),
|
||||||
|
&VARIANT::default(),
|
||||||
|
&VARIANT::default(),
|
||||||
|
&VARIANT::default(),
|
||||||
|
)?;
|
||||||
|
|
||||||
|
// 指定要删除的任务文件夹路径
|
||||||
|
let folder_path = BSTR::from("\\easytierGame");
|
||||||
|
let root = BSTR::from("\\");
|
||||||
|
let task_name = BSTR::from("auto start");
|
||||||
|
|
||||||
|
// 获取任务文件夹
|
||||||
|
let task_folder: ITaskFolder = task_service.GetFolder(&folder_path)?;
|
||||||
|
task_folder.DeleteTask(&task_name, 0)?;
|
||||||
|
println!("Task AutoStart Task deleted successfully.");
|
||||||
|
|
||||||
|
let task_folder: ITaskFolder = task_service.GetFolder(&root)?;
|
||||||
|
|
||||||
|
// 删除任务文件夹
|
||||||
|
task_folder.DeleteFolder(&folder_path, 0)?;
|
||||||
|
|
||||||
|
println!("Task folder easytierGame deleted successfully.");
|
||||||
|
|
||||||
|
// 释放 COM 库
|
||||||
|
CoUninitialize();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let ts = planIfTaskScheduler::new()?;
|
||||||
|
let com = ts.get_com();
|
||||||
|
let sb = ScheduleBuilder::new(&com).unwrap();
|
||||||
|
|
||||||
|
let exe = std::env::current_exe()?;
|
||||||
|
let exe = exe.to_str().unwrap();
|
||||||
|
|
||||||
|
let settings = PrincipalSettings {
|
||||||
|
display_name: "".to_string(),
|
||||||
|
group_id: None,
|
||||||
|
id: "".to_string(),
|
||||||
|
logon_type: LogonType::InteractiveToken,
|
||||||
|
run_level: RunLevel::Highest,
|
||||||
|
user_id: Some(whoami::username()),
|
||||||
|
};
|
||||||
|
sb.create_logon()
|
||||||
|
.author("heixiansen")?
|
||||||
|
.trigger("trigger", enabled)?
|
||||||
|
.action(Action::new("auto start", exe, "", ""))?
|
||||||
|
.in_folder("easytierGame")?
|
||||||
|
.principal(settings)?
|
||||||
|
.delay(Duration {
|
||||||
|
seconds: Some(6),
|
||||||
|
..Default::default()
|
||||||
|
})?
|
||||||
|
.build()?
|
||||||
|
.register("auto start", TaskCreationFlags::CreateOrUpdate as i32)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub const AUTOSTART_ARG: &str = "--autostart";
|
pub const AUTOSTART_ARG: &str = "--autostart";
|
||||||
|
|
||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
@@ -340,6 +517,7 @@ pub fn run() {
|
|||||||
let stop_signal_clone = Arc::clone(&stop_signal); // 创建一个原子布尔值的克隆,用于传递给命令
|
let stop_signal_clone = Arc::clone(&stop_signal); // 创建一个原子布尔值的克隆,用于传递给命令
|
||||||
let context = tauri::generate_context!();
|
let context = tauri::generate_context!();
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
|
.plugin(tauri_plugin_fs::init())
|
||||||
.plugin(tauri_plugin_autostart::init(
|
.plugin(tauri_plugin_autostart::init(
|
||||||
MacosLauncher::LaunchAgent,
|
MacosLauncher::LaunchAgent,
|
||||||
Some(vec![AUTOSTART_ARG]),
|
Some(vec![AUTOSTART_ARG]),
|
||||||
@@ -389,7 +567,10 @@ pub fn run() {
|
|||||||
download_easytier_zip,
|
download_easytier_zip,
|
||||||
get_cli_version,
|
get_cli_version,
|
||||||
get_members_by_cli,
|
get_members_by_cli,
|
||||||
search_pid_by_pname
|
search_pid_by_pname,
|
||||||
|
get_exe_directory,
|
||||||
|
spawn_autostart,
|
||||||
|
autostart_is_enabled
|
||||||
])
|
])
|
||||||
.run(context)
|
.run(context)
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
|
|||||||
@@ -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.0.7",
|
"version": "1.1.2",
|
||||||
"identifier": "com.tauri.easytier-game",
|
"identifier": "com.tauri.easytier-game",
|
||||||
|
|
||||||
"build": {
|
"build": {
|
||||||
@@ -13,8 +13,8 @@
|
|||||||
"app": {
|
"app": {
|
||||||
"windows": [
|
"windows": [
|
||||||
{
|
{
|
||||||
"title": "easytier-game",
|
"title": "easytier-game 1.1.2",
|
||||||
"width": 331,
|
"width": 335,
|
||||||
"height": 305,
|
"height": 305,
|
||||||
"resizable": false,
|
"resizable": false,
|
||||||
"fullscreen": false,
|
"fullscreen": false,
|
||||||
@@ -32,8 +32,15 @@
|
|||||||
"bundle": {
|
"bundle": {
|
||||||
"active": false,
|
"active": false,
|
||||||
"targets": "all",
|
"targets": "all",
|
||||||
"externalBin": ["WinIPBroadcast"],
|
"resources": [
|
||||||
"resources": ["icons/icon-inactive.ico", "icons/icon.ico", "easytier-cli.exe", "easytier-core.exe", "Packet.dll", "wintun.dll"],
|
"easytier/config/",
|
||||||
|
"easytier/icons/",
|
||||||
|
"easytier/tool/WinIPBroadcast.exe",
|
||||||
|
"easytier/easytier-cli.exe",
|
||||||
|
"easytier/easytier-core.exe",
|
||||||
|
"easytier/Packet.dll",
|
||||||
|
"easytier/wintun.dll"
|
||||||
|
],
|
||||||
"windows": {
|
"windows": {
|
||||||
"webviewInstallMode": {
|
"webviewInstallMode": {
|
||||||
"type": "embedBootstrapper"
|
"type": "embedBootstrapper"
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export default defineStore("main", {
|
|||||||
ipv4: "",
|
ipv4: "",
|
||||||
proxyNetworks: "", // 子网代理
|
proxyNetworks: "", // 子网代理
|
||||||
autoStart: false, // 是否自动启动
|
autoStart: false, // 是否自动启动
|
||||||
|
coonectAfterStart: false, //软件打开后,是否自动连接
|
||||||
disableIpv6: false, // 是否禁用IPv6
|
disableIpv6: false, // 是否禁用IPv6
|
||||||
disbleListenner: false, // 是否禁用监听
|
disbleListenner: false, // 是否禁用监听
|
||||||
disableEncryption: false, // 是否禁用加密
|
disableEncryption: false, // 是否禁用加密
|
||||||
@@ -23,7 +24,13 @@ export default defineStore("main", {
|
|||||||
relayAllPeerrpc: false, // 是否启用所有对等RPC
|
relayAllPeerrpc: false, // 是否启用所有对等RPC
|
||||||
disbleP2p: false, // 是否使用P2P
|
disbleP2p: false, // 是否使用P2P
|
||||||
dhcp: true, // 是否使用DHCP
|
dhcp: true, // 是否使用DHCP
|
||||||
|
saveErrorLog: true, // 是否保存错误日志
|
||||||
|
logLevel: "error", //日志等级
|
||||||
|
devName: false, //自定义网卡名
|
||||||
|
devNameValue: "", //自定义网卡名
|
||||||
},
|
},
|
||||||
|
configStartEnable: false, //使用配置文件启动
|
||||||
|
configPath: "", //配置文件路径
|
||||||
cidrEnable: false,
|
cidrEnable: false,
|
||||||
basePeers: ["public.easytier.top:11010"],
|
basePeers: ["public.easytier.top:11010"],
|
||||||
};
|
};
|
||||||
@@ -39,6 +46,7 @@ export default defineStore("main", {
|
|||||||
"config.networkPassword",
|
"config.networkPassword",
|
||||||
"config.disbleP2p",
|
"config.disbleP2p",
|
||||||
"config.autoStart",
|
"config.autoStart",
|
||||||
|
"config.coonectAfterStart",
|
||||||
"config.disableIpv6",
|
"config.disableIpv6",
|
||||||
"config.disbleListenner",
|
"config.disbleListenner",
|
||||||
"config.disableEncryption",
|
"config.disableEncryption",
|
||||||
@@ -51,6 +59,8 @@ export default defineStore("main", {
|
|||||||
"config.relayAllPeerrpc",
|
"config.relayAllPeerrpc",
|
||||||
"config.hostname",
|
"config.hostname",
|
||||||
"config.dhcp",
|
"config.dhcp",
|
||||||
|
"config.saveErrorLog",
|
||||||
|
"config.logLevel"
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
"components/**/*.ts",
|
"components/**/*.ts",
|
||||||
"components/**/*.js",
|
"components/**/*.js",
|
||||||
"components/**/*.vue",
|
"components/**/*.vue",
|
||||||
|
"app.vue",
|
||||||
"pages/**/*.ts",
|
"pages/**/*.ts",
|
||||||
"pages/**/*.js",
|
"pages/**/*.js",
|
||||||
"pages/**/*.vue",
|
"pages/**/*.vue",
|
||||||
|
|||||||
Vendored
+6
@@ -1 +1,7 @@
|
|||||||
|
interface ImportMetaEnv {
|
||||||
|
readonly VITE_CONFIG_PATH: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ImportMeta {
|
||||||
|
readonly env: ImportMetaEnv;
|
||||||
|
}
|
||||||
|
|||||||
+35
-4
@@ -77,7 +77,38 @@ export const ATJ = (promise: Promise<any>, errorExt: string | undefined = undefi
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const openBrowser = (key: string) => {
|
export const parsePeerInfo = (content: string) => {
|
||||||
// logger.info(`${import.meta.env.VITE_BROWSER_JOB_URL}${key}`)
|
// 将表格字符串分割成行
|
||||||
// _launcherApi.openBrowser(`${import.meta.env.VITE_BROWSER_JOB_URL}${key}`);
|
const lines = content.split('\n')
|
||||||
};
|
|
||||||
|
// 提取表头(keys)
|
||||||
|
const headers = lines[1]
|
||||||
|
.split('│')
|
||||||
|
.slice(1, -1)
|
||||||
|
.map((h) => h.trim())
|
||||||
|
|
||||||
|
// 初始化结果数组
|
||||||
|
const result: any[] = []
|
||||||
|
|
||||||
|
// 遍历数据行
|
||||||
|
for (let i = 3; i < lines.length - 1; i += 2) {
|
||||||
|
if (lines[i].trim() === '') continue // 跳过空行
|
||||||
|
|
||||||
|
// 分割每一行的数据
|
||||||
|
const values = lines[i]
|
||||||
|
.split('│')
|
||||||
|
.slice(1, -1)
|
||||||
|
.map((v) => v.trim())
|
||||||
|
|
||||||
|
// 创建对象并添加到结果数组
|
||||||
|
const obj: any = {}
|
||||||
|
headers.forEach((header, index) => {
|
||||||
|
obj[header] = values[index] === '-' || values[index] === '' ? null : values[index]
|
||||||
|
})
|
||||||
|
|
||||||
|
// 每行数据都作为一个新对象添加到结果数组中
|
||||||
|
result.push(obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user