muzhiyu-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.
- package/README.md +202 -0
- package/components/muzhiyu/mu-action-sheet/mu-action-sheet.vue +335 -0
- package/components/muzhiyu/mu-alert/mu-alert.vue +220 -0
- package/components/muzhiyu/mu-back-top/mu-back-top.vue +161 -0
- package/components/muzhiyu/mu-badge/mu-badge.vue +150 -0
- package/components/muzhiyu/mu-barcode/mu-barcode.vue +100 -0
- package/components/muzhiyu/mu-blank/mu-blank.vue +30 -0
- package/components/muzhiyu/mu-bottom-nav/mu-bottom-nav.vue +331 -0
- package/components/muzhiyu/mu-bubble/mu-bubble.vue +316 -0
- package/components/muzhiyu/mu-button/mu-button.vue +431 -0
- package/components/muzhiyu/mu-calendar/mu-calendar.vue +429 -0
- package/components/muzhiyu/mu-car-input/mu-car-input.vue +209 -0
- package/components/muzhiyu/mu-card/mu-card.vue +317 -0
- package/components/muzhiyu/mu-cascader/mu-cascader.vue +336 -0
- package/components/muzhiyu/mu-cell/mu-cell.vue +368 -0
- package/components/muzhiyu/mu-checkbox/mu-checkbox.vue +116 -0
- package/components/muzhiyu/mu-checkbox-group/mu-checkbox-group.vue +40 -0
- package/components/muzhiyu/mu-code-input/mu-code-input.vue +264 -0
- package/components/muzhiyu/mu-collapse/mu-collapse.vue +316 -0
- package/components/muzhiyu/mu-color-picker/mu-color-picker.vue +466 -0
- package/components/muzhiyu/mu-config/index.js +34 -0
- package/components/muzhiyu/mu-config/mu-config.vue +54 -0
- package/components/muzhiyu/mu-countdown/mu-countdown.vue +338 -0
- package/components/muzhiyu/mu-cropper/mu-cropper.vue +415 -0
- package/components/muzhiyu/mu-date-picker/mu-date-picker.vue +290 -0
- package/components/muzhiyu/mu-datetime/mu-datetime.vue +262 -0
- package/components/muzhiyu/mu-divider/mu-divider.vue +229 -0
- package/components/muzhiyu/mu-drawer/mu-drawer.vue +172 -0
- package/components/muzhiyu/mu-dropdown/mu-dropdown.vue +215 -0
- package/components/muzhiyu/mu-dropdown-top/mu-dropdown-top.vue +243 -0
- package/components/muzhiyu/mu-empty/mu-empty.vue +217 -0
- package/components/muzhiyu/mu-fab/mu-fab.vue +324 -0
- package/components/muzhiyu/mu-footer/mu-footer.vue +21 -0
- package/components/muzhiyu/mu-form/mu-form.vue +170 -0
- package/components/muzhiyu/mu-grid/mu-grid.vue +95 -0
- package/components/muzhiyu/mu-grid-item/mu-grid-item.vue +247 -0
- package/components/muzhiyu/mu-html/mu-html.vue +145 -0
- package/components/muzhiyu/mu-icon/mu-icon.vue +822 -0
- package/components/muzhiyu/mu-image-grid/mu-image-grid.vue +225 -0
- package/components/muzhiyu/mu-image-preview/mu-image-preview.vue +286 -0
- package/components/muzhiyu/mu-index-list/mu-index-list.vue +381 -0
- package/components/muzhiyu/mu-input/mu-input.vue +570 -0
- package/components/muzhiyu/mu-input-number/mu-input-number.vue +193 -0
- package/components/muzhiyu/mu-keyboard/mu-keyboard.vue +415 -0
- package/components/muzhiyu/mu-list/mu-list.vue +89 -0
- package/components/muzhiyu/mu-loading/mu-loading.vue +124 -0
- package/components/muzhiyu/mu-loading-page/mu-loading-page.vue +529 -0
- package/components/muzhiyu/mu-loadmore/mu-loadmore.vue +26 -0
- package/components/muzhiyu/mu-modal/mu-modal.vue +298 -0
- package/components/muzhiyu/mu-navbar/mu-navbar.vue +223 -0
- package/components/muzhiyu/mu-nomore/mu-nomore.vue +107 -0
- package/components/muzhiyu/mu-notice-bar/mu-notice-bar.vue +284 -0
- package/components/muzhiyu/mu-notify/mu-notify.vue +202 -0
- package/components/muzhiyu/mu-overlay/mu-overlay.vue +94 -0
- package/components/muzhiyu/mu-pagination/mu-pagination.vue +330 -0
- package/components/muzhiyu/mu-password-input/mu-password-input.vue +119 -0
- package/components/muzhiyu/mu-picker/mu-picker.vue +297 -0
- package/components/muzhiyu/mu-popup/mu-popup.vue +297 -0
- package/components/muzhiyu/mu-progress/mu-progress.vue +156 -0
- package/components/muzhiyu/mu-pull-refresh/mu-pull-refresh.vue +54 -0
- package/components/muzhiyu/mu-qrcode/mu-qrcode.vue +340 -0
- package/components/muzhiyu/mu-qrcode/qrcode.js +2237 -0
- package/components/muzhiyu/mu-radio/mu-radio.vue +125 -0
- package/components/muzhiyu/mu-radio-group/mu-radio-group.vue +37 -0
- package/components/muzhiyu/mu-rate/mu-rate.vue +103 -0
- package/components/muzhiyu/mu-search/mu-search.vue +320 -0
- package/components/muzhiyu/mu-section/mu-section.vue +206 -0
- package/components/muzhiyu/mu-select/mu-select.vue +440 -0
- package/components/muzhiyu/mu-share-sheet/mu-share-sheet.vue +269 -0
- package/components/muzhiyu/mu-sidebar/mu-sidebar.vue +304 -0
- package/components/muzhiyu/mu-signature/mu-signature.vue +449 -0
- package/components/muzhiyu/mu-skeleton/mu-skeleton.vue +225 -0
- package/components/muzhiyu/mu-slider/mu-slider.vue +228 -0
- package/components/muzhiyu/mu-space/mu-space.vue +84 -0
- package/components/muzhiyu/mu-steps/mu-steps.vue +311 -0
- package/components/muzhiyu/mu-sticky/mu-sticky.vue +57 -0
- package/components/muzhiyu/mu-swipe-cell/mu-swipe-cell.vue +281 -0
- package/components/muzhiyu/mu-swiper/mu-swiper.vue +107 -0
- package/components/muzhiyu/mu-switch/mu-switch.vue +99 -0
- package/components/muzhiyu/mu-tabbar/mu-tabbar.vue +382 -0
- package/components/muzhiyu/mu-table/mu-table.vue +420 -0
- package/components/muzhiyu/mu-tabs/mu-tabs.vue +339 -0
- package/components/muzhiyu/mu-tag/mu-tag.vue +65 -0
- package/components/muzhiyu/mu-text-ellipsis/mu-text-ellipsis.vue +54 -0
- package/components/muzhiyu/mu-timeline/mu-timeline.vue +166 -0
- package/components/muzhiyu/mu-tips/mu-tips.vue +36 -0
- package/components/muzhiyu/mu-toast/mu-toast.vue +151 -0
- package/components/muzhiyu/mu-transfer/mu-transfer.vue +114 -0
- package/components/muzhiyu/mu-tree/mu-tree.vue +263 -0
- package/components/muzhiyu/mu-upload/mu-upload.vue +415 -0
- package/components/muzhiyu/mu-waterfall/mu-waterfall.vue +321 -0
- package/components/muzhiyu/mu-watermark/mu-watermark.vue +60 -0
- package/index.js +83 -0
- package/package.json +38 -0
- package/utils/index.js +600 -0
- package/utils/request.js +265 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="mu-waterfall" :style="{ gap: formattedGap }">
|
|
3
|
+
<!-- 多列布局容器 -->
|
|
4
|
+
<view
|
|
5
|
+
v-for="(col, ci) in columnData"
|
|
6
|
+
:key="ci"
|
|
7
|
+
class="mu-waterfall__col"
|
|
8
|
+
:style="{ gap: formattedGap }"
|
|
9
|
+
>
|
|
10
|
+
<view
|
|
11
|
+
v-for="(item, ii) in col"
|
|
12
|
+
:key="item._key || ii"
|
|
13
|
+
class="mu-waterfall__item"
|
|
14
|
+
:style="itemStyle"
|
|
15
|
+
@tap="handleClick(item)"
|
|
16
|
+
>
|
|
17
|
+
<slot :item="item" :index="item._index" :column="ci">
|
|
18
|
+
<!-- 默认极奢卡片视图 -->
|
|
19
|
+
<view class="mu-waterfall__card">
|
|
20
|
+
<!-- 封面图片与角标 -->
|
|
21
|
+
<view class="mu-waterfall__img-box">
|
|
22
|
+
<image
|
|
23
|
+
v-if="item.image"
|
|
24
|
+
class="mu-waterfall__img"
|
|
25
|
+
:src="item.image"
|
|
26
|
+
mode="widthFix"
|
|
27
|
+
/>
|
|
28
|
+
<view v-if="item.badge" class="mu-waterfall__badge">
|
|
29
|
+
<mu-badge :count="item.badge" type="error" />
|
|
30
|
+
</view>
|
|
31
|
+
</view>
|
|
32
|
+
|
|
33
|
+
<!-- 卡片文案区域 -->
|
|
34
|
+
<view class="mu-waterfall__info">
|
|
35
|
+
<!-- 标题 (多行自动省略) -->
|
|
36
|
+
<text v-if="item.title" class="mu-waterfall__title">{{ item.title }}</text>
|
|
37
|
+
|
|
38
|
+
<!-- 标签 Tag 组 -->
|
|
39
|
+
<view v-if="item.tag || item.tags" class="mu-waterfall__tags">
|
|
40
|
+
<text v-if="item.tag" class="mu-waterfall__tag">{{ item.tag }}</text>
|
|
41
|
+
<template v-else-if="Array.isArray(item.tags)">
|
|
42
|
+
<text v-for="(t, ti) in item.tags" :key="ti" class="mu-waterfall__tag">{{ t }}</text>
|
|
43
|
+
</template>
|
|
44
|
+
</view>
|
|
45
|
+
|
|
46
|
+
<!-- 底部价格/赞与作者 -->
|
|
47
|
+
<view class="mu-waterfall__footer">
|
|
48
|
+
<view v-if="item.price !== undefined" class="mu-waterfall__price-box">
|
|
49
|
+
<text class="mu-waterfall__symbol">¥</text>
|
|
50
|
+
<text class="mu-waterfall__price">{{ item.price }}</text>
|
|
51
|
+
<text v-if="item.originalPrice" class="mu-waterfall__original-price">¥{{ item.originalPrice }}</text>
|
|
52
|
+
</view>
|
|
53
|
+
<view v-else-if="item.user" class="mu-waterfall__user">
|
|
54
|
+
<image v-if="item.userAvatar" class="mu-waterfall__avatar" :src="item.userAvatar" mode="aspectFill" />
|
|
55
|
+
<text class="mu-waterfall__username">{{ item.user }}</text>
|
|
56
|
+
</view>
|
|
57
|
+
|
|
58
|
+
<!-- 点赞数 -->
|
|
59
|
+
<view v-if="item.likes !== undefined" class="mu-waterfall__like">
|
|
60
|
+
<mu-icon name="heart" :size="12" color="#F43F5E" />
|
|
61
|
+
<text class="mu-waterfall__like-num">{{ item.likes }}</text>
|
|
62
|
+
</view>
|
|
63
|
+
</view>
|
|
64
|
+
</view>
|
|
65
|
+
</view>
|
|
66
|
+
</slot>
|
|
67
|
+
</view>
|
|
68
|
+
</view>
|
|
69
|
+
</view>
|
|
70
|
+
</template>
|
|
71
|
+
|
|
72
|
+
<script setup>
|
|
73
|
+
/**
|
|
74
|
+
* mu-waterfall 瀑布流布局
|
|
75
|
+
* @description 双列/多列贪心动态高度分配瀑布流,带全防卫空数组与格式防护
|
|
76
|
+
*/
|
|
77
|
+
import { computed } from 'vue'
|
|
78
|
+
|
|
79
|
+
const props = defineProps({
|
|
80
|
+
data: { type: Array, default: () => [] },
|
|
81
|
+
columns: { type: [Number, String], default: 2 }, // 默认 2 列
|
|
82
|
+
gap: { type: [Number, String], default: 16 }, // 间距 rpx
|
|
83
|
+
radius: { type: [Number, String], default: 20 } // 圆角 rpx
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
const emit = defineEmits(['click'])
|
|
87
|
+
|
|
88
|
+
const formattedGap = computed(() => {
|
|
89
|
+
if (typeof props.gap === 'number') return `${props.gap}rpx`
|
|
90
|
+
if (typeof props.gap === 'string') {
|
|
91
|
+
if (props.gap.endsWith('rpx') || props.gap.endsWith('px')) return props.gap
|
|
92
|
+
return `${props.gap}rpx`
|
|
93
|
+
}
|
|
94
|
+
return '16rpx'
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
const formattedRadius = computed(() => {
|
|
98
|
+
if (typeof props.radius === 'number') return `${props.radius}rpx`
|
|
99
|
+
if (typeof props.radius === 'string') {
|
|
100
|
+
if (props.radius.endsWith('rpx') || props.radius.endsWith('px')) return props.radius
|
|
101
|
+
return `${props.radius}rpx`
|
|
102
|
+
}
|
|
103
|
+
return '20rpx'
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
// 贪心算法分配到最短列
|
|
107
|
+
const columnData = computed(() => {
|
|
108
|
+
const colsCount = Math.max(1, Number(props.columns) || 2)
|
|
109
|
+
const cols = Array.from({ length: colsCount }, () => [])
|
|
110
|
+
const heights = new Array(colsCount).fill(0)
|
|
111
|
+
|
|
112
|
+
if (!props.data || !Array.isArray(props.data)) return cols
|
|
113
|
+
|
|
114
|
+
props.data.forEach((item, index) => {
|
|
115
|
+
if (!item) return
|
|
116
|
+
const minIdx = heights.indexOf(Math.min(...heights))
|
|
117
|
+
const enriched = { ...item, _key: item.id || `wf_${index}`, _index: index }
|
|
118
|
+
cols[minIdx].push(enriched)
|
|
119
|
+
// 如果有自定义高度权重,则用 height,否则默认估算 220
|
|
120
|
+
heights[minIdx] += (Number(item.height) || 220)
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
return cols
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
const itemStyle = computed(() => ({
|
|
127
|
+
borderRadius: formattedRadius.value
|
|
128
|
+
}))
|
|
129
|
+
|
|
130
|
+
function handleClick(item) {
|
|
131
|
+
emit('click', { item, index: item._index })
|
|
132
|
+
}
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
<style lang="scss" scoped>
|
|
136
|
+
@import "@/uni.scss";
|
|
137
|
+
|
|
138
|
+
.mu-waterfall {
|
|
139
|
+
display: flex;
|
|
140
|
+
width: 100%;
|
|
141
|
+
box-sizing: border-box;
|
|
142
|
+
|
|
143
|
+
&__col {
|
|
144
|
+
flex: 1;
|
|
145
|
+
display: flex;
|
|
146
|
+
flex-direction: column;
|
|
147
|
+
min-width: 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
&__item {
|
|
151
|
+
background: #ffffff;
|
|
152
|
+
border: 1rpx solid rgba(226, 232, 240, 0.8);
|
|
153
|
+
overflow: hidden;
|
|
154
|
+
cursor: pointer;
|
|
155
|
+
box-shadow: 0 4rpx 16rpx rgba(15, 23, 42, 0.03);
|
|
156
|
+
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
|
157
|
+
|
|
158
|
+
&:active {
|
|
159
|
+
transform: scale(0.98);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
&__card {
|
|
164
|
+
display: flex;
|
|
165
|
+
flex-direction: column;
|
|
166
|
+
width: 100%;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
&__img-box {
|
|
170
|
+
position: relative;
|
|
171
|
+
width: 100%;
|
|
172
|
+
overflow: hidden;
|
|
173
|
+
background: #F8FAFC;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
&__img {
|
|
177
|
+
width: 100%;
|
|
178
|
+
display: block;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
&__badge {
|
|
182
|
+
position: absolute;
|
|
183
|
+
top: 12rpx;
|
|
184
|
+
left: 12rpx;
|
|
185
|
+
background: #F43F5E;
|
|
186
|
+
padding: 4rpx 12rpx;
|
|
187
|
+
border-radius: 8rpx;
|
|
188
|
+
box-shadow: 0 4rpx 10rpx rgba(244, 63, 94, 0.3);
|
|
189
|
+
|
|
190
|
+
&-text {
|
|
191
|
+
font-size: 20rpx;
|
|
192
|
+
font-weight: 800;
|
|
193
|
+
color: #ffffff;
|
|
194
|
+
line-height: 1;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
&__info {
|
|
199
|
+
padding: 16rpx 20rpx;
|
|
200
|
+
display: flex;
|
|
201
|
+
flex-direction: column;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
&__title {
|
|
205
|
+
font-size: 26rpx;
|
|
206
|
+
font-weight: 700;
|
|
207
|
+
color: $mu-text-primary;
|
|
208
|
+
line-height: 1.4;
|
|
209
|
+
margin-bottom: 8rpx;
|
|
210
|
+
overflow: hidden;
|
|
211
|
+
text-overflow: ellipsis;
|
|
212
|
+
display: -webkit-box;
|
|
213
|
+
-webkit-line-clamp: 2;
|
|
214
|
+
-webkit-box-orient: vertical;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
&__tags {
|
|
218
|
+
display: flex;
|
|
219
|
+
flex-wrap: wrap;
|
|
220
|
+
gap: 8rpx;
|
|
221
|
+
margin-bottom: 12rpx;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
&__tag {
|
|
225
|
+
font-size: 18rpx;
|
|
226
|
+
font-weight: 700;
|
|
227
|
+
color: #171717;
|
|
228
|
+
background: rgba(99, 102, 241, 0.08);
|
|
229
|
+
padding: 2rpx 10rpx;
|
|
230
|
+
border-radius: 6rpx;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
&__footer {
|
|
234
|
+
display: flex;
|
|
235
|
+
align-items: center;
|
|
236
|
+
justify-content: space-between;
|
|
237
|
+
margin-top: 4rpx;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
&__price-box {
|
|
241
|
+
display: flex;
|
|
242
|
+
align-items: baseline;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
&__symbol {
|
|
246
|
+
font-size: 20rpx;
|
|
247
|
+
font-weight: 800;
|
|
248
|
+
color: #F43F5E;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
&__price {
|
|
252
|
+
font-size: 32rpx;
|
|
253
|
+
font-weight: 900;
|
|
254
|
+
color: #F43F5E;
|
|
255
|
+
letter-spacing: -0.5rpx;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
&__original-price {
|
|
259
|
+
font-size: 20rpx;
|
|
260
|
+
color: #94A3B8;
|
|
261
|
+
text-decoration: line-through;
|
|
262
|
+
margin-left: 8rpx;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
&__user {
|
|
266
|
+
display: flex;
|
|
267
|
+
align-items: center;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
&__avatar {
|
|
271
|
+
width: 32rpx;
|
|
272
|
+
height: 32rpx;
|
|
273
|
+
border-radius: 50%;
|
|
274
|
+
margin-right: 8rpx;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
&__username {
|
|
278
|
+
font-size: 20rpx;
|
|
279
|
+
color: #64748B;
|
|
280
|
+
font-weight: 500;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
&__like {
|
|
284
|
+
display: flex;
|
|
285
|
+
align-items: center;
|
|
286
|
+
gap: 4rpx;
|
|
287
|
+
|
|
288
|
+
&-num {
|
|
289
|
+
font-size: 20rpx;
|
|
290
|
+
color: #94A3B8;
|
|
291
|
+
font-weight: 600;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.mu-dark, page.mu-dark {
|
|
297
|
+
|
|
298
|
+
.mu-waterfall {
|
|
299
|
+
&__item {
|
|
300
|
+
background: $mu-dark-bg-base;
|
|
301
|
+
border-color: rgba(255, 255, 255, 0.08);
|
|
302
|
+
}
|
|
303
|
+
&__img-box { background: rgba(255, 255, 255, 0.04); }
|
|
304
|
+
&__title { color: $mu-dark-text-primary; }
|
|
305
|
+
&__username, &__like-num { color: $mu-dark-text-secondary; }
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
@media (prefers-color-scheme: dark) {
|
|
310
|
+
|
|
311
|
+
.mu-waterfall {
|
|
312
|
+
&__item {
|
|
313
|
+
background: $mu-dark-bg-base;
|
|
314
|
+
border-color: rgba(255, 255, 255, 0.08);
|
|
315
|
+
}
|
|
316
|
+
&__img-box { background: rgba(255, 255, 255, 0.04); }
|
|
317
|
+
&__title { color: $mu-dark-text-primary; }
|
|
318
|
+
&__username, &__like-num { color: $mu-dark-text-secondary; }
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
</style>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="mu-watermark" :class="{ 'mu-watermark--full': fullPage }" :style="{ opacity: opacity }">
|
|
3
|
+
<view v-for="i in count" :key="i" class="mu-watermark__inner" :style="watermarkStyle">
|
|
4
|
+
<text class="mu-watermark__text">{{ text }}</text>
|
|
5
|
+
</view>
|
|
6
|
+
</view>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup>
|
|
10
|
+
/**
|
|
11
|
+
* mu-watermark 水印
|
|
12
|
+
* @description 全屏或局部水印,防截图盗用
|
|
13
|
+
* @property {string} text - 水印文字
|
|
14
|
+
* @property {number} rotate - 旋转角度
|
|
15
|
+
* @property {number} gapX - 水平间距
|
|
16
|
+
* @property {number} gapY - 垂直间距
|
|
17
|
+
* @property {number} fontSize - 字号rpx
|
|
18
|
+
* @property {number} opacity - 透明度
|
|
19
|
+
* @property {string} color - 文字颜色
|
|
20
|
+
* @property {boolean} fullPage - 是否全屏
|
|
21
|
+
*/
|
|
22
|
+
import { computed } from 'vue'
|
|
23
|
+
|
|
24
|
+
const props = defineProps({
|
|
25
|
+
text: { type: String, default: 'MuZhiYuUI' },
|
|
26
|
+
rotate: { type: Number, default: -22 },
|
|
27
|
+
gapX: { type: Number, default: 48 },
|
|
28
|
+
gapY: { type: Number, default: 48 },
|
|
29
|
+
fontSize: { type: Number, default: 28 },
|
|
30
|
+
opacity: { type: Number, default: 0.1 },
|
|
31
|
+
color: { type: String, default: '#000' },
|
|
32
|
+
fullPage: { type: Boolean, default: true },
|
|
33
|
+
count: { type: Number, default: 30 }
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const watermarkStyle = computed(() => ({
|
|
37
|
+
transform: `rotate(${props.rotate}deg)`,
|
|
38
|
+
color: props.color,
|
|
39
|
+
fontSize: `${props.fontSize}rpx`,
|
|
40
|
+
padding: `${props.gapY}rpx ${props.gapX}rpx`
|
|
41
|
+
}))
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<style lang="scss" scoped>
|
|
45
|
+
.mu-watermark {
|
|
46
|
+
pointer-events: none;
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
position: absolute; inset: 0; z-index: 0;
|
|
49
|
+
display: flex; flex-wrap: wrap; align-content: flex-start;
|
|
50
|
+
&--full { position: fixed; }
|
|
51
|
+
&__inner {
|
|
52
|
+
display: inline-block;
|
|
53
|
+
white-space: nowrap;
|
|
54
|
+
}
|
|
55
|
+
&__text {
|
|
56
|
+
font-weight: 400;
|
|
57
|
+
user-select: none;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
</style>
|
package/index.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MuzhiyuUI 极奢全端组件库统一入口导出文件
|
|
3
|
+
* 支持 Vue3 插件注册 app.use() 与 UniApp 全局对象 uni.$mu 零 import 调用
|
|
4
|
+
* @author muzhiyu
|
|
5
|
+
* @version 1.0.0
|
|
6
|
+
*/
|
|
7
|
+
import http from './utils/request.js'
|
|
8
|
+
import { util, validate, format, color } from './utils/index.js'
|
|
9
|
+
|
|
10
|
+
// Toast 快捷 JS 弹窗函数
|
|
11
|
+
const toast = (title, type, options = {}) => {
|
|
12
|
+
let opts = {}
|
|
13
|
+
if (typeof title === 'object' && title !== null) {
|
|
14
|
+
opts = { ...title }
|
|
15
|
+
if (title.icon) {
|
|
16
|
+
opts.type = (title.icon === 'success') ? 'success' : ((title.icon === 'error' || title.icon === 'fail') ? 'error' : ((title.icon === 'loading') ? 'loading' : 'default'))
|
|
17
|
+
}
|
|
18
|
+
} else {
|
|
19
|
+
opts = { title, type: type || 'default', ...options }
|
|
20
|
+
}
|
|
21
|
+
uni.$emit('mu-toast-show', opts)
|
|
22
|
+
}
|
|
23
|
+
toast.hide = () => uni.$emit('mu-toast-hide')
|
|
24
|
+
|
|
25
|
+
// Notify 快捷 JS 顶部通知函数
|
|
26
|
+
const notify = (options) => {
|
|
27
|
+
let opts = typeof options === 'string' ? { message: options } : (options || {})
|
|
28
|
+
uni.$emit('mu-notify-show', opts)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// LoadingPage 快捷 JS 全屏加载页函数
|
|
32
|
+
const loadingPage = (text, type, options = {}) => {
|
|
33
|
+
let opts = {}
|
|
34
|
+
if (typeof text === 'object') {
|
|
35
|
+
opts = text
|
|
36
|
+
} else {
|
|
37
|
+
opts = { text: text || '页面加载中...', type: type || 'logo', ...options }
|
|
38
|
+
}
|
|
39
|
+
uni.$emit('mu-loading-page-show', opts)
|
|
40
|
+
}
|
|
41
|
+
loadingPage.hide = () => uni.$emit('mu-loading-page-hide')
|
|
42
|
+
loadingPage.close = () => uni.$emit('mu-loading-page-close')
|
|
43
|
+
|
|
44
|
+
const mu = {
|
|
45
|
+
http,
|
|
46
|
+
util,
|
|
47
|
+
validate,
|
|
48
|
+
format,
|
|
49
|
+
color,
|
|
50
|
+
toast,
|
|
51
|
+
notify,
|
|
52
|
+
loadingPage
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 自动挂载到 UniApp 原生全局命名空间 uni.$mu, uni.$toast 并拦截原生 uni.showToast
|
|
56
|
+
if (typeof uni !== 'undefined') {
|
|
57
|
+
uni.$mu = mu
|
|
58
|
+
uni.$toast = toast
|
|
59
|
+
uni.showToast = function(opts) {
|
|
60
|
+
toast(opts)
|
|
61
|
+
}
|
|
62
|
+
uni.hideToast = function() {
|
|
63
|
+
uni.$emit('mu-toast-hide')
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { http, util, validate, format, color, toast, notify, loadingPage }
|
|
68
|
+
|
|
69
|
+
export default {
|
|
70
|
+
install(app) {
|
|
71
|
+
app.config.globalProperties.$mu = mu
|
|
72
|
+
if (typeof uni !== 'undefined') {
|
|
73
|
+
uni.$mu = mu
|
|
74
|
+
uni.$toast = toast
|
|
75
|
+
uni.showToast = function(opts) {
|
|
76
|
+
toast(opts)
|
|
77
|
+
}
|
|
78
|
+
uni.hideToast = function() {
|
|
79
|
+
uni.$emit('mu-toast-hide')
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "muzhiyu-ui",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "基于 UniApp Vue3 + SCSS 打造的全端极奢组件库",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"docs:dev": "npx vitepress dev docs",
|
|
8
|
+
"docs:build": "npx vitepress build docs",
|
|
9
|
+
"docs:preview": "npx vitepress preview docs"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"components",
|
|
13
|
+
"utils",
|
|
14
|
+
"theme.scss",
|
|
15
|
+
"index.js"
|
|
16
|
+
],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"uniapp",
|
|
19
|
+
"vue3",
|
|
20
|
+
"ui-library",
|
|
21
|
+
"wechat-miniprogram",
|
|
22
|
+
"components",
|
|
23
|
+
"muzhiyu-ui"
|
|
24
|
+
],
|
|
25
|
+
"author": "muzhiyu",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"uni_modules": {
|
|
28
|
+
"id": "muzhiyu-ui",
|
|
29
|
+
"name": "muzhiyu-ui 极奢组件库",
|
|
30
|
+
"version": "1.0.0",
|
|
31
|
+
"description": "基于 UniApp Vue3 + SCSS 打造的全端极奢 UI 组件库",
|
|
32
|
+
"site": "",
|
|
33
|
+
"displayName": "MuzhiyuUI 极奢全端组件库"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"vitepress": "^1.6.4"
|
|
37
|
+
}
|
|
38
|
+
}
|