优化标签栏中:1.固定标签的位置;2.vuex中的actions方法
This commit is contained in:
parent
6a5a426057
commit
da1da1d4d5
@ -26,7 +26,7 @@
|
|||||||
* @version:
|
* @version:
|
||||||
* @Date: 2021-04-20 11:06:21
|
* @Date: 2021-04-20 11:06:21
|
||||||
* @LastEditors: huzhushan@126.com
|
* @LastEditors: huzhushan@126.com
|
||||||
* @LastEditTime: 2021-04-21 12:47:01
|
* @LastEditTime: 2021-04-29 10:52:41
|
||||||
* @Author: huzhushan@126.com
|
* @Author: huzhushan@126.com
|
||||||
* @HomePage: https://huzhushan.gitee.io/vue3-element-admin
|
* @HomePage: https://huzhushan.gitee.io/vue3-element-admin
|
||||||
* @Github: https://github.com/huzhushan/vue3-element-admin
|
* @Github: https://github.com/huzhushan/vue3-element-admin
|
||||||
@ -58,7 +58,7 @@ export const useContextMenu = tagList => {
|
|||||||
state.visible = false
|
state.visible = false
|
||||||
},
|
},
|
||||||
refreshSelectedTag(tag) {
|
refreshSelectedTag(tag) {
|
||||||
store.dispatch('tags/delCacheList', tag)
|
store.commit('tags/DEL_CACHE_LIST', tag)
|
||||||
const { fullPath } = tag
|
const { fullPath } = tag
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
router.replace({
|
router.replace({
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
* @version:
|
* @version:
|
||||||
* @Date: 2021-04-20 11:06:21
|
* @Date: 2021-04-20 11:06:21
|
||||||
* @LastEditors: huzhushan@126.com
|
* @LastEditors: huzhushan@126.com
|
||||||
* @LastEditTime: 2021-04-21 12:47:12
|
* @LastEditTime: 2021-04-29 11:13:55
|
||||||
* @Author: huzhushan@126.com
|
* @Author: huzhushan@126.com
|
||||||
* @HomePage: https://huzhushan.gitee.io/vue3-element-admin
|
* @HomePage: https://huzhushan.gitee.io/vue3-element-admin
|
||||||
* @Github: https://github.com/huzhushan/vue3-element-admin
|
* @Github: https://github.com/huzhushan/vue3-element-admin
|
||||||
@ -63,6 +63,7 @@ export const useTags = () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const filterAffixTags = routes => {
|
const filterAffixTags = routes => {
|
||||||
|
console.log(222, routes)
|
||||||
return routes.filter(route => isAffix(route))
|
return routes.filter(route => isAffix(route))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +72,7 @@ export const useTags = () => {
|
|||||||
|
|
||||||
for (const tag of affixTags) {
|
for (const tag of affixTags) {
|
||||||
if (tag.name) {
|
if (tag.name) {
|
||||||
store.dispatch('tags/addTagList', tag)
|
store.dispatch('tags/addTag', tag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* @version:
|
* @version:
|
||||||
* @Date: 2021-04-21 09:18:32
|
* @Date: 2021-04-21 09:18:32
|
||||||
* @LastEditors: huzhushan@126.com
|
* @LastEditors: huzhushan@126.com
|
||||||
* @LastEditTime: 2021-04-28 16:49:53
|
* @LastEditTime: 2021-04-29 11:20:14
|
||||||
* @Author: huzhushan@126.com
|
* @Author: huzhushan@126.com
|
||||||
* @HomePage: https://huzhushan.gitee.io/vue3-element-admin
|
* @HomePage: https://huzhushan.gitee.io/vue3-element-admin
|
||||||
* @Github: https://github.com/huzhushan/vue3-element-admin
|
* @Github: https://github.com/huzhushan/vue3-element-admin
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* @version:
|
* @version:
|
||||||
* @Date: 2021-04-20 11:06:21
|
* @Date: 2021-04-20 11:06:21
|
||||||
* @LastEditors: huzhushan@126.com
|
* @LastEditors: huzhushan@126.com
|
||||||
* @LastEditTime: 2021-04-28 17:40:11
|
* @LastEditTime: 2021-04-29 11:19:20
|
||||||
* @Author: huzhushan@126.com
|
* @Author: huzhushan@126.com
|
||||||
* @HomePage: https://huzhushan.gitee.io/vue3-element-admin
|
* @HomePage: https://huzhushan.gitee.io/vue3-element-admin
|
||||||
* @Github: https://github.com/huzhushan/vue3-element-admin
|
* @Github: https://github.com/huzhushan/vue3-element-admin
|
||||||
@ -16,25 +16,30 @@ const TAGLIST = 'VEA-TAGLIST'
|
|||||||
const state = {
|
const state = {
|
||||||
tagList: getItem(TAGLIST) || [],
|
tagList: getItem(TAGLIST) || [],
|
||||||
cacheList: [],
|
cacheList: [],
|
||||||
activePosition: 0,
|
activePosition: -1,
|
||||||
}
|
}
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
ADD_TAG_LIST: (state, { path, fullPath, name, meta, params, query }) => {
|
ADD_TAG_LIST: (state, { path, fullPath, name, meta, params, query }) => {
|
||||||
if (state.tagList.some(v => v.path === path)) return false
|
if (state.tagList.some(v => v.path === path)) return false
|
||||||
|
|
||||||
state.tagList.splice(
|
const target = Object.assign(
|
||||||
state.activePosition + 1,
|
{},
|
||||||
0,
|
{ path, fullPath, name, meta, params, query },
|
||||||
Object.assign(
|
{
|
||||||
{},
|
title: meta.title || '未命名',
|
||||||
{ path, fullPath, name, meta, params, query },
|
fullPath: fullPath || path,
|
||||||
{
|
}
|
||||||
title: meta.title || '未命名',
|
|
||||||
fullPath: fullPath || path,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
if (state.activePosition === -1) {
|
||||||
|
if (name === 'home') {
|
||||||
|
state.tagList.unshift(target)
|
||||||
|
} else {
|
||||||
|
state.tagList.push(target)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
state.tagList.splice(state.activePosition + 1, 0, target)
|
||||||
|
}
|
||||||
|
|
||||||
// 保存到localStorage
|
// 保存到localStorage
|
||||||
setItem(TAGLIST, state.tagList)
|
setItem(TAGLIST, state.tagList)
|
||||||
@ -107,55 +112,26 @@ const actions = {
|
|||||||
saveActivePosition({ commit }, index) {
|
saveActivePosition({ commit }, index) {
|
||||||
commit('SAVE_ACTIVE_POSITION', index)
|
commit('SAVE_ACTIVE_POSITION', index)
|
||||||
},
|
},
|
||||||
addTag({ dispatch }, tag) {
|
addTag({ commit }, tag) {
|
||||||
dispatch('addTagList', tag)
|
|
||||||
dispatch('addCacheList', tag)
|
|
||||||
},
|
|
||||||
addTagList({ commit }, tag) {
|
|
||||||
commit('ADD_TAG_LIST', tag)
|
commit('ADD_TAG_LIST', tag)
|
||||||
},
|
|
||||||
addCacheList({ commit }, tag) {
|
|
||||||
commit('ADD_CACHE_LIST', tag)
|
commit('ADD_CACHE_LIST', tag)
|
||||||
},
|
},
|
||||||
|
delTag({ commit }, tag) {
|
||||||
delTag({ dispatch }, tag) {
|
|
||||||
dispatch('delTagList', tag)
|
|
||||||
dispatch('delCacheList', tag)
|
|
||||||
},
|
|
||||||
delTagList({ commit }, tag) {
|
|
||||||
commit('DEL_TAG_LIST', tag)
|
commit('DEL_TAG_LIST', tag)
|
||||||
},
|
|
||||||
delCacheList({ commit }, tag) {
|
|
||||||
commit('DEL_CACHE_LIST', tag)
|
commit('DEL_CACHE_LIST', tag)
|
||||||
},
|
},
|
||||||
|
delOtherTags({ commit }, tag) {
|
||||||
delOtherTags({ dispatch }, tag) {
|
|
||||||
dispatch('delOtherTagList', tag)
|
|
||||||
dispatch('delOtherCacheList', tag)
|
|
||||||
},
|
|
||||||
delOtherTagList({ commit }, tag) {
|
|
||||||
commit('DEL_OTHER_TAG_LIST', tag)
|
commit('DEL_OTHER_TAG_LIST', tag)
|
||||||
},
|
|
||||||
delOtherCacheList({ commit }, tag) {
|
|
||||||
commit('DEL_OTHER_CACHE_LIST', tag)
|
commit('DEL_OTHER_CACHE_LIST', tag)
|
||||||
},
|
},
|
||||||
|
|
||||||
delSomeTags({ commit }, tags) {
|
delSomeTags({ commit }, tags) {
|
||||||
commit('DEL_SOME_TAG_LIST', tags)
|
commit('DEL_SOME_TAG_LIST', tags)
|
||||||
commit('DEL_SOME_CACHE_LIST', tags)
|
commit('DEL_SOME_CACHE_LIST', tags)
|
||||||
},
|
},
|
||||||
|
delAllTags({ commit }) {
|
||||||
delAllTags({ dispatch }) {
|
|
||||||
dispatch('delAllTagList')
|
|
||||||
dispatch('delAllCacheList')
|
|
||||||
},
|
|
||||||
delAllTagList({ commit }) {
|
|
||||||
commit('DEL_ALL_TAG_LIST')
|
commit('DEL_ALL_TAG_LIST')
|
||||||
},
|
|
||||||
delAllCacheList({ commit }) {
|
|
||||||
commit('DEL_ALL_CACHE_LIST')
|
commit('DEL_ALL_CACHE_LIST')
|
||||||
},
|
},
|
||||||
|
|
||||||
updateTagList({ commit }, { path, fullPath, name, meta, params, query }) {
|
updateTagList({ commit }, { path, fullPath, name, meta, params, query }) {
|
||||||
commit('UPDATE_TAG_LIST', { path, fullPath, name, meta, params, query })
|
commit('UPDATE_TAG_LIST', { path, fullPath, name, meta, params, query })
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user