vue-stack-tabs 0.1.37 → 0.1.39

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,135 +1,135 @@
1
- <script lang="ts" setup>
2
- import { onBeforeMount, onBeforeUnmount, provide, ref } from 'vue'
3
- import type { TransitionProps, DefineComponent, VNode } from 'vue'
4
- import { type RouteLocationNormalizedLoaded } from 'vue-router'
5
- import { getMaxZIndex } from './utils/TabScrollHelper'
6
- import { type ITabData, TabScrollMode } from './model/TabModel'
7
- import TabHeader from './components/TabHeader/index.vue'
8
- import useTabpanel from './hooks/useTabpanel'
9
- import useStackTab from './hooks/useStackTab'
10
- import { useI18n } from 'vue-i18n-lite'
11
- import { useEmitter } from '@/lib/hooks/useTabMitt'
12
- const { tabs, pageShown, caches, destroy, addPage, initial, setMaxSize, setGlobalScroll } =
13
- useTabpanel()
14
- const emit = defineEmits(['onActive', 'onPageLoaded'])
15
- const props = withDefaults(
16
- defineProps<{
17
- // 初始页签数据
18
- defaultTabs?: ITabData[]
19
- // 最大打开数量
20
- max?: number
21
- // 新页加入哪个位置
22
- append?: string
23
- // 右键菜单
24
- contextmenu?: boolean | object
25
- // 页面转场效果
26
- pageTransition?: string
27
- pageTransitionBack?: string
28
- // 标签转场效果
29
- tabTransition?: string | TransitionProps
30
- // tab 滚动效果
31
- tabScrollMode?: TabScrollMode
32
- width?: string
33
- height?: string
34
- i18n?: string
35
- space?: number
36
- globalScroll: boolean
37
- iframePath: string
38
- }>(),
39
- {
40
- defaultTabs: () => [],
41
- max: 20,
42
- append: 'last',
43
- contextmenu: true,
44
- tabTransition: 'stack-tab-zoom',
45
- pageTransition: 'stack-tab-swap',
46
- pageTransitionBack: 'stack-tab-swap-back',
47
- tabScrollMode: TabScrollMode.BOTH,
48
- width: '100%',
49
- height: '100%',
50
- i18n: 'zh-CN',
51
- space: 300,
52
- globalScroll: false
53
- }
54
- )
55
- // provide('locales', { ...props.i18n })
56
- // 最大化,并向下传递
57
- const { changeLocale } = useI18n()
58
- const maximum = ref<boolean>(false)
59
- provide('maximum', maximum)
60
- const { setIFramePath } = useStackTab()
61
- setIFramePath(props.iframePath)
62
- setGlobalScroll(props.globalScroll)
63
- changeLocale(props.i18n)
64
- onBeforeMount(() => {
65
- console.log('on Before mount')
66
- initial(props.defaultTabs)
67
- })
68
- const tabWrapper = (route: RouteLocationNormalizedLoaded, component: VNode): DefineComponent => {
69
- // return defineAsyncComponent(() => addPage(route, component))
70
- return addPage(route, component)
71
- }
72
- const onTabActive = (id: string) => {
73
- emit('onActive', id)
74
- }
75
- setMaxSize(props.max)
76
- onBeforeUnmount(() => {
77
- destroy()
78
- })
79
- const onComponentLoaded = () => {
80
- emit('onPageLoaded')
81
- }
82
- const pageSwitch = ref<string>(props.pageTransition)
83
- const emitter = useEmitter()
84
- emitter.on('FORWARD', () => {
85
- pageSwitch.value = props.pageTransition
86
- })
87
- emitter.on('BACKWARD', () => {
88
- pageSwitch.value = props.pageTransitionBack
89
- })
90
- </script>
91
- <template>
92
- <div
93
- class="stack-tab"
94
- :style="{
95
- width: width,
96
- height: height,
97
- 'z-index': maximum ? getMaxZIndex('body *:not(.stack-tab,.stack-tab *)') : undefined
98
- }"
99
- :class="{ 'stack-tab__maximum': maximum }"
100
- >
101
- <tab-header :space="space" @active="onTabActive" :tab-transition="tabTransition" :max="max">
102
- <template #leftButton>
103
- <slot name="leftButton" />
104
- </template>
105
- <template #rightButton>
106
- <slot name="rightButton" />
107
- </template>
108
- </tab-header>
109
- <div class="stack-tab__container">
110
- <router-view v-slot="{ Component, route }">
111
- <transition :name="pageSwitch" appear mode="out-in">
112
- <keep-alive :include="caches">
113
- <component
114
- :is="tabWrapper(route, Component)"
115
- v-if="pageShown"
116
- :key="route.fullPath"
117
- @on-loaded="onComponentLoaded"
118
- />
119
- </keep-alive>
120
- </transition>
121
- </router-view>
122
- <transition-group :name="pageTransition" appear>
123
- <iframe
124
- v-for="frame of tabs.filter((item) => item.iframe)"
125
- v-show="frame.active"
126
- :key="frame.id"
127
- class="stack-tab__iframe"
128
- :src="/^(javascript|data):/i.test(frame.url ?? '') ? 'about:blank' : frame.url"
129
- frameborder="0"
130
- />
131
- </transition-group>
132
- </div>
133
- </div>
134
- </template>
135
- <style scoped></style>
1
+ <script lang="ts" setup>
2
+ import { onBeforeMount, onBeforeUnmount, provide, ref } from 'vue'
3
+ import type { TransitionProps, DefineComponent, VNode } from 'vue'
4
+ import { type RouteLocationNormalizedLoaded } from 'vue-router'
5
+ import { getMaxZIndex } from './utils/TabScrollHelper'
6
+ import { type ITabData, TabScrollMode } from './model/TabModel'
7
+ import TabHeader from './components/TabHeader/index.vue'
8
+ import useTabpanel from './hooks/useTabpanel'
9
+ import useStackTab from './hooks/useStackTab'
10
+ import { useI18n } from 'vue-i18n-lite'
11
+ import { useEmitter } from '@/lib/hooks/useTabMitt'
12
+ const { tabs, pageShown, caches, destroy, addPage, initial, setMaxSize, setGlobalScroll } =
13
+ useTabpanel()
14
+ const emit = defineEmits(['onActive', 'onPageLoaded'])
15
+ const props = withDefaults(
16
+ defineProps<{
17
+ // 初始页签数据
18
+ defaultTabs?: ITabData[]
19
+ // 最大打开数量
20
+ max?: number
21
+ // 新页加入哪个位置
22
+ append?: string
23
+ // 右键菜单
24
+ contextmenu?: boolean | object
25
+ // 页面转场效果
26
+ pageTransition?: string
27
+ pageTransitionBack?: string
28
+ // 标签转场效果
29
+ tabTransition?: string | TransitionProps
30
+ // tab 滚动效果
31
+ tabScrollMode?: TabScrollMode
32
+ width?: string
33
+ height?: string
34
+ i18n?: string
35
+ space?: number
36
+ globalScroll: boolean
37
+ iframePath: string
38
+ }>(),
39
+ {
40
+ defaultTabs: () => [],
41
+ max: 20,
42
+ append: 'last',
43
+ contextmenu: true,
44
+ tabTransition: 'stack-tab-zoom',
45
+ pageTransition: 'stack-tab-swap',
46
+ pageTransitionBack: 'stack-tab-swap-back',
47
+ tabScrollMode: TabScrollMode.BOTH,
48
+ width: '100%',
49
+ height: '100%',
50
+ i18n: 'zh-CN',
51
+ space: 300,
52
+ globalScroll: false
53
+ }
54
+ )
55
+ // provide('locales', { ...props.i18n })
56
+ // 最大化,并向下传递
57
+ const { changeLocale } = useI18n()
58
+ const maximum = ref<boolean>(false)
59
+ provide('maximum', maximum)
60
+ const { setIFramePath } = useStackTab()
61
+ setIFramePath(props.iframePath)
62
+ setGlobalScroll(props.globalScroll)
63
+ changeLocale(props.i18n)
64
+ onBeforeMount(() => {
65
+ console.log('on Before mount')
66
+ initial(props.defaultTabs)
67
+ })
68
+ const tabWrapper = (route: RouteLocationNormalizedLoaded, component: VNode): DefineComponent => {
69
+ // return defineAsyncComponent(() => addPage(route, component))
70
+ return addPage(route, component)
71
+ }
72
+ const onTabActive = (id: string) => {
73
+ emit('onActive', id)
74
+ }
75
+ setMaxSize(props.max)
76
+ onBeforeUnmount(() => {
77
+ destroy()
78
+ })
79
+ const onComponentLoaded = () => {
80
+ emit('onPageLoaded')
81
+ }
82
+ const pageSwitch = ref<string>(props.pageTransition)
83
+ const emitter = useEmitter()
84
+ emitter.on('FORWARD', () => {
85
+ pageSwitch.value = props.pageTransition
86
+ })
87
+ emitter.on('BACKWARD', () => {
88
+ pageSwitch.value = props.pageTransitionBack
89
+ })
90
+ </script>
91
+ <template>
92
+ <div
93
+ class="stack-tab"
94
+ :style="{
95
+ width: width,
96
+ height: height,
97
+ 'z-index': maximum ? getMaxZIndex('body *:not(.stack-tab,.stack-tab *)') : undefined
98
+ }"
99
+ :class="{ 'stack-tab__maximum': maximum }"
100
+ >
101
+ <tab-header :space="space" @active="onTabActive" :tab-transition="tabTransition" :max="max">
102
+ <template #leftButton>
103
+ <slot name="leftButton" />
104
+ </template>
105
+ <template #rightButton>
106
+ <slot name="rightButton" />
107
+ </template>
108
+ </tab-header>
109
+ <div class="stack-tab__container">
110
+ <router-view v-slot="{ Component, route }">
111
+ <transition :name="pageSwitch" appear mode="out-in">
112
+ <keep-alive :include="caches">
113
+ <component
114
+ :is="tabWrapper(route, Component)"
115
+ v-if="pageShown"
116
+ :key="route.fullPath"
117
+ @on-loaded="onComponentLoaded"
118
+ />
119
+ </keep-alive>
120
+ </transition>
121
+ </router-view>
122
+ <transition-group :name="pageTransition" appear>
123
+ <iframe
124
+ v-for="frame of tabs.filter((item) => item.iframe)"
125
+ v-show="frame.active"
126
+ :key="frame.id"
127
+ class="stack-tab__iframe"
128
+ :src="/^(javascript|data):/i.test(frame.url ?? '') ? 'about:blank' : frame.url"
129
+ frameborder="0"
130
+ />
131
+ </transition-group>
132
+ </div>
133
+ </div>
134
+ </template>
135
+ <style scoped></style>
@@ -1,4 +1,4 @@
1
- @import 'var';
1
+ @use 'var' as *;
2
2
  /*
3
3
  icon按钮特效
4
4
  */
