passed default theme handling to webSettings
This commit is contained in:
parent
03a6269b5f
commit
1171bc1cdf
2 changed files with 23 additions and 12 deletions
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
let data;
|
let data;
|
||||||
|
|
||||||
const urlResolver = document.createElement('a');
|
const urlResolver = document.createElement('a');
|
||||||
|
@ -86,12 +85,32 @@ export function getMultiServer() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const defaultTheme = {
|
||||||
|
'name': 'Dark',
|
||||||
|
'id': 'dark',
|
||||||
|
'default': true
|
||||||
|
};
|
||||||
|
|
||||||
|
const checkDefaultTheme = (themes) => {
|
||||||
|
if (themes) {
|
||||||
|
const defaultTheme = themes.find((theme) => theme.default);
|
||||||
|
|
||||||
|
if (!defaultTheme) {
|
||||||
|
themes.push(defaultTheme);
|
||||||
|
}
|
||||||
|
|
||||||
|
return themes;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [defaultTheme];
|
||||||
|
};
|
||||||
|
|
||||||
export function getThemes() {
|
export function getThemes() {
|
||||||
return getConfig().then(config => {
|
return getConfig().then(config => {
|
||||||
return config.themes;
|
return checkDefaultTheme(Array.isArray(config.themes) ? config.themes : []);
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.log('cannot get web config:', error);
|
console.log('cannot get web config:', error);
|
||||||
return [];
|
return checkDefaultTheme();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,18 +17,10 @@ function getThemes() {
|
||||||
|
|
||||||
function getThemeStylesheetInfo(id) {
|
function getThemeStylesheetInfo(id) {
|
||||||
return getThemes().then(themes => {
|
return getThemes().then(themes => {
|
||||||
let theme = themes.find(theme => {
|
const theme = themes.find(theme => {
|
||||||
return id ? theme.id === id : theme.default;
|
return id ? theme.id === id : theme.default;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!theme) {
|
|
||||||
theme = {
|
|
||||||
'name': 'Dark',
|
|
||||||
'id': 'dark',
|
|
||||||
'default': true
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
stylesheetPath: 'themes/' + theme.id + '/theme.css',
|
stylesheetPath: 'themes/' + theme.id + '/theme.css',
|
||||||
themeId: theme.id
|
themeId: theme.id
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue