@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,99 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view>
|
|
3
|
+
<view class="jumpApplet" v-if="datas.isButton">
|
|
4
|
+
<button
|
|
5
|
+
class="jumpAppletBtn"
|
|
6
|
+
:style="{ color: datas.textColor, backgroundColor: datas.btnColor }"
|
|
7
|
+
@click="jump"
|
|
8
|
+
>
|
|
9
|
+
{{ datas.title }}
|
|
10
|
+
</button>
|
|
11
|
+
</view>
|
|
12
|
+
<image v-else :src="datas.imageUrl" mode="widthFix" @click="jump"></image>
|
|
13
|
+
</view>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup lang="ts">
|
|
17
|
+
/**
|
|
18
|
+
* @component JumpApplet
|
|
19
|
+
* @description 通过按钮或图片触发小程序、H5 URL Scheme 或企业微信承接页跳转。
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { computed, onMounted } from 'vue';
|
|
23
|
+
import { resolveCmsOptions } from '../../libs/cms';
|
|
24
|
+
import { toast } from '../../libs/function/toast';
|
|
25
|
+
import { CmsError, type CmsLinkAction } from '../snake-cms/types';
|
|
26
|
+
import type { JumpAppletEmits, JumpAppletProps } from './types';
|
|
27
|
+
|
|
28
|
+
defineOptions({ name: 'JumpApplet', options: { virtualHost: true, styleIsolation: 'shared' } });
|
|
29
|
+
|
|
30
|
+
const props = withDefaults(defineProps<JumpAppletProps>(), {
|
|
31
|
+
datas: () => ({}),
|
|
32
|
+
linkService: undefined,
|
|
33
|
+
pageInfo: () => ({})
|
|
34
|
+
});
|
|
35
|
+
const emit = defineEmits<JumpAppletEmits>();
|
|
36
|
+
const service = computed(() => props.linkService || resolveCmsOptions().services?.link);
|
|
37
|
+
|
|
38
|
+
async function jump(): Promise<void> {
|
|
39
|
+
if (!props.datas.path) {
|
|
40
|
+
toast('缺少跳转页面路径');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (!props.datas.isWeCom && !props.datas.appId) {
|
|
44
|
+
toast('缺少 appId');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!service.value) {
|
|
48
|
+
const error = new CmsError('link', '未配置 CMS 跳转服务');
|
|
49
|
+
emit('error', error);
|
|
50
|
+
toast(error.message);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
let action: CmsLinkAction;
|
|
54
|
+
if (props.datas.isWeCom) {
|
|
55
|
+
action = { type: 'external', url: props.datas.path };
|
|
56
|
+
} else {
|
|
57
|
+
action = {
|
|
58
|
+
type: 'mini-program',
|
|
59
|
+
appId: props.datas.appId,
|
|
60
|
+
path: `${props.datas.path}${props.datas.query || ''}`,
|
|
61
|
+
extraData: props.datas.extraData || {},
|
|
62
|
+
envVersion: props.datas.envVersion
|
|
63
|
+
};
|
|
64
|
+
// #ifdef H5
|
|
65
|
+
action = {
|
|
66
|
+
type: 'scheme',
|
|
67
|
+
appId: props.datas.appId,
|
|
68
|
+
path: props.datas.path,
|
|
69
|
+
query: props.datas.query
|
|
70
|
+
};
|
|
71
|
+
// #endif
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
await service.value.open(action, { pageInfo: props.pageInfo });
|
|
75
|
+
} catch (cause) {
|
|
76
|
+
const error = new CmsError('link', '页面跳转失败', cause);
|
|
77
|
+
emit('error', error);
|
|
78
|
+
toast(error.message);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
onMounted(() => {
|
|
83
|
+
if (props.datas.isAuto) void jump();
|
|
84
|
+
});
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
<style lang="scss" scoped>
|
|
88
|
+
.jumpApplet {
|
|
89
|
+
margin: 10rpx 40rpx;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.jumpAppletBtn {
|
|
93
|
+
cursor: pointer;
|
|
94
|
+
|
|
95
|
+
&::after {
|
|
96
|
+
border: none;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CmsError, CmsLinkService, CmsPageInfo } from '../snake-cms/types';
|
|
2
|
+
|
|
3
|
+
/** JumpApplet 组件的公开属性。 */
|
|
4
|
+
export interface JumpAppletProps<Data extends Record<string, any> = Record<string, any>> {
|
|
5
|
+
/** CMS 装修组件配置数据。 */
|
|
6
|
+
datas?: Data;
|
|
7
|
+
/** link service 配置。 */
|
|
8
|
+
linkService?: CmsLinkService;
|
|
9
|
+
/** CMS 页面上下文信息。 */
|
|
10
|
+
pageInfo?: CmsPageInfo;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** JumpApplet 组件的事件契约。 */
|
|
14
|
+
export type JumpAppletEmits = {
|
|
15
|
+
/** error 事件携带的参数。 */
|
|
16
|
+
error: [error: CmsError];
|
|
17
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="snake-line" :class="customClass" :style="[lineStyle, customStyle]" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
/**
|
|
7
|
+
* @component Line
|
|
8
|
+
* @description 分隔线条,支持横向与竖向两种方向、半像素细线以及虚线样式,常用于分隔内容块。
|
|
9
|
+
* @see /components/line
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { computed } from 'vue';
|
|
13
|
+
import { addUnit } from '../../libs/function/unit';
|
|
14
|
+
import { lineProps } from './types';
|
|
15
|
+
|
|
16
|
+
defineOptions({ name: 'SnakeLine', options: { virtualHost: true, styleIsolation: 'shared' } });
|
|
17
|
+
const props = defineProps(lineProps);
|
|
18
|
+
|
|
19
|
+
/** 线条样式,以 1px 边框加缩放实现跨端一致的半像素细线。 */
|
|
20
|
+
const lineStyle = computed(() => {
|
|
21
|
+
const style: Record<string, string> = { margin: props.margin };
|
|
22
|
+
if (props.direction === 'row') {
|
|
23
|
+
style.borderBottomWidth = '1px';
|
|
24
|
+
style.borderBottomStyle = props.borderStyle;
|
|
25
|
+
style.width = addUnit(props.length);
|
|
26
|
+
if (props.hairLine) style.transform = 'scaleY(0.5)';
|
|
27
|
+
} else {
|
|
28
|
+
style.borderLeftWidth = '1px';
|
|
29
|
+
style.borderLeftStyle = props.borderStyle;
|
|
30
|
+
style.height = addUnit(props.length);
|
|
31
|
+
if (props.hairLine) style.transform = 'scaleX(0.5)';
|
|
32
|
+
}
|
|
33
|
+
style.borderColor = props.color;
|
|
34
|
+
return style;
|
|
35
|
+
});
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<style scoped>
|
|
39
|
+
.snake-line {
|
|
40
|
+
vertical-align: middle;
|
|
41
|
+
}
|
|
42
|
+
</style>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
import type { StyleValue } from '../../types/global';
|
|
3
|
+
|
|
4
|
+
/** LineDirection 类型定义。 */
|
|
5
|
+
export type LineDirection = 'row' | 'col';
|
|
6
|
+
/** LineBorderStyle 类型定义。 */
|
|
7
|
+
export type LineBorderStyle = 'solid' | 'dashed' | 'dotted';
|
|
8
|
+
|
|
9
|
+
/** lineProps 运行时属性及默认值。 */
|
|
10
|
+
export const lineProps = {
|
|
11
|
+
/** 线条颜色。 */
|
|
12
|
+
color: { type: String, default: 'var(--snake-color-border, #e4e7ed)' },
|
|
13
|
+
/** 长度,竖向表现为高度,横向表现为长度,可为百分比或带 rpx 单位的值。 */
|
|
14
|
+
length: { type: String, default: '100%' },
|
|
15
|
+
/** 线条方向,row 横向,col 竖向。 */
|
|
16
|
+
direction: { type: String as PropType<LineDirection>, default: 'row' },
|
|
17
|
+
/** 是否显示半像素细线条。 */
|
|
18
|
+
hairLine: { type: Boolean, default: true },
|
|
19
|
+
/** 线条与上下左右元素的间距,字符串形式,如 "30rpx"、"20rpx 30rpx"。 */
|
|
20
|
+
margin: { type: String, default: '0' },
|
|
21
|
+
/** 线条类型,solid 实线,dashed 方形虚线,dotted 圆点虚线。 */
|
|
22
|
+
borderStyle: { type: String as PropType<LineBorderStyle>, default: 'solid' },
|
|
23
|
+
/** 根节点自定义类名。 */
|
|
24
|
+
customClass: { type: String, default: '' },
|
|
25
|
+
/** 根节点自定义样式。 */
|
|
26
|
+
customStyle: { type: [String, Object, Array] as PropType<StyleValue>, default: '' }
|
|
27
|
+
} as const;
|
|
28
|
+
|
|
29
|
+
/** Line 组件的公开属性。 */
|
|
30
|
+
export type LineProps = ExtractPropTypes<typeof lineProps>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="snake-line-progress"
|
|
4
|
+
:style="{ borderRadius: round ? '100rpx' : '0', height: `${height}rpx`, backgroundColor: inactiveColor }"
|
|
5
|
+
>
|
|
6
|
+
<view
|
|
7
|
+
:class="[
|
|
8
|
+
type ? `snake-line-progress__active--${type}` : '',
|
|
9
|
+
striped ? 'snake-line-progress__active--striped' : '',
|
|
10
|
+
striped && stripedActive ? 'snake-line-progress__active--striped-active' : ''
|
|
11
|
+
]"
|
|
12
|
+
class="snake-line-progress__active"
|
|
13
|
+
:style="progressStyle"
|
|
14
|
+
>
|
|
15
|
+
<slot v-if="slots.default" />
|
|
16
|
+
<text class="snake-line-progress__percent" v-else-if="showPercent">{{ percent }}%</text>
|
|
17
|
+
</view>
|
|
18
|
+
</view>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script setup lang="ts">
|
|
22
|
+
/**
|
|
23
|
+
* @component LineProgress
|
|
24
|
+
* @description 线形进度条,用于展示操作或任务的当前进度,支持主题色预设、条纹与百分比展示。
|
|
25
|
+
* @see /components/line-progress
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { computed, useSlots } from 'vue';
|
|
29
|
+
import { lineProgressProps } from './types';
|
|
30
|
+
|
|
31
|
+
defineOptions({ name: 'LineProgress', options: { virtualHost: true, styleIsolation: 'shared' } });
|
|
32
|
+
const props = defineProps(lineProgressProps);
|
|
33
|
+
const slots = useSlots();
|
|
34
|
+
|
|
35
|
+
/** 激活部分的宽度与颜色,主题预设优先于 activeColor。 */
|
|
36
|
+
const progressStyle = computed(() => {
|
|
37
|
+
const style: Record<string, string> = {};
|
|
38
|
+
style.width = `${props.percent}%`;
|
|
39
|
+
if (!props.type && props.activeColor) style.backgroundColor = props.activeColor;
|
|
40
|
+
return style;
|
|
41
|
+
});
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<style scoped>
|
|
45
|
+
.snake-line-progress {
|
|
46
|
+
display: inline-flex;
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
align-items: center;
|
|
49
|
+
width: 100%;
|
|
50
|
+
border-radius: 100rpx;
|
|
51
|
+
}
|
|
52
|
+
.snake-line-progress__active {
|
|
53
|
+
display: flex;
|
|
54
|
+
width: 0;
|
|
55
|
+
height: 100%;
|
|
56
|
+
align-items: center;
|
|
57
|
+
justify-content: space-around;
|
|
58
|
+
font-size: 20rpx;
|
|
59
|
+
color: var(--snake-color-white, #fff);
|
|
60
|
+
transition: all 0.4s ease;
|
|
61
|
+
}
|
|
62
|
+
.snake-line-progress__active--primary {
|
|
63
|
+
background-color: var(--snake-color-primary, #06d290);
|
|
64
|
+
}
|
|
65
|
+
.snake-line-progress__active--success {
|
|
66
|
+
background-color: var(--snake-color-success, #19be6b);
|
|
67
|
+
}
|
|
68
|
+
.snake-line-progress__active--warning {
|
|
69
|
+
background-color: var(--snake-color-warning, #ff9900);
|
|
70
|
+
}
|
|
71
|
+
.snake-line-progress__active--error {
|
|
72
|
+
background-color: var(--snake-color-error, #fa3534);
|
|
73
|
+
}
|
|
74
|
+
.snake-line-progress__active--info {
|
|
75
|
+
background-color: var(--snake-color-info, #909399);
|
|
76
|
+
}
|
|
77
|
+
.snake-line-progress__active--striped {
|
|
78
|
+
background-image: linear-gradient(
|
|
79
|
+
45deg,
|
|
80
|
+
rgba(255, 255, 255, 0.15) 25%,
|
|
81
|
+
transparent 25%,
|
|
82
|
+
transparent 50%,
|
|
83
|
+
rgba(255, 255, 255, 0.15) 50%,
|
|
84
|
+
rgba(255, 255, 255, 0.15) 75%,
|
|
85
|
+
transparent 75%,
|
|
86
|
+
transparent
|
|
87
|
+
);
|
|
88
|
+
background-size: 39px 39px;
|
|
89
|
+
}
|
|
90
|
+
.snake-line-progress__active--striped-active {
|
|
91
|
+
animation: snake-line-progress-stripes 2s linear infinite;
|
|
92
|
+
}
|
|
93
|
+
.snake-line-progress__percent {
|
|
94
|
+
padding: 0 10rpx;
|
|
95
|
+
color: var(--snake-color-text-light, #c0c4cc);
|
|
96
|
+
}
|
|
97
|
+
@keyframes snake-line-progress-stripes {
|
|
98
|
+
0% {
|
|
99
|
+
background-position: 0 0;
|
|
100
|
+
}
|
|
101
|
+
100% {
|
|
102
|
+
background-position: 39px 0;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
</style>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
|
|
3
|
+
/** lineProgressProps 运行时属性及默认值。 */
|
|
4
|
+
export const lineProgressProps = {
|
|
5
|
+
/** 进度条两端是否显示半圆形。 */
|
|
6
|
+
round: { type: Boolean, default: true },
|
|
7
|
+
/** 主题颜色,如设置则 activeColor 失效,可选 primary/success/warning/error/info。 */
|
|
8
|
+
type: { type: String, default: '' },
|
|
9
|
+
/** 激活部分的颜色。 */
|
|
10
|
+
activeColor: { type: String, default: 'var(--snake-color-success, #19be6b)' },
|
|
11
|
+
/** 进度条的底色。 */
|
|
12
|
+
inactiveColor: { type: String, default: 'var(--snake-color-divider, #e4e7ed)' },
|
|
13
|
+
/** 进度百分比,数值 0-100。 */
|
|
14
|
+
percent: { type: [Number, String] as PropType<number | string>, default: 0 },
|
|
15
|
+
/** 是否在进度条内部显示百分比的值。 */
|
|
16
|
+
showPercent: { type: Boolean, default: true },
|
|
17
|
+
/** 进度条的高度,数值按 rpx 处理。 */
|
|
18
|
+
height: { type: [Number, String] as PropType<number | string>, default: 28 },
|
|
19
|
+
/** 是否显示激活部分的条纹。 */
|
|
20
|
+
striped: { type: Boolean, default: false },
|
|
21
|
+
/** 条纹是否具有动态效果。 */
|
|
22
|
+
stripedActive: { type: Boolean, default: false }
|
|
23
|
+
} as const;
|
|
24
|
+
|
|
25
|
+
/** LineProgress 组件的公开属性。 */
|
|
26
|
+
export type LineProgressProps = ExtractPropTypes<typeof lineProgressProps>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<text
|
|
3
|
+
class="snake-link"
|
|
4
|
+
:style="{
|
|
5
|
+
color: color,
|
|
6
|
+
fontSize: `${fontSize}rpx`,
|
|
7
|
+
borderBottom: underLine ? `1px solid ${lineColor || color}` : 'none',
|
|
8
|
+
paddingBottom: underLine ? '0rpx' : '0'
|
|
9
|
+
}"
|
|
10
|
+
@click.stop="openLink"
|
|
11
|
+
>
|
|
12
|
+
<!-- #ifdef MP-TOUTIAO -->
|
|
13
|
+
{{ text }}
|
|
14
|
+
<!-- #endif -->
|
|
15
|
+
<!-- #ifndef MP-TOUTIAO -->
|
|
16
|
+
<slot>{{ text }}</slot>
|
|
17
|
+
<!-- #endif -->
|
|
18
|
+
</text>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script setup lang="ts">
|
|
22
|
+
/**
|
|
23
|
+
* @component Link
|
|
24
|
+
* @description 超链接,不同平台有不同表现形式:App 通过内置浏览器打开,小程序复制链接到粘贴板并提示,H5 使用 window.open。
|
|
25
|
+
* @see /components/link
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { computed } from 'vue';
|
|
29
|
+
import { toast } from '../../libs/function/toast';
|
|
30
|
+
import { useLocale } from '../../libs/hooks/useLocale';
|
|
31
|
+
import { linkProps, type LinkEmits } from './types';
|
|
32
|
+
|
|
33
|
+
defineOptions({ name: 'SnakeLink', options: { virtualHost: true, styleIsolation: 'shared' } });
|
|
34
|
+
const props = defineProps(linkProps);
|
|
35
|
+
const emit = defineEmits<LinkEmits>();
|
|
36
|
+
const { t } = useLocale('link');
|
|
37
|
+
|
|
38
|
+
const mpTipsValue = computed(() => props.mpTips || t('mpTips'));
|
|
39
|
+
|
|
40
|
+
/** 打开链接,不同平台有不同表现形式。 */
|
|
41
|
+
function openLink() {
|
|
42
|
+
if (!props.defaultClick) {
|
|
43
|
+
emit('click', props.href);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// #ifdef APP-PLUS
|
|
47
|
+
if (typeof plus !== 'undefined' && plus.runtime) {
|
|
48
|
+
plus.runtime.openURL(props.href);
|
|
49
|
+
}
|
|
50
|
+
// #endif
|
|
51
|
+
// #ifdef H5
|
|
52
|
+
if (typeof window !== 'undefined') {
|
|
53
|
+
window.open(props.href);
|
|
54
|
+
}
|
|
55
|
+
// #endif
|
|
56
|
+
// #ifdef MP
|
|
57
|
+
if (typeof uni !== 'undefined' && uni.setClipboardData) {
|
|
58
|
+
uni.setClipboardData({
|
|
59
|
+
data: props.href,
|
|
60
|
+
success: () => {
|
|
61
|
+
uni.hideToast();
|
|
62
|
+
toast(mpTipsValue.value);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
// #endif
|
|
67
|
+
}
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<style scoped>
|
|
71
|
+
.snake-link {
|
|
72
|
+
line-height: 1;
|
|
73
|
+
}
|
|
74
|
+
</style>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
|
|
3
|
+
/** linkProps 运行时属性及默认值。 */
|
|
4
|
+
export const linkProps = {
|
|
5
|
+
/** 超链接文字。 */
|
|
6
|
+
text: { type: [String, Number] as PropType<string | number>, default: '' },
|
|
7
|
+
/** 文字颜色。 */
|
|
8
|
+
color: { type: String, default: 'var(--snake-color-primary, #06D290)' },
|
|
9
|
+
/** 字体大小,数值按 rpx 处理。 */
|
|
10
|
+
fontSize: { type: [String, Number] as PropType<string | number>, default: 28 },
|
|
11
|
+
/** 是否显示下划线。 */
|
|
12
|
+
underLine: { type: Boolean, default: false },
|
|
13
|
+
/** 要跳转的链接。 */
|
|
14
|
+
href: { type: String, default: '' },
|
|
15
|
+
/** 小程序中复制到粘贴板后的提示语。 */
|
|
16
|
+
mpTips: { type: String, default: '' },
|
|
17
|
+
/** 下划线颜色,默认同文字颜色。 */
|
|
18
|
+
lineColor: { type: String, default: '' },
|
|
19
|
+
/** 是否默认点击跳转。 */
|
|
20
|
+
defaultClick: { type: Boolean, default: true }
|
|
21
|
+
} as const;
|
|
22
|
+
|
|
23
|
+
/** Link 组件的公开属性。 */
|
|
24
|
+
export type LinkProps = ExtractPropTypes<typeof linkProps>;
|
|
25
|
+
|
|
26
|
+
/** Link 组件的事件契约。 */
|
|
27
|
+
export type LinkEmits = {
|
|
28
|
+
/** defaultClick 为 false 时点击触发,携带链接地址。 */
|
|
29
|
+
click: [href: string];
|
|
30
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="menu-wrap">
|
|
3
|
+
<scroll-view scroll-y scroll-with-animation class="tab-view menu-scroll-view" :scroll-top="scrollTop">
|
|
4
|
+
<view
|
|
5
|
+
v-for="(item, index) in items"
|
|
6
|
+
:key="index"
|
|
7
|
+
class="tab-item"
|
|
8
|
+
:class="[current == index ? 'tab-item-active' : '']"
|
|
9
|
+
:data-current="index"
|
|
10
|
+
@tap.stop="swichMenu(item, index)"
|
|
11
|
+
>
|
|
12
|
+
<text class="tab-item-text">{{ item.text }}</text>
|
|
13
|
+
</view>
|
|
14
|
+
</scroll-view>
|
|
15
|
+
<view class="content">
|
|
16
|
+
<slot name="content"></slot>
|
|
17
|
+
</view>
|
|
18
|
+
</view>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script>
|
|
22
|
+
/**
|
|
23
|
+
* @component TreeSelect
|
|
24
|
+
* @description 列表切换组件内部使用的树形分类选择器,负责节点测量、滚动定位和分类切换。
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
export default {
|
|
28
|
+
name: 'tree-select',
|
|
29
|
+
emits: ['click-nav'],
|
|
30
|
+
props: {
|
|
31
|
+
items: {
|
|
32
|
+
type: Array,
|
|
33
|
+
default() {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
current: {
|
|
38
|
+
type: [Number, String],
|
|
39
|
+
default: 0
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
data() {
|
|
43
|
+
return {
|
|
44
|
+
scrollTop: 0, //tab标题的滚动条位置
|
|
45
|
+
currentIndex: 0,
|
|
46
|
+
menuHeight: 0, // 左边菜单的高度
|
|
47
|
+
menuItemHeight: 0 // 左边菜单item的高度
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
watch: {
|
|
51
|
+
current(val) {
|
|
52
|
+
// 父组件如果重置了current,则重新赋值
|
|
53
|
+
this.currentIndex = val;
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
methods: {
|
|
57
|
+
/** 切换分类并将激活项滚动到左侧菜单中部。 */
|
|
58
|
+
async swichMenu(item, index) {
|
|
59
|
+
// 当前分类不重复触发业务请求。
|
|
60
|
+
if (this.currentIndex === index) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
// 首次交互可能早于节点测量,按需获取真实尺寸。
|
|
64
|
+
if (this.menuHeight == 0 || this.menuItemHeight == 0) {
|
|
65
|
+
await this.getElRect('menu-scroll-view', 'menuHeight');
|
|
66
|
+
await this.getElRect('tab-item', 'menuItemHeight');
|
|
67
|
+
}
|
|
68
|
+
// 让激活项中心与可视区域中心对齐。
|
|
69
|
+
this.scrollTop = index * this.menuItemHeight + this.menuItemHeight / 2 - this.menuHeight / 2;
|
|
70
|
+
this.$emit('click-nav', item, index);
|
|
71
|
+
},
|
|
72
|
+
/**
|
|
73
|
+
* 获取目标节点尺寸;节点尚未挂载时短暂重试。
|
|
74
|
+
* Promise 必须等到成功测量后再完成,调用方才能安全计算滚动位置。
|
|
75
|
+
*/
|
|
76
|
+
getElRect(elClass, dataVal) {
|
|
77
|
+
return new Promise(resolve => {
|
|
78
|
+
const query = uni.createSelectorQuery().in(this);
|
|
79
|
+
query
|
|
80
|
+
.select('.' + elClass)
|
|
81
|
+
.fields(
|
|
82
|
+
{
|
|
83
|
+
size: true
|
|
84
|
+
},
|
|
85
|
+
res => {
|
|
86
|
+
// 条件渲染下节点查询可能暂时为空,延迟到下一轮重试。
|
|
87
|
+
if (!res) {
|
|
88
|
+
setTimeout(() => {
|
|
89
|
+
this.getElRect(elClass, dataVal).then(resolve);
|
|
90
|
+
}, 10);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
this[dataVal] = res.height;
|
|
94
|
+
resolve(res);
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
.exec();
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
<style lang="scss" scoped>
|
|
105
|
+
.menu-wrap {
|
|
106
|
+
display: flex;
|
|
107
|
+
flex: 1;
|
|
108
|
+
height: auto;
|
|
109
|
+
overflow: hidden;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.tab-view {
|
|
113
|
+
width: 140rpx;
|
|
114
|
+
height: 100%;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.tab-item {
|
|
118
|
+
box-sizing: border-box;
|
|
119
|
+
display: flex;
|
|
120
|
+
align-items: center;
|
|
121
|
+
justify-content: center;
|
|
122
|
+
width: 140rpx;
|
|
123
|
+
height: 110rpx;
|
|
124
|
+
font-size: 26rpx;
|
|
125
|
+
font-weight: 400;
|
|
126
|
+
line-height: 1;
|
|
127
|
+
color: var(--snake-color-text-secondary, #444);
|
|
128
|
+
background: var(--snake-color-background, #f6f6f6);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.tab-item-active {
|
|
132
|
+
position: relative;
|
|
133
|
+
font-size: 30rpx;
|
|
134
|
+
font-weight: 600;
|
|
135
|
+
color: var(--snake-color-text, #000);
|
|
136
|
+
background: var(--snake-color-surface, #fff);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.tab-item-active::before {
|
|
140
|
+
position: absolute;
|
|
141
|
+
top: 39rpx;
|
|
142
|
+
left: 0;
|
|
143
|
+
height: 32rpx;
|
|
144
|
+
content: '';
|
|
145
|
+
border-left: 4px solid var(--snake-color-primary, #06d290);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.right-box {
|
|
149
|
+
background-color: var(--snake-color-surface-muted, rgb(250, 250, 250));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.content {
|
|
153
|
+
width: 100%;
|
|
154
|
+
overflow: hidden;
|
|
155
|
+
}
|
|
156
|
+
</style>
|