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.
Files changed (72) hide show
  1. package/{types → dist}/src/lib/hooks/useStackTab.d.ts +2 -2
  2. package/{types → dist}/src/lib/hooks/useTabpanel.d.ts +6 -2
  3. package/{types → dist}/src/lib/index.d.ts +7 -1
  4. package/{types → dist}/src/lib/model/TabModel.d.ts +2 -1
  5. package/dist/style.css +1 -1
  6. package/dist/vue-stack-tabs.es.js +2340 -2321
  7. package/dist/vue-stack-tabs.umd.js +10 -10
  8. package/package.json +3 -4
  9. package/src/lib/StackTabs.vue +136 -126
  10. package/src/lib/assets/style/common/mixins.scss +45 -45
  11. package/src/lib/assets/style/common/var.scss +65 -65
  12. package/src/lib/assets/style/icon.scss +93 -93
  13. package/src/lib/assets/style/index.scss +4 -4
  14. package/src/lib/assets/style/overlayer.scss +40 -40
  15. package/src/lib/assets/style/stackTab.scss +395 -395
  16. package/src/lib/assets/style/transition.scss +40 -40
  17. package/src/lib/banner.ts +51 -51
  18. package/src/lib/components/ContextMenu/ContextMenuItem.vue +15 -15
  19. package/src/lib/components/ContextMenu/index.vue +129 -129
  20. package/src/lib/components/OverlayLoading/Component.vue +182 -191
  21. package/src/lib/components/OverlayLoading/api.ts +31 -31
  22. package/src/lib/components/OverlayLoading/helpers.ts +31 -31
  23. package/src/lib/components/OverlayLoading/index.ts +12 -12
  24. package/src/lib/components/OverlayLoading/loaders/bars.vue +79 -79
  25. package/src/lib/components/OverlayLoading/loaders/dots.vue +92 -92
  26. package/src/lib/components/OverlayLoading/loaders/index.ts +9 -9
  27. package/src/lib/components/OverlayLoading/loaders/spinner.vue +41 -41
  28. package/src/lib/components/TabHeader/TabHeaderButton.vue +35 -35
  29. package/src/lib/components/TabHeader/TabHeaderItem.vue +63 -63
  30. package/src/lib/components/TabHeader/TabHeaderScroll.vue +240 -240
  31. package/src/lib/components/TabHeader/index.vue +135 -135
  32. package/src/lib/hooks/useContextMenu.ts +50 -50
  33. package/src/lib/hooks/useStackTab.ts +74 -65
  34. package/src/lib/hooks/useTabLoading.ts +34 -34
  35. package/src/lib/hooks/useTabRouter.ts +94 -94
  36. package/src/lib/hooks/useTabpanel.tsx +516 -491
  37. package/src/lib/i18n/index.ts +72 -72
  38. package/src/lib/i18n/lang/en.ts +15 -15
  39. package/src/lib/i18n/lang/zh-CN.ts +15 -15
  40. package/src/lib/iframe.vue +7 -7
  41. package/src/lib/index.ts +32 -23
  42. package/src/lib/model/TabModel.ts +178 -169
  43. package/src/lib/utils/TabIdHelper.ts +70 -70
  44. package/src/lib/utils/TabScrollHelper.ts +104 -104
  45. package/src/lib/utils/UriHelper.ts +22 -22
  46. /package/{types → dist}/index.d.ts +0 -0
  47. /package/{types → dist}/src/lib/StackTabs.vue.d.ts +0 -0
  48. /package/{types → dist}/src/lib/banner.d.ts +0 -0
  49. /package/{types → dist}/src/lib/components/ContextMenu/ContextMenuItem.vue.d.ts +0 -0
  50. /package/{types → dist}/src/lib/components/ContextMenu/index.vue.d.ts +0 -0
  51. /package/{types → dist}/src/lib/components/OverlayLoading/Component.vue.d.ts +0 -0
  52. /package/{types → dist}/src/lib/components/OverlayLoading/api.d.ts +0 -0
  53. /package/{types → dist}/src/lib/components/OverlayLoading/helpers.d.ts +0 -0
  54. /package/{types → dist}/src/lib/components/OverlayLoading/index.d.ts +0 -0
  55. /package/{types → dist}/src/lib/components/OverlayLoading/loaders/bars.vue.d.ts +0 -0
  56. /package/{types → dist}/src/lib/components/OverlayLoading/loaders/dots.vue.d.ts +0 -0
  57. /package/{types → dist}/src/lib/components/OverlayLoading/loaders/index.d.ts +0 -0
  58. /package/{types → dist}/src/lib/components/OverlayLoading/loaders/spinner.vue.d.ts +0 -0
  59. /package/{types → dist}/src/lib/components/TabHeader/TabHeaderButton.vue.d.ts +0 -0
  60. /package/{types → dist}/src/lib/components/TabHeader/TabHeaderItem.vue.d.ts +0 -0
  61. /package/{types → dist}/src/lib/components/TabHeader/TabHeaderScroll.vue.d.ts +0 -0
  62. /package/{types → dist}/src/lib/components/TabHeader/index.vue.d.ts +0 -0
  63. /package/{types → dist}/src/lib/hooks/useContextMenu.d.ts +0 -0
  64. /package/{types → dist}/src/lib/hooks/useTabLoading.d.ts +0 -0
  65. /package/{types → dist}/src/lib/hooks/useTabRouter.d.ts +0 -0
  66. /package/{types → dist}/src/lib/i18n/index.d.ts +0 -0
  67. /package/{types → dist}/src/lib/i18n/lang/en.d.ts +0 -0
  68. /package/{types → dist}/src/lib/i18n/lang/zh-CN.d.ts +0 -0
  69. /package/{types → dist}/src/lib/iframe.vue.d.ts +0 -0
  70. /package/{types → dist}/src/lib/utils/TabIdHelper.d.ts +0 -0
  71. /package/{types → dist}/src/lib/utils/TabScrollHelper.d.ts +0 -0
  72. /package/{types → dist}/src/lib/utils/UriHelper.d.ts +0 -0
