mirror of
https://github.com/fugary/simple-element-plus-template.git
synced 2025-11-12 14:27:49 +00:00
优化tabs以及缓存规则
This commit is contained in:
@@ -22,17 +22,17 @@ export default [{
|
||||
component: () => import('@/views/admin/Authority.vue')
|
||||
}, {
|
||||
path: `${BASE_PATH}/menus`,
|
||||
name: 'Menus',
|
||||
name: 'MenusBase',
|
||||
children: [{
|
||||
path: '',
|
||||
name: 'menus-index',
|
||||
name: 'Menus',
|
||||
component: () => import('@/views/admin/Menus.vue')
|
||||
}, {
|
||||
path: 'edit/:id',
|
||||
name: 'menus-edit',
|
||||
name: 'MenuEdit',
|
||||
component: () => import('@/views/admin/MenuEdit.vue'),
|
||||
meta: {
|
||||
replaceTabHistory: 'menus-index',
|
||||
replaceTabHistory: 'Menus',
|
||||
labelKey: 'menu.label.menuEdit',
|
||||
icon: 'Edit'
|
||||
}
|
||||
|
||||
@@ -65,19 +65,14 @@ export const useTabsViewStore = defineStore('tabsView', () => {
|
||||
if (idx < 0) {
|
||||
const replaceIdx = historyTabs.value.findIndex(v => checkMataReplaceHistory(v, tab) ||
|
||||
checkMataReplaceHistory(tab, v) || isSameReplaceHistory(v, tab))
|
||||
let replaceTab = null
|
||||
if (replaceIdx > -1) {
|
||||
console.info(replaceIdx, historyTabs.value[replaceIdx])
|
||||
if (replaceIdx !== undefined) {
|
||||
historyTabs.value.splice(replaceIdx, 1, Object.assign({}, tab))
|
||||
return
|
||||
}
|
||||
}
|
||||
historyTabs.value.push(Object.assign({}, tab)) // 可能是Proxy,需要解析出来
|
||||
if (isCachedTabMode.value && tab.name) {
|
||||
if (!cachedTabs.value.includes(tab.name)) {
|
||||
cachedTabs.value.push(tab.name)
|
||||
}
|
||||
replaceTab = historyTabs.value[replaceIdx]
|
||||
historyTabs.value.splice(replaceIdx, 1, Object.assign({}, tab))
|
||||
} else {
|
||||
historyTabs.value.push(Object.assign({}, tab)) // 可能是Proxy,需要解析出来
|
||||
}
|
||||
addCachedTab(tab, replaceTab)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,8 +111,9 @@ export const useTabsViewStore = defineStore('tabsView', () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
const addCachedTab = (tab) => {
|
||||
if (isCachedTabMode.value && tab.name) {
|
||||
const addCachedTab = (tab, replaceTab) => {
|
||||
if (isCachedTabMode.value && tab.name && !tab.name.includes('-')) {
|
||||
removeCachedTab(replaceTab)
|
||||
if (!cachedTabs.value.includes(tab.name)) {
|
||||
cachedTabs.value.push(tab.name)
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<script setup>
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { loadAndParseMenus, loadMenuResult, useMenuFormOptions } from '@/services/menu/MenuService'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const backUrl = '/admin/menus'
|
||||
const menuDto = ref({
|
||||
id: route.params.id
|
||||
})
|
||||
@@ -35,6 +37,7 @@ const submitForm = form => {
|
||||
form.validate(valid => {
|
||||
if (valid) {
|
||||
console.log('submit', menuDto.value)
|
||||
router.push(backUrl)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -47,7 +50,7 @@ const submitForm = form => {
|
||||
:model="menuDto"
|
||||
:options="menuFormOptions"
|
||||
label-width="120px"
|
||||
back-url="/admin/menus"
|
||||
:back-url="backUrl"
|
||||
@submit-form="submitForm"
|
||||
/>
|
||||
</el-container>
|
||||
|
||||
Reference in New Issue
Block a user