mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-19 03:17:02 -04:00
Add proper user-friendly theme manager (#635)
Co-authored-by: Justice Almanzar <superdash993@gmail.com> Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
parent
bb7deeb09c
commit
d6c43986fd
18 changed files with 814 additions and 131 deletions
|
@ -18,8 +18,14 @@
|
|||
|
||||
export const enum IpcEvents {
|
||||
QUICK_CSS_UPDATE = "VencordQuickCssUpdate",
|
||||
THEME_UPDATE = "VencordThemeUpdate",
|
||||
GET_QUICK_CSS = "VencordGetQuickCss",
|
||||
SET_QUICK_CSS = "VencordSetQuickCss",
|
||||
UPLOAD_THEME = "VencordUploadTheme",
|
||||
DELETE_THEME = "VencordDeleteTheme",
|
||||
GET_THEMES_DIR = "VencordGetThemesDir",
|
||||
GET_THEMES_LIST = "VencordGetThemesList",
|
||||
GET_THEME_DATA = "VencordGetThemeData",
|
||||
GET_SETTINGS_DIR = "VencordGetSettingsDir",
|
||||
GET_SETTINGS = "VencordGetSettings",
|
||||
SET_SETTINGS = "VencordSetSettings",
|
||||
|
|
|
@ -46,9 +46,23 @@ async function initThemes() {
|
|||
document.documentElement.appendChild(themesStyle);
|
||||
}
|
||||
|
||||
const { themeLinks } = Settings;
|
||||
const links = themeLinks.map(link => `@import url("${link.trim()}");`).join("\n");
|
||||
themesStyle.textContent = links;
|
||||
const { themeLinks, enabledThemes } = Settings;
|
||||
|
||||
const links: string[] = [...themeLinks];
|
||||
|
||||
if (IS_WEB) {
|
||||
for (const theme of enabledThemes) {
|
||||
const themeData = await VencordNative.themes.getThemeData(theme);
|
||||
if (!themeData) continue;
|
||||
const blob = new Blob([themeData], { type: "text/css" });
|
||||
links.push(URL.createObjectURL(blob));
|
||||
}
|
||||
} else {
|
||||
const localThemes = enabledThemes.map(theme => `vencord:///themes/${theme}?v=${Date.now()}`);
|
||||
links.push(...localThemes);
|
||||
}
|
||||
|
||||
themesStyle.textContent = links.map(link => `@import url("${link.trim()}");`).join("\n");
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
|
@ -57,4 +71,8 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
|
||||
initThemes();
|
||||
addSettingsListener("themeLinks", initThemes);
|
||||
addSettingsListener("enabledThemes", initThemes);
|
||||
|
||||
if (!IS_WEB)
|
||||
VencordNative.quickCss.addThemeChangeListener(initThemes);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue