style: 🎨 缩写了一些很小的 if 判断
This commit is contained in:
@@ -222,9 +222,7 @@ export default {
|
|||||||
*/
|
*/
|
||||||
update ({ state }, { tagName, title }) {
|
update ({ state }, { tagName, title }) {
|
||||||
const index = state.opened.findIndex(page => page.fullPath === tagName)
|
const index = state.opened.findIndex(page => page.fullPath === tagName)
|
||||||
if (index === 0) {
|
if (index === 0) return
|
||||||
return
|
|
||||||
}
|
|
||||||
if (title && state.opened[index]) {
|
if (title && state.opened[index]) {
|
||||||
state.opened[index].meta.title = title
|
state.opened[index].meta.title = title
|
||||||
}
|
}
|
||||||
@@ -244,10 +242,7 @@ export default {
|
|||||||
if (currentIndex > 0) {
|
if (currentIndex > 0) {
|
||||||
// 删除打开的页面 并在缓存设置中删除
|
// 删除打开的页面 并在缓存设置中删除
|
||||||
for (let i = state.opened.length - 1; i >= 0; i--) {
|
for (let i = state.opened.length - 1; i >= 0; i--) {
|
||||||
if (state.opened[i].name === 'index' || i >= currentIndex) {
|
if (state.opened[i].name === 'index' || i >= currentIndex) continue
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
commit('keepAliveRemove', state.opened[i].name)
|
commit('keepAliveRemove', state.opened[i].name)
|
||||||
state.opened.splice(i, 1)
|
state.opened.splice(i, 1)
|
||||||
}
|
}
|
||||||
@@ -272,10 +267,7 @@ export default {
|
|||||||
})
|
})
|
||||||
// 删除打开的页面 并在缓存设置中删除
|
// 删除打开的页面 并在缓存设置中删除
|
||||||
for (let i = state.opened.length - 1; i >= 0; i--) {
|
for (let i = state.opened.length - 1; i >= 0; i--) {
|
||||||
if (state.opened[i].name === 'index' || currentIndex >= i) {
|
if (state.opened[i].name === 'index' || currentIndex >= i) continue
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
commit('keepAliveRemove', state.opened[i].name)
|
commit('keepAliveRemove', state.opened[i].name)
|
||||||
state.opened.splice(i, 1)
|
state.opened.splice(i, 1)
|
||||||
}
|
}
|
||||||
@@ -299,10 +291,7 @@ export default {
|
|||||||
})
|
})
|
||||||
// 删除打开的页面数据 并更新缓存设置
|
// 删除打开的页面数据 并更新缓存设置
|
||||||
for (let i = state.opened.length - 1; i >= 0; i--) {
|
for (let i = state.opened.length - 1; i >= 0; i--) {
|
||||||
if (state.opened[i].name === 'index' || currentIndex === i) {
|
if (state.opened[i].name === 'index' || currentIndex === i) continue
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
commit('keepAliveRemove', state.opened[i].name)
|
commit('keepAliveRemove', state.opened[i].name)
|
||||||
state.opened.splice(i, 1)
|
state.opened.splice(i, 1)
|
||||||
}
|
}
|
||||||
@@ -320,10 +309,7 @@ export default {
|
|||||||
async closeAll ({ state, commit, dispatch }) {
|
async closeAll ({ state, commit, dispatch }) {
|
||||||
// 删除打开的页面 并在缓存设置中删除
|
// 删除打开的页面 并在缓存设置中删除
|
||||||
for (let i = state.opened.length - 1; i >= 0; i--) {
|
for (let i = state.opened.length - 1; i >= 0; i--) {
|
||||||
if (state.opened[i].name === 'index') {
|
if (state.opened[i].name === 'index') continue
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
commit('keepAliveRemove', state.opened[i].name)
|
commit('keepAliveRemove', state.opened[i].name)
|
||||||
state.opened.splice(i, 1)
|
state.opened.splice(i, 1)
|
||||||
}
|
}
|
||||||
@@ -395,11 +381,9 @@ export default {
|
|||||||
routes.forEach(route => {
|
routes.forEach(route => {
|
||||||
if (route.children && route.children.length > 0) {
|
if (route.children && route.children.length > 0) {
|
||||||
push(route.children)
|
push(route.children)
|
||||||
} else {
|
} else if (!route.hidden) {
|
||||||
if (!route.hidden) {
|
const { meta, name, path } = route
|
||||||
const { meta, name, path } = route
|
pool.push({ meta, name, path })
|
||||||
pool.push({ meta, name, path })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user