瀏覽代碼

个人中心放出来

ith5 3 月之前
父節點
當前提交
0275bea193
共有 4 個文件被更改,包括 79 次插入97 次删除
  1. 26 24
      src/router/homePageRoutes.js
  2. 16 39
      src/router/webRouter.js
  3. 32 32
      src/store/modules/tag.js
  4. 5 2
      src/store/modules/user.js

+ 26 - 24
src/router/homePageRoutes.js

@@ -1,25 +1,27 @@
 const homePageRoutes = [
   {
-    name: 'dashboard',
-    path: '/dashboard',
+    name: "dashboard",
+    path: "/dashboard",
     meta: {
-      title: '仪表盘',
-      icon: 'icon-dashboard',
-      type: 'M',
-      affix: true
+      title: "仪表盘",
+      icon: "icon-dashboard",
+      type: "M",
+      affix: true,
+      hidden: true,
     },
-    component: () => import('@/views/dashboard/index.vue')
-  }
-  // {
-  //   name: "userCenter",
-  //   path: "/usercenter",
-  //   meta: {
-  //     title: "个人信息",
-  //     icon: "icon-user",
-  //     type: "M",
-  //   },
-  //   component: () => import("@/views/dashboard/userCenter/index.vue"),
-  // },
+    component: "dashboard/index",
+  },
+  {
+    name: "userCenter",
+    path: "/usercenter",
+    meta: {
+      title: "个人信息",
+      icon: "icon-user",
+      type: "M",
+      hidden: true,
+    },
+    component: "dashboard/userCenter/index",
+  },
   // {
   //   name: 'appStore',
   //   path: 'https://saas.saithink.top/#/appStore',
@@ -29,12 +31,12 @@ const homePageRoutes = [
   //     type: 'L'
   //   }
   // }
-]
+];
 
 export const homePage = {
-  name: 'home',
-  path: '/dashboard',
-  meta: { title: '首页', icon: 'icon-home', hidden: false, type: 'M' }
-}
+  name: "home",
+  path: "/dashboard",
+  meta: { title: "首页", icon: "icon-home", hidden: false, type: "M" },
+};
 
-export default homePageRoutes
+export default homePageRoutes;

+ 16 - 39
src/router/webRouter.js

@@ -1,48 +1,25 @@
-// import homePageRoutes from "./homePageRoutes";
+import homePageRoutes from "./homePageRoutes";
 //系统路由
 const routes = [
   {
-    name: 'layout',
-    path: '/',
-    component: () => import('@/layout/index.vue'),
-    redirect: 'dashboard',
-    children: [
-      {
-        name: 'dashboard',
-        path: '/dashboard',
-        meta: {
-          title: '仪表盘2',
-          icon: 'icon-dashboard',
-          type: 'M',
-          affix: true
-        },
-        component: () => import('@/views/dashboard/index.vue')
-      },
-      {
-        name: 'userCenter',
-        path: '/usercenter',
-        meta: {
-          title: '个人信息',
-          icon: 'icon-user',
-          type: 'M',
-          hidden: true
-        },
-        component: () => import('@/views/dashboard/userCenter/index.vue')
-      }
-    ]
+    name: "layout",
+    path: "/",
+    component: () => import("@/layout/index.vue"),
+    redirect: "dashboard",
+    children: homePageRoutes,
   },
   {
-    name: 'login',
-    path: '/login',
-    component: () => import('@/views/login.vue'),
-    meta: { title: '登录' }
+    name: "login",
+    path: "/login",
+    component: () => import("@/views/login.vue"),
+    meta: { title: "登录" },
   },
   {
-    path: '/:pathMatch(.*)*',
+    path: "/:pathMatch(.*)*",
     hidden: true,
-    meta: { title: '访问的页面不存在' },
-    component: () => import('@/layout/404.vue')
-  }
-]
+    meta: { title: "访问的页面不存在" },
+    component: () => import("@/layout/404.vue"),
+  },
+];
 
-export default routes
+export default routes;

