#Fix 开机自启使用系统账户,修复cidr无法查看的问题,修复服务器选择时的bug #26

This commit is contained in:
黑先森
2025-10-24 12:11:17 +08:00
parent c10a3ae22f
commit 9e83ca7d91
5 changed files with 260 additions and 380 deletions
+2 -11
View File
@@ -69,7 +69,7 @@
data.isRunning = true;
const [error, member] = await ATJ(invoke<string>("get_route_by_cli"));
data.isRunning = false;
// if(!member) return;
if(!member) return;
if (error) {
data.route = [];
return "";
@@ -79,16 +79,7 @@
await listenOutput();
return;
}
const routeInfo = parseCliInfo(member);
routeInfo.forEach(value => {
if (value.cost === "Local") {
value.cost = "本机";
}
if (value.ipv4 && value.ipv4.includes("/")) {
value.ipv4 = value.ipv4.split("/")[0];
}
});
data.route = routeInfo;
data.route = JSON.parse(member);
};
const listenStart = async () => {
+4 -50
View File
@@ -67,6 +67,7 @@
</template>
<ElSelect
allow-create
:reserve-keyword="false"
filterable
multiple
collapse-tags
@@ -962,7 +963,7 @@
// console.log(mainStore.config.serverUrl);
for (const p of protocols) {
for (const url of mainStore.config.serverUrl) {
if (url.toLowerCase().startsWith(`${p}://`)) {
if (url.replace(/\\/g, "/").toLowerCase().startsWith(`${p}://`)) {
inputProtocols.push(p);
}
}
@@ -971,8 +972,8 @@
mainStore.config.protocol = uniq([...mainStore.config.protocol, ...inputProtocols]);
mainStore.config.serverUrl = (mainStore.config.serverUrl || []).map(url => {
for (const p of protocols) {
if (url.toLowerCase().startsWith(`${p}://`)) {
return url.slice(inputProtocols.length + 3);
if (url.replace(/\\/g, "/").toLowerCase().startsWith(`${p}://`)) {
return url.slice(p.length + 3);
}
}
return url;
@@ -1385,52 +1386,6 @@
});
};
// 节点参数含义解析:
// - is_active: 节点是否激活运行
// - is_approved: 节点是否被管理员批准
// - allow_relay: 是否允许中继转发
// - current_health_status: 当前健康状态 ("healthy", "unhealthy", "unknown")
// - usage_percentage: 使用率百分比 (0-100)
// - health_percentage_24h: 24小时健康率 (0-100)
// - last_response_time: 最后响应时间(毫秒),越小越好
// - current_connections: 当前连接数
// - max_connections: 最大连接数
// - protocol: 协议类型 ("tcp", "udp", "quic" 等)
const initNodesList = async () => {
let nodesList = await invoke<string>("fetch_nodes_list", { page: 1, limit: 1000 });
if (nodesList === "_EasytierGameFetchNodesError_") {
nodesList = "";
}
try {
const nodesListData: NodesResponse = JSON.parse(nodesList);
console.log("节点数据:", nodesListData);
if (nodesListData.success && nodesListData.data.items) {
// 过滤可用节点
const availableNodes = filterAvailableNodes(nodesListData.data.items);
console.log(`总节点数: ${nodesListData.data.items.length}, 可用节点数: ${availableNodes.length}`);
// 按优先级排序
const sortedNodes = sortNodesByPriority(availableNodes);
// 处理过滤后的节点数据
sortedNodes.forEach((node, index) => {
console.log(`${index + 1}. ${node.name} (${node.protocol}) - ${node.address}`);
console.log(
` 状态: ${node.current_health_status}, 使用率: ${node.usage_percentage.toFixed(1)}%, 响应时间: ${node.last_response_time}ms`
);
console.log(` 连接: ${node.current_connections}/${node.max_connections}, 24h健康率: ${node.health_percentage_24h}%`);
});
// 将可用节点添加到服务器列表
// addNodesToServerList(sortedNodes);
}
} catch (err) {
console.error("解析节点数据失败:", err);
}
};
// 过滤可用节点的函数
const filterAvailableNodes = (nodes: NodeItem[]): NodeItem[] => {
return nodes.filter(node => {
@@ -1532,7 +1487,6 @@
onMounted(async () => {
await compatibleInitServerUrl();
initNodesList();
await initGuiJson();
await compatibleInitAutoStart();
// await initAutoStart();
+4 -4
View File
@@ -87,7 +87,7 @@
:type="getResponseTimeType(row.last_response_time)"
size="small"
>
{{ row.last_response_time }}ms
{{ Number(row.last_response_time / 1000).toFixed(2) }}ms
</ElTag>
</template>
</ElTableColumn>
@@ -176,8 +176,8 @@ import { uniq } from "lodash-es";
// 获取响应时间类型
const getResponseTimeType = (responseTime: number) => {
if (responseTime < 1000) return "success";
if (responseTime < 5000) return "warning";
if (responseTime < 60 * 1000) return "success";
if (responseTime < 100 * 1000) return "warning";
return "danger";
};
@@ -196,9 +196,9 @@ import { uniq } from "lodash-es";
if (nodesList === "_EasytierGameFetchNodesError_") {
nodesList = "";
}
if (nodesList) {
const nodesListData: NodesResponse = JSON.parse(nodesList);
console.log(nodesListData);
if (nodesListData.success && nodesListData.data.items) {
// 过滤可用节点
const availableNodes = filterAvailableNodes(nodesListData.data.items);
+244 -311
View File
File diff suppressed because it is too large Load Diff
+6 -4
View File
@@ -303,6 +303,8 @@ async fn get_members_by_cli() -> String {
async fn get_route_by_cli() -> String {
let cli_path = get_tool_exe_path("\\easytier\\easytier-cli.exe");
match tokioCommand::new(&cli_path)
.arg("-o")
.arg("json")
.arg("route")
.creation_flags(0x08000000)
.output()
@@ -816,10 +818,10 @@ fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error
exec_action.SetPath(&BSTR::from(exe_path))?;
exec_action.SetArguments(&BSTR::from("--task-auto-start"))?;
// 使用当前用户运行
// 使用管理员权限运行,用户账户无法修改
let principal = task_definition.Principal()?;
principal.SetUserId(&BSTR::from(whoami::username().as_str()))?;
principal.SetLogonType(TASK_LOGON_INTERACTIVE_TOKEN)?;
principal.SetUserId(&BSTR::from("SYSTEM"))?;
principal.SetLogonType(TASK_LOGON_SERVICE_ACCOUNT)?;
principal.SetRunLevel(TASK_RUNLEVEL_HIGHEST)?;
// 设置任务设置
@@ -841,7 +843,7 @@ fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error
TASK_CREATE_OR_UPDATE.0,
&VARIANT::default(),
&VARIANT::default(),
TASK_LOGON_INTERACTIVE_TOKEN,
TASK_LOGON_SERVICE_ACCOUNT,
&VARIANT::default(),
)?;