@atooyu/uxto-ui 1.0.0

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 (141) hide show
  1. package/README.md +259 -0
  2. package/dist/index.js +5055 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/index.mjs +5055 -0
  5. package/dist/index.mjs.map +1 -0
  6. package/dist/style.css +2528 -0
  7. package/package.json +93 -0
  8. package/src/components/index.ts +51 -0
  9. package/src/components/u-avatar/u-avatar.vue +205 -0
  10. package/src/components/u-badge/u-badge.vue +145 -0
  11. package/src/components/u-button/u-button.vue +239 -0
  12. package/src/components/u-cell/u-cell.vue +179 -0
  13. package/src/components/u-cell-group/u-cell-group.vue +46 -0
  14. package/src/components/u-checkbox/u-checkbox.vue +174 -0
  15. package/src/components/u-checkbox-group/u-checkbox-group.vue +72 -0
  16. package/src/components/u-code-input/u-code-input.vue +248 -0
  17. package/src/components/u-count-down/u-count-down.vue +182 -0
  18. package/src/components/u-datetime-picker/u-datetime-picker.vue +377 -0
  19. package/src/components/u-divider/u-divider.vue +71 -0
  20. package/src/components/u-empty/u-empty.vue +98 -0
  21. package/src/components/u-grid/u-grid.vue +63 -0
  22. package/src/components/u-grid-item/u-grid-item.vue +170 -0
  23. package/src/components/u-icon/icons/account.svg +3 -0
  24. package/src/components/u-icon/icons/arrow-down.svg +3 -0
  25. package/src/components/u-icon/icons/arrow-left.svg +3 -0
  26. package/src/components/u-icon/icons/arrow-right.svg +3 -0
  27. package/src/components/u-icon/icons/arrow-up.svg +3 -0
  28. package/src/components/u-icon/icons/bell.svg +3 -0
  29. package/src/components/u-icon/icons/bookmark-o.svg +3 -0
  30. package/src/components/u-icon/icons/bookmark.svg +3 -0
  31. package/src/components/u-icon/icons/chat.svg +3 -0
  32. package/src/components/u-icon/icons/check-circle.svg +3 -0
  33. package/src/components/u-icon/icons/check.svg +3 -0
  34. package/src/components/u-icon/icons/chevron-left.svg +3 -0
  35. package/src/components/u-icon/icons/chevron-right.svg +3 -0
  36. package/src/components/u-icon/icons/clear-o.svg +3 -0
  37. package/src/components/u-icon/icons/clear.svg +3 -0
  38. package/src/components/u-icon/icons/clipboard.svg +3 -0
  39. package/src/components/u-icon/icons/clock.svg +3 -0
  40. package/src/components/u-icon/icons/close.svg +3 -0
  41. package/src/components/u-icon/icons/code.svg +3 -0
  42. package/src/components/u-icon/icons/copy.svg +3 -0
  43. package/src/components/u-icon/icons/delete.svg +3 -0
  44. package/src/components/u-icon/icons/download.svg +3 -0
  45. package/src/components/u-icon/icons/edit.svg +3 -0
  46. package/src/components/u-icon/icons/email.svg +3 -0
  47. package/src/components/u-icon/icons/error-o.svg +3 -0
  48. package/src/components/u-icon/icons/error.svg +3 -0
  49. package/src/components/u-icon/icons/exit-fullscreen.svg +3 -0
  50. package/src/components/u-icon/icons/expand-less.svg +3 -0
  51. package/src/components/u-icon/icons/expand-more.svg +3 -0
  52. package/src/components/u-icon/icons/eye-off.svg +3 -0
  53. package/src/components/u-icon/icons/eye.svg +3 -0
  54. package/src/components/u-icon/icons/flag-o.svg +3 -0
  55. package/src/components/u-icon/icons/flag.svg +3 -0
  56. package/src/components/u-icon/icons/fullscreen.svg +3 -0
  57. package/src/components/u-icon/icons/grid.svg +3 -0
  58. package/src/components/u-icon/icons/group.svg +3 -0
  59. package/src/components/u-icon/icons/heart-o.svg +3 -0
  60. package/src/components/u-icon/icons/heart.svg +3 -0
  61. package/src/components/u-icon/icons/info-o.svg +3 -0
  62. package/src/components/u-icon/icons/info.svg +3 -0
  63. package/src/components/u-icon/icons/keyboard-arrow-down.svg +3 -0
  64. package/src/components/u-icon/icons/keyboard-arrow-left.svg +3 -0
  65. package/src/components/u-icon/icons/keyboard-arrow-right.svg +3 -0
  66. package/src/components/u-icon/icons/keyboard-arrow-up.svg +3 -0
  67. package/src/components/u-icon/icons/like-o.svg +3 -0
  68. package/src/components/u-icon/icons/like.svg +3 -0
  69. package/src/components/u-icon/icons/link.svg +3 -0
  70. package/src/components/u-icon/icons/list.svg +3 -0
  71. package/src/components/u-icon/icons/loading.svg +3 -0
  72. package/src/components/u-icon/icons/lock.svg +3 -0
  73. package/src/components/u-icon/icons/menu-o.svg +3 -0
  74. package/src/components/u-icon/icons/menu.svg +3 -0
  75. package/src/components/u-icon/icons/message.svg +3 -0
  76. package/src/components/u-icon/icons/minus.svg +3 -0
  77. package/src/components/u-icon/icons/notification.svg +3 -0
  78. package/src/components/u-icon/icons/phone.svg +3 -0
  79. package/src/components/u-icon/icons/plus.svg +3 -0
  80. package/src/components/u-icon/icons/question.svg +3 -0
  81. package/src/components/u-icon/icons/redo.svg +3 -0
  82. package/src/components/u-icon/icons/refresh-o.svg +3 -0
  83. package/src/components/u-icon/icons/refresh.svg +3 -0
  84. package/src/components/u-icon/icons/reload.svg +3 -0
  85. package/src/components/u-icon/icons/search-o.svg +3 -0
  86. package/src/components/u-icon/icons/search.svg +3 -0
  87. package/src/components/u-icon/icons/setting.svg +3 -0
  88. package/src/components/u-icon/icons/share.svg +3 -0
  89. package/src/components/u-icon/icons/smile-o.svg +3 -0
  90. package/src/components/u-icon/icons/smile.svg +3 -0
  91. package/src/components/u-icon/icons/star-o.svg +3 -0
  92. package/src/components/u-icon/icons/star.svg +3 -0
  93. package/src/components/u-icon/icons/success-o.svg +3 -0
  94. package/src/components/u-icon/icons/success.svg +3 -0
  95. package/src/components/u-icon/icons/sync.svg +3 -0
  96. package/src/components/u-icon/icons/tick.svg +3 -0
  97. package/src/components/u-icon/icons/undo.svg +3 -0
  98. package/src/components/u-icon/icons/unlock.svg +3 -0
  99. package/src/components/u-icon/icons/upload.svg +3 -0
  100. package/src/components/u-icon/icons/user.svg +3 -0
  101. package/src/components/u-icon/icons/warning-o.svg +3 -0
  102. package/src/components/u-icon/icons/warning.svg +3 -0
  103. package/src/components/u-icon/icons/zoom-in.svg +3 -0
  104. package/src/components/u-icon/icons/zoom-out.svg +3 -0
  105. package/src/components/u-icon/index.ts +219 -0
  106. package/src/components/u-icon/u-icon.vue +117 -0
  107. package/src/components/u-image/u-image.vue +106 -0
  108. package/src/components/u-input/u-input.vue +208 -0
  109. package/src/components/u-keyboard/u-keyboard.vue +213 -0
  110. package/src/components/u-layout/u-layout.vue +58 -0
  111. package/src/components/u-line-progress/u-line-progress.vue +156 -0
  112. package/src/components/u-link/u-link.vue +113 -0
  113. package/src/components/u-list/u-list.vue +148 -0
  114. package/src/components/u-list-item/u-list-item.vue +180 -0
  115. package/src/components/u-loading/u-loading.vue +80 -0
  116. package/src/components/u-loading-page/u-loading-page.vue +94 -0
  117. package/src/components/u-modal/u-modal.vue +159 -0
  118. package/src/components/u-notice-bar/u-notice-bar.vue +113 -0
  119. package/src/components/u-number-box/u-number-box.vue +262 -0
  120. package/src/components/u-parse/u-parse.vue +197 -0
  121. package/src/components/u-picker/u-picker.vue +219 -0
  122. package/src/components/u-popup/u-popup.vue +257 -0
  123. package/src/components/u-radio/u-radio.vue +159 -0
  124. package/src/components/u-radio-group/u-radio-group.vue +61 -0
  125. package/src/components/u-rate/u-rate.vue +187 -0
  126. package/src/components/u-read-more/u-read-more.vue +117 -0
  127. package/src/components/u-search/u-search.vue +238 -0
  128. package/src/components/u-skeleton/u-skeleton.vue +192 -0
  129. package/src/components/u-slider/u-slider.vue +453 -0
  130. package/src/components/u-swiper/u-swiper.vue +301 -0
  131. package/src/components/u-swiper-item/u-swiper-item.vue +82 -0
  132. package/src/components/u-switch/u-switch.vue +105 -0
  133. package/src/components/u-tabbar/u-tabbar.vue +221 -0
  134. package/src/components/u-tag/u-tag.vue +144 -0
  135. package/src/components/u-textarea/u-textarea.vue +189 -0
  136. package/src/components/u-toast/u-toast.vue +186 -0
  137. package/src/components/u-tooltip/u-tooltip.vue +364 -0
  138. package/src/components/u-transition/u-transition.vue +216 -0
  139. package/src/components/u-upload/u-upload.vue +403 -0
  140. package/src/styles/index.scss +59 -0
  141. package/src/styles/variables.scss +68 -0
