@puresnake/snake-ui 0.0.0-stage → 0.0.2
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/LICENSE +21 -0
- package/changelog.md +83 -0
- package/components/snake-activity-list/snake-activity-list.vue +365 -0
- package/components/snake-activity-list/types.ts +29 -0
- package/components/snake-auxiliary-segmentation/snake-auxiliary-segmentation.vue +44 -0
- package/components/snake-auxiliary-segmentation/types.ts +5 -0
- package/components/snake-button/snake-button.vue +357 -0
- package/components/snake-button/types.ts +103 -0
- package/components/snake-button-sort/snake-button-sort.vue +72 -0
- package/components/snake-button-sort/types.ts +22 -0
- package/components/snake-calendar/snake-calendar.vue +998 -0
- package/components/snake-calendar/types.ts +189 -0
- package/components/snake-cell-group/snake-cell-group.vue +55 -0
- package/components/snake-cell-group/types.ts +19 -0
- package/components/snake-cell-item/snake-cell-item.vue +159 -0
- package/components/snake-cell-item/types.ts +66 -0
- package/components/snake-checkbox/snake-checkbox.vue +264 -0
- package/components/snake-checkbox/types.ts +70 -0
- package/components/snake-checkbox-group/snake-checkbox-group.vue +154 -0
- package/components/snake-checkbox-group/types.ts +52 -0
- package/components/snake-cms/blocks/v2/cms-v2-carousel.vue +87 -0
- package/components/snake-cms/blocks/v2/cms-v2-coupon.vue +25 -0
- package/components/snake-cms/blocks/v2/cms-v2-custom.vue +12 -0
- package/components/snake-cms/blocks/v2/cms-v2-divider.vue +33 -0
- package/components/snake-cms/blocks/v2/cms-v2-floatbutton.vue +28 -0
- package/components/snake-cms/blocks/v2/cms-v2-goods-list.vue +150 -0
- package/components/snake-cms/blocks/v2/cms-v2-hotzone.vue +41 -0
- package/components/snake-cms/blocks/v2/cms-v2-images.vue +41 -0
- package/components/snake-cms/blocks/v2/cms-v2-magiccube.vue +93 -0
- package/components/snake-cms/blocks/v2/cms-v2-notice.vue +80 -0
- package/components/snake-cms/blocks/v2/cms-v2-popup.vue +46 -0
- package/components/snake-cms/blocks/v2/cms-v2-richtext.vue +18 -0
- package/components/snake-cms/blocks/v2/cms-v2-search.vue +115 -0
- package/components/snake-cms/blocks/v2/cms-v2-video.vue +25 -0
- package/components/snake-cms/blocks/v2/shared.ts +84 -0
- package/components/snake-cms/snake-cms.vue +409 -0
- package/components/snake-cms/types.ts +50 -0
- package/components/snake-commodity-search/snake-commodity-search.vue +234 -0
- package/components/snake-commodity-search/types.ts +11 -0
- package/components/snake-config-provider/snake-config-provider.vue +61 -0
- package/components/snake-config-provider/types.ts +22 -0
- package/components/snake-count-down/snake-count-down.vue +231 -0
- package/components/snake-count-down/types.ts +103 -0
- package/components/snake-coupon/snake-coupon.vue +209 -0
- package/components/snake-coupon/types.ts +21 -0
- package/components/snake-custom-module/snake-custom-module.vue +25 -0
- package/components/snake-custom-module/types.ts +11 -0
- package/components/snake-drop-menu/snake-drop-menu.vue +123 -0
- package/components/snake-drop-menu/types.ts +95 -0
- package/components/snake-drop-menu-item/snake-drop-menu-item.vue +181 -0
- package/components/snake-drop-menu-item/types.ts +48 -0
- package/components/snake-empty/snake-empty.vue +100 -0
- package/components/snake-empty/types.ts +48 -0
- package/components/snake-filter-sorts/filter-page.vue +695 -0
- package/components/snake-filter-sorts/snake-filter-sorts.vue +185 -0
- package/components/snake-filter-sorts/types.ts +57 -0
- package/components/snake-floating-bubble/snake-floating-bubble.vue +157 -0
- package/components/snake-floating-bubble/types.ts +43 -0
- package/components/snake-follow/snake-follow.vue +18 -0
- package/components/snake-follow/types.ts +2 -0
- package/components/snake-form/snake-form.vue +124 -0
- package/components/snake-form/types.ts +96 -0
- package/components/snake-form-item/snake-form-item.vue +331 -0
- package/components/snake-form-item/types.ts +70 -0
- package/components/snake-goods-list/snake-goods-list.vue +792 -0
- package/components/snake-goods-list/types.ts +55 -0
- package/components/snake-graphic-navigation/snake-graphic-navigation.vue +198 -0
- package/components/snake-graphic-navigation/types.ts +43 -0
- package/components/snake-icon/icon-names.ts +222 -0
- package/components/snake-icon/snake-icon.vue +220 -0
- package/components/snake-icon/types.ts +45 -0
- package/components/snake-image/snake-image.vue +230 -0
- package/components/snake-image/types.ts +70 -0
- package/components/snake-images/snake-images.vue +80 -0
- package/components/snake-images/types.ts +5 -0
- package/components/snake-index-anchor/snake-index-anchor.vue +83 -0
- package/components/snake-index-anchor/types.ts +14 -0
- package/components/snake-index-list/anchor-registry.ts +80 -0
- package/components/snake-index-list/snake-index-list.vue +259 -0
- package/components/snake-index-list/types.ts +115 -0
- package/components/snake-index-list-panel/snake-index-list-panel.vue +277 -0
- package/components/snake-index-list-panel/types.ts +10 -0
- package/components/snake-input/snake-input.vue +225 -0
- package/components/snake-input/types.ts +99 -0
- package/components/snake-jump-applet/snake-jump-applet.vue +99 -0
- package/components/snake-jump-applet/types.ts +17 -0
- package/components/snake-line/snake-line.vue +42 -0
- package/components/snake-line/types.ts +30 -0
- package/components/snake-line-progress/snake-line-progress.vue +105 -0
- package/components/snake-line-progress/types.ts +26 -0
- package/components/snake-link/snake-link.vue +74 -0
- package/components/snake-link/types.ts +30 -0
- package/components/snake-list-switching/components/tree-select/index.vue +156 -0
- package/components/snake-list-switching/snake-list-switching.vue +1285 -0
- package/components/snake-list-switching/types.ts +11 -0
- package/components/snake-loading/snake-loading.vue +241 -0
- package/components/snake-loading/types.ts +34 -0
- package/components/snake-loadmore/snake-loadmore.vue +103 -0
- package/components/snake-loadmore/types.ts +56 -0
- package/components/snake-magic-cube/snake-magic-cube.vue +622 -0
- package/components/snake-magic-cube/types.ts +5 -0
- package/components/snake-modal/snake-modal.vue +434 -0
- package/components/snake-modal/types.ts +71 -0
- package/components/snake-navbar/snake-navbar.vue +194 -0
- package/components/snake-navbar/types.ts +54 -0
- package/components/snake-no-network/snake-no-network.vue +125 -0
- package/components/snake-no-network/types.ts +27 -0
- package/components/snake-notice/snake-notice.vue +44 -0
- package/components/snake-notice/types.ts +5 -0
- package/components/snake-notice-bar/snake-notice-bar.vue +336 -0
- package/components/snake-notice-bar/types.ts +82 -0
- package/components/snake-overlay/snake-overlay.vue +73 -0
- package/components/snake-overlay/types.ts +35 -0
- package/components/snake-page-popup/snake-page-popup.vue +146 -0
- package/components/snake-page-popup/types.ts +28 -0
- package/components/snake-parse/audio/audio.vue +286 -0
- package/components/snake-parse/audio/context.js +11 -0
- package/components/snake-parse/audio/index.js +34 -0
- package/components/snake-parse/node/node.vue +830 -0
- package/components/snake-parse/parser.js +1480 -0
- package/components/snake-parse/snake-parse.vue +548 -0
- package/components/snake-parse/static/app-plus/snake-parse/js/handler.js +109 -0
- package/components/snake-parse/static/app-plus/snake-parse/js/uni.webview.js +0 -0
- package/components/snake-parse/static/app-plus/snake-parse/js/uni.webview.min.js +1 -0
- package/components/snake-parse/static/app-plus/snake-parse/local.html +3 -0
- package/components/snake-parse/style/index.js +132 -0
- package/components/snake-parse/style/parser.js +175 -0
- package/components/snake-parse/types.ts +49 -0
- package/components/snake-picture-ads/snake-picture-ads.vue +292 -0
- package/components/snake-picture-ads/types.ts +5 -0
- package/components/snake-popup/snake-popup.vue +348 -0
- package/components/snake-popup/types.ts +88 -0
- package/components/snake-qr-code/qrcode.ts +1214 -0
- package/components/snake-qr-code/snake-qr-code.vue +408 -0
- package/components/snake-qr-code/types.ts +78 -0
- package/components/snake-radio/snake-radio.vue +271 -0
- package/components/snake-radio/types.ts +64 -0
- package/components/snake-radio-group/snake-radio-group.vue +98 -0
- package/components/snake-radio-group/types.ts +48 -0
- package/components/snake-read-more/snake-read-more.vue +140 -0
- package/components/snake-read-more/types.ts +53 -0
- package/components/snake-rich-text/snake-rich-text.vue +24 -0
- package/components/snake-rich-text/types.ts +5 -0
- package/components/snake-root-portal/snake-root-portal.vue +92 -0
- package/components/snake-root-portal/types.ts +9 -0
- package/components/snake-search/snake-search.vue +202 -0
- package/components/snake-search/types.ts +84 -0
- package/components/snake-select/snake-select.vue +371 -0
- package/components/snake-select/types.ts +75 -0
- package/components/snake-skeleton/snake-skeleton.vue +104 -0
- package/components/snake-skeleton/types.ts +32 -0
- package/components/snake-skeleton-item/snake-skeleton-item.vue +90 -0
- package/components/snake-skeleton-item/types.ts +30 -0
- package/components/snake-slider/snake-slider.vue +249 -0
- package/components/snake-slider/types.ts +59 -0
- package/components/snake-sticky/snake-sticky.vue +178 -0
- package/components/snake-sticky/types.ts +48 -0
- package/components/snake-subsection/snake-subsection.vue +188 -0
- package/components/snake-subsection/types.ts +54 -0
- package/components/snake-swiper/snake-swiper.vue +229 -0
- package/components/snake-swiper/types.ts +79 -0
- package/components/snake-switch/snake-switch.vue +100 -0
- package/components/snake-switch/types.ts +41 -0
- package/components/snake-tabbar/snake-tabbar.vue +306 -0
- package/components/snake-tabbar/types.ts +93 -0
- package/components/snake-tabs/snake-tabs.vue +305 -0
- package/components/snake-tabs/types.ts +79 -0
- package/components/snake-text/snake-text.vue +292 -0
- package/components/snake-text/types.ts +100 -0
- package/components/snake-textarea/snake-textarea.vue +171 -0
- package/components/snake-textarea/types.ts +79 -0
- package/components/snake-toast/snake-toast.vue +330 -0
- package/components/snake-toast/types.ts +55 -0
- package/components/snake-tooltip/position.ts +33 -0
- package/components/snake-tooltip/snake-tooltip.vue +339 -0
- package/components/snake-tooltip/types.ts +80 -0
- package/components/snake-transition/snake-transition.vue +315 -0
- package/components/snake-transition/types.ts +65 -0
- package/components/snake-upload/snake-upload.vue +1801 -0
- package/components/snake-upload/types.ts +256 -0
- package/components/snake-videos/snake-videos.vue +122 -0
- package/components/snake-videos/types.ts +7 -0
- package/iconfont.css +881 -0
- package/index.d.ts +7 -0
- package/index.scss +26 -0
- package/index.ts +94 -0
- package/libs/cms/blocks.ts +103 -0
- package/libs/cms/config.ts +25 -0
- package/libs/cms/index.ts +7 -0
- package/libs/cms/normalize.ts +135 -0
- package/libs/cms/resolve.ts +12 -0
- package/libs/cms/types.ts +164 -0
- package/libs/cms/use-commerce.ts +385 -0
- package/libs/cms/v2.ts +193 -0
- package/libs/config/index.ts +4 -0
- package/libs/config/modal.ts +93 -0
- package/libs/config/state.ts +33 -0
- package/libs/config/theme.ts +351 -0
- package/libs/config/toast.ts +71 -0
- package/libs/config/types.ts +135 -0
- package/libs/config/zIndex.ts +44 -0
- package/libs/css/color.scss +105 -0
- package/libs/css/common.scss +171 -0
- package/libs/css/style.h5.scss +7 -0
- package/libs/css/style.mp.scss +7 -0
- package/libs/css/style.theme.scss +70 -0
- package/libs/css/style.vue.scss +140 -0
- package/libs/form/async-validator.min.d.ts +75 -0
- package/libs/form/async-validator.min.js +3 -0
- package/libs/form/index.ts +3 -0
- package/libs/form/path.ts +40 -0
- package/libs/form/types.ts +51 -0
- package/libs/form/validate.ts +149 -0
- package/libs/foundation.ts +96 -0
- package/libs/function/$parent.ts +33 -0
- package/libs/function/clipboard.ts +13 -0
- package/libs/function/color.ts +55 -0
- package/libs/function/debounce.ts +34 -0
- package/libs/function/deepClone.ts +30 -0
- package/libs/function/deepMerge.ts +25 -0
- package/libs/function/emitter.ts +30 -0
- package/libs/function/format.ts +27 -0
- package/libs/function/getParent.ts +53 -0
- package/libs/function/getRect.ts +29 -0
- package/libs/function/guid.ts +11 -0
- package/libs/function/index.ts +31 -0
- package/libs/function/queryParams.ts +73 -0
- package/libs/function/random.ts +6 -0
- package/libs/function/randomArray.ts +14 -0
- package/libs/function/route.ts +155 -0
- package/libs/function/sleep.ts +7 -0
- package/libs/function/style.ts +58 -0
- package/libs/function/styleUtils.ts +83 -0
- package/libs/function/system.ts +14 -0
- package/libs/function/test.ts +202 -0
- package/libs/function/throttle.ts +36 -0
- package/libs/function/timeFormat.ts +27 -0
- package/libs/function/timeFrom.ts +27 -0
- package/libs/function/toast.ts +10 -0
- package/libs/function/trim.ts +11 -0
- package/libs/function/type2icon.ts +11 -0
- package/libs/function/unit.ts +45 -0
- package/libs/hooks/index.ts +11 -0
- package/libs/hooks/useChildren.ts +125 -0
- package/libs/hooks/useColor.ts +5 -0
- package/libs/hooks/useDebounce.ts +5 -0
- package/libs/hooks/useLocale.ts +13 -0
- package/libs/hooks/useModal.ts +131 -0
- package/libs/hooks/useParent.ts +62 -0
- package/libs/hooks/useRect.ts +44 -0
- package/libs/hooks/useRouter.ts +5 -0
- package/libs/hooks/useTheme.ts +31 -0
- package/libs/hooks/useThrottle.ts +5 -0
- package/libs/hooks/useToast.ts +116 -0
- package/libs/index.ts +18 -0
- package/libs/request/auto-http.ts +1 -0
- package/libs/request/index.ts +343 -0
- package/libs/runtime/accessors.ts +55 -0
- package/libs/runtime/context.ts +40 -0
- package/libs/runtime/index.ts +18 -0
- package/libs/runtime/types.ts +49 -0
- package/libs/util/calendar.ts +6 -0
- package/locale/index.ts +130 -0
- package/locale/lang/en-US.ts +67 -0
- package/locale/lang/zh-CN.ts +67 -0
- package/package.json +134 -5
- package/plugins/index.ts +1 -0
- package/plugins/root/README.md +86 -0
- package/plugins/root/index.ts +123 -0
- package/plugins/root/page.ts +77 -0
- package/plugins/root/root.ts +53 -0
- package/plugins/root/utils.ts +137 -0
- package/readme.md +79 -0
- package/theme.scss +118 -0
- package/types/components.d.ts +236 -0
- package/types/global.d.ts +21 -0
- package/types/index.d.ts +6 -0
- package/types/uni-app.d.ts +16 -0
- package/README.md +0 -3
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** ListSwitching 组件的公开属性。 */
|
|
2
|
+
export interface ListSwitchingProps<Data extends Record<string, any> = Record<string, any>> {
|
|
3
|
+
/** CMS 装修组件配置数据。 */
|
|
4
|
+
datas?: Data;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/** ListSwitching 组件的事件契约。 */
|
|
8
|
+
export type ListSwitchingEmits<Item extends Record<string, any> = Record<string, any>> = {
|
|
9
|
+
/** item-click 事件携带的参数。 */
|
|
10
|
+
'item-click': [item: Item];
|
|
11
|
+
};
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view v-if="show" class="snake-loading" :class="[`snake-loading--${direction}`, customClass]" :style="rootStyle">
|
|
3
|
+
<view class="snake-loading__spinner" :class="`snake-loading__spinner--${type}`" :style="spinnerStyle">
|
|
4
|
+
<view v-if="type === 'circular'" class="snake-loading__spinner-wrapper" />
|
|
5
|
+
<view v-else-if="type === 'spinner'" class="snake-loading__spinner-wrapper">
|
|
6
|
+
<view v-for="index in spinnerDots" :key="index" class="snake-loading__spinner-dot" />
|
|
7
|
+
</view>
|
|
8
|
+
<view v-else-if="type === 'dots'" class="snake-loading__spinner-wrapper">
|
|
9
|
+
<view v-for="index in 3" :key="index" class="snake-loading__spinner-dot" />
|
|
10
|
+
</view>
|
|
11
|
+
<view v-else class="snake-loading__spinner-wrapper">
|
|
12
|
+
<view v-for="index in 4" :key="index" class="snake-loading__wave-bar"><view /></view>
|
|
13
|
+
</view>
|
|
14
|
+
</view>
|
|
15
|
+
<view v-if="$slots.default || text" class="snake-loading__text" :style="textStyle">
|
|
16
|
+
<slot>{{ text }}</slot>
|
|
17
|
+
</view>
|
|
18
|
+
</view>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script setup lang="ts">
|
|
22
|
+
/**
|
|
23
|
+
* @component Loading
|
|
24
|
+
* @description Renders a reusable loading indicator for feedback states.
|
|
25
|
+
* @see /components/loading
|
|
26
|
+
*/
|
|
27
|
+
import { computed, type CSSProperties } from 'vue';
|
|
28
|
+
import { addUnit } from '../../libs/function/unit';
|
|
29
|
+
import type { LoadingProps } from './types';
|
|
30
|
+
|
|
31
|
+
defineOptions({ name: 'SnakeLoading', options: { virtualHost: true, styleIsolation: 'shared' } });
|
|
32
|
+
|
|
33
|
+
const props = withDefaults(defineProps<LoadingProps>(), {
|
|
34
|
+
show: true,
|
|
35
|
+
type: 'circular',
|
|
36
|
+
color: 'var(--snake-color-primary, #06D290)',
|
|
37
|
+
size: 34,
|
|
38
|
+
text: '',
|
|
39
|
+
textColor: 'var(--snake-color-text-muted, #909399)',
|
|
40
|
+
textSize: 14,
|
|
41
|
+
direction: 'vertical',
|
|
42
|
+
inheritColor: false,
|
|
43
|
+
duration: 800,
|
|
44
|
+
customClass: '',
|
|
45
|
+
customStyle: ''
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const spinnerDots = Array.from({ length: 12 }, (_, index) => index + 1);
|
|
49
|
+
const rootStyle = computed(() => [
|
|
50
|
+
{ color: props.inheritColor ? 'inherit' : props.color } as CSSProperties,
|
|
51
|
+
props.customStyle
|
|
52
|
+
]);
|
|
53
|
+
const spinnerStyle = computed(() => ({
|
|
54
|
+
width: addUnit(props.size),
|
|
55
|
+
height: addUnit(props.size),
|
|
56
|
+
'--snake-loading-duration': `${props.duration}ms`
|
|
57
|
+
}));
|
|
58
|
+
const textStyle = computed(() => ({ color: props.textColor, fontSize: addUnit(props.textSize) }));
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<style scoped>
|
|
62
|
+
.snake-loading {
|
|
63
|
+
display: inline-flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
justify-content: center;
|
|
66
|
+
line-height: 1;
|
|
67
|
+
}
|
|
68
|
+
.snake-loading--horizontal {
|
|
69
|
+
flex-direction: row;
|
|
70
|
+
}
|
|
71
|
+
.snake-loading--vertical {
|
|
72
|
+
flex-direction: column;
|
|
73
|
+
}
|
|
74
|
+
.snake-loading__spinner {
|
|
75
|
+
position: relative;
|
|
76
|
+
box-sizing: border-box;
|
|
77
|
+
flex: none;
|
|
78
|
+
animation: snake-loading-rotate var(--snake-loading-duration) linear infinite;
|
|
79
|
+
}
|
|
80
|
+
.snake-loading__spinner-wrapper {
|
|
81
|
+
position: relative;
|
|
82
|
+
width: 100%;
|
|
83
|
+
height: 100%;
|
|
84
|
+
}
|
|
85
|
+
.snake-loading__spinner--circular .snake-loading__spinner-wrapper {
|
|
86
|
+
border-radius: 50%;
|
|
87
|
+
background: conic-gradient(transparent 0deg 90deg, currentColor 330deg 360deg);
|
|
88
|
+
-webkit-mask: radial-gradient(closest-side, transparent calc(100% - 15%), #000 calc(100% - 15%));
|
|
89
|
+
mask: radial-gradient(closest-side, transparent calc(100% - 15%), #000 calc(100% - 15%));
|
|
90
|
+
}
|
|
91
|
+
.snake-loading__spinner--spinner {
|
|
92
|
+
animation-timing-function: steps(12);
|
|
93
|
+
}
|
|
94
|
+
.snake-loading__spinner--spinner .snake-loading__spinner-dot {
|
|
95
|
+
position: absolute;
|
|
96
|
+
top: 0;
|
|
97
|
+
left: 0;
|
|
98
|
+
width: 100%;
|
|
99
|
+
height: 100%;
|
|
100
|
+
transform: rotate(calc((var(--index) - 1) * 30deg));
|
|
101
|
+
}
|
|
102
|
+
.snake-loading__spinner--spinner .snake-loading__spinner-dot::before {
|
|
103
|
+
display: block;
|
|
104
|
+
width: 10%;
|
|
105
|
+
height: 25%;
|
|
106
|
+
margin: 0 auto;
|
|
107
|
+
border-radius: 999px;
|
|
108
|
+
background: currentColor;
|
|
109
|
+
content: '';
|
|
110
|
+
}
|
|
111
|
+
.snake-loading__spinner--spinner .snake-loading__spinner-dot:nth-child(1) {
|
|
112
|
+
--index: 1;
|
|
113
|
+
opacity: 1;
|
|
114
|
+
}
|
|
115
|
+
.snake-loading__spinner--spinner .snake-loading__spinner-dot:nth-child(2) {
|
|
116
|
+
--index: 2;
|
|
117
|
+
opacity: 0.94;
|
|
118
|
+
}
|
|
119
|
+
.snake-loading__spinner--spinner .snake-loading__spinner-dot:nth-child(3) {
|
|
120
|
+
--index: 3;
|
|
121
|
+
opacity: 0.88;
|
|
122
|
+
}
|
|
123
|
+
.snake-loading__spinner--spinner .snake-loading__spinner-dot:nth-child(4) {
|
|
124
|
+
--index: 4;
|
|
125
|
+
opacity: 0.81;
|
|
126
|
+
}
|
|
127
|
+
.snake-loading__spinner--spinner .snake-loading__spinner-dot:nth-child(5) {
|
|
128
|
+
--index: 5;
|
|
129
|
+
opacity: 0.75;
|
|
130
|
+
}
|
|
131
|
+
.snake-loading__spinner--spinner .snake-loading__spinner-dot:nth-child(6) {
|
|
132
|
+
--index: 6;
|
|
133
|
+
opacity: 0.69;
|
|
134
|
+
}
|
|
135
|
+
.snake-loading__spinner--spinner .snake-loading__spinner-dot:nth-child(7) {
|
|
136
|
+
--index: 7;
|
|
137
|
+
opacity: 0.63;
|
|
138
|
+
}
|
|
139
|
+
.snake-loading__spinner--spinner .snake-loading__spinner-dot:nth-child(8) {
|
|
140
|
+
--index: 8;
|
|
141
|
+
opacity: 0.56;
|
|
142
|
+
}
|
|
143
|
+
.snake-loading__spinner--spinner .snake-loading__spinner-dot:nth-child(9) {
|
|
144
|
+
--index: 9;
|
|
145
|
+
opacity: 0.5;
|
|
146
|
+
}
|
|
147
|
+
.snake-loading__spinner--spinner .snake-loading__spinner-dot:nth-child(10) {
|
|
148
|
+
--index: 10;
|
|
149
|
+
opacity: 0.44;
|
|
150
|
+
}
|
|
151
|
+
.snake-loading__spinner--spinner .snake-loading__spinner-dot:nth-child(11) {
|
|
152
|
+
--index: 11;
|
|
153
|
+
opacity: 0.38;
|
|
154
|
+
}
|
|
155
|
+
.snake-loading__spinner--spinner .snake-loading__spinner-dot:nth-child(12) {
|
|
156
|
+
--index: 12;
|
|
157
|
+
opacity: 0.31;
|
|
158
|
+
}
|
|
159
|
+
.snake-loading__spinner--dots {
|
|
160
|
+
animation: none;
|
|
161
|
+
}
|
|
162
|
+
.snake-loading__spinner--dots .snake-loading__spinner-wrapper {
|
|
163
|
+
display: flex;
|
|
164
|
+
align-items: center;
|
|
165
|
+
justify-content: space-between;
|
|
166
|
+
}
|
|
167
|
+
.snake-loading__spinner--dots .snake-loading__spinner-dot {
|
|
168
|
+
width: 20%;
|
|
169
|
+
height: 20%;
|
|
170
|
+
border-radius: 50%;
|
|
171
|
+
background: currentColor;
|
|
172
|
+
animation: snake-loading-dot var(--snake-loading-duration) linear infinite both;
|
|
173
|
+
}
|
|
174
|
+
.snake-loading__spinner--dots .snake-loading__spinner-dot:nth-child(2) {
|
|
175
|
+
animation-delay: calc(var(--snake-loading-duration) / 3);
|
|
176
|
+
}
|
|
177
|
+
.snake-loading__spinner--dots .snake-loading__spinner-dot:nth-child(3) {
|
|
178
|
+
animation-delay: calc(var(--snake-loading-duration) * 2 / 3);
|
|
179
|
+
}
|
|
180
|
+
.snake-loading__spinner--wave {
|
|
181
|
+
animation: none;
|
|
182
|
+
}
|
|
183
|
+
.snake-loading__spinner--wave .snake-loading__spinner-wrapper {
|
|
184
|
+
display: flex;
|
|
185
|
+
align-items: center;
|
|
186
|
+
justify-content: center;
|
|
187
|
+
gap: 6.25%;
|
|
188
|
+
}
|
|
189
|
+
.snake-loading__wave-bar {
|
|
190
|
+
display: flex;
|
|
191
|
+
align-items: center;
|
|
192
|
+
width: 12.5%;
|
|
193
|
+
height: 83.33%;
|
|
194
|
+
}
|
|
195
|
+
.snake-loading__wave-bar > view {
|
|
196
|
+
width: 100%;
|
|
197
|
+
border-radius: 999px;
|
|
198
|
+
background: currentColor;
|
|
199
|
+
animation: snake-loading-wave var(--snake-loading-duration) ease-in-out infinite alternate;
|
|
200
|
+
}
|
|
201
|
+
.snake-loading__wave-bar:nth-child(2) > view {
|
|
202
|
+
animation-delay: calc(var(--snake-loading-duration) / -4);
|
|
203
|
+
}
|
|
204
|
+
.snake-loading__wave-bar:nth-child(3) > view {
|
|
205
|
+
animation-delay: calc(var(--snake-loading-duration) / -2);
|
|
206
|
+
}
|
|
207
|
+
.snake-loading__wave-bar:nth-child(4) > view {
|
|
208
|
+
animation-delay: calc(var(--snake-loading-duration) * -3 / 4);
|
|
209
|
+
}
|
|
210
|
+
.snake-loading__text {
|
|
211
|
+
line-height: 1.4;
|
|
212
|
+
}
|
|
213
|
+
.snake-loading--horizontal .snake-loading__text {
|
|
214
|
+
margin-left: 12rpx;
|
|
215
|
+
}
|
|
216
|
+
.snake-loading--vertical .snake-loading__text {
|
|
217
|
+
margin-top: 12rpx;
|
|
218
|
+
}
|
|
219
|
+
@keyframes snake-loading-rotate {
|
|
220
|
+
to {
|
|
221
|
+
transform: rotate(360deg);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
@keyframes snake-loading-dot {
|
|
225
|
+
0%,
|
|
226
|
+
100% {
|
|
227
|
+
opacity: 0.15;
|
|
228
|
+
}
|
|
229
|
+
33% {
|
|
230
|
+
opacity: 1;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
@keyframes snake-loading-wave {
|
|
234
|
+
from {
|
|
235
|
+
height: 20%;
|
|
236
|
+
}
|
|
237
|
+
to {
|
|
238
|
+
height: 100%;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
</style>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { StyleValue } from '../../types/global';
|
|
2
|
+
|
|
3
|
+
/** Available loading animations. */
|
|
4
|
+
export type LoadingType = 'circular' | 'spinner' | 'dots' | 'wave';
|
|
5
|
+
/** Relative placement of the loading text. */
|
|
6
|
+
export type LoadingDirection = 'horizontal' | 'vertical';
|
|
7
|
+
|
|
8
|
+
/** Public props for SnakeLoading. */
|
|
9
|
+
export interface LoadingProps {
|
|
10
|
+
/** Whether the component is rendered. */
|
|
11
|
+
show?: boolean;
|
|
12
|
+
/** Loading animation type. */
|
|
13
|
+
type?: LoadingType;
|
|
14
|
+
/** Loading indicator color. */
|
|
15
|
+
color?: string;
|
|
16
|
+
/** Loading indicator size. */
|
|
17
|
+
size?: number | string;
|
|
18
|
+
/** Fallback text for the default slot. */
|
|
19
|
+
text?: string;
|
|
20
|
+
/** Text color. */
|
|
21
|
+
textColor?: string;
|
|
22
|
+
/** Text size. */
|
|
23
|
+
textSize?: number | string;
|
|
24
|
+
/** Indicator and text layout direction. */
|
|
25
|
+
direction?: LoadingDirection;
|
|
26
|
+
/** Whether to inherit the parent color. */
|
|
27
|
+
inheritColor?: boolean;
|
|
28
|
+
/** Animation duration in milliseconds. */
|
|
29
|
+
duration?: number;
|
|
30
|
+
/** Root element class name. */
|
|
31
|
+
customClass?: string;
|
|
32
|
+
/** Root element inline style. */
|
|
33
|
+
customStyle?: StyleValue;
|
|
34
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="snake-loadmore" :class="customClass" :style="rootStyle" @click="click">
|
|
3
|
+
<SnakeLine class="snake-loadmore__line" length="50%" />
|
|
4
|
+
<view class="snake-loadmore__content">
|
|
5
|
+
<Loading
|
|
6
|
+
v-if="status === 'loading' && icon"
|
|
7
|
+
:type="iconType === 'flower' ? 'spinner' : iconType === 'circle' ? 'circular' : 'spinner'"
|
|
8
|
+
:color="iconColor"
|
|
9
|
+
size="34"
|
|
10
|
+
/>
|
|
11
|
+
<text class="snake-loadmore__text">{{ label }}</text>
|
|
12
|
+
</view>
|
|
13
|
+
<SnakeLine class="snake-loadmore__line" length="50%" />
|
|
14
|
+
</view>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup lang="ts">
|
|
18
|
+
/**
|
|
19
|
+
* @component Loadmore
|
|
20
|
+
* @description 用于列表底部反馈分页状态。组件不直接请求数据,点击可加载状态时会派发 `loadmore`,由业务更新 `status`。
|
|
21
|
+
* @see /components/loadmore
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { computed } from 'vue';
|
|
25
|
+
import { addUnit } from '../../libs/function/unit';
|
|
26
|
+
import { translate } from '../../locale';
|
|
27
|
+
import Loading from '../snake-loading/snake-loading.vue';
|
|
28
|
+
import SnakeLine from '../snake-line/snake-line.vue';
|
|
29
|
+
import type { LoadmoreEmits, LoadmoreProps } from './types';
|
|
30
|
+
|
|
31
|
+
defineOptions({ name: 'Loadmore', options: { virtualHost: true, styleIsolation: 'shared' } });
|
|
32
|
+
const props = withDefaults(defineProps<LoadmoreProps>(), {
|
|
33
|
+
status: 'loadmore',
|
|
34
|
+
loadText: '',
|
|
35
|
+
loadingText: '',
|
|
36
|
+
nomoreText: '',
|
|
37
|
+
bgColor: 'transparent',
|
|
38
|
+
icon: true,
|
|
39
|
+
iconType: 'circle',
|
|
40
|
+
iconColor: 'var(--snake-color-text-light, #c0c4cc)',
|
|
41
|
+
isDot: false,
|
|
42
|
+
color: 'var(--snake-color-text-secondary, #606266)',
|
|
43
|
+
fontSize: 28,
|
|
44
|
+
marginTop: 0,
|
|
45
|
+
marginBottom: 0,
|
|
46
|
+
height: 'auto',
|
|
47
|
+
customClass: '',
|
|
48
|
+
customStyle: ''
|
|
49
|
+
});
|
|
50
|
+
const emit = defineEmits<LoadmoreEmits>();
|
|
51
|
+
const labels = computed(() => (typeof props.loadText === 'object' ? props.loadText : {}));
|
|
52
|
+
const label = computed(() => {
|
|
53
|
+
if (props.status === 'loading') return props.loadingText || labels.value.loading || translate('common.loading');
|
|
54
|
+
if (props.status === 'nomore')
|
|
55
|
+
return props.isDot ? '●' : props.nomoreText || labels.value.nomore || translate('common.noMore');
|
|
56
|
+
return (
|
|
57
|
+
(typeof props.loadText === 'string' ? props.loadText : labels.value.loadmore) || translate('common.loadMore')
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
const rootStyle = computed(() => [
|
|
61
|
+
{
|
|
62
|
+
backgroundColor: props.bgColor,
|
|
63
|
+
color: props.color,
|
|
64
|
+
fontSize: addUnit(props.fontSize, 'rpx'),
|
|
65
|
+
marginTop: addUnit(props.marginTop, 'rpx'),
|
|
66
|
+
marginBottom: addUnit(props.marginBottom, 'rpx'),
|
|
67
|
+
height: props.height === 'auto' ? 'auto' : addUnit(props.height, 'rpx')
|
|
68
|
+
},
|
|
69
|
+
props.customStyle
|
|
70
|
+
]);
|
|
71
|
+
function click() {
|
|
72
|
+
emit('click', props.status);
|
|
73
|
+
if (props.status === 'loadmore') emit('loadmore');
|
|
74
|
+
}
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<style scoped>
|
|
78
|
+
.snake-loadmore {
|
|
79
|
+
display: flex;
|
|
80
|
+
align-items: center;
|
|
81
|
+
justify-content: center;
|
|
82
|
+
min-height: 80rpx;
|
|
83
|
+
gap: 12rpx;
|
|
84
|
+
padding: 12rpx 24rpx;
|
|
85
|
+
line-height: 1.5;
|
|
86
|
+
}
|
|
87
|
+
.snake-loadmore__line {
|
|
88
|
+
min-width: 0;
|
|
89
|
+
flex: 1;
|
|
90
|
+
}
|
|
91
|
+
.snake-loadmore__content {
|
|
92
|
+
display: flex;
|
|
93
|
+
flex: 0 0 auto;
|
|
94
|
+
align-items: center;
|
|
95
|
+
justify-content: center;
|
|
96
|
+
gap: 12rpx;
|
|
97
|
+
padding: 0 12rpx;
|
|
98
|
+
}
|
|
99
|
+
.snake-loadmore__text {
|
|
100
|
+
color: inherit;
|
|
101
|
+
font-size: inherit;
|
|
102
|
+
}
|
|
103
|
+
</style>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { UnitValue } from '../../libs/function/unit';
|
|
2
|
+
import type { StyleValue } from '../../types/global';
|
|
3
|
+
|
|
4
|
+
/** LoadmoreStatus 类型定义。 */
|
|
5
|
+
export type LoadmoreStatus = 'loadmore' | 'loading' | 'nomore';
|
|
6
|
+
/** LoadmoreText 类型定义。 */
|
|
7
|
+
export interface LoadmoreText {
|
|
8
|
+
/** loadmore 配置。 */
|
|
9
|
+
loadmore?: string;
|
|
10
|
+
/** 是否显示加载状态。 */
|
|
11
|
+
loading?: string;
|
|
12
|
+
/** nomore 配置。 */
|
|
13
|
+
nomore?: string;
|
|
14
|
+
}
|
|
15
|
+
/** Loadmore 组件的公开属性。 */
|
|
16
|
+
export interface LoadmoreProps {
|
|
17
|
+
/** 当前状态。 */
|
|
18
|
+
status?: LoadmoreStatus;
|
|
19
|
+
/** load text 配置。 */
|
|
20
|
+
loadText?: string | LoadmoreText;
|
|
21
|
+
/** 加载状态下显示的文本。 */
|
|
22
|
+
loadingText?: string;
|
|
23
|
+
/** nomore text 配置。 */
|
|
24
|
+
nomoreText?: string;
|
|
25
|
+
/** 背景颜色。 */
|
|
26
|
+
bgColor?: string;
|
|
27
|
+
/** 图标名称。 */
|
|
28
|
+
icon?: boolean;
|
|
29
|
+
/** icon type 配置。 */
|
|
30
|
+
iconType?: 'circle' | 'flower' | 'spinner';
|
|
31
|
+
/** 图标颜色。 */
|
|
32
|
+
iconColor?: string;
|
|
33
|
+
/** is dot 配置。 */
|
|
34
|
+
isDot?: boolean;
|
|
35
|
+
/** 内容颜色。 */
|
|
36
|
+
color?: string;
|
|
37
|
+
/** 文字尺寸,数值按 rpx 处理。 */
|
|
38
|
+
fontSize?: UnitValue;
|
|
39
|
+
/** 组件顶部外边距。 */
|
|
40
|
+
marginTop?: UnitValue;
|
|
41
|
+
/** 组件底部外边距。 */
|
|
42
|
+
marginBottom?: UnitValue;
|
|
43
|
+
/** 组件高度;数值按 rpx 处理,默认自适应内容。 */
|
|
44
|
+
height?: UnitValue;
|
|
45
|
+
/** 根节点自定义类名。 */
|
|
46
|
+
customClass?: string;
|
|
47
|
+
/** 根节点自定义样式。 */
|
|
48
|
+
customStyle?: StyleValue;
|
|
49
|
+
}
|
|
50
|
+
/** Loadmore 组件的事件契约。 */
|
|
51
|
+
export type LoadmoreEmits = {
|
|
52
|
+
/** loadmore 事件携带的参数。 */
|
|
53
|
+
loadmore: [];
|
|
54
|
+
/** click 事件携带的参数。 */
|
|
55
|
+
click: [status: LoadmoreStatus];
|
|
56
|
+
};
|