Selaa lähdekoodia

异步加载pinia问题

CzRger 2 viikkoa sitten
vanhempi
commit
ed1fe63189
4 muutettua tiedostoa jossa 19 lisäystä ja 21 poistoa
  1. 1 2
      .gitignore
  2. 16 16
      src/layout/top-left/head/index.vue
  3. 1 1
      src/main.ts
  4. 1 2
      src/router/index.ts

+ 1 - 2
.gitignore

@@ -22,6 +22,5 @@ dist-ssr
 *.njsproj
 *.sln
 *.sw?
-smart-ask-answer-web/
-smart-ask-answer-web.zip
 stats.html
+big-model-web

+ 16 - 16
src/layout/top-left/head/index.vue

@@ -96,13 +96,16 @@
 import { computed, getCurrentInstance, onMounted, reactive } from 'vue'
 import { useAppStore, useDialogStore, useDictionaryStore } from '@/stores'
 import { useRoute, useRouter } from 'vue-router'
+import { sysDict } from '@/api/modules/global/dictionary'
+import { copy } from '@/utils/czr-util'
+import { ElMessage } from 'element-plus'
+import { loginChangeTenant, loginLogout } from '@/api/modules/global/login'
 
 const AppStore = useAppStore()
 const DictionaryStore = useDictionaryStore()
 const DialogStore = useDialogStore()
 const router = useRouter()
 const route = useRoute()
-const { proxy } = getCurrentInstance()
 const state: any = reactive({
   drawer: false,
   dictMap: new Map(),
@@ -113,20 +116,6 @@ const menusCpt: any = computed(
   () => router.options.routes.filter((v) => v.name === 'root')[0],
 )
 
-import { sysDict } from '@/api/modules/global/dictionary'
-import { copy } from '@/utils/czr-util'
-import { ElMessage } from 'element-plus'
-import { loginChangeTenant, loginLogout } from '@/api/modules/global/login'
-sysDict().then(({ data }: any) => {
-  data.forEach((v) => {
-    const d = state.dictMap.get(v.dictType)
-    if (d) {
-      d.children.push(v)
-    } else {
-      state.dictMap.set(v.dictType, { name: v.remark, children: [v] })
-    }
-  })
-})
 const copyDict = (label, value) => {
   try {
     const key = value.replace(/_([a-z])/g, (match, letter) =>
@@ -167,7 +156,18 @@ const logout = () => {
     },
   })
 }
-onMounted(() => {})
+onMounted(() => {
+  sysDict().then(({ data }: any) => {
+    data.forEach((v) => {
+      const d = state.dictMap.get(v.dictType)
+      if (d) {
+        d.children.push(v)
+      } else {
+        state.dictMap.set(v.dictType, { name: v.remark, children: [v] })
+      }
+    })
+  })
+})
 </script>
 
 <style lang="scss" scoped>

+ 1 - 1
src/main.ts

@@ -1,6 +1,6 @@
 import { createApp } from 'vue'
 import App from './App.vue'
-import router, { beforeInit } from './router'
+import router from './router'
 import 'virtual:svg-icons-register' // 【svg-icons相关】
 import initComponent from '@/plugins/initComponent'
 import initProperties from '@/plugins/initProperties'

+ 1 - 2
src/router/index.ts

@@ -4,7 +4,6 @@ import bigModelRouter from './modules/big-model'
 import Temp404 from '@/views/global/temp/404.vue'
 import RouterView from '@/layout/router-view.vue'
 // @ts-ignore
-import Layout from '@/layout/index.vue'
 import { useAppStore } from '@/stores'
 const routes = [
   demoRouter,
@@ -12,7 +11,7 @@ const routes = [
   {
     name: 'root',
     path: '/',
-    component: Layout,
+    component: () => import('@/layout/index.vue'),
     redirect: '/knowledge',
     children: [...bigModelRouter],
   },