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 icoIcon from '../../../resources/icon.ico?asset'
|
||||||
import pngIcon from '../../../resources/icon.png?asset'
|
import pngIcon from '../../../resources/icon.png?asset'
|
||||||
import { patchMihomoConfig } from './mihomoApi'
|
import { patchMihomoConfig } from './mihomoApi'
|
||||||
import { createWindow, destroyTimer, mainWindow } from '..'
|
import { mainWindow, showMainWindow } from '..'
|
||||||
import { app, ipcMain, Menu, shell, Tray } from 'electron'
|
import { app, ipcMain, Menu, shell, Tray } from 'electron'
|
||||||
import { dataDir, logDir, mihomoCoreDir, mihomoWorkDir } from '../utils/dirs'
|
import { dataDir, logDir, mihomoCoreDir, mihomoWorkDir } from '../utils/dirs'
|
||||||
import { triggerSysProxy } from '../resolve/sysproxy'
|
import { triggerSysProxy } from '../resolve/sysproxy'
|
||||||
|
@ -23,15 +23,7 @@ const buildContextMenu = async (): Promise<Menu> => {
|
||||||
label: '显示窗口',
|
label: '显示窗口',
|
||||||
type: 'normal',
|
type: 'normal',
|
||||||
click: (): void => {
|
click: (): void => {
|
||||||
if (!mainWindow) {
|
showMainWindow()
|
||||||
if (destroyTimer) {
|
|
||||||
clearTimeout(destroyTimer)
|
|
||||||
}
|
|
||||||
createWindow(true)
|
|
||||||
} else {
|
|
||||||
mainWindow?.show()
|
|
||||||
mainWindow?.focusOnWebView()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -169,14 +161,7 @@ export async function createTray(): Promise<void> {
|
||||||
if (mainWindow?.isVisible()) {
|
if (mainWindow?.isVisible()) {
|
||||||
mainWindow?.close()
|
mainWindow?.close()
|
||||||
} else {
|
} else {
|
||||||
if (!mainWindow) {
|
showMainWindow()
|
||||||
if (destroyTimer) {
|
|
||||||
clearTimeout(destroyTimer)
|
|
||||||
}
|
|
||||||
createWindow(true)
|
|
||||||
} else {
|
|
||||||
mainWindow?.show()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,16 +27,7 @@ if (!gotTheLock) {
|
||||||
const initPromise = init()
|
const initPromise = init()
|
||||||
|
|
||||||
app.on('second-instance', async (_event, commandline) => {
|
app.on('second-instance', async (_event, commandline) => {
|
||||||
if (!mainWindow) {
|
showMainWindow()
|
||||||
if (destroyTimer) {
|
|
||||||
clearTimeout(destroyTimer)
|
|
||||||
}
|
|
||||||
createWindow(true)
|
|
||||||
} else {
|
|
||||||
mainWindow?.show()
|
|
||||||
mainWindow?.focusOnWebView()
|
|
||||||
}
|
|
||||||
|
|
||||||
const url = commandline.pop()
|
const url = commandline.pop()
|
||||||
if (url) {
|
if (url) {
|
||||||
await handleDeepLink(url)
|
await handleDeepLink(url)
|
||||||
|
@ -44,16 +35,7 @@ app.on('second-instance', async (_event, commandline) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('open-url', async (_event, url) => {
|
app.on('open-url', async (_event, url) => {
|
||||||
if (!mainWindow) {
|
showMainWindow()
|
||||||
if (destroyTimer) {
|
|
||||||
clearTimeout(destroyTimer)
|
|
||||||
}
|
|
||||||
createWindow(true)
|
|
||||||
} else {
|
|
||||||
mainWindow?.show()
|
|
||||||
mainWindow?.focusOnWebView()
|
|
||||||
}
|
|
||||||
|
|
||||||
await handleDeepLink(url)
|
await handleDeepLink(url)
|
||||||
})
|
})
|
||||||
// Quit when all windows are closed, except on macOS. There, it's common
|
// 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?.destroy()
|
||||||
mainWindow = null
|
mainWindow = null
|
||||||
}, 300000)
|
}, 300000)
|
||||||
// mainWindow?.webContents.reload()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
mainWindow.webContents.setWindowOpenHandler((details) => {
|
mainWindow.webContents.setWindowOpenHandler((details) => {
|
||||||
|
@ -207,3 +188,15 @@ export function createWindow(show = false): void {
|
||||||
mainWindow.loadFile(join(__dirname, '../renderer/index.html'))
|
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])
|
}, [items])
|
||||||
|
|
||||||
return (
|
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">
|
<div className="sticky top-[48px] z-40 backdrop-blur bg-background/40 flex p-2">
|
||||||
<Input
|
<Input
|
||||||
variant="bordered"
|
variant="bordered"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user