feat: init

This commit is contained in:
ex_zhangwenlei@exiot.cmcc
2024-01-02 21:50:01 +08:00
commit df02b23b2d
69 changed files with 7333 additions and 0 deletions

19
src/hooks/useTheme.ts Normal file
View File

@@ -0,0 +1,19 @@
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 };
};