style: 🎨 缩写了一些很小的 if 判断

This commit is contained in:
FairyEver 2020-08-26 14:09:30 +08:00
parent 792f046bc7
commit 1c911df4a0
1 changed files with 8 additions and 24 deletions

View File

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