mirror of
https://github.com/EasyTier/EasytierGame.git
synced 2025-05-19 10:27:56 +00:00
#improvement 联机成功后右下角角标增加绿点,优化二级窗口创建逻辑修复控制台报错,增加开机自启功能,禁用p2p默认改为不禁用
This commit is contained in:
+69
-74
@@ -1,89 +1,86 @@
|
||||
import { Menu, MenuItem, PredefinedMenuItem } from '@tauri-apps/api/menu'
|
||||
import { TrayIcon } from '@tauri-apps/api/tray'
|
||||
import { getCurrentWindow } from '@tauri-apps/api/window'
|
||||
import pkg from '@/package.json'
|
||||
import { Menu, MenuItem, PredefinedMenuItem } from "@tauri-apps/api/menu";
|
||||
import { TrayIcon } from "@tauri-apps/api/tray";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import pkg from "@/package.json";
|
||||
|
||||
const DEFAULT_TRAY_NAME = 'main'
|
||||
const DEFAULT_TRAY_NAME = "main";
|
||||
|
||||
async function toggleVisibility() {
|
||||
if (await getCurrentWindow().isVisible()) {
|
||||
await getCurrentWindow().hide()
|
||||
}
|
||||
else {
|
||||
await getCurrentWindow().show()
|
||||
await getCurrentWindow().setFocus()
|
||||
}
|
||||
if (await getCurrentWindow().isVisible()) {
|
||||
await getCurrentWindow().hide();
|
||||
} else {
|
||||
await getCurrentWindow().show();
|
||||
await getCurrentWindow().setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
export async function useTray(init: boolean = false, beforExit) {
|
||||
let tray
|
||||
try {
|
||||
tray = await TrayIcon.getById(DEFAULT_TRAY_NAME)
|
||||
if (!tray) {
|
||||
tray = await TrayIcon.new({
|
||||
tooltip: `EasyTier\n${pkg.version}`,
|
||||
title: `EasyTier\n${pkg.version}`,
|
||||
id: DEFAULT_TRAY_NAME,
|
||||
menu: await Menu.new({
|
||||
id: 'main',
|
||||
items: await generateMenuItem(beforExit),
|
||||
}),
|
||||
action: async (e) => {
|
||||
toggleVisibility()
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.warn('Error while creating tray icon:', error)
|
||||
return null
|
||||
}
|
||||
export async function useTray(init: boolean = false, beforExit: Function) {
|
||||
let tray;
|
||||
try {
|
||||
tray = await TrayIcon.getById(DEFAULT_TRAY_NAME);
|
||||
if (!tray) {
|
||||
tray = await TrayIcon.new({
|
||||
tooltip: `EasyTier\n${pkg.version}`,
|
||||
title: `EasyTier\n${pkg.version}`,
|
||||
id: DEFAULT_TRAY_NAME,
|
||||
menu: await Menu.new({
|
||||
id: "main",
|
||||
items: await generateMenuItem(beforExit)
|
||||
}),
|
||||
action: async e => {
|
||||
toggleVisibility();
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn("Error while creating tray icon:", error);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (init) {
|
||||
tray.setTooltip(`EasyTier\n${pkg.version}`)
|
||||
tray.setMenuOnLeftClick(false)
|
||||
tray.setMenu(await Menu.new({
|
||||
id: 'main',
|
||||
items: await generateMenuItem(beforExit),
|
||||
}))
|
||||
}
|
||||
if (init) {
|
||||
tray.setTooltip(`EasyTier\n${pkg.version}`);
|
||||
tray.setMenuOnLeftClick(false);
|
||||
tray.setMenu(
|
||||
await Menu.new({
|
||||
id: "main",
|
||||
items: await generateMenuItem(beforExit)
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return tray
|
||||
return tray;
|
||||
}
|
||||
|
||||
export async function generateMenuItem(beforExit: Function) {
|
||||
return [
|
||||
await MenuItemExit('退出', beforExit),
|
||||
await PredefinedMenuItem.new({ item: 'Separator' }),
|
||||
await MenuItemShow('显示 / 隐藏'),
|
||||
]
|
||||
return [await MenuItemExit("退出", beforExit), await PredefinedMenuItem.new({ item: "Separator" }), await MenuItemShow("显示 / 隐藏")];
|
||||
}
|
||||
|
||||
export async function MenuItemExit(text: string, beforExit: Function) {
|
||||
return await MenuItem.new({
|
||||
id: "quit",
|
||||
text,
|
||||
action: async () => {
|
||||
if (beforExit) {
|
||||
await beforExit();
|
||||
}
|
||||
await getCurrentWindow().close();
|
||||
}
|
||||
})
|
||||
return await MenuItem.new({
|
||||
id: "quit",
|
||||
text,
|
||||
action: async () => {
|
||||
if (beforExit) {
|
||||
await beforExit();
|
||||
}
|
||||
await getCurrentWindow().close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export async function MenuItemShow(text: string) {
|
||||
return await MenuItem.new({
|
||||
id: 'show',
|
||||
text,
|
||||
action: async () => {
|
||||
await toggleVisibility()
|
||||
},
|
||||
})
|
||||
return await MenuItem.new({
|
||||
id: "show",
|
||||
text,
|
||||
action: async () => {
|
||||
await toggleVisibility();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// export async function setTrayMenu(items: (MenuItem | PredefinedMenuItem)[] | undefined = undefined) {
|
||||
// const tray = await useTray()
|
||||
// // const tray = await useTray()
|
||||
// const tray = await TrayIcon.getById(DEFAULT_TRAY_NAME)
|
||||
// if (!tray)
|
||||
// return
|
||||
// const menu = await Menu.new({
|
||||
@@ -93,12 +90,10 @@ export async function MenuItemShow(text: string) {
|
||||
// tray.setMenu(menu)
|
||||
// }
|
||||
|
||||
// export async function setTrayRunState(isRunning: boolean = false) {
|
||||
// const tray = await useTray()
|
||||
// if (!tray)
|
||||
// return
|
||||
// tray.setIcon(isRunning ? 'icons/icon-inactive.ico' : 'icons/icon.ico')
|
||||
// }
|
||||
export async function setTrayRunState(tray: TrayIcon | null, isRunning: boolean = false) {
|
||||
if (!tray) return;
|
||||
tray.setIcon(isRunning ? "icons/icon-inactive.ico" : "icons/icon.ico");
|
||||
}
|
||||
|
||||
// export async function setTrayTooltip(tooltip: string) {
|
||||
// if (tooltip) {
|
||||
@@ -108,4 +103,4 @@ export async function MenuItemShow(text: string) {
|
||||
// tray.setTooltip(`EasyTier\n${pkg.version}\n${tooltip}`)
|
||||
// tray.setTitle(`EasyTier\n${pkg.version}\n${tooltip}`)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ export default defineNuxtConfig({
|
||||
sourcemap: !!process.env.TAURI_DEBUG
|
||||
},
|
||||
esbuild: {
|
||||
pure: ["console.log"],
|
||||
// pure: ["console.log"],
|
||||
drop: ["debugger"]
|
||||
}
|
||||
},
|
||||
|
||||
+6
-3
@@ -3,7 +3,7 @@
|
||||
"private": true,
|
||||
"author": "leizi97",
|
||||
"description": "A simple network initiator based on Easytier",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"scripts": {
|
||||
"dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0",
|
||||
"build": "nuxt generate --dotenv env/.env.prod"
|
||||
@@ -18,6 +18,7 @@
|
||||
"@tauri-apps/cli": "^2.0.2",
|
||||
"@tauri-apps/plugin-cli": "^2.0.0",
|
||||
"@tauri-apps/plugin-http": "^2.0.0",
|
||||
"@tauri-apps/plugin-shell": "~2",
|
||||
"@tinymce/tinymce-vue": "^5.1.1",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/qs": "^6.9.15",
|
||||
@@ -35,7 +36,9 @@
|
||||
"typescript": "^5.4.5",
|
||||
"vue": "^3.4.24",
|
||||
"vue-clipboard3": "^2.0.0",
|
||||
"xlsx": "^0.18.5",
|
||||
"@tauri-apps/plugin-shell": "~2"
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tauri-apps/plugin-autostart": "~2"
|
||||
}
|
||||
}
|
||||
|
||||
+149
-81
@@ -218,41 +218,50 @@
|
||||
>
|
||||
禁用ipv6
|
||||
</ElCheckbox>
|
||||
<ElCheckbox
|
||||
@change="handleAutoStart"
|
||||
:model-value="config.autoStart"
|
||||
size="small"
|
||||
>
|
||||
开机自启
|
||||
</ElCheckbox>
|
||||
<ElCheckbox
|
||||
v-model="config.disbleListenner"
|
||||
size="small"
|
||||
>
|
||||
禁用端口监听
|
||||
</ElCheckbox>
|
||||
<ElLink
|
||||
class="!text-[11px] pb-[2px] ml-[15px]"
|
||||
type="info"
|
||||
:underline="false"
|
||||
@click="open('https://github.com/EasyTier/EasyTier/releases')"
|
||||
>
|
||||
easytier发布页
|
||||
</ElLink>
|
||||
<div class="flex items-center gap-[0_5px]">
|
||||
<div>
|
||||
<ElLink
|
||||
class="!text-[11px]"
|
||||
type="info"
|
||||
:underline="false"
|
||||
@click="open('https://github.com/dechamps/WinIPBroadcast/releases/tag/winipbroadcast-1.6')"
|
||||
>
|
||||
WinIPBroadcast
|
||||
<ElTooltip content="找不到游戏房间时,就开启它后再刷新尝试(默认开启)">
|
||||
<ElIcon class="ml-[3px]"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</ElLink>
|
||||
<ElSwitch
|
||||
inline-prompt
|
||||
:model-value="data.winipBcStart"
|
||||
@change="handleWinipBcStart"
|
||||
size="small"
|
||||
label="WinIPBroadcast"
|
||||
active-text="开启"
|
||||
inactive-text="关闭"
|
||||
></ElSwitch>
|
||||
</div>
|
||||
<ElLink
|
||||
class="!text-[11px]"
|
||||
class="!text-[11px] pb-[2px] ml-[15px]"
|
||||
type="info"
|
||||
:underline="false"
|
||||
@click="open('https://github.com/dechamps/WinIPBroadcast/releases/tag/winipbroadcast-1.6')"
|
||||
@click="open('https://github.com/EasyTier/EasytierGame')"
|
||||
>
|
||||
WinIPBroadcast
|
||||
<ElTooltip content="找不到游戏房间时,就开启它后再刷新尝试(默认开启)">
|
||||
<ElIcon class="ml-[3px]"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
主页
|
||||
</ElLink>
|
||||
<ElSwitch
|
||||
inline-prompt
|
||||
:model-value="data.winipBcStart"
|
||||
@change="handleWinipBcStart"
|
||||
size="small"
|
||||
label="WinIPBroadcast"
|
||||
active-text="开启"
|
||||
inactive-text="关闭"
|
||||
></ElSwitch>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -260,19 +269,20 @@
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
|
||||
import { open, Command } from "@tauri-apps/plugin-shell";
|
||||
import { QuestionFilled, Delete, List, UserFilled } from "@element-plus/icons-vue";
|
||||
import { reactive, onBeforeUnmount, onMounted } from "vue";
|
||||
import { useTray } from "~/composables/tray";
|
||||
import { useTray, setTrayRunState } from "~/composables/tray";
|
||||
import useMainStore from "@/stores/index";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { getCurrentWindow, LogicalPosition } from "@tauri-apps/api/window";
|
||||
import { getCurrentWindow, LogicalPosition, PhysicalPosition } from "@tauri-apps/api/window";
|
||||
import { WebviewWindow, getAllWebviewWindows } from "@tauri-apps/api/webviewWindow";
|
||||
import * as tauriAutoStart from "@tauri-apps/plugin-autostart";
|
||||
|
||||
let is_close = false;
|
||||
|
||||
useTray(true, async () => {
|
||||
const tray = await useTray(true, async () => {
|
||||
is_close = true;
|
||||
await invoke("stop_command", { child_id: listenObj.thread_id || 0 });
|
||||
await invoke("stop_command", { child_id: data.winipBcPid || 0 });
|
||||
@@ -299,7 +309,7 @@
|
||||
const appWindow = getCurrentWindow();
|
||||
if (appWindow.label == "main") {
|
||||
appWindow.onCloseRequested(async event => {
|
||||
// console.log(appWindow.label);
|
||||
console.log(appWindow.label);
|
||||
if (!is_close) {
|
||||
event.preventDefault();
|
||||
appWindow.hide();
|
||||
@@ -330,13 +340,14 @@
|
||||
thread_id: null,
|
||||
async listenOutput() {
|
||||
const appWindow = getCurrentWindow();
|
||||
const unListen = await listen("command-output", event => {
|
||||
const unListen = await listen("command-output", async event => {
|
||||
data.isStart = true;
|
||||
if (event.payload) {
|
||||
data.startLoading = false;
|
||||
let ipv4 = /new: Some\((\d+\.\d+\.\d+\.\d+)\/.*\)/g.exec(event.payload as string)?.[1];
|
||||
if (ipv4) {
|
||||
data.isSuccessGetIp = true;
|
||||
await setTrayRunState(tray, true);
|
||||
config.ipv4 = ipv4;
|
||||
}
|
||||
}
|
||||
@@ -431,10 +442,10 @@
|
||||
if (data.winipBcPid) {
|
||||
data.winipBcStart = true;
|
||||
} else {
|
||||
Elmessage.error(`启动失败`);
|
||||
ElMessage.error(`启动失败`);
|
||||
}
|
||||
} catch (err) {
|
||||
Elmessage.error(`启动失败`);
|
||||
ElMessage.error(`启动失败`);
|
||||
console.log(err);
|
||||
}
|
||||
} else {
|
||||
@@ -449,11 +460,48 @@
|
||||
await handleWinipBcStart();
|
||||
}
|
||||
};
|
||||
|
||||
let logsTimer = null;
|
||||
|
||||
const handleAutoStart = async () => {
|
||||
let is_enable = await tauriAutoStart.isEnabled();
|
||||
if (!config.autoStart && !is_enable) {
|
||||
try {
|
||||
await tauriAutoStart.enable();
|
||||
} catch (err) {
|
||||
ElMessage.error(`开机自启失败`);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
await tauriAutoStart.disable();
|
||||
} catch (err) {
|
||||
// ElMessage.error(`取消自启失败`);
|
||||
}
|
||||
}
|
||||
is_enable = await tauriAutoStart.isEnabled();
|
||||
if (!is_enable) {
|
||||
config.autoStart = false;
|
||||
} else {
|
||||
config.autoStart = true;
|
||||
}
|
||||
};
|
||||
|
||||
const initAutoStart = async () => {
|
||||
try {
|
||||
const is_enable = await tauriAutoStart.isEnabled();
|
||||
if (!is_enable) {
|
||||
config.autoStart = false;
|
||||
} else {
|
||||
config.autoStart = true;
|
||||
}
|
||||
} catch (err) {
|
||||
config.autoStart = false;
|
||||
}
|
||||
};
|
||||
|
||||
let logsTimer: NodeJS.Timeout | null = null;
|
||||
|
||||
onMounted(async () => {
|
||||
// await handleUpdateCore(); //默认不自动更新
|
||||
await initAutoStart();
|
||||
await initStartWinIpBroadcast();
|
||||
await getCoreVersion();
|
||||
await listenObj.listenThreadId();
|
||||
@@ -502,7 +550,9 @@
|
||||
const reset = async () => {
|
||||
data.isStart = false;
|
||||
data.isSuccessGetIp = false;
|
||||
config.ipv4 = "";
|
||||
if (config.dhcp) {
|
||||
config.ipv4 = "";
|
||||
}
|
||||
const memberDialog = await getAllWebviewWindows();
|
||||
const memberDialogs = memberDialog.filter(item => item.label === "member");
|
||||
if (memberDialogs && memberDialogs.length > 0) {
|
||||
@@ -514,7 +564,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await setTrayRunState(tray, false);
|
||||
await unListenAll();
|
||||
};
|
||||
|
||||
@@ -532,19 +582,24 @@
|
||||
}
|
||||
};
|
||||
|
||||
let unListenMemberClose: UnlistenFn | null = null;
|
||||
let unlistenMemberCreated: UnlistenFn | null = null;
|
||||
const handleShowMemberDialog = async () => {
|
||||
try {
|
||||
if (!data.isStart) {
|
||||
return ElMessage.warning("请先开始联机");
|
||||
}
|
||||
if (!mainStore.config.ipv4) {
|
||||
return ElMessage.warning("请等待获取IP");
|
||||
}
|
||||
const appWindow = getCurrentWindow();
|
||||
const appSize = await appWindow.innerSize();
|
||||
if (!data.isStart) {
|
||||
return ElMessage.warning("请先开始联机");
|
||||
}
|
||||
if (!mainStore.config.ipv4) {
|
||||
return ElMessage.warning("请等待获取IP");
|
||||
}
|
||||
const appWindow = getCurrentWindow();
|
||||
if (appWindow) {
|
||||
const appSize = await appWindow.outerSize();
|
||||
const factor = await appWindow.scaleFactor();
|
||||
const appPosition = await appWindow.outerPosition();
|
||||
if (appWindow) {
|
||||
const memberDialog = new WebviewWindow("member", {
|
||||
const logicalPosition = new PhysicalPosition(appPosition.x + appSize.width, appPosition.y).toLogical(factor);
|
||||
let memberDialog = await WebviewWindow.getByLabel("member");
|
||||
if (!memberDialog) {
|
||||
memberDialog = new WebviewWindow("member", {
|
||||
title: "成员列表",
|
||||
width: 470,
|
||||
height: 380,
|
||||
@@ -554,36 +609,44 @@
|
||||
decorations: true,
|
||||
maximizable: false,
|
||||
minimizable: false,
|
||||
x: appPosition.x + appSize.width + 10,
|
||||
y: appPosition.y,
|
||||
x: logicalPosition.x,
|
||||
y: logicalPosition.y,
|
||||
url: "#/member"
|
||||
});
|
||||
if (!data.memberVisible) {
|
||||
data.memberVisible = true;
|
||||
memberDialog.onCloseRequested(() => {
|
||||
data.logVisible = false;
|
||||
});
|
||||
const appWindow = getCurrentWindow();
|
||||
} else {
|
||||
unlistenMemberCreated = await memberDialog.once("tauri://webview-created", async () => {
|
||||
if (memberDialog) {
|
||||
data.logVisible = true;
|
||||
await memberDialog.show();
|
||||
}
|
||||
});
|
||||
unListenMemberClose = await memberDialog.onCloseRequested(() => {
|
||||
data.logVisible = false;
|
||||
unListenMemberClose && unListenMemberClose();
|
||||
});
|
||||
} else {
|
||||
const visible = await memberDialog.isVisible();
|
||||
if (visible) {
|
||||
data.memberVisible = false;
|
||||
memberDialog.destroy();
|
||||
await memberDialog.close();
|
||||
unlistenMemberCreated && unlistenMemberCreated();
|
||||
}
|
||||
|
||||
// await memberDialog.setPosition(new LogicalPosition(appPosition.x + appSize.width + 10, appPosition.y));
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
};
|
||||
|
||||
let unListenlogClose: UnlistenFn | null = null;
|
||||
let unlistenLogCreated: UnlistenFn | null = null;
|
||||
const handleShowLogDialog = async () => {
|
||||
try {
|
||||
logsTimer && clearInterval(logsTimer);
|
||||
const appWindow = getCurrentWindow();
|
||||
const appSize = await appWindow.innerSize();
|
||||
logsTimer && clearInterval(logsTimer);
|
||||
const appWindow = getCurrentWindow();
|
||||
if (appWindow) {
|
||||
const appSize = await appWindow.outerSize();
|
||||
const factor = await appWindow.scaleFactor();
|
||||
const appPosition = await appWindow.outerPosition();
|
||||
if (appWindow) {
|
||||
const infoDialog = new WebviewWindow("log", {
|
||||
const logicalPosition = new PhysicalPosition(appPosition.x + appSize.width, appPosition.y).toLogical(factor);
|
||||
let infoDialog = await WebviewWindow.getByLabel("log");
|
||||
if (!infoDialog) {
|
||||
infoDialog = new WebviewWindow("log", {
|
||||
title: "日志",
|
||||
width: 600,
|
||||
height: 380,
|
||||
@@ -593,26 +656,31 @@
|
||||
decorations: true,
|
||||
maximizable: false,
|
||||
minimizable: false,
|
||||
x: appPosition.x + appSize.width + 10,
|
||||
y: appPosition.y,
|
||||
x: logicalPosition.x,
|
||||
y: logicalPosition.y,
|
||||
url: "#/log"
|
||||
});
|
||||
if (!data.logVisible) {
|
||||
data.logVisible = true;
|
||||
infoDialog.onCloseRequested(() => {
|
||||
data.logVisible = false;
|
||||
});
|
||||
|
||||
logsTimer = setInterval(() => {
|
||||
appWindow.emitTo("log", "logs", data.log);
|
||||
}, 3000);
|
||||
} else {
|
||||
unlistenLogCreated = await infoDialog.once("tauri://webview-created", async () => {
|
||||
if (infoDialog) {
|
||||
data.logVisible = true;
|
||||
logsTimer = setInterval(() => {
|
||||
appWindow.emitTo("log", "logs", data.log);
|
||||
}, 3000);
|
||||
await infoDialog.show();
|
||||
}
|
||||
});
|
||||
unListenlogClose = await infoDialog.onCloseRequested(() => {
|
||||
data.logVisible = false;
|
||||
infoDialog.destroy();
|
||||
unListenlogClose && unListenlogClose();
|
||||
});
|
||||
} else {
|
||||
const visible = await infoDialog.isVisible();
|
||||
if (visible) {
|
||||
data.logVisible = false;
|
||||
await infoDialog.close();
|
||||
unlistenLogCreated && unlistenLogCreated();
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@
|
||||
const showTableHeader = [
|
||||
["ipv4", "虚拟网IP"],
|
||||
["hostname", "主机名"],
|
||||
["cost", "方式"],
|
||||
["cost", "路由"],
|
||||
["lat_ms", "延迟/ms"],
|
||||
["loss_rate", "丢包率"],
|
||||
["version", "版本"]
|
||||
|
||||
Generated
+11
@@ -7,6 +7,10 @@ settings:
|
||||
importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
'@tauri-apps/plugin-autostart':
|
||||
specifier: ~2
|
||||
version: 2.0.0
|
||||
devDependencies:
|
||||
'@element-plus/icons-vue':
|
||||
specifier: ^2.3.1
|
||||
@@ -1008,6 +1012,9 @@ packages:
|
||||
engines: {node: '>= 10'}
|
||||
hasBin: true
|
||||
|
||||
'@tauri-apps/plugin-autostart@2.0.0':
|
||||
resolution: {integrity: sha512-NEwOQWVasZ8RczXkMLNJokRDujneuMH/UFA5t84DLkbNZUmiD3G7HZWhgSd1YQ0BFU9h9w+h2B/py3y6bzWg4Q==}
|
||||
|
||||
'@tauri-apps/plugin-cli@2.0.0':
|
||||
resolution: {integrity: sha512-glQmlL1IiCGEa1FHYa/PTPSeYhfu56omLRgHXWlJECDt6DbJyRuJWVgtkQfUxtqnVdYnnU+DGIGeiInoEqtjLw==}
|
||||
|
||||
@@ -5568,6 +5575,10 @@ snapshots:
|
||||
'@tauri-apps/cli-win32-ia32-msvc': 2.0.2
|
||||
'@tauri-apps/cli-win32-x64-msvc': 2.0.2
|
||||
|
||||
'@tauri-apps/plugin-autostart@2.0.0':
|
||||
dependencies:
|
||||
'@tauri-apps/api': 2.0.2
|
||||
|
||||
'@tauri-apps/plugin-cli@2.0.0':
|
||||
dependencies:
|
||||
'@tauri-apps/api': 2.0.2
|
||||
|
||||
Generated
+62
-6
@@ -288,6 +288,17 @@ version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
||||
|
||||
[[package]]
|
||||
name = "auto-launch"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f012b8cc0c850f34117ec8252a44418f2e34a2cf501de89e29b241ae5f79471"
|
||||
dependencies = [
|
||||
"dirs 4.0.0",
|
||||
"thiserror",
|
||||
"winreg 0.10.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.4.0"
|
||||
@@ -979,13 +990,33 @@ dependencies = [
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "4.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"
|
||||
dependencies = [
|
||||
"dirs-sys 0.3.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "5.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
"dirs-sys 0.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"redox_users",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1078,7 +1109,7 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
|
||||
|
||||
[[package]]
|
||||
name = "easytier-game"
|
||||
version = "1.0.5"
|
||||
version = "1.0.6"
|
||||
dependencies = [
|
||||
"log",
|
||||
"reqwest",
|
||||
@@ -1087,6 +1118,7 @@ dependencies = [
|
||||
"sysinfo",
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
"tauri-plugin-autostart",
|
||||
"tauri-plugin-log",
|
||||
"tauri-plugin-shell",
|
||||
"tauri-plugin-single-instance",
|
||||
@@ -1110,7 +1142,7 @@ dependencies = [
|
||||
"rustc_version",
|
||||
"toml 0.8.2",
|
||||
"vswhom",
|
||||
"winreg",
|
||||
"winreg 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4086,7 +4118,7 @@ checksum = "5920aad0804ea5e86808d4b6e8753d3bcbae7efc8f4e41a4da00b45427559868"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
"dirs",
|
||||
"dirs 5.0.1",
|
||||
"dunce",
|
||||
"embed_plist",
|
||||
"futures-util",
|
||||
@@ -4137,7 +4169,7 @@ checksum = "935f9b3c49b22b3e2e485a57f46d61cd1ae07b1cbb2ba87387a387caf2d8c4e7"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cargo_toml",
|
||||
"dirs",
|
||||
"dirs 5.0.1",
|
||||
"glob",
|
||||
"heck 0.5.0",
|
||||
"json-patch",
|
||||
@@ -4209,6 +4241,21 @@ dependencies = [
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-autostart"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bba6bb936e0fd0a58ed958b49e2e423dd40949c9d9425cc991be996959e3838e"
|
||||
dependencies = [
|
||||
"auto-launch",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tauri",
|
||||
"tauri-plugin",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-log"
|
||||
version = "2.0.1"
|
||||
@@ -4609,7 +4656,7 @@ checksum = "533fc2d4105e0e3d96ce1c71f2d308c9fbbe2ef9c587cab63dd627ab5bde218f"
|
||||
dependencies = [
|
||||
"core-graphics",
|
||||
"crossbeam-channel",
|
||||
"dirs",
|
||||
"dirs 5.0.1",
|
||||
"libappindicator",
|
||||
"muda",
|
||||
"objc2",
|
||||
@@ -5430,6 +5477,15 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winreg"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winreg"
|
||||
version = "0.52.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "easytier-game"
|
||||
version = "1.0.5"
|
||||
version = "1.0.6"
|
||||
homepage = "https://github.com/EasyTier/EasyTier"
|
||||
repository = "https://github.com/EasyTier/EasytierGame"
|
||||
description = "A simple network initiator based on Easytier"
|
||||
@@ -38,4 +38,5 @@ sysinfo = '0.32.0'
|
||||
# prost-types = "0.13"
|
||||
|
||||
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
|
||||
tauri-plugin-autostart = "2"
|
||||
tauri-plugin-single-instance = "2"
|
||||
|
||||
@@ -20,6 +20,12 @@
|
||||
"core:webview:allow-webview-show",
|
||||
"core:webview:allow-webview-hide",
|
||||
"core:webview:allow-webview-close",
|
||||
"autostart:allow-enable",
|
||||
"autostart:allow-disable",
|
||||
"autostart:allow-is-enabled",
|
||||
"core:tray:allow-get-by-id",
|
||||
"core:tray:allow-set-icon",
|
||||
"core:tray:allow-new",
|
||||
{
|
||||
"identifier": "shell:allow-spawn",
|
||||
"allow": [
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"identifier": "desktop-capability",
|
||||
"platforms": [
|
||||
"macOS",
|
||||
"windows",
|
||||
"linux"
|
||||
],
|
||||
"permissions": [
|
||||
"autostart:default"
|
||||
]
|
||||
}
|
||||
@@ -14,6 +14,8 @@ use sysinfo::System;
|
||||
use tauri::tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent};
|
||||
use tauri::Emitter;
|
||||
use tauri::Manager;
|
||||
use tauri_plugin_autostart::MacosLauncher;
|
||||
|
||||
// 定义GitHub Release的结构体
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct Release {
|
||||
@@ -267,7 +269,7 @@ fn stop_command(child_id: u32) {
|
||||
} else {
|
||||
eprintln!("Failed to terminate process {}.", child_id);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
println!("child id is 0");
|
||||
}
|
||||
}
|
||||
@@ -330,12 +332,18 @@ fn search_pid_by_pname(target_process_name: String) -> u32 {
|
||||
return 0;
|
||||
}
|
||||
|
||||
pub const AUTOSTART_ARG: &str = "--autostart";
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
let stop_signal = Arc::new(AtomicBool::new(false)); // 创建一个原子布尔值,用于控制命令的停止
|
||||
let stop_signal_clone = Arc::clone(&stop_signal); // 创建一个原子布尔值的克隆,用于传递给命令
|
||||
let context = tauri::generate_context!();
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_autostart::init(
|
||||
MacosLauncher::LaunchAgent,
|
||||
Some(vec![AUTOSTART_ARG]),
|
||||
))
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| {
|
||||
let _ = app
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "easytier-game",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"identifier": "com.tauri.easytier-game",
|
||||
|
||||
"build": {
|
||||
@@ -28,12 +28,18 @@
|
||||
"csp": null
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
"bundle": {
|
||||
"active": false,
|
||||
"targets": "all",
|
||||
"externalBin": ["WinIPBroadcast"],
|
||||
"resources": ["icons/icon-inactive.ico", "icons/icon.ico"],
|
||||
"windows": {
|
||||
"webviewInstallMode": {
|
||||
"type": "embedBootstrapper"
|
||||
}
|
||||
},
|
||||
"createUpdaterArtifacts": false,
|
||||
"icon": ["icons/32x32.png", "icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico"]
|
||||
"icon": ["icons/icon.png", "icons/icon.rgba", "icons/icon.icns", "icons/icon.ico", "icons/icon-inactive.ico"]
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -9,9 +9,10 @@ export default defineStore("main", {
|
||||
networkPassword: "",
|
||||
hostname: "",
|
||||
ipv4: "",
|
||||
autoStart: false, // 是否自动启动
|
||||
disableIpv6: false, // 是否禁用IPv6
|
||||
disbleListenner: false, // 是否禁用监听
|
||||
disbleP2p: true, // 是否使用P2P
|
||||
disbleP2p: false, // 是否使用P2P
|
||||
dhcp: true, // 是否使用DHCP
|
||||
},
|
||||
basePeers: ["public.easytier.top:11010"],
|
||||
@@ -25,6 +26,7 @@ export default defineStore("main", {
|
||||
"config.protocol",
|
||||
"config.networkPassword",
|
||||
"config.disbleP2p",
|
||||
"config.autoStart",
|
||||
"config.disableIpv6",
|
||||
"config.disbleListenner",
|
||||
"config.hostname",
|
||||
|
||||
Reference in New Issue
Block a user