mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-15 04:51:06 +02:00
titlebar switching
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ipcMain, safeStorage } from 'electron';
|
||||
import { ipcMain, nativeTheme, safeStorage } from 'electron';
|
||||
import Store from 'electron-store';
|
||||
|
||||
export const store = new Store();
|
||||
@@ -48,3 +48,8 @@ ipcMain.handle('password-set', (_event, password: string, server: string) => {
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
ipcMain.on('theme-set', (_event, theme: 'dark' | 'light' | 'system') => {
|
||||
store.set('theme', theme);
|
||||
nativeTheme.themeSource = theme;
|
||||
});
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
Tray,
|
||||
Menu,
|
||||
nativeImage,
|
||||
nativeTheme,
|
||||
BrowserWindowConstructorOptions,
|
||||
protocol,
|
||||
net,
|
||||
@@ -414,6 +415,11 @@ const createWindow = async () => {
|
||||
// eslint-disable-next-line
|
||||
new AppUpdater();
|
||||
}
|
||||
|
||||
const theme = store.get('theme') as 'dark' | 'light' | 'system' | undefined;
|
||||
if (theme) {
|
||||
nativeTheme.themeSource = theme;
|
||||
}
|
||||
};
|
||||
|
||||
app.commandLine.appendSwitch('disable-features', 'HardwareMediaKeyHandling,MediaSessionService');
|
||||
|
||||
@@ -43,6 +43,10 @@ const fontError = (cb: (event: IpcRendererEvent, file: string) => void) => {
|
||||
ipcRenderer.on('custom-font-error', cb);
|
||||
};
|
||||
|
||||
const themeSet = (theme: 'dark' | 'light' | 'system'): void => {
|
||||
ipcRenderer.send('theme-set', theme);
|
||||
};
|
||||
|
||||
export const localSettings = {
|
||||
disableMediaKeys,
|
||||
enableMediaKeys,
|
||||
@@ -54,6 +58,7 @@ export const localSettings = {
|
||||
restart,
|
||||
set,
|
||||
setZoomFactor,
|
||||
themeSet,
|
||||
};
|
||||
|
||||
export type LocalSettings = typeof localSettings;
|
||||
|
||||
Reference in New Issue
Block a user