vue-stack-tabs 0.1.11 → 0.1.13
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/{types → dist}/src/lib/hooks/useStackTab.d.ts +2 -2
- package/{types → dist}/src/lib/hooks/useTabpanel.d.ts +6 -2
- package/{types → dist}/src/lib/index.d.ts +7 -1
- package/{types → dist}/src/lib/model/TabModel.d.ts +2 -1
- package/dist/style.css +1 -1
- package/dist/vue-stack-tabs.es.js +2340 -2321
- package/dist/vue-stack-tabs.umd.js +10 -10
- package/package.json +3 -4
- package/src/lib/StackTabs.vue +136 -126
- 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 -129
- package/src/lib/components/OverlayLoading/Component.vue +182 -191
- 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 -135
- package/src/lib/hooks/useContextMenu.ts +50 -50
- package/src/lib/hooks/useStackTab.ts +74 -65
- package/src/lib/hooks/useTabLoading.ts +34 -34
- package/src/lib/hooks/useTabRouter.ts +94 -94
- package/src/lib/hooks/useTabpanel.tsx +516 -491
- 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 +32 -23
- package/src/lib/model/TabModel.ts +178 -169
- 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 → dist}/index.d.ts +0 -0
- /package/{types → dist}/src/lib/StackTabs.vue.d.ts +0 -0
- /package/{types → dist}/src/lib/banner.d.ts +0 -0
- /package/{types → dist}/src/lib/components/ContextMenu/ContextMenuItem.vue.d.ts +0 -0
- /package/{types → dist}/src/lib/components/ContextMenu/index.vue.d.ts +0 -0
- /package/{types → dist}/src/lib/components/OverlayLoading/Component.vue.d.ts +0 -0
- /package/{types → dist}/src/lib/components/OverlayLoading/api.d.ts +0 -0
- /package/{types → dist}/src/lib/components/OverlayLoading/helpers.d.ts +0 -0
- /package/{types → dist}/src/lib/components/OverlayLoading/index.d.ts +0 -0
- /package/{types → dist}/src/lib/components/OverlayLoading/loaders/bars.vue.d.ts +0 -0
- /package/{types → dist}/src/lib/components/OverlayLoading/loaders/dots.vue.d.ts +0 -0
- /package/{types → dist}/src/lib/components/OverlayLoading/loaders/index.d.ts +0 -0
- /package/{types → dist}/src/lib/components/OverlayLoading/loaders/spinner.vue.d.ts +0 -0
- /package/{types → dist}/src/lib/components/TabHeader/TabHeaderButton.vue.d.ts +0 -0
- /package/{types → dist}/src/lib/components/TabHeader/TabHeaderItem.vue.d.ts +0 -0
- /package/{types → dist}/src/lib/components/TabHeader/TabHeaderScroll.vue.d.ts +0 -0
- /package/{types → dist}/src/lib/components/TabHeader/index.vue.d.ts +0 -0
- /package/{types → dist}/src/lib/hooks/useContextMenu.d.ts +0 -0
- /package/{types → dist}/src/lib/hooks/useTabLoading.d.ts +0 -0
- /package/{types → dist}/src/lib/hooks/useTabRouter.d.ts +0 -0
- /package/{types → dist}/src/lib/i18n/index.d.ts +0 -0
- /package/{types → dist}/src/lib/i18n/lang/en.d.ts +0 -0
- /package/{types → dist}/src/lib/i18n/lang/zh-CN.d.ts +0 -0
- /package/{types → dist}/src/lib/iframe.vue.d.ts +0 -0
- /package/{types → dist}/src/lib/utils/TabIdHelper.d.ts +0 -0
- /package/{types → dist}/src/lib/utils/TabScrollHelper.d.ts +0 -0
- /package/{types → dist}/src/lib/utils/UriHelper.d.ts +0 -0
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import type { ITabBase } from '../model/TabModel'
|
|
2
|
-
import { compressToEncodedURIComponent, decompressFromEncodedURIComponent } from 'lz-string'
|
|
3
|
-
import Hex from 'hex-encoding'
|
|
4
|
-
import { blake3 } from '@noble/hashes/blake3'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* compress tab info to string
|
|
8
|
-
* format:
|
|
9
|
-
* {tab id}{current timestamp}{tab name}{tab closable}
|
|
10
|
-
* @param tabData
|
|
11
|
-
*/
|
|
12
|
-
export const encodeTabInfo = (tabData: ITabBase): string => {
|
|
13
|
-
// const info: ITabBase = {
|
|
14
|
-
// id: tabData.id,
|
|
15
|
-
// title: tabData.title,
|
|
16
|
-
// iframe: tabData.iframe,
|
|
17
|
-
// closable: tabData.closable,
|
|
18
|
-
// refreshable: tabData.refreshable
|
|
19
|
-
// }
|
|
20
|
-
const info = `${tabData.id}|${tabData.title}|${tabData.iframe ? 'Y' : 'N'}|${tabData.closable ? 'Y' : 'N'}|${tabData.refreshable ? 'Y' : 'N'}`
|
|
21
|
-
return compressToEncodedURIComponent(info)
|
|
22
|
-
// const compressed = await compress(new TextEncoder().encode(info))
|
|
23
|
-
// return fromUint8Array(compressed, true)
|
|
24
|
-
// return compressToEncodedURIComponent(
|
|
25
|
-
// `${tabData.id}|${tabData.title}|${tabData.iframe ? 'Y' : 'N'}|${tabData.closable ? 'Y' : 'N'}|${tabData.refreshable ? 'Y' : 'N'}`
|
|
26
|
-
// )
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const decodeTabInfo = (tab: string): ITabBase => {
|
|
30
|
-
// const decompressed = await decompress(toUint8Array(tab))
|
|
31
|
-
const tabString = decompressFromEncodedURIComponent(tab)
|
|
32
|
-
// const tabString = new TextDecoder().decode(decompressed)
|
|
33
|
-
// return JSON.parse(new TextDecoder().decode(decompressed))
|
|
34
|
-
// const tabString = decompressFromEncodedURIComponent(tab)
|
|
35
|
-
const tabValues: string[] = tabString.split('|')
|
|
36
|
-
return {
|
|
37
|
-
id: tabValues[0],
|
|
38
|
-
title: tabValues[1],
|
|
39
|
-
iframe: tabValues[2] === 'Y',
|
|
40
|
-
closable: tabValues[3] === 'Y',
|
|
41
|
-
refreshable: tabValues[4] === 'Y'
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export const createPageId = (tabId: string, path: string, query: Object): string => {
|
|
46
|
-
const queryArray = []
|
|
47
|
-
console.log(query)
|
|
48
|
-
type ObjectKey = keyof typeof query
|
|
49
|
-
for (const key in query) {
|
|
50
|
-
if (!key.startsWith('__')) {
|
|
51
|
-
queryArray.push({
|
|
52
|
-
key,
|
|
53
|
-
value: query[key as ObjectKey]
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
queryArray.sort((a, b) => {
|
|
58
|
-
let result = 0
|
|
59
|
-
if (a.key > b.key) {
|
|
60
|
-
result = 1
|
|
61
|
-
} else if (a.key < b.key) {
|
|
62
|
-
result = -1
|
|
63
|
-
}
|
|
64
|
-
return result
|
|
65
|
-
})
|
|
66
|
-
const hash = blake3(`${tabId}|${path}|${JSON.stringify(queryArray)}`)
|
|
67
|
-
return Hex.encode(hash)
|
|
68
|
-
// return uuidv5(`${tabId}|${path}|${JSON.stringify(queryArray)}`, uuidv5.URL).replaceAll('-', '')
|
|
69
|
-
// return await blake3(`${tabId}|${path}|${JSON.stringify(queryArray)}`)
|
|
70
|
-
}
|
|
1
|
+
import type { ITabBase } from '../model/TabModel'
|
|
2
|
+
import { compressToEncodedURIComponent, decompressFromEncodedURIComponent } from 'lz-string'
|
|
3
|
+
import Hex from 'hex-encoding'
|
|
4
|
+
import { blake3 } from '@noble/hashes/blake3'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* compress tab info to string
|
|
8
|
+
* format:
|
|
9
|
+
* {tab id}{current timestamp}{tab name}{tab closable}
|
|
10
|
+
* @param tabData
|
|
11
|
+
*/
|
|
12
|
+
export const encodeTabInfo = (tabData: ITabBase): string => {
|
|
13
|
+
// const info: ITabBase = {
|
|
14
|
+
// id: tabData.id,
|
|
15
|
+
// title: tabData.title,
|
|
16
|
+
// iframe: tabData.iframe,
|
|
17
|
+
// closable: tabData.closable,
|
|
18
|
+
// refreshable: tabData.refreshable
|
|
19
|
+
// }
|
|
20
|
+
const info = `${tabData.id}|${tabData.title}|${tabData.iframe ? 'Y' : 'N'}|${tabData.closable ? 'Y' : 'N'}|${tabData.refreshable ? 'Y' : 'N'}`
|
|
21
|
+
return compressToEncodedURIComponent(info)
|
|
22
|
+
// const compressed = await compress(new TextEncoder().encode(info))
|
|
23
|
+
// return fromUint8Array(compressed, true)
|
|
24
|
+
// return compressToEncodedURIComponent(
|
|
25
|
+
// `${tabData.id}|${tabData.title}|${tabData.iframe ? 'Y' : 'N'}|${tabData.closable ? 'Y' : 'N'}|${tabData.refreshable ? 'Y' : 'N'}`
|
|
26
|
+
// )
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const decodeTabInfo = (tab: string): ITabBase => {
|
|
30
|
+
// const decompressed = await decompress(toUint8Array(tab))
|
|
31
|
+
const tabString = decompressFromEncodedURIComponent(tab)
|
|
32
|
+
// const tabString = new TextDecoder().decode(decompressed)
|
|
33
|
+
// return JSON.parse(new TextDecoder().decode(decompressed))
|
|
34
|
+
// const tabString = decompressFromEncodedURIComponent(tab)
|
|
35
|
+
const tabValues: string[] = tabString.split('|')
|
|
36
|
+
return {
|
|
37
|
+
id: tabValues[0],
|
|
38
|
+
title: tabValues[1],
|
|
39
|
+
iframe: tabValues[2] === 'Y',
|
|
40
|
+
closable: tabValues[3] === 'Y',
|
|
41
|
+
refreshable: tabValues[4] === 'Y'
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const createPageId = (tabId: string, path: string, query: Object): string => {
|
|
46
|
+
const queryArray = []
|
|
47
|
+
console.log(query)
|
|
48
|
+
type ObjectKey = keyof typeof query
|
|
49
|
+
for (const key in query) {
|
|
50
|
+
if (!key.startsWith('__')) {
|
|
51
|
+
queryArray.push({
|
|
52
|
+
key,
|
|
53
|
+
value: query[key as ObjectKey]
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
queryArray.sort((a, b) => {
|
|
58
|
+
let result = 0
|
|
59
|
+
if (a.key > b.key) {
|
|
60
|
+
result = 1
|
|
61
|
+
} else if (a.key < b.key) {
|
|
62
|
+
result = -1
|
|
63
|
+
}
|
|
64
|
+
return result
|
|
65
|
+
})
|
|
66
|
+
const hash = blake3(`${tabId}|${path}|${JSON.stringify(queryArray)}`)
|
|
67
|
+
return Hex.encode(hash)
|
|
68
|
+
// return uuidv5(`${tabId}|${path}|${JSON.stringify(queryArray)}`, uuidv5.URL).replaceAll('-', '')
|
|
69
|
+
// return await blake3(`${tabId}|${path}|${JSON.stringify(queryArray)}`)
|
|
70
|
+
}
|
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 滚动到指定位置
|
|
3
|
-
* @export
|
|
4
|
-
* @param {Element} wrap 滚动区域
|
|
5
|
-
* @param {number} [left=0]
|
|
6
|
-
* @param {number} [top=0]
|
|
7
|
-
*/
|
|
8
|
-
export const _scrollTo = ({
|
|
9
|
-
wrap,
|
|
10
|
-
left = 0,
|
|
11
|
-
top = 0,
|
|
12
|
-
smooth = true
|
|
13
|
-
}: {
|
|
14
|
-
wrap: HTMLElement | null
|
|
15
|
-
left?: number
|
|
16
|
-
top?: number
|
|
17
|
-
smooth?: boolean
|
|
18
|
-
}) => {
|
|
19
|
-
if (!wrap) return
|
|
20
|
-
|
|
21
|
-
if (wrap.scrollTo) {
|
|
22
|
-
wrap.scrollTo({
|
|
23
|
-
left,
|
|
24
|
-
top,
|
|
25
|
-
behavior: smooth ? 'smooth' : 'auto'
|
|
26
|
-
})
|
|
27
|
-
} else {
|
|
28
|
-
wrap.scrollLeft = left
|
|
29
|
-
wrap.scrollTop = top
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* 指定元素滚动到可视区域
|
|
35
|
-
* @export
|
|
36
|
-
* @param {Element} el 目标元素
|
|
37
|
-
* @param {Element} wrap 滚动区域
|
|
38
|
-
* @param {String} block 垂直方向的对齐,可选:'start', 'center', 'end', 或 'nearest'
|
|
39
|
-
* @param {String} inline 水平方向的对齐,可选值同上
|
|
40
|
-
*/
|
|
41
|
-
export function _scrollIntoView({
|
|
42
|
-
el,
|
|
43
|
-
wrap,
|
|
44
|
-
block = 'start',
|
|
45
|
-
inline = 'nearest'
|
|
46
|
-
}: {
|
|
47
|
-
el: HTMLElement
|
|
48
|
-
wrap: any
|
|
49
|
-
block?: any
|
|
50
|
-
inline?: any
|
|
51
|
-
}) {
|
|
52
|
-
if (!el || !wrap) return
|
|
53
|
-
|
|
54
|
-
if (el.scrollIntoView) {
|
|
55
|
-
el.scrollIntoView({ behavior: 'smooth', block, inline })
|
|
56
|
-
} else {
|
|
57
|
-
const { offsetLeft, offsetTop } = el
|
|
58
|
-
let left, top
|
|
59
|
-
|
|
60
|
-
if (block === 'center') {
|
|
61
|
-
top = offsetTop + (el.clientHeight - wrap.clientHeight) / 2
|
|
62
|
-
} else {
|
|
63
|
-
top = offsetTop
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (inline === 'center') {
|
|
67
|
-
left = offsetLeft + (el.clientWidth - wrap.clientWidth) / 2
|
|
68
|
-
} else {
|
|
69
|
-
left = offsetLeft
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
_scrollTo({ wrap, left, top })
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// 获取滚动条宽度
|
|
77
|
-
export const getScrollbarWidth = (function () {
|
|
78
|
-
let width: number | null = null
|
|
79
|
-
|
|
80
|
-
return function () {
|
|
81
|
-
if (width !== null) return width
|
|
82
|
-
|
|
83
|
-
const div = document.createElement('div')
|
|
84
|
-
|
|
85
|
-
div.style.cssText = 'width: 100px; height: 100px;overflow-y: scroll'
|
|
86
|
-
document.body.appendChild(div)
|
|
87
|
-
width = div.offsetWidth - div.clientWidth
|
|
88
|
-
div.parentElement?.removeChild(div)
|
|
89
|
-
|
|
90
|
-
return width
|
|
91
|
-
}
|
|
92
|
-
})()
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* 获取最大z-index
|
|
96
|
-
* @returns 最大z-index的值
|
|
97
|
-
*/
|
|
98
|
-
export const getMaxZIndex = (key = '.stack-tab__container *'): number => {
|
|
99
|
-
const allZIndex = Array.from(document.querySelectorAll(key)).map(
|
|
100
|
-
(e) => +window.getComputedStyle(e).zIndex || 0
|
|
101
|
-
)
|
|
102
|
-
// 特殊处理,不高于90000的才行
|
|
103
|
-
return allZIndex.length ? Math.max(...allZIndex.filter((item) => item < 90000)) + 1 : 1
|
|
104
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 滚动到指定位置
|
|
3
|
+
* @export
|
|
4
|
+
* @param {Element} wrap 滚动区域
|
|
5
|
+
* @param {number} [left=0]
|
|
6
|
+
* @param {number} [top=0]
|
|
7
|
+
*/
|
|
8
|
+
export const _scrollTo = ({
|
|
9
|
+
wrap,
|
|
10
|
+
left = 0,
|
|
11
|
+
top = 0,
|
|
12
|
+
smooth = true
|
|
13
|
+
}: {
|
|
14
|
+
wrap: HTMLElement | null
|
|
15
|
+
left?: number
|
|
16
|
+
top?: number
|
|
17
|
+
smooth?: boolean
|
|
18
|
+
}) => {
|
|
19
|
+
if (!wrap) return
|
|
20
|
+
|
|
21
|
+
if (wrap.scrollTo) {
|
|
22
|
+
wrap.scrollTo({
|
|
23
|
+
left,
|
|
24
|
+
top,
|
|
25
|
+
behavior: smooth ? 'smooth' : 'auto'
|
|
26
|
+
})
|
|
27
|
+
} else {
|
|
28
|
+
wrap.scrollLeft = left
|
|
29
|
+
wrap.scrollTop = top
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 指定元素滚动到可视区域
|
|
35
|
+
* @export
|
|
36
|
+
* @param {Element} el 目标元素
|
|
37
|
+
* @param {Element} wrap 滚动区域
|
|
38
|
+
* @param {String} block 垂直方向的对齐,可选:'start', 'center', 'end', 或 'nearest'
|
|
39
|
+
* @param {String} inline 水平方向的对齐,可选值同上
|
|
40
|
+
*/
|
|
41
|
+
export function _scrollIntoView({
|
|
42
|
+
el,
|
|
43
|
+
wrap,
|
|
44
|
+
block = 'start',
|
|
45
|
+
inline = 'nearest'
|
|
46
|
+
}: {
|
|
47
|
+
el: HTMLElement
|
|
48
|
+
wrap: any
|
|
49
|
+
block?: any
|
|
50
|
+
inline?: any
|
|
51
|
+
}) {
|
|
52
|
+
if (!el || !wrap) return
|
|
53
|
+
|
|
54
|
+
if (el.scrollIntoView) {
|
|
55
|
+
el.scrollIntoView({ behavior: 'smooth', block, inline })
|
|
56
|
+
} else {
|
|
57
|
+
const { offsetLeft, offsetTop } = el
|
|
58
|
+
let left, top
|
|
59
|
+
|
|
60
|
+
if (block === 'center') {
|
|
61
|
+
top = offsetTop + (el.clientHeight - wrap.clientHeight) / 2
|
|
62
|
+
} else {
|
|
63
|
+
top = offsetTop
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (inline === 'center') {
|
|
67
|
+
left = offsetLeft + (el.clientWidth - wrap.clientWidth) / 2
|
|
68
|
+
} else {
|
|
69
|
+
left = offsetLeft
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
_scrollTo({ wrap, left, top })
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// 获取滚动条宽度
|
|
77
|
+
export const getScrollbarWidth = (function () {
|
|
78
|
+
let width: number | null = null
|
|
79
|
+
|
|
80
|
+
return function () {
|
|
81
|
+
if (width !== null) return width
|
|
82
|
+
|
|
83
|
+
const div = document.createElement('div')
|
|
84
|
+
|
|
85
|
+
div.style.cssText = 'width: 100px; height: 100px;overflow-y: scroll'
|
|
86
|
+
document.body.appendChild(div)
|
|
87
|
+
width = div.offsetWidth - div.clientWidth
|
|
88
|
+
div.parentElement?.removeChild(div)
|
|
89
|
+
|
|
90
|
+
return width
|
|
91
|
+
}
|
|
92
|
+
})()
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 获取最大z-index
|
|
96
|
+
* @returns 最大z-index的值
|
|
97
|
+
*/
|
|
98
|
+
export const getMaxZIndex = (key = '.stack-tab__container *'): number => {
|
|
99
|
+
const allZIndex = Array.from(document.querySelectorAll(key)).map(
|
|
100
|
+
(e) => +window.getComputedStyle(e).zIndex || 0
|
|
101
|
+
)
|
|
102
|
+
// 特殊处理,不高于90000的才行
|
|
103
|
+
return allZIndex.length ? Math.max(...allZIndex.filter((item) => item < 90000)) + 1 : 1
|
|
104
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
export const uriDecode = (uri: string) => {
|
|
2
|
-
const uris = uri.split('?')
|
|
3
|
-
if (uris.length <= 1) {
|
|
4
|
-
return {
|
|
5
|
-
path: uris[0],
|
|
6
|
-
query: {}
|
|
7
|
-
}
|
|
8
|
-
} else {
|
|
9
|
-
const arr = uris[1].split('&')
|
|
10
|
-
const query: Record<string, string> = {}
|
|
11
|
-
for (const item of arr) {
|
|
12
|
-
const kv = item.split('=')
|
|
13
|
-
if (kv[1] !== null && kv[1] !== undefined && kv[1] !== '') {
|
|
14
|
-
query[kv[0]] = kv[1]
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return {
|
|
18
|
-
path: uris[0],
|
|
19
|
-
query
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
1
|
+
export const uriDecode = (uri: string) => {
|
|
2
|
+
const uris = uri.split('?')
|
|
3
|
+
if (uris.length <= 1) {
|
|
4
|
+
return {
|
|
5
|
+
path: uris[0],
|
|
6
|
+
query: {}
|
|
7
|
+
}
|
|
8
|
+
} else {
|
|
9
|
+
const arr = uris[1].split('&')
|
|
10
|
+
const query: Record<string, string> = {}
|
|
11
|
+
for (const item of arr) {
|
|
12
|
+
const kv = item.split('=')
|
|
13
|
+
if (kv[1] !== null && kv[1] !== undefined && kv[1] !== '') {
|
|
14
|
+
query[kv[0]] = kv[1]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
path: uris[0],
|
|
19
|
+
query
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|