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, "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.6", "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"
+9 -7
View File
@@ -183,8 +183,8 @@
</ElFormItem> </ElFormItem>
</div> </div>
<!-- </div> --> <!-- </div> -->
<div class="flex items-start gap-[0_10px]"> <div class="flex items-start">
<div class="w-[122px]"> <div>
<div> <div>
<ElDropdown <ElDropdown
@command="handleStartCommand" @command="handleStartCommand"
@@ -247,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"
@@ -288,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')"
@@ -480,7 +480,7 @@
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) {
@@ -825,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("分享失败");
} }
} }
@@ -843,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;
+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.6" 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.6", "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.6", "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,
+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);
}