mirror of
https://github.com/EasyTier/EasytierGame.git
synced 2026-10-19 16:16:35 +00:00
托盘菜单也增加重新联机选项
This commit is contained in:
+15
-4
@@ -22,7 +22,7 @@ async function toggleVisibility() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function useTray(init: boolean = false, beforExit: Function, handleConnection: Function) {
|
||||
export async function useTray(init: boolean = false, beforExit: Function, handleConnection: Function, handleReconnect: Function) {
|
||||
let tray;
|
||||
try {
|
||||
tray = await TrayIcon.getById(DEFAULT_TRAY_NAME);
|
||||
@@ -31,7 +31,7 @@ export async function useTray(init: boolean = false, beforExit: Function, handle
|
||||
tooltip: `EasyTierGame\n${pkg.version}`,
|
||||
title: `EasyTierGame\n${pkg.version}`,
|
||||
id: DEFAULT_TRAY_NAME,
|
||||
menu: await Menu.new({ id: "main", items: await generateMenuItem(beforExit, handleConnection) }),
|
||||
menu: await Menu.new({ id: "main", items: await generateMenuItem(beforExit, handleConnection, handleReconnect) }),
|
||||
action: async e => {
|
||||
toggleVisibility();
|
||||
}
|
||||
@@ -45,16 +45,17 @@ export async function useTray(init: boolean = false, beforExit: Function, handle
|
||||
if (init) {
|
||||
tray.setTooltip(`EasyTierGame\n${pkg.version}`);
|
||||
tray.setShowMenuOnLeftClick(false);
|
||||
tray.setMenu(await Menu.new({ id: "main", items: await generateMenuItem(beforExit, handleConnection) }));
|
||||
tray.setMenu(await Menu.new({ id: "main", items: await generateMenuItem(beforExit, handleConnection, handleReconnect) }));
|
||||
}
|
||||
|
||||
return tray;
|
||||
}
|
||||
|
||||
export async function generateMenuItem(beforExit: Function, handleConnection: Function) {
|
||||
export async function generateMenuItem(beforExit: Function, handleConnection: Function, handleReconnect: Function) {
|
||||
return [
|
||||
await MenuItemShow("显示 / 隐藏"),
|
||||
await MenuItemExchangeConnection("联机 / 断开", handleConnection),
|
||||
await MenuItemReconnect("重新联机", handleReconnect),
|
||||
await MenuItemTheme(),
|
||||
await PredefinedMenuItem.new({ item: "Separator" }),
|
||||
await MenuItemPublicPeers(),
|
||||
@@ -63,6 +64,16 @@ export async function generateMenuItem(beforExit: Function, handleConnection: Fu
|
||||
];
|
||||
}
|
||||
|
||||
export async function MenuItemReconnect(text: string, handleReconnect: Function) {
|
||||
return await MenuItem.new({
|
||||
id: "reconnect",
|
||||
text,
|
||||
action: async () => {
|
||||
await handleReconnect();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export async function MenuItemExit(text: string, beforExit: Function) {
|
||||
return await MenuItem.new({
|
||||
id: "quit",
|
||||
|
||||
+10
-3
@@ -752,6 +752,9 @@
|
||||
async () => {
|
||||
await handleConnection();
|
||||
return data.isStart;
|
||||
},
|
||||
async () => {
|
||||
await handleReconnect();
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1696,7 +1699,12 @@
|
||||
}
|
||||
|
||||
if (command === "reconnect") {
|
||||
if (data.isStart) {
|
||||
handleReconnect();
|
||||
}
|
||||
};
|
||||
|
||||
const handleReconnect = async () => {
|
||||
if (data.isStart) {
|
||||
ElMessage.info({
|
||||
message: "正在重新联机...",
|
||||
duration: 2200
|
||||
@@ -1708,8 +1716,7 @@
|
||||
}else {
|
||||
handleConnection();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const handleDeleteAdminConfig = async () => {
|
||||
const path = configAdminData.fileName;
|
||||
|
||||
Reference in New Issue
Block a user