@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,256 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
import type { ImageMode, StyleValue } from '../../types/global';
|
|
3
|
+
|
|
4
|
+
/** 可选择的文件类别。 */
|
|
5
|
+
export type UploadAcceptType = 'image' | 'video' | 'file' | 'media' | 'all';
|
|
6
|
+
/** 标准化后的文件类别。 */
|
|
7
|
+
export type UploadFileType = 'image' | 'video' | 'file';
|
|
8
|
+
/** 文件在上传队列中的状态。 */
|
|
9
|
+
export type UploadStatus = 'ready' | 'uploading' | 'success' | 'failed';
|
|
10
|
+
|
|
11
|
+
/** Snake Upload 使用的文件记录。 */
|
|
12
|
+
export interface UploadFileItem extends Record<string, unknown> {
|
|
13
|
+
/** 预览或上传完成后的 URL。 */
|
|
14
|
+
url?: string;
|
|
15
|
+
/** 本地临时文件路径。 */
|
|
16
|
+
path?: string;
|
|
17
|
+
/** 文件名。 */
|
|
18
|
+
name?: string;
|
|
19
|
+
/** 文件字节数。 */
|
|
20
|
+
size?: number;
|
|
21
|
+
/** 标准化文件类别。 */
|
|
22
|
+
fileType?: UploadFileType;
|
|
23
|
+
/** 队列状态。 */
|
|
24
|
+
status?: UploadStatus;
|
|
25
|
+
/** 0 到 100 的上传进度。 */
|
|
26
|
+
progress?: number;
|
|
27
|
+
/** 是否上传失败。 */
|
|
28
|
+
error?: boolean;
|
|
29
|
+
/** 状态或错误提示。 */
|
|
30
|
+
message?: string;
|
|
31
|
+
/** 上传服务返回值。 */
|
|
32
|
+
response?: unknown;
|
|
33
|
+
/** 文件选择器返回的原始文件。 */
|
|
34
|
+
file?: unknown;
|
|
35
|
+
/** 视频等文件的缩略图。 */
|
|
36
|
+
thumb?: string;
|
|
37
|
+
/** 默认上传模式创建的 uni-app 上传任务。 */
|
|
38
|
+
uploadTask?: UniApp.UploadTask;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** 自定义上传适配器的运行上下文。 */
|
|
42
|
+
export interface UploadRequestContext {
|
|
43
|
+
/** 当前文件索引。 */
|
|
44
|
+
index: number;
|
|
45
|
+
/** 当前文件列表快照。 */
|
|
46
|
+
files: readonly UploadFileItem[];
|
|
47
|
+
/** 表单文件字段名。 */
|
|
48
|
+
name: string;
|
|
49
|
+
/** 备用上传地址。 */
|
|
50
|
+
action: string;
|
|
51
|
+
/** 调用方配置的请求头。 */
|
|
52
|
+
header: Record<string, unknown>;
|
|
53
|
+
/** 调用方配置的附加表单数据。 */
|
|
54
|
+
formData: Record<string, unknown>;
|
|
55
|
+
/** 向组件报告上传进度。 */
|
|
56
|
+
onProgress: (percent: number) => void;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** 自定义上传适配器的标准成功结果。 */
|
|
60
|
+
export interface UploadRequestResult extends Record<string, unknown> {
|
|
61
|
+
/** 上传完成后的公开访问地址。 */
|
|
62
|
+
url: string;
|
|
63
|
+
/** OSS 或业务接口的原始响应。 */
|
|
64
|
+
response?: unknown;
|
|
65
|
+
/** 可选的新文件名。 */
|
|
66
|
+
name?: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** 自定义上传函数,可用于 OSS、腾讯云、七牛或业务上传接口。 */
|
|
70
|
+
export type UploadRequest = (file: UploadFileItem, context: UploadRequestContext) => Promise<UploadRequestResult | string>;
|
|
71
|
+
|
|
72
|
+
/** Upload 回调中用于区分组件实例的索引。 */
|
|
73
|
+
export type UploadIndex = string | number;
|
|
74
|
+
|
|
75
|
+
/** Upload 选择、超限和预览等事件的统一载荷。 */
|
|
76
|
+
export interface UploadFileEvent {
|
|
77
|
+
/** 关联的文件。 */
|
|
78
|
+
file: UploadFileItem | UploadFileItem[];
|
|
79
|
+
/** 上传字段名称。 */
|
|
80
|
+
name: string;
|
|
81
|
+
/** 文件在列表中的起始位置。 */
|
|
82
|
+
index: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Upload 自定义选取事件的载荷。 */
|
|
86
|
+
export interface UploadChooseEvent {
|
|
87
|
+
/** 当前允许的文件类型。 */
|
|
88
|
+
accept: UploadAcceptType;
|
|
89
|
+
/** 本次还能选择的文件数。 */
|
|
90
|
+
maxCount: number | string;
|
|
91
|
+
/** 当前文件列表快照。 */
|
|
92
|
+
fileList: UploadFileItem[];
|
|
93
|
+
/** 调用方传入的组件索引。 */
|
|
94
|
+
index: UploadIndex;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Upload 旧版 customUpload 事件的载荷。 */
|
|
98
|
+
export interface UploadLegacyCustomEvent {
|
|
99
|
+
/** 当前允许的文件类型。 */
|
|
100
|
+
accept: UploadAcceptType;
|
|
101
|
+
/** 是否允许多选。 */
|
|
102
|
+
multiple: boolean;
|
|
103
|
+
/** 可用的文件来源。 */
|
|
104
|
+
capture: Array<'album' | 'camera'>;
|
|
105
|
+
/** 是否压缩视频。 */
|
|
106
|
+
compressed: boolean;
|
|
107
|
+
/** 视频最长时长。 */
|
|
108
|
+
maxDuration: number;
|
|
109
|
+
/** 图像尺寸策略。 */
|
|
110
|
+
sizeType: Array<'original' | 'compressed'>;
|
|
111
|
+
/** 视频摄像头方向。 */
|
|
112
|
+
camera: 'front' | 'back';
|
|
113
|
+
/** 本次还能选择的文件数。 */
|
|
114
|
+
maxCount: number;
|
|
115
|
+
/** 调用默认文件选择器。 */
|
|
116
|
+
chooseFile: (options?: Record<string, unknown>) => Promise<unknown[]>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Upload 组件的事件契约。 */
|
|
120
|
+
export type UploadEmits = {
|
|
121
|
+
/** 双向绑定文件列表。 */
|
|
122
|
+
'update:modelValue': [files: UploadFileItem[]];
|
|
123
|
+
/** 文件列表变化。 */
|
|
124
|
+
'on-list-change': [files: UploadFileItem[], index: UploadIndex];
|
|
125
|
+
/** 文件超出单文件大小限制。 */
|
|
126
|
+
'on-oversize': [file: UploadFileItem, files: UploadFileItem[], index: UploadIndex];
|
|
127
|
+
/** 文件超出数量限制。 */
|
|
128
|
+
'on-exceed': [file: UploadFileItem, files: UploadFileItem[], index: UploadIndex];
|
|
129
|
+
/** 请求调用方自行选择文件。 */
|
|
130
|
+
'on-choose': [detail: UploadChooseEvent];
|
|
131
|
+
/** 文件选择完成。 */
|
|
132
|
+
'on-choose-complete': [files: UploadFileItem[], index: UploadIndex];
|
|
133
|
+
/** 文件选择失败。 */
|
|
134
|
+
'on-choose-fail': [error: unknown];
|
|
135
|
+
/** 全部文件上传完成。 */
|
|
136
|
+
'on-uploaded': [files: UploadFileItem[], index: UploadIndex];
|
|
137
|
+
/** 单文件上传成功。 */
|
|
138
|
+
'on-success': [response: unknown, index: number, files: UploadFileItem[], componentIndex: UploadIndex];
|
|
139
|
+
/** 单文件上传失败。 */
|
|
140
|
+
'on-error': [error: unknown, index: number, files: UploadFileItem[], componentIndex: UploadIndex];
|
|
141
|
+
/** 单文件上传状态变化。 */
|
|
142
|
+
'on-change': [result: unknown, index: number, files: UploadFileItem[], componentIndex: UploadIndex];
|
|
143
|
+
/** 上传进度变化。 */
|
|
144
|
+
'on-progress': [progress: unknown, index: number, files: UploadFileItem[], componentIndex: UploadIndex];
|
|
145
|
+
/** 文件移除完成。 */
|
|
146
|
+
'on-remove': [index: number, files: UploadFileItem[], componentIndex: UploadIndex];
|
|
147
|
+
/** 文件预览。 */
|
|
148
|
+
'on-preview': [url: string | undefined, files: UploadFileItem[], componentIndex: UploadIndex];
|
|
149
|
+
/** 兼容旧版自定义上传。 */
|
|
150
|
+
customUpload: [detail: UploadLegacyCustomEvent];
|
|
151
|
+
/** 开始选择文件。 */
|
|
152
|
+
chooseStart: [];
|
|
153
|
+
/** 选择文件结束。 */
|
|
154
|
+
chooseComplete: [];
|
|
155
|
+
/** 兼容旧版错误事件。 */
|
|
156
|
+
error: [error: unknown];
|
|
157
|
+
/** 文件进入读取流程前。 */
|
|
158
|
+
beforeRead: [detail: UploadFileEvent];
|
|
159
|
+
/** 文件进入读取流程后。 */
|
|
160
|
+
afterRead: [detail: UploadFileEvent];
|
|
161
|
+
/** 兼容旧版超限事件。 */
|
|
162
|
+
oversize: [detail: UploadFileEvent];
|
|
163
|
+
/** 兼容旧版删除事件。 */
|
|
164
|
+
delete: [detail: UploadFileItem & { name: string; index: number }];
|
|
165
|
+
/** 兼容旧版预览事件。 */
|
|
166
|
+
clickPreview: [detail: UploadFileItem & { name: string; index: number }];
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/** Snake Upload 的运行时 props 定义。 */
|
|
170
|
+
export const uploadProps = {
|
|
171
|
+
customStyle: { type: [String, Object] as PropType<StyleValue>, default: '' },
|
|
172
|
+
customClass: { type: String, default: '' },
|
|
173
|
+
width: { type: [Number, String], default: 200 },
|
|
174
|
+
height: { type: [Number, String], default: 200 },
|
|
175
|
+
maxCount: { type: [Number, String], default: 52 },
|
|
176
|
+
deletable: { type: Boolean, default: true },
|
|
177
|
+
mode: { type: String as PropType<'grid' | 'list'>, default: 'grid' },
|
|
178
|
+
showUploadList: { type: Boolean, default: true },
|
|
179
|
+
showProgress: { type: Boolean, default: true },
|
|
180
|
+
delBgColor: { type: String, default: 'var(--snake-color-error, #fa3534)' },
|
|
181
|
+
delIcon: { type: String, default: 'close' },
|
|
182
|
+
delColor: { type: String, default: '#fff' },
|
|
183
|
+
imageMode: { type: String as PropType<ImageMode>, default: 'aspectFill' },
|
|
184
|
+
customBtn: { type: Boolean, default: false },
|
|
185
|
+
uploadText: { type: String, default: '' },
|
|
186
|
+
action: { type: String, default: '' },
|
|
187
|
+
timeout: { type: Number, default: 60_000 },
|
|
188
|
+
disabled: { type: Boolean, default: false },
|
|
189
|
+
index: { type: [String, Number], default: '' },
|
|
190
|
+
header: { type: Object as PropType<Record<string, unknown>>, default: () => ({}) },
|
|
191
|
+
formData: { type: Object as PropType<Record<string, unknown>>, default: () => ({}) },
|
|
192
|
+
name: { type: String, default: 'file' },
|
|
193
|
+
sizeType: { type: Array as PropType<Array<'original' | 'compressed'>>, default: () => ['original', 'compressed'] },
|
|
194
|
+
sourceType: { type: Array as PropType<Array<'album' | 'camera'>>, default: () => ['album', 'camera'] },
|
|
195
|
+
previewFullImage: { type: Boolean, default: true },
|
|
196
|
+
previewFile: { type: Boolean, default: true },
|
|
197
|
+
multiple: { type: Boolean, default: true },
|
|
198
|
+
maxSize: { type: [Number, String], default: Number.MAX_VALUE },
|
|
199
|
+
modelValue: { type: Array as PropType<UploadFileItem[]>, default: () => [] },
|
|
200
|
+
fileList: { type: Array as PropType<UploadFileItem[]>, default: () => [] },
|
|
201
|
+
limitType: { type: Array as PropType<string[]>, default: () => [] },
|
|
202
|
+
autoUpload: { type: Boolean, default: true },
|
|
203
|
+
showTips: { type: Boolean, default: true },
|
|
204
|
+
showConfirm: { type: Boolean, default: true },
|
|
205
|
+
beforeUpload: {
|
|
206
|
+
type: Function as PropType<(index: number, files: UploadFileItem[]) => boolean | Promise<unknown>>,
|
|
207
|
+
default: undefined
|
|
208
|
+
},
|
|
209
|
+
beforeRemove: {
|
|
210
|
+
type: Function as PropType<(index: number, files: UploadFileItem[]) => boolean | Promise<unknown>>,
|
|
211
|
+
default: undefined
|
|
212
|
+
},
|
|
213
|
+
toJson: { type: Boolean, default: true },
|
|
214
|
+
accept: { type: String as PropType<UploadAcceptType>, default: 'image' },
|
|
215
|
+
showFileName: { type: Boolean, default: true },
|
|
216
|
+
showFileSize: { type: Boolean, default: false },
|
|
217
|
+
fileIconMap: {
|
|
218
|
+
type: Object as PropType<Record<string, { name: string; color?: string }>>,
|
|
219
|
+
default: () => ({})
|
|
220
|
+
},
|
|
221
|
+
compressed: { type: Boolean, default: true },
|
|
222
|
+
maxDuration: { type: Number, default: 60 },
|
|
223
|
+
camera: { type: String as PropType<'front' | 'back'>, default: 'back' },
|
|
224
|
+
extension: { type: Array as PropType<string[]>, default: () => [] },
|
|
225
|
+
imageShape: { type: String as PropType<'square' | 'circle'>, default: 'square' },
|
|
226
|
+
customChoose: { type: Boolean, default: false },
|
|
227
|
+
uploadRequest: { type: Function as PropType<UploadRequest>, default: undefined },
|
|
228
|
+
isCustomUpload: { type: Boolean, default: false }
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
/** Snake Upload 的公开属性类型。 */
|
|
232
|
+
export type UploadProps = ExtractPropTypes<typeof uploadProps>;
|
|
233
|
+
|
|
234
|
+
/** 通过组件 ref 可调用的方法。 */
|
|
235
|
+
export interface UploadExpose {
|
|
236
|
+
/** 当前内部文件列表。 */
|
|
237
|
+
lists: UploadFileItem[];
|
|
238
|
+
/** 清空文件列表。 */
|
|
239
|
+
clear: () => void;
|
|
240
|
+
/** 上传所有待上传文件。 */
|
|
241
|
+
upload: () => void;
|
|
242
|
+
/** 重传全部失败文件或指定文件。 */
|
|
243
|
+
reUpload: (index?: number) => void;
|
|
244
|
+
/** 重试指定文件。 */
|
|
245
|
+
retry: (index: number) => void;
|
|
246
|
+
/** 直接移除指定文件。 */
|
|
247
|
+
remove: (index: number) => void;
|
|
248
|
+
/** 按组件交互规则删除指定文件。 */
|
|
249
|
+
deleteItem: (index: number) => void;
|
|
250
|
+
/** 打开文件选择器。 */
|
|
251
|
+
selectFile: () => void;
|
|
252
|
+
/** 将外部选择的文件加入上传队列。 */
|
|
253
|
+
addFiles: (files: UploadFileItem[]) => void;
|
|
254
|
+
/** 兼容旧组件,将文件交给 beforeRead/afterRead 流程。 */
|
|
255
|
+
onBeforeRead: (file: UploadFileItem | UploadFileItem[]) => void;
|
|
256
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view>
|
|
3
|
+
<view
|
|
4
|
+
v-if="videoSrc"
|
|
5
|
+
class="snake-videos__cover"
|
|
6
|
+
role="button"
|
|
7
|
+
tabindex="0"
|
|
8
|
+
aria-label="播放视频"
|
|
9
|
+
@click="open"
|
|
10
|
+
@keydown.enter.prevent="open"
|
|
11
|
+
@keydown.space.prevent="open"
|
|
12
|
+
>
|
|
13
|
+
<snake-image :src="coverSrc" alt="视频封面" width="100%" mode="widthFix"></snake-image>
|
|
14
|
+
<view
|
|
15
|
+
style="
|
|
16
|
+
position: absolute;
|
|
17
|
+
top: 50%;
|
|
18
|
+
left: 50%;
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
width: 100%;
|
|
23
|
+
height: 100%;
|
|
24
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
25
|
+
transform: translate(-50%, -50%);
|
|
26
|
+
"
|
|
27
|
+
>
|
|
28
|
+
<snake-icon name="play-right-fill" size="70rpx" color="#fff"></snake-icon>
|
|
29
|
+
</view>
|
|
30
|
+
</view>
|
|
31
|
+
<view v-else class="snake-videos__empty">{{ datas.emptyText || '暂无视频' }}</view>
|
|
32
|
+
|
|
33
|
+
<!-- <video
|
|
34
|
+
class="videos"
|
|
35
|
+
:src="datas.src"
|
|
36
|
+
object-fit="fill"
|
|
37
|
+
style="width: 100%"
|
|
38
|
+
@click.stop=""
|
|
39
|
+
:poster="datas.src + '?x-oss-process=video/snapshot,t_0,f_jpg'"></video> -->
|
|
40
|
+
|
|
41
|
+
<snake-popup v-if="videoSrc" v-model="show" mode="center" @close="show = false">
|
|
42
|
+
<view class="snake-videos__player" v-if="show" @click.stop="close">
|
|
43
|
+
<view
|
|
44
|
+
class="snake-videos__close"
|
|
45
|
+
role="button"
|
|
46
|
+
tabindex="0"
|
|
47
|
+
aria-label="关闭视频"
|
|
48
|
+
@keydown.enter.prevent="close"
|
|
49
|
+
@keydown.space.prevent="close"
|
|
50
|
+
>
|
|
51
|
+
<snake-icon name="close" color="#909399" size="30rpx" bold></snake-icon>
|
|
52
|
+
</view>
|
|
53
|
+
<video
|
|
54
|
+
class="videos"
|
|
55
|
+
:src="videoSrc"
|
|
56
|
+
object-fit="fill"
|
|
57
|
+
style="width: 100%"
|
|
58
|
+
@click.stop=""
|
|
59
|
+
:poster="coverSrc"
|
|
60
|
+
></video>
|
|
61
|
+
</view>
|
|
62
|
+
</snake-popup>
|
|
63
|
+
</view>
|
|
64
|
+
</template>
|
|
65
|
+
|
|
66
|
+
<script setup lang="ts">
|
|
67
|
+
/**
|
|
68
|
+
* @component Videos
|
|
69
|
+
* @description 显示视频首帧封面,点击后在全屏弹层中播放视频。
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
import { computed, ref } from 'vue';
|
|
73
|
+
import type { VideosProps } from './types';
|
|
74
|
+
|
|
75
|
+
defineOptions({ name: 'Videos', options: { virtualHost: true, styleIsolation: 'shared' } });
|
|
76
|
+
const props = withDefaults(defineProps<VideosProps>(), { datas: () => ({}), scrollTop: 0 });
|
|
77
|
+
const show = ref(false);
|
|
78
|
+
const videoSrc = computed(() => String(props.datas.src || ''));
|
|
79
|
+
const coverSrc = computed(() => props.datas.poster || `${videoSrc.value}?x-oss-process=video/snapshot,t_0,f_jpg`);
|
|
80
|
+
function open() {
|
|
81
|
+
if (!videoSrc.value) return;
|
|
82
|
+
show.value = true;
|
|
83
|
+
}
|
|
84
|
+
function close() {
|
|
85
|
+
show.value = false;
|
|
86
|
+
}
|
|
87
|
+
</script>
|
|
88
|
+
|
|
89
|
+
<style lang="scss" scoped>
|
|
90
|
+
.videos {
|
|
91
|
+
width: 100%;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.snake-videos__cover {
|
|
95
|
+
position: relative;
|
|
96
|
+
width: 100%;
|
|
97
|
+
height: 100%;
|
|
98
|
+
}
|
|
99
|
+
.snake-videos__empty {
|
|
100
|
+
display: flex;
|
|
101
|
+
min-height: 240rpx;
|
|
102
|
+
align-items: center;
|
|
103
|
+
justify-content: center;
|
|
104
|
+
color: var(--snake-color-text-secondary, #909399);
|
|
105
|
+
background: var(--snake-color-bg, #f7f8fa);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.snake-videos__player {
|
|
109
|
+
position: relative;
|
|
110
|
+
width: 100vw;
|
|
111
|
+
height: 100vh;
|
|
112
|
+
display: flex;
|
|
113
|
+
align-items: center;
|
|
114
|
+
background-color: #000;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.snake-videos__close {
|
|
118
|
+
position: absolute;
|
|
119
|
+
top: 60rpx;
|
|
120
|
+
right: 50rpx;
|
|
121
|
+
}
|
|
122
|
+
</style>
|