Compare commits

...
25 Commits
Author SHA1 Message Date
黑先森 44183b1ad2 升级tauri为2.1.1 2024-11-12 15:40:48 +08:00
黑先森 fe1bc6f89e 增加ping的延迟1秒一次 2024-11-12 14:18:55 +08:00
黑先森 be59e56bd1 fix: 修复分享配置有中文无法分享的问题 2024-11-12 12:12:35 +08:00
黑先森 f556e17f85 固定窗口高度 2024-11-12 11:21:03 +08:00
黑先森 c7170967ec 给予一定的宽度可变调整 2024-11-12 11:04:21 +08:00
黑先森 1801082601 修复与优化
- 没有自动保存配置文件启动的bug
- 修复配置文件启动无法打开成员列表的bug
- 修复动态ipv4获取后,没有正确赋值到界面上的bug
- 增加使用配置文件启动时的提示
2024-11-11 18:19:28 +08:00
黑先森 189f3467c3 Merge branch 'dev_1.1.5'
# Conflicts:
#	README.md
2024-11-11 16:56:48 +08:00
黑先森 2eb69352f7 优化readme 2024-11-08 12:17:38 +08:00
黑先森 9ea0eea0ac Merge branch 'dev_1.1.4' 2024-11-05 18:30:29 +08:00
leizi97 c572925a0d Merge branch 'dev_1.1.3' 2024-11-04 22:46:28 +08:00
leizi97 e4fbaa921c Merge branch 'dev_1.1.2' 2024-11-04 21:29:29 +08:00
leizi97 76d29cbeeb Merge branch 'dev_1.1.1' 2024-11-03 23:13:43 +08:00
leizi97 6f57a866a4 Merge branch 'dev_1.1.0' 2024-11-03 22:09:58 +08:00
leizi97 fe9f1c01b7 Merge branch 'dev_1.0.9' 2024-10-29 23:32:48 +08:00
leizi97 43d681e888 Merge branch 'dev_1.0.9' 2024-10-29 22:51:34 +08:00
黑先森 d402f107b0 Merge branch 'dev_1.0.8' 2024-10-25 18:42:52 +08:00
leizi97 74fbfed7be Merge branch 'dev_1.0.7' 2024-10-23 22:04:58 +08:00
黑先森 5b9eed9520 Merge branch 'dev_1.0.6' 2024-10-17 19:35:37 +08:00
黑先森andGitHub 1ae122ab2a Update README.md 2024-10-16 17:41:44 +08:00
黑先森 3db962f3dc #improvement 增加说明图 2024-10-16 17:35:24 +08:00
黑先森 a7f1292067 Merge branch 'dev_1.0.5' 2024-10-16 17:22:00 +08:00
黑先森 022e71de01 Merge branch 'dev_1.0.5' 2024-10-16 16:41:30 +08:00
黑先森 5350af87ed Merge branch 'dev_1.0.4' 2024-10-16 09:52:35 +08:00
leizi97 5d6b7bdf13 Merge branch 'main' of https://github.com/EasyTier/EasytierGame 2024-10-13 21:37:27 +08:00
黑先森andGitHub 5740bd08c1 Update README.md 2024-10-13 21:28:41 +08:00
15 changed files with 400 additions and 742 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

