Ver Fonte

chore: 调整首页布局&配置不同角色跳转首页

cfofpp há 6 meses atrás
pai
commit
f09f7faf97

+ 5 - 1
src/permission.js

@@ -30,7 +30,11 @@ router.beforeEach((to, from, next) => {
             store.dispatch("GenerateRoutes").then((accessRoutes) => {
               // 根据roles权限生成可访问的路由表
               router.addRoutes(accessRoutes); // 动态添加可访问路由表
-              next({ ...to, replace: true }); // hack方法 确保addRoutes已完成
+              next({
+                path: accessRoutes.length ? accessRoutes[0].path : to.path,
+                replace: true,
+              });
+              // next({ ...to, replace: true }); // hack方法 确保addRoutes已完成
             });
           })
           .catch((err) => {

+ 15 - 14
src/router/index.js

@@ -74,6 +74,7 @@ export const constantRoutes = [
   {
     path: "",
     component: Layout,
+    hidden: true,
     redirect: "index",
     meta: { title: "首页", icon: "dashboard", affix: true },
     children: [
@@ -113,20 +114,20 @@ export const constantRoutes = [
       },
     ],
   },
-  // {
-  //   path: "/home",
-  //   name: "home",
-  //   hidden: true,
-  //   component: Layout,
-  //   children: [
-  //     {
-  //       path: "/home/index",
-  //       component: () => import("@/views/home/index"),
-  //       name: "home",
-  //       meta: { title: "首页" },
-  //     },
-  //   ],
-  // },
+  {
+    path: "/home",
+    name: "home",
+    hidden: true,
+    component: Layout,
+    children: [
+      {
+        path: "/home/index",
+        component: () => import("@/views/home/index"),
+        name: "home",
+        meta: { title: "首页" },
+      },
+    ],
+  },
   {
     path: "/secure",
     name: "secure",

+ 2 - 2
src/views/home/components/map/index.vue

@@ -7,7 +7,7 @@
       <el-button @click="back" type="text">返回></el-button>
     </div>
     <div style="display: flex; justify-content: space-between; height: 100%">
-      <div id="hy-map" style="width: 65%; height: 90%"></div>
+      <div id="hy-map" style="width: 65%; height: 97%"></div>
       <div class="item-container">
         <div class="item" v-for="(ite, i) in itemData" :key="i">
           <div class="val">121</div>
@@ -184,7 +184,7 @@ export default {
 <style lang="scss" scoped>
 .item-container {
   // height: 20%;
-  height: 90%;
+  height: 97%;
   display: flex;
   flex-wrap: wrap;
   align-items: center;

+ 2 - 2
src/views/home/index.vue

@@ -96,10 +96,10 @@ export default {
   height: 100%;
 }
 .h-40 {
-  height: calc(40% - 5px);
+  height: calc(33% - 5px);
 }
 .h-60 {
-  height: calc(60% - 5px);
+  height: calc(67% - 5px);
 }
 .h-48 {
   height: calc(50% - 5px);

+ 2 - 7
src/views/index.vue

@@ -1,12 +1,6 @@
 <template>
-  <div
-    class="content"
-    :style="{ padding: $store.state.user.homeType === 1 ? '0px' : '15px 15p' }"
-  >
+  <div class="content">
     <div v-if="$store.state.user.homeType === 1">
-      <mapHome />
-    </div>
-    <div v-else>
       <el-form
         :model="queryParams"
         class="demo-ruleForm"
@@ -111,6 +105,7 @@
         </el-card>
       </div>
     </div>
+    <div v-else>首页暂无数据...</div>
   </div>
 </template>
 <script>