vue-stack-tabs 0.1.36 → 0.1.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/favicon.svg +9 -9
- package/dist/src/lib/StackTabs.vue.d.ts +131 -49
- package/dist/src/lib/components/ContextMenu/ContextMenuItem.vue.d.ts +3 -12
- package/dist/src/lib/components/ContextMenu/index.vue.d.ts +6 -30
- package/dist/src/lib/components/PageLoading.vue.d.ts +3 -12
- package/dist/src/lib/components/TabHeader/TabHeaderButton.vue.d.ts +4 -29
- package/dist/src/lib/components/TabHeader/TabHeaderItem.vue.d.ts +7 -16
- package/dist/src/lib/components/TabHeader/TabHeaderScroll.vue.d.ts +5 -30
- package/dist/src/lib/components/TabHeader/index.vue.d.ts +8 -38
- package/dist/src/lib/hooks/useContextMenu.d.ts +3 -2
- package/dist/src/lib/hooks/useStackTab.d.ts +5 -2
- package/dist/src/lib/hooks/useTabMitt.d.ts +3 -2
- package/dist/src/lib/hooks/useTabRouter.d.ts +2 -1
- package/dist/src/lib/hooks/useTabpanel.d.ts +26 -6
- package/dist/src/lib/i18n/index.d.ts +1 -1
- package/dist/src/lib/iframe.vue.d.ts +1 -1
- package/dist/src/lib/index.d.ts +8 -8
- package/dist/src/lib/utils/TabIdHelper.d.ts +2 -1
- package/dist/src/lib/utils/TabScrollHelper.d.ts +3 -3
- package/dist/style.css +1 -1
- package/dist/vue-stack-tabs.es.js +1355 -1508
- package/dist/vue-stack-tabs.umd.js +2 -3
- package/package.json +49 -52
- package/src/lib/StackTabs.vue +135 -124
- package/src/lib/assets/style/transition.scss +62 -40
- package/src/lib/hooks/useStackTab.ts +119 -112
- package/src/lib/hooks/useTabRouter.ts +103 -99
- package/src/lib/hooks/useTabpanel.tsx +685 -684
- package/src/lib/utils/TabIdHelper.ts +70 -70
package/src/lib/StackTabs.vue
CHANGED
|
@@ -1,124 +1,135 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { onBeforeMount, onBeforeUnmount, provide, ref
|
|
3
|
-
import type { TransitionProps, DefineComponent, VNode } from 'vue'
|
|
4
|
-
import { type RouteLocationNormalizedLoaded
|
|
5
|
-
import { getMaxZIndex } from './utils/TabScrollHelper'
|
|
6
|
-
import { type ITabData, TabScrollMode } from './model/TabModel'
|
|
7
|
-
import TabHeader from './components/TabHeader/index.vue'
|
|
8
|
-
import useTabpanel from './hooks/useTabpanel'
|
|
9
|
-
import useStackTab from './hooks/useStackTab'
|
|
10
|
-
import { useI18n } from 'vue-i18n-lite'
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { onBeforeMount, onBeforeUnmount, provide, ref } from 'vue'
|
|
3
|
+
import type { TransitionProps, DefineComponent, VNode } from 'vue'
|
|
4
|
+
import { type RouteLocationNormalizedLoaded } from 'vue-router'
|
|
5
|
+
import { getMaxZIndex } from './utils/TabScrollHelper'
|
|
6
|
+
import { type ITabData, TabScrollMode } from './model/TabModel'
|
|
7
|
+
import TabHeader from './components/TabHeader/index.vue'
|
|
8
|
+
import useTabpanel from './hooks/useTabpanel'
|
|
9
|
+
import useStackTab from './hooks/useStackTab'
|
|
10
|
+
import { useI18n } from 'vue-i18n-lite'
|
|
11
|
+
import { useEmitter } from '@/lib/hooks/useTabMitt'
|
|
12
|
+
const { tabs, pageShown, caches, destroy, addPage, initial, setMaxSize, setGlobalScroll } =
|
|
13
|
+
useTabpanel()
|
|
14
|
+
const emit = defineEmits(['onActive', 'onPageLoaded'])
|
|
15
|
+
const props = withDefaults(
|
|
16
|
+
defineProps<{
|
|
17
|
+
// 初始页签数据
|
|
18
|
+
defaultTabs?: ITabData[]
|
|
19
|
+
// 最大打开数量
|
|
20
|
+
max?: number
|
|
21
|
+
// 新页加入哪个位置
|
|
22
|
+
append?: string
|
|
23
|
+
// 右键菜单
|
|
24
|
+
contextmenu?: boolean | object
|
|
25
|
+
// 页面转场效果
|
|
26
|
+
pageTransition?: string
|
|
27
|
+
pageTransitionBack?: string
|
|
28
|
+
// 标签转场效果
|
|
29
|
+
tabTransition?: string | TransitionProps
|
|
30
|
+
// tab 滚动效果
|
|
31
|
+
tabScrollMode?: TabScrollMode
|
|
32
|
+
width?: string
|
|
33
|
+
height?: string
|
|
34
|
+
i18n?: string
|
|
35
|
+
space?: number
|
|
36
|
+
globalScroll: boolean
|
|
37
|
+
iframePath: string
|
|
38
|
+
}>(),
|
|
39
|
+
{
|
|
40
|
+
defaultTabs: () => [],
|
|
41
|
+
max: 20,
|
|
42
|
+
append: 'last',
|
|
43
|
+
contextmenu: true,
|
|
44
|
+
tabTransition: 'stack-tab-zoom',
|
|
45
|
+
pageTransition: 'stack-tab-swap',
|
|
46
|
+
pageTransitionBack: 'stack-tab-swap-back',
|
|
47
|
+
tabScrollMode: TabScrollMode.BOTH,
|
|
48
|
+
width: '100%',
|
|
49
|
+
height: '100%',
|
|
50
|
+
i18n: 'zh-CN',
|
|
51
|
+
space: 300,
|
|
52
|
+
globalScroll: false
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
// provide('locales', { ...props.i18n })
|
|
56
|
+
// 最大化,并向下传递
|
|
57
|
+
const { changeLocale } = useI18n()
|
|
58
|
+
const maximum = ref<boolean>(false)
|
|
59
|
+
provide('maximum', maximum)
|
|
60
|
+
const { setIFramePath } = useStackTab()
|
|
61
|
+
setIFramePath(props.iframePath)
|
|
62
|
+
setGlobalScroll(props.globalScroll)
|
|
63
|
+
changeLocale(props.i18n)
|
|
64
|
+
onBeforeMount(() => {
|
|
65
|
+
console.log('on Before mount')
|
|
66
|
+
initial(props.defaultTabs)
|
|
67
|
+
})
|
|
68
|
+
const tabWrapper = (route: RouteLocationNormalizedLoaded, component: VNode): DefineComponent => {
|
|
69
|
+
// return defineAsyncComponent(() => addPage(route, component))
|
|
70
|
+
return addPage(route, component)
|
|
71
|
+
}
|
|
72
|
+
const onTabActive = (id: string) => {
|
|
73
|
+
emit('onActive', id)
|
|
74
|
+
}
|
|
75
|
+
setMaxSize(props.max)
|
|
76
|
+
onBeforeUnmount(() => {
|
|
77
|
+
destroy()
|
|
78
|
+
})
|
|
79
|
+
const onComponentLoaded = () => {
|
|
80
|
+
emit('onPageLoaded')
|
|
81
|
+
}
|
|
82
|
+
const pageSwitch = ref<string>(props.pageTransition)
|
|
83
|
+
const emitter = useEmitter()
|
|
84
|
+
emitter.on('FORWARD', () => {
|
|
85
|
+
pageSwitch.value = props.pageTransition
|
|
86
|
+
})
|
|
87
|
+
emitter.on('BACKWARD', () => {
|
|
88
|
+
pageSwitch.value = props.pageTransitionBack
|
|
89
|
+
})
|
|
90
|
+
</script>
|
|
91
|
+
<template>
|
|
92
|
+
<div
|
|
93
|
+
class="stack-tab"
|
|
94
|
+
:style="{
|
|
95
|
+
width: width,
|
|
96
|
+
height: height,
|
|
97
|
+
'z-index': maximum ? getMaxZIndex('body *:not(.stack-tab,.stack-tab *)') : undefined
|
|
98
|
+
}"
|
|
99
|
+
:class="{ 'stack-tab__maximum': maximum }"
|
|
100
|
+
>
|
|
101
|
+
<tab-header :space="space" @active="onTabActive" :tab-transition="tabTransition" :max="max">
|
|
102
|
+
<template #leftButton>
|
|
103
|
+
<slot name="leftButton" />
|
|
104
|
+
</template>
|
|
105
|
+
<template #rightButton>
|
|
106
|
+
<slot name="rightButton" />
|
|
107
|
+
</template>
|
|
108
|
+
</tab-header>
|
|
109
|
+
<div class="stack-tab__container">
|
|
110
|
+
<router-view v-slot="{ Component, route }">
|
|
111
|
+
<transition :name="pageSwitch" appear mode="out-in">
|
|
112
|
+
<keep-alive :include="caches">
|
|
113
|
+
<component
|
|
114
|
+
:is="tabWrapper(route, Component)"
|
|
115
|
+
v-if="pageShown"
|
|
116
|
+
:key="route.fullPath"
|
|
117
|
+
@on-loaded="onComponentLoaded"
|
|
118
|
+
/>
|
|
119
|
+
</keep-alive>
|
|
120
|
+
</transition>
|
|
121
|
+
</router-view>
|
|
122
|
+
<transition-group :name="pageTransition" appear>
|
|
123
|
+
<iframe
|
|
124
|
+
v-for="frame of tabs.filter((item) => item.iframe)"
|
|
125
|
+
v-show="frame.active"
|
|
126
|
+
:key="frame.id"
|
|
127
|
+
class="stack-tab__iframe"
|
|
128
|
+
:src="/^(javascript|data):/i.test(frame.url ?? '') ? 'about:blank' : frame.url"
|
|
129
|
+
frameborder="0"
|
|
130
|
+
/>
|
|
131
|
+
</transition-group>
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
</template>
|
|
135
|
+
<style scoped></style>
|
|
@@ -1,40 +1,62 @@
|
|
|
1
|
-
/*
|
|
2
|
-
transition 过渡样式
|
|
3
|
-
*/
|
|
4
|
-
.stack-tab-zoom {
|
|
5
|
-
&-enter-active,
|
|
6
|
-
&-leave-active {
|
|
7
|
-
transition: all 0.3s ease-in-out;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
&-enter-from,
|
|
11
|
-
&-leave-to {
|
|
12
|
-
transform: scale(0);
|
|
13
|
-
opacity: 0;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/*
|
|
18
|
-
页面交换
|
|
19
|
-
*/
|
|
20
|
-
.stack-tab-swap {
|
|
21
|
-
$trans: 30px;
|
|
22
|
-
|
|
23
|
-
&-enter-active,
|
|
24
|
-
&-leave-active {
|
|
25
|
-
transition: all 0.3s ease-in-out;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
&-enter-from,
|
|
29
|
-
&-leave-to {
|
|
30
|
-
opacity: 0;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
&-enter-from {
|
|
34
|
-
transform: translateX(
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
&-leave-to {
|
|
38
|
-
transform: translateX(
|
|
39
|
-
}
|
|
40
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
transition 过渡样式
|
|
3
|
+
*/
|
|
4
|
+
.stack-tab-zoom {
|
|
5
|
+
&-enter-active,
|
|
6
|
+
&-leave-active {
|
|
7
|
+
transition: all 0.3s ease-in-out;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
&-enter-from,
|
|
11
|
+
&-leave-to {
|
|
12
|
+
transform: scale(0);
|
|
13
|
+
opacity: 0;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
页面交换
|
|
19
|
+
*/
|
|
20
|
+
.stack-tab-swap {
|
|
21
|
+
$trans: 30px;
|
|
22
|
+
|
|
23
|
+
&-enter-active,
|
|
24
|
+
&-leave-active {
|
|
25
|
+
transition: all 0.3s ease-in-out;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&-enter-from,
|
|
29
|
+
&-leave-to {
|
|
30
|
+
opacity: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&-enter-from {
|
|
34
|
+
transform: translateX($trans);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&-leave-to {
|
|
38
|
+
transform: translateX(-$trans);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.stack-tab-swap-back {
|
|
43
|
+
$trans: 30px;
|
|
44
|
+
|
|
45
|
+
&-enter-active,
|
|
46
|
+
&-leave-active {
|
|
47
|
+
transition: all 0.3s ease-in-out;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&-enter-from,
|
|
51
|
+
&-leave-to {
|
|
52
|
+
opacity: 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&-enter-from {
|
|
56
|
+
transform: translateX(-$trans);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&-leave-to {
|
|
60
|
+
transform: translateX($trans);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -1,112 +1,119 @@
|
|
|
1
|
-
import { useRouter } from 'vue-router'
|
|
2
|
-
import useTabpanel from '../hooks/useTabpanel'
|
|
3
|
-
import { throttle } from '
|
|
4
|
-
import type { ITabData } from '../model/TabModel'
|
|
5
|
-
import { defu } from 'defu'
|
|
6
|
-
|
|
7
|
-
import { encodeTabInfo } from '../utils/TabIdHelper'
|
|
8
|
-
import { uriDecode } from '../utils/UriHelper'
|
|
9
|
-
import { ulid } from '
|
|
10
|
-
import { MittType, useEmitter } from './useTabMitt'
|
|
11
|
-
import { nextTick } from 'vue'
|
|
12
|
-
|
|
13
|
-
let iframePath: string
|
|
14
|
-
export default () => {
|
|
15
|
-
const router = useRouter()
|
|
16
|
-
const { active, hasTab, pageShown, reset, canAddTab, renewTab, getTab } = useTabpanel()
|
|
17
|
-
const emitter = useEmitter()
|
|
18
|
-
/**
|
|
19
|
-
* 打开新的TAB页面
|
|
20
|
-
* @param tab
|
|
21
|
-
* @param to
|
|
22
|
-
*/
|
|
23
|
-
const openNewTab = throttle((tab: ITabData, renew = false) => {
|
|
24
|
-
return new Promise((resolve, reject) => {
|
|
25
|
-
if (!pageShown.value) {
|
|
26
|
-
reject()
|
|
27
|
-
return
|
|
28
|
-
}
|
|
29
|
-
const tabInfo = defu(tab, {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
tabInfo.id
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
// activeTab =
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
// }
|
|
78
|
-
//
|
|
79
|
-
toPage(tab, tabInfo)
|
|
80
|
-
resolve(tabInfo.id)
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
path =
|
|
100
|
-
query
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
path
|
|
104
|
-
query
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
1
|
+
import { useRouter } from 'vue-router'
|
|
2
|
+
import useTabpanel from '../hooks/useTabpanel'
|
|
3
|
+
import { throttle } from 'throttle-debounce'
|
|
4
|
+
import type { ITabData } from '../model/TabModel'
|
|
5
|
+
import { defu } from 'defu'
|
|
6
|
+
|
|
7
|
+
import { encodeTabInfo } from '../utils/TabIdHelper'
|
|
8
|
+
import { uriDecode } from '../utils/UriHelper'
|
|
9
|
+
import { ulid } from 'ulid'
|
|
10
|
+
import { MittType, useEmitter } from './useTabMitt'
|
|
11
|
+
import { nextTick } from 'vue'
|
|
12
|
+
|
|
13
|
+
let iframePath: string
|
|
14
|
+
export default () => {
|
|
15
|
+
const router = useRouter()
|
|
16
|
+
const { active, hasTab, pageShown, reset, canAddTab, renewTab, getTab } = useTabpanel()
|
|
17
|
+
const emitter = useEmitter()
|
|
18
|
+
/**
|
|
19
|
+
* 打开新的TAB页面
|
|
20
|
+
* @param tab
|
|
21
|
+
* @param to
|
|
22
|
+
*/
|
|
23
|
+
const openNewTab = throttle(500, (tab: ITabData, renew = false) => {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
if (!pageShown.value) {
|
|
26
|
+
reject()
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
const tabInfo = defu(tab, {
|
|
30
|
+
refreshable: true,
|
|
31
|
+
closable: true,
|
|
32
|
+
iframe: false
|
|
33
|
+
})
|
|
34
|
+
if (tabInfo.id && renew && hasTab(tabInfo.id!)) {
|
|
35
|
+
renewTab(tab)
|
|
36
|
+
const currentTab = getTab(tab.id!)
|
|
37
|
+
// if current tab is active, then must reload the component of router view for complete remove the cache!!!
|
|
38
|
+
if (currentTab?.active) {
|
|
39
|
+
pageShown.value = false
|
|
40
|
+
nextTick(() => {
|
|
41
|
+
pageShown.value = true
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* In the function of openNewTab, if the tab already 'ACTIVE' then do nothing.
|
|
47
|
+
*/
|
|
48
|
+
if (hasTab(tabInfo.id!) && !renew) {
|
|
49
|
+
emitter.emit(MittType.TAB_ACTIVE, { id: tabInfo.id! })
|
|
50
|
+
// active(tabInfo.id!)
|
|
51
|
+
resolve(tabInfo.id)
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
if (!tabInfo.id) {
|
|
55
|
+
tabInfo.id = ulid()
|
|
56
|
+
}
|
|
57
|
+
if (!canAddTab()) {
|
|
58
|
+
reject('Max Size')
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// if (initialed) {
|
|
63
|
+
// // 增加tab
|
|
64
|
+
// let activeTab: ITabItem | null = null
|
|
65
|
+
// for (const tab of unref(tabs)) {
|
|
66
|
+
// tab.active = false
|
|
67
|
+
// }
|
|
68
|
+
// activeTab = {
|
|
69
|
+
// id: tabInfo.id!,
|
|
70
|
+
// title: tabInfo.title,
|
|
71
|
+
// closable: tabInfo.closable!,
|
|
72
|
+
// refreshable: tabInfo.refreshable!,
|
|
73
|
+
// iframe: tabInfo.iframe!,
|
|
74
|
+
// url: tabInfo.iframe ? tab.path : null,
|
|
75
|
+
// active: true,
|
|
76
|
+
// pages: new Stack<ITabPage>()
|
|
77
|
+
// } as ITabItem
|
|
78
|
+
// addTab(activeTab).finally(() => {
|
|
79
|
+
// toPage(tab, tabInfo)
|
|
80
|
+
// resolve(tabInfo.id)
|
|
81
|
+
// })
|
|
82
|
+
// } else {
|
|
83
|
+
toPage(tab, tabInfo)
|
|
84
|
+
resolve(tabInfo.id)
|
|
85
|
+
// }
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
const toPage = (tab: ITabData, tabInfo: any) => {
|
|
89
|
+
const __tab = encodeTabInfo(tabInfo)
|
|
90
|
+
let query = defu(
|
|
91
|
+
{
|
|
92
|
+
__tab
|
|
93
|
+
},
|
|
94
|
+
tab.query
|
|
95
|
+
) as Record<string, string>
|
|
96
|
+
let path
|
|
97
|
+
if (!tab.iframe) {
|
|
98
|
+
const url = uriDecode(tab.path)
|
|
99
|
+
path = url.path
|
|
100
|
+
query = defu(url.query, query)
|
|
101
|
+
} else {
|
|
102
|
+
const __src = encodeURIComponent(tab.path as string)
|
|
103
|
+
path = iframePath
|
|
104
|
+
query['__src'] = __src
|
|
105
|
+
}
|
|
106
|
+
router.push({
|
|
107
|
+
path,
|
|
108
|
+
query
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
const setIFramePath = (path: string) => {
|
|
112
|
+
iframePath = path
|
|
113
|
+
}
|
|
114
|
+
const getWrapper = () =>{
|
|
115
|
+
return document.getElementsByClassName('cache-page-wrapper')[0]
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return { openNewTab, setIFramePath, active, reset,getWrapper }
|
|
119
|
+
}
|