mirror of
https://github.com/EasyTier/EasytierGame.git
synced 2025-05-19 10:27:56 +00:00
修复与功能更新
1.解决UAC开机自启失败的问题 2.联机成功后右下角图标增加 ip地址的 tooltip提示 3.高级选项: 新增软件启动自动联机的功能开关,搭配修复后的开机自启功能,可实现类windows服务的无感联机 4.高级选项:增加日志配置
This commit is contained in:
+9
-10
@@ -92,15 +92,14 @@ export async function MenuItemShow(text: string) {
|
||||
|
||||
export async function setTrayRunState(tray: TrayIcon | null, isRunning: boolean = false) {
|
||||
if (!tray) return;
|
||||
tray.setIcon(isRunning ? "easytier/icons/icon-inactive.ico" : "easytier/icons/icon.ico");
|
||||
await tray.setIcon(isRunning ? "easytier/icons/icon-inactive.ico" : "easytier/icons/icon.ico");
|
||||
}
|
||||
|
||||
// export async function setTrayTooltip(tooltip: string) {
|
||||
// if (tooltip) {
|
||||
// const tray = await useTray()
|
||||
// if (!tray)
|
||||
// return
|
||||
// tray.setTooltip(`EasyTier\n${pkg.version}\n${tooltip}`)
|
||||
// tray.setTitle(`EasyTier\n${pkg.version}\n${tooltip}`)
|
||||
// }
|
||||
// }
|
||||
export async function setTrayTooltip(tray: TrayIcon | null, tooltip?: string | null) {
|
||||
if (!tray) return;
|
||||
if (tooltip) {
|
||||
await tray.setTooltip(`EasyTier\n${pkg.version}\n${tooltip}`);
|
||||
} else {
|
||||
await tray.setTooltip(`EasyTier\n${pkg.version}`);
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+3
-1
@@ -1 +1,3 @@
|
||||
VITE_CONFIG_PATH=easytier/config/
|
||||
VITE_CONFIG_PATH=easytier/config/
|
||||
VITE_LOG_PATH=easytier/logs/
|
||||
VITE_AUTO_START_SERVICE_NAME=easytierGameAutoStart
|
||||
Vendored
+3
-1
@@ -1 +1,3 @@
|
||||
VITE_CONFIG_PATH=easytier/config/
|
||||
VITE_CONFIG_PATH=easytier/config/
|
||||
VITE_LOG_PATH=easytier/logs/
|
||||
VITE_AUTO_START_SERVICE_NAME=easytierGameAutoStart
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
"private": true,
|
||||
"author": "leizi97",
|
||||
"description": "A simple network initiator based on Easytier",
|
||||
"version": "1.0.9",
|
||||
"version": "1.1.0",
|
||||
"scripts": {
|
||||
"dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0",
|
||||
"build": "nuxt generate --dotenv env/.env.prod"
|
||||
|
||||
+42
-3
@@ -1,8 +1,7 @@
|
||||
<template>
|
||||
<div class="h-full overflow-auto flex flex-col items-start px-[25px]">
|
||||
<div>
|
||||
<ElCheckbox v-model="mainStore.config.disableIpv6">不使用IPv6</ElCheckbox>
|
||||
</div>
|
||||
<div><ElCheckbox v-model="mainStore.config.coonectAfterStart">软件启动后,自动"启动联机"(搭配开机自启,无感联机)</ElCheckbox></div>
|
||||
<div><ElCheckbox v-model="mainStore.config.disableIpv6">不使用IPv6</ElCheckbox></div>
|
||||
<div><ElCheckbox v-model="mainStore.config.disbleListenner">不监听任何端口,只连接到对等节点</ElCheckbox></div>
|
||||
<div><ElCheckbox v-model="mainStore.config.enablExitNode">允许此节点成为出口节点</ElCheckbox></div>
|
||||
<div><ElCheckbox v-model="mainStore.config.disableEncryption">禁用对等节点通信的加密,默认为false,必须与对等节点相同</ElCheckbox></div>
|
||||
@@ -14,13 +13,53 @@
|
||||
<div>
|
||||
<ElCheckbox v-model="mainStore.config.relayAllPeerrpc">转发所有对等节点的RPC数据包,即使对等节点不在转发网络白名单内</ElCheckbox>
|
||||
</div>
|
||||
<div class="flex items-center gap-[5px] 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>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import useMainStore from "@/stores/index";
|
||||
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 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) => {
|
||||
// console.log("subscribe", a);
|
||||
appWindow.emitTo("main", "config", { config: { ...mainStore.config } });
|
||||
|
||||
+146
-69
@@ -2,27 +2,32 @@
|
||||
<ElForm
|
||||
size="small"
|
||||
label-position="top"
|
||||
:model="config">
|
||||
:model="config"
|
||||
>
|
||||
<ElFormItem
|
||||
label="服务器"
|
||||
prop="serverUrl">
|
||||
prop="serverUrl"
|
||||
>
|
||||
<template #label>
|
||||
<div class="flex items-center gap-[0_5px]">
|
||||
<div>服务器</div>
|
||||
<span>-</span>
|
||||
<ElTag
|
||||
effect="dark"
|
||||
:type="data.isSuccessGetIp ? 'success' : 'info'">
|
||||
:type="data.isSuccessGetIp ? 'success' : 'info'"
|
||||
>
|
||||
{{ data.isSuccessGetIp ? "联机成功" : data.isStart && !data.isSuccessGetIp ? "联机中" : "未联机" }}
|
||||
</ElTag>
|
||||
<ElButton
|
||||
v-if="!data.coreVersion"
|
||||
@click="getCoreVersion(true)">
|
||||
@click="getCoreVersion(true)"
|
||||
>
|
||||
获取工具版本
|
||||
</ElButton>
|
||||
<ElTag
|
||||
v-else
|
||||
type="info">
|
||||
type="info"
|
||||
>
|
||||
{{ data.coreVersion }}
|
||||
</ElTag>
|
||||
<ElButton
|
||||
@@ -30,8 +35,9 @@
|
||||
:loading="data.update"
|
||||
type="warning"
|
||||
@click="handleUpdateCore"
|
||||
size="small">
|
||||
{{ data.coreVersion ? "更新" : "下载" }}
|
||||
size="small"
|
||||
>
|
||||
{{ data.coreVersion ? "更新插件" : "下载插件" }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
@@ -40,7 +46,8 @@
|
||||
filterable
|
||||
default-first-option
|
||||
v-model="config.serverUrl"
|
||||
@change="handleServerUrlChange">
|
||||
@change="handleServerUrlChange"
|
||||
>
|
||||
<template #prefix>
|
||||
<div :class="config.protocol && config.protocol.length > 1 ? 'w-[120px]' : 'w-[80px]'">
|
||||
<ElSelect
|
||||
@@ -49,12 +56,14 @@
|
||||
collapse-tags
|
||||
@click.stop
|
||||
v-model="config.protocol"
|
||||
@change="handleServerUrlChange">
|
||||
@change="handleServerUrlChange"
|
||||
>
|
||||
<ElOption
|
||||
v-for="item in protocols"
|
||||
:key="item"
|
||||
:label="item"
|
||||
:value="item"></ElOption>
|
||||
:value="item"
|
||||
></ElOption>
|
||||
</ElSelect>
|
||||
</div>
|
||||
</template>
|
||||
@@ -62,14 +71,16 @@
|
||||
v-for="item in mainStore.basePeers"
|
||||
:key="item"
|
||||
:label="item"
|
||||
:value="item">
|
||||
:value="item"
|
||||
>
|
||||
<div class="flex items-center justify-between">
|
||||
<span style="float: left">{{ item }}</span>
|
||||
<ElButton
|
||||
@click.stop="handleDeleteServerUrl(item)"
|
||||
round
|
||||
:icon="Delete"
|
||||
type="danger"></ElButton>
|
||||
type="danger"
|
||||
></ElButton>
|
||||
</div>
|
||||
</ElOption>
|
||||
</ElSelect>
|
||||
@@ -88,7 +99,8 @@
|
||||
<ElInput
|
||||
maxlength="100"
|
||||
placeholder="请输入网络名"
|
||||
v-model="config.networkName"></ElInput>
|
||||
v-model="config.networkName"
|
||||
></ElInput>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
@@ -106,7 +118,8 @@
|
||||
maxlength="100"
|
||||
placeholder="请输入网络密码"
|
||||
v-model="config.networkPassword"
|
||||
type="password"></ElInput>
|
||||
type="password"
|
||||
></ElInput>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
</div>
|
||||
@@ -123,11 +136,13 @@
|
||||
<ElInput
|
||||
maxlength="100"
|
||||
placeholder="例如: Player1"
|
||||
v-model="config.hostname"></ElInput>
|
||||
v-model="config.hostname"
|
||||
></ElInput>
|
||||
</ElFormItem>
|
||||
<ElFormItem
|
||||
class="w-[70%]"
|
||||
label="局域网IP">
|
||||
label="局域网IP"
|
||||
>
|
||||
<template #label>
|
||||
<div class="flex items-center h-[20px]">
|
||||
虚拟网IP
|
||||
@@ -140,14 +155,16 @@
|
||||
inline-prompt
|
||||
inactive-text="固定IP"
|
||||
active-text="动态获取IP"
|
||||
size="small"></ElSwitch>
|
||||
size="small"
|
||||
></ElSwitch>
|
||||
</div>
|
||||
</template>
|
||||
<ElInput
|
||||
maxlength="100"
|
||||
:disabled="config.dhcp"
|
||||
:placeholder="data.isStart ? '等待动态分配IP...' : '例如: 10.126.126.1'"
|
||||
v-model="config.ipv4"></ElInput>
|
||||
v-model="config.ipv4"
|
||||
></ElInput>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<div class="flex items-start gap-[0_10px]">
|
||||
@@ -159,15 +176,17 @@
|
||||
size="default"
|
||||
:type="!data.isStart ? 'primary' : 'danger'"
|
||||
:disabled="data.startLoading || !data.coreVersion || data.update"
|
||||
@click="handleConnection">
|
||||
@click="handleConnection"
|
||||
>
|
||||
{{ !data.isStart ? "启动联机" : "停止联机" }}
|
||||
<template #dropdown>
|
||||
<ElDropdownMenu>
|
||||
<ElDropdownItem
|
||||
command="toml"
|
||||
:disabled="data.isStart"
|
||||
>配置文件启动</ElDropdownItem
|
||||
>
|
||||
配置文件启动
|
||||
</ElDropdownItem>
|
||||
</ElDropdownMenu>
|
||||
</template>
|
||||
</ElDropdown>
|
||||
@@ -175,49 +194,57 @@
|
||||
<div class="mt-[6px] pl-[2px]">
|
||||
<ElTooltip
|
||||
placement="left"
|
||||
content="日志">
|
||||
content="日志"
|
||||
>
|
||||
<ElButton
|
||||
:type="!data.logVisible ? 'info' : 'warning'"
|
||||
@click="handleShowLogDialog"
|
||||
:icon="List"
|
||||
size="small"
|
||||
plain></ElButton>
|
||||
plain
|
||||
></ElButton>
|
||||
</ElTooltip>
|
||||
<ElTooltip
|
||||
placement="left"
|
||||
content="成员">
|
||||
content="成员"
|
||||
>
|
||||
<ElButton
|
||||
@click="handleShowMemberDialog"
|
||||
:icon="UserFilled"
|
||||
plain
|
||||
type="success"
|
||||
size="small"></ElButton>
|
||||
size="small"
|
||||
></ElButton>
|
||||
</ElTooltip>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<ElCheckbox
|
||||
v-model="config.disbleP2p"
|
||||
size="small">
|
||||
size="small"
|
||||
>
|
||||
强制中转
|
||||
</ElCheckbox>
|
||||
<ElCheckbox
|
||||
@change="handleAutoStart"
|
||||
@change="handleAutoStartByTask"
|
||||
:model-value="config.autoStart"
|
||||
size="small">
|
||||
size="small"
|
||||
>
|
||||
开机自启
|
||||
</ElCheckbox>
|
||||
<div>
|
||||
<ElButton
|
||||
@click="handleShowCidrDialog"
|
||||
:icon="Share"
|
||||
>子网代理</ElButton
|
||||
>
|
||||
子网代理
|
||||
</ElButton>
|
||||
<ElButton
|
||||
@click="handleShowAdvanceDialog"
|
||||
:icon="Setting"
|
||||
>高级选项</ElButton
|
||||
>
|
||||
高级选项
|
||||
</ElButton>
|
||||
</div>
|
||||
<div class="flex items-center gap-[0_5px]">
|
||||
<div>
|
||||
@@ -225,7 +252,8 @@
|
||||
class="!text-[11px]"
|
||||
type="info"
|
||||
: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
|
||||
<ElTooltip content="找不到游戏房间时,就开启它后再刷新尝试(默认开启)">
|
||||
<ElIcon class="ml-[3px]"><QuestionFilled /></ElIcon>
|
||||
@@ -238,13 +266,15 @@
|
||||
size="small"
|
||||
label="WinIPBroadcast"
|
||||
active-text="开启"
|
||||
inactive-text="关闭"></ElSwitch>
|
||||
inactive-text="关闭"
|
||||
></ElSwitch>
|
||||
</div>
|
||||
<ElLink
|
||||
class="!text-[11px] pb-[2px] ml-[15px]"
|
||||
type="info"
|
||||
:underline="false"
|
||||
@click="open('https://github.com/EasyTier/EasytierGame')">
|
||||
@click="open('https://github.com/EasyTier/EasytierGame')"
|
||||
>
|
||||
主页
|
||||
</ElLink>
|
||||
</div>
|
||||
@@ -256,42 +286,50 @@
|
||||
top="10px"
|
||||
v-model="configStart.visible"
|
||||
:close-on-press-escape="false"
|
||||
title="配置文件启动">
|
||||
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
|
||||
<span>启用</span>
|
||||
<ElSwitch v-model="mainStore.configStartEnable"></ElSwitch>
|
||||
<ElTooltip content="启用后将完全使用选中的配置文件作为联机配置,其余界面配置不会生效">
|
||||
<ElIcon class="ml-[3px]"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
<ElButton
|
||||
@click="openConfigDir"
|
||||
size="small"
|
||||
>打开配置目录</ElButton
|
||||
>
|
||||
打开配置目录
|
||||
</ElButton>
|
||||
<ElButton
|
||||
@click="handleStartCommand('toml')"
|
||||
type="primary"
|
||||
:icon="RefreshRight"
|
||||
size="small"
|
||||
>刷新</ElButton
|
||||
>
|
||||
刷新
|
||||
</ElButton>
|
||||
</div>
|
||||
<div class="mt-[5px]">
|
||||
<ElSelect
|
||||
v-model="mainStore.configPath"
|
||||
no-data-text="目录没有配置文件"
|
||||
placeholder="选择配置文件">
|
||||
placeholder="选择配置文件"
|
||||
>
|
||||
<ElOption
|
||||
v-for="item in configStart.list"
|
||||
:key="item.path"
|
||||
:value="item.path"
|
||||
:label="item.name"></ElOption>
|
||||
:label="item.name"
|
||||
></ElOption>
|
||||
</ElSelect>
|
||||
</div>
|
||||
<div class="mt-[5px] text-right">
|
||||
<ElButton
|
||||
@click="configStart.visible = false"
|
||||
type="danger"
|
||||
>关闭</ElButton
|
||||
>
|
||||
关闭
|
||||
</ElButton>
|
||||
</div>
|
||||
</ElDialog>
|
||||
</template>
|
||||
@@ -301,14 +339,14 @@
|
||||
import { open, Command } from "@tauri-apps/plugin-shell";
|
||||
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 { useTray, setTrayRunState, setTrayTooltip } from "~/composables/tray";
|
||||
import useMainStore from "@/stores/index";
|
||||
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 etWindows from "@/composables/windows";
|
||||
import * as tauriAutoStart from "@tauri-apps/plugin-autostart";
|
||||
import { resourceDir as getResourceDir, join } from '@tauri-apps/api/path';
|
||||
import { resourceDir as getResourceDir, join } from "@tauri-apps/api/path";
|
||||
import { readDir, exists, mkdir, BaseDirectory } from "@tauri-apps/plugin-fs";
|
||||
|
||||
let is_close = false;
|
||||
@@ -336,21 +374,22 @@
|
||||
coreVersion: "",
|
||||
isSuccessGetIp: false,
|
||||
startLoading: false,
|
||||
isStart: false,
|
||||
isStart: false
|
||||
});
|
||||
|
||||
const configStart = reactive({
|
||||
const configStart = reactive<{ list: Array<{ path: string; name: string }>; [key: string]: any }>({
|
||||
visible: false,
|
||||
loading: false,
|
||||
list: [], //配置文件列表
|
||||
list: [] //配置文件列表
|
||||
});
|
||||
|
||||
const closePrevent = async () => {
|
||||
const appWindow = getCurrentWindow();
|
||||
if (appWindow.label == "main") {
|
||||
appWindow.onCloseRequested(async (event) => {
|
||||
console.log(appWindow.label);
|
||||
appWindow.onCloseRequested(async event => {
|
||||
// console.log(appWindow.label);
|
||||
if (!is_close) {
|
||||
console.log(1);
|
||||
event.preventDefault();
|
||||
appWindow.hide();
|
||||
}
|
||||
@@ -381,7 +420,7 @@
|
||||
thread_id: null,
|
||||
async listenOutput() {
|
||||
const appWindow = getCurrentWindow();
|
||||
const unListen = await listen("command-output", async (event) => {
|
||||
const unListen = await listen("command-output", async event => {
|
||||
data.isStart = true;
|
||||
if (event.payload) {
|
||||
data.startLoading = false;
|
||||
@@ -390,6 +429,7 @@
|
||||
data.isSuccessGetIp = true;
|
||||
await setTrayRunState(tray, true);
|
||||
config.ipv4 = ipv4;
|
||||
await setTrayTooltip(tray, `IP: ${ipv4}`);
|
||||
}
|
||||
}
|
||||
appWindow.emitTo("log", "logs", data.log);
|
||||
@@ -398,7 +438,7 @@
|
||||
this.unListenOutPut = unListen;
|
||||
},
|
||||
async listenThreadId() {
|
||||
const unListen = await listen("thread-id", (event) => {
|
||||
const unListen = await listen("thread-id", event => {
|
||||
if (event.payload) {
|
||||
this.thread_id = event.payload;
|
||||
}
|
||||
@@ -406,14 +446,14 @@
|
||||
this.unListenThreadId = unListen;
|
||||
},
|
||||
async listenConfigStart() {
|
||||
const unListen = await listen("config", (event) => {
|
||||
const unListen = await listen("config", event => {
|
||||
// console.log("config", event.payload);
|
||||
const ipv4 = config.ipv4;
|
||||
mainStore.$patch(event.payload as any);
|
||||
config.ipv4 = ipv4;
|
||||
});
|
||||
this.unListenConfigStart = unListen;
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
const unListenAll = async () => {
|
||||
@@ -547,16 +587,49 @@
|
||||
}
|
||||
};
|
||||
|
||||
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 = await tauriAutoStart.isEnabled();
|
||||
if (is_enable) {
|
||||
await tauriAutoStart.disable();
|
||||
await invoke("spawn_autostart", { enabled: true });
|
||||
const is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean;
|
||||
config.autoStart = is_enable_by_task;
|
||||
} else {
|
||||
const is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean;
|
||||
config.autoStart = is_enable_by_task;
|
||||
}
|
||||
} catch (err) {
|
||||
await invoke("spawn_autostart", { enabled: false });
|
||||
config.autoStart = false;
|
||||
}
|
||||
};
|
||||
|
||||
const initConnectAfterStart = async () => {
|
||||
if (config.coonectAfterStart && data.coreVersion) {
|
||||
await reset();
|
||||
await handleConnection();
|
||||
}
|
||||
};
|
||||
|
||||
let logsTimer: NodeJS.Timeout | null = null;
|
||||
|
||||
onMounted(async () => {
|
||||
// await handleUpdateCore(); //默认不自动更新
|
||||
await initAutoStart();
|
||||
await compatibleInitAutoStart();
|
||||
// await initAutoStart();
|
||||
await initStartWinIpBroadcast();
|
||||
await getCoreVersion();
|
||||
await listenObj.listenThreadId();
|
||||
await listenObj.listenConfigStart();
|
||||
await initConfigDir();
|
||||
await initConnectAfterStart();
|
||||
closePrevent();
|
||||
});
|
||||
|
||||
@@ -574,7 +647,7 @@
|
||||
// const resourceDir = await getResourceDir();
|
||||
// const configPath = await join(resourceDir, mainStore.configPath);
|
||||
// args.push("-c", configPath);
|
||||
|
||||
|
||||
args.push("-c", mainStore.configPath);
|
||||
return args;
|
||||
}
|
||||
@@ -595,7 +668,7 @@
|
||||
}
|
||||
if (config.serverUrl) {
|
||||
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) {
|
||||
args.push("--disable-p2p");
|
||||
@@ -611,8 +684,8 @@
|
||||
const reg = /\d+\.\d+\.\d+\.\d+\/\d+/g;
|
||||
const formatProxyNetworks = config.proxyNetworks
|
||||
.split("\n")
|
||||
.map((item) => item.trim())
|
||||
.filter((item) => item && reg.test(item));
|
||||
.map(item => item.trim())
|
||||
.filter(item => item && reg.test(item));
|
||||
args.push("--proxy-networks", ...formatProxyNetworks);
|
||||
config.proxyNetworks = formatProxyNetworks.join("\n");
|
||||
}
|
||||
@@ -640,6 +713,9 @@
|
||||
if (config.relayAllPeerrpc) {
|
||||
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);
|
||||
}
|
||||
return args;
|
||||
};
|
||||
|
||||
@@ -650,7 +726,7 @@
|
||||
config.ipv4 = "";
|
||||
}
|
||||
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) {
|
||||
data.memberVisible = false;
|
||||
for (const memberDialog of memberDialogs) {
|
||||
@@ -661,6 +737,7 @@
|
||||
}
|
||||
}
|
||||
await setTrayRunState(tray, false);
|
||||
await setTrayTooltip(tray);
|
||||
await unListenAll();
|
||||
};
|
||||
|
||||
@@ -679,7 +756,7 @@
|
||||
await listenObj.listenOutput();
|
||||
|
||||
await invoke("run_command", {
|
||||
args,
|
||||
args
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -693,10 +770,10 @@
|
||||
if (isExists) {
|
||||
const entries = await readDir(path, { baseDir: BaseDirectory.Resource });
|
||||
configStart.list = entries
|
||||
.filter((item) => item.isFile)
|
||||
.map((item) => ({
|
||||
.filter(item => item.isFile)
|
||||
.map(item => ({
|
||||
name: item.name,
|
||||
path: `${path}${item.name}`,
|
||||
path: `${path}${item.name}`
|
||||
})) as any;
|
||||
} else {
|
||||
mainStore.configStartEnable = false;
|
||||
@@ -723,7 +800,7 @@
|
||||
const openConfigDir = async () => {
|
||||
const resourceDir = await getResourceDir();
|
||||
const configPath = await join(resourceDir, import.meta.env.VITE_CONFIG_PATH);
|
||||
console.log(configPath)
|
||||
console.log(configPath);
|
||||
await Command.create("explorer", [configPath]).execute();
|
||||
};
|
||||
|
||||
@@ -741,7 +818,7 @@
|
||||
title: "成员列表",
|
||||
width: 470,
|
||||
height: 380,
|
||||
url: "#/member",
|
||||
url: "#/member"
|
||||
},
|
||||
() => {
|
||||
data.memberVisible = true;
|
||||
@@ -760,7 +837,7 @@
|
||||
width: 600,
|
||||
height: 380,
|
||||
resizable: false,
|
||||
url: "#/log",
|
||||
url: "#/log"
|
||||
},
|
||||
(_, appWindow) => {
|
||||
data.logVisible = true;
|
||||
@@ -783,7 +860,7 @@
|
||||
width: 600,
|
||||
height: 380,
|
||||
resizable: false,
|
||||
url: "#/cidr",
|
||||
url: "#/cidr"
|
||||
},
|
||||
(_, appWindow) => {
|
||||
data.cidrVisible = true;
|
||||
@@ -802,7 +879,7 @@
|
||||
width: 600,
|
||||
height: 380,
|
||||
resizable: false,
|
||||
url: "#/advance",
|
||||
url: "#/advance"
|
||||
},
|
||||
(_, appWindow) => {
|
||||
data.advanceVisible = true;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
/gen/schemas
|
||||
/gen/schemas
|
||||
/easytier/
|
||||
Generated
+22
-3
@@ -97,9 +97,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.89"
|
||||
version = "1.0.92"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6"
|
||||
checksum = "74f37166d7d48a0284b99dd824694c26119c700b53bf0d1540cdb147dbdaaf13"
|
||||
|
||||
[[package]]
|
||||
name = "arbitrary"
|
||||
@@ -1109,7 +1109,7 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
|
||||
|
||||
[[package]]
|
||||
name = "easytier-game"
|
||||
version = "1.0.9"
|
||||
version = "1.1.0"
|
||||
dependencies = [
|
||||
"log",
|
||||
"planif",
|
||||
@@ -1124,6 +1124,8 @@ dependencies = [
|
||||
"tauri-plugin-log",
|
||||
"tauri-plugin-shell",
|
||||
"tauri-plugin-single-instance",
|
||||
"whoami",
|
||||
"windows 0.58.0",
|
||||
"zip",
|
||||
]
|
||||
|
||||
@@ -5046,6 +5048,12 @@ version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "wasite"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.93"
|
||||
@@ -5216,6 +5224,17 @@ dependencies = [
|
||||
"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]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "easytier-game"
|
||||
version = "1.0.9"
|
||||
version = "1.1.0"
|
||||
homepage = "https://github.com/EasyTier/EasyTier"
|
||||
repository = "https://github.com/EasyTier/EasytierGame"
|
||||
description = "A simple network initiator based on Easytier"
|
||||
@@ -36,10 +36,15 @@ 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" }
|
||||
whoami = "1.5.2"
|
||||
tauri-plugin-fs = "2"
|
||||
# prost = "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]
|
||||
tauri-plugin-autostart = "2.0.1"
|
||||
tauri-plugin-single-instance = "2.0.1"
|
||||
|
||||
@@ -45,11 +45,16 @@
|
||||
"cmd": "easytier/tool/WinIPBroadcast",
|
||||
"name": "WinIPBroadcast"
|
||||
},
|
||||
{
|
||||
"args": true,
|
||||
"cmd": "explorer",
|
||||
"name": "explorer"
|
||||
}
|
||||
{
|
||||
"args": true,
|
||||
"cmd": "easytier/tool/nssm",
|
||||
"name": "nssm"
|
||||
},
|
||||
{
|
||||
"args": true,
|
||||
"cmd": "explorer",
|
||||
"name": "explorer"
|
||||
}
|
||||
]
|
||||
},
|
||||
"fs:default",
|
||||
|
||||
+172
-1
@@ -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 serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
@@ -15,6 +19,10 @@ use tauri::tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent}
|
||||
use tauri::Emitter;
|
||||
use tauri::Manager;
|
||||
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的结构体
|
||||
#[derive(Debug, Deserialize)]
|
||||
@@ -217,6 +225,7 @@ fn run_command(
|
||||
let stop_signal2 = Arc::clone(&stop_signal);
|
||||
let args2 = args.clone();
|
||||
thread::spawn(move || {
|
||||
// trace, debug, info, warn, error, off
|
||||
let mut child = Command::new("easytier/easytier-core.exe")
|
||||
.args(args)
|
||||
.creation_flags(0x08000000)
|
||||
@@ -341,6 +350,165 @@ fn search_pid_by_pname(target_process_name: String) -> u32 {
|
||||
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";
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
@@ -399,7 +567,10 @@ pub fn run() {
|
||||
download_easytier_zip,
|
||||
get_cli_version,
|
||||
get_members_by_cli,
|
||||
search_pid_by_pname
|
||||
search_pid_by_pname,
|
||||
get_exe_directory,
|
||||
spawn_autostart,
|
||||
autostart_is_enabled
|
||||
])
|
||||
.run(context)
|
||||
.expect("error while running tauri application");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "easytier-game",
|
||||
"version": "1.0.9",
|
||||
"version": "1.1.0",
|
||||
"identifier": "com.tauri.easytier-game",
|
||||
|
||||
"build": {
|
||||
@@ -34,9 +34,8 @@
|
||||
"targets": "all",
|
||||
"resources": [
|
||||
"easytier/config/",
|
||||
"easytier/icons/",
|
||||
"easytier/tool/WinIPBroadcast.exe",
|
||||
"easytier/icons/icon-inactive.ico",
|
||||
"easytier/icons/icon.ico",
|
||||
"easytier/easytier-cli.exe",
|
||||
"easytier/easytier-core.exe",
|
||||
"easytier/Packet.dll",
|
||||
|
||||
@@ -11,6 +11,7 @@ export default defineStore("main", {
|
||||
ipv4: "",
|
||||
proxyNetworks: "", // 子网代理
|
||||
autoStart: false, // 是否自动启动
|
||||
coonectAfterStart: false, //软件打开后,是否自动连接
|
||||
disableIpv6: false, // 是否禁用IPv6
|
||||
disbleListenner: false, // 是否禁用监听
|
||||
disableEncryption: false, // 是否禁用加密
|
||||
@@ -23,6 +24,8 @@ export default defineStore("main", {
|
||||
relayAllPeerrpc: false, // 是否启用所有对等RPC
|
||||
disbleP2p: false, // 是否使用P2P
|
||||
dhcp: true, // 是否使用DHCP
|
||||
saveErrorLog: true, // 是否保存错误日志
|
||||
logLevel: "error", //日志等级
|
||||
},
|
||||
configStartEnable: false, //使用配置文件启动
|
||||
configPath: "", //配置文件路径
|
||||
@@ -41,6 +44,7 @@ export default defineStore("main", {
|
||||
"config.networkPassword",
|
||||
"config.disbleP2p",
|
||||
"config.autoStart",
|
||||
"config.coonectAfterStart",
|
||||
"config.disableIpv6",
|
||||
"config.disbleListenner",
|
||||
"config.disableEncryption",
|
||||
@@ -53,6 +57,8 @@ export default defineStore("main", {
|
||||
"config.relayAllPeerrpc",
|
||||
"config.hostname",
|
||||
"config.dhcp",
|
||||
"config.saveErrorLog",
|
||||
"config.logLevel"
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user