| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 | <template>    <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>        <div class="logo shrink" v-else>            <div class="text">运营支撑</div>        </div>        <div class="menu-wrap no-scrollbar">            <el-menu                class="sidebar-el-menu"                :default-active="onRoutes"                :collapse="collapse"                background-color="#171F32"                text-color="#aaadba"                active-text-color="#2887f2"                unique-opened                collapse-transition                router                :style="collapse ? 'width:84px' : 'width:220px'"            >                <menu-tree :menuList="menuList" :collapse="collapse" :openArray="openArray"></menu-tree>            </el-menu>        </div>        <div class="footer">            <img                :class="[collapse ? 'expandhover' : 'packuphover']"                :src="collapse ? btnCollpaseright : btnCollpaseleft"                @click="collapseChage"            />        </div>    </div></template><script>import MenuTree from './MenuTree.vue';export default {    data() {        return {            btnCollpaseright: require('@assets/img/btn_collpaseright.png'),            btnCollpaseleft: require('@assets/img/btn_collpaseleft.png'),            openList: []        };    },    components: {        MenuTree    },    computed: {        onRoutes() {            return this.$route.path;        },        collapse() {            return this.$store.getters['getCollapse'];        },        menuList() {            let list = this.$store.getters['getMenuList'];            return list;        },        openArray() {            return this.openList;        }    },    methods: {        // 侧边栏折叠        collapseChage() {            this.$store.dispatch('collapse', !this.collapse);        },        thisfindMen(arr, indexPath) {            let status = [];            arr.map((v) => {                if (v.children) {                    v.children.map((s) => {                        if ('/' + s.linkPath === indexPath) {                            status.push(v.linkPath, s.linkPath);                        }                    });                } else {                    if ('/' + v.linkPath === indexPath) {                        status.push(v.linkPath);                    }                }            });            return status;        }    },    watch: {        $route(newValue, oldValue) {            this.openList = this.thisfindMen(this.$store.getters['getMenuList'], newValue.path);        }    },    created() {        this.openList = this.thisfindMen(this.$store.getters['getMenuList'], this.$route.path);    }};</script><style  lang="scss">.sidebar {    width: 220px;    display: flex;    flex-direction: column;    background: #171f32;    border-radius: 0px 30px 30px 0px;    z-index: 2;    .logo {        width: 100%;        height: 110px;        color: #ffffff;        padding: 35px 10px 0 20px;        border-bottom: 1px solid #2a335c;        margin-bottom: 25px;        img {            width: 90px;            height: 24px;            display: inline-block;            vertical-align: middle;            margin-right: 6px;        }        .title {            font-size: 16px;            font-weight: 500;            display: inline-block;            vertical-align: middle;            background: rgba(255, 255, 255, 0.1);            border-radius: 4px;            border: 1px solid rgba(255, 255, 255, 0.4);            padding: 0px 7px;        }        .point {            width: 4px;            height: 4px;            display: inline-block;            // margin-right: 5px;            vertical-align: middle;            text-align: center;        }        .text {            width: 40px;            margin-left: -14px;        }    }    .menu-wrap {        overflow: auto;        flex: 1;        scrollbar-width: 0;    }    .menu-footer.dark {        bottom: 0;        left: 0;        width: 220px;        height: 30px;        div {            width: 100%;            height: 100%;            border-radius: 0px 0 30px 0px;            background-color: #171f32;            border: none;        }        &.dark {            background-color: #070f22 !important;            z-index: 1;        }        &.light {            background-color: #f4f7f9 !important;            z-index: 1;        }    }    .footer {        position: absolute;        bottom: 30px;        left: 20px;        z-index: 11;        width: 30px;        height: 30px;        img {            display: block;            width: 24px;            height: 24px;            cursor: pointer;        }    }}.el-menu {    border: none;}.sidebar-el-menu .el-submenu.is-opened > .el-submenu__title {    //设置一级菜单点开后的状态    color: #fff !important;    background: rgb(44, 53, 74);    border-radius: 0;}.sidebar-el-menu > .el-submenu.is-opened > .el-menu--inline > .el-submenu.is-opened > .el-submenu__title {    color: #fff !important;}.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;    .el-submenu__icon-arrow::before {        color: rgb(39, 135, 241);    }}.el-menu-item.is-active {    color: rgb(39, 135, 241);}.el-submenu.is-active > div > span {    color: rgb(39, 135, 241);}.sidebar .logo.shrink {    display: flex;    font-size: 16px;    justify-content: center;    // color: $mainTextColor;    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;    }}// .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;}.el-menu--collapse > .is-active > .el-submenu__title {    background: transparent !important;}.el-submenu > .el-submenu__title:hover {    //设置一级菜单的鼠标经过时候的样式    background: rgb(44, 53, 74) !important;    border-radius: 32px 0px 0px 32px !important;}.el-menu-item:hover {    border-radius: 32px 0px 0px 32px;}</style>
 |