@@ -6,13 +6,13 @@ icon按钮特效
6
6
  width: $icon-size;
7
7
  height: $icon-size;
8
8
  margin-left: $icon-margin;
9
- background-color: $--stack-tab-text-color;
9
+ background-color: $stack-tab-text-color;
10
10
  mask: url($icon-url) no-repeat center center;
11
11
  mask-size: contain;
12
12
 
13
13
  &:hover {
14
14
  cursor: pointer;
15
- background-color: $--stack-tab-color-primary;
15
+ background-color: $stack-tab-color-primary;
16
16
  animation: rotate-center 0.3s ease-in-out both;
17
17
  mask:
18
18
  url($icon-url),
@@ -25,7 +25,7 @@ icon按钮特效
25
25
  /*
26
26
  cursor: pointer;
27
27
  */
28
- background-color: $--stack-tab-color-primary-activate;
28
+ background-color: $stack-tab-color-primary-activate;
29
29
  mask:
30
30
  url($icon-url),
31
31
  url('./image/mask.svg') no-repeat center center;
@@ -1,65 +1,66 @@
1
+ @use "sass:color";
1
2
  /*
2
3
  主色调
3
4
  */
4
- $--stack-tab-color-primary: #409eff !default;
5
- $--stack-tab-color-primary-invert: #ffac30 !default;
5
+ $stack-tab-color-primary: #409eff !default;
6
+ $stack-tab-color-primary-invert: #ffac30 !default;
6
7
  /*
7
8
  大红色
8
9
  */
9
- $--stack-tab-color-danger: #ef4f4f !default;
10
+ $stack-tab-color-danger: #ef4f4f !default;
10
11
  /*
11
12
  白色
12
13
  */
13
- $--stack-tab-color-white: #fff !default;
14
+ $stack-tab-color-white: #fff !default;
14
15
  /*
15
16
  黑色
16
17
  */
17
- $--stack-tab-color-black: #000 !default;
18
- $--stack-tab-color-grey: #4d4d4d !default;
19
- $--stack-tab-color-disabled: #aaa !default;
18
+ $stack-tab-color-black: #000 !default;
19
+ $stack-tab-color-grey: #4d4d4d !default;
20
+ $stack-tab-color-disabled: #aaa !default;
20
21
  /*
21
22
  ICON点击颜色
22
23
  */
23
- $--stack-tab-color-primary-activate: mix($--stack-tab-color-primary, #000, 80%) !default;
24
+ $stack-tab-color-primary-activate: color.mix($stack-tab-color-primary, #000, 80%) !default;
24
25
  /*
25
26
  背景颜色
26
27
  */
27
- $--stack-tab-background-color-base: #fff !default;
28
- $--stack-tab-background-color-inactive: #fafafa !default;
28
+ $stack-tab-background-color-base: #fff !default;
29
+ $stack-tab-background-color-inactive: #fafafa !default;
29
30
  /*
30
31
  tab边框颜色
31
32
  */
32
- $--stack-tab-border-color: #f0f0f0;
33
- $--stack-tab-border: 1px solid $--stack-tab-border-color;
33
+ $stack-tab-border-color: #f0f0f0;
34
+ $stack-tab-border: 1px solid $stack-tab-border-color;
34
35
  /*
35
36
  tab文本颜色
36
37
  */
37
- $--stack-tab-text-color: $--stack-tab-color-grey;
38
+ $stack-tab-text-color: $stack-tab-color-grey;
38
39
  /*
39
40
  tab文本大小
40
41
  */
41
- $--stack-tab-font-size: 14px;
42
+ $stack-tab-font-size: 14px;
42
43
 
43
- $--stack-tab-padding: 24px;
44
- $--stack-tab-icon-margin: 4px;
45
- $--stack-tab-icon-size: 14px;
44
+ $stack-tab-padding: 24px;
45
+ $stack-tab-icon-margin: 4px;
46
+ $stack-tab-icon-size: 14px;
46
47
 
47
- $--stack-tab-button-size: 20px;
48
+ $stack-tab-button-size: 20px;
48
49
  /*
49
50
  tab头高度
50
51
  */
51
- $--stack-tab-head-height: 40px;
52
- $--stack-tab-head-invalid-height: $--stack-tab-head-height -3px;
52
+ $stack-tab-head-height: 40px;
53
+ $stack-tab-head-invalid-height: $stack-tab-head-height -3px;
53
54
 
54
- $--stack-tab-scroll-height: 6px;
55
- $--stack-tab-scroll-border-radius: $--stack-tab-scroll-height;
56
- $--stack-tab__trans: all 0.15s ease-in-out;
55
+ $stack-tab-scroll-height: 6px;
56
+ $stack-tab-scroll-border-radius: $stack-tab-scroll-height;
57
+ $stack-tab__trans: all 0.15s ease-in-out;
57
58
 
58
59
  /*
59
60
  阴影
60
61
  */
61
- $--stack-tab-shadow-left: -5px 0 5px -5px rgb(0 0 0 / 60%); //#ccc;
62
- $--stack-tab-shadow-right: 5px 0 5px -5px rgb(0 0 0 / 60%); //#ccc;
63
- $--stack-tab-shadow-right-inset: inset -5px 0 5px -5px rgb(0 0 0 / 60%); //#ccc;
64
- $--stack-tab-shadow-left-inset: inset 5px 0 5px -5px rgb(0 0 0 / 60%); //#ccc;
65
- $--stack-tab-shadow-context-menu: 5px 5px 5px rgb(0 0 0 / 10%);
62
+ $stack-tab-shadow-left: -5px 0 5px -5px rgb(0 0 0 / 60%); //#ccc;
63
+ $stack-tab-shadow-right: 5px 0 5px -5px rgb(0 0 0 / 60%); //#ccc;
64
+ $stack-tab-shadow-right-inset: inset -5px 0 5px -5px rgb(0 0 0 / 60%); //#ccc;
65
+ $stack-tab-shadow-left-inset: inset 5px 0 5px -5px rgb(0 0 0 / 60%); //#ccc;
66
+ $stack-tab-shadow-context-menu: 5px 5px 5px rgb(0 0 0 / 10%);
@@ -1,4 +1,4 @@
1
- @import './common/var';
1
+ @use 'common/var' as *;
2
2
 
3
3
  // 全屏
4
4
  .stack-tab__icon-fullscreen {
@@ -1,4 +1,4 @@
1
- @import 'stackTab';
2
- @import 'icon';
3
- @import 'transition';
4
- @import 'overlayer';
1
+ @use 'stackTab.scss';
2
+ @use 'icon.scss';
3
+ @use 'transition.scss';
4
+ @use 'overlayer.scss';