vue-stack-tabs 0.1.36 → 0.1.37

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.
@@ -1,12 +1,12 @@
1
1
  import { useRouter } from 'vue-router'
2
2
  import useTabpanel from '../hooks/useTabpanel'
3
- import { throttle } from 'lodash-es'
3
+ import { throttle } from 'throttle-debounce'
4
4
  import type { ITabData } from '../model/TabModel'
5
5
  import { defu } from 'defu'
6
6
 
7
7
  import { encodeTabInfo } from '../utils/TabIdHelper'
8
8
  import { uriDecode } from '../utils/UriHelper'
9
- import { ulid } from 'ulidx'
9
+ import { ulid } from 'ulid'
10
10
  import { MittType, useEmitter } from './useTabMitt'
11
11
  import { nextTick } from 'vue'
12
12
 
@@ -20,13 +20,17 @@ export default () => {
20
20
  * @param tab
21
21
  * @param to
22
22
  */
23
- const openNewTab = throttle((tab: ITabData, renew = false) => {
23
+ const openNewTab = throttle(500, (tab: ITabData, renew = false) => {
24
24
  return new Promise((resolve, reject) => {
25
25
  if (!pageShown.value) {
26
26
  reject()
27
27
  return
28
28
  }
29
- const tabInfo = defu(tab, { refreshable: true, closable: true, iframe: false })
29
+ const tabInfo = defu(tab, {
30
+ refreshable: true,
31
+ closable: true,
32
+ iframe: false
33
+ })
30
34
  if (tabInfo.id && renew && hasTab(tabInfo.id!)) {
31
35
  renewTab(tab)
32
36
  const currentTab = getTab(tab.id!)
@@ -80,7 +84,7 @@ export default () => {
80
84
  resolve(tabInfo.id)
81
85
  // }
82
86
  })
83
- }, 500)
87
+ })
84
88
  const toPage = (tab: ITabData, tabInfo: any) => {
85
89
  const __tab = encodeTabInfo(tabInfo)
86
90
  let query = defu(
@@ -6,12 +6,14 @@ import { type RouteLocationPathRaw, useRoute, useRouter } from 'vue-router'
6
6
 
7
7
  import useTabpanel from '@/lib/hooks/useTabpanel'
8
8
  import { uriDecode } from '@/lib/utils/UriHelper'
9
+ import { useEmitter } from '@/lib/hooks/useTabMitt'
9
10
  export default () => {
10
11
  const { attrs, props } = getCurrentInstance() as ComponentInternalInstance
11
12
  const { pageShown, getTab, markDeletableCache, removeComponent, getComponent, addPageScroller } =
12
13
  useTabpanel()
13
14
  const route = useRoute()
14
15
  const router = useRouter()
16
+ const emitter = useEmitter()
15
17
  let currentId = ''
16
18
  // const currentPageId = ''
17
19
  let currentTab = ''
@@ -31,6 +33,7 @@ export default () => {
31
33
  },
32
34
  to.query
33
35
  )
36
+ emitter.emit('FORWARD')
34
37
  router.push({
35
38
  path: to.path,
36
39
  query
@@ -85,6 +88,7 @@ export default () => {
85
88
  const sourceComponent = component.components.DynamicComponent
86
89
  sourceComponent.props = defu(query, sourceComponent.props)
87
90
  }
91
+ emitter.emit('BACKWARD')
88
92
  router.push({
89
93
  path: pageRoute!.path,
90
94
  query: pageRoute!.query
@@ -12,7 +12,7 @@ import {
12
12
  import type { DefineComponent, VNode } from 'vue'
13
13
  import { useRouter } from 'vue-router'
14
14
  import type { RouteLocationNormalizedLoaded } from 'vue-router'
15
- import { ulid } from 'ulidx'
15
+ import { ulid } from 'ulid'
16
16
  import { encodeTabInfo, createPageId, decodeTabInfo } from '../utils/TabIdHelper'
17
17
  import { defu } from 'defu'
18
18
  import { Stack } from '../model/TabModel'
@@ -588,6 +588,7 @@ export default () => {
588
588
  */
589
589
  const active = (id: string, route = true) => {
590
590
  // return new Promise((resolve)=>{
591
+ emitter.emit('FORWARD')
591
592
  for (let i = tabs.value.length - 1; i >= 0; i--) {
592
593
  const tab = tabs.value[i] as ITabItem
593
594
  if (tab.id === id) {