mirror of
https://github.com/EasyTier/EasytierGame.git
synced 2025-05-19 10:27:56 +00:00
增加日志窗口,增加成员弹窗,优化按钮和布局,增加仓库地址,增加license,优化退出代码,退出时停止子进程,屏蔽右键菜单
This commit is contained in:
@@ -10,3 +10,7 @@ dist
|
||||
.idea
|
||||
.vscode
|
||||
release
|
||||
src-tauri/easytier-cli.exe
|
||||
src-tauri/easytier-core.exe
|
||||
src-tauri/Packet.dll
|
||||
src-tauri/wintun.dll
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
||||
|
||||
Copyright 2023 sunsijie
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,8 @@
|
||||
// const infoDialog = new WebviewWindow("log", {
|
||||
// title: "日志",
|
||||
// resizable: false,
|
||||
// width: 600,
|
||||
// height: 400,
|
||||
// parent: appWindow,
|
||||
// url: "/log"
|
||||
// });
|
||||
+41
-35
@@ -15,7 +15,7 @@ async function toggleVisibility() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function useTray(init: boolean = false) {
|
||||
export async function useTray(init: boolean = false, beforExit) {
|
||||
let tray
|
||||
try {
|
||||
tray = await TrayIcon.getById(DEFAULT_TRAY_NAME)
|
||||
@@ -26,9 +26,9 @@ export async function useTray(init: boolean = false) {
|
||||
id: DEFAULT_TRAY_NAME,
|
||||
menu: await Menu.new({
|
||||
id: 'main',
|
||||
items: await generateMenuItem(),
|
||||
items: await generateMenuItem(beforExit),
|
||||
}),
|
||||
action: async () => {
|
||||
action: async (e) => {
|
||||
toggleVisibility()
|
||||
},
|
||||
})
|
||||
@@ -44,25 +44,31 @@ export async function useTray(init: boolean = false) {
|
||||
tray.setMenuOnLeftClick(false)
|
||||
tray.setMenu(await Menu.new({
|
||||
id: 'main',
|
||||
items: await generateMenuItem(),
|
||||
items: await generateMenuItem(beforExit),
|
||||
}))
|
||||
}
|
||||
|
||||
return tray
|
||||
}
|
||||
|
||||
export async function generateMenuItem() {
|
||||
export async function generateMenuItem(beforExit: Function) {
|
||||
return [
|
||||
await MenuItemExit('Exit'),
|
||||
await MenuItemExit('退出', beforExit),
|
||||
await PredefinedMenuItem.new({ item: 'Separator' }),
|
||||
await MenuItemShow('Show / Hide'),
|
||||
await MenuItemShow('显示 / 隐藏'),
|
||||
]
|
||||
}
|
||||
|
||||
export async function MenuItemExit(text: string) {
|
||||
return await PredefinedMenuItem.new({
|
||||
export async function MenuItemExit(text: string, beforExit: Function) {
|
||||
return await MenuItem.new({
|
||||
id: "quit",
|
||||
text,
|
||||
item: 'Quit',
|
||||
action: async () => {
|
||||
if (beforExit) {
|
||||
await beforExit();
|
||||
}
|
||||
await getCurrentWindow().close();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -76,30 +82,30 @@ export async function MenuItemShow(text: string) {
|
||||
})
|
||||
}
|
||||
|
||||
export async function setTrayMenu(items: (MenuItem | PredefinedMenuItem)[] | undefined = undefined) {
|
||||
const tray = await useTray()
|
||||
if (!tray)
|
||||
return
|
||||
const menu = await Menu.new({
|
||||
id: 'main',
|
||||
items: items || await generateMenuItem(),
|
||||
})
|
||||
tray.setMenu(menu)
|
||||
}
|
||||
// export async function setTrayMenu(items: (MenuItem | PredefinedMenuItem)[] | undefined = undefined) {
|
||||
// const tray = await useTray()
|
||||
// if (!tray)
|
||||
// return
|
||||
// const menu = await Menu.new({
|
||||
// id: 'main',
|
||||
// items: items || await generateMenuItem(),
|
||||
// })
|
||||
// tray.setMenu(menu)
|
||||
// }
|
||||
|
||||
export async function setTrayRunState(isRunning: boolean = false) {
|
||||
const tray = await useTray()
|
||||
if (!tray)
|
||||
return
|
||||
tray.setIcon(isRunning ? 'icons/icon-inactive.ico' : 'icons/icon.ico')
|
||||
}
|
||||
// export async function setTrayRunState(isRunning: boolean = false) {
|
||||
// const tray = await useTray()
|
||||
// if (!tray)
|
||||
// return
|
||||
// tray.setIcon(isRunning ? 'icons/icon-inactive.ico' : 'icons/icon.ico')
|
||||
// }
|
||||
|
||||
export async function setTrayTooltip(tooltip: string) {
|
||||
if (tooltip) {
|
||||
const tray = await useTray()
|
||||
if (!tray)
|
||||
return
|
||||
tray.setTooltip(`EasyTier\n${pkg.version}\n${tooltip}`)
|
||||
tray.setTitle(`EasyTier\n${pkg.version}\n${tooltip}`)
|
||||
}
|
||||
}
|
||||
// export async function setTrayTooltip(tooltip: string) {
|
||||
// if (tooltip) {
|
||||
// const tray = await useTray()
|
||||
// if (!tray)
|
||||
// return
|
||||
// tray.setTooltip(`EasyTier\n${pkg.version}\n${tooltip}`)
|
||||
// tray.setTitle(`EasyTier\n${pkg.version}\n${tooltip}`)
|
||||
// }
|
||||
// }
|
||||
+3
-18
@@ -3,23 +3,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="tsx">
|
||||
import { onBeforeUnmount } from "vue";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
|
||||
const appWindow = getCurrentWindow();
|
||||
|
||||
const unlisten = listen("window-close-event", (event) => {
|
||||
closeApp();
|
||||
//屏蔽右键菜单
|
||||
document.addEventListener("contextmenu", (e: MouseEvent) => {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
unlisten.then((unlisten) => {
|
||||
unlisten && unlisten instanceof Function && unlisten();
|
||||
});
|
||||
});
|
||||
|
||||
const closeApp = async () => {
|
||||
appWindow.hide();
|
||||
};
|
||||
</script>
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "easytier-game",
|
||||
"private": true,
|
||||
"author": "luoleixin@digisky.com",
|
||||
"author": "leizi97",
|
||||
"description": "A simple network initiator based on Easytier",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.4",
|
||||
"scripts": {
|
||||
"dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0",
|
||||
"build": "nuxt generate --dotenv env/.env.prod"
|
||||
|
||||
+201
-67
@@ -2,37 +2,43 @@
|
||||
<ElForm
|
||||
size="small"
|
||||
label-position="top"
|
||||
:model="config">
|
||||
:model="config"
|
||||
>
|
||||
<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 ? "联机成功" : "联机中" }}
|
||||
</ElTag>
|
||||
<ElButton
|
||||
v-if="!data.coreVersion"
|
||||
@click="getCoreVersion(true)"
|
||||
>获取工具版本</ElButton
|
||||
>
|
||||
获取工具版本
|
||||
</ElButton>
|
||||
<ElTag
|
||||
v-else
|
||||
type="info"
|
||||
>{{ data.coreVersion }}</ElTag
|
||||
>
|
||||
core-{{ data.coreVersion }}
|
||||
</ElTag>
|
||||
<ElButton
|
||||
:disabled="data.isStart"
|
||||
:loading="data.update"
|
||||
type="warning"
|
||||
@click="handleUpdateCore"
|
||||
size="small"
|
||||
>{{ data.coreVersion ? "更新" : "下载" }}</ElButton
|
||||
>
|
||||
{{ data.coreVersion ? "更新" : "下载" }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
<ElSelect
|
||||
@@ -40,7 +46,8 @@
|
||||
filterable
|
||||
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
|
||||
@@ -48,12 +55,14 @@
|
||||
multiple
|
||||
collapse-tags
|
||||
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>
|
||||
@@ -61,15 +70,18 @@
|
||||
v-for="item in mainStore.basePeers"
|
||||
:key="item"
|
||||
:label="item"
|
||||
:value="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>
|
||||
type="danger"
|
||||
></ElButton>
|
||||
</div>
|
||||
</ElOption>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<div class="flex flex-wrap gap-[0_10px] items-center">
|
||||
@@ -86,7 +98,8 @@
|
||||
<ElInput
|
||||
maxlength="100"
|
||||
placeholder="请输入网络名"
|
||||
v-model="config.networkName"></ElInput>
|
||||
v-model="config.networkName"
|
||||
></ElInput>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
@@ -104,7 +117,8 @@
|
||||
maxlength="100"
|
||||
placeholder="请输入网络密码"
|
||||
v-model="config.networkPassword"
|
||||
type="password"></ElInput>
|
||||
type="password"
|
||||
></ElInput>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
</div>
|
||||
@@ -121,11 +135,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
|
||||
@@ -138,57 +154,82 @@
|
||||
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 ? '等待动态分配IP...' : '例如: 10.126.126.1'"
|
||||
v-model="config.ipv4"></ElInput>
|
||||
v-model="config.ipv4"
|
||||
></ElInput>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<div class="flex items-start gap-[0_30px]">
|
||||
<div>
|
||||
<div class="w-[95px]">
|
||||
<div>
|
||||
<ElButton
|
||||
:type="!data.isStart ? 'primary' : 'danger'"
|
||||
:disabled="data.startLoading || !data.coreVersion || data.update"
|
||||
@click="handleConnection"
|
||||
size="default">
|
||||
{{ !data.isStart ? "开始联机" : "停止联机" }}
|
||||
size="default"
|
||||
>
|
||||
{{ !data.isStart ? "启动联机" : "停止联机" }}
|
||||
</ElButton>
|
||||
</div>
|
||||
<div class="mt-[6px]">
|
||||
<ElTooltip
|
||||
placement="right"
|
||||
:content="data.logVisible ? '关闭日志' : '打开日志'"
|
||||
>
|
||||
<ElButton
|
||||
type="info"
|
||||
@click="handleShowDialog"
|
||||
size="default">
|
||||
日志信息
|
||||
</ElButton>
|
||||
:type="!data.logVisible ? 'info' : 'warning'"
|
||||
@click="handleShowLogDialog"
|
||||
:icon="List"
|
||||
size="small"
|
||||
plain
|
||||
></ElButton>
|
||||
</ElTooltip>
|
||||
<ElTooltip
|
||||
placement="left"
|
||||
content="成员信息"
|
||||
>
|
||||
<ElButton
|
||||
@click="handleShowMemberDialog"
|
||||
:icon="UserFilled"
|
||||
plain
|
||||
type="success"
|
||||
size="small"
|
||||
></ElButton>
|
||||
</ElTooltip>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<ElCheckbox
|
||||
v-model="config.disbleP2p"
|
||||
size="small">
|
||||
size="small"
|
||||
>
|
||||
禁用p2p
|
||||
</ElCheckbox>
|
||||
<ElCheckbox
|
||||
v-model="config.disableIpv6"
|
||||
size="small">
|
||||
size="small"
|
||||
>
|
||||
禁用ipv6
|
||||
</ElCheckbox>
|
||||
<ElCheckbox
|
||||
v-model="config.disbleListenner"
|
||||
size="small">
|
||||
size="small"
|
||||
>
|
||||
禁用端口监听
|
||||
</ElCheckbox>
|
||||
<ElLink
|
||||
class="!text-[11px] pb-[2px] ml-[15px]"
|
||||
type="info"
|
||||
:underline="false"
|
||||
@click="open('https://github.com/EasyTier/EasyTier/releases')">
|
||||
@click="open('https://github.com/EasyTier/EasyTier/releases')"
|
||||
>
|
||||
easytier发布页
|
||||
</ElLink>
|
||||
<div>
|
||||
@@ -196,52 +237,62 @@
|
||||
class="!text-[11px]"
|
||||
type="danger"
|
||||
:underline="false"
|
||||
@click="open('https://github.com/dechamps/WinIPBroadcast/releases/tag/winipbroadcast-1.6')">
|
||||
找不到房间?建议安装WinIPBroadcast
|
||||
@click="open('https://github.com/dechamps/WinIPBroadcast/releases/tag/winipbroadcast-1.6')"
|
||||
>
|
||||
找不到房间?安装WinIPBroadcast
|
||||
</ElLink>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ElForm>
|
||||
<ElDialog
|
||||
title="日志信息"
|
||||
top="0"
|
||||
v-model="data.visible"
|
||||
width="100%"
|
||||
class="!h-full !m-0">
|
||||
<ElInput
|
||||
type="textarea"
|
||||
rows="10"
|
||||
v-model="data.log"
|
||||
resize="none"
|
||||
readonly />
|
||||
</ElDialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import { open } from "@tauri-apps/plugin-shell";
|
||||
import { QuestionFilled, Delete } from "@element-plus/icons-vue";
|
||||
import { QuestionFilled, Delete, List, UserFilled } from "@element-plus/icons-vue";
|
||||
import { reactive, onBeforeUnmount, onMounted } from "vue";
|
||||
import { useTray } from "~/composables/tray";
|
||||
import useMainStore from "@/stores/index";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { getCurrentWindow, LogicalPosition } from "@tauri-apps/api/window";
|
||||
import { WebviewWindow, getAllWebviewWindows } from "@tauri-apps/api/webviewWindow";
|
||||
|
||||
let is_close = false;
|
||||
|
||||
useTray(true, async () => {
|
||||
is_close = true;
|
||||
await invoke("stop_command", { child_id: listenObj.thread_id || 0 });
|
||||
});
|
||||
|
||||
useTray(true);
|
||||
const mainStore = useMainStore();
|
||||
const config = mainStore.config;
|
||||
const protocols = ["tcp", "udp", "ws", "wss", "wg"];
|
||||
const data = reactive({
|
||||
visible: false,
|
||||
logVisible: false,
|
||||
memberVisible: false,
|
||||
log: "",
|
||||
update: false,
|
||||
releaseList: [],
|
||||
coreVersion: "",
|
||||
isSuccessGetIp: false,
|
||||
startLoading: false,
|
||||
isStart: false,
|
||||
isStart: false
|
||||
});
|
||||
|
||||
const closePrevent = async () => {
|
||||
const appWindow = getCurrentWindow();
|
||||
if (appWindow.label == "main") {
|
||||
appWindow.onCloseRequested(async event => {
|
||||
console.log(appWindow.label);
|
||||
if (!is_close) {
|
||||
event.preventDefault();
|
||||
appWindow.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteServerUrl = (url: string) => {
|
||||
const newBasePeers = [...mainStore.basePeers];
|
||||
const idx = newBasePeers.indexOf(url);
|
||||
@@ -261,10 +312,10 @@
|
||||
const listenObj: { [key: string]: any } = {
|
||||
unListenOutPut: null,
|
||||
unListenThreadId: null,
|
||||
unListenReleaseList: null,
|
||||
thread_id: null,
|
||||
async listenOutput() {
|
||||
const unListen = await listen("command-output", (event) => {
|
||||
const appWindow = getCurrentWindow();
|
||||
const unListen = await listen("command-output", event => {
|
||||
data.isStart = true;
|
||||
if (event.payload) {
|
||||
data.startLoading = false;
|
||||
@@ -274,27 +325,19 @@
|
||||
config.ipv4 = ipv4;
|
||||
}
|
||||
}
|
||||
appWindow.emitTo("log", "logs", data.log);
|
||||
data.log += (event.payload as string) + "\n";
|
||||
});
|
||||
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;
|
||||
}
|
||||
});
|
||||
this.unListenThreadId = unListen;
|
||||
},
|
||||
|
||||
async releaseListListener() {
|
||||
const unListen = await listen("release-list", (event) => {
|
||||
if (event.payload) {
|
||||
console.log(event.payload);
|
||||
}
|
||||
});
|
||||
this.unListenReleaseList = unListen;
|
||||
},
|
||||
};
|
||||
|
||||
const unListenAll = async () => {
|
||||
@@ -330,12 +373,13 @@
|
||||
ElMessage.error(`获取版本失败`);
|
||||
return [false, null, null];
|
||||
}
|
||||
} else {
|
||||
ElMessage.error(`获取版本失败`);
|
||||
}
|
||||
return [false, null, null];
|
||||
};
|
||||
|
||||
const handleUpdateCore = async () => {
|
||||
// easytier-windows-x86_64-v2.0.3.zip
|
||||
data.update = true;
|
||||
await getCoreVersion();
|
||||
const [isNeedUpdate, downloadUrl, latestVersionFileName] = await checkUpdate();
|
||||
@@ -356,8 +400,8 @@
|
||||
onMounted(async () => {
|
||||
// await handleUpdateCore(); //默认不自动更新
|
||||
await getCoreVersion();
|
||||
await listenObj.releaseListListener();
|
||||
await listenObj.listenThreadId();
|
||||
closePrevent();
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
@@ -384,7 +428,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");
|
||||
@@ -402,6 +446,18 @@
|
||||
data.isStart = false;
|
||||
data.isSuccessGetIp = false;
|
||||
config.ipv4 = "";
|
||||
const memberDialog = await getAllWebviewWindows();
|
||||
const memberDialogs = memberDialog.filter(item => item.label === "member");
|
||||
if (memberDialogs && memberDialogs.length > 0) {
|
||||
data.memberVisible = false;
|
||||
for (const memberDialog of memberDialogs) {
|
||||
const isVisible = await memberDialog.isVisible();
|
||||
if (isVisible) {
|
||||
await memberDialog.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await unListenAll();
|
||||
};
|
||||
|
||||
@@ -414,12 +470,90 @@
|
||||
await listenObj.listenOutput();
|
||||
const args = getArgs();
|
||||
await invoke("run_command", {
|
||||
args,
|
||||
args
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleShowDialog = async () => {
|
||||
data.visible = true;
|
||||
const handleShowMemberDialog = async () => {
|
||||
try {
|
||||
if (!data.isStart) {
|
||||
return ElMessage.warning("请先开始联机");
|
||||
}
|
||||
if (!mainStore.config.ipv4) {
|
||||
return ElMessage.warning("请等待获取IP");
|
||||
}
|
||||
const appWindow = getCurrentWindow();
|
||||
const appSize = await appWindow.innerSize();
|
||||
const appPosition = await appWindow.outerPosition();
|
||||
if (appWindow) {
|
||||
const memberDialog = new WebviewWindow("member", {
|
||||
title: "成员列表",
|
||||
width: 470,
|
||||
height: 380,
|
||||
parent: appWindow,
|
||||
closable: true,
|
||||
resizable: true,
|
||||
decorations: true,
|
||||
maximizable: false,
|
||||
minimizable: false,
|
||||
x: appPosition.x + appSize.width + 10,
|
||||
y: appPosition.y,
|
||||
url: "#/member"
|
||||
});
|
||||
if (!data.memberVisible) {
|
||||
data.memberVisible = true;
|
||||
memberDialog.onCloseRequested(() => {
|
||||
data.logVisible = false;
|
||||
})
|
||||
const appWindow = getCurrentWindow();
|
||||
appWindow.emitTo("log", "logs", data.log);
|
||||
} else {
|
||||
data.memberVisible = false;
|
||||
memberDialog.destroy();
|
||||
}
|
||||
|
||||
// await memberDialog.setPosition(new LogicalPosition(appPosition.x + appSize.width + 10, appPosition.y));
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
};
|
||||
|
||||
const handleShowLogDialog = async () => {
|
||||
try {
|
||||
const appWindow = getCurrentWindow();
|
||||
const appSize = await appWindow.innerSize();
|
||||
const appPosition = await appWindow.outerPosition();
|
||||
if (appWindow) {
|
||||
const infoDialog = new WebviewWindow("log", {
|
||||
title: "日志",
|
||||
width: 600,
|
||||
height: 380,
|
||||
parent: appWindow,
|
||||
closable: true,
|
||||
resizable: false,
|
||||
decorations: true,
|
||||
maximizable: false,
|
||||
minimizable: false,
|
||||
x: appPosition.x + appSize.width + 10,
|
||||
y: appPosition.y,
|
||||
url: "#/log"
|
||||
});
|
||||
|
||||
if (!data.logVisible) {
|
||||
data.logVisible = true;
|
||||
infoDialog.onCloseRequested(() => {
|
||||
data.logVisible = false;
|
||||
})
|
||||
appWindow.emitTo("log", "logs", data.log);
|
||||
} else {
|
||||
data.logVisible = false;
|
||||
infoDialog.destroy();
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<template>
|
||||
<ElInput
|
||||
type="textarea"
|
||||
rows="17"
|
||||
v-model="data.log"
|
||||
resize="none"
|
||||
readonly
|
||||
placeholder="等待日志中..."
|
||||
/>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
|
||||
import { reactive, onMounted, onBeforeUnmount } from "vue";
|
||||
const data = reactive({
|
||||
log: ""
|
||||
});
|
||||
|
||||
const listenStart = async () => {
|
||||
const unListen = await listen("logs", event => {
|
||||
data.log = (event.payload as string) || "";
|
||||
});
|
||||
return unListen;
|
||||
};
|
||||
|
||||
let unlistenStart: UnlistenFn | null = null;
|
||||
onMounted(async () => {
|
||||
unlistenStart = await listenStart();
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
unlistenStart && unlistenStart();
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,172 @@
|
||||
<template>
|
||||
<div class="overflow-auto h-full">
|
||||
<div class="w-[1200px]">
|
||||
<span v-if="!data.member || data.member.length <= 0">{{ "等待成员信息中..." }}</span>
|
||||
<ElTable
|
||||
stripe
|
||||
:data="data.member"
|
||||
v-else
|
||||
>
|
||||
<ElTableColumn
|
||||
v-for="prop in showTableHeader"
|
||||
:prop="prop"
|
||||
:label="prop"
|
||||
></ElTableColumn>
|
||||
</ElTable>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { reactive, onMounted, onBeforeUnmount } from "vue";
|
||||
const data = reactive<{ member: any[] }>({
|
||||
member: []
|
||||
});
|
||||
|
||||
const showTableHeader = ["ipv4", "hostname", "cost", "lat_ms", "loss_rate", "nat_type", "version"];
|
||||
const headers = [
|
||||
"ipv4",
|
||||
"hostname",
|
||||
"cost",
|
||||
"lat_ms",
|
||||
"loss_rate",
|
||||
"rx_bytes",
|
||||
"rx_unit",
|
||||
"tx_bytes",
|
||||
"tx_unit",
|
||||
"tunnel_proto",
|
||||
"nat_type",
|
||||
"id",
|
||||
"version"
|
||||
];
|
||||
|
||||
const formatData = (data: any[]) => {
|
||||
if (!data) return [];
|
||||
const result = [];
|
||||
let obj: any = {};
|
||||
let length = data.length;
|
||||
for (let idx = 0; idx < length; idx++) {
|
||||
let headersIdx = idx % headers.length;
|
||||
if (headersIdx === 0) {
|
||||
console.log(idx, [...data]);
|
||||
obj = {};
|
||||
result.push(obj);
|
||||
}
|
||||
if (["ipv4"].includes(headers[headersIdx]) && !/\d+\.\d+\.\d+\.\d\/\d+/.test(data[idx]) && data[idx]) {
|
||||
const next = data[idx];
|
||||
data[idx] = "-";
|
||||
const head = data.slice(0, idx);
|
||||
const latest = data.slice(idx);
|
||||
data = [...head, next, ...latest];
|
||||
length = data.length;
|
||||
} else if (["rx_bytes", "tx_bytes"].includes(headers[headersIdx]) && data[idx] == "-") {
|
||||
const head = data.slice(0, idx);
|
||||
const latest = data.slice(idx);
|
||||
data = [...head, "-", ...latest];
|
||||
length = data.length;
|
||||
} else if (
|
||||
["tunnel_proto"].includes(headers[headersIdx]) &&
|
||||
![
|
||||
"tcp",
|
||||
"udp",
|
||||
"ws",
|
||||
"wss",
|
||||
"wg",
|
||||
"-",
|
||||
"tcp,udp",
|
||||
"ws,wss",
|
||||
"tcp,udp,ws,wss,wg",
|
||||
"tcp,ws,wss,wg",
|
||||
"udp,ws,wss,wg",
|
||||
"tcp,wg",
|
||||
"udp,wg",
|
||||
"tcp,ws",
|
||||
"tcp,wss",
|
||||
"udp,ws",
|
||||
"udp,wss",
|
||||
"tcp,udp,ws",
|
||||
"tcp,udp,wss",
|
||||
"tcp,udp,ws,wss",
|
||||
"tcp,udp,ws,wss,wg",
|
||||
"tcp,udp,wg",
|
||||
"tcp,udp,ws,wg",
|
||||
"udp,tcp",
|
||||
"udp,tcp,ws",
|
||||
"udp,tcp,wss",
|
||||
"udp,tcp,ws,wss",
|
||||
"udp,tcp,ws,wss,wg",
|
||||
"udp,tcp,wg",
|
||||
"udp,tcp,ws,wg",
|
||||
"tcp,udp,wss,wg",
|
||||
"tcp,udp,ws,wg",
|
||||
"tcp,udp,wss,wg",
|
||||
"ws,tcp",
|
||||
"ws,udp",
|
||||
"ws,tcp,udp",
|
||||
"ws,tcp,udp,ws",
|
||||
"ws,tcp,udp,wss",
|
||||
"ws,tcp,udp,ws,wss",
|
||||
"ws,tcp,udp,ws,wss,wg",
|
||||
"ws,tcp,udp,wg",
|
||||
"ws,tcp,udp,ws,wg",
|
||||
"ws,udp,tcp",
|
||||
"ws,udp,tcp,ws",
|
||||
"ws,udp,tcp,wss",
|
||||
"ws,udp,tcp,ws,wss",
|
||||
"wss,tcp",
|
||||
"wss,udp",
|
||||
"wss,tcp,udp",
|
||||
"wss,tcp,udp,ws",
|
||||
"wss,tcp,udp,wss",
|
||||
"wss,tcp,udp,ws,wss",
|
||||
"wss,tcp,udp,ws,wss,wg",
|
||||
"wss,tcp,udp,wg",
|
||||
"wg,tcp",
|
||||
"wg,udp",
|
||||
"wg,tcp,udp",
|
||||
"wg,tcp,udp,ws",
|
||||
"wg,tcp,udp,wss",
|
||||
"wg,tcp,udp,ws,wss",
|
||||
"wg,tcp,udp,ws,wss,wg",
|
||||
"wg,tcp,udp,wg",
|
||||
"wg,udp,tcp"
|
||||
].includes(data[idx])
|
||||
) {
|
||||
const head = data.slice(0, idx);
|
||||
const latest = data.slice(idx);
|
||||
data = [...head, "-", ...latest];
|
||||
length = data.length;
|
||||
}
|
||||
obj[headers[headersIdx]] = data[idx];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
const listenOutput = async () => {
|
||||
const member = await invoke("get_members_by_cli");
|
||||
let memberData = ((member as string) || "")
|
||||
.replace(/[\│\├\┌\└\─\┬\┴\┼\┤\┐\┘]+/g, "")
|
||||
.split(" ")
|
||||
.filter(el => el && !["\n", "\n\n"].includes(el))
|
||||
.slice(11);
|
||||
if (memberData.length <= 0) {
|
||||
return;
|
||||
}
|
||||
const result = formatData(memberData);
|
||||
data.member = result;
|
||||
console.log({ member: data.member });
|
||||
};
|
||||
|
||||
let timer: NodeJS.Timeout | null = null;
|
||||
|
||||
onMounted(async () => {
|
||||
listenOutput();
|
||||
// timer = setInterval(() => {
|
||||
// listenOutput();
|
||||
// }, 3000);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
timer && clearInterval(timer);
|
||||
});
|
||||
</script>
|
||||
Generated
+1
-1
@@ -1059,7 +1059,7 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
|
||||
|
||||
[[package]]
|
||||
name = "easytier-game"
|
||||
version = "1.0.3"
|
||||
version = "1.0.4"
|
||||
dependencies = [
|
||||
"log",
|
||||
"reqwest",
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
[package]
|
||||
name = "easytier-game"
|
||||
version = "1.0.3"
|
||||
version = "1.0.4"
|
||||
homepage = "https://github.com/EasyTier/EasyTier"
|
||||
repository = "https://github.com/EasyTier/EasytierGame"
|
||||
description = "A simple network initiator based on Easytier"
|
||||
authors = ["you"]
|
||||
license = ""
|
||||
repository = ""
|
||||
authors = ["leizi97"]
|
||||
license = "LICENSE"
|
||||
|
||||
edition = "2021"
|
||||
rust-version = "1.77.2"
|
||||
|
||||
@@ -16,6 +18,7 @@ crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2.0.1", features = [] }
|
||||
# prost-build = "0.13.2"
|
||||
|
||||
[dependencies]
|
||||
serde_json = "1.0"
|
||||
@@ -30,6 +33,8 @@ tauri-plugin-log = "2.0.0-rc"
|
||||
tauri-plugin-shell = "2"
|
||||
reqwest = { version = "0.12", features = ["json"] }
|
||||
zip = "2.2.0"
|
||||
# prost = "0.13"
|
||||
# prost-types = "0.13"
|
||||
|
||||
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
|
||||
tauri-plugin-single-instance = "2"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../LICENSE
|
||||
@@ -3,13 +3,25 @@
|
||||
"identifier": "default",
|
||||
"description": "enables the default permissions",
|
||||
"windows": [
|
||||
"main"
|
||||
"main",
|
||||
"log"
|
||||
],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"core:window:allow-minimize",
|
||||
"core:window:allow-hide",
|
||||
"core:window:allow-close",
|
||||
"shell:allow-open"
|
||||
"shell:allow-open",
|
||||
"core:window:allow-show",
|
||||
"core:window:allow-create",
|
||||
"core:window:allow-set-position",
|
||||
"core:window:allow-destroy",
|
||||
"core:webview:allow-create-webview-window",
|
||||
"core:webview:allow-set-webview-size",
|
||||
"core:webview:allow-set-webview-position",
|
||||
"core:webview:allow-create-webview",
|
||||
"core:webview:allow-webview-show",
|
||||
"core:webview:allow-webview-hide",
|
||||
"core:webview:allow-webview-close"
|
||||
]
|
||||
}
|
||||
|
||||
+83
-37
@@ -1,5 +1,6 @@
|
||||
use reqwest::{Client, Error};
|
||||
use serde::Deserialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use std::fs::{self, File};
|
||||
use std::io::{BufRead, BufReader, Write};
|
||||
use std::os::windows::process::CommandExt;
|
||||
@@ -11,8 +12,7 @@ use std::sync::{
|
||||
use std::{path, thread};
|
||||
use tauri::tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent};
|
||||
use tauri::Emitter;
|
||||
use tauri::{Manager, WindowEvent};
|
||||
|
||||
use tauri::Manager;
|
||||
// 定义GitHub Release的结构体
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct Release {
|
||||
@@ -47,26 +47,6 @@ pub async fn fetch_releases() -> Result<Vec<Release>, Error> {
|
||||
response.json::<Vec<Release>>().await
|
||||
}
|
||||
|
||||
static mut IS_CLOSE: bool = false;
|
||||
|
||||
#[tauri::command(rename_all = "snake_case")]
|
||||
fn my_commit_output(commit_msg: String, window: tauri::Window) -> Result<bool, String> {
|
||||
println!("{}", commit_msg);
|
||||
unsafe {
|
||||
IS_CLOSE = true;
|
||||
}
|
||||
window.close().unwrap();
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
#[tauri::command(rename_all = "snake_case")]
|
||||
fn force_close(window: tauri::Window) {
|
||||
unsafe {
|
||||
IS_CLOSE = true;
|
||||
}
|
||||
window.close().unwrap();
|
||||
}
|
||||
|
||||
#[tauri::command(rename_all = "snake_case")]
|
||||
fn get_core_version() -> String {
|
||||
match Command::new("easytier-core.exe")
|
||||
@@ -82,9 +62,74 @@ fn get_core_version() -> String {
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command(rename_all = "snake_case")]
|
||||
fn get_cli_version() -> String {
|
||||
match Command::new("easytier-cli.exe")
|
||||
.arg("--version")
|
||||
.creation_flags(0x08000000)
|
||||
.output()
|
||||
{
|
||||
Ok(output) => {
|
||||
let output_str = String::from_utf8_lossy(&output.stdout);
|
||||
return output_str.trim().to_string();
|
||||
}
|
||||
Err(_e) => return "".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct RoutePeerInfo {
|
||||
peer_id: u64,
|
||||
cost: u64,
|
||||
hostname: Option<String>,
|
||||
udp_stun_info: String,
|
||||
easytier_version: String,
|
||||
network_length: u64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct RouteTable {
|
||||
peer_infos: HashMap<u32, RoutePeerInfo>,
|
||||
ipv4_peer_id_map: HashMap<String, u64>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct PeerRouteServiceImpl {
|
||||
route_table_with_cost: RouteTable,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct PeerRoute {
|
||||
my_peer_id: u64,
|
||||
service_impl: PeerRouteServiceImpl,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct MyResponse {
|
||||
response: PeerRoute
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[tauri::command(rename_all = "snake_case")]
|
||||
fn get_members_by_cli() -> String {
|
||||
match Command::new("easytier-cli.exe")
|
||||
.arg("peer")
|
||||
.arg("list")
|
||||
.creation_flags(0x08000000)
|
||||
.output()
|
||||
{
|
||||
Ok(output) => {
|
||||
let output_str = String::from_utf8_lossy(&output.stdout);
|
||||
return output_str.trim().to_string();
|
||||
}
|
||||
Err(_e) => return _e.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command(rename_all = "snake_case")]
|
||||
async fn download_easytier_zip(download_url: String, file_name: String) {
|
||||
let target = format!("https://ghp.ci/?q={}",download_url);
|
||||
let target = format!("https://ghp.ci/{}", download_url);
|
||||
let response = reqwest::get(target)
|
||||
.await
|
||||
.expect("error to download easytier url");
|
||||
@@ -269,16 +314,17 @@ pub fn run() {
|
||||
let context = tauri::generate_context!();
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.on_window_event(move |window, event| {
|
||||
if let WindowEvent::CloseRequested { api, .. } = event {
|
||||
unsafe {
|
||||
if !IS_CLOSE {
|
||||
api.prevent_close();
|
||||
window.emit("window-close-event", "").unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
// .on_window_event(move |window, event| {
|
||||
// if let WindowEvent::CloseRequested { api, .. } = event {
|
||||
// println!("close window");
|
||||
// unsafe {
|
||||
// if !IS_CLOSE && window.label() == "main" {
|
||||
// api.prevent_close();
|
||||
// window.emit("window-close-event", "").unwrap();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
.plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| {
|
||||
let _ = app
|
||||
.get_webview_window("main")
|
||||
@@ -316,13 +362,13 @@ pub fn run() {
|
||||
})
|
||||
.manage(stop_signal_clone)
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
my_commit_output,
|
||||
force_close,
|
||||
run_command,
|
||||
stop_command,
|
||||
get_core_version,
|
||||
fetch_easytier_list,
|
||||
download_easytier_zip
|
||||
download_easytier_zip,
|
||||
get_cli_version,
|
||||
get_members_by_cli
|
||||
])
|
||||
.run(context)
|
||||
.expect("error while running tauri application");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "easytier-game",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.4",
|
||||
"identifier": "com.tauri.easytier-game",
|
||||
|
||||
"build": {
|
||||
|
||||
Reference in New Issue
Block a user