首页优化及路由

main
MY-SH\lenovo 10 months ago
parent 274ee08d6b
commit 9f748f183d

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 KiB

@ -1,30 +1,35 @@
<template> <template>
<el-menu <div class="bj">
:default-active="activeMenu" <div class="masking">
mode="horizontal" <el-menu
@select="handleSelect" :default-active="activeMenu"
> mode="horizontal"
<template v-for="(item, index) in topMenus"> @select="handleSelect"
<el-menu-item class="_elMenu"
:style="{ '--theme': theme } " >
:index="item.path" <template v-for="(item, index) in topMenus">
:key="index" <el-menu-item
> :key="index"
<!-- <svg-icon :index="item.path"
v-if="item.meta && item.meta.icon && item.meta.icon !== '#'" :style="{ '--theme': theme } "
:icon-class="item.meta.icon" >
/> --> <!-- <svg-icon
<img :src="item.meta.img" style="height: 40px; width:auto;" alt=""> v-if="item.meta && item.meta.icon && item.meta.icon !== '#'"
{{ item.meta.title }} :icon-class="item.meta.icon"
</el-menu-item> /> -->
</template> <img :src="item.meta.img" alt="" style="height: 40px; width:auto;">
{{ item.meta.title }}
</el-menu> </el-menu-item>
</template>
</el-menu >
</div>
</div>
</template> </template>
<script> <script>
import { constantRoutes } from "@/router"; import {constantRoutes} from "@/router";
import { eventBus } from '@/main.js'; import {eventBus} from '@/main.js';
// //
const hideList = ["/index", "/user/profile"]; const hideList = ["/index", "/user/profile"];
@ -37,18 +42,18 @@ export default {
// index // index
currentIndex: undefined, currentIndex: undefined,
img1:require('../assets/images/icon/menu (6).png'), img1: require('../assets/images/icon/menu (6).png'),
img2:require('../assets/images/icon/menu (10).png'), img2: require('../assets/images/icon/menu (10).png'),
img3:require('../assets/images/icon/menu (2).png'), img3: require('../assets/images/icon/menu (2).png'),
img4:require('../assets/images/icon/menu (7).png'), img4: require('../assets/images/icon/menu (7).png'),
img5:require('../assets/images/xzzf.png'), img5: require('../assets/images/xzzf.png'),
img6:require('../assets/images/icon/menu (8).png'), img6: require('../assets/images/icon/menu (8).png'),
img7:require('../assets/images/icon/menu (9).png'), img7: require('../assets/images/icon/menu (9).png'),
img8:require('../assets/images/icon/menu (1).png'), img8: require('../assets/images/icon/menu (1).png'),
img9:require('../assets/images/icon/menu (11).png'), img9: require('../assets/images/icon/menu (11).png'),
img10:require('../assets/images/icon/menu (5).png'), img10: require('../assets/images/icon/menu (5).png'),
img11:require('../assets/images/icon/menu (12).png'), img11: require('../assets/images/icon/menu (12).png'),
img12:require('../assets/images/icon/menu (4).png'), img12: require('../assets/images/icon/menu (4).png'),
}; };
}, },
computed: { computed: {
@ -59,12 +64,23 @@ export default {
// //
topMenus() { topMenus() {
let topMenus = []; let topMenus = [];
//let imgArr= [this.img1,this.img2,this.img3,this.img4,this.img5,this.img6,this.img7,this.img8,this.img9,this.img10,this.img11,this.img12] //let imgArr= [this.img1,this.img2,this.img3,this.img4,this.img5,this.img6,this.img7,this.img8,this.img9,this.img10,this.img11,this.img12]
let imgArr = {"/ehsRisk":this.img1,"/ehsMaterial":this.img2,"/ehsDocu":this.img3,"/ehsTeam":this.img4,"/ehsLawEnforce":this.img5, let imgArr = {
"/ehsNoticeMessage":this.img6,"/enterprise":this.img7,"/ehsNoticeMessage1":this.img8,"/ehsHiddenDangerMenu":this.img9, "/ehsRisk": this.img1,
"/system":this.img10,"/monitor":this.img11,"/tool":this.img12} ; "/ehsMaterial": this.img2,
"/ehsDocu": this.img3,
"/ehsTeam": this.img4,
"/ehsLawEnforce": this.img5,
"/ehsNoticeMessage": this.img6,
"/enterprise": this.img7,
"/ehsNoticeMessage1": this.img8,
"/ehsHiddenDangerMenu": this.img9,
"/system": this.img10,
"/monitor": this.img11,
"/tool": this.img12
};
this.routers.map((menu,index) => { this.routers.map((menu, index) => {
if (menu.hidden !== true) { if (menu.hidden !== true) {
console.log(menu.path); console.log(menu.path);
// //
@ -132,15 +148,15 @@ export default {
// this.openAlert(); // this.openAlert();
// this.openMaterialMsg(); // this.openMaterialMsg();
}, },
/* mounted() { /* mounted() {
//get1 //get1
//this.timer = setTimeout(this.get, 1000); //this.timer = setTimeout(this.get, 1000);
},*/ },*/
// //
/* beforeDestroy() { /* beforeDestroy() {
clearTimeout(this.timer); clearTimeout(this.timer);
},*/ },*/
methods: { methods: {
@ -157,15 +173,35 @@ export default {
const routeMenu = this.childrenMenus.find((item) => item.path === key); const routeMenu = this.childrenMenus.find((item) => item.path === key);
if (routeMenu && routeMenu.query) { if (routeMenu && routeMenu.query) {
let query = JSON.parse(routeMenu.query); let query = JSON.parse(routeMenu.query);
this.$router.push({ path: key, query: query }); this.$router.push({path: key, query: query});
} else { } else {
this.$router.push({ path: key }); this.$router.push({path: key});
} }
this.$store.dispatch("app/toggleSideBarHide", true); this.$store.dispatch("app/toggleSideBarHide", true);
} else { } else {
// //
this.activeRoutes(key); this.activeRoutes(key);
this.$store.dispatch("app/toggleSideBarHide", false); this.$store.dispatch("app/toggleSideBarHide", false);
let myRoutes = [];
if (this.childrenMenus && this.childrenMenus.length > 0) {
this.childrenMenus.map((item) => {
if (key == item.parentPath || (key == "index" && "" == item.path)) {
myRoutes.push(item);
}
});
}
setTimeout(() => {
if(myRoutes[0].path != this.$route.path) {
this.$router.replace({
path: myRoutes[0].path
})
} else {
this.$router.replace({
path: '/index'
})
}
}, 100)
} }
}, },
// //
@ -192,26 +228,42 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.bj{
background-image: url("../assets/images/indexBj.png");
background-size: 100% 100%;
background-repeat: no-repeat;
height: calc(100vh - 120px);
}
.masking{
height: 100%;
background: rgba(255, 255, 255, 85%);
}
.el-menu-item { .el-menu-item {
display: block; display: flex;
text-align: center; text-align: center;
width: 20%; width: 20%;
line-height: 100px; line-height: 20px;
height: auto; height: 100px;
border: 1px solid #c1c1c1 !important; border: 1px solid #c1c1c1 !important;
color: #494848; color: #494848;
font-weight: 600; font-weight: 600;
font-size: 17px; font-size: 17px;
letter-spacing: 1px; letter-spacing: 1px;
flex-direction: row;
flex-wrap: wrap;
align-content: center;
align-items: center;
justify-content: center;
white-space: normal;
word-break: break-all;
} }
.el-menu.el-menu--horizontal { .el-menu.el-menu--horizontal {
border-bottom: transparent; border-bottom: transparent;
// margin-left: 45px; // margin-left: 45px;
// margin-top: 40px; // margin-top: 40px;
width: 95%; width: 95%;
margin: 30px auto; margin: 30px auto;
} }
.el-menu-item.is-active { .el-menu-item.is-active {
@ -221,4 +273,20 @@ export default {
.el-message { .el-message {
min-width: 580px; min-width: 580px;
} }
ul.el-menu--horizontal.el-menu{
background: transparent;
}
li.el-menu-item{
background: rgb(255 255 255 / 60%);
word-wrap: break-word;
overflow-wrap: break-word;
}
_elMenu{
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-content: center;
align-items: center;
}
</style> </style>

Loading…
Cancel
Save