Compare commits

..
5 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
7 changed files with 209 additions and 567 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
"private": true,
"author": "leizi97",
"description": "A simple network initiator based on Easytier",
"version": "1.1.6",
"version": "1.1.7",
"scripts": {
"dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0",
"build": "nuxt generate --dotenv env/.env.prod"
+9 -7
View File
@@ -183,8 +183,8 @@
</ElFormItem>
</div>
<!-- </div> -->
<div class="flex items-start gap-[0_10px]">
<div class="w-[122px]">
<div class="flex items-start">
<div>
<div>
<ElDropdown
@command="handleStartCommand"
@@ -247,7 +247,7 @@
</ElTooltip>
</div>
</div>
<div>
<div class="ml-auto">
<ElCheckbox
v-model="config.disbleP2p"
size="small"
@@ -288,7 +288,7 @@
</ElButton>
</div>
<ElLink
class="!text-[10px] pb-[2px] ml-[8px]"
class="!text-[9px] pb-[2px] ml-[8px] truncate"
type="info"
:underline="false"
@click="open('https://github.com/EasyTier/EasytierGame')"
@@ -480,7 +480,7 @@
unListenConfigStart: null,
thread_id: null,
async listenOutput() {
const appWindow = getCurrentWindow();
// const appWindow = getCurrentWindow();
const unListen = await listen("command-output", async event => {
data.isStart = true;
if (event.payload) {
@@ -825,9 +825,11 @@
}
if (command === "share_config") {
try {
await writeText(btoa(JSON.stringify({ config: mainStore.config })));
const WT = btoa(encodeURIComponent(JSON.stringify({ config: mainStore.config })))
await writeText(WT);
ElMessage.success("配置已复制");
} catch (err) {
console.log(err);
ElMessage.error("分享失败");
}
}
@@ -843,7 +845,7 @@
confirmButtonText: "确定",
cancelButtonText: "取消"
});
const payload = JSON.parse(atob(importConfigData.data));
const payload = JSON.parse(decodeURIComponent(atob(importConfigData.data)));
mainStore.$patch(payload);
ElMessage.success("导入成功");
importConfigData.visible = false;
+24 -6
View File
@@ -144,7 +144,7 @@
<ElInputNumber
controls-position="right"
size="small"
:precision="0"
:precision="0"
v-model="data.pingNum"
:min="1"
:max="10"
@@ -155,6 +155,7 @@
</ElInputNumber>
<ElButton
size="small"
:disabled="data.isPing"
@click="handleTestPing"
>
Ping一下
@@ -181,6 +182,7 @@
import useMainStore from "@/stores/index";
import { handleWinipBcStart, initStartWinIpBroadcast } from "@/composables/netcard";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { isValidIP } from "~/utils";
const mainStore = useMainStore();
const data = reactive({
@@ -189,6 +191,7 @@
pingNum: 1,
winipBcStart: false,
pingIp: "",
isPing: false,
pingLog: "",
firewallStatus: {
domain: false,
@@ -228,28 +231,41 @@
}
};
const awaitTime = (time: number) => {
return new Promise(res => {
setTimeout(res, time);
});
};
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) {
data.pingLog = "";
data.isPing = true;
try {
for (let i = 0; i < data.pingNum; i++) {
const output = await Command.create("ping", ["-n", "1", data.pingIp], {
encoding: "gb2312"
}).execute();
data.pingLog = data.pingLog.slice(-1000);
if (output.stdout) {
data.pingLog += output.stdout.split("\n")[2];
data.pingLog += `${i + 1} - ${output.stdout.split("\n")[2]}`;
}
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) {
ElMessage.error("Ping发生错误");
console.log(err);
} finally {
data.isPing = false;
}
}else {
ElMessage.error("请输入正确的IP");
}
};
@@ -306,6 +322,7 @@
}
}
} catch (err) {
// netsh advfirewall firewall add rule name="EXE名称" dir=out action=allow program="EXE绝对路径"
ElMessage.error("获取防火墙状态失败");
console.log(err);
}
@@ -318,6 +335,7 @@
});
onMounted(() => {
data.pingIp = mainStore.config.ipv4;
initStartWinIpBroadcast();
});
</script>
+128 -516
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,6 +1,6 @@
[package]
name = "easytier-game"
version = "1.1.6"
version = "1.1.7"
homepage = "https://github.com/EasyTier/EasyTier"
repository = "https://github.com/EasyTier/EasytierGame"
description = "A simple network initiator based on Easytier"
@@ -18,20 +18,20 @@ name = "app_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2.0.2", features = [] }
tauri-build = { version = "2.0.3", features = [] }
# prost-build = "0.13.2"
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
log = "0.4"
tauri = { version = "2.0.6", features = [
tauri = { version = "2.1.1", features = [
"tray-icon",
"image-png",
"image-ico",
] }
tauri-plugin-log = "2.0.1"
tauri-plugin-log = "2.0.2"
tauri-plugin-shell = "2.0.2"
reqwest = { version = "0.12", features = ["json"] }
zip = "2.2.0"
@@ -39,7 +39,7 @@ sysinfo = '0.32.0'
planif = { git = "https://github.com/mattrobineau/planif", tag = "1.0.1" }
whoami = "1.5.2"
tauri-plugin-fs = "2"
tauri-plugin-clipboard-manager = "2.0.0-rc"
tauri-plugin-clipboard-manager = "2.0.2"
# prost = "0.13"
# prost-types = "0.13"
+8 -4
View File
@@ -1,7 +1,7 @@
{
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "easytier-game",
"version": "1.1.6",
"version": "1.1.7",
"identifier": "com.tauri.easytier-game",
"build": {
@@ -13,10 +13,14 @@
"app": {
"windows": [
{
"title": "easytier-game 1.1.6",
"width": 335,
"title": "easytier-game 1.1.7",
"minWidth": 340,
"width": 340,
"height": 305,
"resizable": false,
"minHeight": 305,
"maxHeight": 305,
"maxWidth": 360,
"resizable": true,
"fullscreen": false,
"decorations": true,
"center": true,
+34 -28
View File
@@ -1,4 +1,3 @@
import { ElMessage } from "element-plus";
import Clipboard from "vue-clipboard3";
@@ -79,36 +78,43 @@ export const ATJ = (promise: Promise<any>, errorExt: string | undefined = undefi
export const parsePeerInfo = (content: string) => {
// 将表格字符串分割成行
const lines = content.split('\n')
const lines = content.split("\n");
// 提取表头(keys
const headers = lines[1]
.split('│')
.slice(1, -1)
.map((h) => h.trim())
.split("│")
.slice(1, -1)
.map(h => h.trim());
// 初始化结果数组
const result: any[] = []
const result: any[] = [];
// 遍历数据行
for (let i = 3; i < lines.length - 1; i += 2) {
if (lines[i].trim() === '') continue // 跳过空行
// 分割每一行的数据
const values = lines[i]
.split('│')
.slice(1, -1)
.map((v) => v.trim())
// 创建对象并添加到结果数组
const obj: any = {}
headers.forEach((header, index) => {
obj[header] = values[index] === '-' || values[index] === '' ? null : values[index]
})
// 每行数据都作为一个新对象添加到结果数组中
result.push(obj)
if (lines[i].trim() === "") continue; // 跳过空行
// 分割每一行的数据
const values = lines[i]
.split("│")
.slice(1, -1)
.map(v => v.trim());
// 创建对象并添加到结果数组
const obj: any = {};
headers.forEach((header, index) => {
obj[header] = values[index] === "-" || values[index] === "" ? null : values[index];
});
// 每行数据都作为一个新对象添加到结果数组中
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);
}