mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-01 19:13:58 +00:00
feat: support to save and load theme setting from localStorage (#342)
This commit is contained in:
parent
8618a9440e
commit
03e1508afc
@ -90,6 +90,14 @@ limitations under the License. -->
|
||||
const pageTitle = ref<string>("");
|
||||
const theme = ref<boolean>(true);
|
||||
|
||||
const savedTheme = window.localStorage.getItem("theme-is-dark");
|
||||
if (savedTheme === "false") {
|
||||
theme.value = false;
|
||||
} else if (savedTheme === "") {
|
||||
// read the theme preference from system setting if there is no user setting
|
||||
theme.value = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
||||
}
|
||||
|
||||
changeTheme();
|
||||
resetDuration();
|
||||
getVersion();
|
||||
@ -107,6 +115,7 @@ limitations under the License. -->
|
||||
root.classList.remove(Themes.Dark);
|
||||
appStore.setTheme(Themes.Light);
|
||||
}
|
||||
window.localStorage.setItem("theme-is-dark", String(theme.value));
|
||||
}
|
||||
|
||||
function getName(list: any[]) {
|
||||
|
Loading…
Reference in New Issue
Block a user