Quellcode durchsuchen

获取商城模版

Xiao_123 vor 4 Monaten
Ursprung
Commit
ff65bafbc6
2 geänderte Dateien mit 11 neuen und 4 gelöschten Zeilen
  1. 8 1
      src/permission.js
  2. 3 3
      src/views/mall/home/index.vue

+ 8 - 1
src/permission.js

@@ -2,10 +2,11 @@ import router from './router'
 import { useNProgress } from '@/hooks/web/useNProgress'
 import { useTitle } from '@/hooks/web/useTitle'
 import { getToken, getIsEnterprise } from '@/utils/auth'
-import { useDictStore } from '@/store/dict'
+// import { useDictStore } from '@/store/dict'
 import { useUserStore } from '@/store/user'
 import Confirm from '@/plugins/confirm'
 import dialogExtend from '@/plugins/dialogExtend'
+import { useMallStore } from '@/store/mall'
 
 const { start, done } = useNProgress()
 // loginType:1.enterprise: 企业路由
@@ -14,6 +15,12 @@ const { start, done } = useNProgress()
 //            3.personalCommon: 无需登录也能访问的页面
 // 路由守卫
 router.beforeEach(async (to, from, next) => {
+  // 获取商城装修模版
+  const mallStore = useMallStore()
+  if (!localStorage.getItem('mallTemplate')) {
+    await mallStore.getMallDiyTemplate()
+  }
+  
   localStorage.setItem('routerTest', to.path) // 本地环境保存代码热更新会导致路径缺失问题
   const tokenIndex = getIsEnterprise() ? 1: 2
   start()

+ 3 - 3
src/views/mall/home/index.vue

@@ -37,9 +37,9 @@ import { useRouter } from 'vue-router'
 const router = useRouter()
 
 // 获取装修模版
-onMounted(async () => {
-  await useMallStore().getMallDiyTemplate()
-})
+// onMounted(async () => {
+//   await useMallStore().getMallDiyTemplate()
+// })
 
 let template = ref(JSON.parse(localStorage.getItem('mallTemplate')) || {})
 useMallStore().$subscribe((mutation, state) => {