vue-stack-tabs 0.1.12 → 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 +5 -0
- 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 -2322
- 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 -24
- 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
package/src/lib/i18n/index.ts
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { useI18n } from 'vue-i18n'
|
|
2
|
-
import { inject } from 'vue'
|
|
3
|
-
export default () => {
|
|
4
|
-
// 引入lang目录下文件
|
|
5
|
-
// 此处使用了 VITE 的 import.meta.globEager。非 VITE 的 可以使用 require.context
|
|
6
|
-
const modules = import.meta.glob('./lang/*', { eager: true })
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 获取所有语言文件
|
|
10
|
-
* @param {Object} mList
|
|
11
|
-
*/
|
|
12
|
-
function getLangFiles(mList: any, msg: any) {
|
|
13
|
-
for (const path in mList) {
|
|
14
|
-
if (mList[path].default) {
|
|
15
|
-
// 获取文件名
|
|
16
|
-
const pathName = path.substring(path.lastIndexOf('/') + 1, path.lastIndexOf('.'))
|
|
17
|
-
|
|
18
|
-
if (msg[pathName]) {
|
|
19
|
-
msg[pathName] = {
|
|
20
|
-
...mList[pathName],
|
|
21
|
-
...mList[path].default
|
|
22
|
-
}
|
|
23
|
-
} else {
|
|
24
|
-
msg[pathName] = mList[path].default
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 注册i18n实例并引入语言文件
|
|
32
|
-
*/
|
|
33
|
-
// const i18n = createI18n({
|
|
34
|
-
// fallbackLocale: 'zh-CN',
|
|
35
|
-
// // 定义默认语言为中文
|
|
36
|
-
// locale: 'zh-CN',
|
|
37
|
-
// legacy: false,
|
|
38
|
-
// // 挂载到全局,不然会报错
|
|
39
|
-
// // globalInjection: true,
|
|
40
|
-
// messages: getAllLang(),
|
|
41
|
-
// })
|
|
42
|
-
/**
|
|
43
|
-
* 局部使用i18n
|
|
44
|
-
*/
|
|
45
|
-
// const i18n = useI18n({
|
|
46
|
-
// useScope: 'local',
|
|
47
|
-
// locale: 'zh-CN',
|
|
48
|
-
// messages: getAllLang(),
|
|
49
|
-
// })
|
|
50
|
-
|
|
51
|
-
// 假设你还有其他目录下的语言文件 它的路径是 src/views/home/locales/en-US.ts
|
|
52
|
-
// 那么你就可以 使用 :lower:(小写) :upper:(大写) 来引入文件
|
|
53
|
-
// const viewModules = import.meta.globEager('../views/**/locales/[[:lower:]][[:lower:]]-[[:upper:]][[:upper:]].ts')
|
|
54
|
-
|
|
55
|
-
const allLangs: any = () => {
|
|
56
|
-
const message: any = {}
|
|
57
|
-
getLangFiles(modules, message)
|
|
58
|
-
return message
|
|
59
|
-
}
|
|
60
|
-
const localeI18n = inject('locales') as { locale: string; messages: object }
|
|
61
|
-
const getI18n = () => {
|
|
62
|
-
const combinateMessage = { ...allLangs(), ...localeI18n.messages }
|
|
63
|
-
return useI18n({
|
|
64
|
-
useScope: 'local',
|
|
65
|
-
locale: localeI18n.locale,
|
|
66
|
-
messages: combinateMessage
|
|
67
|
-
})
|
|
68
|
-
}
|
|
69
|
-
return {
|
|
70
|
-
getI18n
|
|
71
|
-
}
|
|
72
|
-
}
|
|
1
|
+
import { useI18n } from 'vue-i18n'
|
|
2
|
+
import { inject } from 'vue'
|
|
3
|
+
export default () => {
|
|
4
|
+
// 引入lang目录下文件
|
|
5
|
+
// 此处使用了 VITE 的 import.meta.globEager。非 VITE 的 可以使用 require.context
|
|
6
|
+
const modules = import.meta.glob('./lang/*', { eager: true })
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 获取所有语言文件
|
|
10
|
+
* @param {Object} mList
|
|
11
|
+
*/
|
|
12
|
+
function getLangFiles(mList: any, msg: any) {
|
|
13
|
+
for (const path in mList) {
|
|
14
|
+
if (mList[path].default) {
|
|
15
|
+
// 获取文件名
|
|
16
|
+
const pathName = path.substring(path.lastIndexOf('/') + 1, path.lastIndexOf('.'))
|
|
17
|
+
|
|
18
|
+
if (msg[pathName]) {
|
|
19
|
+
msg[pathName] = {
|
|
20
|
+
...mList[pathName],
|
|
21
|
+
...mList[path].default
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
msg[pathName] = mList[path].default
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 注册i18n实例并引入语言文件
|
|
32
|
+
*/
|
|
33
|
+
// const i18n = createI18n({
|
|
34
|
+
// fallbackLocale: 'zh-CN',
|
|
35
|
+
// // 定义默认语言为中文
|
|
36
|
+
// locale: 'zh-CN',
|
|
37
|
+
// legacy: false,
|
|
38
|
+
// // 挂载到全局,不然会报错
|
|
39
|
+
// // globalInjection: true,
|
|
40
|
+
// messages: getAllLang(),
|
|
41
|
+
// })
|
|
42
|
+
/**
|
|
43
|
+
* 局部使用i18n
|
|
44
|
+
*/
|
|
45
|
+
// const i18n = useI18n({
|
|
46
|
+
// useScope: 'local',
|
|
47
|
+
// locale: 'zh-CN',
|
|
48
|
+
// messages: getAllLang(),
|
|
49
|
+
// })
|
|
50
|
+
|
|
51
|
+
// 假设你还有其他目录下的语言文件 它的路径是 src/views/home/locales/en-US.ts
|
|
52
|
+
// 那么你就可以 使用 :lower:(小写) :upper:(大写) 来引入文件
|
|
53
|
+
// const viewModules = import.meta.globEager('../views/**/locales/[[:lower:]][[:lower:]]-[[:upper:]][[:upper:]].ts')
|
|
54
|
+
|
|
55
|
+
const allLangs: any = () => {
|
|
56
|
+
const message: any = {}
|
|
57
|
+
getLangFiles(modules, message)
|
|
58
|
+
return message
|
|
59
|
+
}
|
|
60
|
+
const localeI18n = inject('locales') as { locale: string; messages: object }
|
|
61
|
+
const getI18n = () => {
|
|
62
|
+
const combinateMessage = { ...allLangs(), ...localeI18n.messages }
|
|
63
|
+
return useI18n({
|
|
64
|
+
useScope: 'local',
|
|
65
|
+
locale: localeI18n.locale,
|
|
66
|
+
messages: combinateMessage
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
getI18n
|
|
71
|
+
}
|
|
72
|
+
}
|
package/src/lib/i18n/lang/en.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
VueStackTab: {
|
|
3
|
-
close: 'close',
|
|
4
|
-
closeLefts: 'close lefts',
|
|
5
|
-
closeRights: 'close rights',
|
|
6
|
-
closeOthers: 'close others',
|
|
7
|
-
closeAll: 'close all',
|
|
8
|
-
reload: 'reload',
|
|
9
|
-
reloadAll: 'reload all',
|
|
10
|
-
maximum: 'maximum',
|
|
11
|
-
restore: 'restore',
|
|
12
|
-
undefined: 'undefined',
|
|
13
|
-
loading: 'loading'
|
|
14
|
-
}
|
|
15
|
-
}
|
|
1
|
+
export default {
|
|
2
|
+
VueStackTab: {
|
|
3
|
+
close: 'close',
|
|
4
|
+
closeLefts: 'close lefts',
|
|
5
|
+
closeRights: 'close rights',
|
|
6
|
+
closeOthers: 'close others',
|
|
7
|
+
closeAll: 'close all',
|
|
8
|
+
reload: 'reload',
|
|
9
|
+
reloadAll: 'reload all',
|
|
10
|
+
maximum: 'maximum',
|
|
11
|
+
restore: 'restore',
|
|
12
|
+
undefined: 'undefined',
|
|
13
|
+
loading: 'loading'
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
VueStackTab: {
|
|
3
|
-
close: '关闭',
|
|
4
|
-
closeLefts: '关闭左侧',
|
|
5
|
-
closeRights: '关闭右侧',
|
|
6
|
-
closeOthers: '关闭其他',
|
|
7
|
-
closeAll: '关闭所有',
|
|
8
|
-
reload: '刷新',
|
|
9
|
-
reloadAll: '刷新所有',
|
|
10
|
-
maximum: '最大化',
|
|
11
|
-
restore: '还原',
|
|
12
|
-
undefined: '未命名',
|
|
13
|
-
loading: '加载中'
|
|
14
|
-
}
|
|
15
|
-
}
|
|
1
|
+
export default {
|
|
2
|
+
VueStackTab: {
|
|
3
|
+
close: '关闭',
|
|
4
|
+
closeLefts: '关闭左侧',
|
|
5
|
+
closeRights: '关闭右侧',
|
|
6
|
+
closeOthers: '关闭其他',
|
|
7
|
+
closeAll: '关闭所有',
|
|
8
|
+
reload: '刷新',
|
|
9
|
+
reloadAll: '刷新所有',
|
|
10
|
+
maximum: '最大化',
|
|
11
|
+
restore: '还原',
|
|
12
|
+
undefined: '未命名',
|
|
13
|
+
loading: '加载中'
|
|
14
|
+
}
|
|
15
|
+
}
|
package/src/lib/iframe.vue
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import useTabRouter from './hooks/useTabRouter'
|
|
3
|
-
useTabRouter()
|
|
4
|
-
</script>
|
|
5
|
-
<template>
|
|
6
|
-
<div></div>
|
|
7
|
-
</template>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import useTabRouter from './hooks/useTabRouter'
|
|
3
|
+
useTabRouter()
|
|
4
|
+
</script>
|
|
5
|
+
<template>
|
|
6
|
+
<div></div>
|
|
7
|
+
</template>
|
package/src/lib/index.ts
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
|
-
import type { App } from 'vue'
|
|
2
|
-
import { createI18n } from 'vue-i18n'
|
|
3
|
-
import StackTab from './StackTabs.vue'
|
|
4
|
-
import tabVersion from './banner'
|
|
5
|
-
import IFrame from './iframe.vue'
|
|
6
|
-
import useTabLoading from './hooks/useTabLoading'
|
|
7
|
-
import useTabRouter from './hooks/useTabRouter'
|
|
8
|
-
import useStackTab from './hooks/useStackTab'
|
|
9
|
-
import TabHeaderButton from '@/lib/components/TabHeader/TabHeaderButton.vue'
|
|
10
|
-
import './assets/style/index.scss'
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
}
|
|
1
|
+
import type { App } from 'vue'
|
|
2
|
+
import { createI18n } from 'vue-i18n'
|
|
3
|
+
import StackTab from './StackTabs.vue'
|
|
4
|
+
import tabVersion from './banner'
|
|
5
|
+
import IFrame from './iframe.vue'
|
|
6
|
+
import useTabLoading from './hooks/useTabLoading'
|
|
7
|
+
import useTabRouter from './hooks/useTabRouter'
|
|
8
|
+
import useStackTab from './hooks/useStackTab'
|
|
9
|
+
import TabHeaderButton from '@/lib/components/TabHeader/TabHeaderButton.vue'
|
|
10
|
+
import './assets/style/index.scss'
|
|
11
|
+
|
|
12
|
+
const i18n = createI18n({
|
|
13
|
+
legacy: false,
|
|
14
|
+
locale: 'zh-CN',
|
|
15
|
+
fallbackLocale: 'en-US'
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
export * from './model/TabModel'
|
|
19
|
+
// Cutsom type
|
|
20
|
+
declare module '@vue/runtime-core' {
|
|
21
|
+
export interface GlobalComponents {
|
|
22
|
+
VueStackTabs: typeof StackTab
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { IFrame, useTabLoading, useTabRouter, useStackTab, TabHeaderButton, StackTab }
|
|
27
|
+
export default {
|
|
28
|
+
install(Vue: App): void {
|
|
29
|
+
tabVersion(import.meta.env.PACKAGE_VERSION)
|
|
30
|
+
Vue.component('VueStackTabs', StackTab).use(i18n)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -1,169 +1,178 @@
|
|
|
1
|
-
// Tab的滚动方式
|
|
2
|
-
export enum TabScrollMode {
|
|
3
|
-
// 使用滚轮
|
|
4
|
-
WHEEL = 'wheel',
|
|
5
|
-
// 使用按钮
|
|
6
|
-
BUTTON = 'button',
|
|
7
|
-
// 两者都可以
|
|
8
|
-
BOTH = 'both'
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// export enum EventType {
|
|
12
|
-
// I18N_LOCALES = 'I18N_LOCALES',
|
|
13
|
-
// PANEL_MAXIMUM = 'PANEL_MAXIMUM',
|
|
14
|
-
// TAB_ACTIVE = 'TAB_ACTIVE',
|
|
15
|
-
// TAB_CLOSE = 'TAB_CLOSE',
|
|
16
|
-
// TAB_CLOSE_ALL = 'TAB_CLOSE_ALL',
|
|
17
|
-
// TAB_CLOSE_RIGHT = 'TAB_CLOSE_RIGHT',
|
|
18
|
-
// TAB_CLOSE_LEFT = 'TAB_CLOSE_LEFT',
|
|
19
|
-
// TAB_REFRESH = 'TAB_REFRESH',
|
|
20
|
-
// TAB_REFRESH_ALL = 'TAB_REFRESH_ALL'
|
|
21
|
-
// }
|
|
22
|
-
// 拖拽数据接口
|
|
23
|
-
export interface DragData {
|
|
24
|
-
thumbLeft: number
|
|
25
|
-
startScrollLeft: number
|
|
26
|
-
startThumbLeft: number
|
|
27
|
-
startPageX: number
|
|
28
|
-
}
|
|
29
|
-
// 滑块数据接口
|
|
30
|
-
export interface ScrollData {
|
|
31
|
-
clientWidth: number
|
|
32
|
-
scrollWidth: number
|
|
33
|
-
scrollLeft: number
|
|
34
|
-
}
|
|
35
|
-
// 滚动条事件类型
|
|
36
|
-
export type ScrollEvents = {
|
|
37
|
-
ScrollUpdate: void
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Tab data for open
|
|
42
|
-
*/
|
|
43
|
-
export interface ITabData extends ITabBase {
|
|
44
|
-
// tab name
|
|
45
|
-
title: string
|
|
46
|
-
path: string
|
|
47
|
-
query?: Record<string, string>
|
|
48
|
-
}
|
|
49
|
-
export interface ITabBase {
|
|
50
|
-
id?: string
|
|
51
|
-
title: string
|
|
52
|
-
closable?: boolean
|
|
53
|
-
refreshable?: boolean
|
|
54
|
-
iframe?: boolean
|
|
55
|
-
}
|
|
56
|
-
export interface ITabItem extends ITabBase {
|
|
57
|
-
id: string
|
|
58
|
-
closable: boolean
|
|
59
|
-
refreshable: boolean
|
|
60
|
-
iframe: boolean
|
|
61
|
-
url?: string
|
|
62
|
-
active: boolean
|
|
63
|
-
pages: Stack<ITabPage>
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface ITabPage {
|
|
67
|
-
id: string
|
|
68
|
-
tabId: string
|
|
69
|
-
path: string
|
|
70
|
-
query?: Record<string, string>
|
|
71
|
-
}
|
|
72
|
-
export interface IContextMenu {
|
|
73
|
-
icon?: string
|
|
74
|
-
title: string
|
|
75
|
-
callback(id: string): void
|
|
76
|
-
disabled: (tabData: ITabBase) => boolean
|
|
77
|
-
}
|
|
78
|
-
// export interface TabRouteLocationRaw {
|
|
79
|
-
// path: string
|
|
80
|
-
// query?: any
|
|
81
|
-
// }
|
|
82
|
-
// export interface PageRouteLocationRaw {
|
|
83
|
-
// pId: string
|
|
84
|
-
// path: string
|
|
85
|
-
// query: any
|
|
86
|
-
// }
|
|
87
|
-
export class Stack<T> {
|
|
88
|
-
// 存储的Map
|
|
89
|
-
private items: Map<number, T>
|
|
90
|
-
|
|
91
|
-
//
|
|
92
|
-
constructor() {
|
|
93
|
-
this.items = new Map()
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
1
|
+
// Tab的滚动方式
|
|
2
|
+
export enum TabScrollMode {
|
|
3
|
+
// 使用滚轮
|
|
4
|
+
WHEEL = 'wheel',
|
|
5
|
+
// 使用按钮
|
|
6
|
+
BUTTON = 'button',
|
|
7
|
+
// 两者都可以
|
|
8
|
+
BOTH = 'both'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// export enum EventType {
|
|
12
|
+
// I18N_LOCALES = 'I18N_LOCALES',
|
|
13
|
+
// PANEL_MAXIMUM = 'PANEL_MAXIMUM',
|
|
14
|
+
// TAB_ACTIVE = 'TAB_ACTIVE',
|
|
15
|
+
// TAB_CLOSE = 'TAB_CLOSE',
|
|
16
|
+
// TAB_CLOSE_ALL = 'TAB_CLOSE_ALL',
|
|
17
|
+
// TAB_CLOSE_RIGHT = 'TAB_CLOSE_RIGHT',
|
|
18
|
+
// TAB_CLOSE_LEFT = 'TAB_CLOSE_LEFT',
|
|
19
|
+
// TAB_REFRESH = 'TAB_REFRESH',
|
|
20
|
+
// TAB_REFRESH_ALL = 'TAB_REFRESH_ALL'
|
|
21
|
+
// }
|
|
22
|
+
// 拖拽数据接口
|
|
23
|
+
export interface DragData {
|
|
24
|
+
thumbLeft: number
|
|
25
|
+
startScrollLeft: number
|
|
26
|
+
startThumbLeft: number
|
|
27
|
+
startPageX: number
|
|
28
|
+
}
|
|
29
|
+
// 滑块数据接口
|
|
30
|
+
export interface ScrollData {
|
|
31
|
+
clientWidth: number
|
|
32
|
+
scrollWidth: number
|
|
33
|
+
scrollLeft: number
|
|
34
|
+
}
|
|
35
|
+
// 滚动条事件类型
|
|
36
|
+
export type ScrollEvents = {
|
|
37
|
+
ScrollUpdate: void
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Tab data for open
|
|
42
|
+
*/
|
|
43
|
+
export interface ITabData extends ITabBase {
|
|
44
|
+
// tab name
|
|
45
|
+
title: string
|
|
46
|
+
path: string
|
|
47
|
+
query?: Record<string, string>
|
|
48
|
+
}
|
|
49
|
+
export interface ITabBase {
|
|
50
|
+
id?: string
|
|
51
|
+
title: string
|
|
52
|
+
closable?: boolean
|
|
53
|
+
refreshable?: boolean
|
|
54
|
+
iframe?: boolean
|
|
55
|
+
}
|
|
56
|
+
export interface ITabItem extends ITabBase {
|
|
57
|
+
id: string
|
|
58
|
+
closable: boolean
|
|
59
|
+
refreshable: boolean
|
|
60
|
+
iframe: boolean
|
|
61
|
+
url?: string
|
|
62
|
+
active: boolean
|
|
63
|
+
pages: Stack<ITabPage>
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface ITabPage {
|
|
67
|
+
id: string
|
|
68
|
+
tabId: string
|
|
69
|
+
path: string
|
|
70
|
+
query?: Record<string, string>
|
|
71
|
+
}
|
|
72
|
+
export interface IContextMenu {
|
|
73
|
+
icon?: string
|
|
74
|
+
title: string
|
|
75
|
+
callback(id: string): void
|
|
76
|
+
disabled: (tabData: ITabBase) => boolean
|
|
77
|
+
}
|
|
78
|
+
// export interface TabRouteLocationRaw {
|
|
79
|
+
// path: string
|
|
80
|
+
// query?: any
|
|
81
|
+
// }
|
|
82
|
+
// export interface PageRouteLocationRaw {
|
|
83
|
+
// pId: string
|
|
84
|
+
// path: string
|
|
85
|
+
// query: any
|
|
86
|
+
// }
|
|
87
|
+
export class Stack<T> {
|
|
88
|
+
// 存储的Map
|
|
89
|
+
private items: Map<number, T>
|
|
90
|
+
|
|
91
|
+
//
|
|
92
|
+
constructor(items?:T[]) {
|
|
93
|
+
this.items = new Map()
|
|
94
|
+
if(items) {
|
|
95
|
+
for (const item of items) {
|
|
96
|
+
this.push(item)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @description: 入栈
|
|
103
|
+
* @param {T} element 要入栈的元素
|
|
104
|
+
*/
|
|
105
|
+
push(element: T) {
|
|
106
|
+
this.items.set(this.items.size, element)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @description: 出栈
|
|
111
|
+
* @return {T} 返回出栈的元素
|
|
112
|
+
*/
|
|
113
|
+
pop(): T | undefined {
|
|
114
|
+
if (this.isEmpty()) {
|
|
115
|
+
return undefined
|
|
116
|
+
}
|
|
117
|
+
const result = this.items.get(this.items.size - 1)
|
|
118
|
+
this.items.delete(this.items.size - 1)
|
|
119
|
+
return result
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @description: 返回栈顶的元素
|
|
124
|
+
* @return {T}
|
|
125
|
+
*/
|
|
126
|
+
peek(): T | undefined {
|
|
127
|
+
if (this.isEmpty()) {
|
|
128
|
+
return undefined
|
|
129
|
+
}
|
|
130
|
+
return this.items.get(this.items.size - 1)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @description: 返回栈是否为空
|
|
135
|
+
* @return {Boolean}
|
|
136
|
+
*/
|
|
137
|
+
isEmpty(): boolean {
|
|
138
|
+
return this.items.size === 0
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @description: 返回栈里的元素个数
|
|
143
|
+
* @return {Number}
|
|
144
|
+
*/
|
|
145
|
+
size(): number {
|
|
146
|
+
return this.items.size
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* @description: 清空栈
|
|
151
|
+
*/
|
|
152
|
+
clear() {
|
|
153
|
+
this.items.clear()
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
list() {
|
|
157
|
+
return Array.from(this.items.values())
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @description: 覆盖Object默认的toString
|
|
162
|
+
* @return {String}
|
|
163
|
+
*/
|
|
164
|
+
toString(): string {
|
|
165
|
+
if (this.isEmpty()) {
|
|
166
|
+
return ''
|
|
167
|
+
}
|
|
168
|
+
let result: string = ''
|
|
169
|
+
this.items.forEach((value, key) => {
|
|
170
|
+
result = `${result}${key === 0 ? '' : ', '}${value}`
|
|
171
|
+
})
|
|
172
|
+
return result
|
|
173
|
+
}
|
|
174
|
+
toJSON() {
|
|
175
|
+
// return Object.fromEntries(this.items)
|
|
176
|
+
return Array.from(this.items.values())
|
|
177
|
+
}
|
|
178
|
+
}
|