@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,213 @@
1
+ <template>
2
+ <view v-if="visible" class="u-keyboard" @click="handleOverlayClick">
3
+ <view class="u-keyboard__panel" @click.stop>
4
+ <view class="u-keyboard__header">
5
+ <text class="u-keyboard__title">{{ title }}</text>
6
+ <text class="u-keyboard__close" @click="handleClose">完成</text>
7
+ </view>
8
+
9
+ <view class="u-keyboard__body" :class="`u-keyboard__body--${type}`">
10
+ <view
11
+ v-for="(key, index) in displayKeys"
12
+ :key="`${key}-${index}`"
13
+ class="u-keyboard__key"
14
+ :class="{
15
+ 'u-keyboard__key--action': isActionKey(key),
16
+ 'u-keyboard__key--wide': key === '删除' || key === 'ABC' || key === '省份'
17
+ }"
18
+ @click="handleKeyClick(key)"
19
+ >
20
+ <text>{{ key }}</text>
21
+ </view>
22
+ </view>
23
+ </view>
24
+ </view>
25
+ </template>
26
+
27
+ <script setup lang="ts">
28
+ import { computed } from 'vue'
29
+
30
+ type KeyboardType = 'number' | 'idcard' | 'car'
31
+
32
+ interface Props {
33
+ visible?: boolean
34
+ type?: KeyboardType
35
+ hideDot?: boolean
36
+ randomKeyOrder?: boolean
37
+ title?: string
38
+ maxlength?: number
39
+ modelValue?: string
40
+ closeOnClickOverlay?: boolean
41
+ }
42
+
43
+ const props = withDefaults(defineProps<Props>(), {
44
+ visible: false,
45
+ type: 'number',
46
+ hideDot: false,
47
+ randomKeyOrder: false,
48
+ title: '安全键盘',
49
+ maxlength: 0,
50
+ modelValue: '',
51
+ closeOnClickOverlay: true
52
+ })
53
+
54
+ const emit = defineEmits<{
55
+ 'update:visible': [value: boolean]
56
+ 'update:modelValue': [value: string]
57
+ input: [value: string]
58
+ delete: [value: string]
59
+ confirm: [value: string]
60
+ close: []
61
+ }>()
62
+
63
+ const displayKeys = computed(() => {
64
+ const { inputKeys, tailKeys } = getKeyGroups()
65
+ const keys = props.randomKeyOrder ? shuffle(inputKeys) : inputKeys
66
+ return [...keys, ...tailKeys]
67
+ })
68
+
69
+ const getKeyGroups = () => {
70
+ if (props.type === 'idcard') {
71
+ const inputKeys = ['1', '2', '3', '4', '5', '6', '7', '8', '9', props.hideDot ? 'X' : '.', '0', 'X']
72
+ return {
73
+ inputKeys: props.hideDot ? inputKeys.filter((key, index) => !(index === 9 && key === 'X')) : inputKeys.filter((key) => key !== '.' || !props.hideDot),
74
+ tailKeys: ['删除']
75
+ }
76
+ }
77
+
78
+ if (props.type === 'car') {
79
+ return {
80
+ inputKeys: [
81
+ '京', '沪', '粤', '浙', '苏', '鲁', '晋', '冀', '豫', '川',
82
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K',
83
+ 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
84
+ 'W', 'X', 'Y', 'Z', '港', '澳'
85
+ ],
86
+ tailKeys: ['删除']
87
+ }
88
+ }
89
+
90
+ return {
91
+ inputKeys: ['1', '2', '3', '4', '5', '6', '7', '8', '9', ...(props.hideDot ? [] : ['.']), '0'],
92
+ tailKeys: ['删除']
93
+ }
94
+ }
95
+
96
+ const handleKeyClick = (key: string) => {
97
+ if (key === '删除') {
98
+ const nextValue = props.modelValue.slice(0, -1)
99
+ emit('update:modelValue', nextValue)
100
+ emit('delete', nextValue)
101
+ return
102
+ }
103
+
104
+ const nextValue = `${props.modelValue}${key}`
105
+ if (props.maxlength > 0 && nextValue.length > props.maxlength) {
106
+ return
107
+ }
108
+
109
+ emit('update:modelValue', nextValue)
110
+ emit('input', nextValue)
111
+ }
112
+
113
+ const handleClose = () => {
114
+ emit('update:visible', false)
115
+ emit('confirm', props.modelValue)
116
+ emit('close')
117
+ }
118
+
119
+ const handleOverlayClick = () => {
120
+ if (props.closeOnClickOverlay) {
121
+ emit('update:visible', false)
122
+ emit('close')
123
+ }
124
+ }
125
+
126
+ const isActionKey = (key: string) => key === '删除' || key === 'ABC' || key === '省份'
127
+
128
+ function shuffle(source: string[]) {
129
+ const list = [...source]
130
+ for (let i = list.length - 1; i > 0; i -= 1) {
131
+ const j = Math.floor(Math.random() * (i + 1))
132
+ ;[list[i], list[j]] = [list[j], list[i]]
133
+ }
134
+ return list
135
+ }
136
+ </script>
137
+
138
+ <script lang="ts">
139
+ export default {
140
+ options: {
141
+ virtualHost: true,
142
+ styleIsolation: 'shared'
143
+ }
144
+ }
145
+ </script>
146
+
147
+ <style lang="scss" scoped>
148
+ .u-keyboard {
149
+ position: fixed;
150
+ inset: 0;
151
+ display: flex;
152
+ align-items: flex-end;
153
+ background: rgba(0, 0, 0, 0.45);
154
+ z-index: 1000;
155
+
156
+ &__panel {
157
+ width: 100%;
158
+ background: $--bg-color;
159
+ border-radius: $--border-radius-lg $--border-radius-lg 0 0;
160
+ padding: $--spacing-md;
161
+ box-sizing: border-box;
162
+ }
163
+
164
+ &__header {
165
+ display: flex;
166
+ align-items: center;
167
+ justify-content: space-between;
168
+ margin-bottom: $--spacing-md;
169
+ }
170
+
171
+ &__title {
172
+ font-size: $--font-size-md;
173
+ color: $--text-color;
174
+ font-weight: 600;
175
+ }
176
+
177
+ &__close {
178
+ font-size: $--font-size-md;
179
+ color: $--color-primary;
180
+ }
181
+
182
+ &__body {
183
+ display: grid;
184
+ grid-template-columns: repeat(3, 1fr);
185
+ gap: $--spacing-sm;
186
+
187
+ &--car {
188
+ grid-template-columns: repeat(6, 1fr);
189
+ }
190
+ }
191
+
192
+ &__key {
193
+ display: flex;
194
+ align-items: center;
195
+ justify-content: center;
196
+ min-height: 44px;
197
+ background: $--bg-color-2;
198
+ border-radius: $--border-radius-md;
199
+ font-size: $--font-size-lg;
200
+ color: $--text-color;
201
+
202
+ &--action {
203
+ background: #d7dbe0;
204
+ color: $--text-color-2;
205
+ font-size: $--font-size-md;
206
+ }
207
+
208
+ &--wide {
209
+ grid-column: span 1;
210
+ }
211
+ }
212
+ }
213
+ </style>
@@ -0,0 +1,58 @@
1
+ <template>
2
+ <view class="u-layout" :class="{ 'u-layout--has-footer': hasFooter }">
3
+ <view v-if="$slots.header" class="u-layout__header">
4
+ <slot name="header" />
5
+ </view>
6
+ <view class="u-layout__content">
7
+ <slot />
8
+ </view>
9
+ <view v-if="$slots.footer" class="u-layout__footer">
10
+ <slot name="footer" />
11
+ </view>
12
+ </view>
13
+ </template>
14
+
15
+ <script setup lang="ts">
16
+ import { useSlots, computed } from 'vue'
17
+
18
+ const slots = useSlots()
19
+
20
+ const hasFooter = computed(() => !!slots.footer)
21
+ </script>
22
+
23
+ <script lang="ts">
24
+ export default {
25
+ options: {
26
+ virtualHost: true,
27
+ styleIsolation: 'shared'
28
+ }
29
+ }
30
+ </script>
31
+
32
+ <style lang="scss" scoped>
33
+ .u-layout {
34
+ display: flex;
35
+ flex-direction: column;
36
+ min-height: 100vh;
37
+ background-color: $--bg-color;
38
+
39
+ &__header {
40
+ position: sticky;
41
+ top: 0;
42
+ z-index: 100;
43
+ background-color: $--bg-color-2;
44
+ }
45
+
46
+ &__content {
47
+ flex: 1;
48
+ overflow: auto;
49
+ }
50
+
51
+ &__footer {
52
+ position: sticky;
53
+ bottom: 0;
54
+ z-index: 100;
55
+ background-color: $--bg-color-2;
56
+ }
57
+ }
58
+ </style>
@@ -0,0 +1,156 @@
1
+ <template>
2
+ <view class="u-line-progress" :style="wrapperStyle">
3
+ <view class="u-line-progress__track" :style="trackStyle">
4
+ <view
5
+ class="u-line-progress__bar"
6
+ :class="{
7
+ 'u-line-progress__bar--striped': striped,
8
+ 'u-line-progress__bar--animated': striped && animated
9
+ }"
10
+ :style="barStyle"
11
+ >
12
+ <text
13
+ v-if="showText && textInside && percentage <= 100"
14
+ class="u-line-progress__text u-line-progress__text--inside"
15
+ >{{ textContent }}</text>
16
+ </view>
17
+ </view>
18
+ <text
19
+ v-if="showText && !textInside"
20
+ class="u-line-progress__text"
21
+ >{{ textContent }}</text>
22
+ </view>
23
+ </template>
24
+
25
+ <script setup lang="ts">
26
+ import { computed } from 'vue'
27
+
28
+ interface Props {
29
+ percentage: number
30
+ height?: number | string
31
+ color?: string
32
+ trackColor?: string
33
+ showText?: boolean
34
+ textInside?: boolean
35
+ format?: (percentage: number) => string
36
+ striped?: boolean
37
+ animated?: boolean
38
+ inactive?: boolean
39
+ }
40
+
41
+ const props = withDefaults(defineProps<Props>(), {
42
+ percentage: 0,
43
+ height: 6,
44
+ color: '#1989fa',
45
+ trackColor: '#e5e5e5',
46
+ showText: true,
47
+ textInside: false,
48
+ striped: false,
49
+ animated: false,
50
+ inactive: false
51
+ })
52
+
53
+ const heightStyle = computed(() => {
54
+ const height = props.height
55
+ return typeof height === 'number' ? `${height}px` : height
56
+ })
57
+
58
+ const wrapperStyle = computed(() => ({
59
+ height: props.textInside ? heightStyle.value : 'auto'
60
+ }))
61
+
62
+ const trackStyle = computed(() => ({
63
+ height: heightStyle.value,
64
+ backgroundColor: props.trackColor,
65
+ borderRadius: heightStyle.value
66
+ }))
67
+
68
+ const barStyle = computed(() => {
69
+ const percentage = Math.min(100, Math.max(0, props.percentage))
70
+ return {
71
+ width: `${percentage}%`,
72
+ backgroundColor: props.inactive ? '#c8c9cc' : props.color,
73
+ borderRadius: heightStyle.value
74
+ }
75
+ })
76
+
77
+ const textContent = computed(() => {
78
+ if (props.format) {
79
+ return props.format(props.percentage)
80
+ }
81
+ return `${Math.round(props.percentage)}%`
82
+ })
83
+ </script>
84
+
85
+ <script lang="ts">
86
+ export default {
87
+ options: {
88
+ virtualHost: true,
89
+ styleIsolation: 'shared'
90
+ }
91
+ }
92
+ </script>
93
+
94
+ <style lang="scss" scoped>
95
+ .u-line-progress {
96
+ display: flex;
97
+ align-items: center;
98
+ width: 100%;
99
+
100
+ &__track {
101
+ flex: 1;
102
+ overflow: hidden;
103
+ position: relative;
104
+ }
105
+
106
+ &__bar {
107
+ height: 100%;
108
+ transition: width 0.3s ease-out;
109
+ position: relative;
110
+
111
+ &--striped {
112
+ background-image: linear-gradient(
113
+ 45deg,
114
+ rgba(255, 255, 255, 0.15) 25%,
115
+ transparent 25%,
116
+ transparent 50%,
117
+ rgba(255, 255, 255, 0.15) 50%,
118
+ rgba(255, 255, 255, 0.15) 75%,
119
+ transparent 75%,
120
+ transparent
121
+ );
122
+ background-size: 1rem 1rem;
123
+ }
124
+
125
+ &--animated {
126
+ animation: u-line-progress-stripes 1s linear infinite;
127
+ }
128
+ }
129
+
130
+ &__text {
131
+ font-size: $--font-size-sm;
132
+ color: $--text-color-2;
133
+ white-space: nowrap;
134
+ margin-left: $--spacing-sm;
135
+
136
+ &--inside {
137
+ position: absolute;
138
+ top: 50%;
139
+ left: 50%;
140
+ transform: translate(-50%, -50%);
141
+ margin-left: 0;
142
+ color: #fff;
143
+ font-size: 12px;
144
+ }
145
+ }
146
+ }
147
+
148
+ @keyframes u-line-progress-stripes {
149
+ from {
150
+ background-position: 1rem 0;
151
+ }
152
+ to {
153
+ background-position: 0 0;
154
+ }
155
+ }
156
+ </style>
@@ -0,0 +1,113 @@
1
+ <template>
2
+ <text
3
+ class="u-link"
4
+ :class="linkClass"
5
+ :style="linkStyle"
6
+ @click="handleClick"
7
+ >
8
+ <slot>{{ text }}</slot>
9
+ </text>
10
+ </template>
11
+
12
+ <script setup lang="ts">
13
+ import { computed } from 'vue'
14
+
15
+ type LinkType = 'default' | 'primary' | 'success' | 'warning' | 'danger'
16
+
17
+ interface Props {
18
+ text?: string
19
+ type?: LinkType
20
+ color?: string
21
+ underline?: boolean
22
+ href?: string
23
+ disabled?: boolean
24
+ }
25
+
26
+ const props = withDefaults(defineProps<Props>(), {
27
+ text: '',
28
+ type: 'default',
29
+ underline: false,
30
+ disabled: false
31
+ })
32
+
33
+ const emit = defineEmits<{
34
+ (e: 'click'): void
35
+ }>()
36
+
37
+ const linkClass = computed(() => [
38
+ `u-link--${props.type}`,
39
+ {
40
+ 'u-link--underline': props.underline,
41
+ 'u-link--disabled': props.disabled
42
+ }
43
+ ])
44
+
45
+ const linkStyle = computed(() => {
46
+ const style: Record<string, string> = {}
47
+ if (props.color) {
48
+ style.color = props.color
49
+ }
50
+ return style
51
+ })
52
+
53
+ const handleClick = () => {
54
+ if (props.disabled) return
55
+
56
+ if (props.href) {
57
+ // 在新窗口打开链接
58
+ // uni-app 环境下使用特定方法
59
+ // #ifdef H5
60
+ window.open(props.href, '_blank')
61
+ // #endif
62
+ }
63
+
64
+ emit('click')
65
+ }
66
+ </script>
67
+
68
+ <script lang="ts">
69
+ export default {
70
+ options: {
71
+ virtualHost: true,
72
+ styleIsolation: 'shared'
73
+ }
74
+ }
75
+ </script>
76
+
77
+ <style lang="scss" scoped>
78
+ .u-link {
79
+ display: inline;
80
+ color: $--text-color-2;
81
+ font-size: inherit;
82
+ word-break: break-all;
83
+
84
+ &--default {
85
+ color: $--text-color-2;
86
+ }
87
+
88
+ &--primary {
89
+ color: $--color-primary;
90
+ }
91
+
92
+ &--success {
93
+ color: $--color-success;
94
+ }
95
+
96
+ &--warning {
97
+ color: $--color-warning;
98
+ }
99
+
100
+ &--danger {
101
+ color: $--color-danger;
102
+ }
103
+
104
+ &--underline {
105
+ text-decoration: underline;
106
+ }
107
+
108
+ &--disabled {
109
+ color: $--text-color-3;
110
+ opacity: 0.5;
111
+ }
112
+ }
113
+ </style>
@@ -0,0 +1,148 @@
1
+ <template>
2
+ <view class="u-list">
3
+ <!-- 列表头部 -->
4
+ <view v-if="$slots.header || header" class="u-list__header">
5
+ <slot name="header">{{ header }}</slot>
6
+ </view>
7
+
8
+ <!-- 列表内容 -->
9
+ <view class="u-list__content">
10
+ <slot />
11
+ </view>
12
+
13
+ <!-- 加载状态 -->
14
+ <view v-if="loading" class="u-list__loading">
15
+ <view class="u-list__loading-icon"></view>
16
+ <text class="u-list__loading-text">{{ loadingText }}</text>
17
+ </view>
18
+
19
+ <!-- 加载完成 -->
20
+ <view v-if="finished && !loading" class="u-list__finished">
21
+ <text class="u-list__finished-text">{{ finishedText }}</text>
22
+ </view>
23
+
24
+ <!-- 加载失败 -->
25
+ <view v-if="error && !loading" class="u-list__error" @click="handleErrorClick">
26
+ <text class="u-list__error-text">{{ errorText }}</text>
27
+ </view>
28
+
29
+ <!-- 列表底部 -->
30
+ <view v-if="$slots.footer || footer" class="u-list__footer">
31
+ <slot name="footer">{{ footer }}</slot>
32
+ </view>
33
+ </view>
34
+ </template>
35
+
36
+ <script setup lang="ts">
37
+ interface Props {
38
+ loading?: boolean
39
+ finished?: boolean
40
+ error?: boolean
41
+ loadingText?: string
42
+ finishedText?: string
43
+ errorText?: string
44
+ header?: string
45
+ footer?: string
46
+ immediateCheck?: boolean
47
+ offset?: number
48
+ direction?: 'up' | 'down'
49
+ }
50
+
51
+ const props = withDefaults(defineProps<Props>(), {
52
+ loading: false,
53
+ finished: false,
54
+ error: false,
55
+ loadingText: '加载中...',
56
+ finishedText: '加载完成',
57
+ errorText: '加载失败,点击重试',
58
+ header: '',
59
+ footer: '',
60
+ immediateCheck: true,
61
+ offset: 50,
62
+ direction: 'down'
63
+ })
64
+
65
+ const emit = defineEmits<{
66
+ load: []
67
+ 'update:loading': [value: boolean]
68
+ 'update:error': [value: boolean]
69
+ }>()
70
+
71
+ const handleErrorClick = () => {
72
+ emit('update:error', false)
73
+ emit('load')
74
+ }
75
+ </script>
76
+
77
+ <script lang="ts">
78
+ export default {
79
+ options: {
80
+ virtualHost: true,
81
+ styleIsolation: 'shared'
82
+ }
83
+ }
84
+ </script>
85
+
86
+ <style lang="scss" scoped>
87
+ .u-list {
88
+ width: 100%;
89
+
90
+ &__header,
91
+ &__footer {
92
+ padding: $--spacing-md $--spacing-lg;
93
+ font-size: $--font-size-sm;
94
+ color: $--text-color-2;
95
+ }
96
+
97
+ &__content {
98
+ min-height: 50px;
99
+ }
100
+
101
+ &__loading,
102
+ &__finished,
103
+ &__error {
104
+ display: flex;
105
+ align-items: center;
106
+ justify-content: center;
107
+ padding: $--spacing-lg;
108
+ font-size: $--font-size-md;
109
+ color: $--text-color-2;
110
+ }
111
+
112
+ &__loading {
113
+ gap: $--spacing-sm;
114
+ }
115
+
116
+ &__loading-icon {
117
+ width: 16px;
118
+ height: 16px;
119
+ border: 2px solid $--border-color;
120
+ border-top-color: $--color-primary;
121
+ border-radius: 50%;
122
+ animation: u-list-spin 0.8s linear infinite;
123
+ }
124
+
125
+ &__loading-text,
126
+ &__finished-text,
127
+ &__error-text {
128
+ font-size: $--font-size-sm;
129
+ color: $--text-color-2;
130
+ }
131
+
132
+ &__error {
133
+ }
134
+
135
+ &__error-text {
136
+ color: $--color-primary;
137
+ }
138
+ }
139
+
140
+ @keyframes u-list-spin {
141
+ from {
142
+ transform: rotate(0deg);
143
+ }
144
+ to {
145
+ transform: rotate(360deg);
146
+ }
147
+ }
148
+ </style>