mirror of
https://github.com/jeffvli/feishin.git
synced 2026-07-22 10:26:33 +02:00
feat: add support for loading custom themes from files (#2218)
* feat: add support for loading custom themes from files --------- Co-authored-by: jeffvli <jeffvictorli@gmail.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { ipcRenderer } from 'electron';
|
||||
|
||||
export interface CustomTheme {
|
||||
app?: Record<string, unknown>;
|
||||
colors?: Record<string, unknown>;
|
||||
error?: string;
|
||||
extends?: string;
|
||||
filename: string;
|
||||
id: string;
|
||||
label: string;
|
||||
mantineOverride?: Record<string, unknown>;
|
||||
mode: 'dark' | 'light';
|
||||
stylesheetContents?: string[];
|
||||
warnings?: string[];
|
||||
}
|
||||
|
||||
const get = async (): Promise<CustomTheme[]> => {
|
||||
return ipcRenderer.invoke('custom-themes-get');
|
||||
};
|
||||
|
||||
const reload = async (): Promise<CustomTheme[]> => {
|
||||
return ipcRenderer.invoke('custom-themes-reload');
|
||||
};
|
||||
|
||||
const openFolder = async (): Promise<boolean> => {
|
||||
return ipcRenderer.invoke('custom-themes-open-folder');
|
||||
};
|
||||
|
||||
const onUpdate = (cb: (themes: CustomTheme[]) => void) => {
|
||||
const listener = (_event: Electron.IpcRendererEvent, themes: CustomTheme[]) => cb(themes);
|
||||
ipcRenderer.on('custom-themes-updated', listener);
|
||||
return () => ipcRenderer.removeListener('custom-themes-updated', listener);
|
||||
};
|
||||
|
||||
export const customThemes = {
|
||||
get,
|
||||
onUpdate,
|
||||
openFolder,
|
||||
reload,
|
||||
};
|
||||
|
||||
export type CustomThemes = typeof customThemes;
|
||||
@@ -2,6 +2,7 @@ import { contextBridge, webUtils } from 'electron';
|
||||
|
||||
import { autodiscover } from './autodiscover';
|
||||
import { browser } from './browser';
|
||||
import { customThemes } from './custom-themes';
|
||||
import { discordRpc } from './discord-rpc';
|
||||
import { ipc } from './ipc';
|
||||
import { localSettings } from './local-settings';
|
||||
@@ -16,6 +17,7 @@ import { visualizer } from './visualizer';
|
||||
const api = {
|
||||
autodiscover,
|
||||
browser,
|
||||
customThemes,
|
||||
discordRpc,
|
||||
getPathForFile: webUtils.getPathForFile,
|
||||
ipc,
|
||||
|
||||
Reference in New Issue
Block a user