@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,82 @@
|
|
|
1
|
+
import type { UnitValue } from '../../libs/function/unit';
|
|
2
|
+
import type { StyleValue } from '../../types/global';
|
|
3
|
+
/** NoticeBarMode 类型定义。 */
|
|
4
|
+
export type NoticeBarMode = 'horizontal' | 'vertical';
|
|
5
|
+
/** NoticeBarDirection 类型定义。 */
|
|
6
|
+
export type NoticeBarDirection = 'row' | 'column';
|
|
7
|
+
/** NoticeBar 组件的公开属性。 */
|
|
8
|
+
export interface NoticeBarProps {
|
|
9
|
+
/** 用于渲染的数据列表。 */
|
|
10
|
+
list?: string[];
|
|
11
|
+
/** 展示文本。 */
|
|
12
|
+
text?: string | string[];
|
|
13
|
+
/** 组件类型或展示模式。 */
|
|
14
|
+
type?: 'primary' | 'success' | 'warning' | 'error' | 'info';
|
|
15
|
+
/** 组件展示模式。 */
|
|
16
|
+
mode?: NoticeBarMode;
|
|
17
|
+
/** 内容排列或滚动方向。 */
|
|
18
|
+
direction?: NoticeBarDirection;
|
|
19
|
+
/** 标准 v-model 可见性。未传入 show 时作为外部控制值。 */
|
|
20
|
+
modelValue?: boolean;
|
|
21
|
+
/** 是否显示组件。支持 v-model:show。 */
|
|
22
|
+
show?: boolean;
|
|
23
|
+
/** 是否自动播放。 */
|
|
24
|
+
autoplay?: boolean;
|
|
25
|
+
/** volume icon 配置。 */
|
|
26
|
+
volumeIcon?: boolean;
|
|
27
|
+
/** volume size 配置。 */
|
|
28
|
+
volumeSize?: UnitValue;
|
|
29
|
+
/** more icon 配置。 */
|
|
30
|
+
moreIcon?: boolean;
|
|
31
|
+
/** 关闭按钮图标名称。 */
|
|
32
|
+
closeIcon?: boolean;
|
|
33
|
+
/** 背景颜色。 */
|
|
34
|
+
bgColor?: string;
|
|
35
|
+
/** 内容颜色。 */
|
|
36
|
+
color?: string;
|
|
37
|
+
/** 文字尺寸,数值按 rpx 处理。 */
|
|
38
|
+
fontSize?: UnitValue;
|
|
39
|
+
/** 动画持续时间。 */
|
|
40
|
+
duration?: number;
|
|
41
|
+
/** speed 配置。 */
|
|
42
|
+
speed?: number;
|
|
43
|
+
/** is circular 配置。 */
|
|
44
|
+
isCircular?: boolean;
|
|
45
|
+
/** play state 配置。 */
|
|
46
|
+
playState?: 'play' | 'paused';
|
|
47
|
+
/** disable touch 配置。 */
|
|
48
|
+
disableTouch?: boolean;
|
|
49
|
+
/** 圆角尺寸。 */
|
|
50
|
+
borderRadius?: UnitValue;
|
|
51
|
+
/** padding 配置。 */
|
|
52
|
+
padding?: string;
|
|
53
|
+
/** no list hidden 配置。 */
|
|
54
|
+
noListHidden?: boolean;
|
|
55
|
+
/** 根节点自定义类名。 */
|
|
56
|
+
customClass?: string;
|
|
57
|
+
/** 根节点自定义样式。 */
|
|
58
|
+
customStyle?: StyleValue;
|
|
59
|
+
}
|
|
60
|
+
/** NoticeBar 组件的事件契约。 */
|
|
61
|
+
export type NoticeBarEmits = {
|
|
62
|
+
/** 标准 v-model 更新。 */
|
|
63
|
+
'update:modelValue': [value: boolean];
|
|
64
|
+
/** show 双向绑定更新。 */
|
|
65
|
+
'update:show': [value: boolean];
|
|
66
|
+
/** click 事件携带的参数。 */
|
|
67
|
+
click: [index: number];
|
|
68
|
+
/** change 事件携带的参数。 */
|
|
69
|
+
change: [index: number];
|
|
70
|
+
/** close 事件携带的参数。 */
|
|
71
|
+
close: [];
|
|
72
|
+
/** getMore 事件携带的参数。 */
|
|
73
|
+
getMore: [];
|
|
74
|
+
/** 一次非循环播放完成,或纵向轮播完成一整轮时触发。 */
|
|
75
|
+
end: [];
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/** NoticeBar 组件实例公开的方法。 */
|
|
79
|
+
export interface NoticeBarExpose {
|
|
80
|
+
/** 从第一条消息重新开始播放并重新测量尺寸。 */
|
|
81
|
+
reset(): void;
|
|
82
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<snake-transition
|
|
3
|
+
:show="visible"
|
|
4
|
+
name="fade"
|
|
5
|
+
:duration="duration"
|
|
6
|
+
:custom-class="['snake-overlay', customClass].filter(Boolean).join(' ')"
|
|
7
|
+
:custom-style="overlayStyle"
|
|
8
|
+
@click="click"
|
|
9
|
+
@after-enter="emit('opened')"
|
|
10
|
+
@after-leave="emit('closed')"
|
|
11
|
+
@touchmove.stop.prevent="lockScroll ? stopTouchMove() : undefined"
|
|
12
|
+
>
|
|
13
|
+
<slot />
|
|
14
|
+
</snake-transition>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup lang="ts">
|
|
18
|
+
/**
|
|
19
|
+
* @component Overlay
|
|
20
|
+
* @description 带完整淡入淡出动画的全屏遮罩,可锁定遮罩区域滚动并承载自定义内容。
|
|
21
|
+
* @see /components/overlay
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { computed, getCurrentInstance } from 'vue';
|
|
25
|
+
import zIndex from '../../libs/config/zIndex';
|
|
26
|
+
import Transition from '../snake-transition/snake-transition.vue';
|
|
27
|
+
import type { OverlayEmits, OverlayProps } from './types';
|
|
28
|
+
|
|
29
|
+
defineOptions({ name: 'Overlay', options: { virtualHost: true, styleIsolation: 'shared' } });
|
|
30
|
+
|
|
31
|
+
const props = withDefaults(defineProps<OverlayProps>(), {
|
|
32
|
+
modelValue: false,
|
|
33
|
+
opacity: 0.5,
|
|
34
|
+
zIndex: zIndex.mask,
|
|
35
|
+
duration: 300,
|
|
36
|
+
lockScroll: true,
|
|
37
|
+
customClass: '',
|
|
38
|
+
customStyle: ''
|
|
39
|
+
});
|
|
40
|
+
const emit = defineEmits<OverlayEmits>();
|
|
41
|
+
// 与 snake-popup 同理:未绑定 show 时 Boolean casting 会让 `??` 失效,需检测实际绑定来源。
|
|
42
|
+
const showBound = 'show' in (getCurrentInstance()?.vnode?.props ?? {});
|
|
43
|
+
const visible = computed(() => (showBound ? props.show : props.modelValue));
|
|
44
|
+
// 层级:z-index 全权交给行内样式——显示时取 mask 档、隐藏时 -1,
|
|
45
|
+
// 传入值非法(undefined/NaN 会被小程序当作非法声明丢弃)时由 || 退回 mask 档
|
|
46
|
+
const overlayStyle = computed(() => [
|
|
47
|
+
{
|
|
48
|
+
backgroundColor: `rgba(0, 0, 0, ${Math.min(1, Math.max(0, props.opacity))})`,
|
|
49
|
+
zIndex: visible.value ? props.zIndex || zIndex.mask : -1
|
|
50
|
+
},
|
|
51
|
+
props.customStyle
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
function click(event: unknown) {
|
|
55
|
+
emit('click', event);
|
|
56
|
+
emit('update:modelValue', false);
|
|
57
|
+
emit('update:show', false);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function stopTouchMove() {
|
|
61
|
+
// uni-app 通过空处理器阻止遮罩上的 touchmove 冒泡。
|
|
62
|
+
}
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<style>
|
|
66
|
+
.snake-overlay {
|
|
67
|
+
position: fixed;
|
|
68
|
+
top: 0;
|
|
69
|
+
right: 0;
|
|
70
|
+
bottom: 0;
|
|
71
|
+
left: 0;
|
|
72
|
+
}
|
|
73
|
+
</style>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { StyleValue } from '../../types/global';
|
|
2
|
+
|
|
3
|
+
/** Overlay 组件的公开属性。 */
|
|
4
|
+
export interface OverlayProps {
|
|
5
|
+
/** 双向绑定的当前值。 */
|
|
6
|
+
modelValue?: boolean;
|
|
7
|
+
/** 是否显示组件。 */
|
|
8
|
+
show?: boolean;
|
|
9
|
+
/** opacity 配置。 */
|
|
10
|
+
opacity?: number;
|
|
11
|
+
/** 组件层级。 */
|
|
12
|
+
zIndex?: number;
|
|
13
|
+
/** 动画持续时间。 */
|
|
14
|
+
duration?: number;
|
|
15
|
+
/** lock scroll 配置。 */
|
|
16
|
+
lockScroll?: boolean;
|
|
17
|
+
/** 根节点自定义类名。 */
|
|
18
|
+
customClass?: string;
|
|
19
|
+
/** 根节点自定义样式。 */
|
|
20
|
+
customStyle?: StyleValue;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Overlay 组件的事件契约。 */
|
|
24
|
+
export type OverlayEmits = {
|
|
25
|
+
/** update:modelValue 事件携带的参数。 */
|
|
26
|
+
'update:modelValue': [value: boolean];
|
|
27
|
+
/** update:show 事件携带的参数。 */
|
|
28
|
+
'update:show': [value: boolean];
|
|
29
|
+
/** click 事件携带的参数。 */
|
|
30
|
+
click: [event: unknown];
|
|
31
|
+
/** opened 事件携带的参数。 */
|
|
32
|
+
opened: [];
|
|
33
|
+
/** closed 事件携带的参数。 */
|
|
34
|
+
closed: [];
|
|
35
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="page-popup">
|
|
3
|
+
<snake-popup
|
|
4
|
+
v-model="show"
|
|
5
|
+
border-radius="10rpx"
|
|
6
|
+
:mode="datas.popupMode"
|
|
7
|
+
:bg-color="datas.popupMode === 'bottom' ? 'var(--snake-color-surface, #fff)' : 'transparent'"
|
|
8
|
+
>
|
|
9
|
+
<view class="popup-container">
|
|
10
|
+
<view :class="[`page-popup-popup page-popup-popup--${datas.popupMode}`]">
|
|
11
|
+
<view
|
|
12
|
+
:class="[`close close--${datas.popupMode}`]"
|
|
13
|
+
@click.stop="show = false"
|
|
14
|
+
v-if="datas.popupMode === 'bottom'"
|
|
15
|
+
>
|
|
16
|
+
<snake-icon name="close" color="var(--snake-color-text, #26273a)" size="18"></snake-icon>
|
|
17
|
+
</view>
|
|
18
|
+
<image
|
|
19
|
+
class="page-popup-img"
|
|
20
|
+
mode="aspectFill"
|
|
21
|
+
:src="datas.image"
|
|
22
|
+
@click.stop="handleToPage"
|
|
23
|
+
></image>
|
|
24
|
+
</view>
|
|
25
|
+
<view
|
|
26
|
+
:class="[`close close--${datas.popupMode}`]"
|
|
27
|
+
@click.stop="show = false"
|
|
28
|
+
v-if="datas.popupMode === 'center'"
|
|
29
|
+
>
|
|
30
|
+
<snake-icon name="close-circle-fill" color="#fff" size="28"></snake-icon>
|
|
31
|
+
</view>
|
|
32
|
+
</view>
|
|
33
|
+
</snake-popup>
|
|
34
|
+
</view>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<script setup lang="ts">
|
|
38
|
+
/**
|
|
39
|
+
* @component PagePopup
|
|
40
|
+
* @description 页面进入后立即展示居中或底部图片弹窗,并支持图片跳转。
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
import { onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
|
44
|
+
import type { PagePopupProps } from './types';
|
|
45
|
+
|
|
46
|
+
defineOptions({ name: 'PagePopup', options: { virtualHost: true, styleIsolation: 'shared' } });
|
|
47
|
+
|
|
48
|
+
const props = withDefaults(defineProps<PagePopupProps>(), {
|
|
49
|
+
datas: () => ({}),
|
|
50
|
+
autoOpen: true
|
|
51
|
+
});
|
|
52
|
+
const show = ref(props.autoOpen);
|
|
53
|
+
|
|
54
|
+
watch(show, visible => {
|
|
55
|
+
if (props.datas.popupMode !== 'bottom') return;
|
|
56
|
+
if (visible) {
|
|
57
|
+
uni.hideTabBar({ animation: true });
|
|
58
|
+
} else {
|
|
59
|
+
uni.$snake.sleep(300).then(() => {
|
|
60
|
+
if (!show.value || props.datas.popupMode !== 'bottom') uni.showTabBar({ animation: true });
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
watch(
|
|
66
|
+
() => props.datas.popupMode,
|
|
67
|
+
(mode, previousMode) => {
|
|
68
|
+
if (!show.value) return;
|
|
69
|
+
if (mode === 'bottom') uni.hideTabBar({ animation: true });
|
|
70
|
+
else if (previousMode === 'bottom') uni.showTabBar({ animation: true });
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
onMounted(() => {
|
|
75
|
+
if (show.value && props.datas.popupMode === 'bottom') {
|
|
76
|
+
uni.hideTabBar({ animation: true });
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
onBeforeUnmount(() => {
|
|
81
|
+
if (show.value && props.datas.popupMode === 'bottom') uni.showTabBar({ animation: true });
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
function open() {
|
|
85
|
+
show.value = true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function close() {
|
|
89
|
+
show.value = false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
defineExpose({ open, close });
|
|
93
|
+
|
|
94
|
+
function handleToPage() {
|
|
95
|
+
if (props.datas.url) uni.$snake.navTo(props.datas.url);
|
|
96
|
+
}
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<style lang="scss" scoped>
|
|
100
|
+
.page-popup {
|
|
101
|
+
width: 100%;
|
|
102
|
+
height: 100%;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.popup-container {
|
|
106
|
+
position: relative;
|
|
107
|
+
width: 100%;
|
|
108
|
+
height: 100%;
|
|
109
|
+
|
|
110
|
+
.page-popup-popup {
|
|
111
|
+
box-sizing: border-box;
|
|
112
|
+
width: 100%;
|
|
113
|
+
height: 572rpx;
|
|
114
|
+
|
|
115
|
+
&--center {
|
|
116
|
+
width: 540rpx;
|
|
117
|
+
height: 740rpx;
|
|
118
|
+
|
|
119
|
+
.page-popup-img {
|
|
120
|
+
height: 740rpx !important;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.page-popup-img {
|
|
125
|
+
display: block;
|
|
126
|
+
width: 100%;
|
|
127
|
+
height: 524rpx;
|
|
128
|
+
border-radius: 6rpx;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.close {
|
|
133
|
+
display: flex;
|
|
134
|
+
justify-content: flex-end;
|
|
135
|
+
padding-top: 16rpx;
|
|
136
|
+
padding-right: 16rpx;
|
|
137
|
+
|
|
138
|
+
&--center {
|
|
139
|
+
position: absolute;
|
|
140
|
+
bottom: -100rpx;
|
|
141
|
+
left: 50%;
|
|
142
|
+
transform: translateX(-50%);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
</style>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** PagePopupMode 类型定义。 */
|
|
2
|
+
export type PagePopupMode = 'bottom' | 'center';
|
|
3
|
+
|
|
4
|
+
/** PagePopup 配置数据。 */
|
|
5
|
+
export interface PagePopupData {
|
|
6
|
+
/** popup mode 配置。 */
|
|
7
|
+
popupMode?: PagePopupMode;
|
|
8
|
+
/** 图片地址。 */
|
|
9
|
+
image?: string;
|
|
10
|
+
/** 点击后跳转地址。 */
|
|
11
|
+
url?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** PagePopup 组件的公开属性。 */
|
|
15
|
+
export interface PagePopupProps {
|
|
16
|
+
/** CMS 装修组件配置数据。 */
|
|
17
|
+
datas?: PagePopupData;
|
|
18
|
+
/** 组件挂载后是否立即打开弹窗。 */
|
|
19
|
+
autoOpen?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** PagePopup 实例公开的操作。 */
|
|
23
|
+
export interface PagePopupExpose {
|
|
24
|
+
/** 打开弹窗。 */
|
|
25
|
+
open(): void;
|
|
26
|
+
/** 关闭弹窗。 */
|
|
27
|
+
close(): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view v-if="controls" @click="onClick" class="_contain">
|
|
3
|
+
<!-- 海报和按钮 -->
|
|
4
|
+
<view class="_poster" :style="'background-image:url(' + poster + ')'">
|
|
5
|
+
<view class="_button" @tap="_buttonTap">
|
|
6
|
+
<view :class="playing ? '_pause' : '_play'" />
|
|
7
|
+
</view>
|
|
8
|
+
</view>
|
|
9
|
+
<!-- 曲名和作者 -->
|
|
10
|
+
<view class="_title">
|
|
11
|
+
<view class="_name">{{ name || '未知音频' }}</view>
|
|
12
|
+
<view class="_author">{{ author || '未知作者' }}</view>
|
|
13
|
+
</view>
|
|
14
|
+
<!-- 进度条 -->
|
|
15
|
+
<slider
|
|
16
|
+
class="_slider"
|
|
17
|
+
activeColor="#585959"
|
|
18
|
+
block-size="12"
|
|
19
|
+
handle-size="12"
|
|
20
|
+
:disabled="error"
|
|
21
|
+
:value="value"
|
|
22
|
+
@changing="_seeking"
|
|
23
|
+
@change="_seeked"
|
|
24
|
+
/>
|
|
25
|
+
<!--播放时间-->
|
|
26
|
+
<view class="_time">{{ time || '00:00' }}</view>
|
|
27
|
+
</view>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script>
|
|
31
|
+
/**
|
|
32
|
+
* @fileoverview audio 组件
|
|
33
|
+
*/
|
|
34
|
+
import context from './context';
|
|
35
|
+
export default {
|
|
36
|
+
data() {
|
|
37
|
+
return {
|
|
38
|
+
error: false,
|
|
39
|
+
playing: false,
|
|
40
|
+
time: '00:00',
|
|
41
|
+
value: 0
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
props: {
|
|
45
|
+
aid: String,
|
|
46
|
+
name: String, // 音乐名
|
|
47
|
+
author: String, // 作者
|
|
48
|
+
poster: String, // 海报图片地址
|
|
49
|
+
autoplay: [Boolean, String], // 是否自动播放
|
|
50
|
+
controls: [Boolean, String], // 是否显示控件
|
|
51
|
+
loop: [Boolean, String], // 是否循环播放
|
|
52
|
+
src: String // 源地址
|
|
53
|
+
},
|
|
54
|
+
watch: {
|
|
55
|
+
src(src) {
|
|
56
|
+
this.setSrc(src);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
mounted() {
|
|
60
|
+
this._ctx = uni.createInnerAudioContext();
|
|
61
|
+
this._ctx.onError(err => {
|
|
62
|
+
this.error = true;
|
|
63
|
+
this.$emit('error', err);
|
|
64
|
+
});
|
|
65
|
+
this._ctx.onTimeUpdate(() => {
|
|
66
|
+
const time = this._ctx.currentTime;
|
|
67
|
+
const min = parseInt(time / 60);
|
|
68
|
+
const sec = Math.ceil(time % 60);
|
|
69
|
+
this.time = (min > 9 ? min : '0' + min) + ':' + (sec > 9 ? sec : '0' + sec);
|
|
70
|
+
if (!this.lastTime) {
|
|
71
|
+
this.value = (time / this._ctx.duration) * 100; // 不在拖动状态下
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
this._ctx.onEnded(() => {
|
|
75
|
+
if (!this.loop) {
|
|
76
|
+
this.playing = false;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
context.set(this.aid, this);
|
|
80
|
+
this.setSrc(this.src);
|
|
81
|
+
},
|
|
82
|
+
// #ifdef VUE2
|
|
83
|
+
beforeDestroy() {
|
|
84
|
+
this._ctx.destroy();
|
|
85
|
+
context.remove(this.aid);
|
|
86
|
+
},
|
|
87
|
+
// #endif
|
|
88
|
+
// #ifdef VUE3
|
|
89
|
+
beforeUnmount() {
|
|
90
|
+
this._ctx.destroy();
|
|
91
|
+
context.remove(this.aid);
|
|
92
|
+
},
|
|
93
|
+
// #endif
|
|
94
|
+
onPageShow() {
|
|
95
|
+
if (this.playing && this._ctx.paused) {
|
|
96
|
+
this._ctx.play();
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
methods: {
|
|
100
|
+
// 设置源
|
|
101
|
+
setSrc(src) {
|
|
102
|
+
this._ctx.autoplay = this.autoplay;
|
|
103
|
+
this._ctx.loop = this.loop;
|
|
104
|
+
this._ctx.src = src;
|
|
105
|
+
if (this.autoplay && !this.playing) {
|
|
106
|
+
this.playing = true;
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
// 播放
|
|
110
|
+
play() {
|
|
111
|
+
this._ctx.play();
|
|
112
|
+
this.playing = true;
|
|
113
|
+
this.$emit('play', {
|
|
114
|
+
target: {
|
|
115
|
+
id: this.aid
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
// 暂停
|
|
120
|
+
pause() {
|
|
121
|
+
this._ctx.pause();
|
|
122
|
+
this.playing = false;
|
|
123
|
+
this.$emit('pause');
|
|
124
|
+
},
|
|
125
|
+
// 设置播放速率
|
|
126
|
+
playbackRate(rate) {
|
|
127
|
+
this._ctx.playbackRate = rate;
|
|
128
|
+
},
|
|
129
|
+
// 移动进度条
|
|
130
|
+
seek(sec) {
|
|
131
|
+
this._ctx.seek(sec);
|
|
132
|
+
},
|
|
133
|
+
// 内部方法
|
|
134
|
+
_buttonTap() {
|
|
135
|
+
if (this.playing) this.pause();
|
|
136
|
+
else this.play();
|
|
137
|
+
},
|
|
138
|
+
_seeking(e) {
|
|
139
|
+
// 避免过于频繁 setData
|
|
140
|
+
if (e.timeStamp - this.lastTime < 200) return;
|
|
141
|
+
const time = Math.round((e.detail.value / 100) * this._ctx.duration);
|
|
142
|
+
const min = parseInt(time / 60);
|
|
143
|
+
const sec = time % 60;
|
|
144
|
+
this.time = (min > 9 ? min : '0' + min) + ':' + (sec > 9 ? sec : '0' + sec);
|
|
145
|
+
this.lastTime = e.timeStamp;
|
|
146
|
+
},
|
|
147
|
+
_seeked(e) {
|
|
148
|
+
this.seek((e.detail.value / 100) * this._ctx.duration);
|
|
149
|
+
this.lastTime = undefined;
|
|
150
|
+
},
|
|
151
|
+
onClick(e) {
|
|
152
|
+
this.$emit('onClick', e);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
</script>
|
|
157
|
+
|
|
158
|
+
<style>
|
|
159
|
+
/* 顶层容器 */
|
|
160
|
+
._contain {
|
|
161
|
+
position: relative;
|
|
162
|
+
display: inline-flex;
|
|
163
|
+
width: 290px;
|
|
164
|
+
background-color: #fcfcfc;
|
|
165
|
+
border: 1px solid #e0e0e0;
|
|
166
|
+
border-radius: 2px;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/* 播放、暂停按钮 */
|
|
170
|
+
._button {
|
|
171
|
+
display: flex;
|
|
172
|
+
align-items: center;
|
|
173
|
+
justify-content: center;
|
|
174
|
+
width: 20px;
|
|
175
|
+
height: 20px;
|
|
176
|
+
overflow: hidden;
|
|
177
|
+
background-color: rgb(0, 0, 0, 0.2);
|
|
178
|
+
border: 1px solid white;
|
|
179
|
+
border-radius: 50%;
|
|
180
|
+
opacity: 0.9;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
._play {
|
|
184
|
+
margin-left: 2px;
|
|
185
|
+
border-top: 4px solid transparent;
|
|
186
|
+
border-bottom: 4px solid transparent;
|
|
187
|
+
border-left: 8px solid white;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
._pause {
|
|
191
|
+
width: 8px;
|
|
192
|
+
height: 8px;
|
|
193
|
+
background-color: white;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/* 海报 */
|
|
197
|
+
._poster {
|
|
198
|
+
display: flex;
|
|
199
|
+
align-items: center;
|
|
200
|
+
justify-content: center;
|
|
201
|
+
width: 70px;
|
|
202
|
+
height: 70px;
|
|
203
|
+
background-color: #e6e6e6;
|
|
204
|
+
background-size: contain;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/* 标题栏 */
|
|
208
|
+
._title {
|
|
209
|
+
flex: 1;
|
|
210
|
+
margin: 4px 0 0 14px;
|
|
211
|
+
text-align: left;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
._author {
|
|
215
|
+
width: 45px;
|
|
216
|
+
font-size: 12px;
|
|
217
|
+
color: #888;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
._name {
|
|
221
|
+
width: 140px;
|
|
222
|
+
font-size: 15px;
|
|
223
|
+
line-height: 39px;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
._author,
|
|
227
|
+
._name {
|
|
228
|
+
overflow: hidden;
|
|
229
|
+
text-overflow: ellipsis;
|
|
230
|
+
white-space: nowrap;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* 进度条 */
|
|
234
|
+
._slider {
|
|
235
|
+
position: absolute;
|
|
236
|
+
right: 16px;
|
|
237
|
+
bottom: 8px;
|
|
238
|
+
width: 140px;
|
|
239
|
+
margin: 0;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/* 播放时间 */
|
|
243
|
+
._time {
|
|
244
|
+
margin: 7px 14px 0 0;
|
|
245
|
+
font-size: 12px;
|
|
246
|
+
color: #888;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/* 响应式布局,大屏幕用更大的尺寸 */
|
|
250
|
+
@media (min-width: 400px) {
|
|
251
|
+
._contain {
|
|
252
|
+
width: 380px;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
._button {
|
|
256
|
+
width: 26px;
|
|
257
|
+
height: 26px;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
._poster {
|
|
261
|
+
width: 90px;
|
|
262
|
+
height: 90px;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
._author {
|
|
266
|
+
width: 60px;
|
|
267
|
+
font-size: 15px;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
._name {
|
|
271
|
+
width: 180px;
|
|
272
|
+
font-size: 19px;
|
|
273
|
+
line-height: 55px;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
._slider {
|
|
277
|
+
right: 20px;
|
|
278
|
+
bottom: 10px;
|
|
279
|
+
width: 180px;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
._time {
|
|
283
|
+
font-size: 15px;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
</style>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview audio 插件
|
|
3
|
+
*/
|
|
4
|
+
import context from './context';
|
|
5
|
+
let index = 0;
|
|
6
|
+
|
|
7
|
+
function Audio(vm) {
|
|
8
|
+
this.vm = vm;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
Audio.prototype.onUpdate = function () {
|
|
12
|
+
this.audios = [];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
Audio.prototype.onParse = function (node) {
|
|
16
|
+
if (node.name === 'audio') {
|
|
17
|
+
if (!node.attrs.id) {
|
|
18
|
+
node.attrs.id = 'a' + index++;
|
|
19
|
+
}
|
|
20
|
+
this.audios.push(node.attrs.id);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
Audio.prototype.onLoad = function () {
|
|
25
|
+
setTimeout(() => {
|
|
26
|
+
for (let i = 0; i < this.audios.length; i++) {
|
|
27
|
+
const ctx = context.get(this.audios[i]);
|
|
28
|
+
ctx.id = this.audios[i];
|
|
29
|
+
this.vm._videos.push(ctx);
|
|
30
|
+
}
|
|
31
|
+
}, 500);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default Audio;
|