feat(too): to

This commit is contained in:
ex_zhangwenlei@exiot.cmcc
2024-01-10 01:04:51 +08:00
parent f0a62aacb5
commit 3283a2d975
9 changed files with 5 additions and 246 deletions

View File

@@ -1,19 +0,0 @@
import { useStorage } from '@vueuse/core';
import { ref } from 'vue';
export const useTheme = (theme?: string) => {
const StorageTheme = useStorage('data-theme', theme) || ref('default');
const setTheme = (theme: string) => {
StorageTheme.value = theme;
const body = document.getElementsByTagName('body')[0];
if (body) {
body.setAttribute('data-theme', StorageTheme.value);
}
};
if (theme) {
setTheme(theme);
} else {
setTheme(StorageTheme.value as string);
}
return { StorageTheme, setTheme };
};