@@ -0,0 +1,301 @@
1
+ <template>
2
+ <view class="u-swiper">
3
+ <swiper
4
+ class="u-swiper__wrapper"
5
+ :autoplay="autoplay"
6
+ :interval="interval"
7
+ :duration="duration"
8
+ :indicator-dots="showIndicator && !indicatorSlot"
9
+ :indicator-color="indicatorColor"
10
+ :indicator-active-color="indicatorActiveColor"
11
+ :circular="circular"
12
+ :vertical="vertical"
13
+ :current="currentIndex"
14
+ @change="handleChange"
15
+ @animationfinish="handleAnimationFinish"
16
+ >
17
+ <slot />
18
+ </swiper>
19
+
20
+ <!-- 加载状态 -->
21
+ <view v-if="loading" class="u-swiper__loading">
22
+ <view class="u-swiper__loading-icon" />
23
+ </view>
24
+
25
+ <!-- 标题 -->
26
+ <view v-if="showTitle && currentTitle" class="u-swiper__title">
27
+ <text class="u-swiper__title-text">{{ currentTitle }}</text>
28
+ </view>
29
+
30
+ <!-- 自定义指示器 -->
31
+ <view v-if="showIndicator && indicatorSlot" class="u-swiper__indicator">
32
+ <slot name="indicator" :current="currentIndex" :total="itemCount" />
33
+ </view>
34
+
35
+ <!-- 默认指示器样式 -->
36
+ <view v-if="showIndicator && !customIndicator && !indicatorSlot" :class="indicatorClass" :style="indicatorStyle">
37
+ <view
38
+ v-for="i in itemCount"
39
+ :key="i"
40
+ class="u-swiper__indicator-item"
41
+ :class="{ 'u-swiper__indicator-item--active': i - 1 === currentIndex }"
42
+ />
43
+ </view>
44
+ </view>
45
+ </template>
46
+
47
+ <script setup lang="ts">
48
+ import { computed, ref, useSlots, watch, provide } from 'vue'
49
+
50
+ type IndicatorPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
51
+
52
+ interface Props {
53
+ autoplay?: boolean
54
+ interval?: number
55
+ duration?: number
56
+ circular?: boolean
57
+ vertical?: boolean
58
+ indicatorDots?: boolean
59
+ indicatorColor?: string
60
+ indicatorActiveColor?: string
61
+ indicatorPosition?: IndicatorPosition
62
+ loading?: boolean
63
+ showTitle?: boolean
64
+ height?: string | number
65
+ card?: boolean
66
+ cardScale?: number
67
+ cardSpace?: number
68
+ }
69
+
70
+ const props = withDefaults(defineProps<Props>(), {
71
+ autoplay: true,
72
+ interval: 3000,
73
+ duration: 500,
74
+ circular: true,
75
+ vertical: false,
76
+ indicatorDots: true,
77
+ indicatorColor: 'rgba(255, 255, 255, 0.5)',
78
+ indicatorActiveColor: '#ffffff',
79
+ indicatorPosition: 'bottom-right',
80
+ loading: false,
81
+ showTitle: false,
82
+ height: 200,
83
+ card: false,
84
+ cardScale: 0.9,
85
+ cardSpace: 10
86
+ })
87
+
88
+ const emit = defineEmits<{
89
+ change: [index: number]
90
+ animationfinish: [index: number]
91
+ }>()
92
+
93
+ const slots = useSlots()
94
+ const currentIndex = ref(0)
95
+ const itemCount = ref(0)
96
+ const currentTitle = ref('')
97
+ const itemTitles = ref<string[]>([])
98
+
99
+ const indicatorSlot = computed(() => Boolean(slots.indicator))
100
+ const customIndicator = computed(() => props.card)
101
+
102
+ const showIndicator = computed(() => props.indicatorDots && itemCount.value > 1)
103
+
104
+ const indicatorClass = computed(() => [
105
+ 'u-swiper__indicator-wrapper',
106
+ `u-swiper__indicator-wrapper--${props.indicatorPosition}`,
107
+ {
108
+ 'u-swiper__indicator-wrapper--vertical': props.vertical
109
+ }
110
+ ])
111
+
112
+ const indicatorStyle = computed(() => {
113
+ const style: Record<string, string> = {}
114
+
115
+ if (props.indicatorColor) {
116
+ style.setProperty('--indicator-color', props.indicatorColor)
117
+ }
118
+ if (props.indicatorActiveColor) {
119
+ style.setProperty('--indicator-active-color', props.indicatorActiveColor)
120
+ }
121
+
122
+ return style
123
+ })
124
+
125
+ const swiperHeight = computed(() => {
126
+ if (typeof props.height === 'number') {
127
+ return `${props.height}px`
128
+ }
129
+ return props.height
130
+ })
131
+
132
+ const registerItem = (title?: string) => {
133
+ const index = itemCount.value
134
+ itemCount.value += 1
135
+ if (title) {
136
+ itemTitles.value.push(title)
137
+ }
138
+ return index
139
+ }
140
+
141
+ const handleChange = (e: any) => {
142
+ const { current } = e.detail
143
+ currentIndex.value = current
144
+ if (itemTitles.value[current]) {
145
+ currentTitle.value = itemTitles.value[current]
146
+ }
147
+ emit('change', current)
148
+ }
149
+
150
+ const handleAnimationFinish = (e: any) => {
151
+ emit('animationfinish', e.detail.current)
152
+ }
153
+
154
+ const setActiveIndex = (index: number) => {
155
+ currentIndex.value = index
156
+ }
157
+
158
+ watch(() => props.loading, (val) => {
159
+ if (!val && itemTitles.value[currentIndex.value]) {
160
+ currentTitle.value = itemTitles.value[currentIndex.value]
161
+ }
162
+ })
163
+
164
+ provide('u-swiper', {
165
+ card: computed(() => props.card),
166
+ cardScale: computed(() => props.cardScale),
167
+ cardSpace: computed(() => props.cardSpace),
168
+ vertical: computed(() => props.vertical),
169
+ height: swiperHeight,
170
+ registerItem,
171
+ setActiveIndex
172
+ })
173
+ </script>
174
+
175
+ <script lang="ts">
176
+ export default {
177
+ options: {
178
+ virtualHost: true,
179
+ styleIsolation: 'shared'
180
+ }
181
+ }
182
+ </script>
183
+
184
+ <style lang="scss" scoped>
185
+ .u-swiper {
186
+ position: relative;
187
+ width: 100%;
188
+ overflow: hidden;
189
+
190
+ &__wrapper {
191
+ width: 100%;
192
+ height: var(--swiper-height, 200px);
193
+ }
194
+
195
+ &__loading {
196
+ position: absolute;
197
+ top: 0;
198
+ left: 0;
199
+ right: 0;
200
+ bottom: 0;
201
+ display: flex;
202
+ align-items: center;
203
+ justify-content: center;
204
+ background-color: rgba(0, 0, 0, 0.3);
205
+ z-index: 10;
206
+
207
+ &-icon {
208
+ width: 32px;
209
+ height: 32px;
210
+ border: 3px solid rgba(255, 255, 255, 0.3);
211
+ border-top-color: #fff;
212
+ border-radius: 50%;
213
+ animation: u-swiper-loading 0.8s linear infinite;
214
+ }
215
+ }
216
+
217
+ @keyframes u-swiper-loading {
218
+ to {
219
+ transform: rotate(360deg);
220
+ }
221
+ }
222
+
223
+ &__title {
224
+ position: absolute;
225
+ left: 0;
226
+ right: 0;
227
+ bottom: 0;
228
+ padding: $--spacing-sm $--spacing-base;
229
+ background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.5));
230
+ z-index: 5;
231
+
232
+ &-text {
233
+ font-size: $--font-size-base;
234
+ color: $--text-color-white;
235
+ line-height: 1.4;
236
+ }
237
+ }
238
+
239
+ &__indicator {
240
+ position: absolute;
241
+ z-index: 5;
242
+ }
243
+
244
+ &__indicator-wrapper {
245
+ position: absolute;
246
+ display: flex;
247
+ z-index: 5;
248
+ padding: $--spacing-xs $--spacing-sm;
249
+
250
+ &--top-left {
251
+ top: 0;
252
+ left: 0;
253
+ }
254
+
255
+ &--top-right {
256
+ top: 0;
257
+ right: 0;
258
+ }
259
+
260
+ &--bottom-left {
261
+ bottom: 0;
262
+ left: 0;
263
+ }
264
+
265
+ &--bottom-right {
266
+ bottom: 0;
267
+ right: 0;
268
+ }
269
+
270
+ &--vertical {
271
+ flex-direction: column;
272
+ }
273
+ }
274
+
275
+ &__indicator-item {
276
+ width: 6px;
277
+ height: 6px;
278
+ border-radius: 50%;
279
+ background-color: var(--indicator-color, rgba(255, 255, 255, 0.5));
280
+ margin: 0 4px;
281
+ transition: all 0.3s;
282
+
283
+ &--active {
284
+ width: 16px;
285
+ border-radius: 4px;
286
+ background-color: var(--indicator-active-color, #fff);
287
+ }
288
+ }
289
+ }
290
+
291
+ .u-swiper__indicator-wrapper--vertical .u-swiper__indicator-item {
292
+ width: 6px;
293
+ height: 6px;
294
+ margin: 4px 0;
295
+
296
+ &--active {
297
+ width: 6px;
298
+ height: 16px;
299
+ }
300
+ }
301
+ </style>
@@ -0,0 +1,82 @@
1
+ <template>
2
+ <swiper-item class="u-swiper-item" :class="{ 'u-swiper-item--card': isCard }" :style="itemStyle">
3
+ <slot />
4
+ </swiper-item>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { computed, inject } from 'vue'
9
+ import type { ComputedRef } from 'vue'
10
+
11
+ interface SwiperContext {
12
+ card: ComputedRef<boolean>
13
+ cardScale: ComputedRef<number>
14
+ cardSpace: ComputedRef<number>
15
+ vertical: ComputedRef<boolean>
16
+ height: ComputedRef<string>
17
+ registerItem: (title?: string) => number
18
+ setActiveIndex: (index: number) => void
19
+ }
20
+
21
+ interface Props {
22
+ title?: string
23
+ }
24
+
25
+ const props = withDefaults(defineProps<Props>(), {
26
+ title: ''
27
+ })
28
+
29
+ const swiper = inject<SwiperContext | null>('u-swiper', null)
30
+
31
+ if (swiper) {
32
+ swiper.registerItem(props.title)
33
+ }
34
+
35
+ const isCard = computed(() => swiper?.card.value ?? false)
36
+ const cardScale = computed(() => swiper?.cardScale.value ?? 0.9)
37
+ const cardSpace = computed(() => swiper?.cardSpace.value ?? 10)
38
+ const isVertical = computed(() => swiper?.vertical.value ?? false)
39
+ const swiperHeight = computed(() => swiper?.height.value ?? '200px')
40
+
41
+ const itemStyle = computed(() => {
42
+ if (!isCard.value) {
43
+ return {}
44
+ }
45
+
46
+ if (isVertical.value) {
47
+ return {
48
+ height: swiperHeight.value,
49
+ padding: `${cardSpace.value}px 0`
50
+ }
51
+ }
52
+
53
+ return {
54
+ width: `${cardScale.value * 100}%`,
55
+ marginLeft: `${(1 - cardScale.value) * 50}%`,
56
+ marginRight: `${(1 - cardScale.value) * 50}%`
57
+ }
58
+ })
59
+ </script>
60
+
61
+ <script lang="ts">
62
+ export default {
63
+ options: {
64
+ virtualHost: true,
65
+ styleIsolation: 'shared'
66
+ }
67
+ }
68
+ </script>
69
+
70
+ <style lang="scss" scoped>
71
+ .u-swiper-item {
72
+ width: 100%;
73
+ height: 100%;
74
+ overflow: hidden;
75
+
76
+ &--card {
77
+ display: flex;
78
+ align-items: center;
79
+ justify-content: center;
80
+ }
81
+ }
82
+ </style>
@@ -0,0 +1,105 @@
1
+ <template>
2
+ <view
3
+ class="u-switch"
4
+ :class="{ 'u-switch--on': modelValue, 'u-switch--disabled': disabled }"
5
+ :style="switchStyle"
6
+ @click="handleClick"
7
+ >
8
+ <view class="u-switch__node" :style="nodeStyle">
9
+ <u-loading v-if="loading" :size="nodeSize" :color="modelValue ? '#fff' : '#999'" />
10
+ </view>
11
+ </view>
12
+ </template>
13
+
14
+ <script setup lang="ts">
15
+ import { computed } from 'vue'
16
+
17
+ interface Props {
18
+ modelValue?: boolean
19
+ disabled?: boolean
20
+ loading?: boolean
21
+ size?: number
22
+ }
23
+
24
+ const props = withDefaults(defineProps<Props>(), {
25
+ modelValue: false,
26
+ disabled: false,
27
+ loading: false,
28
+ size: 30
29
+ })
30
+
31
+ const emit = defineEmits<{
32
+ 'update:modelValue': [value: boolean]
33
+ change: [value: boolean]
34
+ }>()
35
+
36
+ // 计算节点大小
37
+ const nodeSize = computed(() => Math.round(props.size * 0.8))
38
+
39
+ // 开关样式
40
+ const switchStyle = computed(() => ({
41
+ width: `${Math.round(props.size * 1.67)}px`,
42
+ height: `${props.size}px`,
43
+ borderRadius: `${props.size / 2}px`
44
+ }))
45
+
46
+ // 节点样式
47
+ const nodeStyle = computed(() => {
48
+ const node = nodeSize.value
49
+ const gap = Math.round((props.size - node) / 2)
50
+ const translateX = props.modelValue ? props.size - node - gap * 2 : 0
51
+
52
+ return {
53
+ width: `${node}px`,
54
+ height: `${node}px`,
55
+ top: `${gap}px`,
56
+ left: `${gap}px`,
57
+ transform: `translateX(${translateX}px)`
58
+ }
59
+ })
60
+
61
+ const handleClick = () => {
62
+ if (props.disabled || props.loading) return
63
+
64
+ const newValue = !props.modelValue
65
+ emit('update:modelValue', newValue)
66
+ emit('change', newValue)
67
+ }
68
+ </script>
69
+
70
+ <script lang="ts">
71
+ export default {
72
+ options: {
73
+ virtualHost: true,
74
+ styleIsolation: 'shared'
75
+ }
76
+ }
77
+ </script>
78
+
79
+ <style lang="scss" scoped>
80
+ .u-switch {
81
+ position: relative;
82
+ background-color: $--bg-color-3;
83
+ transition: background-color $--transition-duration;
84
+ box-sizing: border-box;
85
+
86
+ &--on {
87
+ background-color: $--color-primary;
88
+ }
89
+
90
+ &--disabled {
91
+ opacity: 0.5;
92
+ }
93
+
94
+ &__node {
95
+ position: absolute;
96
+ background-color: $--bg-color-2;
97
+ border-radius: 50%;
98
+ display: flex;
99
+ align-items: center;
100
+ justify-content: center;
101
+ transition: transform $--transition-duration;
102
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
103
+ }
104
+ }
105
+ </style>
@@ -0,0 +1,221 @@
1
+ <template>
2
+ <view class="u-tabbar">
3
+ <!-- 导航栏背景 -->
4
+ <view class="u-tabbar__nav-wrap">
5
+ <!-- 左侧Tab按钮 -->
6
+ <view
7
+ class="u-tabbar__tab-btn"
8
+ :class="{ 'u-tabbar__tab-btn--active': modelValue === leftTab.value }"
9
+ @click="switchTab(leftTab.value)"
10
+ >
11
+ <text class="u-tabbar__tab-icon">{{ leftTab.icon }}</text>
12
+ <text class="u-tabbar__tab-text">{{ leftTab.label }}</text>
13
+ </view>
14
+
15
+ <!-- 中间占位 + 凸起按钮 -->
16
+ <view class="u-tabbar__center">
17
+ <view
18
+ class="u-tabbar__center-btn"
19
+ :class="{ 'u-tabbar__center-btn--active': modelValue === centerTab.value }"
20
+ @click="switchTab(centerTab.value)"
21
+ >
22
+ <text class="u-tabbar__center-brand">{{ centerBrand }}</text>
23
+ <text class="u-tabbar__center-text">{{ centerLabel }}</text>
24
+ </view>
25
+ </view>
26
+
27
+ <!-- 右侧Tab按钮 -->
28
+ <view
29
+ class="u-tabbar__tab-btn"
30
+ :class="{ 'u-tabbar__tab-btn--active': modelValue === rightTab.value }"
31
+ @click="switchTab(rightTab.value)"
32
+ >
33
+ <text class="u-tabbar__tab-icon">{{ rightTab.icon }}</text>
34
+ <text class="u-tabbar__tab-text">{{ rightTab.label }}</text>
35
+ </view>
36
+ </view>
37
+ </view>
38
+ </template>
39
+
40
+ <script setup lang="ts">
41
+ interface TabItem {
42
+ label: string
43
+ icon: string
44
+ value: string
45
+ }
46
+
47
+ interface Props {
48
+ modelValue?: string
49
+ leftTab?: TabItem
50
+ centerTab?: TabItem
51
+ rightTab?: TabItem
52
+ centerBrand?: string
53
+ centerLabel?: string
54
+ }
55
+
56
+ const props = withDefaults(defineProps<Props>(), {
57
+ modelValue: 'home',
58
+ leftTab: () => ({ label: '首页', icon: '⌂', value: 'home' }),
59
+ centerTab: () => ({ label: '图域', icon: 'TU', value: 'center' }),
60
+ rightTab: () => ({ label: '我的', icon: '◉', value: 'mine' }),
61
+ centerBrand: 'TU',
62
+ centerLabel: '图域'
63
+ })
64
+
65
+ const emit = defineEmits<{
66
+ 'update:modelValue': [value: string]
67
+ 'tab-change': [value: string]
68
+ }>()
69
+
70
+ const switchTab = (tab: string) => {
71
+ emit('update:modelValue', tab)
72
+ emit('tab-change', tab)
73
+ }
74
+ </script>
75
+
76
+ <script lang="ts">
77
+ export default {
78
+ options: {
79
+ virtualHost: true,
80
+ styleIsolation: 'shared'
81
+ }
82
+ }
83
+ </script>
84
+
85
+ <style lang="scss" scoped>
86
+ // 薄荷主题色
87
+ $--mint-1: #12b6af;
88
+ $--mint-2: #9fe4dd;
89
+ $--ink: #1b4d4a;
90
+ $--paper: #ffffff;
91
+
92
+ .u-tabbar {
93
+ position: fixed;
94
+ left: 0;
95
+ right: 0;
96
+ bottom: 0;
97
+ z-index: 999;
98
+ width: 100%;
99
+ }
100
+
101
+ // 导航栏容器 - 胶囊形状
102
+ .u-tabbar__nav-wrap {
103
+ position: absolute;
104
+ left: 14px;
105
+ right: 14px;
106
+ bottom: calc(10px + env(safe-area-inset-bottom));
107
+ /* 鴻蒙兼容 */
108
+ bottom: calc(10px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom)));
109
+ z-index: 5;
110
+ height: 56px;
111
+ border-radius: 28px;
112
+ background: linear-gradient(90deg, $--mint-1 0%, $--mint-2 100%);
113
+ box-shadow: 0 10px 24px rgba(7, 114, 108, 0.3);
114
+ display: flex;
115
+ align-items: center;
116
+ justify-content: space-between;
117
+ padding: 0 8px;
118
+ box-sizing: border-box;
119
+ }
120
+
121
+ // Tab按钮
122
+ .u-tabbar__tab-btn {
123
+ flex: 1;
124
+ height: 40px;
125
+ border-radius: 20px;
126
+ background: transparent;
127
+ display: flex;
128
+ align-items: center;
129
+ justify-content: center;
130
+ gap: 4px;
131
+ font-size: 14px;
132
+ transition: all 200ms ease;
133
+ white-space: nowrap;
134
+ overflow: hidden;
135
+ min-width: 0;
136
+
137
+ &--active {
138
+ background: $--paper;
139
+ color: #0c958e;
140
+ box-shadow: inset 0 0 0 1px rgba(17, 135, 128, 0.14);
141
+ }
142
+ }
143
+
144
+ .u-tabbar__tab-icon {
145
+ font-size: 16px;
146
+ font-weight: 700;
147
+ color: rgba(255, 255, 255, 0.9);
148
+ flex-shrink: 0;
149
+ }
150
+
151
+ .u-tabbar__tab-btn--active .u-tabbar__tab-icon {
152
+ color: #0c958e;
153
+ }
154
+
155
+ .u-tabbar__tab-text {
156
+ font-weight: 600;
157
+ color: rgba(255, 255, 255, 0.9);
158
+ overflow: hidden;
159
+ text-overflow: ellipsis;
160
+ }
161
+
162
+ .u-tabbar__tab-btn--active .u-tabbar__tab-text {
163
+ color: #0c958e;
164
+ }
165
+
166
+ // 中间区域 - 占位
167
+ .u-tabbar__center {
168
+ position: relative;
169
+ width: 72px;
170
+ height: 56px;
171
+ flex-shrink: 0;
172
+ }
173
+
174
+ // 中间凸起按钮
175
+ .u-tabbar__center-btn {
176
+ position: absolute;
177
+ left: 50%;
178
+ top: -22px;
179
+ transform: translateX(-50%);
180
+ width: 72px;
181
+ height: 72px;
182
+ border-radius: 50%;
183
+ border: 2px solid #dff7f4;
184
+ background: linear-gradient(180deg, #65d8d1 0%, #21b5ae 100%);
185
+ color: #fff;
186
+ display: flex;
187
+ flex-direction: column;
188
+ align-items: center;
189
+ justify-content: center;
190
+ gap: 1px;
191
+ box-shadow: 0 8px 20px rgba(8, 112, 106, 0.3);
192
+ transition: all 200ms ease;
193
+
194
+ &:active {
195
+ transform: translateX(-50%) scale(0.95);
196
+ }
197
+
198
+ &--active {
199
+ background: $--paper;
200
+ border-color: $--mint-1;
201
+
202
+ .u-tabbar__center-brand,
203
+ .u-tabbar__center-text {
204
+ color: $--mint-1;
205
+ }
206
+ }
207
+ }
208
+
209
+ .u-tabbar__center-brand {
210
+ font-size: 22px;
211
+ line-height: 1;
212
+ font-weight: 700;
213
+ color: #fff;
214
+ }
215
+
216
+ .u-tabbar__center-text {
217
+ font-size: 12px;
218
+ letter-spacing: 0.5px;
219
+ color: #fff;
220
+ }
221
+ </style>