vue-stack-tabs 0.1.13 → 0.1.15
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/dist/vue-stack-tabs.es.js +822 -829
- package/dist/vue-stack-tabs.umd.js +7 -7
- package/package.json +1 -1
- package/src/lib/StackTabs.vue +124 -136
- package/src/lib/assets/style/transition.scss +40 -40
- package/src/lib/hooks/useStackTab.ts +1 -0
- package/src/lib/hooks/useTabLoading.ts +1 -1
- package/src/lib/hooks/useTabRouter.ts +0 -1
- package/src/lib/hooks/useTabpanel.tsx +516 -516
package/package.json
CHANGED
package/src/lib/StackTabs.vue
CHANGED
|
@@ -1,136 +1,124 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { onBeforeMount, onUnmounted, 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
|
-
const { tabs, pageShown, caches, addPage, destroy, initial,setMaxSize } = useTabpanel()
|
|
11
|
-
const emit = defineEmits(['onActive'])
|
|
12
|
-
const props = withDefaults(
|
|
13
|
-
defineProps<{
|
|
14
|
-
// 初始页签数据
|
|
15
|
-
defaultTabs?: ITabData[]
|
|
16
|
-
// 最大打开数量
|
|
17
|
-
max?: number
|
|
18
|
-
// 新页加入哪个位置
|
|
19
|
-
append?: string
|
|
20
|
-
// 右键菜单
|
|
21
|
-
contextmenu?: boolean | object
|
|
22
|
-
// 页面转场效果
|
|
23
|
-
pageTransition?: string
|
|
24
|
-
// 标签转场效果
|
|
25
|
-
tabTransition?: string | TransitionProps
|
|
26
|
-
// tab 滚动效果
|
|
27
|
-
tabScrollMode?: TabScrollMode
|
|
28
|
-
width?: string
|
|
29
|
-
height?: string
|
|
30
|
-
i18n?: { locale?: string; messages?: object }
|
|
31
|
-
messages?: any
|
|
32
|
-
reloadable?: boolean
|
|
33
|
-
closable?: boolean
|
|
34
|
-
space?: number
|
|
35
|
-
iframePath: string
|
|
36
|
-
}>(),
|
|
37
|
-
{
|
|
38
|
-
defaultTabs: () => [],
|
|
39
|
-
max: 20,
|
|
40
|
-
append: 'last',
|
|
41
|
-
contextmenu: true,
|
|
42
|
-
tabTransition: 'stack-tab-zoom',
|
|
43
|
-
pageTransition: 'stack-tab-swap',
|
|
44
|
-
tabScrollMode: TabScrollMode.BOTH,
|
|
45
|
-
width: '100%',
|
|
46
|
-
height: '100%',
|
|
47
|
-
i18n: () => ({ locale: 'zh-CN', messages: {} }),
|
|
48
|
-
reloadable: true,
|
|
49
|
-
closable: true,
|
|
50
|
-
space: 300
|
|
51
|
-
}
|
|
52
|
-
)
|
|
53
|
-
provide('locales', { ...props.i18n })
|
|
54
|
-
// 最大化,并向下传递
|
|
55
|
-
const maximum = ref<boolean>(false)
|
|
56
|
-
provide('maximum', maximum)
|
|
57
|
-
const { setIFramePath } = useStackTab()
|
|
58
|
-
setIFramePath(props.iframePath)
|
|
59
|
-
onBeforeMount(() => {
|
|
60
|
-
console.log('on Before mount')
|
|
61
|
-
initial(props.defaultTabs)
|
|
62
|
-
})
|
|
63
|
-
const tabWrapper = (route: RouteLocationNormalizedLoaded, component: VNode): DefineComponent => {
|
|
64
|
-
// return defineAsyncComponent(() => addPage(route, component))
|
|
65
|
-
return addPage(route, component)
|
|
66
|
-
}
|
|
67
|
-
const onTabActive = (id: string) => {
|
|
68
|
-
emit('onActive', id)
|
|
69
|
-
}
|
|
70
|
-
setMaxSize(props.max)
|
|
71
|
-
onUnmounted(() => {
|
|
72
|
-
destroy()
|
|
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
|
-
|
|
125
|
-
v-for="frame of tabs.filter((item) => item.iframe)"
|
|
126
|
-
v-show="frame.active && pageShown"
|
|
127
|
-
:key="frame.id"
|
|
128
|
-
class="stack-tab__iframe"
|
|
129
|
-
:src="/^(javascript|data):/i.test(frame.url ?? '') ? 'about:blank' : frame.url"
|
|
130
|
-
frameborder="0"
|
|
131
|
-
/>
|
|
132
|
-
</transition-group>
|
|
133
|
-
</div>
|
|
134
|
-
</div>
|
|
135
|
-
</template>
|
|
136
|
-
<style scoped></style>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { onBeforeMount, onUnmounted, 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
|
+
const { tabs, pageShown, caches, addPage, destroy, initial,setMaxSize } = useTabpanel()
|
|
11
|
+
const emit = defineEmits(['onActive'])
|
|
12
|
+
const props = withDefaults(
|
|
13
|
+
defineProps<{
|
|
14
|
+
// 初始页签数据
|
|
15
|
+
defaultTabs?: ITabData[]
|
|
16
|
+
// 最大打开数量
|
|
17
|
+
max?: number
|
|
18
|
+
// 新页加入哪个位置
|
|
19
|
+
append?: string
|
|
20
|
+
// 右键菜单
|
|
21
|
+
contextmenu?: boolean | object
|
|
22
|
+
// 页面转场效果
|
|
23
|
+
pageTransition?: string
|
|
24
|
+
// 标签转场效果
|
|
25
|
+
tabTransition?: string | TransitionProps
|
|
26
|
+
// tab 滚动效果
|
|
27
|
+
tabScrollMode?: TabScrollMode
|
|
28
|
+
width?: string
|
|
29
|
+
height?: string
|
|
30
|
+
i18n?: { locale?: string; messages?: object }
|
|
31
|
+
messages?: any
|
|
32
|
+
reloadable?: boolean
|
|
33
|
+
closable?: boolean
|
|
34
|
+
space?: number
|
|
35
|
+
iframePath: string
|
|
36
|
+
}>(),
|
|
37
|
+
{
|
|
38
|
+
defaultTabs: () => [],
|
|
39
|
+
max: 20,
|
|
40
|
+
append: 'last',
|
|
41
|
+
contextmenu: true,
|
|
42
|
+
tabTransition: 'stack-tab-zoom',
|
|
43
|
+
pageTransition: 'stack-tab-swap',
|
|
44
|
+
tabScrollMode: TabScrollMode.BOTH,
|
|
45
|
+
width: '100%',
|
|
46
|
+
height: '100%',
|
|
47
|
+
i18n: () => ({ locale: 'zh-CN', messages: {} }),
|
|
48
|
+
reloadable: true,
|
|
49
|
+
closable: true,
|
|
50
|
+
space: 300
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
provide('locales', { ...props.i18n })
|
|
54
|
+
// 最大化,并向下传递
|
|
55
|
+
const maximum = ref<boolean>(false)
|
|
56
|
+
provide('maximum', maximum)
|
|
57
|
+
const { setIFramePath } = useStackTab()
|
|
58
|
+
setIFramePath(props.iframePath)
|
|
59
|
+
onBeforeMount(() => {
|
|
60
|
+
console.log('on Before mount')
|
|
61
|
+
initial(props.defaultTabs)
|
|
62
|
+
})
|
|
63
|
+
const tabWrapper = (route: RouteLocationNormalizedLoaded, component: VNode): DefineComponent => {
|
|
64
|
+
// return defineAsyncComponent(() => addPage(route, component))
|
|
65
|
+
return addPage(route, component)
|
|
66
|
+
}
|
|
67
|
+
const onTabActive = (id: string) => {
|
|
68
|
+
emit('onActive', id)
|
|
69
|
+
}
|
|
70
|
+
setMaxSize(props.max)
|
|
71
|
+
onUnmounted(() => {
|
|
72
|
+
destroy()
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
</script>
|
|
76
|
+
<template>
|
|
77
|
+
<div
|
|
78
|
+
class="stack-tab"
|
|
79
|
+
:style="{
|
|
80
|
+
width: width,
|
|
81
|
+
height: height,
|
|
82
|
+
'z-index': maximum ? getMaxZIndex('body *:not(.stack-tab,.stack-tab *)') : undefined
|
|
83
|
+
}"
|
|
84
|
+
:class="{ 'stack-tab__maximum': maximum }"
|
|
85
|
+
>
|
|
86
|
+
<tab-header :space="space" @active="onTabActive" :tab-transition="tabTransition" :max="max">
|
|
87
|
+
<template #leftButton>
|
|
88
|
+
<slot name="leftButton" />
|
|
89
|
+
</template>
|
|
90
|
+
<template #rightButton>
|
|
91
|
+
<slot name="rightButton" />
|
|
92
|
+
</template>
|
|
93
|
+
</tab-header>
|
|
94
|
+
<div class="stack-tab__container">
|
|
95
|
+
<router-view v-slot="{ Component, route }">
|
|
96
|
+
<transition :name="pageTransition" @after-leave="pageShown=true" mode="out-in">
|
|
97
|
+
<keep-alive :include="caches">
|
|
98
|
+
<suspense>
|
|
99
|
+
<template #default>
|
|
100
|
+
<component
|
|
101
|
+
:is="tabWrapper(route, Component)"
|
|
102
|
+
v-if="pageShown"
|
|
103
|
+
:key="route.fullPath"
|
|
104
|
+
/>
|
|
105
|
+
</template>
|
|
106
|
+
<template #fallback> Loading.... </template>
|
|
107
|
+
</suspense>
|
|
108
|
+
</keep-alive>
|
|
109
|
+
</transition>
|
|
110
|
+
</router-view>
|
|
111
|
+
<transition-group :name="pageTransition" appear>
|
|
112
|
+
<iframe
|
|
113
|
+
v-for="frame of tabs.filter((item) => item.iframe)"
|
|
114
|
+
v-show="frame.active && pageShown"
|
|
115
|
+
:key="frame.id"
|
|
116
|
+
class="stack-tab__iframe"
|
|
117
|
+
:src="/^(javascript|data):/i.test(frame.url ?? '') ? 'about:blank' : frame.url"
|
|
118
|
+
frameborder="0"
|
|
119
|
+
/>
|
|
120
|
+
</transition-group>
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
</template>
|
|
124
|
+
<style scoped></style>
|
|
@@ -1,40 +1,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
|
-
}
|
|
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
|
+
}
|
|
@@ -9,7 +9,7 @@ export default () => {
|
|
|
9
9
|
closeTabLoading()
|
|
10
10
|
})
|
|
11
11
|
const openTabLoading = () => {
|
|
12
|
-
const container = document.querySelector(`#${attrs.tId}`)
|
|
12
|
+
const container = document.querySelector(`#${'W-'+attrs.tId}`)
|
|
13
13
|
if (loadingInstance === null) {
|
|
14
14
|
loadingInstance = $loading.show({
|
|
15
15
|
canCancel: false,
|