vue-stack-tabs 0.1.8 → 0.1.10
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/style.css +1 -1
- package/dist/vue-stack-tabs.es.js +727 -757
- package/dist/vue-stack-tabs.umd.js +10 -10
- package/package.json +4 -4
- package/src/lib/StackTabs.vue +126 -127
- package/src/lib/assets/style/common/mixins.scss +45 -45
- package/src/lib/assets/style/common/var.scss +65 -65
- package/src/lib/assets/style/icon.scss +93 -93
- package/src/lib/assets/style/index.scss +4 -4
- package/src/lib/assets/style/overlayer.scss +40 -40
- package/src/lib/assets/style/stackTab.scss +395 -395
- package/src/lib/assets/style/transition.scss +40 -40
- package/src/lib/banner.ts +51 -51
- package/src/lib/components/ContextMenu/ContextMenuItem.vue +15 -15
- package/src/lib/components/ContextMenu/index.vue +129 -128
- package/src/lib/components/OverlayLoading/Component.vue +191 -188
- package/src/lib/components/OverlayLoading/api.ts +31 -31
- package/src/lib/components/OverlayLoading/helpers.ts +31 -31
- package/src/lib/components/OverlayLoading/index.ts +12 -12
- package/src/lib/components/OverlayLoading/loaders/bars.vue +79 -79
- package/src/lib/components/OverlayLoading/loaders/dots.vue +92 -92
- package/src/lib/components/OverlayLoading/loaders/index.ts +9 -9
- package/src/lib/components/OverlayLoading/loaders/spinner.vue +41 -41
- package/src/lib/components/TabHeader/TabHeaderButton.vue +35 -35
- package/src/lib/components/TabHeader/TabHeaderItem.vue +63 -63
- package/src/lib/components/TabHeader/TabHeaderScroll.vue +240 -240
- package/src/lib/components/TabHeader/index.vue +135 -134
- package/src/lib/hooks/useContextMenu.ts +50 -50
- package/src/lib/hooks/useStackTab.ts +65 -65
- package/src/lib/hooks/useTabLoading.ts +34 -35
- package/src/lib/hooks/useTabRouter.ts +94 -95
- package/src/lib/hooks/useTabpanel.tsx +490 -490
- package/src/lib/i18n/index.ts +72 -72
- package/src/lib/i18n/lang/en.ts +15 -15
- package/src/lib/i18n/lang/zh-CN.ts +15 -15
- package/src/lib/iframe.vue +7 -7
- package/src/lib/index.ts +23 -23
- package/src/lib/model/TabModel.ts +169 -182
- package/src/lib/utils/TabIdHelper.ts +70 -70
- package/src/lib/utils/TabScrollHelper.ts +104 -104
- package/src/lib/utils/UriHelper.ts +22 -22
- package/types/index.d.ts +3 -11
- package/types/src/lib/StackTabs.vue.d.ts +122 -0
- package/types/src/lib/components/ContextMenu/ContextMenuItem.vue.d.ts +17 -0
- package/types/src/lib/components/ContextMenu/index.vue.d.ts +45 -0
- package/types/src/lib/components/OverlayLoading/Component.vue.d.ts +100 -0
- package/types/src/lib/components/OverlayLoading/api.d.ts +5 -0
- package/types/src/lib/components/OverlayLoading/helpers.d.ts +7 -0
- package/types/src/lib/components/OverlayLoading/index.d.ts +6 -0
- package/types/src/lib/components/OverlayLoading/loaders/bars.vue.d.ts +39 -0
- package/types/src/lib/components/OverlayLoading/loaders/dots.vue.d.ts +39 -0
- package/types/src/lib/components/OverlayLoading/loaders/index.d.ts +96 -0
- package/types/src/lib/components/OverlayLoading/loaders/spinner.vue.d.ts +39 -0
- package/types/src/lib/components/TabHeader/TabHeaderButton.vue.d.ts +48 -0
- package/types/src/lib/components/TabHeader/TabHeaderItem.vue.d.ts +21 -0
- package/types/src/lib/components/TabHeader/TabHeaderScroll.vue.d.ts +49 -0
- package/types/src/lib/components/TabHeader/index.vue.d.ts +64 -0
- package/types/src/lib/hooks/useContextMenu.d.ts +13 -0
- package/types/src/lib/hooks/useStackTab.d.ts +8 -0
- package/types/{hooks → src/lib/hooks}/useTabRouter.d.ts +2 -1
- package/types/src/lib/hooks/useTabpanel.d.ts +68 -0
- package/types/src/lib/i18n/index.d.ts +4 -0
- package/types/src/lib/i18n/lang/en.d.ts +16 -0
- package/types/src/lib/i18n/lang/zh-CN.d.ts +16 -0
- package/types/src/lib/iframe.vue.d.ts +2 -0
- package/types/src/lib/index.d.ts +12 -0
- package/types/{model → src/lib/model}/TabModel.d.ts +0 -20
- package/types/src/lib/utils/TabScrollHelper.d.ts +33 -0
- package/types/hooks/useStackTab.d.ts +0 -9
- package/types/iframe.vue.d.ts +0 -2
- /package/types/{banner.d.ts → src/lib/banner.d.ts} +0 -0
- /package/types/{hooks → src/lib/hooks}/useTabLoading.d.ts +0 -0
- /package/types/{utils → src/lib/utils}/TabIdHelper.d.ts +0 -0
- /package/types/{utils → src/lib/utils}/UriHelper.d.ts +0 -0
|
@@ -1,95 +1,94 @@
|
|
|
1
|
-
import { defu } from 'defu'
|
|
2
|
-
|
|
3
|
-
import { getCurrentInstance } from 'vue'
|
|
4
|
-
import type { ComponentInternalInstance } from 'vue'
|
|
5
|
-
import { useRoute, useRouter } from 'vue-router'
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const {
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*
|
|
38
|
-
* @param
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
let
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
1
|
+
import { defu } from 'defu'
|
|
2
|
+
|
|
3
|
+
import { getCurrentInstance } from 'vue'
|
|
4
|
+
import type { ComponentInternalInstance } from 'vue'
|
|
5
|
+
import { type RouteLocationPathRaw, useRoute, useRouter } from 'vue-router'
|
|
6
|
+
|
|
7
|
+
import useTabpanel from '@/lib/hooks/useTabpanel'
|
|
8
|
+
import { uriDecode } from '@/lib/utils/UriHelper'
|
|
9
|
+
export default () => {
|
|
10
|
+
const { attrs } = getCurrentInstance() as ComponentInternalInstance
|
|
11
|
+
const { pageShown, getTab, markDeletableCache, removeComponent, getComponent } = useTabpanel()
|
|
12
|
+
const route = useRoute()
|
|
13
|
+
const router = useRouter()
|
|
14
|
+
let currentId = ''
|
|
15
|
+
// const currentPageId = ''
|
|
16
|
+
let currentTab = ''
|
|
17
|
+
|
|
18
|
+
currentId = attrs.tId as string
|
|
19
|
+
// currentPageId = attrs.pId as string
|
|
20
|
+
currentTab = route.query.__tab as string
|
|
21
|
+
|
|
22
|
+
const forward = (to: RouteLocationPathRaw) => {
|
|
23
|
+
pageShown.value = false
|
|
24
|
+
const query = defu(
|
|
25
|
+
{
|
|
26
|
+
__tab: currentTab
|
|
27
|
+
},
|
|
28
|
+
to.query
|
|
29
|
+
)
|
|
30
|
+
router.push({
|
|
31
|
+
path: to.path,
|
|
32
|
+
query
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 返回
|
|
37
|
+
* @param to url or step
|
|
38
|
+
* @param query 返回时要加截的数据
|
|
39
|
+
*/
|
|
40
|
+
const backward = (to: number | string, query?: Object) => {
|
|
41
|
+
pageShown.value = false
|
|
42
|
+
|
|
43
|
+
const tab = getTab(currentId)
|
|
44
|
+
if (!tab) {
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
const tabStack = tab.pages
|
|
48
|
+
let absTo = 0
|
|
49
|
+
if (typeof to === 'number') {
|
|
50
|
+
absTo = Math.abs(to)
|
|
51
|
+
} else {
|
|
52
|
+
let index = 1
|
|
53
|
+
let hasPath = false
|
|
54
|
+
const pageItems = tabStack.list()
|
|
55
|
+
const url = uriDecode(to)
|
|
56
|
+
query = defu(url.query, query)
|
|
57
|
+
for (let i = tabStack.size() - 2; i >= 0; i--) {
|
|
58
|
+
if (pageItems[i].path === url.path) {
|
|
59
|
+
hasPath = true
|
|
60
|
+
break
|
|
61
|
+
}
|
|
62
|
+
index += 1
|
|
63
|
+
}
|
|
64
|
+
if (hasPath) {
|
|
65
|
+
absTo = index
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (absTo === 0 || tabStack!.size() <= absTo) {
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
// const removeCaches = new Set()
|
|
73
|
+
for (let i = 0; i < absTo; i++) {
|
|
74
|
+
const popRoute = tabStack.pop()
|
|
75
|
+
removeComponent(popRoute!.id)
|
|
76
|
+
markDeletableCache(popRoute!.id)
|
|
77
|
+
}
|
|
78
|
+
const pageRoute = tabStack?.peek()
|
|
79
|
+
const component = getComponent(pageRoute!.id)
|
|
80
|
+
if (component !== null && component !== undefined) {
|
|
81
|
+
const sourceComponent = component.components.DynamicComponent
|
|
82
|
+
sourceComponent.props = defu(query, sourceComponent.props)
|
|
83
|
+
}
|
|
84
|
+
router.push({
|
|
85
|
+
path: pageRoute!.path,
|
|
86
|
+
query: pageRoute!.query
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
forward,
|
|
92
|
+
backward
|
|
93
|
+
}
|
|
94
|
+
}
|