forked from ai-shifu/ChatALL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeme.js
31 lines (29 loc) · 858 Bytes
/
theme.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const SYSTEM = "system";
const DARK = "dark";
const LIGHT = "light";
export const Theme = { DARK, LIGHT };
export const Mode = { SYSTEM, ...Theme };
/**
* Determine the actual theme for system mode
* @param {string} mode
* @param {object} ipcRenderer
* @returns {string} resolved theme
*/
export const resolveTheme = async (mode, ipcRenderer) => {
let resolvedTheme = mode;
if (mode === Mode.SYSTEM) {
const nativeTheme = await ipcRenderer.invoke("get-native-theme");
resolvedTheme = nativeTheme.shouldUseDarkColors ? Theme.DARK : Theme.LIGHT;
}
return resolvedTheme;
};
/**
* Apply theme to UI
* @param {string} theme dark / light
* @param {object} vuetifyTheme from veutify useTheme
*/
export const applyTheme = (theme, vuetifyTheme) => {
if (vuetifyTheme) {
vuetifyTheme.global.name.value = theme; // vuetify theme
}
};