Compare commits

...
4 Commits
14 changed files with 622 additions and 220 deletions
+69 -74
View File
@@ -1,89 +1,86 @@
import { Menu, MenuItem, PredefinedMenuItem } from '@tauri-apps/api/menu' import { Menu, MenuItem, PredefinedMenuItem } from "@tauri-apps/api/menu";
import { TrayIcon } from '@tauri-apps/api/tray' import { TrayIcon } from "@tauri-apps/api/tray";
import { getCurrentWindow } from '@tauri-apps/api/window' import { getCurrentWindow } from "@tauri-apps/api/window";
import pkg from '@/package.json' import pkg from "@/package.json";
const DEFAULT_TRAY_NAME = 'main' const DEFAULT_TRAY_NAME = "main";
async function toggleVisibility() { async function toggleVisibility() {
if (await getCurrentWindow().isVisible()) { if (await getCurrentWindow().isVisible()) {
await getCurrentWindow().hide() await getCurrentWindow().hide();
} } else {
else { await getCurrentWindow().show();
await getCurrentWindow().show() await getCurrentWindow().setFocus();
await getCurrentWindow().setFocus() }
}
} }
export async function useTray(init: boolean = false, beforExit) { export async function useTray(init: boolean = false, beforExit: Function) {
let tray let tray;
try { try {
tray = await TrayIcon.getById(DEFAULT_TRAY_NAME) tray = await TrayIcon.getById(DEFAULT_TRAY_NAME);
if (!tray) { if (!tray) {
tray = await TrayIcon.new({ tray = await TrayIcon.new({
tooltip: `EasyTier\n${pkg.version}`, tooltip: `EasyTier\n${pkg.version}`,
title: `EasyTier\n${pkg.version}`, title: `EasyTier\n${pkg.version}`,
id: DEFAULT_TRAY_NAME, id: DEFAULT_TRAY_NAME,
menu: await Menu.new({ menu: await Menu.new({
id: 'main', id: "main",
items: await generateMenuItem(beforExit), items: await generateMenuItem(beforExit)
}), }),
action: async (e) => { action: async e => {
toggleVisibility() toggleVisibility();
}, }
}) });
} }
} } catch (error) {
catch (error) { console.warn("Error while creating tray icon:", error);
console.warn('Error while creating tray icon:', error) return null;
return null }
}
if (init) { if (init) {
tray.setTooltip(`EasyTier\n${pkg.version}`) tray.setTooltip(`EasyTier\n${pkg.version}`);
tray.setMenuOnLeftClick(false) tray.setMenuOnLeftClick(false);
tray.setMenu(await Menu.new({ tray.setMenu(
id: 'main', await Menu.new({
items: await generateMenuItem(beforExit), id: "main",
})) items: await generateMenuItem(beforExit)
} })
);
}
return tray return tray;
} }
export async function generateMenuItem(beforExit: Function) { export async function generateMenuItem(beforExit: Function) {
return [ return [await MenuItemExit("退出", beforExit), await PredefinedMenuItem.new({ item: "Separator" }), await MenuItemShow("显示 / 隐藏")];
await MenuItemExit('退出', beforExit),
await PredefinedMenuItem.new({ item: 'Separator' }),
await MenuItemShow('显示 / 隐藏'),
]
} }
export async function MenuItemExit(text: string, beforExit: Function) { export async function MenuItemExit(text: string, beforExit: Function) {
return await MenuItem.new({ return await MenuItem.new({
id: "quit", id: "quit",
text, text,
action: async () => { action: async () => {
if (beforExit) { if (beforExit) {
await beforExit(); await beforExit();
} }
await getCurrentWindow().close(); await getCurrentWindow().close();
} }
}) });
} }
export async function MenuItemShow(text: string) { export async function MenuItemShow(text: string) {
return await MenuItem.new({ return await MenuItem.new({
id: 'show', id: "show",
text, text,
action: async () => { action: async () => {
await toggleVisibility() await toggleVisibility();
}, }
}) });
} }
// export async function setTrayMenu(items: (MenuItem | PredefinedMenuItem)[] | undefined = undefined) { // 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) // if (!tray)
// return // return
// const menu = await Menu.new({ // const menu = await Menu.new({
@@ -93,12 +90,10 @@ export async function MenuItemShow(text: string) {
// tray.setMenu(menu) // tray.setMenu(menu)
// } // }
// export async function setTrayRunState(isRunning: boolean = false) { export async function setTrayRunState(tray: TrayIcon | null, isRunning: boolean = false) {
// const tray = await useTray() if (!tray) return;
// if (!tray) tray.setIcon(isRunning ? "icons/icon-inactive.ico" : "icons/icon.ico");
// return }
// tray.setIcon(isRunning ? 'icons/icon-inactive.ico' : 'icons/icon.ico')
// }
// export async function setTrayTooltip(tooltip: string) { // export async function setTrayTooltip(tooltip: string) {
// if (tooltip) { // if (tooltip) {
@@ -108,4 +103,4 @@ export async function MenuItemShow(text: string) {
// tray.setTooltip(`EasyTier\n${pkg.version}\n${tooltip}`) // tray.setTooltip(`EasyTier\n${pkg.version}\n${tooltip}`)
// tray.setTitle(`EasyTier\n${pkg.version}\n${tooltip}`) // tray.setTitle(`EasyTier\n${pkg.version}\n${tooltip}`)
// } // }
// } // }
+1 -1
View File
@@ -70,7 +70,7 @@ export default defineNuxtConfig({
sourcemap: !!process.env.TAURI_DEBUG sourcemap: !!process.env.TAURI_DEBUG
}, },
esbuild: { esbuild: {
pure: ["console.log"], // pure: ["console.log"],
drop: ["debugger"] drop: ["debugger"]
} }
}, },
+6 -3
View File
@@ -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.4", "version": "1.0.6",
"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"
@@ -18,6 +18,7 @@
"@tauri-apps/cli": "^2.0.2", "@tauri-apps/cli": "^2.0.2",
"@tauri-apps/plugin-cli": "^2.0.0", "@tauri-apps/plugin-cli": "^2.0.0",
"@tauri-apps/plugin-http": "^2.0.0", "@tauri-apps/plugin-http": "^2.0.0",
"@tauri-apps/plugin-shell": "~2",
"@tinymce/tinymce-vue": "^5.1.1", "@tinymce/tinymce-vue": "^5.1.1",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/qs": "^6.9.15", "@types/qs": "^6.9.15",
@@ -35,7 +36,9 @@
"typescript": "^5.4.5", "typescript": "^5.4.5",
"vue": "^3.4.24", "vue": "^3.4.24",
"vue-clipboard3": "^2.0.0", "vue-clipboard3": "^2.0.0",
"xlsx": "^0.18.5", "xlsx": "^0.18.5"
"@tauri-apps/plugin-shell": "~2" },
"dependencies": {
"@tauri-apps/plugin-autostart": "~2"
} }
} }
+192 -65
View File
@@ -218,28 +218,49 @@
> >
禁用ipv6 禁用ipv6
</ElCheckbox> </ElCheckbox>
<ElCheckbox
@change="handleAutoStart"
:model-value="config.autoStart"
size="small"
>
开机自启
</ElCheckbox>
<ElCheckbox <ElCheckbox
v-model="config.disbleListenner" v-model="config.disbleListenner"
size="small" size="small"
> >
禁用端口监听 禁用端口监听
</ElCheckbox> </ElCheckbox>
<ElLink <div class="flex items-center gap-[0_5px]">
class="!text-[11px] pb-[2px] ml-[15px]" <div>
type="info" <ElLink
:underline="false" class="!text-[11px]"
@click="open('https://github.com/EasyTier/EasyTier/releases')" type="info"
> :underline="false"
easytier发布页 @click="open('https://github.com/dechamps/WinIPBroadcast/releases/tag/winipbroadcast-1.6')"
</ElLink> >
<div> 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 <ElLink
class="!text-[11px]" class="!text-[11px] pb-[2px] ml-[15px]"
type="danger" type="info"
:underline="false" :underline="false"
@click="open('https://github.com/dechamps/WinIPBroadcast/releases/tag/winipbroadcast-1.6')" @click="open('https://github.com/EasyTier/EasytierGame')"
> >
找不到房间安装WinIPBroadcast 主页
</ElLink> </ElLink>
</div> </div>
</div> </div>
@@ -248,21 +269,23 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { invoke } from "@tauri-apps/api/core"; import { invoke } from "@tauri-apps/api/core";
import { listen } from "@tauri-apps/api/event"; import { listen, type UnlistenFn } from "@tauri-apps/api/event";
import { open } from "@tauri-apps/plugin-shell"; import { open, Command } from "@tauri-apps/plugin-shell";
import { QuestionFilled, Delete, List, UserFilled } from "@element-plus/icons-vue"; import { QuestionFilled, Delete, List, UserFilled } from "@element-plus/icons-vue";
import { reactive, onBeforeUnmount, onMounted } from "vue"; import { reactive, onBeforeUnmount, onMounted } from "vue";
import { useTray } from "~/composables/tray"; import { useTray, setTrayRunState } from "~/composables/tray";
import useMainStore from "@/stores/index"; import useMainStore from "@/stores/index";
import { ElMessage } from "element-plus"; 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 { WebviewWindow, getAllWebviewWindows } from "@tauri-apps/api/webviewWindow";
import * as tauriAutoStart from "@tauri-apps/plugin-autostart";
let is_close = false; let is_close = false;
useTray(true, async () => { const tray = await useTray(true, async () => {
is_close = true; is_close = true;
await invoke("stop_command", { child_id: listenObj.thread_id || 0 }); await invoke("stop_command", { child_id: listenObj.thread_id || 0 });
await invoke("stop_command", { child_id: data.winipBcPid || 0 });
}); });
const mainStore = useMainStore(); const mainStore = useMainStore();
@@ -270,6 +293,8 @@
const protocols = ["tcp", "udp", "ws", "wss", "wg"]; const protocols = ["tcp", "udp", "ws", "wss", "wg"];
const data = reactive({ const data = reactive({
logVisible: false, logVisible: false,
winipBcPid: 0, //WinIPBroadcast进程id
winipBcStart: false,
memberVisible: false, memberVisible: false,
log: "", log: "",
update: false, update: false,
@@ -315,13 +340,14 @@
thread_id: null, thread_id: null,
async listenOutput() { async listenOutput() {
const appWindow = getCurrentWindow(); const appWindow = getCurrentWindow();
const unListen = await listen("command-output", 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;
let ipv4 = /new: Some\((\d+\.\d+\.\d+\.\d+)\/.*\)/g.exec(event.payload as string)?.[1]; let ipv4 = /new: Some\((\d+\.\d+\.\d+\.\d+)\/.*\)/g.exec(event.payload as string)?.[1];
if (ipv4) { if (ipv4) {
data.isSuccessGetIp = true; data.isSuccessGetIp = true;
await setTrayRunState(tray, true);
config.ipv4 = ipv4; config.ipv4 = ipv4;
} }
} }
@@ -397,8 +423,86 @@
data.releaseList = list as never[]; data.releaseList = list as never[];
}; };
const getWinIpBroadcastPid = async () => {
const pid = await invoke("search_pid_by_pname", { target_process_name: "WinIPBroadcast" });
data.winipBcPid = (pid as number) || 0;
if (data.winipBcPid && data.winipBcPid > 0) {
data.winipBcStart = true;
} else {
data.winipBcStart = false;
}
};
const handleWinipBcStart = async () => {
if (!data.winipBcStart) {
try {
await invoke("stop_command", { child_id: data.winipBcPid || 0 });
const child = await Command.create("WinIPBroadcast", ["run"]).spawn();
data.winipBcPid = child.pid || 0;
if (data.winipBcPid) {
data.winipBcStart = true;
} else {
ElMessage.error(`启动失败`);
}
} catch (err) {
ElMessage.error(`启动失败`);
console.log(err);
}
} else {
await invoke("stop_command", { child_id: data.winipBcPid || 0 });
await getWinIpBroadcastPid();
}
};
const initStartWinIpBroadcast = async () => {
await getWinIpBroadcastPid();
if (!data.winipBcStart) {
await handleWinipBcStart();
}
};
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 () => { onMounted(async () => {
// await handleUpdateCore(); //默认不自动更新 // await handleUpdateCore(); //默认不自动更新
await initAutoStart();
await initStartWinIpBroadcast();
await getCoreVersion(); await getCoreVersion();
await listenObj.listenThreadId(); await listenObj.listenThreadId();
closePrevent(); closePrevent();
@@ -407,6 +511,7 @@
onBeforeUnmount(() => { onBeforeUnmount(() => {
unListenAll(); unListenAll();
listenObj.unListenReleaseList && listenObj.unListenReleaseList(); listenObj.unListenReleaseList && listenObj.unListenReleaseList();
logsTimer && clearInterval(logsTimer);
}); });
const getArgs = () => { const getArgs = () => {
@@ -445,7 +550,9 @@
const reset = async () => { const reset = async () => {
data.isStart = false; data.isStart = false;
data.isSuccessGetIp = false; data.isSuccessGetIp = false;
config.ipv4 = ""; if (config.dhcp) {
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) {
@@ -457,7 +564,7 @@
} }
} }
} }
await setTrayRunState(tray, false);
await unListenAll(); await unListenAll();
}; };
@@ -475,19 +582,24 @@
} }
}; };
let unListenMemberClose: UnlistenFn | null = null;
let unlistenMemberCreated: UnlistenFn | null = null;
const handleShowMemberDialog = async () => { const handleShowMemberDialog = async () => {
try { if (!data.isStart) {
if (!data.isStart) { return ElMessage.warning("请先开始联机");
return ElMessage.warning("请先开始联机"); }
} if (!mainStore.config.ipv4) {
if (!mainStore.config.ipv4) { return ElMessage.warning("请等待获取IP");
return ElMessage.warning("请等待获取IP"); }
} const appWindow = getCurrentWindow();
const appWindow = getCurrentWindow(); if (appWindow) {
const appSize = await appWindow.innerSize(); const appSize = await appWindow.outerSize();
const factor = await appWindow.scaleFactor();
const appPosition = await appWindow.outerPosition(); const appPosition = await appWindow.outerPosition();
if (appWindow) { const logicalPosition = new PhysicalPosition(appPosition.x + appSize.width, appPosition.y).toLogical(factor);
const memberDialog = new WebviewWindow("member", { let memberDialog = await WebviewWindow.getByLabel("member");
if (!memberDialog) {
memberDialog = new WebviewWindow("member", {
title: "成员列表", title: "成员列表",
width: 470, width: 470,
height: 380, height: 380,
@@ -497,36 +609,44 @@
decorations: true, decorations: true,
maximizable: false, maximizable: false,
minimizable: false, minimizable: false,
x: appPosition.x + appSize.width + 10, x: logicalPosition.x,
y: appPosition.y, y: logicalPosition.y,
url: "#/member" url: "#/member"
}); });
if (!data.memberVisible) { unlistenMemberCreated = await memberDialog.once("tauri://webview-created", async () => {
data.memberVisible = true; if (memberDialog) {
memberDialog.onCloseRequested(() => { data.logVisible = true;
data.logVisible = false; await memberDialog.show();
}) }
const appWindow = getCurrentWindow(); });
appWindow.emitTo("log", "logs", data.log); unListenMemberClose = await memberDialog.onCloseRequested(() => {
} else { data.logVisible = false;
unListenMemberClose && unListenMemberClose();
});
} else {
const visible = await memberDialog.isVisible();
if (visible) {
data.memberVisible = false; 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 () => { const handleShowLogDialog = async () => {
try { logsTimer && clearInterval(logsTimer);
const appWindow = getCurrentWindow(); const appWindow = getCurrentWindow();
const appSize = await appWindow.innerSize(); if (appWindow) {
const appSize = await appWindow.outerSize();
const factor = await appWindow.scaleFactor();
const appPosition = await appWindow.outerPosition(); const appPosition = await appWindow.outerPosition();
if (appWindow) { const logicalPosition = new PhysicalPosition(appPosition.x + appSize.width, appPosition.y).toLogical(factor);
const infoDialog = new WebviewWindow("log", { let infoDialog = await WebviewWindow.getByLabel("log");
if (!infoDialog) {
infoDialog = new WebviewWindow("log", {
title: "日志", title: "日志",
width: 600, width: 600,
height: 380, height: 380,
@@ -536,24 +656,31 @@
decorations: true, decorations: true,
maximizable: false, maximizable: false,
minimizable: false, minimizable: false,
x: appPosition.x + appSize.width + 10, x: logicalPosition.x,
y: appPosition.y, y: logicalPosition.y,
url: "#/log" url: "#/log"
}); });
unlistenLogCreated = await infoDialog.once("tauri://webview-created", async () => {
if (!data.logVisible) { if (infoDialog) {
data.logVisible = true; data.logVisible = true;
infoDialog.onCloseRequested(() => { logsTimer = setInterval(() => {
data.logVisible = false; appWindow.emitTo("log", "logs", data.log);
}) }, 3000);
appWindow.emitTo("log", "logs", data.log); await infoDialog.show();
} else { }
});
unListenlogClose = await infoDialog.onCloseRequested(() => {
data.logVisible = false; 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> </script>
+28 -7
View File
@@ -9,9 +9,23 @@
> >
<ElTableColumn <ElTableColumn
v-for="prop in showTableHeader" v-for="prop in showTableHeader"
:prop="prop" :label="prop[1]"
:label="prop" :key="prop[0]"
></ElTableColumn> >
<template #default="{ row }">
<span v-if="prop[0] == 'loss_rate'">
{{ row[prop[0]] && row[prop[0]] != "-" ? Number(row[prop[0]] * 100).toFixed(2) + "%" : row[prop[0]] }}
</span>
<span v-else-if="prop[0] != 'cost'">{{ row[prop[0]] }}</span>
<ElTag
v-else
effect="dark"
:type="row[prop[0]] == 'p2p' ? 'success' : 'info'"
>
{{ row[prop[0]] }}
</ElTag>
</template>
</ElTableColumn>
</ElTable> </ElTable>
</div> </div>
</div> </div>
@@ -23,7 +37,14 @@
member: [] member: []
}); });
const showTableHeader = ["ipv4", "hostname", "cost", "lat_ms", "loss_rate", "nat_type", "version"]; const showTableHeader = [
["ipv4", "虚拟网IP"],
["hostname", "主机名"],
["cost", "路由"],
["lat_ms", "延迟/ms"],
["loss_rate", "丢包率"],
["version", "版本"]
];
const headers = [ const headers = [
"ipv4", "ipv4",
"hostname", "hostname",
@@ -161,9 +182,9 @@
onMounted(async () => { onMounted(async () => {
listenOutput(); listenOutput();
// timer = setInterval(() => { timer = setInterval(() => {
// listenOutput(); listenOutput();
// }, 3000); }, 1000 * 10);
}); });
onBeforeUnmount(() => { onBeforeUnmount(() => {
+11
View File
@@ -7,6 +7,10 @@ settings:
importers: importers:
.: .:
dependencies:
'@tauri-apps/plugin-autostart':
specifier: ~2
version: 2.0.0
devDependencies: devDependencies:
'@element-plus/icons-vue': '@element-plus/icons-vue':
specifier: ^2.3.1 specifier: ^2.3.1
@@ -1008,6 +1012,9 @@ packages:
engines: {node: '>= 10'} engines: {node: '>= 10'}
hasBin: true hasBin: true
'@tauri-apps/plugin-autostart@2.0.0':
resolution: {integrity: sha512-NEwOQWVasZ8RczXkMLNJokRDujneuMH/UFA5t84DLkbNZUmiD3G7HZWhgSd1YQ0BFU9h9w+h2B/py3y6bzWg4Q==}
'@tauri-apps/plugin-cli@2.0.0': '@tauri-apps/plugin-cli@2.0.0':
resolution: {integrity: sha512-glQmlL1IiCGEa1FHYa/PTPSeYhfu56omLRgHXWlJECDt6DbJyRuJWVgtkQfUxtqnVdYnnU+DGIGeiInoEqtjLw==} resolution: {integrity: sha512-glQmlL1IiCGEa1FHYa/PTPSeYhfu56omLRgHXWlJECDt6DbJyRuJWVgtkQfUxtqnVdYnnU+DGIGeiInoEqtjLw==}
@@ -5568,6 +5575,10 @@ snapshots:
'@tauri-apps/cli-win32-ia32-msvc': 2.0.2 '@tauri-apps/cli-win32-ia32-msvc': 2.0.2
'@tauri-apps/cli-win32-x64-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': '@tauri-apps/plugin-cli@2.0.0':
dependencies: dependencies:
'@tauri-apps/api': 2.0.2 '@tauri-apps/api': 2.0.2
+198 -20
View File
@@ -288,6 +288,17 @@ version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" 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]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.4.0" version = "1.4.0"
@@ -810,6 +821,25 @@ dependencies = [
"crossbeam-utils", "crossbeam-utils",
] ]
[[package]]
name = "crossbeam-deque"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d"
dependencies = [
"crossbeam-epoch",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
dependencies = [
"crossbeam-utils",
]
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.8.20" version = "0.8.20"
@@ -960,13 +990,33 @@ dependencies = [
"subtle", "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]] [[package]]
name = "dirs" name = "dirs"
version = "5.0.1" version = "5.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
dependencies = [ 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]] [[package]]
@@ -1059,20 +1109,28 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
[[package]] [[package]]
name = "easytier-game" name = "easytier-game"
version = "1.0.4" version = "1.0.6"
dependencies = [ dependencies = [
"log", "log",
"reqwest", "reqwest",
"serde", "serde",
"serde_json", "serde_json",
"sysinfo",
"tauri", "tauri",
"tauri-build", "tauri-build",
"tauri-plugin-autostart",
"tauri-plugin-log", "tauri-plugin-log",
"tauri-plugin-shell", "tauri-plugin-shell",
"tauri-plugin-single-instance", "tauri-plugin-single-instance",
"zip", "zip",
] ]
[[package]]
name = "either"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
[[package]] [[package]]
name = "embed-resource" name = "embed-resource"
version = "2.5.0" version = "2.5.0"
@@ -1084,7 +1142,7 @@ dependencies = [
"rustc_version", "rustc_version",
"toml 0.8.2", "toml 0.8.2",
"vswhom", "vswhom",
"winreg", "winreg 0.52.0",
] ]
[[package]] [[package]]
@@ -2413,6 +2471,15 @@ version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
[[package]]
name = "ntapi"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "num-conv" name = "num-conv"
version = "0.1.0" version = "0.1.0"
@@ -3172,6 +3239,26 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539"
[[package]]
name = "rayon"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa"
dependencies = [
"either",
"rayon-core",
]
[[package]]
name = "rayon-core"
version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2"
dependencies = [
"crossbeam-deque",
"crossbeam-utils",
]
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.5.7" version = "0.5.7"
@@ -3913,6 +4000,20 @@ dependencies = [
"futures-core", "futures-core",
] ]
[[package]]
name = "sysinfo"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3b5ae3f4f7d64646c46c4cae4e3f01d1c5d255c7406fdd7c7f999a94e488791"
dependencies = [
"core-foundation-sys",
"libc",
"memchr",
"ntapi",
"rayon",
"windows 0.57.0",
]
[[package]] [[package]]
name = "system-configuration" name = "system-configuration"
version = "0.6.1" version = "0.6.1"
@@ -3980,7 +4081,7 @@ dependencies = [
"tao-macros", "tao-macros",
"unicode-segmentation", "unicode-segmentation",
"url", "url",
"windows", "windows 0.58.0",
"windows-core 0.58.0", "windows-core 0.58.0",
"windows-version", "windows-version",
"x11-dl", "x11-dl",
@@ -4017,7 +4118,7 @@ checksum = "5920aad0804ea5e86808d4b6e8753d3bcbae7efc8f4e41a4da00b45427559868"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
"dirs", "dirs 5.0.1",
"dunce", "dunce",
"embed_plist", "embed_plist",
"futures-util", "futures-util",
@@ -4057,7 +4158,7 @@ dependencies = [
"webkit2gtk", "webkit2gtk",
"webview2-com", "webview2-com",
"window-vibrancy", "window-vibrancy",
"windows", "windows 0.58.0",
] ]
[[package]] [[package]]
@@ -4068,7 +4169,7 @@ checksum = "935f9b3c49b22b3e2e485a57f46d61cd1ae07b1cbb2ba87387a387caf2d8c4e7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cargo_toml", "cargo_toml",
"dirs", "dirs 5.0.1",
"glob", "glob",
"heck 0.5.0", "heck 0.5.0",
"json-patch", "json-patch",
@@ -4140,6 +4241,21 @@ dependencies = [
"walkdir", "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]] [[package]]
name = "tauri-plugin-log" name = "tauri-plugin-log"
version = "2.0.1" version = "2.0.1"
@@ -4214,7 +4330,7 @@ dependencies = [
"tauri-utils", "tauri-utils",
"thiserror", "thiserror",
"url", "url",
"windows", "windows 0.58.0",
] ]
[[package]] [[package]]
@@ -4239,7 +4355,7 @@ dependencies = [
"url", "url",
"webkit2gtk", "webkit2gtk",
"webview2-com", "webview2-com",
"windows", "windows 0.58.0",
"wry", "wry",
] ]
@@ -4540,7 +4656,7 @@ checksum = "533fc2d4105e0e3d96ce1c71f2d308c9fbbe2ef9c587cab63dd627ab5bde218f"
dependencies = [ dependencies = [
"core-graphics", "core-graphics",
"crossbeam-channel", "crossbeam-channel",
"dirs", "dirs 5.0.1",
"libappindicator", "libappindicator",
"muda", "muda",
"objc2", "objc2",
@@ -4919,10 +5035,10 @@ checksum = "6f61ff3d9d0ee4efcb461b14eb3acfda2702d10dc329f339303fc3e57215ae2c"
dependencies = [ dependencies = [
"webview2-com-macros", "webview2-com-macros",
"webview2-com-sys", "webview2-com-sys",
"windows", "windows 0.58.0",
"windows-core 0.58.0", "windows-core 0.58.0",
"windows-implement", "windows-implement 0.58.0",
"windows-interface", "windows-interface 0.58.0",
] ]
[[package]] [[package]]
@@ -4943,7 +5059,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3a3e2eeb58f82361c93f9777014668eb3d07e7d174ee4c819575a9208011886" checksum = "a3a3e2eeb58f82361c93f9777014668eb3d07e7d174ee4c819575a9208011886"
dependencies = [ dependencies = [
"thiserror", "thiserror",
"windows", "windows 0.58.0",
"windows-core 0.58.0", "windows-core 0.58.0",
] ]
@@ -4992,6 +5108,16 @@ dependencies = [
"windows-version", "windows-version",
] ]
[[package]]
name = "windows"
version = "0.57.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143"
dependencies = [
"windows-core 0.57.0",
"windows-targets 0.52.6",
]
[[package]] [[package]]
name = "windows" name = "windows"
version = "0.58.0" version = "0.58.0"
@@ -5011,19 +5137,42 @@ dependencies = [
"windows-targets 0.52.6", "windows-targets 0.52.6",
] ]
[[package]]
name = "windows-core"
version = "0.57.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d"
dependencies = [
"windows-implement 0.57.0",
"windows-interface 0.57.0",
"windows-result 0.1.2",
"windows-targets 0.52.6",
]
[[package]] [[package]]
name = "windows-core" name = "windows-core"
version = "0.58.0" version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"
dependencies = [ dependencies = [
"windows-implement", "windows-implement 0.58.0",
"windows-interface", "windows-interface 0.58.0",
"windows-result", "windows-result 0.2.0",
"windows-strings", "windows-strings",
"windows-targets 0.52.6", "windows-targets 0.52.6",
] ]
[[package]]
name = "windows-implement"
version = "0.57.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
]
[[package]] [[package]]
name = "windows-implement" name = "windows-implement"
version = "0.58.0" version = "0.58.0"
@@ -5035,6 +5184,17 @@ dependencies = [
"syn 2.0.79", "syn 2.0.79",
] ]
[[package]]
name = "windows-interface"
version = "0.57.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
]
[[package]] [[package]]
name = "windows-interface" name = "windows-interface"
version = "0.58.0" version = "0.58.0"
@@ -5052,11 +5212,20 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0"
dependencies = [ dependencies = [
"windows-result", "windows-result 0.2.0",
"windows-strings", "windows-strings",
"windows-targets 0.52.6", "windows-targets 0.52.6",
] ]
[[package]]
name = "windows-result"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8"
dependencies = [
"windows-targets 0.52.6",
]
[[package]] [[package]]
name = "windows-result" name = "windows-result"
version = "0.2.0" version = "0.2.0"
@@ -5072,7 +5241,7 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
dependencies = [ dependencies = [
"windows-result", "windows-result 0.2.0",
"windows-targets 0.52.6", "windows-targets 0.52.6",
] ]
@@ -5308,6 +5477,15 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "winreg"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "winreg" name = "winreg"
version = "0.52.0" version = "0.52.0"
@@ -5352,7 +5530,7 @@ dependencies = [
"webkit2gtk", "webkit2gtk",
"webkit2gtk-sys", "webkit2gtk-sys",
"webview2-com", "webview2-com",
"windows", "windows 0.58.0",
"windows-core 0.58.0", "windows-core 0.58.0",
"windows-version", "windows-version",
"x11-dl", "x11-dl",
+3 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "easytier-game" name = "easytier-game"
version = "1.0.4" version = "1.0.6"
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"
@@ -33,8 +33,10 @@ tauri-plugin-log = "2.0.0-rc"
tauri-plugin-shell = "2" tauri-plugin-shell = "2"
reqwest = { version = "0.12", features = ["json"] } reqwest = { version = "0.12", features = ["json"] }
zip = "2.2.0" zip = "2.2.0"
sysinfo = '0.32.0'
# prost = "0.13" # prost = "0.13"
# prost-types = "0.13" # prost-types = "0.13"
[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"
tauri-plugin-single-instance = "2" tauri-plugin-single-instance = "2"
Binary file not shown.
+48 -25
View File
@@ -1,27 +1,50 @@
{ {
"$schema": "../gen/schemas/desktop-schema.json", "$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default", "identifier": "default",
"description": "enables the default permissions", "description": "enables the default permissions",
"windows": [ "windows": ["main", "log"],
"main", "permissions": [
"log" "core:default",
], "core:window:allow-minimize",
"permissions": [ "core:window:allow-hide",
"core:default", "core:window:allow-close",
"core:window:allow-minimize", "shell:allow-open",
"core:window:allow-hide", "core:window:allow-show",
"core:window:allow-close", "core:window:allow-create",
"shell:allow-open", "core:window:allow-set-position",
"core:window:allow-show", "core:window:allow-destroy",
"core:window:allow-create", "core:webview:allow-create-webview-window",
"core:window:allow-set-position", "core:webview:allow-set-webview-size",
"core:window:allow-destroy", "core:webview:allow-set-webview-position",
"core:webview:allow-create-webview-window", "core:webview:allow-create-webview",
"core:webview:allow-set-webview-size", "core:webview:allow-webview-show",
"core:webview:allow-set-webview-position", "core:webview:allow-webview-hide",
"core:webview:allow-create-webview", "core:webview:allow-webview-close",
"core:webview:allow-webview-show", "autostart:allow-enable",
"core:webview:allow-webview-hide", "autostart:allow-disable",
"core:webview:allow-webview-close" "autostart:allow-is-enabled",
] "core:tray:allow-get-by-id",
"core:tray:allow-set-icon",
"core:tray:allow-new",
{
"identifier": "shell:allow-spawn",
"allow": [
{
"args": ["run"],
"cmd": "WinIPBroadcast",
"name": "WinIPBroadcast"
}
]
},
{
"identifier": "shell:allow-execute",
"allow": [
{
"args": ["run"],
"cmd": "WinIPBroadcast",
"name": "WinIPBroadcast"
}
]
}
]
} }
+11
View File
@@ -0,0 +1,11 @@
{
"identifier": "desktop-capability",
"platforms": [
"macOS",
"windows",
"linux"
],
"permissions": [
"autostart:default"
]
}
+42 -21
View File
@@ -10,9 +10,12 @@ use std::sync::{
mpsc, Arc, mpsc, Arc,
}; };
use std::{path, thread}; use std::{path, thread};
use sysinfo::System;
use tauri::tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent}; use tauri::tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent};
use tauri::Emitter; use tauri::Emitter;
use tauri::Manager; use tauri::Manager;
use tauri_plugin_autostart::MacosLauncher;
// 定义GitHub Release的结构体 // 定义GitHub Release的结构体
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
pub struct Release { pub struct Release {
@@ -106,11 +109,9 @@ struct PeerRoute {
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
struct MyResponse { struct MyResponse {
response: PeerRoute response: PeerRoute,
} }
#[tauri::command(rename_all = "snake_case")] #[tauri::command(rename_all = "snake_case")]
fn get_members_by_cli() -> String { fn get_members_by_cli() -> String {
match Command::new("easytier-cli.exe") match Command::new("easytier-cli.exe")
@@ -203,7 +204,8 @@ fn run_command(
stop_signal.store(false, Ordering::Relaxed); stop_signal.store(false, Ordering::Relaxed);
let app_handle1 = app_handle.clone(); let app_handle1 = app_handle.clone();
let app_handle2 = app_handle.clone(); let app_handle2 = app_handle.clone();
let stop_signal = Arc::clone(&stop_signal); let stop_signal1 = Arc::clone(&stop_signal);
let stop_signal2 = Arc::clone(&stop_signal);
let args2 = args.clone(); let args2 = args.clone();
thread::spawn(move || { thread::spawn(move || {
let mut child = Command::new("easytier-core.exe") let mut child = Command::new("easytier-core.exe")
@@ -234,13 +236,13 @@ fn run_command(
} }
} }
} }
stop_signal1.store(true, Ordering::Relaxed);
println!("end"); println!("end");
}); });
thread::spawn(move || { thread::spawn(move || {
while let Ok(line) = rx.recv() { while let Ok(line) = rx.recv() {
if stop_signal.load(Ordering::Relaxed) { if stop_signal2.load(Ordering::Relaxed) {
break; break;
} }
app_handle2 app_handle2
@@ -251,8 +253,7 @@ fn run_command(
} }
#[tauri::command(rename_all = "snake_case")] #[tauri::command(rename_all = "snake_case")]
fn stop_command(child_id: u32, stop_signal: tauri::State<Arc<AtomicBool>>) { fn stop_command(child_id: u32) {
println!("stop command");
if child_id != 0 { if child_id != 0 {
let output = Command::new("taskkill") let output = Command::new("taskkill")
.arg("/F") .arg("/F")
@@ -268,8 +269,9 @@ fn stop_command(child_id: u32, stop_signal: tauri::State<Arc<AtomicBool>>) {
} else { } else {
eprintln!("Failed to terminate process {}.", child_id); eprintln!("Failed to terminate process {}.", child_id);
} }
} else {
println!("child id is 0");
} }
stop_signal.store(true, Ordering::Relaxed);
} }
#[tauri::command(rename_all = "snake_case")] #[tauri::command(rename_all = "snake_case")]
@@ -307,24 +309,42 @@ fn toggle_window_visibility<R: tauri::Runtime>(app: &tauri::AppHandle<R>) {
} }
} }
#[tauri::command(rename_all = "snake_case")]
fn search_pid_by_pname(target_process_name: String) -> u32 {
// 创建一个新的 System 实例
let mut system = System::new_all();
// 刷新所有进程信息
system.refresh_all();
// 遍历所有进程
for (pid, process) in system.processes() {
if process
.name()
.to_string_lossy()
.to_lowercase()
.contains(&target_process_name.to_lowercase())
{
println!("Found process '{}' with PID: {}", target_process_name, pid);
return pid.as_u32();
}
}
return 0;
}
pub const AUTOSTART_ARG: &str = "--autostart";
#[cfg_attr(mobile, tauri::mobile_entry_point)] #[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() { pub fn run() {
let stop_signal = Arc::new(AtomicBool::new(false)); // 创建一个原子布尔值,用于控制命令的停止 let stop_signal = Arc::new(AtomicBool::new(false)); // 创建一个原子布尔值,用于控制命令的停止
let stop_signal_clone = Arc::clone(&stop_signal); // 创建一个原子布尔值的克隆,用于传递给命令 let stop_signal_clone = Arc::clone(&stop_signal); // 创建一个原子布尔值的克隆,用于传递给命令
let context = tauri::generate_context!(); let context = tauri::generate_context!();
tauri::Builder::default() tauri::Builder::default()
.plugin(tauri_plugin_autostart::init(
MacosLauncher::LaunchAgent,
Some(vec![AUTOSTART_ARG]),
))
.plugin(tauri_plugin_shell::init()) .plugin(tauri_plugin_shell::init())
// .on_window_event(move |window, event| {
// if let WindowEvent::CloseRequested { api, .. } = event {
// println!("close window");
// unsafe {
// if !IS_CLOSE && window.label() == "main" {
// api.prevent_close();
// window.emit("window-close-event", "").unwrap();
// }
// }
// }
// })
.plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| { .plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| {
let _ = app let _ = app
.get_webview_window("main") .get_webview_window("main")
@@ -368,7 +388,8 @@ pub fn run() {
fetch_easytier_list, fetch_easytier_list,
download_easytier_zip, download_easytier_zip,
get_cli_version, get_cli_version,
get_members_by_cli get_members_by_cli,
search_pid_by_pname
]) ])
.run(context) .run(context)
.expect("error while running tauri application"); .expect("error while running tauri application");
+10 -2
View File
@@ -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.4", "version": "1.0.6",
"identifier": "com.tauri.easytier-game", "identifier": "com.tauri.easytier-game",
"build": { "build": {
@@ -28,10 +28,18 @@
"csp": null "csp": null
} }
}, },
"bundle": { "bundle": {
"active": false, "active": false,
"targets": "all", "targets": "all",
"externalBin": ["WinIPBroadcast"],
"resources": ["icons/icon-inactive.ico", "icons/icon.ico"],
"windows": {
"webviewInstallMode": {
"type": "embedBootstrapper"
}
},
"createUpdaterArtifacts": false, "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
View File
@@ -9,9 +9,10 @@ export default defineStore("main", {
networkPassword: "", networkPassword: "",
hostname: "", hostname: "",
ipv4: "", ipv4: "",
autoStart: false, // 是否自动启动
disableIpv6: false, // 是否禁用IPv6 disableIpv6: false, // 是否禁用IPv6
disbleListenner: false, // 是否禁用监听 disbleListenner: false, // 是否禁用监听
disbleP2p: true, // 是否使用P2P disbleP2p: false, // 是否使用P2P
dhcp: true, // 是否使用DHCP dhcp: true, // 是否使用DHCP
}, },
basePeers: ["public.easytier.top:11010"], basePeers: ["public.easytier.top:11010"],
@@ -25,6 +26,7 @@ export default defineStore("main", {
"config.protocol", "config.protocol",
"config.networkPassword", "config.networkPassword",
"config.disbleP2p", "config.disbleP2p",
"config.autoStart",
"config.disableIpv6", "config.disableIpv6",
"config.disbleListenner", "config.disbleListenner",
"config.hostname", "config.hostname",