diff --git a/src/config/website.js b/src/config/website.js index e2c2efa..d9de2be 100644 --- a/src/config/website.js +++ b/src/config/website.js @@ -31,7 +31,7 @@ export default { screenshot: true, fullscreen: false, theme: true, - menu: false, + menu: true, styleRadio:'1',//风格样式 }, //首页配置 diff --git a/src/page/index/index.vue b/src/page/index/index.vue index 8393924..5137836 100644 --- a/src/page/index/index.vue +++ b/src/page/index/index.vue @@ -4,7 +4,7 @@
- +
@@ -54,6 +54,7 @@ export default { provide() { return { index: this, + leftMenu:[] }; }, computed: { @@ -65,6 +66,8 @@ export default { 'isSearch', 'menu', 'setting', + 'leftMenu', + 'selectIndex','selectedIndex' ]), validSidebar() { return !( @@ -77,9 +80,52 @@ export default { }, props: [], methods: { + //打开菜单 风格2 + openMenu2(item = {}) { + if(!item.id){ + this.$store.dispatch('GetMenu', item.id).then(data => { + if (data.length !== 0) { + this.$router.$avueRouter.formatRoutes(data, true); + } + //当点击顶部菜单后默认打开第一个菜单 + /*if (!this.validatenull(item)) { + let itemActive = {}, + childItemActive = 0; + if (item.path) { + itemActive = item; + } else { + if (this.menu[childItemActive].length === 0) { + itemActive = this.menu[childItemActive]; + } else { + itemActive = this.menu[childItemActive].children[childItemActive]; + } + } + this.$store.commit('SET_MENU_ID', item); + this.$router.push({ + path: this.$router.$avueRouter.getPath({ + name: (itemActive.label || itemActive.name), + src: itemActive.path + }, itemActive.meta) + }); + }*/ + }); + }else{ + if (item.children.length !== 0) { + this.$store.commit('SET_LEFT_MENU', item.children); + let tmpIndex = item.children.findIndex(item1 => item1.id == this.selectedIndex) + let index = tmpIndex == -1 ? 0 : tmpIndex + this.$store.commit('SET_SELECT_INDEX', index); + // setStore({ name: 'left_menu', content: item.children }); + // this.$router.$avueRouter.formatRoutes(item.children, true); + } + } + + }, //打开菜单 openMenu(item = {}) { this.$store.dispatch('GetMenu', item.id).then(data => { + console.log('data=================',data) + console.log('item.id--------------------',item.id) if (data.length !== 0) { this.$router.$avueRouter.formatRoutes(data, true); } diff --git a/src/page/index/sidebar/index.vue b/src/page/index/sidebar/index.vue index 0dc4ad6..7e3485d 100644 --- a/src/page/index/sidebar/index.vue +++ b/src/page/index/sidebar/index.vue @@ -1,30 +1,69 @@ + diff --git a/src/page/index/top/index.vue b/src/page/index/top/index.vue index 01527ee..c1b45a5 100644 --- a/src/page/index/top/index.vue +++ b/src/page/index/top/index.vue @@ -10,28 +10,28 @@
- +
-
+
-
+ + + +
diff --git a/src/page/index/top/top-menu.vue b/src/page/index/top/top-menu.vue index bd351a6..9ace926 100644 --- a/src/page/index/top/top-menu.vue +++ b/src/page/index/top/top-menu.vue @@ -1,5 +1,5 @@ + diff --git a/src/store/getters.js b/src/store/getters.js index 3edda43..4a3084e 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -29,6 +29,10 @@ const getters = { menuId: state => state.user.menuId, menu: state => state.user.menu, menuAll: state => state.user.menuAll, + leftMenu: state => state.user.leftMenu, + activeIndex:state => state.user.activeIndex, + selectIndex:state => state.user.selectIndex, + selectedIndex:state => state.user.selectedIndex, logsList: state => state.logs.logsList, logsLen: state => state.logs.logsList.length || 0, logsFlag: (state, getters) => getters.logsLen === 0, diff --git a/src/store/modules/common.js b/src/store/modules/common.js index 507143b..121680c 100644 --- a/src/store/modules/common.js +++ b/src/store/modules/common.js @@ -11,7 +11,7 @@ const common = { isRefresh: true, isLock: getStore({ name: 'isLock' }), colorName: getStore({ name: 'colorName' }) || '#2C77F1', - themeName: getStore({ name: 'themeName' }) || 'theme-go', + themeName: getStore({ name: 'themeName' }) || 'theme-white', lockPasswd: getStore({ name: 'lockPasswd' }) || '', website: website, setting: website.setting, diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 32a22b0..c107316 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -35,7 +35,12 @@ const user = { menuAll: getStore({ name: 'menuAll' }) || [], token: getStore({ name: 'token' }) || '', refreshToken: getStore({ name: 'refreshToken' }) || '', - }, + leftMenu:getStore({name:'leftMenu'}) || [], + activeIndex:getStore({name:'activeIndex'}) || '', + selectedIndex:getStore({name:'selectedIndex'}) || '', + selectIndex:getStore({name:'selectIndex'}) || 0, + }, + actions: { //根据用户名登录 LoginByUsername({ commit }, userInfo = {}) { @@ -226,6 +231,8 @@ const user = { .then(() => { commit('SET_TOKEN', ''); commit('SET_MENU_ALL_NULL', []); + commit('SET_LEFT_MENU', []); + commit('SET_ACTIVE_INDEX', ''); commit('SET_MENU', []); commit('SET_ROLES', []); commit('DEL_ALL_TAG', []); @@ -245,6 +252,8 @@ const user = { return new Promise(resolve => { commit('SET_TOKEN', ''); commit('SET_MENU_ALL_NULL', []); + commit('SET_LEFT_MENU', []); + commit('SET_ACTIVE_INDEX', ''); commit('SET_MENU', []); commit('SET_ROLES', []); commit('DEL_ALL_TAG', []); @@ -269,6 +278,7 @@ const user = { const data = res.data.data; let menu = deepClone(data); menu.forEach(ele => formatPath(ele, true)); + console.log('setMenu--------------------------------',menu) commit('SET_MENU', menu); commit('SET_MENU_ALL', menu); dispatch('GetButtons'); @@ -358,6 +368,22 @@ const user = { state.menu = menu; setStore({ name: 'menu', content: state.menu }); }, + SET_LEFT_MENU:(state,leftMenu) =>{ + state.leftMenu = leftMenu + setStore({name:'leftMenu',leftMenu}) + }, + SET_ACTIVE_INDEX:(state,activeIndex) =>{ + state.activeIndex = activeIndex + setStore({name:'activeIndex',content:activeIndex}) + }, + SET_SELECT_INDEX:(state,selectIndex) =>{ + state.selectIndex = selectIndex + setStore({name:'selectIndex',content:selectIndex}) + }, + SET_SELECTED_INDEX:(state,selectedIndex) =>{ + state.selectedIndex = selectedIndex + setStore({name:'selectedIndex',content:selectedIndex}) + }, SET_ROLES: (state, roles) => { state.roles = roles; }, diff --git a/src/styles/top.scss b/src/styles/top.scss index ddb4cbb..347a88d 100644 --- a/src/styles/top.scss +++ b/src/styles/top.scss @@ -47,7 +47,7 @@ .top-search { line-height: variables.$top_height; position: absolute !important; - right: 200px; + right: 160px; top: 0; width: 300px;