+1 -1
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.1.5", "version": "1.1.7",
"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"
+198 -182
View File
@@ -4,181 +4,187 @@
label-position="top" label-position="top"
:model="config" :model="config"
> >
<ElFormItem <!-- element-loading-custom-class="config-start"
label="服务器" v-loading="mainStore.configStartEnable"
prop="serverUrl" :element-loading-spinner="'<path />'"
> element-loading-text="-------已经启用配置文件,界面配置不再生效-------" -->
<template #label> <!-- <div> -->
<div class="flex items-center gap-[0_5px]">
<div>服务器</div>
<span>-</span>
<ElTag
effect="dark"
:type="data.isSuccessGetIp ? 'success' : 'info'"
>
{{ data.isSuccessGetIp ? "联机成功" : data.isStart && !data.isSuccessGetIp ? "联机中" : "未联机" }}
</ElTag>
<ElButton
v-if="!data.coreVersion"
@click="getCoreVersion(true)"
>
获取内核版本
</ElButton>
<ElTag
v-else
type="info"
>
{{ data.coreVersion }}
</ElTag>
<ElPopconfirm
width="325"
cancel-button-text="取消"
confirm-button-text="继续"
title="内核从github下载,需要出国工具,可能下载缓慢或失败,是否继续?
也可以从官方群里手动下载后解压到easytier-game.exe同级目录下的easytier目录里,全部覆盖即可"
@confirm="handleUpdateCore"
>
<template #reference>
<ElButton
:disabled="data.isStart"
:loading="data.update"
type="warning"
size="small"
>
{{ data.coreVersion ? "更新内核" : "下载内核" }}
</ElButton>
</template>
</ElPopconfirm>
</div>
</template>
<ElSelect
allow-create
filterable
default-first-option
v-model="config.serverUrl"
@change="handleServerUrlChange"
>
<template #prefix>
<div :class="config.protocol && config.protocol.length > 1 ? 'w-[120px]' : 'w-[80px]'">
<ElSelect
placeholder="协议"
multiple
collapse-tags
@click.stop
v-model="config.protocol"
@change="handleServerUrlChange"
>
<ElOption
v-for="item in protocols"
:key="item"
:label="item"
:value="item"
></ElOption>
</ElSelect>
</div>
</template>
<ElOption
v-for="item in mainStore.basePeers"
:key="item"
:label="item"
:value="item"
>
<div class="flex items-center justify-between">
<span style="float: left">{{ item }}</span>
<ElButton
@click.stop="handleDeleteServerUrl(item)"
round
:icon="Delete"
type="danger"
></ElButton>
</div>
</ElOption>
</ElSelect>
</ElFormItem>
<div class="flex flex-wrap gap-[0_10px] items-center">
<div class="flex-1">
<ElFormItem label="网络名">
<template #label>
<div class="flex items-center">
网络名
<ElTooltip content="对应命令行参数 --network-name">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
</div>
</template>
<ElInput
maxlength="100"
placeholder="请输入网络名"
v-model="config.networkName"
></ElInput>
</ElFormItem>
</div>
<div class="flex-1">
<ElFormItem label="网络密码">
<template #label>
<div class="flex items-center">
网络密码
<ElTooltip content="对应命令行参数 --network-secret">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
</div>
</template>
<ElInput
show-password
maxlength="100"
placeholder="请输入网络密码"
v-model="config.networkPassword"
type="password"
></ElInput>
</ElFormItem>
</div>
</div>
<div class="flex gap-[0_10px]">
<ElFormItem label="主机名">
<template #label>
<div class="flex items-center">
主机名
<ElTooltip content="对应命令行参数 --hostname">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
</div>
</template>
<ElInput
maxlength="100"
placeholder="例如: Player1"
v-model="config.hostname"
></ElInput>
</ElFormItem>
<ElFormItem <ElFormItem
class="w-[70%]" label="服务器"
label="局域网IP" prop="serverUrl"
> >
<template #label> <template #label>
<div class="flex items-center h-[20px]"> <div class="flex items-center gap-[0_5px]">
虚拟网IP <div>服务器</div>
<ElTooltip content="对应命令行参数 --ipv4"> <span>-</span>
<ElIcon><QuestionFilled /></ElIcon> <ElTag
</ElTooltip> effect="dark"
<ElSwitch :type="data.isSuccessGetIp ? 'success' : 'info'"
v-model="config.dhcp" >
class="ml-[5px]" {{ data.isSuccessGetIp ? "联机成功" : data.isStart && !data.isSuccessGetIp ? "联机中" : "未联机" }}
inline-prompt </ElTag>
inactive-text="固定IP" <ElButton
active-text="动态获取IP" v-if="!data.coreVersion"
size="small" @click="getCoreVersion(true)"
></ElSwitch> >
获取内核版本
</ElButton>
<ElTag
v-else
type="info"
>
{{ data.coreVersion }}
</ElTag>
<ElPopconfirm
width="325"
cancel-button-text="取消"
confirm-button-text="继续"
title="内核从github下载,需要出国工具,可能下载缓慢或失败,是否继续?
也可以从官方群里手动下载后解压到easytier-game.exe同级目录下的easytier目录里,全部覆盖即可"
@confirm="handleUpdateCore"
>
<template #reference>
<ElButton
:disabled="data.isStart"
:loading="data.update"
type="warning"
size="small"
>
{{ data.coreVersion ? "更新内核" : "下载内核" }}
</ElButton>
</template>
</ElPopconfirm>
</div> </div>
</template> </template>
<ElInput <ElSelect
maxlength="100" allow-create
:disabled="config.dhcp" filterable
:placeholder="data.isStart ? '等待动态分配IP...' : '例如: 10.126.126.1'" default-first-option
v-model="config.ipv4" v-model="config.serverUrl"
></ElInput> @change="handleServerUrlChange"
>
<template #prefix>
<div :class="config.protocol && config.protocol.length > 1 ? 'w-[120px]' : 'w-[80px]'">
<ElSelect
placeholder="协议"
multiple
collapse-tags
@click.stop
v-model="config.protocol"
@change="handleServerUrlChange"
>
<ElOption
v-for="item in protocols"
:key="item"
:label="item"
:value="item"
></ElOption>
</ElSelect>
</div>
</template>
<ElOption
v-for="item in mainStore.basePeers"
:key="item"
:label="item"
:value="item"
>
<div class="flex items-center justify-between">
<span style="float: left">{{ item }}</span>
<ElButton
@click.stop="handleDeleteServerUrl(item)"
round
:icon="Delete"
type="danger"
></ElButton>
</div>
</ElOption>
</ElSelect>
</ElFormItem> </ElFormItem>
</div> <div class="flex flex-wrap gap-[0_10px] items-center">
<div class="flex items-start gap-[0_10px]"> <div class="flex-1">
<div class="w-[122px]"> <ElFormItem label="网络名">
<template #label>
<div class="flex items-center">
网络名
<ElTooltip content="对应命令行参数 --network-name">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
</div>
</template>
<ElInput
maxlength="100"
placeholder="请输入网络名"
v-model="config.networkName"
></ElInput>
</ElFormItem>
</div>
<div class="flex-1">
<ElFormItem label="网络密码">
<template #label>
<div class="flex items-center">
网络密码
<ElTooltip content="对应命令行参数 --network-secret">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
</div>
</template>
<ElInput
show-password
maxlength="100"
placeholder="请输入网络密码"
v-model="config.networkPassword"
type="password"
></ElInput>
</ElFormItem>
</div>
</div>
<div class="flex gap-[0_10px]">
<ElFormItem label="主机名">
<template #label>
<div class="flex items-center">
主机名
<ElTooltip content="对应命令行参数 --hostname">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
</div>
</template>
<ElInput
maxlength="100"
placeholder="例如: Player1"
v-model="config.hostname"
></ElInput>
</ElFormItem>
<ElFormItem
class="w-[70%]"
label="局域网IP"
>
<template #label>
<div class="flex items-center h-[20px]">
虚拟网IP
<ElTooltip content="对应命令行参数 --ipv4">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
<ElSwitch
v-model="config.dhcp"
class="ml-[5px]"
inline-prompt
inactive-text="固定IP"
active-text="动态获取IP"
size="small"
></ElSwitch>
</div>
</template>
<ElInput
maxlength="100"
:disabled="config.dhcp"
:placeholder="data.isStart && config.dhcp ? '等待动态分配IP...' : '例如: 10.126.126.1'"
v-model="config.ipv4"
></ElInput>
</ElFormItem>
</div>
<!-- </div> -->
<div class="flex items-start">
<div>
<div> <div>
<ElDropdown <ElDropdown
@command="handleStartCommand" @command="handleStartCommand"
@@ -241,7 +247,7 @@
</ElTooltip> </ElTooltip>
</div> </div>
</div> </div>
<div> <div class="ml-auto">
<ElCheckbox <ElCheckbox
v-model="config.disbleP2p" v-model="config.disbleP2p"
size="small" size="small"
@@ -282,7 +288,7 @@
</ElButton> </ElButton>
</div> </div>
<ElLink <ElLink
class="!text-[10px] pb-[2px] ml-[8px]" class="!text-[9px] pb-[2px] ml-[8px] truncate"
type="info" type="info"
:underline="false" :underline="false"
@click="open('https://github.com/EasyTier/EasytierGame')" @click="open('https://github.com/EasyTier/EasytierGame')"
@@ -474,13 +480,13 @@
unListenConfigStart: null, unListenConfigStart: null,
thread_id: null, thread_id: null,
async listenOutput() { async listenOutput() {
const appWindow = getCurrentWindow(); // const appWindow = getCurrentWindow();
const unListen = await listen("command-output", async 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 = /dhcp ip changed. old: None, new: Some\((\d+\.\d+\.\d+\.\d+).*\)/g.exec(event.payload as string)?.[1];
if (config.dhcp) { if (config.dhcp || mainStore.configStartEnable) {
if (ipv4) { if (ipv4) {
config.ipv4 = ipv4; config.ipv4 = ipv4;
await setTrayRunState(tray, true); await setTrayRunState(tray, true);
@@ -495,8 +501,11 @@
} }
} }
} }
appWindow.emitTo("log", "logs", data.log); const logArr = data.log.split("\n");
const start = logArr.length > 1000 ? logArr.length - 1000 : 0;
data.log = logArr.slice(start).join("\n");
data.log += (event.payload as string) + "\n"; data.log += (event.payload as string) + "\n";
}); });
this.unListenOutPut = unListen; this.unListenOutPut = unListen;
}, },
@@ -772,10 +781,15 @@
await reset(); await reset();
} else { } else {
const args = await getArgs(); const args = await getArgs();
if (!args || args.length <= 0) { if (!args || args.length <= 0) {
return ElMessage.error("无配置"); return ElMessage.error("无配置");
} }
if(args[0] === "-c") {
ElMessage.warning({
message: "使用配置文件中.",
duration: 5000,
});
}
data.log = ""; //清空日志 data.log = ""; //清空日志
data.startLoading = true; data.startLoading = true;
await unListenAll(); await unListenAll();
@@ -811,9 +825,11 @@
} }
if (command === "share_config") { if (command === "share_config") {
try { try {
await writeText(btoa(JSON.stringify({ config: mainStore.config }))); const WT = btoa(encodeURIComponent(JSON.stringify({ config: mainStore.config })))
await writeText(WT);
ElMessage.success("配置已复制"); ElMessage.success("配置已复制");
} catch (err) { } catch (err) {
console.log(err);
ElMessage.error("分享失败"); ElMessage.error("分享失败");
} }
} }
@@ -829,7 +845,7 @@
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消" cancelButtonText: "取消"
}); });
const payload = JSON.parse(atob(importConfigData.data)); const payload = JSON.parse(decodeURIComponent(atob(importConfigData.data)));
mainStore.$patch(payload); mainStore.$patch(payload);
ElMessage.success("导入成功"); ElMessage.success("导入成功");
importConfigData.visible = false; importConfigData.visible = false;
@@ -864,9 +880,9 @@
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");
} // }
await etWindows( await etWindows(
"member", "member",
@@ -899,7 +915,7 @@
data.logVisible = true; data.logVisible = true;
logsTimer && clearInterval(logsTimer); logsTimer && clearInterval(logsTimer);
logsTimer = setInterval(() => { logsTimer = setInterval(() => {
appWindow.emitTo("log", "logs", data.log ? (data.log as string).split("\n").slice(-1000).join("\n") : ""); appWindow.emitTo("log", "logs", data.log);
}, 600); }, 600);
}, },
() => { () => {
+24 -6
View File
@@ -144,7 +144,7 @@
<ElInputNumber <ElInputNumber
controls-position="right" controls-position="right"
size="small" size="small"
:precision="0" :precision="0"
v-model="data.pingNum" v-model="data.pingNum"
:min="1" :min="1"
:max="10" :max="10"
@@ -155,6 +155,7 @@
</ElInputNumber> </ElInputNumber>
<ElButton <ElButton
size="small" size="small"
:disabled="data.isPing"
@click="handleTestPing" @click="handleTestPing"
> >
Ping一下 Ping一下
@@ -181,6 +182,7 @@
import useMainStore from "@/stores/index"; import useMainStore from "@/stores/index";
import { handleWinipBcStart, initStartWinIpBroadcast } from "@/composables/netcard"; import { handleWinipBcStart, initStartWinIpBroadcast } from "@/composables/netcard";
import { getCurrentWindow } from "@tauri-apps/api/window"; import { getCurrentWindow } from "@tauri-apps/api/window";
import { isValidIP } from "~/utils";
const mainStore = useMainStore(); const mainStore = useMainStore();
const data = reactive({ const data = reactive({
@@ -189,6 +191,7 @@
pingNum: 1, pingNum: 1,
winipBcStart: false, winipBcStart: false,
pingIp: "", pingIp: "",
isPing: false,
pingLog: "", pingLog: "",
firewallStatus: { firewallStatus: {
domain: false, domain: false,
@@ -228,28 +231,41 @@
} }
}; };
const awaitTime = (time: number) => {
return new Promise(res => {
setTimeout(res, time);
});
};
const handleTestPing = async () => { const handleTestPing = async () => {
/^((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(?::(?:[0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$/; // const is = isValidIP(data.pingIp);
if (data.pingIp) { if (data.pingIp) {
data.pingLog = ""; data.pingLog = "";
data.isPing = true;
try { try {
for (let i = 0; i < data.pingNum; i++) { for (let i = 0; i < data.pingNum; i++) {
const output = await Command.create("ping", ["-n", "1", data.pingIp], { const output = await Command.create("ping", ["-n", "1", data.pingIp], {
encoding: "gb2312" encoding: "gb2312"
}).execute(); }).execute();
data.pingLog = data.pingLog.slice(-1000);
if (output.stdout) { if (output.stdout) {
data.pingLog += output.stdout.split("\n")[2]; data.pingLog += `${i + 1} - ${output.stdout.split("\n")[2]}`;
} }
if (output.stderr) { if (output.stderr) {
data.pingLog += output.stderr; data.pingLog += `${i + 1}error - ${output.stderr}`;
}
if(i != data.pingNum - 1) {
await awaitTime(1000);
} }
} }
data.pingLog += '完毕'
} catch (err) { } catch (err) {
ElMessage.error("Ping发生错误"); ElMessage.error("Ping发生错误");
console.log(err); console.log(err);
} finally {
data.isPing = false;
} }
}else {
ElMessage.error("请输入正确的IP");
} }
}; };
@@ -306,6 +322,7 @@
} }
} }
} catch (err) { } catch (err) {
// netsh advfirewall firewall add rule name="EXE名称" dir=out action=allow program="EXE绝对路径"
ElMessage.error("获取防火墙状态失败"); ElMessage.error("获取防火墙状态失败");
console.log(err); console.log(err);
} }
@@ -318,6 +335,7 @@
}); });
onMounted(() => { onMounted(() => {
data.pingIp = mainStore.config.ipv4;
initStartWinIpBroadcast(); initStartWinIpBroadcast();
}); });
</script> </script>
+128 -516
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "easytier-game" name = "easytier-game"
version = "1.1.5" version = "1.1.7"
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"
@@ -18,20 +18,20 @@ name = "app_lib"
crate-type = ["staticlib", "cdylib", "rlib"] crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies] [build-dependencies]
tauri-build = { version = "2.0.2", features = [] } tauri-build = { version = "2.0.3", features = [] }
# prost-build = "0.13.2" # prost-build = "0.13.2"
[dependencies] [dependencies]
serde_json = "1.0" serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
log = "0.4" log = "0.4"
tauri = { version = "2.0.6", features = [ tauri = { version = "2.1.1", features = [
"tray-icon", "tray-icon",
"image-png", "image-png",
"image-ico", "image-ico",
] } ] }
tauri-plugin-log = "2.0.1" tauri-plugin-log = "2.0.2"
tauri-plugin-shell = "2.0.2" tauri-plugin-shell = "2.0.2"
reqwest = { version = "0.12", features = ["json"] } reqwest = { version = "0.12", features = ["json"] }
zip = "2.2.0" zip = "2.2.0"
@@ -39,7 +39,7 @@ sysinfo = '0.32.0'
planif = { git = "https://github.com/mattrobineau/planif", tag = "1.0.1" } planif = { git = "https://github.com/mattrobineau/planif", tag = "1.0.1" }
whoami = "1.5.2" whoami = "1.5.2"
tauri-plugin-fs = "2" tauri-plugin-fs = "2"
tauri-plugin-clipboard-manager = "2.0.0-rc" tauri-plugin-clipboard-manager = "2.0.2"
# prost = "0.13" # prost = "0.13"
# prost-types = "0.13" # prost-types = "0.13"
+8 -4
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.1.5", "version": "1.1.7",
"identifier": "com.tauri.easytier-game", "identifier": "com.tauri.easytier-game",
"build": { "build": {
@@ -13,10 +13,14 @@
"app": { "app": {
"windows": [ "windows": [
{ {
"title": "easytier-game 1.1.5", "title": "easytier-game 1.1.7",
"width": 335, "minWidth": 340,
"width": 340,
"height": 305, "height": 305,
"resizable": false, "minHeight": 305,
"maxHeight": 305,
"maxWidth": 360,
"resizable": true,
"fullscreen": false, "fullscreen": false,
"decorations": true, "decorations": true,
"center": true, "center": true,
+2
View File
@@ -44,6 +44,8 @@ export default defineStore("main", {
"basePeers", "basePeers",
"cidrEnable", "cidrEnable",
"theme", "theme",
"configStartEnable",
"configPath",
"winIpBcAutoStart", "winIpBcAutoStart",
"config.proxyNetworks", "config.proxyNetworks",
"config.serverUrl", "config.serverUrl",
+34 -28
View File
@@ -1,4 +1,3 @@
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import Clipboard from "vue-clipboard3"; import Clipboard from "vue-clipboard3";
@@ -79,36 +78,43 @@ export const ATJ = (promise: Promise<any>, errorExt: string | undefined = undefi
export const parsePeerInfo = (content: string) => { export const parsePeerInfo = (content: string) => {
// 将表格字符串分割成行 // 将表格字符串分割成行
const lines = content.split('\n') const lines = content.split("\n");
// 提取表头(keys // 提取表头(keys
const headers = lines[1] const headers = lines[1]
.split('│') .split("│")
.slice(1, -1) .slice(1, -1)
.map((h) => h.trim()) .map(h => h.trim());
// 初始化结果数组 // 初始化结果数组
const result: any[] = [] const result: any[] = [];
// 遍历数据行 // 遍历数据行
for (let i = 3; i < lines.length - 1; i += 2) { for (let i = 3; i < lines.length - 1; i += 2) {
if (lines[i].trim() === '') continue // 跳过空行 if (lines[i].trim() === "") continue; // 跳过空行
// 分割每一行的数据 // 分割每一行的数据
const values = lines[i] const values = lines[i]
.split('│') .split("│")
.slice(1, -1) .slice(1, -1)
.map((v) => v.trim()) .map(v => v.trim());
// 创建对象并添加到结果数组 // 创建对象并添加到结果数组
const obj: any = {} const obj: any = {};
headers.forEach((header, index) => { headers.forEach((header, index) => {
obj[header] = values[index] === '-' || values[index] === '' ? null : values[index] obj[header] = values[index] === "-" || values[index] === "" ? null : values[index];
}) });
// 每行数据都作为一个新对象添加到结果数组中 // 每行数据都作为一个新对象添加到结果数组中
result.push(obj) result.push(obj);
} }
return result return result;
} };
export function isValidIP(ip: string) {
const ipv4Pattern =
/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
const ipv6Pattern = /^(?:[A-Fa-f0-9]{1,4}:){7}[A-Fa-f0-9]{1,4}$/;
return ipv4Pattern.test(ip) || ipv6Pattern.test(ip);
}