@@ -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
+ }
@@ -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
+ }
@@ -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,23 +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 './assets/style/index.scss'
10
- const i18n = createI18n({
11
- legacy: false,
12
- locale: 'zh-CN',
13
- fallbackLocale: 'en-US'
14
- })
15
-
16
- export * from './model/TabModel'
17
- export { IFrame, useTabLoading, useTabRouter, useStackTab,StackTab }
18
- export default {
19
- install(Vue: App): void {
20
- tabVersion(import.meta.env.PACKAGE_VERSION)
21
- Vue.component('VueStackTabs', StackTab).use(i18n)
22
- }
23
- }
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
- * @description: 入栈
98
- * @param {T} element 要入栈的元素
99
- */
100
- push(element: T) {
101
- this.items.set(this.items.size, element)
102
- }
103
-
104
- /**
105
- * @description: 出栈
106
- * @return {T} 返回出栈的元素
107
- */
108
- pop(): T | undefined {
109
- if (this.isEmpty()) {
110
- return undefined
111
- }
112
- const result = this.items.get(this.items.size - 1)
113
- this.items.delete(this.items.size - 1)
114
- return result
115
- }
116
-
117
- /**
118
- * @description: 返回栈顶的元素
119
- * @return {T}
120
- */
121
- peek(): T | undefined {
122
- if (this.isEmpty()) {
123
- return undefined
124
- }
125
- return this.items.get(this.items.size - 1)
126
- }
127
-
128
- /**
129
- * @description: 返回栈是否为空
130
- * @return {Boolean}
131
- */
132
- isEmpty(): boolean {
133
- return this.items.size === 0
134
- }
135
-
136
- /**
137
- * @description: 返回栈里的元素个数
138
- * @return {Number}
139
- */
140
- size(): number {
141
- return this.items.size
142
- }
143
-
144
- /**
145
- * @description: 清空栈
146
- */
147
- clear() {
148
- this.items.clear()
149
- }
150
-
151
- list() {
152
- return Array.from(this.items.values())
153
- }
154
-
155
- /**
156
- * @description: 覆盖Object默认的toString
157
- * @return {String}
158
- */
159
- toString(): string {
160
- if (this.isEmpty()) {
161
- return ''
162
- }
163
- let result: string = ''
164
- this.items.forEach((value, key) => {
165
- result = `${result}${key === 0 ? '' : ', '}${value}`
166
- })
167
- return result
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
+ }