增加 防止系统休眠 功能 修复winipboadcast关闭后再次打开又启动的bug,优化成员列表字体大小和布局

This commit is contained in:
黑先森
2024-12-04 18:13:55 +08:00
parent 0253d95597
commit 7d6e93d796
13 changed files with 85 additions and 21 deletions
+4
View File
@@ -46,4 +46,8 @@ html.dark body {
align-items: flex-start;
overflow: auto;
flex: 1;
}
.el-table {
font-size: 12px!important;
}
+1
View File
@@ -24,6 +24,7 @@ export const updateConfigJson = async (configJsonSeverUrl: Array<string> | strin
serverUrl,
port,
enableCustomListener,
enablePreventSleep,
customListenerData,
...otherConfig
} = mainStore.config;
+1 -1
View File
@@ -44,7 +44,7 @@ export const handleWinipBcStart = async () => {
await getWinIpBroadcastPid();
if (mainStore.winipBcPid <= 0) {
mainStore.$patch({
winIpBcAutoStart: true
winIpBcAutoStart: false
});
}
}
+1 -1
View File
@@ -3,7 +3,7 @@
"private": true,
"author": "leizi97",
"description": "A simple network initiator based on Easytier",
"version": "1.2.9",
"version": "1.3.0",
"scripts": {
"dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0",
"build": "nuxt generate --dotenv env/.env.prod",
+2
View File
@@ -58,6 +58,7 @@
打开config.json目录
</ElButton>
</div>
<div><ElCheckbox v-model="mainStore.config.enablePreventSleep">防止休眠</ElCheckbox></div>
<ElDivider />
<div class="flex items-center gap-[10px]">
<ElCheckbox v-model="mainStore.config.disbleListenner">不监听任何端口只连接到对等节点</ElCheckbox>
@@ -184,6 +185,7 @@
import { reactive } from "vue";
import { dataSubscribe } from "@/composables/windows";
import { supportProtocols } from "~/utils";
import { getCurrentWindow } from "@tauri-apps/api/window";
const protocols = supportProtocols();
const listenerDialogData = reactive<{ [key: string]: any }>({
+17 -5
View File
@@ -523,7 +523,7 @@
import { updateConfigJson } from "~/composables/configJson";
import { writeText, readText } from "@tauri-apps/plugin-clipboard-manager";
import { sortedUniq, uniq } from "lodash-es";
import { bounce, addQQGroup, supportProtocols } from "~/utils";
import { bounce, addQQGroup, supportProtocols, preventSleep, stopPreventSleep } from "~/utils";
import { ElConfirmDanger, ElConfirmPrimary } from "~/utils/element";
import { getServerArgs } from "@/composables/server";
@@ -668,9 +668,9 @@
mainStore.config.ipv4 = configIpv4;
}
}
if (event.payload.includes("peer connection removed")) {
data.isSuccessGetIp = false;
}
// if (event.payload.includes("peer connection removed")) {
// data.isSuccessGetIp = false;
// }
if (event.payload.includes("new peer connection added") && !data.isSuccessGetIp) {
await setTrayRunState(tray, true);
data.isSuccessGetIp = true;
@@ -737,10 +737,14 @@
async listenConfigStart() {
const appWindow = getCurrentWindow();
const unListen = await listen("config", event => {
// console.error("config", event.payload);
const ipv4 = config.ipv4;
mainStore.$patch(event.payload as any);
config.ipv4 = ipv4;
if(mainStore.config.enablePreventSleep) {
preventSleep();
}else {
stopPreventSleep();
}
appWindow.emitTo({ kind: "Any" }, "global-main-store", { store: { ...mainStore.$state } });
});
const unListen2 = mainStore.$subscribe(() => {
@@ -949,6 +953,12 @@
}
};
const initPreventSleep = async () => {
if (mainStore.config.enablePreventSleep) {
preventSleep();
}
}
const mountedShow = async () => {
const args = await getMatches();
if (!args.args?.["task-auto-start"]?.value) {
@@ -974,6 +984,7 @@
await initConfigDir();
await initAutoStartServer();
await initConnectAfterStart();
initPreventSleep();
mountedShow(); // 不需要await
closePrevent();
});
@@ -986,6 +997,7 @@
listenObj.unListenStartStopServer && listenObj.unListenStartStopServer();
logsTimer && clearInterval(logsTimer);
serverLogsTimer && clearInterval(serverLogsTimer);
stopPreventSleep();
});
const getArgs = async () => {
+9 -6
View File
@@ -1,7 +1,7 @@
<template>
<div class="overflow-auto h-full">
<div class="w-[1200px]">
<span v-if="!data.member || data.member.length <= 0">{{ "等待成员信息中..." }}</span>
<ElText size="small" v-if="!data.member || data.member.length <= 0">{{ "等待成员信息中..." }}</ElText>
<ElTable
stripe
border
@@ -22,10 +22,11 @@
sortable
width="90"
prop="cost"
label="路由"
label="方式"
>
<template #default="{ row }">
<ElTag
size="small"
effect="dark"
:type="row.cost == 'p2p' ? 'success' : 'info'"
>
@@ -42,12 +43,12 @@
<ElTableColumn
sortable
prop="lat_ms"
width="130"
width="100"
label="延迟/ms"
></ElTableColumn>
<ElTableColumn
sortable
width="120"
width="100"
prop="loss_rate"
label="丢包率"
>
@@ -57,7 +58,7 @@
</ElTableColumn>
<ElTableColumn
sortable
width="120"
width="110"
label="NAT类型"
prop="nat_type"
>
@@ -67,17 +68,19 @@
</ElTableColumn>
<ElTableColumn
sortable
width="120"
width="122"
prop="version"
label="版本"
></ElTableColumn>
<ElTableColumn
sortable
width="100"
prop="tunnel_proto"
label="隧道协议"
></ElTableColumn>
<ElTableColumn
sortable
width="90"
prop="rx_bytes"
label="接收"
></ElTableColumn>
+1 -1
View File
@@ -1227,7 +1227,7 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
[[package]]
name = "easytier-game"
version = "1.2.9"
version = "1.3.0"
dependencies = [
"log",
"planif",
+3 -3
View File
@@ -1,6 +1,6 @@
[package]
name = "easytier-game"
version = "1.2.9"
version = "1.3.0"
homepage = "https://github.com/EasyTier/EasyTier"
repository = "https://github.com/EasyTier/EasytierGame"
description = "A simple network initiator based on Easytier"
@@ -34,7 +34,7 @@ tauri = { version = "2.1.1", features = [
tauri-plugin-log = "2.0.2"
tauri-plugin-shell = "2.0.2"
reqwest = { version = "0.12", features = ["json"] }
zip = "2.2.0"
zip = "2.2"
sysinfo = '0.32.0'
planif = { git = "https://github.com/mattrobineau/planif", tag = "1.0.1" }
whoami = "1.5.2"
@@ -47,7 +47,7 @@ tokio = { version = "1.41.1", features = ["process"] }
[dependencies.windows]
version = "0.58.0"
features = ["Win32_System_TaskScheduler"]
features = ["Win32_System_TaskScheduler", "Win32_System_Power"]
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
tauri-plugin-cli = "2"
+26 -1
View File
@@ -20,8 +20,31 @@ use windows::Win32::Foundation::VARIANT_BOOL;
use windows::Win32::System::Com::*;
use windows::Win32::System::TaskScheduler::*;
use windows::Win32::System::Power::SetThreadExecutionState;
use windows::Win32::System::Power::ES_CONTINUOUS;
use windows::Win32::System::Power::ES_SYSTEM_REQUIRED;
use windows::Win32::System::Power::EXECUTION_STATE;
use tokio::process::Command as tokioCommand;
#[tauri::command(rename_all = "snake_case")]
fn prevent_sleep() -> bool {
unsafe {
let result = SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
result != EXECUTION_STATE(0)
}
}
#[tauri::command(rename_all = "snake_case")]
fn allow_sleep() -> bool {
unsafe {
let result = SetThreadExecutionState(ES_CONTINUOUS);
result != EXECUTION_STATE(0)
}
}
// 定义GitHub Release的结构体
#[derive(Debug, Deserialize)]
pub struct Release {
@@ -626,7 +649,9 @@ pub fn run() {
search_pid_by_pname,
get_exe_directory,
spawn_autostart,
autostart_is_enabled
autostart_is_enabled,
prevent_sleep,
allow_sleep
])
.run(context)
.expect("error while running tauri application");
+2 -2
View File
@@ -1,7 +1,7 @@
{
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "easytier-game",
"version": "1.2.9",
"version": "1.3.0",
"identifier": "com.tauri.easytier-game",
"build": {
@@ -13,7 +13,7 @@
"app": {
"windows": [
{
"title": "easytier-game 1.2.9",
"title": "easytier-game 1.3.0",
"label": "main",
"minWidth": 340,
"width": 340,
+2 -1
View File
@@ -34,7 +34,8 @@ export default defineStore("main", {
enableCustonProtocol: false, //自定义默认协议
customProtocol: "tcp", //自定义默认协议
enableNetCardMetric: false, //启用网卡自定义跃点
netCardMetricValue: 1 //自定义网卡跃点值
netCardMetricValue: 1, //自定义网卡跃点值
enablePreventSleep: false, //组织系统休眠
},
serverConfig: {
enableWhiteList: true, // 是否启用白名单
+16
View File
@@ -1,3 +1,4 @@
import { invoke } from "@tauri-apps/api/core";
import { open } from "@tauri-apps/plugin-shell";
export const ENV = import.meta.env;
@@ -70,6 +71,21 @@ export const supportProtocols = () => {
return _supportProtocols.slice();
}
let _prevent_timer: NodeJS.Timeout| null = null;
let _prevent_timer_count = 30; // 秒
export const preventSleep = () => {
_prevent_timer && clearInterval(_prevent_timer);
_prevent_timer = setInterval(async () => {
const result = await invoke('prevent_sleep');
// console.log(`trigger prevent sleep ${result}`);
}, _prevent_timer_count * 1000);
}
export const stopPreventSleep = () => {
_prevent_timer && clearInterval(_prevent_timer);
_prevent_timer = null;
}
export const parsePeerInfo = (content: string) => {
if(!content) return [];
// 将表格字符串分割成行