forked from lvyunqi/QimenIDC-Client-V2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app-setting.ts
87 lines (70 loc) · 2.9 KB
/
app-setting.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { $themeConfig } from './theme.config';
import { useAppStore } from '@/stores/index';
export default {
init(setLocale: any) {
const store = useAppStore();
// set default styles
let val: any = localStorage.getItem('theme'); // light, dark, system
val = val || $themeConfig.theme;
store.toggleTheme(val);
val = localStorage.getItem('menu'); // vertical, collapsible-vertical, horizontal
val = val || $themeConfig.menu;
store.toggleMenu(val);
val = localStorage.getItem('layout'); // full, boxed-layout
val = val || $themeConfig.layout;
store.toggleLayout(val);
val = localStorage.getItem('i18n_locale'); // en, da, de, el, es, fr, hu, it, ja, pl, pt, ru, sv, tr, zh
val = val || $themeConfig.locale;
const list = store.languageList;
const item = list.find((item: any) => item.code === val);
if (item) {
this.toggleLanguage(item, setLocale);
}
val = localStorage.getItem('rtlClass'); // rtl, ltr
val = val || $themeConfig.rtlClass;
store.toggleRTL(val);
val = localStorage.getItem('animation'); // animate__fadeIn, animate__fadeInDown, animate__fadeInUp, animate__fadeInLeft, animate__fadeInRight, animate__slideInDown, animate__slideInLeft, animate__slideInRight, animate__zoomIn
val = val || $themeConfig.animation;
store.toggleAnimation(val);
val = localStorage.getItem('navbar'); // navbar-sticky, navbar-floating, navbar-static
val = val || $themeConfig.navbar;
store.toggleNavbar(val);
val = localStorage.getItem('semidark');
val = val === 'true' ? true : $themeConfig.semidark;
store.toggleSemidark(val);
},
toggleLanguage(item: any, setLocale: any) {
const store = useAppStore();
let lang: any = null;
if (item) {
lang = item;
} else {
let code = store.locale || null;
if (!code) {
code = localStorage.getItem('i18n_locale');
}
item = store.languageList.find((d: any) => d.code === code);
if (item) {
lang = item;
}
}
if (!lang) {
lang = store.languageList.find((d: any) => d.code === 'en');
}
store.toggleLocale(lang.code, setLocale);
return lang;
},
changeAnimation(type = 'add') {
const store = useAppStore();
if (store.animation) {
const eleanimation: any = document.querySelector('.animation');
if (type === 'add') {
eleanimation?.classList.add('animate__animated');
eleanimation?.classList.add(store.animation);
} else {
eleanimation?.classList.remove('animate__animated');
eleanimation?.classList.remove(store.animation);
}
}
},
};