From 1e1ffaa4c545d786dab97aec2c33c044a3b0d625 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com>
Date: Tue, 13 May 2025 15:45:58 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E9=A6=96=E9=A1=B5=EF=BC=8C?=
 =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E7=AC=AC=E4=B8=80=E4=B8=AA=E5=8A=A8=E6=80=81?=
 =?UTF-8?q?=E8=B7=AF=E7=94=B1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ruoyi-ui/src/components/Breadcrumb/index.vue  |  4 +--
 .../src/layout/components/Sidebar/Logo.vue    | 11 +++++---
 .../src/layout/components/TagsView/index.vue  | 14 ++++++++---
 ruoyi-ui/src/permission.js                    | 25 +++++++++++++++++--
 ruoyi-ui/src/plugins/tab.js                   |  3 ++-
 ruoyi-ui/src/router/index.js                  |  4 +--
 ruoyi-ui/src/store/modules/permission.js      | 23 +++++++++++++++--
 ruoyi-ui/src/utils/request.js                 |  3 ++-
 ruoyi-ui/src/views/error/401.vue              |  8 +++++-
 ruoyi-ui/src/views/index.vue                  | 20 +++++++++------
 ruoyi-ui/src/views/login.vue                  |  2 +-
 11 files changed, 91 insertions(+), 26 deletions(-)

diff --git a/ruoyi-ui/src/components/Breadcrumb/index.vue b/ruoyi-ui/src/components/Breadcrumb/index.vue
index 1fbae5f3..976aaff8 100644
--- a/ruoyi-ui/src/components/Breadcrumb/index.vue
+++ b/ruoyi-ui/src/components/Breadcrumb/index.vue
@@ -34,9 +34,9 @@ export default {
       let matched = this.$route.matched.filter(item => item.meta && item.meta.title)
       const first = matched[0]
 
-      if (!this.isDashboard(first)) {
+ /*     if (!this.isDashboard(first)) {
         matched = [{ path: '/index', meta: { title: '首页' }}].concat(matched)
-      }
+      }*/
 
       this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false)
     },
diff --git a/ruoyi-ui/src/layout/components/Sidebar/Logo.vue b/ruoyi-ui/src/layout/components/Sidebar/Logo.vue
index efd7c782..d1523722 100644
--- a/ruoyi-ui/src/layout/components/Sidebar/Logo.vue
+++ b/ruoyi-ui/src/layout/components/Sidebar/Logo.vue
@@ -1,11 +1,11 @@
 <template>
   <div class="sidebar-logo-container" :class="{'collapse':collapse}" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }">
     <transition name="sidebarLogoFade">
-      <router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/">
+      <router-link v-if="collapse" key="collapse" class="sidebar-logo-link" :to="indexPage">
         <img v-if="logo" :src="logo" class="sidebar-logo" />
         <h1 v-else class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1>
       </router-link>
-      <router-link v-else key="expand" class="sidebar-logo-link" to="/">
+      <router-link v-else key="expand" class="sidebar-logo-link" :to="indexPage">
         <img v-if="logo" :src="logo" class="sidebar-logo" />
         <h1 class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1>
       </router-link>
@@ -16,7 +16,7 @@
 <script>
 import logoImg from '@/assets/logo/logo.png'
 import variables from '@/assets/styles/variables.scss'
