1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 14:08:06 +08:00

refactor: Demo server, prohibit operation (#7433)

This commit is contained in:
2024-12-19 10:06:19 +08:00 committed by GitHub
parent 063a071228
commit 956d47f9da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 37 deletions

View File

@ -130,7 +130,7 @@ class RequestHttp {
response.status, response.status,
response.data && response.data['message'] ? response.data['message'] : '', response.data && response.data['message'] ? response.data['message'] : '',
); );
return; return Promise.reject(error);
default: default:
globalStore.isLogin = false; globalStore.isLogin = false;
globalStore.errStatus = 'code-' + response.status; globalStore.errStatus = 'code-' + response.status;

View File

@ -438,48 +438,50 @@ const onChangeThemeColor = () => {
themeColorRef.value.acceptParams({ themeColor: themeColor, theme: globalStore.themeConfig.theme }); themeColorRef.value.acceptParams({ themeColor: themeColor, theme: globalStore.themeConfig.theme });
}; };
const handleThemeChange = async (val: string) => {
globalStore.themeConfig.theme = val;
switchTheme();
if (globalStore.isProductPro) {
await updateXpackSettingByKey('Theme', val);
let color: string;
const themeColor: ThemeColor = JSON.parse(globalStore.themeConfig.themeColor);
if (val === 'auto') {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)');
color = prefersDark.matches ? themeColor.dark : themeColor.light;
} else {
color = val === 'dark' ? themeColor.dark : themeColor.light;
}
globalStore.themeConfig.primary = color;
setPrimaryColor(color);
}
};
const onSave = async (key: string, val: any) => { const onSave = async (key: string, val: any) => {
loading.value = true; loading.value = true;
if (key === 'Language') {
i18n.locale.value = val;
globalStore.updateLanguage(val);
}
if (key === 'Theme') {
globalStore.themeConfig.theme = val;
switchTheme();
if (globalStore.isProductPro) {
await updateXpackSettingByKey('Theme', val);
let color: string;
const themeColor: ThemeColor = JSON.parse(globalStore.themeConfig.themeColor);
if (val === 'auto') {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)');
color = prefersDark.matches ? themeColor.dark : themeColor.light;
} else {
color = val === 'dark' ? themeColor.dark : themeColor.light;
}
globalStore.themeConfig.primary = color;
setPrimaryColor(color);
}
}
if (key === 'MenuTabs') {
globalStore.setOpenMenuTabs(val === 'enable');
}
let param = { let param = {
key: key, key: key,
value: val + '', value: val + '',
}; };
await updateSetting(param) try {
.then(async () => { await updateSetting(param);
if (param.key === 'Language') { if (key === 'Language') {
location.reload(); i18n.locale.value = val;
} globalStore.updateLanguage(val);
loading.value = false; location.reload();
MsgSuccess(i18n.t('commons.msg.operationSuccess')); }
await search();
}) if (key === 'Theme') {
.catch(() => { await handleThemeChange(val);
loading.value = false; }
}); if (key === 'MenuTabs') {
globalStore.setOpenMenuTabs(val === 'enable');
}
MsgSuccess(i18n.t('commons.msg.operationSuccess'));
await search();
} catch (error) {
} finally {
loading.value = false;
}
}; };
onMounted(() => { onMounted(() => {