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,466 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="mu-color-picker">
|
|
3
|
+
<!-- 触发按钮 Preview -->
|
|
4
|
+
<view
|
|
5
|
+
v-if="mode === 'popup'"
|
|
6
|
+
class="mu-color-picker__trigger"
|
|
7
|
+
@tap="openPopup"
|
|
8
|
+
>
|
|
9
|
+
<view class="mu-color-picker__preview-dot" :style="{ background: currentValue }"></view>
|
|
10
|
+
<text class="mu-color-picker__value-text">{{ currentValue }}</text>
|
|
11
|
+
<mu-icon name="arrow_right" :size="16" color="#94A3B8" />
|
|
12
|
+
</view>
|
|
13
|
+
|
|
14
|
+
<!-- 内嵌面板 / 弹出面板 -->
|
|
15
|
+
<view
|
|
16
|
+
v-if="mode === 'inline' || (mode === 'popup' && popupShow)"
|
|
17
|
+
class="mu-color-picker__panel"
|
|
18
|
+
:class="[mode === 'popup' && 'mu-color-picker__panel--popup']"
|
|
19
|
+
>
|
|
20
|
+
<!-- 1. 彩色 Hue 光谱点选色滑块 (彩虹色盘) -->
|
|
21
|
+
<view class="mu-color-picker__section-title">点选彩虹光谱色</view>
|
|
22
|
+
<view
|
|
23
|
+
class="mu-color-picker__hue-bar"
|
|
24
|
+
id="hueBar"
|
|
25
|
+
@touchstart="onHueStart"
|
|
26
|
+
@touchmove="onHueMove"
|
|
27
|
+
@mousedown="onHueMouseDown"
|
|
28
|
+
>
|
|
29
|
+
<view
|
|
30
|
+
class="mu-color-picker__hue-handle"
|
|
31
|
+
:style="{ left: `${huePercent}%` }"
|
|
32
|
+
></view>
|
|
33
|
+
</view>
|
|
34
|
+
|
|
35
|
+
<!-- 2. 灰阶/明度点选滑块 -->
|
|
36
|
+
<view class="mu-color-picker__section-title" style="margin-top: 20rpx;">明度调节</view>
|
|
37
|
+
<view
|
|
38
|
+
class="mu-color-picker__light-bar"
|
|
39
|
+
id="lightBar"
|
|
40
|
+
:style="lightBarBackgroundStyle"
|
|
41
|
+
@touchstart="onLightStart"
|
|
42
|
+
@touchmove="onLightMove"
|
|
43
|
+
@mousedown="onLightMouseDown"
|
|
44
|
+
>
|
|
45
|
+
<view
|
|
46
|
+
class="mu-color-picker__hue-handle"
|
|
47
|
+
:style="{ left: `${lightPercent}%` }"
|
|
48
|
+
></view>
|
|
49
|
+
</view>
|
|
50
|
+
|
|
51
|
+
<!-- 3. 预设调色板 (Presets Palette) -->
|
|
52
|
+
<view class="mu-color-picker__section-title" style="margin-top: 24rpx;">预设配色盘</view>
|
|
53
|
+
<view class="mu-color-picker__presets">
|
|
54
|
+
<view
|
|
55
|
+
v-for="(c, i) in presetColors"
|
|
56
|
+
:key="i"
|
|
57
|
+
class="mu-color-picker__preset-item"
|
|
58
|
+
:class="[c.toLowerCase() === currentValue.toLowerCase() && 'mu-color-picker__preset-item--active']"
|
|
59
|
+
:style="{ background: c }"
|
|
60
|
+
@tap="selectPresetColor(c)"
|
|
61
|
+
>
|
|
62
|
+
<mu-icon v-if="c.toLowerCase() === currentValue.toLowerCase()" name="check" :size="14" color="#FFFFFF" />
|
|
63
|
+
</view>
|
|
64
|
+
</view>
|
|
65
|
+
|
|
66
|
+
<!-- 4. HEX 实时输入框与预览 HEX 块 -->
|
|
67
|
+
<view class="mu-color-picker__footer">
|
|
68
|
+
<view class="mu-color-picker__current-badge" :style="{ background: currentValue }"></view>
|
|
69
|
+
<view class="mu-color-picker__input-box">
|
|
70
|
+
<text class="mu-color-picker__hash">#</text>
|
|
71
|
+
<input
|
|
72
|
+
class="mu-color-picker__input"
|
|
73
|
+
:value="hexValue"
|
|
74
|
+
maxlength="6"
|
|
75
|
+
@input="onHexInput"
|
|
76
|
+
/>
|
|
77
|
+
</view>
|
|
78
|
+
|
|
79
|
+
<view v-if="mode === 'popup'" class="mu-color-picker__confirm-btn" @tap="confirm">
|
|
80
|
+
<text class="mu-color-picker__confirm-text">确定</text>
|
|
81
|
+
</view>
|
|
82
|
+
</view>
|
|
83
|
+
</view>
|
|
84
|
+
</view>
|
|
85
|
+
</template>
|
|
86
|
+
|
|
87
|
+
<script setup>
|
|
88
|
+
import { ref, computed, watch, getCurrentInstance, onUnmounted } from 'vue'
|
|
89
|
+
|
|
90
|
+
const props = defineProps({
|
|
91
|
+
value: { type: String, default: '#171717' },
|
|
92
|
+
mode: { type: String, default: 'inline' }, // inline | popup
|
|
93
|
+
presetColors: {
|
|
94
|
+
type: Array,
|
|
95
|
+
default: () => [
|
|
96
|
+
'#171717', '#4F46E5', '#3B82F6', '#10B981', '#F59E0B', '#EF4444',
|
|
97
|
+
'#EC4899', '#8B5CF6', '#14B8A6', '#0F172A', '#64748B', '#FFFFFF'
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
const emit = defineEmits(['change', 'update:value', 'confirm'])
|
|
103
|
+
|
|
104
|
+
const instance = getCurrentInstance()
|
|
105
|
+
const popupShow = ref(false)
|
|
106
|
+
const currentValue = ref(props.value || '#171717')
|
|
107
|
+
const huePercent = ref(50)
|
|
108
|
+
const lightPercent = ref(50)
|
|
109
|
+
|
|
110
|
+
const isDraggingHue = ref(false)
|
|
111
|
+
const isDraggingLight = ref(false)
|
|
112
|
+
|
|
113
|
+
const hexValue = computed(() => {
|
|
114
|
+
return currentValue.value.replace('#', '').toUpperCase()
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
const lightBarBackgroundStyle = computed(() => {
|
|
118
|
+
const baseColor = hslToHex(huePercent.value * 3.6, 100, 50)
|
|
119
|
+
return {
|
|
120
|
+
background: `linear-gradient(to right, #000000, ${baseColor}, #FFFFFF)`
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
function getClientX(e) {
|
|
125
|
+
if (e.touches && e.touches[0]) return e.touches[0].clientX
|
|
126
|
+
if (e.changedTouches && e.changedTouches[0]) return e.changedTouches[0].clientX
|
|
127
|
+
if (e.clientX !== undefined) return e.clientX
|
|
128
|
+
return 0
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function openPopup() {
|
|
132
|
+
popupShow.value = true
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function selectPresetColor(c) {
|
|
136
|
+
currentValue.value = c
|
|
137
|
+
emit('change', c)
|
|
138
|
+
emit('update:value', c)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function onHexInput(e) {
|
|
142
|
+
const val = e.detail.value.replace(/[^0-9a-fA-F]/g, '')
|
|
143
|
+
if (val.length === 6) {
|
|
144
|
+
const hex = '#' + val
|
|
145
|
+
currentValue.value = hex
|
|
146
|
+
emit('change', hex)
|
|
147
|
+
emit('update:value', hex)
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function handleHueEvent(e) {
|
|
152
|
+
const clientX = getClientX(e)
|
|
153
|
+
const query = uni.createSelectorQuery().in(instance)
|
|
154
|
+
query.select('#hueBar').boundingClientRect(rect => {
|
|
155
|
+
if (rect && rect.width) {
|
|
156
|
+
const x = Math.max(0, Math.min(rect.width, clientX - rect.left))
|
|
157
|
+
huePercent.value = (x / rect.width) * 100
|
|
158
|
+
updateColorFromHsl()
|
|
159
|
+
}
|
|
160
|
+
}).exec()
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function handleLightEvent(e) {
|
|
164
|
+
const clientX = getClientX(e)
|
|
165
|
+
const query = uni.createSelectorQuery().in(instance)
|
|
166
|
+
query.select('#lightBar').boundingClientRect(rect => {
|
|
167
|
+
if (rect && rect.width) {
|
|
168
|
+
const x = Math.max(0, Math.min(rect.width, clientX - rect.left))
|
|
169
|
+
lightPercent.value = (x / rect.width) * 100
|
|
170
|
+
updateColorFromHsl()
|
|
171
|
+
}
|
|
172
|
+
}).exec()
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function onHueStart(e) { handleHueEvent(e) }
|
|
176
|
+
function onHueMove(e) { handleHueEvent(e) }
|
|
177
|
+
|
|
178
|
+
function onLightStart(e) { handleLightEvent(e) }
|
|
179
|
+
function onLightMove(e) { handleLightEvent(e) }
|
|
180
|
+
|
|
181
|
+
// H5 Mouse events
|
|
182
|
+
function onHueMouseDown(e) {
|
|
183
|
+
isDraggingHue.value = true
|
|
184
|
+
handleHueEvent(e)
|
|
185
|
+
// #ifdef H5
|
|
186
|
+
window.addEventListener('mousemove', onHueMouseMove)
|
|
187
|
+
window.addEventListener('mouseup', onMouseUp)
|
|
188
|
+
// #endif
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function onHueMouseMove(e) {
|
|
192
|
+
if (isDraggingHue.value) handleHueEvent(e)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function onLightMouseDown(e) {
|
|
196
|
+
isDraggingLight.value = true
|
|
197
|
+
handleLightEvent(e)
|
|
198
|
+
// #ifdef H5
|
|
199
|
+
window.addEventListener('mousemove', onLightMouseMove)
|
|
200
|
+
window.addEventListener('mouseup', onMouseUp)
|
|
201
|
+
// #endif
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function onLightMouseMove(e) {
|
|
205
|
+
if (isDraggingLight.value) handleLightEvent(e)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function onMouseUp() {
|
|
209
|
+
isDraggingHue.value = false
|
|
210
|
+
isDraggingLight.value = false
|
|
211
|
+
// #ifdef H5
|
|
212
|
+
window.removeEventListener('mousemove', onHueMouseMove)
|
|
213
|
+
window.removeEventListener('mousemove', onLightMouseMove)
|
|
214
|
+
window.removeEventListener('mouseup', onMouseUp)
|
|
215
|
+
// #endif
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function updateColorFromHsl() {
|
|
219
|
+
const h = huePercent.value * 3.6
|
|
220
|
+
const l = lightPercent.value
|
|
221
|
+
const hex = hslToHex(h, 100, l)
|
|
222
|
+
currentValue.value = hex
|
|
223
|
+
emit('change', hex)
|
|
224
|
+
emit('update:value', hex)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function hslToHex(h, s, l) {
|
|
228
|
+
l /= 100
|
|
229
|
+
const a = (s * Math.min(l, 1 - l)) / 100
|
|
230
|
+
const f = n => {
|
|
231
|
+
const k = (n + h / 30) % 12
|
|
232
|
+
const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1)
|
|
233
|
+
return Math.round(255 * color).toString(16).padStart(2, '0')
|
|
234
|
+
}
|
|
235
|
+
return `#${f(0)}${f(8)}${f(4)}`.toUpperCase()
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function confirm() {
|
|
239
|
+
popupShow.value = false
|
|
240
|
+
emit('confirm', currentValue.value)
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
watch(() => props.value, (v) => {
|
|
244
|
+
if (v) currentValue.value = v
|
|
245
|
+
})
|
|
246
|
+
|
|
247
|
+
onUnmounted(() => {
|
|
248
|
+
// #ifdef H5
|
|
249
|
+
window.removeEventListener('mousemove', onHueMouseMove)
|
|
250
|
+
window.removeEventListener('mousemove', onLightMouseMove)
|
|
251
|
+
window.removeEventListener('mouseup', onMouseUp)
|
|
252
|
+
// #endif
|
|
253
|
+
})
|
|
254
|
+
</script>
|
|
255
|
+
|
|
256
|
+
<style lang="scss" scoped>
|
|
257
|
+
@import "@/uni.scss";
|
|
258
|
+
|
|
259
|
+
.mu-color-picker {
|
|
260
|
+
width: 100%;
|
|
261
|
+
box-sizing: border-box;
|
|
262
|
+
|
|
263
|
+
&__trigger {
|
|
264
|
+
display: flex;
|
|
265
|
+
align-items: center;
|
|
266
|
+
padding: 16rpx 24rpx;
|
|
267
|
+
background: #FFFFFF;
|
|
268
|
+
border: 1rpx solid #E2E8F0;
|
|
269
|
+
border-radius: 20rpx;
|
|
270
|
+
cursor: pointer;
|
|
271
|
+
box-shadow: 0 4rpx 16rpx rgba(15, 23, 42, 0.04);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
&__preview-dot {
|
|
275
|
+
width: 40rpx;
|
|
276
|
+
height: 40rpx;
|
|
277
|
+
border-radius: 50%;
|
|
278
|
+
box-shadow: inset 0 0 0 2rpx rgba(0, 0, 0, 0.1);
|
|
279
|
+
margin-right: 16rpx;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
&__value-text {
|
|
283
|
+
flex: 1;
|
|
284
|
+
font-size: 26rpx;
|
|
285
|
+
font-weight: 800;
|
|
286
|
+
color: #0F172A;
|
|
287
|
+
letter-spacing: 1rpx;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
&__panel {
|
|
291
|
+
background: #FFFFFF;
|
|
292
|
+
border-radius: 24rpx;
|
|
293
|
+
padding: 28rpx;
|
|
294
|
+
border: 1rpx solid #E2E8F0;
|
|
295
|
+
box-shadow: 0 8rpx 32rpx rgba(15, 23, 42, 0.06);
|
|
296
|
+
box-sizing: border-box;
|
|
297
|
+
|
|
298
|
+
&--popup {
|
|
299
|
+
margin-top: 16rpx;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
&__section-title {
|
|
304
|
+
font-size: 22rpx;
|
|
305
|
+
font-weight: 700;
|
|
306
|
+
color: #64748B;
|
|
307
|
+
display: block;
|
|
308
|
+
margin-bottom: 12rpx;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/* 彩虹 Hue 滑块 */
|
|
312
|
+
&__hue-bar {
|
|
313
|
+
position: relative;
|
|
314
|
+
width: 100%;
|
|
315
|
+
height: 36rpx;
|
|
316
|
+
border-radius: 999rpx;
|
|
317
|
+
background: linear-gradient(to right, #FF0000, #FFFF00, #00FF00, #00FFFF, #0000FF, #FF00FF, #FF0000);
|
|
318
|
+
cursor: pointer;
|
|
319
|
+
box-shadow: inset 0 2rpx 4rpx rgba(0, 0, 0, 0.15);
|
|
320
|
+
touch-action: none;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/* 明度调节滑块 */
|
|
324
|
+
&__light-bar {
|
|
325
|
+
position: relative;
|
|
326
|
+
width: 100%;
|
|
327
|
+
height: 36rpx;
|
|
328
|
+
border-radius: 999rpx;
|
|
329
|
+
cursor: pointer;
|
|
330
|
+
box-shadow: inset 0 2rpx 4rpx rgba(0, 0, 0, 0.15);
|
|
331
|
+
touch-action: none;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
&__hue-handle {
|
|
335
|
+
position: absolute;
|
|
336
|
+
top: 50%;
|
|
337
|
+
width: 44rpx;
|
|
338
|
+
height: 44rpx;
|
|
339
|
+
border-radius: 50%;
|
|
340
|
+
background: #FFFFFF;
|
|
341
|
+
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.3);
|
|
342
|
+
transform: translate(-50%, -50%);
|
|
343
|
+
border: 4rpx solid #FFFFFF;
|
|
344
|
+
pointer-events: none;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
&__presets {
|
|
348
|
+
display: grid;
|
|
349
|
+
grid-template-columns: repeat(6, 1fr);
|
|
350
|
+
gap: 16rpx;
|
|
351
|
+
margin-top: 12rpx;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
&__preset-item {
|
|
355
|
+
height: 64rpx;
|
|
356
|
+
border-radius: 16rpx;
|
|
357
|
+
display: flex;
|
|
358
|
+
align-items: center;
|
|
359
|
+
justify-content: center;
|
|
360
|
+
cursor: pointer;
|
|
361
|
+
box-shadow: inset 0 0 0 2rpx rgba(0, 0, 0, 0.08);
|
|
362
|
+
|
|
363
|
+
&--active {
|
|
364
|
+
box-shadow: 0 0 0 4rpx #171717;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
&__footer {
|
|
369
|
+
display: flex;
|
|
370
|
+
align-items: center;
|
|
371
|
+
gap: 16rpx;
|
|
372
|
+
margin-top: 28rpx;
|
|
373
|
+
padding-top: 20rpx;
|
|
374
|
+
border-top: 1rpx solid #F1F5F9;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
&__current-badge {
|
|
378
|
+
width: 60rpx;
|
|
379
|
+
height: 60rpx;
|
|
380
|
+
border-radius: 16rpx;
|
|
381
|
+
box-shadow: inset 0 0 0 2rpx rgba(0, 0, 0, 0.1);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
&__input-box {
|
|
385
|
+
flex: 1;
|
|
386
|
+
display: flex;
|
|
387
|
+
align-items: center;
|
|
388
|
+
height: 64rpx;
|
|
389
|
+
background: #F8FAFC;
|
|
390
|
+
border-radius: 16rpx;
|
|
391
|
+
padding: 0 20rpx;
|
|
392
|
+
border: 1rpx solid #E2E8F0;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
&__hash {
|
|
396
|
+
font-size: 26rpx;
|
|
397
|
+
font-weight: 800;
|
|
398
|
+
color: #64748B;
|
|
399
|
+
margin-right: 8rpx;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
&__input {
|
|
403
|
+
flex: 1;
|
|
404
|
+
font-size: 26rpx;
|
|
405
|
+
font-weight: 800;
|
|
406
|
+
color: #0F172A;
|
|
407
|
+
letter-spacing: 1rpx;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
&__confirm-btn {
|
|
411
|
+
padding: 12rpx 32rpx;
|
|
412
|
+
background: #171717;
|
|
413
|
+
border-radius: 999rpx;
|
|
414
|
+
box-shadow: 0 4rpx 16rpx rgba(99, 102, 241, 0.3);
|
|
415
|
+
cursor: pointer;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
&__confirm-text {
|
|
419
|
+
font-size: 24rpx;
|
|
420
|
+
font-weight: 800;
|
|
421
|
+
color: #FFFFFF;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.mu-dark, page.mu-dark {
|
|
426
|
+
.mu-color-picker {
|
|
427
|
+
&__trigger {
|
|
428
|
+
background: $mu-dark-bg-base;
|
|
429
|
+
border-color: rgba(255, 255, 255, 0.1);
|
|
430
|
+
}
|
|
431
|
+
&__value-text { color: $mu-dark-text-primary; }
|
|
432
|
+
&__panel {
|
|
433
|
+
background: $mu-dark-bg-base;
|
|
434
|
+
border-color: rgba(255, 255, 255, 0.1);
|
|
435
|
+
}
|
|
436
|
+
&__section-title { color: $mu-dark-text-secondary; }
|
|
437
|
+
&__input-box {
|
|
438
|
+
background: rgba(255, 255, 255, 0.05);
|
|
439
|
+
border-color: rgba(255, 255, 255, 0.1);
|
|
440
|
+
}
|
|
441
|
+
&__input { color: $mu-dark-text-primary; }
|
|
442
|
+
&__footer { border-color: rgba(255, 255, 255, 0.08); }
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
@media (prefers-color-scheme: dark) {
|
|
447
|
+
.mu-color-picker {
|
|
448
|
+
&__trigger {
|
|
449
|
+
background: $mu-dark-bg-base;
|
|
450
|
+
border-color: rgba(255, 255, 255, 0.1);
|
|
451
|
+
}
|
|
452
|
+
&__value-text { color: $mu-dark-text-primary; }
|
|
453
|
+
&__panel {
|
|
454
|
+
background: $mu-dark-bg-base;
|
|
455
|
+
border-color: rgba(255, 255, 255, 0.1);
|
|
456
|
+
}
|
|
457
|
+
&__section-title { color: $mu-dark-text-secondary; }
|
|
458
|
+
&__input-box {
|
|
459
|
+
background: rgba(255, 255, 255, 0.05);
|
|
460
|
+
border-color: rgba(255, 255, 255, 0.1);
|
|
461
|
+
}
|
|
462
|
+
&__input { color: $mu-dark-text-primary; }
|
|
463
|
+
&__footer { border-color: rgba(255, 255, 255, 0.08); }
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
</style>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MuZhiYuUI 全局配置
|
|
3
|
+
* 用于组件主题定制和全局参数
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const config = {
|
|
7
|
+
// 品牌主色
|
|
8
|
+
primaryColor: '#1677FF',
|
|
9
|
+
// 语义色
|
|
10
|
+
successColor: '#52C41A',
|
|
11
|
+
warningColor: '#FAAD14',
|
|
12
|
+
errorColor: '#FF4D4F',
|
|
13
|
+
infoColor: '#1677FF',
|
|
14
|
+
// 文本色
|
|
15
|
+
textPrimary: '#1A1A1A',
|
|
16
|
+
textSecondary: '#595959',
|
|
17
|
+
textTertiary: '#8C8C8C',
|
|
18
|
+
textDisabled: '#BFBFBF',
|
|
19
|
+
// 背景色
|
|
20
|
+
bgBase: '#FFFFFF',
|
|
21
|
+
bgGray: '#FAFAFA',
|
|
22
|
+
// 边框色
|
|
23
|
+
borderColor: '#E8E8E8',
|
|
24
|
+
// 圆角
|
|
25
|
+
radiusSm: '4px',
|
|
26
|
+
radiusMd: '6px',
|
|
27
|
+
radiusLg: '8px',
|
|
28
|
+
// 动画时长
|
|
29
|
+
duration: 200,
|
|
30
|
+
// 弹窗遮罩透明度
|
|
31
|
+
maskOpacity: 0.45
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default config
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="mu-config-provider"
|
|
4
|
+
:class="[computedTheme === 'dark' && 'mu-dark']"
|
|
5
|
+
:style="providerStyle"
|
|
6
|
+
>
|
|
7
|
+
<slot></slot>
|
|
8
|
+
<mu-toast />
|
|
9
|
+
</view>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup>
|
|
13
|
+
import { computed, provide } from 'vue'
|
|
14
|
+
import MuToast from '../mu-toast/mu-toast.vue'
|
|
15
|
+
|
|
16
|
+
const props = defineProps({
|
|
17
|
+
theme: { type: String, default: 'light' }, // light | dark
|
|
18
|
+
primaryColor: { type: String, default: '#171717' },
|
|
19
|
+
zIndex: { type: Number, default: 1000 },
|
|
20
|
+
unit: { type: String, default: 'rpx' }
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const computedTheme = computed(() => props.theme)
|
|
24
|
+
const computedPrimary = computed(() => props.primaryColor)
|
|
25
|
+
|
|
26
|
+
provide('muConfig', {
|
|
27
|
+
theme: computedTheme,
|
|
28
|
+
primaryColor: computedPrimary,
|
|
29
|
+
zIndex: computed(() => props.zIndex),
|
|
30
|
+
unit: computed(() => props.unit)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const providerStyle = computed(() => {
|
|
34
|
+
const style = {}
|
|
35
|
+
if (props.primaryColor) {
|
|
36
|
+
style['--mu-primary'] = props.primaryColor
|
|
37
|
+
}
|
|
38
|
+
return style
|
|
39
|
+
})
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<style lang="scss">
|
|
43
|
+
.mu-config-provider {
|
|
44
|
+
width: 100%;
|
|
45
|
+
min-height: 100%;
|
|
46
|
+
box-sizing: border-box;
|
|
47
|
+
transition: background-color 0.3s ease, color 0.3s ease;
|
|
48
|
+
|
|
49
|
+
&.mu-dark {
|
|
50
|
+
background-color: #08080C;
|
|
51
|
+
color: #E2E8F0;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
</style>
|