-
+import {mapState} from 'vuex'
 export default {
   name: 'SidebarLogo',
   props: {
@@ -31,7 +31,10 @@ export default {
     },
 	sideTheme() {
       return this.$store.state.settings.sideTheme
-    }
+    },
+    ...mapState({
+      indexPage: state => state.permission.indexPage
+    })
   },
   data() {
     return {
diff --git a/ruoyi-ui/src/layout/components/TagsView/index.vue b/ruoyi-ui/src/layout/components/TagsView/index.vue
index 20c4b55e..54a25761 100644
--- a/ruoyi-ui/src/layout/components/TagsView/index.vue
+++ b/ruoyi-ui/src/layout/components/TagsView/index.vue
@@ -31,6 +31,7 @@
 <script>
 import ScrollPane from './ScrollPane'
 import path from 'path'
+import {mapState} from 'vuex'
 
 export default {
   components: { ScrollPane },
@@ -52,7 +53,10 @@ export default {
     },
     theme() {
       return this.$store.state.settings.theme;
-    }
+    },
+    ...mapState({
+      indexPage: state => state.permission.indexPage
+    })
   },
   watch: {
     $route() {
@@ -83,7 +87,11 @@ export default {
       };
     },
     isAffix(tag) {
-      return tag.meta && tag.meta.affix
+      if (tag.fullPath == this.indexPage) {
+        return true
+      } else {
+        return tag.meta && tag.meta.affix
+      }
     },
     isFirstView() {
       try {
@@ -200,7 +208,7 @@ export default {
           // to reload home page
           this.$router.replace({ path: '/redirect' + view.fullPath })
         } else {
-          this.$router.push('/')
+          this.$router.push(this.indexPage)
         }
       }
     },
diff --git a/ruoyi-ui/src/permission.js b/ruoyi-ui/src/permission.js
index bd182b5c..c2eac29e 100644
--- a/ruoyi-ui/src/permission.js
+++ b/ruoyi-ui/src/permission.js
@@ -27,8 +27,29 @@ router.beforeEach((to, from, next) => {
           store.dispatch('GenerateRoutes').then(accessRoutes => {
             // 根据roles权限生成可访问的路由表
             router.addRoutes(accessRoutes) // 动态添加可访问路由表
-            next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
-          })
+            let path = '';
+
+            path = accessRoutes[0].path + accessRoutes[0].children[0].path //获取第一路由路径
+            if (accessRoutes[0].children[0].query !== undefined) { //如果当前路由存在路由参数,则带入
+              let query = JSON.parse(accessRoutes[0].children[0].query);
+              let temp = '';
+              for (var val in query) {
+                if (temp.length == 0) {
+                  temp = "?";
+                } else {
+                  temp = temp + "&";
+                }
+                temp = temp + val + "=" + query[val];
+              }
+              path = path + temp;
+            }
+            var temp = {...to, replace: true};
+            var curPath = temp.path;
+            if (from.path == '/login' || curPath == "/" ) {
+              next({path, replace: true}) // hack方法 确保addRoutes已完成
+            } else {
+              next(temp) // hack方法 确保addRoutes已完成
+            }          })
         }).catch(err => {
           store.dispatch('LogOut').then(() => {
             Message.error(err)
diff --git a/ruoyi-ui/src/plugins/tab.js b/ruoyi-ui/src/plugins/tab.js
index 4a69cf11..7833eb83 100644
--- a/ruoyi-ui/src/plugins/tab.js
+++ b/ruoyi-ui/src/plugins/tab.js
@@ -31,9 +31,10 @@ export default {
   },
   // 关闭指定tab页签
   closePage(obj) {
+    let indexPage = store.state.permission.indexPage;
     if (obj === undefined) {
       return store.dispatch('tagsView/delView', router.currentRoute).then(({ lastPath }) => {
-        return router.push(lastPath || '/');
+        return router.push(lastPath || indexPage);
       });
     }
     return store.dispatch('tagsView/delView', obj);
diff --git a/ruoyi-ui/src/router/index.js b/ruoyi-ui/src/router/index.js
index 9969deab..d6644df8 100644
--- a/ruoyi-ui/src/router/index.js
+++ b/ruoyi-ui/src/router/index.js
@@ -68,7 +68,7 @@ export const constantRoutes = [
     hidden: true
   },
   /** 支付路由结束 */
-  {
+/*  {
     path: '',
     component: Layout,
     redirect: 'index',
@@ -80,7 +80,7 @@ export const constantRoutes = [
         meta: { title: '首页', icon: 'dashboard', affix: true }
       }
     ]
-  },
+  },*/
   {
     path: '/user',
     component: Layout,
diff --git a/ruoyi-ui/src/store/modules/permission.js b/ruoyi-ui/src/store/modules/permission.js
index cd471a4b..edd16c58 100644
--- a/ruoyi-ui/src/store/modules/permission.js
+++ b/ruoyi-ui/src/store/modules/permission.js
@@ -11,7 +11,8 @@ const permission = {
     addRoutes: [],
     defaultRoutes: [],
     topbarRouters: [],
-    sidebarRouters: []
+    sidebarRouters: [],
+    indexPage: '',
   },
   mutations: {
     SET_ROUTES: (state, routes) => {
@@ -29,6 +30,9 @@ const permission = {
       }]
       state.topbarRouters = routes.concat(index);
     },
+    SET_INDEX_PAGE: (state, routes) => {
+      state.indexPage = routes
+    },
     SET_SIDEBAR_ROUTERS: (state, routes) => {
       state.sidebarRouters = routes
     },
@@ -38,9 +42,23 @@ const permission = {
     GenerateRoutes({ commit }) {
       return new Promise(resolve => {
         // 向后端请求路由数据
-        getRouters(1).then(res => {
+        getRouters().then(res => {
           const sdata = JSON.parse(JSON.stringify(res.data))
           const rdata = JSON.parse(JSON.stringify(res.data))
+          let indexdata = res.data[0].path + "/" + res.data[0].children[0].path
+          if (res.data[0].children[0].query !== undefined) { //如果当前路由存在路由参数,则带入
+            let query = JSON.parse(res.data[0].children[0].query);
+            let temp = '';
+            for (var val in query) {
+              if (temp.length == 0) {
+                temp = "?";
+              } else {
+                temp = temp + "&";
+              }
+              temp = temp + val + "=" + query[val];
+            }
+            indexdata = indexdata + temp;
+          }
           const sidebarRoutes = filterAsyncRouter(sdata)
           const rewriteRoutes = filterAsyncRouter(rdata, false, true)
           const asyncRoutes = filterDynamicRoutes(dynamicRoutes);
@@ -50,6 +68,7 @@ const permission = {
           commit('SET_SIDEBAR_ROUTERS', constantRoutes.concat(sidebarRoutes))
           commit('SET_DEFAULT_ROUTES', sidebarRoutes)
           commit('SET_TOPBAR_ROUTES', sidebarRoutes)
+          commit('SET_INDEX_PAGE', indexdata)
           resolve(rewriteRoutes)
         })
       })
diff --git a/ruoyi-ui/src/utils/request.js b/ruoyi-ui/src/utils/request.js
index 9db73fdd..eba49395 100644
--- a/ruoyi-ui/src/utils/request.js
+++ b/ruoyi-ui/src/utils/request.js
@@ -103,7 +103,8 @@ service.interceptors.response.use(res => {
         ).then(() => {
           isRelogin.show = false;
           store.dispatch('LogOut').then(() => {
-            location.href = '/index';
+            let indexurl = store.state.permission.indexPage
+            location.href = indexurl;
           })
         }).catch(() => {
           isRelogin.show = false;
diff --git a/ruoyi-ui/src/views/error/401.vue b/ruoyi-ui/src/views/error/401.vue
index 448b6ecd..f3b7023b 100644
--- a/ruoyi-ui/src/views/error/401.vue
+++ b/ruoyi-ui/src/views/error/401.vue
@@ -12,7 +12,7 @@
         <h6>对不起,您没有访问权限,请不要进行非法操作!您可以返回主页面</h6>
         <ul class="list-unstyled">
           <li class="link-type">
-            <router-link to="/">
+            <router-link :to="indexPage">
               回首页
             </router-link>
           </li>
@@ -27,6 +27,7 @@
 
 <script>
 import errGif from '@/assets/401_images/401.gif'
+import {mapState} from "vuex";
 
 export default {
   name: 'Page401',
@@ -35,6 +36,11 @@ export default {
       errGif: errGif + '?' + +new Date()
     }
   },
+ computed: {
+   ...mapState({
+     indexPage: state => state.permission.indexPage
+   }),
+ },
   methods: {
     back() {
       if (this.$route.query.noGoBack) {
diff --git a/ruoyi-ui/src/views/index.vue b/ruoyi-ui/src/views/index.vue
index fd0206b9..bc8458bb 100644
--- a/ruoyi-ui/src/views/index.vue
+++ b/ruoyi-ui/src/views/index.vue
@@ -701,7 +701,7 @@ export default {
     /************************************ 设备消息 **************************************/
     /** 时间按钮选项 */
     timeDimensionChange() {
-      /*if (this.messageMonitorTimeDimension === 'day') {
+      if (this.messageMonitorTimeDimension === 'day') {
         this.messageMonitorTimePick = this.getTodayTime()
         const params = {
           time: '1h',
@@ -763,7 +763,7 @@ export default {
 
         this.getMessageMonitorData(params, 'received_message')
         this.getMessageMonitorData(params, 'sent_message')
-      }*/
+      }
 
     },
     /** 设备消息char初始化 */
@@ -1056,11 +1056,17 @@ export default {
 </script>
 
 <style lang="scss" scoped>
-.meter-chart {
-  height: 200px;
-}
 
-.meter-title {
-  font-size: 20px
+.app-container {
+  padding: 20px 5px 10px 5px;
+
+  .meter-chart {
+    height: 200px;
+  }
+
+  .meter-title {
+    font-size: 20px
+  }
 }
+
 </style>
diff --git a/ruoyi-ui/src/views/login.vue b/ruoyi-ui/src/views/login.vue
index ca269990..91eedf44 100644
--- a/ruoyi-ui/src/views/login.vue
+++ b/ruoyi-ui/src/views/login.vue
@@ -200,7 +200,7 @@ export default {
             Cookies.remove("password");
             Cookies.remove("rememberMe");
           }
-          
+
           if(this.captchaOnOff && 'behavioral' === this.captchaType){
             this.$refs.verify.show();
           }else{