mirror of
https://github.com/EasyTier/EasytierGame.git
synced 2025-05-19 10:27:56 +00:00
保存窗口的大小状态,优化成员列表显示,开机自启隐藏于托盘,服务器地址输入支持带协议 [protocol]://
This commit is contained in:
+2
-1
@@ -3,7 +3,7 @@
|
||||
"private": true,
|
||||
"author": "leizi97",
|
||||
"description": "A simple network initiator based on Easytier",
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.1",
|
||||
"scripts": {
|
||||
"dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0",
|
||||
"build": "nuxt generate --dotenv env/.env.prod"
|
||||
@@ -21,6 +21,7 @@
|
||||
"@tauri-apps/plugin-fs": "~2",
|
||||
"@tauri-apps/plugin-http": "^2.0.1",
|
||||
"@tauri-apps/plugin-shell": "~2",
|
||||
"@tauri-apps/plugin-window-state": "~2",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@vitejs/plugin-vue-jsx": "^4.1.0",
|
||||
"@vueuse/core": "^11.2.0",
|
||||
|
||||
+134
-77
@@ -2,7 +2,8 @@
|
||||
<ElForm
|
||||
size="small"
|
||||
label-position="top"
|
||||
:model="config">
|
||||
:model="config"
|
||||
>
|
||||
<!-- element-loading-custom-class="config-start"
|
||||
v-loading="mainStore.configStartEnable"
|
||||
:element-loading-spinner="'<path />'"
|
||||
@@ -10,24 +11,28 @@
|
||||
<!-- <div> -->
|
||||
<ElFormItem
|
||||
label="服务器"
|
||||
prop="serverUrl">
|
||||
prop="serverUrl"
|
||||
>
|
||||
<template #label>
|
||||
<div class="flex items-center gap-[0_5px]">
|
||||
<div>服务器</div>
|
||||
<span>-</span>
|
||||
<ElTag
|
||||
effect="dark"
|
||||
:type="data.isSuccessGetIp ? 'success' : 'info'">
|
||||
:type="data.isSuccessGetIp ? 'success' : 'info'"
|
||||
>
|
||||
{{ data.isSuccessGetIp ? "联机成功" : data.isStart && !data.isSuccessGetIp ? "联机中" : "未联机" }}
|
||||
</ElTag>
|
||||
<ElButton
|
||||
v-if="!data.coreVersion"
|
||||
@click="getCoreVersion(true)">
|
||||
@click="getCoreVersion(true)"
|
||||
>
|
||||
获取内核版本
|
||||
</ElButton>
|
||||
<ElTag
|
||||
v-else
|
||||
type="info">
|
||||
type="info"
|
||||
>
|
||||
{{ data.coreVersion }}
|
||||
</ElTag>
|
||||
<ElPopconfirm
|
||||
@@ -36,13 +41,15 @@
|
||||
confirm-button-text="继续"
|
||||
title="内核从github下载,需要出国工具,可能下载缓慢或失败,是否继续?
|
||||
也可以从官方群里手动下载后解压到easytier-game.exe同级目录下的easytier目录里,全部覆盖即可"
|
||||
@confirm="handleUpdateCore">
|
||||
@confirm="handleUpdateCore"
|
||||
>
|
||||
<template #reference>
|
||||
<ElButton
|
||||
:disabled="data.isStart"
|
||||
:loading="data.update"
|
||||
type="warning"
|
||||
size="small">
|
||||
size="small"
|
||||
>
|
||||
{{ data.coreVersion ? "更新内核" : "下载内核" }}
|
||||
</ElButton>
|
||||
</template>
|
||||
@@ -55,7 +62,8 @@
|
||||
placeholder="请选择服务器地址"
|
||||
default-first-option
|
||||
v-model="config.serverUrl"
|
||||
@change="handleServerUrlChange">
|
||||
@change="handleServerUrlChange"
|
||||
>
|
||||
<template #prefix>
|
||||
<div :class="config.protocol && config.protocol.length > 1 ? 'w-[120px]' : 'w-[80px]'">
|
||||
<ElSelect
|
||||
@@ -64,12 +72,14 @@
|
||||
collapse-tags
|
||||
@click.stop
|
||||
v-model="config.protocol"
|
||||
@change="handleServerUrlChange">
|
||||
@change="handleServerUrlChange"
|
||||
>
|
||||
<ElOption
|
||||
v-for="item in protocols"
|
||||
:key="item"
|
||||
:label="item"
|
||||
:value="item"></ElOption>
|
||||
:value="item"
|
||||
></ElOption>
|
||||
</ElSelect>
|
||||
</div>
|
||||
</template>
|
||||
@@ -77,7 +87,8 @@
|
||||
v-for="item in mainStore.basePeers"
|
||||
:key="item"
|
||||
:label="item"
|
||||
:value="item">
|
||||
:value="item"
|
||||
>
|
||||
<div class="flex items-center gap-[20px] overflow-hidden flex-nowrap max-w-[calc(100vw-62px)]">
|
||||
<ElTooltip :content="item">
|
||||
<p class="truncate">{{ item }}</p>
|
||||
@@ -87,7 +98,8 @@
|
||||
@click.stop="handleDeleteServerUrl(item)"
|
||||
round
|
||||
:icon="Delete"
|
||||
type="danger"></ElButton>
|
||||
type="danger"
|
||||
></ElButton>
|
||||
</div>
|
||||
</div>
|
||||
</ElOption>
|
||||
@@ -107,7 +119,8 @@
|
||||
<ElInput
|
||||
maxlength="100"
|
||||
placeholder="请输入网络名"
|
||||
v-model="config.networkName"></ElInput>
|
||||
v-model="config.networkName"
|
||||
></ElInput>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
@@ -125,7 +138,8 @@
|
||||
maxlength="100"
|
||||
placeholder="请输入网络密码"
|
||||
v-model="config.networkPassword"
|
||||
type="password"></ElInput>
|
||||
type="password"
|
||||
></ElInput>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
</div>
|
||||
@@ -142,11 +156,13 @@
|
||||
<ElInput
|
||||
maxlength="100"
|
||||
placeholder="例如: Player1"
|
||||
v-model="config.hostname"></ElInput>
|
||||
v-model="config.hostname"
|
||||
></ElInput>
|
||||
</ElFormItem>
|
||||
<ElFormItem
|
||||
class="w-[70%]"
|
||||
label="局域网IP">
|
||||
label="局域网IP"
|
||||
>
|
||||
<template #label>
|
||||
<div class="flex items-center h-[20px]">
|
||||
虚拟网IP
|
||||
@@ -159,14 +175,16 @@
|
||||
inline-prompt
|
||||
inactive-text="固定IP"
|
||||
active-text="动态获取IP"
|
||||
size="small"></ElSwitch>
|
||||
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>
|
||||
v-model="config.ipv4"
|
||||
></ElInput>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<!-- </div> -->
|
||||
@@ -180,24 +198,28 @@
|
||||
size="default"
|
||||
:type="!data.isStart ? 'primary' : 'danger'"
|
||||
:disabled="data.startLoading || !data.coreVersion || data.update"
|
||||
@click="handleConnection">
|
||||
@click="handleConnection"
|
||||
>
|
||||
{{ !data.isStart ? "启动联机" : "停止联机" }}
|
||||
<template #dropdown>
|
||||
<ElDropdownMenu>
|
||||
<ElDropdownItem
|
||||
command="import_config"
|
||||
:icon="Link">
|
||||
:icon="Link"
|
||||
>
|
||||
导入配置
|
||||
</ElDropdownItem>
|
||||
<ElDropdownItem
|
||||
command="share_config"
|
||||
:icon="Share">
|
||||
:icon="Share"
|
||||
>
|
||||
分享配置
|
||||
</ElDropdownItem>
|
||||
<ElDropdownItem
|
||||
:icon="Tools"
|
||||
command="toml"
|
||||
:disabled="data.isStart">
|
||||
:disabled="data.isStart"
|
||||
>
|
||||
使用外部配置文件
|
||||
</ElDropdownItem>
|
||||
</ElDropdownMenu>
|
||||
@@ -207,47 +229,57 @@
|
||||
<div class="mt-[6px] pl-[2px]">
|
||||
<ElTooltip
|
||||
placement="left"
|
||||
content="日志">
|
||||
content="日志"
|
||||
>
|
||||
<ElButton
|
||||
:type="!data.logVisible ? 'info' : 'warning'"
|
||||
@click="handleShowLogDialog"
|
||||
:icon="List"
|
||||
size="small"
|
||||
plain></ElButton>
|
||||
plain
|
||||
></ElButton>
|
||||
</ElTooltip>
|
||||
<ElTooltip
|
||||
placement="left"
|
||||
content="成员">
|
||||
content="成员"
|
||||
>
|
||||
<ElButton
|
||||
@click="handleShowMemberDialog"
|
||||
:icon="UserFilled"
|
||||
plain
|
||||
type="success"
|
||||
size="small"></ElButton>
|
||||
size="small"
|
||||
></ElButton>
|
||||
</ElTooltip>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ml-auto">
|
||||
<ElCheckbox
|
||||
v-model="config.disbleP2p"
|
||||
size="small">
|
||||
size="small"
|
||||
>
|
||||
强制中转
|
||||
</ElCheckbox>
|
||||
<ElCheckbox
|
||||
@change="handleAutoStartByTask"
|
||||
:model-value="config.autoStart"
|
||||
size="small">
|
||||
开机自启
|
||||
</ElCheckbox>
|
||||
<ElTooltip placement="top-start" content="自启后隐藏于托盘,不显示界面">
|
||||
<ElCheckbox
|
||||
@change="handleAutoStartByTask"
|
||||
:model-value="config.autoStart"
|
||||
size="small"
|
||||
>
|
||||
开机自启
|
||||
</ElCheckbox>
|
||||
</ElTooltip>
|
||||
<div>
|
||||
<ElButton
|
||||
@click="handleShowCidrDialog"
|
||||
:icon="Share">
|
||||
:icon="Share"
|
||||
>
|
||||
子网代理
|
||||
</ElButton>
|
||||
<ElButton
|
||||
@click="handleShowAdvanceDialog"
|
||||
:icon="Setting">
|
||||
:icon="Setting"
|
||||
>
|
||||
高级选项
|
||||
</ElButton>
|
||||
</div>
|
||||
@@ -258,7 +290,8 @@
|
||||
type="primary"
|
||||
size="small"
|
||||
:icon="MagicStick"
|
||||
@click="handleShowToolDialog">
|
||||
@click="handleShowToolDialog"
|
||||
>
|
||||
增强工具
|
||||
</ElButton>
|
||||
</div>
|
||||
@@ -266,7 +299,8 @@
|
||||
class="!text-[9px] pb-[2px] ml-[8px] truncate"
|
||||
type="info"
|
||||
:underline="false"
|
||||
@click="open('https://github.com/EasyTier/EasytierGame')">
|
||||
@click="open('https://github.com/EasyTier/EasytierGame')"
|
||||
>
|
||||
EasytierGame主页
|
||||
</ElLink>
|
||||
</div>
|
||||
@@ -281,12 +315,14 @@
|
||||
class="!mb-0"
|
||||
v-model="importConfigData.visible"
|
||||
:close-on-press-escape="false"
|
||||
title="导入分享">
|
||||
title="导入分享"
|
||||
>
|
||||
<ElInput
|
||||
type="textarea"
|
||||
:rows="6"
|
||||
placeholder="请粘贴分享的配置"
|
||||
v-model="importConfigData.data"></ElInput>
|
||||
v-model="importConfigData.data"
|
||||
></ElInput>
|
||||
<template #footer>
|
||||
<div>
|
||||
<el-text type="danger">导入成功后,您当前的部分配置将被替换</el-text>
|
||||
@@ -295,7 +331,8 @@
|
||||
<ElButton
|
||||
size="small"
|
||||
@click="handleStartImport"
|
||||
type="primary">
|
||||
type="primary"
|
||||
>
|
||||
导入
|
||||
</ElButton>
|
||||
</div>
|
||||
@@ -309,7 +346,8 @@
|
||||
class="!mb-0"
|
||||
v-model="configStart.visible"
|
||||
:close-on-press-escape="false"
|
||||
title="配置文件启动">
|
||||
title="配置文件启动"
|
||||
>
|
||||
<div class="flex items-center gap-[0_4px]">
|
||||
<span>启用</span>
|
||||
<ElSwitch v-model="mainStore.configStartEnable"></ElSwitch>
|
||||
@@ -318,14 +356,16 @@
|
||||
</ElTooltip>
|
||||
<ElButton
|
||||
@click="openConfigDir"
|
||||
size="small">
|
||||
size="small"
|
||||
>
|
||||
打开配置目录
|
||||
</ElButton>
|
||||
<ElButton
|
||||
@click="handleStartCommand('toml')"
|
||||
type="primary"
|
||||
:icon="RefreshRight"
|
||||
size="small">
|
||||
size="small"
|
||||
>
|
||||
刷新
|
||||
</ElButton>
|
||||
</div>
|
||||
@@ -333,12 +373,14 @@
|
||||
<ElSelect
|
||||
v-model="mainStore.configPath"
|
||||
no-data-text="目录没有配置文件"
|
||||
placeholder="选择配置文件">
|
||||
placeholder="选择配置文件"
|
||||
>
|
||||
<ElOption
|
||||
v-for="item in configStart.list"
|
||||
:key="item.path"
|
||||
:value="item.path"
|
||||
:label="item.name"></ElOption>
|
||||
:label="item.name"
|
||||
></ElOption>
|
||||
</ElSelect>
|
||||
</div>
|
||||
<template #footer>
|
||||
@@ -346,7 +388,8 @@
|
||||
<ElButton
|
||||
size="small"
|
||||
@click="configStart.visible = false"
|
||||
type="danger">
|
||||
type="danger"
|
||||
>
|
||||
关闭
|
||||
</ElButton>
|
||||
</div>
|
||||
@@ -385,7 +428,7 @@
|
||||
const mainStore = useMainStore();
|
||||
const config = mainStore.config;
|
||||
// console.log(config);
|
||||
const protocols = ["tcp", "udp", "ws", "wss", "wg"];
|
||||
const protocols = ["tcp", "udp", "ws", "wss", "wg", "quic"];
|
||||
const data = reactive({
|
||||
logVisible: false,
|
||||
cidrVisible: false,
|
||||
@@ -402,25 +445,25 @@
|
||||
startLoading: false,
|
||||
isStart: false,
|
||||
connectionSuccess: false,
|
||||
configJsonSeverUrl: "", // 本地保存一次,用于回填config.json
|
||||
configJsonSeverUrl: "" // 本地保存一次,用于回填config.json
|
||||
});
|
||||
|
||||
const configStart = reactive<{ list: Array<{ path: string; name: string }>; [key: string]: any }>({
|
||||
visible: false,
|
||||
loading: false,
|
||||
list: [], //配置文件列表
|
||||
list: [] //配置文件列表
|
||||
});
|
||||
|
||||
const importConfigData = reactive<{ data: ""; [key: string]: any }>({
|
||||
visible: false,
|
||||
loading: false,
|
||||
data: "",
|
||||
data: ""
|
||||
});
|
||||
|
||||
const closePrevent = async () => {
|
||||
const appWindow = getCurrentWindow();
|
||||
if (appWindow.label == "main") {
|
||||
appWindow.onCloseRequested(async (event) => {
|
||||
appWindow.onCloseRequested(async event => {
|
||||
// console.log(appWindow.label);
|
||||
if (!is_close) {
|
||||
// console.log(1);
|
||||
@@ -441,10 +484,24 @@
|
||||
newBasePeers.splice(idx, 1);
|
||||
}
|
||||
mainStore.basePeers = uniq([...newBasePeers]);
|
||||
if (mainStore.basePeers.length > 0) {
|
||||
mainStore.config.serverUrl = mainStore.basePeers[0];
|
||||
}
|
||||
};
|
||||
|
||||
const handleServerUrlChange = () => {
|
||||
mainStore.basePeers = uniq([config.serverUrl, ...mainStore.basePeers]);
|
||||
let inputProtocols: string | null = null;
|
||||
for (const p of protocols) {
|
||||
if (config.serverUrl.toLowerCase().startsWith(`${p}://`)) {
|
||||
inputProtocols = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (inputProtocols) {
|
||||
mainStore.config.protocol = [inputProtocols];
|
||||
mainStore.config.serverUrl = mainStore.config.serverUrl.slice(inputProtocols.length + 3);
|
||||
}
|
||||
mainStore.basePeers = uniq([mainStore.config.serverUrl, ...mainStore.basePeers]);
|
||||
};
|
||||
|
||||
const listenObj: { [key: string]: any } = {
|
||||
@@ -454,7 +511,7 @@
|
||||
thread_id: null,
|
||||
async listenOutput() {
|
||||
// const appWindow = getCurrentWindow();
|
||||
const unListen = await listen("command-output", async (event) => {
|
||||
const unListen = await listen("command-output", async event => {
|
||||
data.isStart = true;
|
||||
// console.log(event.payload);
|
||||
if (event.payload) {
|
||||
@@ -487,7 +544,7 @@
|
||||
"netsh",
|
||||
["interface", "ipv4", "set", "interface", devName, "metric=", `${mainStore.config.netCardMetricValue}`],
|
||||
{
|
||||
encoding: "gb2312",
|
||||
encoding: "gb2312"
|
||||
}
|
||||
).execute();
|
||||
} catch (err) {
|
||||
@@ -504,7 +561,7 @@
|
||||
this.unListenOutPut = unListen;
|
||||
},
|
||||
async listenThreadId() {
|
||||
const unListen = await listen("thread-id", (event) => {
|
||||
const unListen = await listen("thread-id", event => {
|
||||
if (event.payload) {
|
||||
this.thread_id = event.payload;
|
||||
}
|
||||
@@ -512,14 +569,14 @@
|
||||
this.unListenThreadId = unListen;
|
||||
},
|
||||
async listenConfigStart() {
|
||||
const unListen = await listen("config", (event) => {
|
||||
const unListen = await listen("config", event => {
|
||||
// console.log("config", event.payload);
|
||||
const ipv4 = config.ipv4;
|
||||
mainStore.$patch(event.payload as any);
|
||||
config.ipv4 = ipv4;
|
||||
});
|
||||
this.unListenConfigStart = unListen;
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
const unListenAll = async () => {
|
||||
@@ -679,8 +736,8 @@
|
||||
config: {
|
||||
...guiJson,
|
||||
...mainStore.config,
|
||||
serverUrl: saveServerUrl,
|
||||
},
|
||||
serverUrl: saveServerUrl
|
||||
}
|
||||
});
|
||||
if (mainStore.createConfigInEasytier) {
|
||||
await updateConfigJson(data.configJsonSeverUrl);
|
||||
@@ -751,7 +808,7 @@
|
||||
}
|
||||
if (config.serverUrl) {
|
||||
const formatUrl = config.serverUrl.replace(/\\/g, "/");
|
||||
args.push("--peers", ...config.protocol.map((protocol) => `${protocol}://${formatUrl}`));
|
||||
args.push("--peers", ...config.protocol.map(protocol => `${protocol}://${formatUrl}`));
|
||||
}
|
||||
if (config.disbleP2p) {
|
||||
args.push("--disable-p2p");
|
||||
@@ -767,8 +824,8 @@
|
||||
const reg = /\d+\.\d+\.\d+\.\d+\/\d+/g;
|
||||
const formatProxyNetworks = config.proxyNetworks
|
||||
.split("\n")
|
||||
.map((item) => item.trim())
|
||||
.filter((item) => item && reg.test(item));
|
||||
.map(item => item.trim())
|
||||
.filter(item => item && reg.test(item));
|
||||
args.push("--proxy-networks", ...formatProxyNetworks);
|
||||
config.proxyNetworks = formatProxyNetworks.join("\n");
|
||||
}
|
||||
@@ -812,7 +869,7 @@
|
||||
config.ipv4 = "";
|
||||
}
|
||||
const memberDialog = await getAllWebviewWindows();
|
||||
const memberDialogs = memberDialog.filter((item) => item.label === "member");
|
||||
const memberDialogs = memberDialog.filter(item => item.label === "member");
|
||||
if (memberDialogs && memberDialogs.length > 0) {
|
||||
data.memberVisible = false;
|
||||
for (const memberDialog of memberDialogs) {
|
||||
@@ -838,7 +895,7 @@
|
||||
if (args[0] === "-c") {
|
||||
ElMessage.warning({
|
||||
message: "使用配置文件中.",
|
||||
duration: 5000,
|
||||
duration: 5000
|
||||
});
|
||||
}
|
||||
data.log = ""; //清空日志
|
||||
@@ -847,7 +904,7 @@
|
||||
await listenObj.listenOutput();
|
||||
|
||||
await invoke("run_command", {
|
||||
args,
|
||||
args
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -861,10 +918,10 @@
|
||||
if (isExists) {
|
||||
const entries = await readDir(path, { baseDir: BaseDirectory.Resource });
|
||||
configStart.list = entries
|
||||
.filter((item) => item.isFile)
|
||||
.map((item) => ({
|
||||
.filter(item => item.isFile)
|
||||
.map(item => ({
|
||||
name: item.name,
|
||||
path: `${path}${item.name}`,
|
||||
path: `${path}${item.name}`
|
||||
})) as any;
|
||||
} else {
|
||||
mainStore.configStartEnable = false;
|
||||
@@ -907,14 +964,14 @@
|
||||
try {
|
||||
await ElMessageBox.confirm("确定导入?", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
cancelButtonText: "取消"
|
||||
});
|
||||
const payload = JSON.parse(decodeURIComponent(atob(importConfigData.data)));
|
||||
mainStore.$patch({
|
||||
config: {
|
||||
...mainStore.config,
|
||||
...payload.config,
|
||||
},
|
||||
...payload.config
|
||||
}
|
||||
});
|
||||
ElMessage.success("导入成功");
|
||||
importConfigData.visible = false;
|
||||
@@ -958,9 +1015,9 @@
|
||||
"member",
|
||||
{
|
||||
title: "成员列表",
|
||||
width: 470,
|
||||
width: 875,
|
||||
height: 380,
|
||||
url: "#/member",
|
||||
url: "#/member"
|
||||
},
|
||||
() => {
|
||||
data.memberVisible = true;
|
||||
@@ -979,7 +1036,7 @@
|
||||
width: 600,
|
||||
height: 380,
|
||||
resizable: false,
|
||||
url: "#/log",
|
||||
url: "#/log"
|
||||
},
|
||||
(_, appWindow) => {
|
||||
data.logVisible = true;
|
||||
@@ -1002,7 +1059,7 @@
|
||||
width: 600,
|
||||
height: 380,
|
||||
resizable: false,
|
||||
url: "#/cidr",
|
||||
url: "#/cidr"
|
||||
},
|
||||
(_, appWindow) => {
|
||||
data.cidrVisible = true;
|
||||
@@ -1021,7 +1078,7 @@
|
||||
width: 600,
|
||||
height: 380,
|
||||
resizable: false,
|
||||
url: "#/advance",
|
||||
url: "#/advance"
|
||||
},
|
||||
(_, appWindow) => {
|
||||
data.advanceVisible = true;
|
||||
@@ -1040,7 +1097,7 @@
|
||||
width: 460,
|
||||
height: 480,
|
||||
resizable: true,
|
||||
url: "#/tool",
|
||||
url: "#/tool"
|
||||
},
|
||||
(_, appWindow) => {
|
||||
data.toolVisible = true;
|
||||
|
||||
+76
-20
@@ -6,26 +6,66 @@
|
||||
stripe
|
||||
border
|
||||
:data="data.member"
|
||||
v-else>
|
||||
v-else
|
||||
>
|
||||
<ElTableColumn
|
||||
v-for="prop in showTableHeader"
|
||||
sortable
|
||||
:prop="prop[0]"
|
||||
:label="prop[1]"
|
||||
:key="prop[0]">
|
||||
width="140"
|
||||
label="主机名"
|
||||
prop="hostname"
|
||||
></ElTableColumn>
|
||||
<ElTableColumn
|
||||
sortable
|
||||
width="90"
|
||||
prop="cost"
|
||||
label="路由"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span v-if="prop[0] == 'loss_rate'">
|
||||
{{ row[prop[0]] && row[prop[0]] != "-" ? Number(row[prop[0]] * 100).toFixed(2) + "%" : row[prop[0]] }}
|
||||
</span>
|
||||
<span v-else-if="prop[0] != 'cost'">{{ row[prop[0]] }}</span>
|
||||
<ElTag
|
||||
v-else
|
||||
effect="dark"
|
||||
:type="row[prop[0]] == 'p2p' ? 'success' : 'info'">
|
||||
{{ row[prop[0]] }}
|
||||
:type="row.cost == 'p2p' ? 'success' : 'info'"
|
||||
>
|
||||
{{ row.cost }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
sortable
|
||||
width="120"
|
||||
prop="ipv4"
|
||||
label="虚拟网IP"
|
||||
></ElTableColumn>
|
||||
<ElTableColumn
|
||||
sortable
|
||||
prop="lat_ms"
|
||||
width="130"
|
||||
label="延迟/ms"
|
||||
></ElTableColumn>
|
||||
<ElTableColumn
|
||||
sortable
|
||||
width="120"
|
||||
prop="loss_rate"
|
||||
label="丢包率"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ row.loss_rate && row.loss_rate != "-" ? Number(row.loss_rate * 100).toFixed(2) + "%" : row.loss_rate }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
sortable
|
||||
width="120"
|
||||
label="nat_type"
|
||||
prop="NAT类型"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ natMaps[row.nat_type.toLowerCase() as natKyes] || row.nat_type || "-" }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
sortable
|
||||
prop="version"
|
||||
label="版本"
|
||||
></ElTableColumn>
|
||||
</ElTable>
|
||||
</div>
|
||||
</div>
|
||||
@@ -34,24 +74,40 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { reactive, onMounted, onBeforeUnmount } from "vue";
|
||||
import { parsePeerInfo } from "@/utils";
|
||||
|
||||
const natMaps = {
|
||||
unknown: "未知",
|
||||
nopat: "nat0",
|
||||
fullcone: "nat1",
|
||||
restricted: "nat2",
|
||||
addressrestricted: "nat2",
|
||||
portrestricted: "nat3",
|
||||
symmetric: "nat4"
|
||||
};
|
||||
type natKyes = keyof typeof natMaps;
|
||||
// NAT1: Full Cone NAT,全锥形NAT,这是最宽松的网络环境,你想做什么,基本没啥限制IP和端口都不受限。
|
||||
// NAT2: Address-Restricted Cone NAT,受限锥型NAT,相比NAT1,NAT2 增加了地址限制,也就是IP受限,而端口不受限。
|
||||
// NAT3: Port-Restricted Cone NAT,端口受限锥型,相比NAT2,NAT3 又增加了端口限制,也就是说IP、端口都受限。
|
||||
// NAT4: Symmetric NAT,对称型NAT,对称型NAT具有端口受限锥型的受限特性,内部地址每一次请求一个特定的外部地址,
|
||||
// 都可能会绑定到一个新的端口号。也就是请求不同的外部地址映射的端口号是可能不同的。这种类型基本上就告别 P2P 了。
|
||||
const data = reactive<{ member: any[] }>({
|
||||
member: [],
|
||||
member: []
|
||||
});
|
||||
|
||||
const showTableHeader = [
|
||||
const _showTableHeader = [
|
||||
["hostname", "主机名"],
|
||||
["lat_ms", "延迟/ms"],
|
||||
["ipv4", "虚拟网IP"],
|
||||
["cost", "路由"],
|
||||
["ipv4", "虚拟网IP"],
|
||||
["lat_ms", "延迟/ms"],
|
||||
["loss_rate", "丢包率"],
|
||||
["nat_type", "NAT类型"],
|
||||
["version", "版本"],
|
||||
["version", "版本"]
|
||||
];
|
||||
|
||||
const listenOutput = async () => {
|
||||
const member = await invoke("get_members_by_cli");
|
||||
const peerInfo = parsePeerInfo(member as string);
|
||||
peerInfo.forEach((value) => {
|
||||
const member = await invoke<string>("get_members_by_cli");
|
||||
const peerInfo = parsePeerInfo(member);
|
||||
peerInfo.forEach(value => {
|
||||
if (value.cost === "Local") {
|
||||
value.cost = "本机";
|
||||
}
|
||||
|
||||
Generated
+11
@@ -7,6 +7,10 @@ settings:
|
||||
importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
'@tauri-apps/plugin-window-state':
|
||||
specifier: ~2
|
||||
version: 2.0.0
|
||||
devDependencies:
|
||||
'@element-plus/icons-vue':
|
||||
specifier: ^2.3.1
|
||||
@@ -1047,6 +1051,9 @@ packages:
|
||||
'@tauri-apps/plugin-shell@2.0.1':
|
||||
resolution: {integrity: sha512-akU1b77sw3qHiynrK0s930y8zKmcdrSD60htjH+mFZqv5WaakZA/XxHR3/sF1nNv9Mgmt/Shls37HwnOr00aSw==}
|
||||
|
||||
'@tauri-apps/plugin-window-state@2.0.0':
|
||||
resolution: {integrity: sha512-O82iRlrh1BLgBI8CTc+NMTPxQhQo8II5admKq9mLvH45Us5i4Zcr74At6eM46nOflFd7R8bZsVNGy+PxOEqUmQ==}
|
||||
|
||||
'@trysound/sax@0.2.0':
|
||||
resolution: {integrity: sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==}
|
||||
engines: {node: '>=10.13.0'}
|
||||
@@ -4759,6 +4766,10 @@ snapshots:
|
||||
dependencies:
|
||||
'@tauri-apps/api': 2.1.1
|
||||
|
||||
'@tauri-apps/plugin-window-state@2.0.0':
|
||||
dependencies:
|
||||
'@tauri-apps/api': 2.1.1
|
||||
|
||||
'@trysound/sax@0.2.0': {}
|
||||
|
||||
'@types/estree@1.0.6': {}
|
||||
|
||||
Generated
+17
-1
@@ -1176,7 +1176,7 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
|
||||
|
||||
[[package]]
|
||||
name = "easytier-game"
|
||||
version = "1.2.0"
|
||||
version = "1.2.1"
|
||||
dependencies = [
|
||||
"log",
|
||||
"planif",
|
||||
@@ -1192,6 +1192,7 @@ dependencies = [
|
||||
"tauri-plugin-log",
|
||||
"tauri-plugin-shell",
|
||||
"tauri-plugin-single-instance",
|
||||
"tauri-plugin-window-state",
|
||||
"whoami",
|
||||
"windows 0.58.0",
|
||||
"zip",
|
||||
@@ -4543,6 +4544,21 @@ dependencies = [
|
||||
"zbus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-window-state"
|
||||
version = "2.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "683c8764751fbbcebf3a594bcee24cf84c62773fa0080d1b40fc80698472421e"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tauri",
|
||||
"tauri-plugin",
|
||||
"thiserror 1.0.64",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-runtime"
|
||||
version = "2.2.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "easytier-game"
|
||||
version = "1.2.0"
|
||||
version = "1.2.1"
|
||||
homepage = "https://github.com/EasyTier/EasyTier"
|
||||
repository = "https://github.com/EasyTier/EasytierGame"
|
||||
description = "A simple network initiator based on Easytier"
|
||||
@@ -50,3 +50,4 @@ features = ["Win32_System_TaskScheduler"]
|
||||
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
|
||||
tauri-plugin-autostart = "2.0.1"
|
||||
tauri-plugin-single-instance = "2.0.1"
|
||||
tauri-plugin-window-state = "2"
|
||||
|
||||
@@ -88,6 +88,8 @@
|
||||
"fs:allow-resource-write-recursive",
|
||||
"clipboard-manager:allow-clear",
|
||||
"clipboard-manager:allow-read-text",
|
||||
"clipboard-manager:allow-write-text"
|
||||
"clipboard-manager:allow-write-text",
|
||||
|
||||
"window-state:default"
|
||||
]
|
||||
}
|
||||
+14
-8
@@ -518,12 +518,17 @@ fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
// 获取命令行参数
|
||||
let _args: Vec<String> = std::env::args().collect();
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
|
||||
let stop_signal = Arc::new(AtomicBool::new(false)); // 创建一个原子布尔值,用于控制命令的停止
|
||||
let stop_signal_clone = Arc::clone(&stop_signal); // 创建一个原子布尔值的克隆,用于传递给命令
|
||||
let context = tauri::generate_context!();
|
||||
tauri::Builder::default()
|
||||
.plugin(
|
||||
tauri_plugin_window_state::Builder::new()
|
||||
.with_state_flags(tauri_plugin_window_state::StateFlags::SIZE)
|
||||
.build(),
|
||||
)
|
||||
.plugin(tauri_plugin_clipboard_manager::init())
|
||||
.plugin(tauri_plugin_fs::init())
|
||||
.plugin(tauri_plugin_autostart::init(
|
||||
@@ -539,7 +544,7 @@ pub fn run() {
|
||||
.expect("failed to set focus");
|
||||
}))
|
||||
.setup(move |app| {
|
||||
// let args = args.clone();
|
||||
let args = args.clone();
|
||||
if cfg!(debug_assertions) {
|
||||
app.handle().plugin(
|
||||
tauri_plugin_log::Builder::default()
|
||||
@@ -566,12 +571,13 @@ pub fn run() {
|
||||
))?)
|
||||
.icon_as_template(false)
|
||||
.build(app)?;
|
||||
// 开机自启隐藏到托盘
|
||||
// if args.contains(&String::from(TASKAUTOSTART_ARG)) {
|
||||
// app.get_webview_window("main")
|
||||
// .expect("no main window to hide")
|
||||
// .hide()?;
|
||||
// }
|
||||
|
||||
// 开机自启隐藏到托盘或者显示主窗口
|
||||
if !args.contains(&String::from(TASKAUTOSTART_ARG)) {
|
||||
let main_window = app.get_webview_window("main").unwrap();
|
||||
main_window.show().expect("failed to show window");
|
||||
main_window.set_focus().expect("failed to set focus");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "easytier-game",
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.1",
|
||||
"identifier": "com.tauri.easytier-game",
|
||||
|
||||
"build": {
|
||||
@@ -13,7 +13,9 @@
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "easytier-game 1.2.0",
|
||||
"title": "easytier-game 1.2.1",
|
||||
"label": "main",
|
||||
"url": "#/",
|
||||
"minWidth": 340,
|
||||
"width": 340,
|
||||
"height": 305,
|
||||
@@ -24,6 +26,7 @@
|
||||
"fullscreen": false,
|
||||
"decorations": true,
|
||||
"center": true,
|
||||
"visible": false,
|
||||
"maximizable": false,
|
||||
"transparent": false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user