mirror of
https://github.com/EasyTier/EasytierGame.git
synced 2025-05-19 10:27:56 +00:00
#Fix 内置WinIPBroadcast默认开启,成员列表显示优化 1.0.5发布
This commit is contained in:
+59
-6
@@ -232,15 +232,27 @@
|
||||
>
|
||||
easytier发布页
|
||||
</ElLink>
|
||||
<div>
|
||||
<div class="flex items-center gap-[0_5px]">
|
||||
<ElLink
|
||||
class="!text-[11px]"
|
||||
type="danger"
|
||||
type="info"
|
||||
:underline="false"
|
||||
@click="open('https://github.com/dechamps/WinIPBroadcast/releases/tag/winipbroadcast-1.6')"
|
||||
>
|
||||
找不到房间?安装WinIPBroadcast
|
||||
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>
|
||||
@@ -249,7 +261,7 @@
|
||||
<script setup lang="ts">
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { listen } 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 { reactive, onBeforeUnmount, onMounted } from "vue";
|
||||
import { useTray } from "~/composables/tray";
|
||||
@@ -263,6 +275,7 @@
|
||||
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 });
|
||||
});
|
||||
|
||||
const mainStore = useMainStore();
|
||||
@@ -270,6 +283,8 @@
|
||||
const protocols = ["tcp", "udp", "ws", "wss", "wg"];
|
||||
const data = reactive({
|
||||
logVisible: false,
|
||||
winipBcPid: 0, //WinIPBroadcast进程id
|
||||
winipBcStart: false,
|
||||
memberVisible: false,
|
||||
log: "",
|
||||
update: false,
|
||||
@@ -284,7 +299,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();
|
||||
@@ -397,8 +412,47 @@
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
// await handleUpdateCore(); //默认不自动更新
|
||||
await initStartWinIpBroadcast();
|
||||
await getCoreVersion();
|
||||
await listenObj.listenThreadId();
|
||||
closePrevent();
|
||||
@@ -519,7 +573,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const handleShowLogDialog = async () => {
|
||||
try {
|
||||
logsTimer && clearInterval(logsTimer);
|
||||
|
||||
+24
-3
@@ -9,9 +9,23 @@
|
||||
>
|
||||
<ElTableColumn
|
||||
v-for="prop in showTableHeader"
|
||||
:prop="prop[0]"
|
||||
:label="prop[1]"
|
||||
></ElTableColumn>
|
||||
:key="prop[0]"
|
||||
>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
@@ -23,7 +37,14 @@
|
||||
member: []
|
||||
});
|
||||
|
||||
const showTableHeader = [["ipv4", "虚拟网IP"], ["hostname", "主机名"], ["lat_ms", "延迟"], ["loss_rate", "丢包率"], ["version", '版本']];
|
||||
const showTableHeader = [
|
||||
["ipv4", "虚拟网IP"],
|
||||
["hostname", "主机名"],
|
||||
["cost", "方式"],
|
||||
["lat_ms", "延迟/ms"],
|
||||
["loss_rate", "丢包率"],
|
||||
["version", "版本"]
|
||||
];
|
||||
const headers = [
|
||||
"ipv4",
|
||||
"hostname",
|
||||
|
||||
Generated
+136
-14
@@ -810,6 +810,25 @@ dependencies = [
|
||||
"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]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.20"
|
||||
@@ -1065,6 +1084,7 @@ dependencies = [
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sysinfo",
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
"tauri-plugin-log",
|
||||
@@ -1073,6 +1093,12 @@ dependencies = [
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
||||
|
||||
[[package]]
|
||||
name = "embed-resource"
|
||||
version = "2.5.0"
|
||||
@@ -2413,6 +2439,15 @@ version = "0.1.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
|
||||
|
||||
[[package]]
|
||||
name = "ntapi"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-conv"
|
||||
version = "0.1.0"
|
||||
@@ -3172,6 +3207,26 @@ version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.7"
|
||||
@@ -3913,6 +3968,20 @@ dependencies = [
|
||||
"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]]
|
||||
name = "system-configuration"
|
||||
version = "0.6.1"
|
||||
@@ -3980,7 +4049,7 @@ dependencies = [
|
||||
"tao-macros",
|
||||
"unicode-segmentation",
|
||||
"url",
|
||||
"windows",
|
||||
"windows 0.58.0",
|
||||
"windows-core 0.58.0",
|
||||
"windows-version",
|
||||
"x11-dl",
|
||||
@@ -4057,7 +4126,7 @@ dependencies = [
|
||||
"webkit2gtk",
|
||||
"webview2-com",
|
||||
"window-vibrancy",
|
||||
"windows",
|
||||
"windows 0.58.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4214,7 +4283,7 @@ dependencies = [
|
||||
"tauri-utils",
|
||||
"thiserror",
|
||||
"url",
|
||||
"windows",
|
||||
"windows 0.58.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4239,7 +4308,7 @@ dependencies = [
|
||||
"url",
|
||||
"webkit2gtk",
|
||||
"webview2-com",
|
||||
"windows",
|
||||
"windows 0.58.0",
|
||||
"wry",
|
||||
]
|
||||
|
||||
@@ -4919,10 +4988,10 @@ checksum = "6f61ff3d9d0ee4efcb461b14eb3acfda2702d10dc329f339303fc3e57215ae2c"
|
||||
dependencies = [
|
||||
"webview2-com-macros",
|
||||
"webview2-com-sys",
|
||||
"windows",
|
||||
"windows 0.58.0",
|
||||
"windows-core 0.58.0",
|
||||
"windows-implement",
|
||||
"windows-interface",
|
||||
"windows-implement 0.58.0",
|
||||
"windows-interface 0.58.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4943,7 +5012,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3a3e2eeb58f82361c93f9777014668eb3d07e7d174ee4c819575a9208011886"
|
||||
dependencies = [
|
||||
"thiserror",
|
||||
"windows",
|
||||
"windows 0.58.0",
|
||||
"windows-core 0.58.0",
|
||||
]
|
||||
|
||||
@@ -4992,6 +5061,16 @@ dependencies = [
|
||||
"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]]
|
||||
name = "windows"
|
||||
version = "0.58.0"
|
||||
@@ -5011,19 +5090,42 @@ dependencies = [
|
||||
"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]]
|
||||
name = "windows-core"
|
||||
version = "0.58.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"
|
||||
dependencies = [
|
||||
"windows-implement",
|
||||
"windows-interface",
|
||||
"windows-result",
|
||||
"windows-implement 0.58.0",
|
||||
"windows-interface 0.58.0",
|
||||
"windows-result 0.2.0",
|
||||
"windows-strings",
|
||||
"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]]
|
||||
name = "windows-implement"
|
||||
version = "0.58.0"
|
||||
@@ -5035,6 +5137,17 @@ dependencies = [
|
||||
"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]]
|
||||
name = "windows-interface"
|
||||
version = "0.58.0"
|
||||
@@ -5052,11 +5165,20 @@ version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0"
|
||||
dependencies = [
|
||||
"windows-result",
|
||||
"windows-result 0.2.0",
|
||||
"windows-strings",
|
||||
"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]]
|
||||
name = "windows-result"
|
||||
version = "0.2.0"
|
||||
@@ -5072,7 +5194,7 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
|
||||
dependencies = [
|
||||
"windows-result",
|
||||
"windows-result 0.2.0",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
@@ -5352,7 +5474,7 @@ dependencies = [
|
||||
"webkit2gtk",
|
||||
"webkit2gtk-sys",
|
||||
"webview2-com",
|
||||
"windows",
|
||||
"windows 0.58.0",
|
||||
"windows-core 0.58.0",
|
||||
"windows-version",
|
||||
"x11-dl",
|
||||
|
||||
@@ -33,6 +33,7 @@ tauri-plugin-log = "2.0.0-rc"
|
||||
tauri-plugin-shell = "2"
|
||||
reqwest = { version = "0.12", features = ["json"] }
|
||||
zip = "2.2.0"
|
||||
sysinfo = '0.32.0'
|
||||
# prost = "0.13"
|
||||
# prost-types = "0.13"
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,27 +1,44 @@
|
||||
{
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "default",
|
||||
"description": "enables the default permissions",
|
||||
"windows": [
|
||||
"main",
|
||||
"log"
|
||||
],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"core:window:allow-minimize",
|
||||
"core:window:allow-hide",
|
||||
"core:window:allow-close",
|
||||
"shell:allow-open",
|
||||
"core:window:allow-show",
|
||||
"core:window:allow-create",
|
||||
"core:window:allow-set-position",
|
||||
"core:window:allow-destroy",
|
||||
"core:webview:allow-create-webview-window",
|
||||
"core:webview:allow-set-webview-size",
|
||||
"core:webview:allow-set-webview-position",
|
||||
"core:webview:allow-create-webview",
|
||||
"core:webview:allow-webview-show",
|
||||
"core:webview:allow-webview-hide",
|
||||
"core:webview:allow-webview-close"
|
||||
]
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "default",
|
||||
"description": "enables the default permissions",
|
||||
"windows": ["main", "log"],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"core:window:allow-minimize",
|
||||
"core:window:allow-hide",
|
||||
"core:window:allow-close",
|
||||
"shell:allow-open",
|
||||
"core:window:allow-show",
|
||||
"core:window:allow-create",
|
||||
"core:window:allow-set-position",
|
||||
"core:window:allow-destroy",
|
||||
"core:webview:allow-create-webview-window",
|
||||
"core:webview:allow-set-webview-size",
|
||||
"core:webview:allow-set-webview-position",
|
||||
"core:webview:allow-create-webview",
|
||||
"core:webview:allow-webview-show",
|
||||
"core:webview:allow-webview-hide",
|
||||
"core:webview:allow-webview-close",
|
||||
{
|
||||
"identifier": "shell:allow-spawn",
|
||||
"allow": [
|
||||
{
|
||||
"args": ["run"],
|
||||
"cmd": "WinIPBroadcast",
|
||||
"name": "WinIPBroadcast"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"identifier": "shell:allow-execute",
|
||||
"allow": [
|
||||
{
|
||||
"args": ["run"],
|
||||
"cmd": "WinIPBroadcast",
|
||||
"name": "WinIPBroadcast"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+34
-21
@@ -10,6 +10,7 @@ use std::sync::{
|
||||
mpsc, Arc,
|
||||
};
|
||||
use std::{path, thread};
|
||||
use sysinfo::System;
|
||||
use tauri::tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent};
|
||||
use tauri::Emitter;
|
||||
use tauri::Manager;
|
||||
@@ -106,11 +107,9 @@ struct PeerRoute {
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct MyResponse {
|
||||
response: PeerRoute
|
||||
response: PeerRoute,
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[tauri::command(rename_all = "snake_case")]
|
||||
fn get_members_by_cli() -> String {
|
||||
match Command::new("easytier-cli.exe")
|
||||
@@ -203,7 +202,8 @@ fn run_command(
|
||||
stop_signal.store(false, Ordering::Relaxed);
|
||||
let app_handle1 = 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();
|
||||
thread::spawn(move || {
|
||||
let mut child = Command::new("easytier-core.exe")
|
||||
@@ -234,13 +234,13 @@ fn run_command(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stop_signal1.store(true, Ordering::Relaxed);
|
||||
println!("end");
|
||||
});
|
||||
|
||||
thread::spawn(move || {
|
||||
while let Ok(line) = rx.recv() {
|
||||
if stop_signal.load(Ordering::Relaxed) {
|
||||
if stop_signal2.load(Ordering::Relaxed) {
|
||||
break;
|
||||
}
|
||||
app_handle2
|
||||
@@ -251,8 +251,7 @@ fn run_command(
|
||||
}
|
||||
|
||||
#[tauri::command(rename_all = "snake_case")]
|
||||
fn stop_command(child_id: u32, stop_signal: tauri::State<Arc<AtomicBool>>) {
|
||||
println!("stop command");
|
||||
fn stop_command(child_id: u32) {
|
||||
if child_id != 0 {
|
||||
let output = Command::new("taskkill")
|
||||
.arg("/F")
|
||||
@@ -268,8 +267,9 @@ fn stop_command(child_id: u32, stop_signal: tauri::State<Arc<AtomicBool>>) {
|
||||
} else {
|
||||
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")]
|
||||
@@ -307,6 +307,29 @@ 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;
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
let stop_signal = Arc::new(AtomicBool::new(false)); // 创建一个原子布尔值,用于控制命令的停止
|
||||
@@ -314,17 +337,6 @@ pub fn run() {
|
||||
let context = tauri::generate_context!();
|
||||
tauri::Builder::default()
|
||||
.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| {
|
||||
let _ = app
|
||||
.get_webview_window("main")
|
||||
@@ -368,7 +380,8 @@ pub fn run() {
|
||||
fetch_easytier_list,
|
||||
download_easytier_zip,
|
||||
get_cli_version,
|
||||
get_members_by_cli
|
||||
get_members_by_cli,
|
||||
search_pid_by_pname
|
||||
])
|
||||
.run(context)
|
||||
.expect("error while running tauri application");
|
||||
|
||||
@@ -28,9 +28,11 @@
|
||||
"csp": null
|
||||
}
|
||||
},
|
||||
|
||||
"bundle": {
|
||||
"active": false,
|
||||
"targets": "all",
|
||||
"externalBin": ["WinIPBroadcast"],
|
||||
"createUpdaterArtifacts": false,
|
||||
"icon": ["icons/32x32.png", "icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user