theme.json is now read if present
This commit is contained in:
parent
eb6053ee04
commit
a6abb536e4
2 changed files with 34 additions and 3 deletions
|
@ -397,7 +397,6 @@ export class BrowserWindow {
|
|||
|
||||
ipcMain.on("get-themes", (event, _key) => {
|
||||
if (existsSync(utils.getPath("themes"))) {
|
||||
// return any .less files and scan any folders in the themes folder for .less files
|
||||
let files = readdirSync(utils.getPath("themes"));
|
||||
let themes = [];
|
||||
for (let file of files) {
|
||||
|
@ -412,7 +411,39 @@ export class BrowserWindow {
|
|||
}
|
||||
}
|
||||
}
|
||||
event.returnValue = themes;
|
||||
let themeObjects = [];
|
||||
for (let theme of themes) {
|
||||
let themePath = join(utils.getPath("themes"), theme);
|
||||
let themeName = theme;
|
||||
let themeDescription = "";
|
||||
if (theme.includes("/")) {
|
||||
themeName = theme.split("/")[1];
|
||||
themeDescription = theme.split("/")[0];
|
||||
}
|
||||
if (themePath.endsWith("index.less")) {
|
||||
themePath = themePath.slice(0, -10);
|
||||
}
|
||||
if (existsSync(join(themePath, "theme.json"))) {
|
||||
let themeJson = JSON.parse(readFileSync(join(themePath, "theme.json"), "utf8"));
|
||||
themeObjects.push({
|
||||
name: themeJson.name || themeName,
|
||||
description: themeJson.description || themeDescription,
|
||||
path: themePath,
|
||||
file: theme,
|
||||
test: join(themePath, "theme.json")
|
||||
});
|
||||
} else {
|
||||
themeObjects.push({
|
||||
name: themeName,
|
||||
description: themeDescription,
|
||||
path: themePath,
|
||||
file: theme,
|
||||
test: join(themePath, "theme.json")
|
||||
});
|
||||
}
|
||||
}
|
||||
event.returnValue = themeObjects;
|
||||
|
||||
} else {
|
||||
event.returnValue = [];
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@
|
|||
<select class="md-select" @change="$root.setTheme($root.cfg.visual.theme)" v-model="$root.cfg.visual.theme">
|
||||
<option value="default.less">{{$root.getLz('settings.option.visual.theme.default')}}</option>
|
||||
<option value="dark.less">{{$root.getLz('settings.option.visual.theme.dark')}}</option>
|
||||
<option v-for="theme in themes" :value="theme">{{ theme.replace(".less", "") }}</option>
|
||||
<option v-for="theme in themes" :value="theme.file">{{ theme.name }}</option>
|
||||
</select>
|
||||
<button class="md-btn md-btn-small md-btn-block" @click="installTheme()" style="margin-top: 8px">Install from GitHub URL</button>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue