|
@@ -8,7 +8,7 @@ import {
|
|
computed,
|
|
computed,
|
|
// ref,
|
|
// ref,
|
|
unref,
|
|
unref,
|
|
- onMounted,
|
|
|
|
|
|
+ // onMounted,
|
|
toRaw,
|
|
toRaw,
|
|
} from 'vue';
|
|
} from 'vue';
|
|
import { Tabs } from 'ant-design-vue';
|
|
import { Tabs } from 'ant-design-vue';
|
|
@@ -24,7 +24,7 @@ import { tabStore } from '/@/store/modules/tab';
|
|
import { closeTab } from './useTabDropdown';
|
|
import { closeTab } from './useTabDropdown';
|
|
import router from '/@/router';
|
|
import router from '/@/router';
|
|
import { useTabs } from '/@/hooks/web/useTabs';
|
|
import { useTabs } from '/@/hooks/web/useTabs';
|
|
-import { PageEnum } from '/@/enums/pageEnum';
|
|
|
|
|
|
+// import { PageEnum } from '/@/enums/pageEnum';
|
|
|
|
|
|
import './index.less';
|
|
import './index.less';
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
@@ -33,14 +33,17 @@ export default defineComponent({
|
|
let isAddAffix = false;
|
|
let isAddAffix = false;
|
|
const go = useGo();
|
|
const go = useGo();
|
|
const { currentRoute } = useRouter();
|
|
const { currentRoute } = useRouter();
|
|
- const { addTab, activeKeyRef } = useTabs();
|
|
|
|
- onMounted(() => {
|
|
|
|
- const route = unref(currentRoute);
|
|
|
|
- addTab(unref(currentRoute).path as PageEnum, false, {
|
|
|
|
- query: route.query,
|
|
|
|
- params: route.params,
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
|
|
+ const {
|
|
|
|
+ // addTab,
|
|
|
|
+ activeKeyRef,
|
|
|
|
+ } = useTabs();
|
|
|
|
+ // onMounted(() => {
|
|
|
|
+ // const route = unref(currentRoute);
|
|
|
|
+ // addTab(unref(currentRoute).path as PageEnum, false, {
|
|
|
|
+ // query: route.query,
|
|
|
|
+ // params: route.params,
|
|
|
|
+ // });
|
|
|
|
+ // });
|
|
|
|
|
|
// 当前激活tab
|
|
// 当前激活tab
|
|
// const activeKeyRef = ref<string>('');
|
|
// const activeKeyRef = ref<string>('');
|
|
@@ -64,14 +67,14 @@ export default defineComponent({
|
|
// 监听路由的话虽然可以,但是路由切换的时间会造成卡顿现象?
|
|
// 监听路由的话虽然可以,但是路由切换的时间会造成卡顿现象?
|
|
// 使用useTab的addTab的话,当用户手动调转,需要自行调用addTab
|
|
// 使用useTab的addTab的话,当用户手动调转,需要自行调用addTab
|
|
// tabStore.commitAddTab((unref(currentRoute) as unknown) as AppRouteRecordRaw);
|
|
// tabStore.commitAddTab((unref(currentRoute) as unknown) as AppRouteRecordRaw);
|
|
- // const { affix } = currentRoute.value.meta || {};
|
|
|
|
- // if (affix) return;
|
|
|
|
- // const hasInTab = tabStore.getTabsState.some(
|
|
|
|
- // (item) => item.fullPath === currentRoute.value.fullPath
|
|
|
|
- // );
|
|
|
|
- // if (!hasInTab) {
|
|
|
|
- // tabStore.commitAddTab((unref(currentRoute) as unknown) as AppRouteRecordRaw);
|
|
|
|
- // }
|
|
|
|
|
|
+ const { affix } = currentRoute.value.meta || {};
|
|
|
|
+ if (affix) return;
|
|
|
|
+ const hasInTab = tabStore.getTabsState.some(
|
|
|
|
+ (item) => item.fullPath === currentRoute.value.fullPath
|
|
|
|
+ );
|
|
|
|
+ if (!hasInTab) {
|
|
|
|
+ tabStore.commitAddTab((unref(currentRoute) as unknown) as AppRouteRecordRaw);
|
|
|
|
+ }
|
|
},
|
|
},
|
|
{
|
|
{
|
|
immediate: true,
|
|
immediate: true,
|