vue-stack-tabs 1.4.1 → 2.2.0
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.en.md +1 -0
- package/README.md +1 -0
- package/README.ru.md +1 -0
- package/dist/StackTabs.vue.d.ts +3 -0
- package/dist/components/ContextMenu/ContextMenuItem.vue.d.ts +1 -1
- package/dist/hooks/tabPanel/pageComponentFactory.d.ts +5 -2
- package/dist/hooks/tabPanel/refresh.d.ts +8 -3
- package/dist/hooks/tabPanel/tabStore.d.ts +80 -0
- package/dist/hooks/useTabActions.d.ts +1 -0
- package/dist/hooks/useTabPanel.d.ts +27 -5
- package/dist/model/TabModel.d.ts +5 -0
- package/dist/style.css +1 -1
- package/dist/utils/tabInfoEncoder.d.ts +10 -0
- package/dist/utils/urlParser.d.ts +14 -3
- package/dist/vue-stack-tabs.es.js +1 -1
- package/package.json +4 -7
- package/src/lib/StackTabs.vue +24 -2
- package/src/lib/assets/image/close_all.svg +1 -9
- package/src/lib/assets/image/close_lefts.svg +1 -1
- package/src/lib/assets/image/close_other.svg +1 -1
- package/src/lib/assets/image/close_rights.svg +1 -1
- package/src/lib/assets/image/reload.svg +1 -3
- package/src/lib/assets/image/reload_all.svg +1 -6
- package/src/lib/assets/style/common/mixins.scss +58 -19
- package/src/lib/assets/style/common/var.scss +100 -60
- package/src/lib/assets/style/icon.scss +31 -98
- package/src/lib/assets/style/index.scss +2 -2
- package/src/lib/assets/style/loading.scss +45 -0
- package/src/lib/assets/style/{stackTab.scss → stack-tab.scss} +105 -177
- package/src/lib/assets/style/transition.scss +12 -17
- package/src/lib/components/ContextMenu/ContextMenuItem.vue +5 -5
- package/src/lib/components/ContextMenu/index.vue +22 -19
- package/src/lib/components/PageLoading.vue +5 -5
- package/src/lib/components/StackKeepAlive/StackKeepAlive.vue +5 -3
- package/src/lib/components/TabHeader/TabHeaderItem.vue +13 -7
- package/src/lib/components/TabHeader/TabHeaderScroll.vue +8 -6
- package/src/lib/components/TabHeader/index.vue +16 -2
- package/src/lib/hooks/tabPanel/pageComponentFactory.tsx +96 -26
- package/src/lib/hooks/tabPanel/refresh.ts +40 -18
- package/src/lib/hooks/tabPanel/tabStore.ts +665 -0
- package/src/lib/hooks/useContextMenu.ts +1 -1
- package/src/lib/hooks/useIframeManager.ts +10 -3
- package/src/lib/hooks/useTabActions.ts +10 -6
- package/src/lib/hooks/useTabPanel.tsx +325 -195
- package/src/lib/hooks/useTabRouter.ts +50 -48
- package/src/lib/model/TabModel.ts +5 -0
- package/src/lib/utils/tabInfoEncoder.ts +101 -17
- package/src/lib/utils/urlParser.ts +35 -11
- package/dist/vue-stack-tabs.css +0 -2
- package/src/lib/assets/style/overlayer.scss +0 -46
|
@@ -2,7 +2,7 @@ import { isNavigationFailure, useRouter } from 'vue-router'
|
|
|
2
2
|
import type { LocationQueryRaw } from 'vue-router'
|
|
3
3
|
import { defu } from 'defu'
|
|
4
4
|
import useTabPanel from './useTabPanel'
|
|
5
|
-
import { encodeTabInfo } from '../utils/tabInfoEncoder'
|
|
5
|
+
import { createId, encodeTabInfo } from '../utils/tabInfoEncoder'
|
|
6
6
|
import {
|
|
7
7
|
parseUrl,
|
|
8
8
|
isCrossOriginUrl,
|
|
@@ -31,12 +31,14 @@ export default function useTabActions(providedRuntimeContext?: StackTabsRuntimeC
|
|
|
31
31
|
const runtimeContext = providedRuntimeContext ?? resolveStackTabsRuntimeContext()
|
|
32
32
|
const {
|
|
33
33
|
active,
|
|
34
|
+
updateTabTitle,
|
|
34
35
|
hasTab,
|
|
35
36
|
refreshKey,
|
|
36
37
|
reset,
|
|
37
38
|
canAddTab,
|
|
38
39
|
renewTab,
|
|
39
40
|
getTab,
|
|
41
|
+
getTopPage,
|
|
40
42
|
tabs,
|
|
41
43
|
moveTab,
|
|
42
44
|
removeTab,
|
|
@@ -60,7 +62,7 @@ export default function useTabActions(providedRuntimeContext?: StackTabsRuntimeC
|
|
|
60
62
|
defaults.iframeRefreshMode = (tab.iframeRefreshMode ?? 'postMessage') as IframeRefreshMode
|
|
61
63
|
}
|
|
62
64
|
const info = defu(tab, defaults)
|
|
63
|
-
if (!info.id) info.id =
|
|
65
|
+
if (!info.id) info.id = createId()
|
|
64
66
|
return info
|
|
65
67
|
}
|
|
66
68
|
|
|
@@ -110,10 +112,12 @@ export default function useTabActions(providedRuntimeContext?: StackTabsRuntimeC
|
|
|
110
112
|
const tabQuery = omitStackTabsReservedQuery(tab.query)
|
|
111
113
|
let query = defu(tabQuery, { __tab }) as LocationQueryRaw
|
|
112
114
|
let path: string
|
|
115
|
+
let hash: string | undefined
|
|
113
116
|
|
|
114
117
|
if (!tab.iframe) {
|
|
115
118
|
const url = parseUrl(tab.path)
|
|
116
119
|
path = url.path
|
|
120
|
+
hash = url.hash || undefined
|
|
117
121
|
query = defu(omitStackTabsReservedQuery(url.query), query, { __tab }) as LocationQueryRaw
|
|
118
122
|
query = {
|
|
119
123
|
...query,
|
|
@@ -131,7 +135,7 @@ export default function useTabActions(providedRuntimeContext?: StackTabsRuntimeC
|
|
|
131
135
|
if (!isAllowedTabUrl(tab.path)) return Promise.reject(new Error('Invalid tab URL'))
|
|
132
136
|
return runNavigationTransaction({
|
|
133
137
|
apply: () => undefined,
|
|
134
|
-
navigate: () => router.push({ path, query }),
|
|
138
|
+
navigate: () => router.push({ path, query, hash }),
|
|
135
139
|
rollback: () => undefined,
|
|
136
140
|
isFailureResult: isNavigationFailure,
|
|
137
141
|
rejectFailureResult: true
|
|
@@ -152,10 +156,9 @@ export default function useTabActions(providedRuntimeContext?: StackTabsRuntimeC
|
|
|
152
156
|
target: { tabId?: string; pageId?: string } = {}
|
|
153
157
|
): HTMLElement | undefined => {
|
|
154
158
|
if (typeof document === 'undefined') return undefined
|
|
155
|
-
const pageId =
|
|
156
|
-
target.pageId ?? (target.tabId ? getTab(target.tabId)?.pages.peek()?.id : undefined)
|
|
159
|
+
const pageId = target.pageId ?? (target.tabId ? getTopPage(target.tabId)?.id : undefined)
|
|
157
160
|
if (pageId) return document.getElementById(`W-${pageId}`) ?? undefined
|
|
158
|
-
return document.querySelector<HTMLElement>('.
|
|
161
|
+
return document.querySelector<HTMLElement>('.stack-tab__cache-page-wrapper') ?? undefined
|
|
159
162
|
}
|
|
160
163
|
|
|
161
164
|
/** iframe 标签在新窗口打开(无法嵌入时降级) */
|
|
@@ -181,6 +184,7 @@ export default function useTabActions(providedRuntimeContext?: StackTabsRuntimeC
|
|
|
181
184
|
// 激活与重置
|
|
182
185
|
activeTab: active,
|
|
183
186
|
moveTab,
|
|
187
|
+
updateTabTitle,
|
|
184
188
|
reset,
|
|
185
189
|
|
|
186
190
|
// 数据与配置
|