2021-11-01 09:42:17 +05:00
|
|
|
const { default: storage } = require("electron-data-storage");
|
2021-09-29 14:02:47 +05:00
|
|
|
const { nativeTheme } = require("electron");
|
2021-08-02 20:44:56 +05:00
|
|
|
|
|
|
|
|
function getTheme() {
|
|
|
|
|
return storage.getSync("theme") || "light";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setTheme(theme) {
|
2021-09-29 14:02:47 +05:00
|
|
|
nativeTheme.themeSource = theme;
|
|
|
|
|
if (global.win) global.win.setBackgroundColor(getBackgroundColor(theme));
|
2021-08-02 20:44:56 +05:00
|
|
|
return storage.set("theme", theme);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-29 14:02:47 +05:00
|
|
|
function getBackgroundColor(theme) {
|
|
|
|
|
if (!theme) theme = getTheme();
|
|
|
|
|
return theme === "dark" ? "#0f0f0f" : "#ffffff";
|
2021-08-02 20:44:56 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = { getTheme, setTheme, getBackgroundColor };
|