| | |
| | | const collapsed = ref(false); |
| | | const router = useRouter(); |
| | | let routerCache = ref([]); |
| | | let routerCacheMap = ref(new Map()); |
| | | let routerCacheList = ref([]); |
| | | let currentCache = ref(null); |
| | | let isRouterAlive = ref(true); |
| | | const menuCache = ref([]); |
| | |
| | | } |
| | | |
| | | function menuSelect(item) { |
| | | console.log(item.key); |
| | | router.push({ |
| | | path: item.key |
| | | }) |
| | | |
| | | let name = item.item.name; |
| | | currentCache.value = name; |
| | | // console.log(routerCache.value); |
| | | |
| | | if (name != undefined && routerCache.value.indexOf(name) == -1) { |
| | | routerCache.value.push(item.item.name) |
| | | routerCacheMap.value.set(name, item.key) |
| | | routerCacheList.value.push({ |
| | | key: item.key, |
| | | languageId: item.item.languageId, |
| | | name: item.item.name, |
| | | }) |
| | | } |
| | | } |
| | | |
| | | function closeTabs(name) { |
| | | function closeTabs(param) { |
| | | let name = param.name; |
| | | let tmp = [] |
| | | let tmpList = []; |
| | | routerCache.value.forEach((item) => { |
| | | if (item != name) { |
| | | tmp.push(item); |
| | | } |
| | | }) |
| | | |
| | | routerCacheList.value.forEach((item) => { |
| | | if (item.name != name) { |
| | | tmpList.push(item); |
| | | } |
| | | }) |
| | | |
| | | console.log(tmpList); |
| | | |
| | | if (tmp == 0) { |
| | | router.push({ |
| | | path: '/' |
| | | }) |
| | | routerCache.value.push('home') |
| | | routerCacheMap.value.set('home', '/') |
| | | routerCacheList.value.push({ |
| | | key: '/', |
| | | languageId: 'common.home', |
| | | name: '主页', |
| | | }) |
| | | selectedKeys.value = ['/'] |
| | | } else { |
| | | switchTabs(tmp[0]); |
| | | switchTabs(tmpList[0]); |
| | | } |
| | | routerCache.value = tmp; |
| | | routerCacheList.value = tmpList; |
| | | } |
| | | |
| | | function reloadTabs() { |
| | |
| | | } |
| | | } |
| | | |
| | | function switchTabs(name) { |
| | | function switchTabs(item) { |
| | | router.push({ |
| | | path: routerCacheMap.value.get(name) |
| | | path: item.key |
| | | }) |
| | | |
| | | currentCache.value = name; |
| | | selectedKeys.value = [routerCacheMap.value.get(name)] |
| | | |
| | | // console.log(routerCacheMap, name, routerCacheMap.value.get(name)); |
| | | |
| | | currentCache.value = item.name; |
| | | selectedKeys.value = [item.key] |
| | | } |
| | | |
| | | const switchLocale = (locale) => { |
| | | globalState.locale = locale; |
| | | localStorage.setItem('locale', locale) |
| | | reloadTabs() |
| | | console.log(locale); |
| | | } |
| | | |
| | | </script> |
| | |
| | | <template #title> |
| | | <span> |
| | | <component :is="components[ref(item.icon).value]" /> |
| | | {{ item.name }} |
| | | {{ formatMessage(item.languageId, item.name) }} |
| | | </span> |
| | | </template> |
| | | <div v-for="(child, idx) in item.children"> |
| | | <a-menu-item v-if="child.status == 1" :key="child.route" :name="child.name"> |
| | | {{ child.name }} |
| | | <a-menu-item v-if="child.status == 1" :key="child.route" :name="child.name" :languageId="child.languageId"> |
| | | {{ formatMessage(child.languageId, child.name) }} |
| | | </a-menu-item> |
| | | </div> |
| | | </a-sub-menu> |
| | |
| | | </a-layout-header> |
| | | <a-layout-content class="content-view"> |
| | | <div class="tabs-fixed"> |
| | | <div v-for="(item, index) in routerCache" :key="index" @click="switchTabs(item)" class="tabs-item" |
| | | :class="currentCache == item ? 'tabs-item-active' : ''"> |
| | | <div :class="currentCache == item ? '' : 'tabs-item-reload-none'" @click="reloadTabs" @click.stop> |
| | | <div v-for="(item, index) in routerCacheList" :key="index" @click="switchTabs(item)" class="tabs-item" |
| | | :class="currentCache == item.name ? 'tabs-item-active' : ''"> |
| | | <div :class="currentCache == item.name ? '' : 'tabs-item-reload-none'" @click="reloadTabs" @click.stop> |
| | | <RedoOutlined /> |
| | | </div> |
| | | <div>{{ item }}</div> |
| | | <div>{{ formatMessage(item.languageId, item.name) }}</div> |
| | | <div @click="closeTabs(item)" @click.stop> |
| | | <CloseOutlined /> |
| | | </div> |