+ 32 - 32
src/store/modules/tag.js

@@ -1,75 +1,75 @@
-import { defineStore } from 'pinia'
-import tool from '@/utils/tool'
+import { defineStore } from "pinia";
+import tool from "@/utils/tool";
 
 const defaultTag = [
-  { name: 'dashboard', title: '仪表盘', path: '/dashboard', affix: true }
-]
-const useTagStore = defineStore('tag', {
+  { name: "dashboard", title: "仪表盘", path: "/dashboard", affix: true },
+];
+const useTagStore = defineStore("tag", {
   state: () => ({
     tags:
-      !tool.local.get('tags') || tool.local.get('tags').length === 0
+      !tool.local.get("tags") || tool.local.get("tags").length === 0
         ? defaultTag
-        : tool.local.get('tags')
+        : tool.local.get("tags"),
   }),
 
   getters: {
     getState() {
-      return { ...this.$state }
-    }
+      return { ...this.$state };
+    },
   },
 
   actions: {
     addTag(tag) {
-      const target = this.tags.find((item) => item.path === tag.path)
+      const target = this.tags.find((item) => item.path === tag.path);
       if (!target && tag.path) {
-        this.tags.push(tag)
+        this.tags.push(tag);
       }
-      this.updateTagsToLocal()
+      this.updateTagsToLocal();
     },
 
     removeTag(tag) {
-      let index = 0
+      let index = 0;
       this.tags.map((item, idx) => {
         if (item.path === tag.path && !item.affix) {
           if (this.tags[idx + 1]) {
-            index = idx
+            index = idx;
           } else if (idx > 0) {
-            index = idx - 1
+            index = idx - 1;
           }
-          this.tags.splice(idx, 1)
+          this.tags.splice(idx, 1);
         }
-      })
-      this.updateTagsToLocal()
-      return this.tags[index]
+      });
+      this.updateTagsToLocal();
+      return this.tags[index];
     },
 
     updateTag(tag) {
       this.tags.map((item) => {
         if (item.path == tag.path) {
-          item = Object.assign(item, tag)
+          item = Object.assign(item, tag);
         }
-      })
-      this.updateTagsToLocal()
+      });
+      this.updateTagsToLocal();
     },
 
     updateTagTitle(path, title) {
       this.tags.map((item) => {
         if (item.path == path) {
-          item.customTitle = title
+          item.customTitle = title;
         }
-      })
-      this.updateTagsToLocal()
+      });
+      this.updateTagsToLocal();
     },
 
     updateTagsToLocal() {
-      tool.local.set('tags', this.tags)
+      tool.local.set("tags", this.tags);
     },
 
     clearTags() {
-      this.tags = defaultTag
-      tool.local.set('tags', defaultTag)
-    }
-  }
-})
+      this.tags = defaultTag;
+      tool.local.set("tags", defaultTag);
+    },
+  },
+});
 
-export default useTagStore
+export default useTagStore;

+ 5 - 2
src/store/modules/user.js

@@ -4,7 +4,7 @@ import tool from "@/utils/tool";
 import router from "@/router";
 import webRouter from "@/router/webRouter";
 import { isUndefined } from "lodash";
-import { homePage } from "@/router/homePageRoutes";
+import homePageRoutes, { homePage } from "@/router/homePageRoutes";
 import { useAppStore, useTagStore, useDictStore } from "@/store";
 
 const useUserStore = defineStore("user", {
@@ -90,12 +90,15 @@ const useUserStore = defineStore("user", {
 
               routers = filterSystemTool(routers);
             }
+
+            routers = routers.concat(homePageRoutes);
             response.data.routers = routers;
 
             this.setInfo(response.data);
             const dictStore = useDictStore();
             await dictStore.initData();
-            // homePage.children = webRouter[0].children
+            // homePage.children = webRouter[0].children;
+            // homePage.children = webRouter[0].children;
             this.setMenu(this.routers);
             this.routers = removeButtonMenu(this.routers);
             this.routers.unshift(homePage);