mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 03:32:17 +08:00
support update all profile
This commit is contained in:
parent
0c5ab9de41
commit
ad538a0a25
|
@ -7,7 +7,7 @@ import {
|
|||
import icoIcon from '../../../resources/icon.ico?asset'
|
||||
import pngIcon from '../../../resources/icon.png?asset'
|
||||
import { patchMihomoConfig } from './mihomoApi'
|
||||
import { createWindow, destroyTimer, mainWindow } from '..'
|
||||
import { mainWindow, showMainWindow } from '..'
|
||||
import { app, ipcMain, Menu, shell, Tray } from 'electron'
|
||||
import { dataDir, logDir, mihomoCoreDir, mihomoWorkDir } from '../utils/dirs'
|
||||
import { triggerSysProxy } from '../resolve/sysproxy'
|
||||
|
@ -23,15 +23,7 @@ const buildContextMenu = async (): Promise<Menu> => {
|
|||
label: '显示窗口',
|
||||
type: 'normal',
|
||||
click: (): void => {
|
||||
if (!mainWindow) {
|
||||
if (destroyTimer) {
|
||||
clearTimeout(destroyTimer)
|
||||
}
|
||||
createWindow(true)
|
||||
} else {
|
||||
mainWindow?.show()
|
||||
mainWindow?.focusOnWebView()
|
||||
}
|
||||
showMainWindow()
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -169,14 +161,7 @@ export async function createTray(): Promise<void> {
|
|||
if (mainWindow?.isVisible()) {
|
||||
mainWindow?.close()
|
||||
} else {
|
||||
if (!mainWindow) {
|
||||
if (destroyTimer) {
|
||||
clearTimeout(destroyTimer)
|
||||
}
|
||||
createWindow(true)
|
||||
} else {
|
||||
mainWindow?.show()
|
||||
}
|
||||
showMainWindow()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -27,16 +27,7 @@ if (!gotTheLock) {
|
|||
const initPromise = init()
|
||||
|
||||
app.on('second-instance', async (_event, commandline) => {
|
||||
if (!mainWindow) {
|
||||
if (destroyTimer) {
|
||||
clearTimeout(destroyTimer)
|
||||
}
|
||||
createWindow(true)
|
||||
} else {
|
||||
mainWindow?.show()
|
||||
mainWindow?.focusOnWebView()
|
||||
}
|
||||
|
||||
showMainWindow()
|
||||
const url = commandline.pop()
|
||||
if (url) {
|
||||
await handleDeepLink(url)
|
||||
|
@ -44,16 +35,7 @@ app.on('second-instance', async (_event, commandline) => {
|
|||
})
|
||||
|
||||
app.on('open-url', async (_event, url) => {
|
||||
if (!mainWindow) {
|
||||
if (destroyTimer) {
|
||||
clearTimeout(destroyTimer)
|
||||
}
|
||||
createWindow(true)
|
||||
} else {
|
||||
mainWindow?.show()
|
||||
mainWindow?.focusOnWebView()
|
||||
}
|
||||
|
||||
showMainWindow()
|
||||
await handleDeepLink(url)
|
||||
})
|
||||
// Quit when all windows are closed, except on macOS. There, it's common
|
||||
|
@ -191,7 +173,6 @@ export function createWindow(show = false): void {
|
|||
mainWindow?.destroy()
|
||||
mainWindow = null
|
||||
}, 300000)
|
||||
// mainWindow?.webContents.reload()
|
||||
})
|
||||
|
||||
mainWindow.webContents.setWindowOpenHandler((details) => {
|
||||
|
@ -207,3 +188,15 @@ export function createWindow(show = false): void {
|
|||
mainWindow.loadFile(join(__dirname, '../renderer/index.html'))
|
||||
}
|
||||
}
|
||||
|
||||
export function showMainWindow(): void {
|
||||
if (destroyTimer) {
|
||||
clearTimeout(destroyTimer)
|
||||
}
|
||||
if (mainWindow) {
|
||||
mainWindow.show()
|
||||
mainWindow.focusOnWebView()
|
||||
} else {
|
||||
createWindow(true)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,29 @@ const Profiles: React.FC = () => {
|
|||
}, [items])
|
||||
|
||||
return (
|
||||
<BasePage ref={pageRef} title="订阅管理">
|
||||
<BasePage
|
||||
ref={pageRef}
|
||||
title="订阅管理"
|
||||
header={
|
||||
<Button
|
||||
size="sm"
|
||||
color="primary"
|
||||
onPress={async () => {
|
||||
for (const item of items) {
|
||||
if (item.id === current) continue
|
||||
if (item.type !== 'remote') continue
|
||||
await addProfileItem(item)
|
||||
}
|
||||
const currentItem = items.find((item) => item.id === current)
|
||||
if (currentItem && currentItem.type === 'remote') {
|
||||
await addProfileItem(currentItem)
|
||||
}
|
||||
}}
|
||||
>
|
||||
更新全部订阅
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
<div className="sticky top-[48px] z-40 backdrop-blur bg-background/40 flex p-2">
|
||||
<Input
|
||||
variant="bordered"
|
||||
|
|
Loading…
Reference in New Issue
Block a user