侧边切换存储当前项 #94

Merged
zhangqi merged 1 commits from zq-sliderDev into master 1 day ago
  1. 2
      src/components/SliderScond.vue
  2. 5
      src/router/index.js
  3. 9
      src/store/index.js

2
src/components/SliderScond.vue

@ -81,6 +81,7 @@ export default {
let subtitle = this.renderKeyNew.subtitle;
this.activeFloor = newVal[this.curIndex]?.list?.[0][subtitle];
this.componentsName = newVal[this.curIndex]?.list?.[0]?.componentsName || '';
store.commit('SET_CURRENTMENUITEM', newVal[this.curIndex]?.list?.[0]);
}
},
mounted() {
@ -183,6 +184,7 @@ export default {
// }, 1000)
// }
setActiveCur(item1, item, index) {
store.commit('SET_CURRENTMENUITEM', item1);
this.curIndex = index;
let subtitle = this.renderKeyNew.subtitle;
let domName = this.renderKeyNew.domName;

5
src/router/index.js

@ -564,6 +564,11 @@ router.beforeEach((to, from, next) => {
next();
});
router.afterEach(() => {
// 清除存储的currentMenuItem
if(!store.state.showSecondSide && store.state.currentMenuItem){
store.commit('SET_CURRENTMENUITEM',null);
}
// 添加延迟确保过渡效果
setTimeout(() => {
store.dispatch('hideLoading')

9
src/store/index.js

@ -18,6 +18,7 @@ export default new Vuex.Store({
isLoading: false, //页面loading
customize: false, //页面loading
componentsName:'',
currentMenuItem:null,
slidermenu:[],
rankMenuData: [{
index: '1',
@ -558,8 +559,16 @@ export default new Vuex.Store({
}) {
commit('SET_COMPONENTS_NAME')
},
SET_CURRENTMENUITEM({
commit
}) {
commit('SET_CURRENTMENUITEM')
},
},
mutations: {
SET_CURRENTMENUITEM(state,data){
state.currentMenuItem = JSON.parse(JSON.stringify(data));
},
SET_COMPONENTS_NAME(state,name){
state.componentsName = name;
},

Loading…
Cancel
Save