Skip to content

Commit

Permalink
fix: 修复结构store失去响应问题
Browse files Browse the repository at this point in the history
  • Loading branch information
yuntian001 committed Jun 20, 2023
1 parent 3d23151 commit b3f74d8
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/layout/components/header/components/tagBar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import contextmenu from './components/contextmenu.vue';
import { isExternal } from '@/utils/validate';
import { resolve } from 'path-browserify';
import $ from 'jquery';
const { themeConfig } = useSettingStore();
const { themeConfig } = storeToRefs(useSettingStore());
// 初始化tags
const tags = reactive([] as RouteLocationNormalized[]);
const resolvePath = (routePath: string, basePath = '') => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
import { mitter, event } from '@/event';
import { useSettingStore, useGlobalStore, useRouteStore } from '@/store';
import { RouteLocationNormalized, RouteRecordRaw } from 'vue-router';
const { themeConfig } = useSettingStore();
const { themeConfig } = storeToRefs(useSettingStore());
const globalStore = useGlobalStore();
const setMenuCollapse = () => {
themeConfig.menuCollapse = !themeConfig.menuCollapse;
themeConfig.value.menuCollapse = !themeConfig.value.menuCollapse;
};
const breadcrumbList = ref([] as Pick<RouteRecordRaw, 'name' | 'path' | 'meta' | 'redirect'>[]);
const route = useRoute();
const { routes } = useRouteStore();
const { routes } = storeToRefs(useRouteStore());
const setBreadcrumbList = (route: RouteLocationNormalized) => {
const list = [] as Pick<RouteRecordRaw, 'name' | 'path' | 'meta' | 'redirect'>[];
let temp = { children: routes } as unknown as RouteRecordRaw;
let temp = { children: routes.value } as unknown as RouteRecordRaw;
route.meta.menuIndex!.forEach((item) => {
temp = temp.children![item];
if (temp.meta && temp.meta.title && temp.meta.breadcrumb !== false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { localeConfig } from '@/config';
import MessageBox from './components/messageBox.vue';
import { useSettingStore } from '@/store';
import User from './components/user.vue';
const { themeConfig } = useSettingStore();
const { themeConfig } = storeToRefs(useSettingStore());
</script>
<style lang="scss" scoped>
.right {
Expand Down
2 changes: 1 addition & 1 deletion src/layout/components/header/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { useSettingStore } from '@/store';
import TopBar from './components/topBar/index.vue';
import TagBar from './components/tagBar/index.vue';
const { themeConfig } = useSettingStore();
const { themeConfig } = storeToRefs(useSettingStore());
</script>
<style lang="scss" scoped>
.layout-header {
Expand Down
2 changes: 1 addition & 1 deletion src/layout/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import LayoutHeader from './components/header/index.vue';
import LayoutMenu from './components/menu/index.vue';
import LayoutPage from './components/page.vue';
import { useSettingStore, useGlobalStore } from '@/store';
const { themeConfig } = useSettingStore();
const { themeConfig } = storeToRefs(useSettingStore());
const globalStore = useGlobalStore();
onMounted(() => {
nextTick(() => (globalStore.layoutLoaded = true));
Expand Down
2 changes: 1 addition & 1 deletion src/views/login/components/header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<script setup lang="ts" name="Header">
import { localeConfig } from '@/config';
import { useSettingStore } from '@/store';
const { themeConfig } = useSettingStore();
const { themeConfig } = storeToRefs(useSettingStore());
</script>
<style lang="scss" scoped>
.header {
Expand Down
2 changes: 2 additions & 0 deletions types/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
export {}
declare global {
const EffectScope: typeof import('vue')['EffectScope']
const ElLoading: typeof import('element-plus/es')['ElLoading']
const ElMessageBox: typeof import('element-plus/es')['ElMessageBox']
const acceptHMRUpdate: typeof import('pinia')['acceptHMRUpdate']
const asyncComputed: typeof import('@vueuse/core')['asyncComputed']
const autoResetRef: typeof import('@vueuse/core')['autoResetRef']
Expand Down

0 comments on commit b3f74d8

Please sign in to comment.