mirror of
https://github.com/EasyTier/EasytierGame.git
synced 2025-05-19 10:27:56 +00:00
开机自启功能修复完成
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
// const infoDialog = new WebviewWindow("log", {
|
||||
// title: "日志",
|
||||
// resizable: false,
|
||||
// width: 600,
|
||||
// height: 400,
|
||||
// parent: appWindow,
|
||||
// url: "/log"
|
||||
// });
|
||||
+5
-1
@@ -4,6 +4,7 @@ import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import pkg from "@/package.json";
|
||||
import { setTheme } from "~/composables/theme";
|
||||
import useMainStore from "@/stores/index";
|
||||
import { resourceDir as getResourceDir, join } from "@tauri-apps/api/path";
|
||||
|
||||
const DEFAULT_TRAY_NAME = "main";
|
||||
|
||||
@@ -113,7 +114,10 @@ export async function MenuItemTheme() {
|
||||
|
||||
export async function setTrayRunState(tray: TrayIcon | null, isRunning: boolean = false) {
|
||||
if (!tray) return;
|
||||
await tray.setIcon(isRunning ? "easytier/icons/icon-inactive.ico" : "easytier/icons/icon.ico");
|
||||
const resourceDir = await getResourceDir();
|
||||
const path = await join(resourceDir, isRunning ? "easytier/icons/icon-inactive.ico" : "easytier/icons/icon.ico");
|
||||
// "easytier/icons/icon-inactive.ico", { baseDir: BaseDirectory.Resource }
|
||||
await tray.setIcon(path);
|
||||
}
|
||||
|
||||
export async function setTrayTooltip(tray: TrayIcon | null, tooltip?: string | null) {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
"private": true,
|
||||
"author": "leizi97",
|
||||
"description": "A simple network initiator based on Easytier",
|
||||
"version": "1.1.9",
|
||||
"version": "1.2.0",
|
||||
"scripts": {
|
||||
"dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0",
|
||||
"build": "nuxt generate --dotenv env/.env.prod"
|
||||
|
||||
+87
-120
@@ -2,8 +2,7 @@
|
||||
<ElForm
|
||||
size="small"
|
||||
label-position="top"
|
||||
:model="config"
|
||||
>
|
||||
:model="config">
|
||||
<!-- element-loading-custom-class="config-start"
|
||||
v-loading="mainStore.configStartEnable"
|
||||
:element-loading-spinner="'<path />'"
|
||||
@@ -11,28 +10,24 @@
|
||||
<!-- <div> -->
|
||||
<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>
|
||||
<ElPopconfirm
|
||||
@@ -41,15 +36,13 @@
|
||||
confirm-button-text="继续"
|
||||
title="内核从github下载,需要出国工具,可能下载缓慢或失败,是否继续?
|
||||
也可以从官方群里手动下载后解压到easytier-game.exe同级目录下的easytier目录里,全部覆盖即可"
|
||||
@confirm="handleUpdateCore"
|
||||
>
|
||||
@confirm="handleUpdateCore">
|
||||
<template #reference>
|
||||
<ElButton
|
||||
:disabled="data.isStart"
|
||||
:loading="data.update"
|
||||
type="warning"
|
||||
size="small"
|
||||
>
|
||||
size="small">
|
||||
{{ data.coreVersion ? "更新内核" : "下载内核" }}
|
||||
</ElButton>
|
||||
</template>
|
||||
@@ -62,8 +55,7 @@
|
||||
placeholder="请选择服务器地址"
|
||||
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
|
||||
@@ -72,14 +64,12 @@
|
||||
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>
|
||||
@@ -87,8 +77,7 @@
|
||||
v-for="item in mainStore.basePeers"
|
||||
:key="item"
|
||||
:label="item"
|
||||
:value="item"
|
||||
>
|
||||
:value="item">
|
||||
<div class="flex items-center gap-[20px] overflow-hidden flex-nowrap max-w-[calc(100vw-62px)]">
|
||||
<ElTooltip :content="item">
|
||||
<p class="truncate">{{ item }}</p>
|
||||
@@ -98,8 +87,7 @@
|
||||
@click.stop="handleDeleteServerUrl(item)"
|
||||
round
|
||||
:icon="Delete"
|
||||
type="danger"
|
||||
></ElButton>
|
||||
type="danger"></ElButton>
|
||||
</div>
|
||||
</div>
|
||||
</ElOption>
|
||||
@@ -119,8 +107,7 @@
|
||||
<ElInput
|
||||
maxlength="100"
|
||||
placeholder="请输入网络名"
|
||||
v-model="config.networkName"
|
||||
></ElInput>
|
||||
v-model="config.networkName"></ElInput>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
@@ -138,8 +125,7 @@
|
||||
maxlength="100"
|
||||
placeholder="请输入网络密码"
|
||||
v-model="config.networkPassword"
|
||||
type="password"
|
||||
></ElInput>
|
||||
type="password"></ElInput>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
</div>
|
||||
@@ -156,13 +142,11 @@
|
||||
<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
|
||||
@@ -175,16 +159,14 @@
|
||||
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 && config.dhcp ? '等待动态分配IP...' : '例如: 10.126.126.1'"
|
||||
v-model="config.ipv4"
|
||||
></ElInput>
|
||||
v-model="config.ipv4"></ElInput>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<!-- </div> -->
|
||||
@@ -198,28 +180,24 @@
|
||||
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="import_config"
|
||||
:icon="Link"
|
||||
>
|
||||
:icon="Link">
|
||||
导入配置
|
||||
</ElDropdownItem>
|
||||
<ElDropdownItem
|
||||
command="share_config"
|
||||
:icon="Share"
|
||||
>
|
||||
:icon="Share">
|
||||
分享配置
|
||||
</ElDropdownItem>
|
||||
<ElDropdownItem
|
||||
:icon="Tools"
|
||||
command="toml"
|
||||
:disabled="data.isStart"
|
||||
>
|
||||
:disabled="data.isStart">
|
||||
使用外部配置文件
|
||||
</ElDropdownItem>
|
||||
</ElDropdownMenu>
|
||||
@@ -229,55 +207,47 @@
|
||||
<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 class="ml-auto">
|
||||
<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"
|
||||
>
|
||||
:icon="Share">
|
||||
子网代理
|
||||
</ElButton>
|
||||
<ElButton
|
||||
@click="handleShowAdvanceDialog"
|
||||
:icon="Setting"
|
||||
>
|
||||
:icon="Setting">
|
||||
高级选项
|
||||
</ElButton>
|
||||
</div>
|
||||
@@ -288,8 +258,7 @@
|
||||
type="primary"
|
||||
size="small"
|
||||
:icon="MagicStick"
|
||||
@click="handleShowToolDialog"
|
||||
>
|
||||
@click="handleShowToolDialog">
|
||||
增强工具
|
||||
</ElButton>
|
||||
</div>
|
||||
@@ -297,8 +266,7 @@
|
||||
class="!text-[9px] pb-[2px] ml-[8px] truncate"
|
||||
type="info"
|
||||
:underline="false"
|
||||
@click="open('https://github.com/EasyTier/EasytierGame')"
|
||||
>
|
||||
@click="open('https://github.com/EasyTier/EasytierGame')">
|
||||
EasytierGame主页
|
||||
</ElLink>
|
||||
</div>
|
||||
@@ -313,14 +281,12 @@
|
||||
class="!mb-0"
|
||||
v-model="importConfigData.visible"
|
||||
:close-on-press-escape="false"
|
||||
title="导入分享"
|
||||
>
|
||||
title="导入分享">
|
||||
<ElInput
|
||||
type="textarea"
|
||||
:rows="6"
|
||||
placeholder="请粘贴分享的配置"
|
||||
v-model="importConfigData.data"
|
||||
></ElInput>
|
||||
v-model="importConfigData.data"></ElInput>
|
||||
<template #footer>
|
||||
<div>
|
||||
<el-text type="danger">导入成功后,您当前的部分配置将被替换</el-text>
|
||||
@@ -329,8 +295,7 @@
|
||||
<ElButton
|
||||
size="small"
|
||||
@click="handleStartImport"
|
||||
type="primary"
|
||||
>
|
||||
type="primary">
|
||||
导入
|
||||
</ElButton>
|
||||
</div>
|
||||
@@ -344,8 +309,7 @@
|
||||
class="!mb-0"
|
||||
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>
|
||||
@@ -354,16 +318,14 @@
|
||||
</ElTooltip>
|
||||
<ElButton
|
||||
@click="openConfigDir"
|
||||
size="small"
|
||||
>
|
||||
size="small">
|
||||
打开配置目录
|
||||
</ElButton>
|
||||
<ElButton
|
||||
@click="handleStartCommand('toml')"
|
||||
type="primary"
|
||||
:icon="RefreshRight"
|
||||
size="small"
|
||||
>
|
||||
size="small">
|
||||
刷新
|
||||
</ElButton>
|
||||
</div>
|
||||
@@ -371,14 +333,12 @@
|
||||
<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>
|
||||
<template #footer>
|
||||
@@ -386,8 +346,7 @@
|
||||
<ElButton
|
||||
size="small"
|
||||
@click="configStart.visible = false"
|
||||
type="danger"
|
||||
>
|
||||
type="danger">
|
||||
关闭
|
||||
</ElButton>
|
||||
</div>
|
||||
@@ -443,25 +402,25 @@
|
||||
startLoading: false,
|
||||
isStart: false,
|
||||
connectionSuccess: false,
|
||||
configJsonSeverUrl: "" // 本地保存一次,用于回填config.json
|
||||
configJsonSeverUrl: "", // 本地保存一次,用于回填config.json
|
||||
});
|
||||
|
||||
const configStart = reactive<{ list: Array<{ path: string; name: string }>; [key: string]: any }>({
|
||||
visible: false,
|
||||
loading: false,
|
||||
list: [] //配置文件列表
|
||||
list: [], //配置文件列表
|
||||
});
|
||||
|
||||
const importConfigData = reactive<{ data: ""; [key: string]: any }>({
|
||||
visible: false,
|
||||
loading: false,
|
||||
data: ""
|
||||
data: "",
|
||||
});
|
||||
|
||||
const closePrevent = async () => {
|
||||
const appWindow = getCurrentWindow();
|
||||
if (appWindow.label == "main") {
|
||||
appWindow.onCloseRequested(async event => {
|
||||
appWindow.onCloseRequested(async (event) => {
|
||||
// console.log(appWindow.label);
|
||||
if (!is_close) {
|
||||
// console.log(1);
|
||||
@@ -495,8 +454,9 @@
|
||||
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;
|
||||
// console.log(event.payload);
|
||||
if (event.payload) {
|
||||
data.startLoading = false;
|
||||
let ipv4 = /dhcp ip changed. old: None, new: Some\((\d+\.\d+\.\d+\.\d+).*\)/g.exec(event.payload as string)?.[1];
|
||||
@@ -527,7 +487,7 @@
|
||||
"netsh",
|
||||
["interface", "ipv4", "set", "interface", devName, "metric=", `${mainStore.config.netCardMetricValue}`],
|
||||
{
|
||||
encoding: "gb2312"
|
||||
encoding: "gb2312",
|
||||
}
|
||||
).execute();
|
||||
} catch (err) {
|
||||
@@ -544,7 +504,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;
|
||||
}
|
||||
@@ -552,14 +512,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 () => {
|
||||
@@ -617,6 +577,7 @@
|
||||
const getReleaseList = async () => {
|
||||
const list = await invoke("fetch_easytier_list");
|
||||
data.releaseList = list as never[];
|
||||
console.log(data.releaseList);
|
||||
};
|
||||
|
||||
const handleAutoStart = async () => {
|
||||
@@ -663,17 +624,23 @@
|
||||
|
||||
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;
|
||||
if (is_enable) {
|
||||
await invoke("spawn_autostart", { enabled: true });
|
||||
await tauriAutoStart.disable();
|
||||
}
|
||||
let is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean;
|
||||
if (is_enable_by_task) {
|
||||
// 每次打开Exe重新加载一次开机自启,因为可能路径变了
|
||||
await invoke("spawn_autostart", { enabled: false });
|
||||
await invoke("spawn_autostart", { enabled: true });
|
||||
}
|
||||
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 });
|
||||
await tauriAutoStart.disable();
|
||||
config.autoStart = false;
|
||||
await invoke("spawn_autostart", { enabled: false });
|
||||
const is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean;
|
||||
config.autoStart = is_enable_by_task;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -712,8 +679,8 @@
|
||||
config: {
|
||||
...guiJson,
|
||||
...mainStore.config,
|
||||
serverUrl: saveServerUrl
|
||||
}
|
||||
serverUrl: saveServerUrl,
|
||||
},
|
||||
});
|
||||
if (mainStore.createConfigInEasytier) {
|
||||
await updateConfigJson(data.configJsonSeverUrl);
|
||||
@@ -784,7 +751,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");
|
||||
@@ -800,8 +767,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");
|
||||
}
|
||||
@@ -845,7 +812,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) {
|
||||
@@ -871,7 +838,7 @@
|
||||
if (args[0] === "-c") {
|
||||
ElMessage.warning({
|
||||
message: "使用配置文件中.",
|
||||
duration: 5000
|
||||
duration: 5000,
|
||||
});
|
||||
}
|
||||
data.log = ""; //清空日志
|
||||
@@ -880,7 +847,7 @@
|
||||
await listenObj.listenOutput();
|
||||
|
||||
await invoke("run_command", {
|
||||
args
|
||||
args,
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -894,10 +861,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;
|
||||
@@ -940,14 +907,14 @@
|
||||
try {
|
||||
await ElMessageBox.confirm("确定导入?", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消"
|
||||
cancelButtonText: "取消",
|
||||
});
|
||||
const payload = JSON.parse(decodeURIComponent(atob(importConfigData.data)));
|
||||
mainStore.$patch({
|
||||
config: {
|
||||
...mainStore.config,
|
||||
...payload.config
|
||||
}
|
||||
...payload.config,
|
||||
},
|
||||
});
|
||||
ElMessage.success("导入成功");
|
||||
importConfigData.visible = false;
|
||||
@@ -993,7 +960,7 @@
|
||||
title: "成员列表",
|
||||
width: 470,
|
||||
height: 380,
|
||||
url: "#/member"
|
||||
url: "#/member",
|
||||
},
|
||||
() => {
|
||||
data.memberVisible = true;
|
||||
@@ -1012,7 +979,7 @@
|
||||
width: 600,
|
||||
height: 380,
|
||||
resizable: false,
|
||||
url: "#/log"
|
||||
url: "#/log",
|
||||
},
|
||||
(_, appWindow) => {
|
||||
data.logVisible = true;
|
||||
@@ -1035,7 +1002,7 @@
|
||||
width: 600,
|
||||
height: 380,
|
||||
resizable: false,
|
||||
url: "#/cidr"
|
||||
url: "#/cidr",
|
||||
},
|
||||
(_, appWindow) => {
|
||||
data.cidrVisible = true;
|
||||
@@ -1054,7 +1021,7 @@
|
||||
width: 600,
|
||||
height: 380,
|
||||
resizable: false,
|
||||
url: "#/advance"
|
||||
url: "#/advance",
|
||||
},
|
||||
(_, appWindow) => {
|
||||
data.advanceVisible = true;
|
||||
@@ -1073,7 +1040,7 @@
|
||||
width: 460,
|
||||
height: 480,
|
||||
resizable: true,
|
||||
url: "#/tool"
|
||||
url: "#/tool",
|
||||
},
|
||||
(_, appWindow) => {
|
||||
data.toolVisible = true;
|
||||
|
||||
Generated
+1
-1
@@ -1176,7 +1176,7 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
|
||||
|
||||
[[package]]
|
||||
name = "easytier-game"
|
||||
version = "1.1.9"
|
||||
version = "1.2.0"
|
||||
dependencies = [
|
||||
"log",
|
||||
"planif",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "easytier-game"
|
||||
version = "1.1.9"
|
||||
version = "1.2.0"
|
||||
homepage = "https://github.com/EasyTier/EasyTier"
|
||||
repository = "https://github.com/EasyTier/EasytierGame"
|
||||
description = "A simple network initiator based on Easytier"
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
"args": [
|
||||
"run"
|
||||
],
|
||||
"cmd": "easytier/tool/WinIPBroadcast",
|
||||
"cmd": "$RESOURCE/easytier/tool/WinIPBroadcast",
|
||||
"name": "WinIPBroadcast"
|
||||
}
|
||||
]
|
||||
@@ -53,12 +53,12 @@
|
||||
"args": [
|
||||
"run"
|
||||
],
|
||||
"cmd": "easytier/tool/WinIPBroadcast",
|
||||
"cmd": "$RESOURCE/easytier/tool/WinIPBroadcast",
|
||||
"name": "WinIPBroadcast"
|
||||
},
|
||||
{
|
||||
"args": true,
|
||||
"cmd": "easytier/tool/nssm",
|
||||
"cmd": "$RESOURCE/easytier/tool/nssm",
|
||||
"name": "nssm"
|
||||
},
|
||||
{
|
||||
|
||||
+52
-27
@@ -60,7 +60,8 @@ pub async fn fetch_releases() -> Result<Vec<Release>, Error> {
|
||||
|
||||
#[tauri::command(rename_all = "snake_case")]
|
||||
fn get_core_version() -> String {
|
||||
match Command::new("easytier/easytier-core.exe")
|
||||
let core_path = get_tool_exe_path(String::from("\\easytier\\easytier-core.exe"));
|
||||
match Command::new(&core_path)
|
||||
.arg("--version")
|
||||
.creation_flags(0x08000000)
|
||||
.output()
|
||||
@@ -73,19 +74,27 @@ fn get_core_version() -> String {
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command(rename_all = "snake_case")]
|
||||
fn get_cli_version() -> String {
|
||||
match Command::new("easytier/easytier-cli.exe")
|
||||
.arg("--version")
|
||||
.creation_flags(0x08000000)
|
||||
.output()
|
||||
{
|
||||
Ok(output) => {
|
||||
let output_str = String::from_utf8_lossy(&output.stdout);
|
||||
return output_str.trim().to_string();
|
||||
}
|
||||
Err(_e) => return "".to_string(),
|
||||
}
|
||||
// #[tauri::command(rename_all = "snake_case")]
|
||||
// #[warn(dead_code)]
|
||||
// fn get_cli_version() -> String {
|
||||
// let cli_path = get_tool_exe_path(String::from("\\easytier\\easytier-cli.exe"));
|
||||
// match Command::new(&cli_path)
|
||||
// .arg("--version")
|
||||
// .creation_flags(0x08000000)
|
||||
// .output()
|
||||
// {
|
||||
// Ok(output) => {
|
||||
// let output_str = String::from_utf8_lossy(&output.stdout);
|
||||
// return output_str.trim().to_string();
|
||||
// }
|
||||
// Err(_e) => return "".to_string(),
|
||||
// }
|
||||
// }
|
||||
|
||||
fn get_tool_exe_path(path: String) -> String {
|
||||
let cur_vec = get_exe_directory();
|
||||
let tool_path = cur_vec[1].to_string() + &path.to_string();
|
||||
return tool_path;
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
@@ -122,7 +131,8 @@ struct MyResponse {
|
||||
|
||||
#[tauri::command(rename_all = "snake_case")]
|
||||
fn get_members_by_cli() -> String {
|
||||
match Command::new("easytier/easytier-cli.exe")
|
||||
let cli_path = get_tool_exe_path(String::from("\\easytier\\easytier-cli.exe"));
|
||||
match Command::new(&cli_path)
|
||||
.arg("peer")
|
||||
.arg("list")
|
||||
.creation_flags(0x08000000)
|
||||
@@ -142,14 +152,17 @@ async fn download_easytier_zip(download_url: String, file_name: String) {
|
||||
let response = reqwest::get(target)
|
||||
.await
|
||||
.expect("error to download easytier url");
|
||||
let file_path = format!("./easytier/{}", file_name);
|
||||
let easytier_path = get_tool_exe_path(String::from("\\easytier"));
|
||||
let file_path = format!("{}\\{}", easytier_path, file_name);
|
||||
println!("download easytier to {}", file_path);
|
||||
|
||||
let easytier_dir = path::Path::new("./easytier");
|
||||
let easytier_dir = path::Path::new(&easytier_path);
|
||||
if !easytier_dir.exists() {
|
||||
fs::create_dir_all(&easytier_dir).unwrap();
|
||||
}
|
||||
|
||||
let path = path::Path::new(&file_path);
|
||||
println!("download easytier to {}", path.display());
|
||||
|
||||
let mut file = match File::create(&path) {
|
||||
Err(why) => panic!("couldn't create {}", why),
|
||||
@@ -197,8 +210,8 @@ fn unzip(fname: &path::Path) {
|
||||
// fs::create_dir_all(p).unwrap();
|
||||
// }
|
||||
// }
|
||||
|
||||
let easytier_dir = path::Path::new("./easytier");
|
||||
let easytier_path = get_tool_exe_path(String::from("\\easytier"));
|
||||
let easytier_dir = path::Path::new(&easytier_path);
|
||||
// if !easytier_dir.exists() {
|
||||
// fs::create_dir_all(&easytier_dir).unwrap();
|
||||
// }
|
||||
@@ -225,8 +238,9 @@ fn run_command(
|
||||
let stop_signal2 = Arc::clone(&stop_signal);
|
||||
let args2 = args.clone();
|
||||
thread::spawn(move || {
|
||||
let core_path = get_tool_exe_path(String::from("\\easytier\\easytier-core.exe"));
|
||||
// trace, debug, info, warn, error, off
|
||||
let mut child = Command::new("easytier/easytier-core.exe")
|
||||
let mut child = Command::new(&core_path)
|
||||
.args(args)
|
||||
.creation_flags(0x08000000)
|
||||
.stdout(Stdio::piped())
|
||||
@@ -355,7 +369,7 @@ 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());
|
||||
// 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;
|
||||
@@ -436,6 +450,8 @@ fn autostart_is_enabled() -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
pub const AUTOSTART_ARG: &str = "--autostart";
|
||||
pub const TASKAUTOSTART_ARG: &str = "--task-auto-start";
|
||||
fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error>> {
|
||||
if !enabled {
|
||||
unsafe {
|
||||
@@ -486,7 +502,7 @@ fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error
|
||||
sb.create_logon()
|
||||
.author("heixiansen")?
|
||||
.trigger("trigger", enabled)?
|
||||
.action(Action::new("auto start", exe, "", ""))?
|
||||
.action(Action::new("auto start", exe, "", &TASKAUTOSTART_ARG))?
|
||||
.in_folder("easytierGame")?
|
||||
.principal(settings)?
|
||||
.delay(Duration {
|
||||
@@ -499,10 +515,11 @@ fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub const AUTOSTART_ARG: &str = "--autostart";
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
// 获取命令行参数
|
||||
let _args: Vec<String> = std::env::args().collect();
|
||||
|
||||
let stop_signal = Arc::new(AtomicBool::new(false)); // 创建一个原子布尔值,用于控制命令的停止
|
||||
let stop_signal_clone = Arc::clone(&stop_signal); // 创建一个原子布尔值的克隆,用于传递给命令
|
||||
let context = tauri::generate_context!();
|
||||
@@ -518,9 +535,11 @@ pub fn run() {
|
||||
let _ = app
|
||||
.get_webview_window("main")
|
||||
.expect("no main window")
|
||||
.set_focus();
|
||||
.set_focus()
|
||||
.expect("failed to set focus");
|
||||
}))
|
||||
.setup(|app| {
|
||||
.setup(move |app| {
|
||||
// let args = args.clone();
|
||||
if cfg!(debug_assertions) {
|
||||
app.handle().plugin(
|
||||
tauri_plugin_log::Builder::default()
|
||||
@@ -547,6 +566,13 @@ pub fn run() {
|
||||
))?)
|
||||
.icon_as_template(false)
|
||||
.build(app)?;
|
||||
// 开机自启隐藏到托盘
|
||||
// if args.contains(&String::from(TASKAUTOSTART_ARG)) {
|
||||
// app.get_webview_window("main")
|
||||
// .expect("no main window to hide")
|
||||
// .hide()?;
|
||||
// }
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.manage(stop_signal_clone)
|
||||
@@ -556,7 +582,6 @@ pub fn run() {
|
||||
get_core_version,
|
||||
fetch_easytier_list,
|
||||
download_easytier_zip,
|
||||
get_cli_version,
|
||||
get_members_by_cli,
|
||||
search_pid_by_pname,
|
||||
get_exe_directory,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "easytier-game",
|
||||
"version": "1.1.9",
|
||||
"version": "1.2.0",
|
||||
"identifier": "com.tauri.easytier-game",
|
||||
|
||||
"build": {
|
||||
@@ -13,7 +13,7 @@
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "easytier-game 1.1.9",
|
||||
"title": "easytier-game 1.2.0",
|
||||
"minWidth": 340,
|
||||
"width": 340,
|
||||
"height": 305,
|
||||
|
||||
Reference in New Issue
Block a user