refactor(projects): 代码优化

ISSUES CLOSED: \
This commit is contained in:
Soybean
2022-05-18 23:43:41 +08:00
parent 4b80a66114
commit 44ab55d594
8 changed files with 5 additions and 108 deletions

View File

@ -43,6 +43,7 @@ export const useRouteStore = defineStore('route-store', {
cacheRoutes: []
}),
actions: {
/** 重置路由的store */
resetRouteStore() {
this.resetRoutes();
this.$reset();

View File

@ -16,6 +16,7 @@ export const useThemeStore = defineStore('theme-store', {
naiveTheme(state) {
return state.darkMode ? darkTheme : undefined;
},
/** 页面动画模式 */
pageAnimateMode(state) {
return state.page.animate ? state.page.animateMode : undefined;
}
@ -34,7 +35,7 @@ export const useThemeStore = defineStore('theme-store', {
this.followSystemTheme = visible;
},
/** 自动跟随系统主题 */
autoFollowSystemMode(darkMode: boolean) {
setAutoFollowSystemMode(darkMode: boolean) {
if (this.followSystemTheme) {
this.darkMode = darkMode;
}

View File

@ -1,21 +0,0 @@
import { watch, onUnmounted } from 'vue';
import { useBodyScroll } from '@/hooks';
import { useAppStore } from '../modules';
/** 订阅app store */
export default function subscribeAppStore() {
const app = useAppStore();
const { scrollBodyHandler } = useBodyScroll();
// 弹窗打开时禁止滚动条
const stopHandle = watch(
() => app.settingDrawerVisible,
newValue => {
scrollBodyHandler(newValue);
}
);
onUnmounted(() => {
stopHandle();
});
}

View File

@ -1,8 +1,6 @@
// import subscribeAppStore from './app';
import subscribeThemeStore from './theme';
/** 订阅状态 */
export function subscribeStore() {
// subscribeAppStore();
subscribeThemeStore();
}

View File

@ -53,7 +53,7 @@ export default function subscribeThemeStore() {
osTheme,
newValue => {
const isDark = newValue === 'dark';
theme.autoFollowSystemMode(isDark);
theme.setAutoFollowSystemMode(isDark);
},
{ immediate: true }
);