ソースを参照

title全部修改

Shannon_mu 3 年 前
コミット
490a5b0d1e

+ 1 - 1
accessControlSystem/src/components/common/Sidebar.vue

@@ -1,7 +1,7 @@
 <template>
     <div class="sidebar" :style="collapse ? 'width:85px' : 'width:220px'">
         <div class="logo" v-if="!collapse">
-            <img style="width: rem(90); height: rem(24)" src="@/assets/img/img_logo2.png" />
+            <img  src="@/assets/img/img_logo2.png" />
             <div class="title"><span class="point"></span>{{ $store.getters['getThisDetai'].name || sessSetThisDetai }}</div>
         </div>
         <div class="logo shrink" v-else>

+ 0 - 1
accessControlSystem/src/main.js

@@ -43,7 +43,6 @@ Vue.use(ElementUI, {
 
 //使用钩子函数对路由进行权限跳转
 router.beforeEach((to, from, next) => {
-  debugger;
   document.title = store.getters['getThisDetai'].name || !!window.sessionStorage.getItem('setThisDetai') ? JSON.parse(window.sessionStorage.getItem('setThisDetai')).name : ''
   if (localStorage.getItem("SC_token")) {
     let menuList = window.sessionStorage.getItem("SC_listMuen")

+ 10 - 1
energyManagement/src/assets/css/public-style.scss

@@ -15,7 +15,16 @@ $ashColor: #dcdcdc;
 .ashText {
   color: $ashColor !important;
 }
-
+@function vw($size) {
+  @return ($size/19.2) * 1vw;
+}
+@function vh($size) {
+  @return ($size/10.8) * 1vh;
+}
+$base_fontSize: 100;
+@function rem($px) {
+  @return $px / $base_fontSize * 1rem;
+}
 .formContent-item_title {
   font-size: 14px;
   position: relative;

+ 1 - 0
energyManagement/src/components/common/Home.vue

@@ -77,6 +77,7 @@ export default {
     },
     created() {
         this.getElement();
+         this.$store.dispatch('SET_MENU_LIST');
         this.$store.dispatch("tags", JSON.parse(sessionStorage.getItem("tabs")) || []);
     },
     mounted() {

+ 48 - 57
energyManagement/src/components/common/Sidebar.vue

@@ -2,10 +2,10 @@
     <div class="sidebar" :style="collapse ? 'width:85px' : ''">
         <div class="logo" v-if="!collapse">
             <img src="@/assets/img/img_logo2.png" />
-            <div class="title"><span class="point"></span>能源管理</div>
+            <div class="title"><span class="point"></span>{{ $store.getters['getThisDetai'].name || sessSetThisDetai }}</div>
         </div>
         <div class="logo shrink" v-else>
-            <div class="text">能源管理</div>
+            <div class="text">{{ $store.getters['getThisDetai'].name || sessSetThisDetai }}</div>
         </div>
         <div class="menu-wrap no-scrollbar">
             {{ menuListsss }}
@@ -61,6 +61,13 @@ export default {
         },
         openArray() {
             return this.openList;
+        },
+        sessSetThisDetai() {
+            let text = '';
+            if (!!window.sessionStorage.getItem('setThisDetai')) {
+                text = JSON.parse(window.sessionStorage.getItem('setThisDetai')).name;
+            }
+            return text;
         }
     },
     methods: {
@@ -98,48 +105,49 @@ export default {
 </script>
 
 <style  lang="scss">
+@import '@assets/css/public-style.scss';
 .sidebar {
-    width: 220px;
+    width: rem(220);
     display: flex;
     flex-direction: column;
     background: #171f32;
-    border-radius: 0px 30px 30px 0px;
+    border-radius: 0px rem(30) rem(30) 0px;
     z-index: 2;
     .logo {
         width: 100%;
-        height: 110px;
+        height: rem(110);
         color: #ffffff;
-        padding: 35px 10px 0 20px;
+        padding: rem(35) rem(10) 0 rem(20);
         border-bottom: 1px solid #2a335c;
-        margin-bottom: 25px;
+        margin-bottom: rem(25);
         img {
-            width: 90px;
-            height: 24px;
+            width: rem(90);
+            height: rem(24);
             display: inline-block;
             vertical-align: middle;
-            margin-right: 6px;
+            margin-right: rem(6);
         }
         .title {
-            font-size: 16px;
+            font-size: rem(16);
             font-weight: 500;
             display: inline-block;
             vertical-align: middle;
             background: rgba(255, 255, 255, 0.1);
-            border-radius: 4px;
+            border-radius: rem(4);
             border: 1px solid rgba(255, 255, 255, 0.4);
-            padding: 0px 7px;
+            padding: 0px rem(7);
         }
         .point {
-            width: 4px;
-            height: 4px;
+            width: rem(4);
+            height: rem(4);
             display: inline-block;
             // margin-right: 5px;
             vertical-align: middle;
             text-align: center;
         }
         .text {
-            width: 40px;
-            margin-left: -14px;
+            width: rem(40);
+            margin-left: rem(-14);
         }
     }
     .menu-wrap {
@@ -150,13 +158,13 @@ export default {
     .menu-footer.dark {
         bottom: 0;
         left: 0;
-        width: 220px;
-        height: 30px;
+        width: rem(220);
+        height: rem(30);
 
         div {
             width: 100%;
             height: 100%;
-            border-radius: 0px 0 30px 0px;
+            border-radius: 0px 0 rem(30) 0px;
             background-color: #171f32;
             border: none;
         }
@@ -172,15 +180,15 @@ export default {
     }
     .footer {
         position: absolute;
-        bottom: 30px;
-        left: 20px;
+        bottom: rem(30);
+        left: rem(20);
         z-index: 11;
-        width: 30px;
-        height: 30px;
+        width: rem(30);
+        height: rem(30);
         img {
             display: block;
-            width: 24px;
-            height: 24px;
+            width: rem(24);
+            height: rem(24);
             cursor: pointer;
         }
     }
@@ -200,60 +208,43 @@ export default {
 }
 .sidebar-el-menu > div > .el-submenu.is-opened.is-active > .el-submenu__title {
     background: #2c354a !important;
-    border-radius: 32px 0px 0px 32px;
-    color: rgb(39, 135, 241) !important;
-    border-right: 2px solid #2787f1;
+    border-radius: rem(32) 0px 0px rem(32);
+    color: $mainTextColor !important;
+    border-right: 2px solid $mainTextColor;
     .el-submenu__icon-arrow::before {
-        color: rgb(39, 135, 241);
+        color: $mainTextColor;
     }
 }
 .el-menu-item.is-active {
-    color: rgb(39, 135, 241);
+    color: $mainTextColor;
 }
 .el-submenu.is-active > div > span {
-    color: rgb(39, 135, 241);
+    color: $mainTextColor;
 }
 
 .sidebar .logo.shrink {
     display: flex;
-    font-size: 16px;
+    font-size: rem(16);
     justify-content: center;
     // color: $mainTextColor;
     border-bottom: 2px solid #2a335c;
-    margin-bottom: 20px;
+    margin-bottom: rem(20);
     align-items: flex-start;
     .text {
-        width: 48px;
-        height: 48px;
+        width: rem(48);
+        height: rem(48);
         background: rgba(255, 255, 255, 0.1);
-        border-radius: 4px;
+        border-radius: rem(4);
         border: 1px solid rgba(255, 255, 255, 0.4);
         text-align: center;
     }
 }
 
-// .sidebar .logo.shrink {
-//     display: flex;
-//     justify-content: center;
-//     color: #2787f1;
-//     border-bottom: 2px solid #2a335c;
-//     margin-bottom: 20px;
-//     align-items: flex-start;
-//     .text {
-//         width: 48px;
-//         height: 48px;
-//         background: rgba(255, 255, 255, 0.1);
-//         border-radius: 4px;
-//         border: 1px solid rgba(255, 255, 255, 0.4);
-//         text-align: center;
-//     }
-// }
-
 .el-menu--collapse > .is-active {
     color: #2787f1;
 
     background: #2c354a;
-    border-radius: 32px 0px 0px 32px;
+    border-radius: rem(32) 0px 0px rem(32);
 }
 
 .el-menu--collapse > .is-active > .el-submenu__title {
@@ -262,9 +253,9 @@ export default {
 .el-submenu > .el-submenu__title:hover {
     //设置一级菜单的鼠标经过时候的样式
     background: rgb(44, 53, 74) !important;
-    border-radius: 32px 0px 0px 32px !important;
+    border-radius: rem(32) 0px 0px rem(32) !important;
 }
 .el-menu-item:hover {
-    border-radius: 32px 0px 0px 32px;
+    border-radius: rem(32) 0px 0px rem(32);
 }
 </style>

+ 62 - 23
energyManagement/src/main.js

@@ -79,39 +79,78 @@ Vue.prototype.routerLoad = {
         });
     },
     // 获取菜单
-    loadMenus() {
-        http.get('/sc-user-center/user/findUserMenu', { appId: '1003' }).then(({ status, data, msg }) => {
-            if (0 === status) {
-                store.commit('setMenuList', data[0].children)
-            }
-        });
-    }
+    // loadMenus() {
+    //     http.get('/sc-user-center/user/findUserMenu', { appId: '1003' }).then(({ status, data, msg }) => {
+    //         if (0 === status) {
+    //             store.commit('setMenuList', data[0].children)
+    //         }
+    //     });
+    // }
 };
+// router.beforeEach((to, from, next) => {
+//     document.title = store.getters['getThisDetai'].name || !!window.sessionStorage.getItem('setThisDetai') ? JSON.parse(window.sessionStorage.getItem('setThisDetai')).name : ''
+//     if (to.path !== '/404') {
+//         // console.log()
+//         let PermissionsRouter = Vue.prototype.routerLoad.findMen(store.getters.getMenuList, to.fullPath)
+//         if (PermissionsRouter) {
+//             next();
+//         } else {
+//             next({ path: 404 })
+//         }
+//         // 跳转时存储路由
+//         localStorage.setItem('path', to.fullPath)
+//     } else {
+//         next();
+//     }
+// });
 router.beforeEach((to, from, next) => {
-    if (to.path !== '/404') {
-        // console.log()
-        let PermissionsRouter = Vue.prototype.routerLoad.findMen(store.getters.getMenuList, to.fullPath)
-        if (PermissionsRouter) {
-            next();
+    document.title = store.getters['getThisDetai'].name || !!window.sessionStorage.getItem('setThisDetai') ? JSON.parse(window.sessionStorage.getItem('setThisDetai')).name : ''
+    if (localStorage.getItem("SC_token")) {
+      let menuList = window.sessionStorage.getItem("SC_listMuen")
+      let newAr = [];
+      if (menuList == null || menuList == undefined) {
+        http.get('/sc-user-center/user/findUserMenu', { appId: '1003' }).then(({ status, data, msg }) => {
+          if (0 == status) {
+            let datas = data[0].children
+            window.sessionStorage.setItem('SC_listMuen', JSON.stringify(datas))
+            window.sessionStorage.setItem('setThisDetai', JSON.stringify(data[0]))
+            store.commit('setThisDetai', data[0]);
+            funcRouter(newAr, datas, router)
+            next({ ...to, replace: true })
+          } else {
+            this.$message.error(msg);
+          }
+        })
+      } else {
+        if (router.options.routes[0].children.length == 0) {
+          funcRouter(newAr, JSON.parse(menuList), router)
+          next({ ...to, replace: true })
         } else {
-            next({ path: 404 })
+          let thisAll = JSON.parse(menuList)[0];
+          if (to.path == '/') {
+            if (!!thisAll.children) {
+              next({ path: `/${thisAll.children[0].linkPath}` })
+            } else {
+              next({ path: `/${thisAll.linkPath}` })
+            }
+          } else {
+            next()
+          }
         }
-        // 跳转时存储路由
-        localStorage.setItem('path', to.fullPath)
+      }
     } else {
-        next();
+      next();
     }
-
-});
+  });
 new Vue({
     router,
     store,
     render: h => h(App),
-    created() {
-        if (localStorage.getItem('SC_token')) {
-            this.routerLoad.loadMenus();
-        }
-    }
+    // created() {
+    //     if (localStorage.getItem('SC_token')) {
+    //         this.routerLoad.loadMenus();
+    //     }
+    // }
 }).$mount('#app');
 Vue.prototype.$http = http;
 Vue.prototype.$api = apiService(http);

+ 23 - 1
energyManagement/src/store/store.js

@@ -24,6 +24,7 @@ const store = new Vuex.Store({
     menuList: [],
     // 当前登录用户信息
     cruUserInfo: {},
+    thisDetai: {},
     //查询是否有未读消息
     messageNumber: false,
     //最近消息列表集合
@@ -86,6 +87,9 @@ const store = new Vuex.Store({
     getCruUserInfo(state) {
       return state.cruUserInfo;
     },
+    getThisDetai(state) {
+      return state.thisDetai;
+  },
     getAreaSelect(state) {
       return state.areaSelect;
     },
@@ -136,6 +140,9 @@ const store = new Vuex.Store({
     setcCruUserInfo(state, data) {
       state.cruUserInfo = data;
     },
+    setThisDetai(state, data) {
+      state.thisDetai = data;
+  },
     setmessageNumber(state, data) {
       state.messageNumber = data;
     },
@@ -239,7 +246,22 @@ const store = new Vuex.Store({
     },
     closeModal(ctx) {
       ctx.commit('setModalParams', { show: false });
-    }
+    },
+    SET_MENU_LIST(ctx) {
+      let value = ctx.getters['getMenuList'] || [];
+      if (!value.length) {
+          http.get('/sc-user-center/user/findUserMenu', { appId: '1003' }).then(({ status, data, msg }) => {
+              if (0 === status) {
+                  ctx.commit('setMenuList', data[0].children);
+                  ctx.commit('setThisDetai', data[0]);
+                  window.localStorage.setItem('SC_listMuen', JSON.stringify(data[0].children))
+                  window.sessionStorage.setItem('setThisDetai', JSON.stringify(data[0]))
+              } else {
+                  this.$message.error(msg)
+              }
+          });
+      }
+  }
   }
 })
 export default store;

+ 1 - 53
operationSupport/src/main.js

@@ -35,7 +35,6 @@ Object.keys(filter).forEach((key) => Vue.filter(key, filter[key]));
 import GeminiScrollbar from 'vue-gemini-scrollbar';
 
 Vue.use(GeminiScrollbar);
-// import VueAMap from 'vue-amap';
 
 Vue.prototype.$moment = moment;
 Vue.config.productionTip = false;
@@ -46,17 +45,6 @@ Vue.use(directived);
 Vue.use(ElementUI, {
     size: 'small'
 });
-// Vue.use(VueAMap);
-//
-// // 初始化vue-amap
-// VueAMap.initAMapApiLoader({
-//     // 高德的key
-//     key: 'def65c683e32ae89dd7f8982b433b7f8',
-//     // 插件集合
-//     plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor'],
-//     // 高德 sdk 版本,默认为 1.4.4
-//     v: '1.4.4'
-// });
 let defaultPath = '';
 Vue.prototype.routerLoad = {
     findOne(arr) {
@@ -93,28 +81,10 @@ Vue.prototype.routerLoad = {
             }
         });
     },
-    // 获取菜单
-    loadMenus() {
-        http.get('/sc-user-center/user/findUserMenu', { appId: '1002' }).then(({ status, data, msg }) => {
-            if (0 === status) {
-                store.commit('setMenuList', data[0].children);
-                if (data[0].children[0].children == null) {
-                    router.push({
-                        path: '/' + data[0].children[0].linkPath
-                    });
-                } else {
-                    router.push({
-                        path: '/' + data[0].children[0].children[0].linkPath
-                    });
-
-                }
-                store.commit('setThisDetai', data[0]);
-            }
-        });
-    }
 };
 //使用钩子函数对路由进行权限跳转
 router.beforeEach((to, from, next) => {
+    document.title = store.getters['getThisDetai'].name || !!window.sessionStorage.getItem('setThisDetai') ? JSON.parse(window.sessionStorage.getItem('setThisDetai')).name : ''
     if (localStorage.getItem("SC_token")) {
         let menuList = window.sessionStorage.getItem("SC_listMuen")
         JSON.parse
@@ -153,32 +123,10 @@ router.beforeEach((to, from, next) => {
         next();
     }
 });
-// router.beforeEach((to, from, next) => {
-//     if (to.path !== '/404') {
-//         let newa = [];
-//         console.log()
-//         Vue.prototype.routerLoad.findMen(newa, store.getters.getMenuList, to.fullPath);
-//         if (newa.length) {
-//             next();
-//         } else {
-//             next({ path: '404' });
-//         }
-//         next();
-//         // 跳转时存储路由
-//         localStorage.setItem('path', to.fullPath);
-//     } else {
-//         next();
-//     }
-// });
 new Vue({
     router,
     store,
     render: (h) => h(App),
-    // created() {
-    //     if (localStorage.getItem('SC_token')) {
-    //         this.routerLoad.loadMenus();
-    //     }
-    // }
 }).$mount('#app');
 Vue.prototype.$http = http;
 Vue.prototype.$api = apiService(http);