mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 05:00:30 +08:00
unified title bar theme
This commit is contained in:
parent
dcb3efbfb8
commit
a7634eaba4
@ -1,6 +1,7 @@
|
|||||||
### New Features
|
### New Features
|
||||||
|
|
||||||
- 支持一键复制环境变量
|
- 支持一键复制环境变量
|
||||||
|
- 同步标题栏深浅主题
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { exec, execFile } from 'child_process'
|
import { exec, execFile } from 'child_process'
|
||||||
import { dialog } from 'electron'
|
import { dialog, nativeTheme } from 'electron'
|
||||||
import { readFile } from 'fs/promises'
|
import { readFile } from 'fs/promises'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { promisify } from 'util'
|
import { promisify } from 'util'
|
||||||
@ -41,3 +41,7 @@ export async function setupFirewall(): Promise<void> {
|
|||||||
await execPromise(createCommand, { shell: 'powershell' })
|
await execPromise(createCommand, { shell: 'powershell' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setNativeTheme(theme: 'system' | 'light' | 'dark'): void {
|
||||||
|
nativeTheme.themeSource = theme
|
||||||
|
}
|
||||||
|
|||||||
@ -48,7 +48,7 @@ import {
|
|||||||
import { isEncryptionAvailable, manualGrantCorePermition, restartCore } from '../core/manager'
|
import { isEncryptionAvailable, manualGrantCorePermition, restartCore } from '../core/manager'
|
||||||
import { triggerSysProxy } from '../sys/sysproxy'
|
import { triggerSysProxy } from '../sys/sysproxy'
|
||||||
import { checkUpdate, downloadAndInstallUpdate } from '../resolve/autoUpdater'
|
import { checkUpdate, downloadAndInstallUpdate } from '../resolve/autoUpdater'
|
||||||
import { getFilePath, openUWPTool, readTextFile, setupFirewall } from '../sys/misc'
|
import { getFilePath, openUWPTool, readTextFile, setNativeTheme, setupFirewall } from '../sys/misc'
|
||||||
import { getRuntimeConfig, getRuntimeConfigStr } from '../core/factory'
|
import { getRuntimeConfig, getRuntimeConfigStr } from '../core/factory'
|
||||||
import { isPortable, setPortable } from './dirs'
|
import { isPortable, setPortable } from './dirs'
|
||||||
import { listWebdavBackups, webdavBackup, webdavRestore } from '../resolve/backup'
|
import { listWebdavBackups, webdavBackup, webdavRestore } from '../resolve/backup'
|
||||||
@ -149,6 +149,9 @@ export function registerIpcMainHandlers(): void {
|
|||||||
ipcMain.handle('webdavBackup', ipcErrorWrapper(webdavBackup))
|
ipcMain.handle('webdavBackup', ipcErrorWrapper(webdavBackup))
|
||||||
ipcMain.handle('webdavRestore', (_e, filename) => ipcErrorWrapper(webdavRestore)(filename))
|
ipcMain.handle('webdavRestore', (_e, filename) => ipcErrorWrapper(webdavRestore)(filename))
|
||||||
ipcMain.handle('listWebdavBackups', ipcErrorWrapper(listWebdavBackups))
|
ipcMain.handle('listWebdavBackups', ipcErrorWrapper(listWebdavBackups))
|
||||||
|
ipcMain.handle('setNativeTheme', (_e, theme) => {
|
||||||
|
setNativeTheme(theme)
|
||||||
|
})
|
||||||
ipcMain.handle('copyEnv', ipcErrorWrapper(copyEnv))
|
ipcMain.handle('copyEnv', ipcErrorWrapper(copyEnv))
|
||||||
ipcMain.handle('alert', (_e, msg) => {
|
ipcMain.handle('alert', (_e, msg) => {
|
||||||
dialog.showErrorBox('Mihomo Party', msg)
|
dialog.showErrorBox('Mihomo Party', msg)
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import MihomoCoreCard from '@renderer/components/sider/mihomo-core-card'
|
|||||||
import ResourceCard from '@renderer/components/sider/resource-card'
|
import ResourceCard from '@renderer/components/sider/resource-card'
|
||||||
import UpdaterButton from '@renderer/components/updater/updater-button'
|
import UpdaterButton from '@renderer/components/updater/updater-button'
|
||||||
import { useAppConfig } from './hooks/use-app-config'
|
import { useAppConfig } from './hooks/use-app-config'
|
||||||
|
import { setNativeTheme } from './utils/ipc'
|
||||||
|
|
||||||
const App: React.FC = () => {
|
const App: React.FC = () => {
|
||||||
const { appConfig, patchAppConfig } = useAppConfig()
|
const { appConfig, patchAppConfig } = useAppConfig()
|
||||||
@ -63,6 +64,14 @@ const App: React.FC = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTheme(appTheme)
|
setTheme(appTheme)
|
||||||
|
if (appTheme === 'system') {
|
||||||
|
setNativeTheme('system')
|
||||||
|
}
|
||||||
|
if (appTheme.includes('light')) {
|
||||||
|
setNativeTheme('light')
|
||||||
|
} else {
|
||||||
|
setNativeTheme('dark')
|
||||||
|
}
|
||||||
}, [appTheme])
|
}, [appTheme])
|
||||||
|
|
||||||
const onDragEnd = async (event: DragEndEvent): Promise<void> => {
|
const onDragEnd = async (event: DragEndEvent): Promise<void> => {
|
||||||
|
|||||||
@ -16,7 +16,8 @@ import {
|
|||||||
restartCore,
|
restartCore,
|
||||||
webdavBackup,
|
webdavBackup,
|
||||||
listWebdavBackups,
|
listWebdavBackups,
|
||||||
copyEnv
|
copyEnv,
|
||||||
|
setNativeTheme
|
||||||
} from '@renderer/utils/ipc'
|
} from '@renderer/utils/ipc'
|
||||||
import { BiCopy } from 'react-icons/bi'
|
import { BiCopy } from 'react-icons/bi'
|
||||||
import { CgWebsite } from 'react-icons/cg'
|
import { CgWebsite } from 'react-icons/cg'
|
||||||
@ -82,6 +83,14 @@ const Settings: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
setTheme(themeStr)
|
setTheme(themeStr)
|
||||||
|
if (themeStr === 'system') {
|
||||||
|
setNativeTheme('system')
|
||||||
|
}
|
||||||
|
if (themeStr.includes('light')) {
|
||||||
|
setNativeTheme('light')
|
||||||
|
} else {
|
||||||
|
setNativeTheme('dark')
|
||||||
|
}
|
||||||
patchAppConfig({ appTheme: themeStr as AppTheme })
|
patchAppConfig({ appTheme: themeStr as AppTheme })
|
||||||
} else {
|
} else {
|
||||||
let themeStr = theme
|
let themeStr = theme
|
||||||
|
|||||||
@ -283,6 +283,10 @@ export async function quitApp(): Promise<void> {
|
|||||||
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('quitApp'))
|
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('quitApp'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function setNativeTheme(theme: 'system' | 'light' | 'dark'): Promise<void> {
|
||||||
|
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('setNativeTheme', theme))
|
||||||
|
}
|
||||||
|
|
||||||
export async function copyEnv(): Promise<void> {
|
export async function copyEnv(): Promise<void> {
|
||||||
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('copyEnv'))
|
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('copyEnv'))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user