mirror of
https://github.com/EasyTier/EasytierGame.git
synced 2025-05-19 10:27:56 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4296f4a338 |
+9
-10
@@ -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 ? "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) {
|
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
-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,
|
"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.9",
|
"version": "1.1.0",
|
||||||
"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"
|
||||||
|
|||||||
+42
-3
@@ -1,8 +1,7 @@
|
|||||||
<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.coonectAfterStart">软件启动后,自动"启动联机"(搭配开机自启,无感联机)</ElCheckbox></div>
|
||||||
<ElCheckbox v-model="mainStore.config.disableIpv6">不使用IPv6</ElCheckbox>
|
<div><ElCheckbox v-model="mainStore.config.disableIpv6">不使用IPv6</ElCheckbox></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.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>
|
||||||
@@ -14,13 +13,53 @@
|
|||||||
<div>
|
<div>
|
||||||
<ElCheckbox v-model="mainStore.config.relayAllPeerrpc">转发所有对等节点的RPC数据包,即使对等节点不在转发网络白名单内</ElCheckbox>
|
<ElCheckbox v-model="mainStore.config.relayAllPeerrpc">转发所有对等节点的RPC数据包,即使对等节点不在转发网络白名单内</ElCheckbox>
|
||||||
</div>
|
</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>
|
</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 } });
|
||||||
|
|||||||
+146
-69
@@ -2,27 +2,32 @@
|
|||||||
<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"
|
||||||
|
>
|
||||||
{{ data.coreVersion }}
|
{{ data.coreVersion }}
|
||||||
</ElTag>
|
</ElTag>
|
||||||
<ElButton
|
<ElButton
|
||||||
@@ -30,8 +35,9 @@
|
|||||||
: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,14 +155,16 @@
|
|||||||
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_10px]">
|
<div class="flex items-start gap-[0_10px]">
|
||||||
@@ -159,15 +176,17 @@
|
|||||||
size="default"
|
size="default"
|
||||||
:type="!data.isStart ? 'primary' : 'danger'"
|
:type="!data.isStart ? 'primary' : 'danger'"
|
||||||
:disabled="data.startLoading || !data.coreVersion || data.update"
|
:disabled="data.startLoading || !data.coreVersion || data.update"
|
||||||
@click="handleConnection">
|
@click="handleConnection"
|
||||||
|
>
|
||||||
{{ !data.isStart ? "启动联机" : "停止联机" }}
|
{{ !data.isStart ? "启动联机" : "停止联机" }}
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<ElDropdownMenu>
|
<ElDropdownMenu>
|
||||||
<ElDropdownItem
|
<ElDropdownItem
|
||||||
command="toml"
|
command="toml"
|
||||||
:disabled="data.isStart"
|
:disabled="data.isStart"
|
||||||
>配置文件启动</ElDropdownItem
|
|
||||||
>
|
>
|
||||||
|
配置文件启动
|
||||||
|
</ElDropdownItem>
|
||||||
</ElDropdownMenu>
|
</ElDropdownMenu>
|
||||||
</template>
|
</template>
|
||||||
</ElDropdown>
|
</ElDropdown>
|
||||||
@@ -175,49 +194,57 @@
|
|||||||
<div class="mt-[6px] pl-[2px]">
|
<div class="mt-[6px] pl-[2px]">
|
||||||
<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>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<ElCheckbox
|
<ElCheckbox
|
||||||
v-model="config.disbleP2p"
|
v-model="config.disbleP2p"
|
||||||
size="small">
|
size="small"
|
||||||
|
>
|
||||||
强制中转
|
强制中转
|
||||||
</ElCheckbox>
|
</ElCheckbox>
|
||||||
<ElCheckbox
|
<ElCheckbox
|
||||||
@change="handleAutoStart"
|
@change="handleAutoStartByTask"
|
||||||
:model-value="config.autoStart"
|
:model-value="config.autoStart"
|
||||||
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>
|
||||||
@@ -225,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>
|
||||||
@@ -238,13 +266,15 @@
|
|||||||
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>
|
||||||
@@ -256,42 +286,50 @@
|
|||||||
top="10px"
|
top="10px"
|
||||||
v-model="configStart.visible"
|
v-model="configStart.visible"
|
||||||
:close-on-press-escape="false"
|
:close-on-press-escape="false"
|
||||||
title="配置文件启动">
|
title="配置文件启动"
|
||||||
|
>
|
||||||
<div class="flex items-center gap-[0_4px]">
|
<div class="flex items-center gap-[0_4px]">
|
||||||
<span>启用</span><ElSwitch v-model="mainStore.configStartEnable"></ElSwitch
|
<span>启用</span>
|
||||||
><ElTooltip content="启用后将完全使用选中的配置文件作为联机配置,其余界面配置不会生效">
|
<ElSwitch v-model="mainStore.configStartEnable"></ElSwitch>
|
||||||
<ElIcon class="ml-[3px]"><QuestionFilled /></ElIcon> </ElTooltip
|
<ElTooltip content="启用后将完全使用选中的配置文件作为联机配置,其余界面配置不会生效">
|
||||||
><ElButton
|
<ElIcon class="ml-[3px]"><QuestionFilled /></ElIcon>
|
||||||
|
</ElTooltip>
|
||||||
|
<ElButton
|
||||||
@click="openConfigDir"
|
@click="openConfigDir"
|
||||||
size="small"
|
size="small"
|
||||||
>打开配置目录</ElButton
|
|
||||||
>
|
>
|
||||||
|
打开配置目录
|
||||||
|
</ElButton>
|
||||||
<ElButton
|
<ElButton
|
||||||
@click="handleStartCommand('toml')"
|
@click="handleStartCommand('toml')"
|
||||||
type="primary"
|
type="primary"
|
||||||
:icon="RefreshRight"
|
:icon="RefreshRight"
|
||||||
size="small"
|
size="small"
|
||||||
>刷新</ElButton
|
|
||||||
>
|
>
|
||||||
|
刷新
|
||||||
|
</ElButton>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-[5px]">
|
<div class="mt-[5px]">
|
||||||
<ElSelect
|
<ElSelect
|
||||||
v-model="mainStore.configPath"
|
v-model="mainStore.configPath"
|
||||||
no-data-text="目录没有配置文件"
|
no-data-text="目录没有配置文件"
|
||||||
placeholder="选择配置文件">
|
placeholder="选择配置文件"
|
||||||
|
>
|
||||||
<ElOption
|
<ElOption
|
||||||
v-for="item in configStart.list"
|
v-for="item in configStart.list"
|
||||||
:key="item.path"
|
:key="item.path"
|
||||||
:value="item.path"
|
:value="item.path"
|
||||||
:label="item.name"></ElOption>
|
:label="item.name"
|
||||||
|
></ElOption>
|
||||||
</ElSelect>
|
</ElSelect>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-[5px] text-right">
|
<div class="mt-[5px] text-right">
|
||||||
<ElButton
|
<ElButton
|
||||||
@click="configStart.visible = false"
|
@click="configStart.visible = false"
|
||||||
type="danger"
|
type="danger"
|
||||||
>关闭</ElButton
|
|
||||||
>
|
>
|
||||||
|
关闭
|
||||||
|
</ElButton>
|
||||||
</div>
|
</div>
|
||||||
</ElDialog>
|
</ElDialog>
|
||||||
</template>
|
</template>
|
||||||
@@ -301,14 +339,14 @@
|
|||||||
import { open, Command } from "@tauri-apps/plugin-shell";
|
import { open, Command } from "@tauri-apps/plugin-shell";
|
||||||
import { QuestionFilled, Delete, List, UserFilled, Setting, Share, RefreshRight } 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 { ElDropdownMenu, 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 { resourceDir as getResourceDir, join } from "@tauri-apps/api/path";
|
||||||
import { readDir, exists, mkdir, BaseDirectory } from "@tauri-apps/plugin-fs";
|
import { readDir, exists, mkdir, BaseDirectory } from "@tauri-apps/plugin-fs";
|
||||||
|
|
||||||
let is_close = false;
|
let is_close = false;
|
||||||
@@ -336,21 +374,22 @@
|
|||||||
coreVersion: "",
|
coreVersion: "",
|
||||||
isSuccessGetIp: false,
|
isSuccessGetIp: false,
|
||||||
startLoading: false,
|
startLoading: false,
|
||||||
isStart: false,
|
isStart: false
|
||||||
});
|
});
|
||||||
|
|
||||||
const configStart = reactive({
|
const configStart = reactive<{ list: Array<{ path: string; name: string }>; [key: string]: any }>({
|
||||||
visible: false,
|
visible: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
list: [], //配置文件列表
|
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();
|
||||||
}
|
}
|
||||||
@@ -381,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;
|
||||||
@@ -390,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);
|
||||||
@@ -398,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;
|
||||||
}
|
}
|
||||||
@@ -406,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 as any);
|
mainStore.$patch(event.payload as any);
|
||||||
config.ipv4 = ipv4;
|
config.ipv4 = ipv4;
|
||||||
});
|
});
|
||||||
this.unListenConfigStart = unListen;
|
this.unListenConfigStart = unListen;
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const unListenAll = async () => {
|
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;
|
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 initConfigDir();
|
||||||
|
await initConnectAfterStart();
|
||||||
closePrevent();
|
closePrevent();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -574,7 +647,7 @@
|
|||||||
// const resourceDir = await getResourceDir();
|
// const resourceDir = await getResourceDir();
|
||||||
// const configPath = await join(resourceDir, mainStore.configPath);
|
// const configPath = await join(resourceDir, mainStore.configPath);
|
||||||
// args.push("-c", configPath);
|
// args.push("-c", configPath);
|
||||||
|
|
||||||
args.push("-c", mainStore.configPath);
|
args.push("-c", mainStore.configPath);
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
@@ -595,7 +668,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");
|
||||||
@@ -611,8 +684,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");
|
||||||
}
|
}
|
||||||
@@ -640,6 +713,9 @@
|
|||||||
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);
|
||||||
|
}
|
||||||
return args;
|
return args;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -650,7 +726,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) {
|
||||||
@@ -661,6 +737,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
await setTrayRunState(tray, false);
|
await setTrayRunState(tray, false);
|
||||||
|
await setTrayTooltip(tray);
|
||||||
await unListenAll();
|
await unListenAll();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -679,7 +756,7 @@
|
|||||||
await listenObj.listenOutput();
|
await listenObj.listenOutput();
|
||||||
|
|
||||||
await invoke("run_command", {
|
await invoke("run_command", {
|
||||||
args,
|
args
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -693,10 +770,10 @@
|
|||||||
if (isExists) {
|
if (isExists) {
|
||||||
const entries = await readDir(path, { baseDir: BaseDirectory.Resource });
|
const entries = await readDir(path, { baseDir: BaseDirectory.Resource });
|
||||||
configStart.list = entries
|
configStart.list = entries
|
||||||
.filter((item) => item.isFile)
|
.filter(item => item.isFile)
|
||||||
.map((item) => ({
|
.map(item => ({
|
||||||
name: item.name,
|
name: item.name,
|
||||||
path: `${path}${item.name}`,
|
path: `${path}${item.name}`
|
||||||
})) as any;
|
})) as any;
|
||||||
} else {
|
} else {
|
||||||
mainStore.configStartEnable = false;
|
mainStore.configStartEnable = false;
|
||||||
@@ -723,7 +800,7 @@
|
|||||||
const openConfigDir = async () => {
|
const openConfigDir = async () => {
|
||||||
const resourceDir = await getResourceDir();
|
const resourceDir = await getResourceDir();
|
||||||
const configPath = await join(resourceDir, import.meta.env.VITE_CONFIG_PATH);
|
const configPath = await join(resourceDir, import.meta.env.VITE_CONFIG_PATH);
|
||||||
console.log(configPath)
|
console.log(configPath);
|
||||||
await Command.create("explorer", [configPath]).execute();
|
await Command.create("explorer", [configPath]).execute();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -741,7 +818,7 @@
|
|||||||
title: "成员列表",
|
title: "成员列表",
|
||||||
width: 470,
|
width: 470,
|
||||||
height: 380,
|
height: 380,
|
||||||
url: "#/member",
|
url: "#/member"
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
data.memberVisible = true;
|
data.memberVisible = true;
|
||||||
@@ -760,7 +837,7 @@
|
|||||||
width: 600,
|
width: 600,
|
||||||
height: 380,
|
height: 380,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
url: "#/log",
|
url: "#/log"
|
||||||
},
|
},
|
||||||
(_, appWindow) => {
|
(_, appWindow) => {
|
||||||
data.logVisible = true;
|
data.logVisible = true;
|
||||||
@@ -783,7 +860,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;
|
||||||
@@ -802,7 +879,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,4 +1,5 @@
|
|||||||
# Generated by Cargo
|
# Generated by Cargo
|
||||||
# will have compiled files and executables
|
# will have compiled files and executables
|
||||||
/target/
|
/target/
|
||||||
/gen/schemas
|
/gen/schemas
|
||||||
|
/easytier/
|
||||||
Generated
+22
-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.9"
|
version = "1.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"planif",
|
"planif",
|
||||||
@@ -1124,6 +1124,8 @@ dependencies = [
|
|||||||
"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",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -5046,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"
|
||||||
@@ -5216,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.9"
|
version = "1.1.0"
|
||||||
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,10 +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"
|
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"
|
||||||
|
|||||||
@@ -45,11 +45,16 @@
|
|||||||
"cmd": "easytier/tool/WinIPBroadcast",
|
"cmd": "easytier/tool/WinIPBroadcast",
|
||||||
"name": "WinIPBroadcast"
|
"name": "WinIPBroadcast"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"args": true,
|
"args": true,
|
||||||
"cmd": "explorer",
|
"cmd": "easytier/tool/nssm",
|
||||||
"name": "explorer"
|
"name": "nssm"
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"args": true,
|
||||||
|
"cmd": "explorer",
|
||||||
|
"name": "explorer"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"fs:default",
|
"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 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)]
|
||||||
@@ -217,6 +225,7 @@ 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 || {
|
||||||
|
// trace, debug, info, warn, error, off
|
||||||
let mut child = Command::new("easytier/easytier-core.exe")
|
let mut child = Command::new("easytier/easytier-core.exe")
|
||||||
.args(args)
|
.args(args)
|
||||||
.creation_flags(0x08000000)
|
.creation_flags(0x08000000)
|
||||||
@@ -341,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)]
|
||||||
@@ -399,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.9",
|
"version": "1.1.0",
|
||||||
"identifier": "com.tauri.easytier-game",
|
"identifier": "com.tauri.easytier-game",
|
||||||
|
|
||||||
"build": {
|
"build": {
|
||||||
@@ -34,9 +34,8 @@
|
|||||||
"targets": "all",
|
"targets": "all",
|
||||||
"resources": [
|
"resources": [
|
||||||
"easytier/config/",
|
"easytier/config/",
|
||||||
|
"easytier/icons/",
|
||||||
"easytier/tool/WinIPBroadcast.exe",
|
"easytier/tool/WinIPBroadcast.exe",
|
||||||
"easytier/icons/icon-inactive.ico",
|
|
||||||
"easytier/icons/icon.ico",
|
|
||||||
"easytier/easytier-cli.exe",
|
"easytier/easytier-cli.exe",
|
||||||
"easytier/easytier-core.exe",
|
"easytier/easytier-core.exe",
|
||||||
"easytier/Packet.dll",
|
"easytier/Packet.dll",
|
||||||
|
|||||||
@@ -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,6 +24,8 @@ 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", //日志等级
|
||||||
},
|
},
|
||||||
configStartEnable: false, //使用配置文件启动
|
configStartEnable: false, //使用配置文件启动
|
||||||
configPath: "", //配置文件路径
|
configPath: "", //配置文件路径
|
||||||
@@ -41,6 +44,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",
|
||||||
@@ -53,6 +57,8 @@ export default defineStore("main", {
|
|||||||
"config.relayAllPeerrpc",
|
"config.relayAllPeerrpc",
|
||||||
"config.hostname",
|
"config.hostname",
|
||||||
"config.dhcp",
|
"config.dhcp",
|
||||||
|
"config.saveErrorLog",
|
||||||
|
"config.logLevel"
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user