@tplc/wot 0.0.1
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/components/common/AbortablePromise.ts +36 -0
- package/components/common/abstracts/_config.scss +7 -0
- package/components/common/abstracts/_function.scss +76 -0
- package/components/common/abstracts/_mixin.scss +339 -0
- package/components/common/abstracts/variable.scss +1346 -0
- package/components/common/base64.ts +30 -0
- package/components/common/canvasHelper.ts +49 -0
- package/components/common/clickoutside.ts +34 -0
- package/components/common/dayjs.ts +157 -0
- package/components/common/event.ts +8 -0
- package/components/common/props.ts +51 -0
- package/components/common/util.ts +751 -0
- package/components/composables/useCell.ts +13 -0
- package/components/composables/useChildren.ts +122 -0
- package/components/composables/useCountDown.ts +138 -0
- package/components/composables/useLockScroll.ts +39 -0
- package/components/composables/useParent.ts +41 -0
- package/components/composables/usePopover.ts +193 -0
- package/components/composables/useQueue.ts +52 -0
- package/components/composables/useRaf.ts +37 -0
- package/components/composables/useTouch.ts +44 -0
- package/components/composables/useTranslate.ts +22 -0
- package/components/wd-action-sheet/index.scss +204 -0
- package/components/wd-action-sheet/types.ts +128 -0
- package/components/wd-action-sheet/wd-action-sheet.vue +174 -0
- package/components/wd-backtop/index.scss +25 -0
- package/components/wd-backtop/types.ts +37 -0
- package/components/wd-backtop/wd-backtop.vue +48 -0
- package/components/wd-badge/index.scss +59 -0
- package/components/wd-badge/types.ts +53 -0
- package/components/wd-badge/wd-badge.vue +69 -0
- package/components/wd-button/index.scss +340 -0
- package/components/wd-button/types.ts +112 -0
- package/components/wd-button/wd-button.vue +176 -0
- package/components/wd-calendar/index.scss +244 -0
- package/components/wd-calendar/types.ts +235 -0
- package/components/wd-calendar/wd-calendar.vue +456 -0
- package/components/wd-calendar-view/index.scss +9 -0
- package/components/wd-calendar-view/month/index.scss +151 -0
- package/components/wd-calendar-view/month/month.vue +391 -0
- package/components/wd-calendar-view/month/types.ts +19 -0
- package/components/wd-calendar-view/monthPanel/index.scss +89 -0
- package/components/wd-calendar-view/monthPanel/month-panel.vue +388 -0
- package/components/wd-calendar-view/monthPanel/types.ts +48 -0
- package/components/wd-calendar-view/types.ts +134 -0
- package/components/wd-calendar-view/utils.ts +451 -0
- package/components/wd-calendar-view/wd-calendar-view.vue +111 -0
- package/components/wd-calendar-view/year/index.scss +148 -0
- package/components/wd-calendar-view/year/types.ts +19 -0
- package/components/wd-calendar-view/year/year.vue +220 -0
- package/components/wd-calendar-view/yearPanel/index.scss +24 -0
- package/components/wd-calendar-view/yearPanel/types.ts +38 -0
- package/components/wd-calendar-view/yearPanel/year-panel.vue +140 -0
- package/components/wd-card/index.scss +70 -0
- package/components/wd-card/types.ts +30 -0
- package/components/wd-card/wd-card.vue +40 -0
- package/components/wd-cell/index.scss +189 -0
- package/components/wd-cell/types.ts +96 -0
- package/components/wd-cell/wd-cell.vue +135 -0
- package/components/wd-cell-group/index.scss +55 -0
- package/components/wd-cell-group/types.ts +41 -0
- package/components/wd-cell-group/wd-cell-group.vue +45 -0
- package/components/wd-checkbox/index.scss +285 -0
- package/components/wd-checkbox/types.ts +68 -0
- package/components/wd-checkbox/wd-checkbox.vue +185 -0
- package/components/wd-checkbox-group/index.scss +20 -0
- package/components/wd-checkbox-group/types.ts +59 -0
- package/components/wd-checkbox-group/wd-checkbox-group.vue +103 -0
- package/components/wd-circle/index.scss +18 -0
- package/components/wd-circle/types.ts +54 -0
- package/components/wd-circle/wd-circle.vue +318 -0
- package/components/wd-col/index.scss +19 -0
- package/components/wd-col/types.ts +15 -0
- package/components/wd-col/wd-col.vue +91 -0
- package/components/wd-col-picker/index.scss +241 -0
- package/components/wd-col-picker/types.ts +170 -0
- package/components/wd-col-picker/wd-col-picker.vue +550 -0
- package/components/wd-collapse/index.scss +55 -0
- package/components/wd-collapse/types.ts +63 -0
- package/components/wd-collapse/wd-collapse.vue +160 -0
- package/components/wd-collapse-item/index.scss +79 -0
- package/components/wd-collapse-item/types.ts +36 -0
- package/components/wd-collapse-item/wd-collapse-item.vue +182 -0
- package/components/wd-config-provider/types.ts +1023 -0
- package/components/wd-config-provider/wd-config-provider.vue +82 -0
- package/components/wd-count-down/index.scss +14 -0
- package/components/wd-count-down/types.ts +41 -0
- package/components/wd-count-down/utils.ts +52 -0
- package/components/wd-count-down/wd-count-down.vue +60 -0
- package/components/wd-count-to/index.scss +6 -0
- package/components/wd-count-to/types.ts +110 -0
- package/components/wd-count-to/wd-count-to.vue +134 -0
- package/components/wd-curtain/index.scss +80 -0
- package/components/wd-curtain/types.ts +45 -0
- package/components/wd-curtain/wd-curtain.vue +174 -0
- package/components/wd-datetime-picker/index.scss +243 -0
- package/components/wd-datetime-picker/types.ts +225 -0
- package/components/wd-datetime-picker/wd-datetime-picker.vue +827 -0
- package/components/wd-datetime-picker-view/index.scss +0 -0
- package/components/wd-datetime-picker-view/types.ts +137 -0
- package/components/wd-datetime-picker-view/wd-datetime-picker-view.vue +514 -0
- package/components/wd-divider/index.scss +32 -0
- package/components/wd-divider/types.ts +12 -0
- package/components/wd-divider/wd-divider.vue +29 -0
- package/components/wd-drop-menu/index.scss +89 -0
- package/components/wd-drop-menu/types.ts +38 -0
- package/components/wd-drop-menu/wd-drop-menu.vue +128 -0
- package/components/wd-drop-menu-item/index.scss +66 -0
- package/components/wd-drop-menu-item/types.ts +78 -0
- package/components/wd-drop-menu-item/wd-drop-menu-item.vue +230 -0
- package/components/wd-fab/index.scss +115 -0
- package/components/wd-fab/types.ts +61 -0
- package/components/wd-fab/wd-fab.vue +257 -0
- package/components/wd-form/index.scss +10 -0
- package/components/wd-form/types.ts +93 -0
- package/components/wd-form/wd-form.vue +185 -0
- package/components/wd-form-item/index.scss +17 -0
- package/components/wd-form-item/types.ts +22 -0
- package/components/wd-form-item/wd-form-item.vue +65 -0
- package/components/wd-gap/index.scss +9 -0
- package/components/wd-gap/types.ts +23 -0
- package/components/wd-gap/wd-gap.vue +39 -0
- package/components/wd-grid/index.scss +9 -0
- package/components/wd-grid/types.ts +54 -0
- package/components/wd-grid/wd-grid.vue +107 -0
- package/components/wd-grid-item/index.scss +137 -0
- package/components/wd-grid-item/types.ts +74 -0
- package/components/wd-grid-item/wd-grid-item.vue +181 -0
- package/components/wd-icon/index.scss +1222 -0
- package/components/wd-icon/types.ts +21 -0
- package/components/wd-icon/wd-icon.vue +53 -0
- package/components/wd-icon/wd-icons.ttf +0 -0
- package/components/wd-img/index.scss +19 -0
- package/components/wd-img/types.ts +53 -0
- package/components/wd-img/wd-img.vue +76 -0
- package/components/wd-img-cropper/index.scss +227 -0
- package/components/wd-img-cropper/types.ts +87 -0
- package/components/wd-img-cropper/wd-img-cropper.vue +659 -0
- package/components/wd-index-anchor/index.scss +34 -0
- package/components/wd-index-anchor/type.ts +9 -0
- package/components/wd-index-anchor/wd-index-anchor.vue +57 -0
- package/components/wd-index-bar/index.scss +39 -0
- package/components/wd-index-bar/type.ts +28 -0
- package/components/wd-index-bar/wd-index-bar.vue +158 -0
- package/components/wd-input/index.scss +326 -0
- package/components/wd-input/types.ts +182 -0
- package/components/wd-input/wd-input.vue +327 -0
- package/components/wd-input-number/index.scss +132 -0
- package/components/wd-input-number/types.ts +78 -0
- package/components/wd-input-number/wd-input-number.vue +221 -0
- package/components/wd-loading/index.scss +34 -0
- package/components/wd-loading/types.ts +31 -0
- package/components/wd-loading/wd-loading.vue +90 -0
- package/components/wd-loadmore/index.scss +39 -0
- package/components/wd-loadmore/types.ts +24 -0
- package/components/wd-loadmore/wd-loadmore.vue +53 -0
- package/components/wd-message-box/index.scss +121 -0
- package/components/wd-message-box/index.ts +95 -0
- package/components/wd-message-box/types.ts +116 -0
- package/components/wd-message-box/wd-message-box.vue +326 -0
- package/components/wd-navbar/index.scss +103 -0
- package/components/wd-navbar/types.ts +52 -0
- package/components/wd-navbar/wd-navbar.vue +142 -0
- package/components/wd-navbar-capsule/index.scss +65 -0
- package/components/wd-navbar-capsule/types.ts +0 -0
- package/components/wd-navbar-capsule/wd-navbar-capsule.vue +31 -0
- package/components/wd-notice-bar/index.scss +86 -0
- package/components/wd-notice-bar/types.ts +56 -0
- package/components/wd-notice-bar/wd-notice-bar.vue +223 -0
- package/components/wd-notify/index.scss +34 -0
- package/components/wd-notify/index.ts +59 -0
- package/components/wd-notify/types.ts +62 -0
- package/components/wd-notify/wd-notify.vue +83 -0
- package/components/wd-number-keyboard/index.scss +78 -0
- package/components/wd-number-keyboard/key/index.scss +79 -0
- package/components/wd-number-keyboard/key/index.vue +76 -0
- package/components/wd-number-keyboard/key/types.ts +11 -0
- package/components/wd-number-keyboard/types.ts +79 -0
- package/components/wd-number-keyboard/wd-number-keyboard.vue +173 -0
- package/components/wd-overlay/index.scss +17 -0
- package/components/wd-overlay/types.ts +25 -0
- package/components/wd-overlay/wd-overlay.vue +46 -0
- package/components/wd-pagination/index.scss +57 -0
- package/components/wd-pagination/types.ts +41 -0
- package/components/wd-pagination/wd-pagination.vue +121 -0
- package/components/wd-password-input/index.scss +123 -0
- package/components/wd-password-input/types.ts +48 -0
- package/components/wd-password-input/wd-password-input.vue +58 -0
- package/components/wd-picker/index.scss +216 -0
- package/components/wd-picker/types.ts +186 -0
- package/components/wd-picker/wd-picker.vue +409 -0
- package/components/wd-picker-view/index.scss +91 -0
- package/components/wd-picker-view/types.ts +162 -0
- package/components/wd-picker-view/wd-picker-view.vue +361 -0
- package/components/wd-popover/index.scss +123 -0
- package/components/wd-popover/types.ts +69 -0
- package/components/wd-popover/wd-popover.vue +216 -0
- package/components/wd-popup/index.scss +112 -0
- package/components/wd-popup/types.ts +68 -0
- package/components/wd-popup/wd-popup.vue +227 -0
- package/components/wd-progress/index.scss +62 -0
- package/components/wd-progress/types.ts +40 -0
- package/components/wd-progress/wd-progress.vue +201 -0
- package/components/wd-radio/index.scss +300 -0
- package/components/wd-radio/types.ts +42 -0
- package/components/wd-radio/wd-radio.vue +136 -0
- package/components/wd-radio-group/index.scss +23 -0
- package/components/wd-radio-group/types.ts +36 -0
- package/components/wd-radio-group/wd-radio-group.vue +54 -0
- package/components/wd-rate/index.scss +24 -0
- package/components/wd-rate/types.ts +91 -0
- package/components/wd-rate/wd-rate.vue +131 -0
- package/components/wd-resize/index.scss +26 -0
- package/components/wd-resize/types.ts +6 -0
- package/components/wd-resize/wd-resize.vue +155 -0
- package/components/wd-row/index.scss +10 -0
- package/components/wd-row/types.ts +16 -0
- package/components/wd-row/wd-row.vue +63 -0
- package/components/wd-search/index.scss +148 -0
- package/components/wd-search/types.ts +83 -0
- package/components/wd-search/wd-search.vue +237 -0
- package/components/wd-segmented/index.scss +97 -0
- package/components/wd-segmented/types.ts +68 -0
- package/components/wd-segmented/wd-segmented.vue +143 -0
- package/components/wd-select-picker/index.scss +177 -0
- package/components/wd-select-picker/types.ts +116 -0
- package/components/wd-select-picker/wd-select-picker.vue +486 -0
- package/components/wd-sidebar/index.scss +25 -0
- package/components/wd-sidebar/types.ts +28 -0
- package/components/wd-sidebar/wd-sidebar.vue +41 -0
- package/components/wd-sidebar-item/index.scss +93 -0
- package/components/wd-sidebar-item/types.ts +31 -0
- package/components/wd-sidebar-item/wd-sidebar-item.vue +114 -0
- package/components/wd-skeleton/index.scss +101 -0
- package/components/wd-skeleton/index.ts +1 -0
- package/components/wd-skeleton/types.ts +69 -0
- package/components/wd-skeleton/wd-skeleton.vue +135 -0
- package/components/wd-slider/index.scss +91 -0
- package/components/wd-slider/types.ts +104 -0
- package/components/wd-slider/wd-slider.vue +377 -0
- package/components/wd-sort-button/index.scss +86 -0
- package/components/wd-sort-button/types.ts +43 -0
- package/components/wd-sort-button/wd-sort-button.vue +76 -0
- package/components/wd-status-tip/index.scss +37 -0
- package/components/wd-status-tip/types.ts +59 -0
- package/components/wd-status-tip/wd-status-tip.vue +94 -0
- package/components/wd-step/index.scss +236 -0
- package/components/wd-step/types.ts +33 -0
- package/components/wd-step/wd-step.vue +151 -0
- package/components/wd-steps/index.scss +10 -0
- package/components/wd-steps/types.ts +59 -0
- package/components/wd-steps/wd-steps.vue +37 -0
- package/components/wd-sticky/index.scss +9 -0
- package/components/wd-sticky/types.ts +13 -0
- package/components/wd-sticky/wd-sticky.vue +190 -0
- package/components/wd-sticky-box/index.scss +6 -0
- package/components/wd-sticky-box/types.ts +20 -0
- package/components/wd-sticky-box/wd-sticky-box.vue +154 -0
- package/components/wd-swipe-action/index.scss +22 -0
- package/components/wd-swipe-action/types.ts +43 -0
- package/components/wd-swipe-action/wd-swipe-action.vue +307 -0
- package/components/wd-swiper/index.scss +23 -0
- package/components/wd-swiper/types.ts +189 -0
- package/components/wd-swiper/wd-swiper.vue +202 -0
- package/components/wd-swiper-nav/index.scss +153 -0
- package/components/wd-swiper-nav/types.ts +42 -0
- package/components/wd-swiper-nav/wd-swiper-nav.vue +37 -0
- package/components/wd-switch/index.scss +58 -0
- package/components/wd-switch/types.ts +56 -0
- package/components/wd-switch/wd-switch.vue +83 -0
- package/components/wd-tab/index.scss +8 -0
- package/components/wd-tab/types.ts +20 -0
- package/components/wd-tab/wd-tab.vue +100 -0
- package/components/wd-tabbar/index.scss +57 -0
- package/components/wd-tabbar/types.ts +88 -0
- package/components/wd-tabbar/wd-tabbar.vue +104 -0
- package/components/wd-tabbar-item/index.scss +52 -0
- package/components/wd-tabbar-item/types.ts +51 -0
- package/components/wd-tabbar-item/wd-tabbar-item.vue +101 -0
- package/components/wd-table/index.scss +132 -0
- package/components/wd-table/types.ts +69 -0
- package/components/wd-table/wd-table.vue +255 -0
- package/components/wd-table-col/index.scss +44 -0
- package/components/wd-table-col/types.ts +54 -0
- package/components/wd-table-col/wd-table-col.vue +149 -0
- package/components/wd-tabs/index.scss +280 -0
- package/components/wd-tabs/types.ts +71 -0
- package/components/wd-tabs/wd-tabs.vue +528 -0
- package/components/wd-tag/index.scss +115 -0
- package/components/wd-tag/types.ts +81 -0
- package/components/wd-tag/wd-tag.vue +154 -0
- package/components/wd-text/index.scss +34 -0
- package/components/wd-text/types.ts +98 -0
- package/components/wd-text/wd-text.vue +138 -0
- package/components/wd-textarea/index.scss +343 -0
- package/components/wd-textarea/types.ts +298 -0
- package/components/wd-textarea/wd-textarea.vue +303 -0
- package/components/wd-toast/index.scss +66 -0
- package/components/wd-toast/index.ts +109 -0
- package/components/wd-toast/types.ts +76 -0
- package/components/wd-toast/wd-toast.vue +212 -0
- package/components/wd-tooltip/index.scss +61 -0
- package/components/wd-tooltip/types.ts +102 -0
- package/components/wd-tooltip/wd-tooltip.vue +167 -0
- package/components/wd-transition/index.scss +91 -0
- package/components/wd-transition/types.ts +89 -0
- package/components/wd-transition/wd-transition.vue +221 -0
- package/components/wd-upload/index.scss +173 -0
- package/components/wd-upload/types.ts +378 -0
- package/components/wd-upload/utils.ts +152 -0
- package/components/wd-upload/wd-upload.vue +737 -0
- package/components/wd-video-preview/index.scss +34 -0
- package/components/wd-video-preview/types.ts +32 -0
- package/components/wd-video-preview/wd-video-preview.vue +76 -0
- package/components/wd-watermark/index.scss +18 -0
- package/components/wd-watermark/types.ts +82 -0
- package/components/wd-watermark/wd-watermark.vue +592 -0
- package/components/wot-design-uni/wot-design-uni.vue +14 -0
- package/global.d.ts +108 -0
- package/index.ts +30 -0
- package/locale/index.ts +41 -0
- package/locale/lang/en-US.ts +128 -0
- package/locale/lang/th-TH.ts +127 -0
- package/locale/lang/vi-VN.ts +89 -0
- package/locale/lang/zh-CN.ts +127 -0
- package/locale/lang/zh-HK.ts +84 -0
- package/locale/lang/zh-TW.ts +84 -0
- package/package.json +20 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { baseProps, makeRequiredProp, makeStringProp } from '../common/props'
|
|
2
|
+
|
|
3
|
+
export const iconProps = {
|
|
4
|
+
...baseProps,
|
|
5
|
+
/**
|
|
6
|
+
* 使用的图标名字,可以使用链接图片
|
|
7
|
+
*/
|
|
8
|
+
name: makeRequiredProp(String),
|
|
9
|
+
/**
|
|
10
|
+
* 图标的颜色
|
|
11
|
+
*/
|
|
12
|
+
color: String,
|
|
13
|
+
/**
|
|
14
|
+
* 图标的字体大小
|
|
15
|
+
*/
|
|
16
|
+
size: String,
|
|
17
|
+
/**
|
|
18
|
+
* 类名前缀,用于使用自定义图标
|
|
19
|
+
*/
|
|
20
|
+
classPrefix: makeStringProp('wd-icon'),
|
|
21
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view @click="handleClick" :class="rootClass" :style="rootStyle">
|
|
3
|
+
<image v-if="isImage" class="wd-icon__image" :src="name"></image>
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
export default {
|
|
9
|
+
name: 'wd-icon',
|
|
10
|
+
options: {
|
|
11
|
+
virtualHost: true,
|
|
12
|
+
addGlobalClass: true,
|
|
13
|
+
styleIsolation: 'shared',
|
|
14
|
+
},
|
|
15
|
+
}
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<script lang="ts" setup>
|
|
19
|
+
import { computed, type CSSProperties } from 'vue'
|
|
20
|
+
import { addUnit, isDef, objToStyle, isImageUrl } from '../common/util'
|
|
21
|
+
import { iconProps } from './types'
|
|
22
|
+
|
|
23
|
+
const props = defineProps(iconProps)
|
|
24
|
+
const emit = defineEmits(['click', 'touch'])
|
|
25
|
+
|
|
26
|
+
const isImage = computed(() => {
|
|
27
|
+
return isDef(props.name) && isImageUrl(props.name)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const rootClass = computed(() => {
|
|
31
|
+
const prefix = props.classPrefix
|
|
32
|
+
return `${prefix} ${props.customClass} ${isImage.value ? 'wd-icon--image' : prefix + '-' + props.name}`
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const rootStyle = computed(() => {
|
|
36
|
+
const style: CSSProperties = {}
|
|
37
|
+
if (props.color) {
|
|
38
|
+
style.color = props.color
|
|
39
|
+
}
|
|
40
|
+
if (props.size) {
|
|
41
|
+
style['font-size'] = addUnit(props.size)
|
|
42
|
+
}
|
|
43
|
+
return `${objToStyle(style)}; ${props.customStyle}`
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
function handleClick(event: any) {
|
|
47
|
+
emit('click', event)
|
|
48
|
+
}
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<style lang="scss" scoped>
|
|
52
|
+
@import './index.scss';
|
|
53
|
+
</style>
|
|
Binary file
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
@import './../common/abstracts/_mixin';
|
|
2
|
+
@import './../common/abstracts/variable';
|
|
3
|
+
|
|
4
|
+
@include b(img) {
|
|
5
|
+
position: relative;
|
|
6
|
+
display: inline-block;
|
|
7
|
+
|
|
8
|
+
@include e(image) {
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
display: block;
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 100%;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@include when(round) {
|
|
16
|
+
overflow: hidden;
|
|
17
|
+
border-radius: 50%;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { baseProps, makeBooleanProp, makeStringProp, numericProp } from '../common/props'
|
|
2
|
+
export type ImageMode =
|
|
3
|
+
| 'scaleToFill'
|
|
4
|
+
| 'aspectFit'
|
|
5
|
+
| 'aspectFill'
|
|
6
|
+
| 'widthFix'
|
|
7
|
+
| 'heightFix'
|
|
8
|
+
| 'top'
|
|
9
|
+
| 'bottom'
|
|
10
|
+
| 'center'
|
|
11
|
+
| 'left'
|
|
12
|
+
| 'right'
|
|
13
|
+
| 'top left'
|
|
14
|
+
| 'top right'
|
|
15
|
+
| 'bottom left'
|
|
16
|
+
| 'bottom right'
|
|
17
|
+
|
|
18
|
+
export const imgProps = {
|
|
19
|
+
...baseProps,
|
|
20
|
+
customImage: makeStringProp(''),
|
|
21
|
+
/**
|
|
22
|
+
* 图片链接
|
|
23
|
+
*/
|
|
24
|
+
src: String,
|
|
25
|
+
/**
|
|
26
|
+
* 是否显示为圆形
|
|
27
|
+
*/
|
|
28
|
+
round: makeBooleanProp(false),
|
|
29
|
+
/**
|
|
30
|
+
* 填充模式:'top left' / 'top right' / 'bottom left' / 'bottom right' / 'right' / 'left' / 'center' / 'bottom' / 'top' / 'heightFix' / 'widthFix' / 'aspectFill' / 'aspectFit' / 'scaleToFill'
|
|
31
|
+
*/
|
|
32
|
+
mode: makeStringProp<ImageMode>('scaleToFill'),
|
|
33
|
+
/**
|
|
34
|
+
* 是否懒加载
|
|
35
|
+
*/
|
|
36
|
+
lazyLoad: makeBooleanProp(false),
|
|
37
|
+
/**
|
|
38
|
+
* 宽度,默认单位为px
|
|
39
|
+
*/
|
|
40
|
+
width: numericProp,
|
|
41
|
+
/**
|
|
42
|
+
* 高度,默认单位为px
|
|
43
|
+
*/
|
|
44
|
+
height: numericProp,
|
|
45
|
+
/**
|
|
46
|
+
* 圆角大小,默认单位为px
|
|
47
|
+
*/
|
|
48
|
+
radius: numericProp,
|
|
49
|
+
/**
|
|
50
|
+
* 是否允许预览
|
|
51
|
+
*/
|
|
52
|
+
enablePreview: makeBooleanProp(false),
|
|
53
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="rootClass" @click="handleClick" :style="rootStyle">
|
|
3
|
+
<image
|
|
4
|
+
:class="`wd-img__image ${customImage}`"
|
|
5
|
+
:style="status !== 'success' ? 'width: 0;height: 0;' : ''"
|
|
6
|
+
:src="src"
|
|
7
|
+
:mode="mode"
|
|
8
|
+
:lazy-load="lazyLoad"
|
|
9
|
+
@load="handleLoad"
|
|
10
|
+
@error="handleError"
|
|
11
|
+
/>
|
|
12
|
+
<slot v-if="status === 'loading'" name="loading"></slot>
|
|
13
|
+
<slot v-if="status === 'error'" name="error"></slot>
|
|
14
|
+
</view>
|
|
15
|
+
</template>
|
|
16
|
+
<script lang="ts">
|
|
17
|
+
export default {
|
|
18
|
+
name: 'wd-img',
|
|
19
|
+
options: {
|
|
20
|
+
virtualHost: true,
|
|
21
|
+
addGlobalClass: true,
|
|
22
|
+
styleIsolation: 'shared',
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<script lang="ts" setup>
|
|
28
|
+
import { computed, ref } from 'vue'
|
|
29
|
+
import { addUnit, isDef, objToStyle } from '../common/util'
|
|
30
|
+
import { imgProps } from './types'
|
|
31
|
+
|
|
32
|
+
const props = defineProps(imgProps)
|
|
33
|
+
const emit = defineEmits(['error', 'click', 'load'])
|
|
34
|
+
|
|
35
|
+
const rootStyle = computed(() => {
|
|
36
|
+
const style: Record<string, string | number> = {}
|
|
37
|
+
if (isDef(props.height)) {
|
|
38
|
+
style.height = addUnit(props.height)
|
|
39
|
+
}
|
|
40
|
+
if (isDef(props.width)) {
|
|
41
|
+
style.width = addUnit(props.width)
|
|
42
|
+
}
|
|
43
|
+
if (isDef(props.radius)) {
|
|
44
|
+
style['border-radius'] = addUnit(props.radius)
|
|
45
|
+
style.overflow = 'hidden'
|
|
46
|
+
}
|
|
47
|
+
return `${objToStyle(style)};${props.customStyle}`
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
const rootClass = computed(() => {
|
|
51
|
+
return `wd-img ${props.round ? 'is-round' : ''} ${props.customClass}`
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const status = ref<'loading' | 'error' | 'success'>('loading')
|
|
55
|
+
|
|
56
|
+
function handleError(event: Event) {
|
|
57
|
+
status.value = 'error'
|
|
58
|
+
emit('error', event)
|
|
59
|
+
}
|
|
60
|
+
function handleClick() {
|
|
61
|
+
if (props.enablePreview && props.src) {
|
|
62
|
+
uni.previewImage({
|
|
63
|
+
urls: [props.src],
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
emit('click')
|
|
67
|
+
}
|
|
68
|
+
function handleLoad(event: Event) {
|
|
69
|
+
status.value = 'success'
|
|
70
|
+
emit('load', event)
|
|
71
|
+
}
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<style lang="scss" scoped>
|
|
75
|
+
@import './index.scss';
|
|
76
|
+
</style>
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
@import './../common/abstracts/_mixin';
|
|
2
|
+
@import './../common/abstracts/variable';
|
|
3
|
+
|
|
4
|
+
@include b(img-cropper) {
|
|
5
|
+
position: fixed;
|
|
6
|
+
top: 0;
|
|
7
|
+
left: 0;
|
|
8
|
+
z-index: 1;
|
|
9
|
+
width: 100vw;
|
|
10
|
+
height: 100vh;
|
|
11
|
+
background: rgba(0, 0, 0, 1);
|
|
12
|
+
|
|
13
|
+
// 裁剪框包裹器
|
|
14
|
+
@include e(wrapper) {
|
|
15
|
+
position: relative;
|
|
16
|
+
background: rgba(0, 0, 0, 0.45);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@include e(cut) {
|
|
20
|
+
position: absolute;
|
|
21
|
+
z-index: 9;
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
width: 100vw;
|
|
25
|
+
height: 100vh;
|
|
26
|
+
pointer-events: none;
|
|
27
|
+
|
|
28
|
+
.wd-img-cropper__cut--top,
|
|
29
|
+
.wd-img-cropper__cut--bottom,
|
|
30
|
+
.wd-img-cropper__cut--left,
|
|
31
|
+
.wd-img-cropper__cut--right {
|
|
32
|
+
// 拖动中背景蒙层为0 拖动结束为0.85
|
|
33
|
+
background-color: rgba(0, 0, 0, 0.85);
|
|
34
|
+
transition: background 0.2s;
|
|
35
|
+
|
|
36
|
+
@include when(hightlight) {
|
|
37
|
+
background-color: rgba(0, 0, 0, 0);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.wd-img-cropper__cut--bottom,
|
|
42
|
+
.wd-img-cropper__cut--right {
|
|
43
|
+
flex: auto;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@include m(middle) {
|
|
47
|
+
display: flex;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@include m(body) {
|
|
51
|
+
position: relative;
|
|
52
|
+
// 若需要变化窗体大小,支持控制窗体的大小来控制下方所有对应的展示
|
|
53
|
+
background-color: transparent;
|
|
54
|
+
|
|
55
|
+
// 节选框的窗体最外部边缘线
|
|
56
|
+
&::before {
|
|
57
|
+
position: absolute;
|
|
58
|
+
top: -50%;
|
|
59
|
+
left: -50%;
|
|
60
|
+
width: calc(200% - 1px);
|
|
61
|
+
height: calc(200% - 1px);
|
|
62
|
+
content: '';
|
|
63
|
+
border: 1px solid #fff;
|
|
64
|
+
transform: scale(0.5) translate(-1px, -1px);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// 结算框对角尺寸
|
|
68
|
+
$border-size: 2px;
|
|
69
|
+
|
|
70
|
+
// 节选框的四个角
|
|
71
|
+
.is-left-top,
|
|
72
|
+
.is-left-bottom,
|
|
73
|
+
.is-right-top,
|
|
74
|
+
.is-right-bottom {
|
|
75
|
+
&::before {
|
|
76
|
+
position: absolute;
|
|
77
|
+
width: $border-size;
|
|
78
|
+
height: 20px;
|
|
79
|
+
content: '';
|
|
80
|
+
background-color: #fff;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&::after {
|
|
84
|
+
position: absolute;
|
|
85
|
+
width: 20px;
|
|
86
|
+
height: $border-size;
|
|
87
|
+
content: '';
|
|
88
|
+
background-color: #fff;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.is-left-top {
|
|
93
|
+
&::before,
|
|
94
|
+
&::after {
|
|
95
|
+
top: -$border-size;
|
|
96
|
+
left: -$border-size;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.is-left-bottom {
|
|
101
|
+
&::before,
|
|
102
|
+
&::after {
|
|
103
|
+
bottom: -$border-size;
|
|
104
|
+
left: -$border-size;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.is-right-top {
|
|
109
|
+
&::before,
|
|
110
|
+
&::after {
|
|
111
|
+
top: -$border-size;
|
|
112
|
+
right: -$border-size;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.is-right-bottom {
|
|
117
|
+
&::before,
|
|
118
|
+
&::after {
|
|
119
|
+
right: -$border-size;
|
|
120
|
+
bottom: -$border-size;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 内部网格线
|
|
125
|
+
.is-gridlines-x,
|
|
126
|
+
.is-gridlines-y {
|
|
127
|
+
position: absolute;
|
|
128
|
+
top: 0;
|
|
129
|
+
left: 0;
|
|
130
|
+
display: flex;
|
|
131
|
+
width: 100%;
|
|
132
|
+
height: 100%;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.is-gridlines-x {
|
|
136
|
+
justify-content: center;
|
|
137
|
+
|
|
138
|
+
&::before {
|
|
139
|
+
display: inline-block;
|
|
140
|
+
width: 66.66%;
|
|
141
|
+
height: 200%;
|
|
142
|
+
content: '';
|
|
143
|
+
border: 1px solid #fff;
|
|
144
|
+
border-top: none;
|
|
145
|
+
border-bottom: none;
|
|
146
|
+
transform: scale(0.5) translate(0, -50%);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// 内部网格线 - y轴
|
|
151
|
+
.is-gridlines-y {
|
|
152
|
+
align-items: center;
|
|
153
|
+
|
|
154
|
+
&::after {
|
|
155
|
+
display: inline-block;
|
|
156
|
+
flex-shrink: 0;
|
|
157
|
+
width: 200%;
|
|
158
|
+
height: 66.66%;
|
|
159
|
+
content: '';
|
|
160
|
+
border: 1px solid #fff;
|
|
161
|
+
border-right: none;
|
|
162
|
+
border-left: none;
|
|
163
|
+
transform: scale(0.5) translate(-50%, 0);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@include e(img) {
|
|
170
|
+
position: absolute;
|
|
171
|
+
top: 0;
|
|
172
|
+
left: 0;
|
|
173
|
+
z-index: 2;
|
|
174
|
+
width: 100%;
|
|
175
|
+
border: none;
|
|
176
|
+
transform-origin: center;
|
|
177
|
+
backface-visibility: hidden;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
@include e(canvas) {
|
|
181
|
+
position: fixed;
|
|
182
|
+
top: -200%;
|
|
183
|
+
z-index: 10;
|
|
184
|
+
width: 150px;
|
|
185
|
+
height: 150px;
|
|
186
|
+
pointer-events: none;
|
|
187
|
+
background: white;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
@include e(footer) {
|
|
191
|
+
position: fixed;
|
|
192
|
+
bottom: 10px;
|
|
193
|
+
z-index: 10;
|
|
194
|
+
width: 100%;
|
|
195
|
+
height: 15vh;
|
|
196
|
+
text-align: center;
|
|
197
|
+
|
|
198
|
+
@include m(button) {
|
|
199
|
+
position: relative;
|
|
200
|
+
// line-height: 32px;
|
|
201
|
+
box-sizing: border-box;
|
|
202
|
+
padding-top: 4vh;
|
|
203
|
+
margin: 0 20px;
|
|
204
|
+
text-align: left;
|
|
205
|
+
|
|
206
|
+
.is-cancel {
|
|
207
|
+
display: inline-block;
|
|
208
|
+
font-size: 16px;
|
|
209
|
+
color: #fff;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.is-confirm {
|
|
213
|
+
position: absolute;
|
|
214
|
+
right: 0;
|
|
215
|
+
// height: 32px;
|
|
216
|
+
width: 56px;
|
|
217
|
+
font-size: 16px;
|
|
218
|
+
border-radius: 16px;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
@include edeep(rotate) {
|
|
224
|
+
font-size: $-img-cropper-icon-size;
|
|
225
|
+
color: $-img-cropper-icon-color;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: weisheng
|
|
3
|
+
* @Date: 2024-06-03 23:43:43
|
|
4
|
+
* @LastEditTime: 2024-06-06 21:40:53
|
|
5
|
+
* @LastEditors: weisheng
|
|
6
|
+
* @Description:
|
|
7
|
+
* @FilePath: /wot-design-uni/src/uni_modules/wot-design-uni/components/wd-img-cropper/types.ts
|
|
8
|
+
* 记得注释
|
|
9
|
+
*/
|
|
10
|
+
import type { ComponentPublicInstance, ExtractPropTypes } from 'vue'
|
|
11
|
+
import {
|
|
12
|
+
baseProps,
|
|
13
|
+
makeBooleanProp,
|
|
14
|
+
makeNumberProp,
|
|
15
|
+
makeNumericProp,
|
|
16
|
+
makeStringProp,
|
|
17
|
+
} from '../common/props'
|
|
18
|
+
|
|
19
|
+
export const imgCropperProps = {
|
|
20
|
+
...baseProps,
|
|
21
|
+
/**
|
|
22
|
+
* 打开图片裁剪组件
|
|
23
|
+
*/
|
|
24
|
+
modelValue: makeBooleanProp(false),
|
|
25
|
+
/**
|
|
26
|
+
* 取消按钮文案
|
|
27
|
+
*/
|
|
28
|
+
cancelButtonText: String,
|
|
29
|
+
/**
|
|
30
|
+
* 确认按钮文案
|
|
31
|
+
*/
|
|
32
|
+
confirmButtonText: String,
|
|
33
|
+
/**
|
|
34
|
+
* 是否禁用旋转
|
|
35
|
+
*/
|
|
36
|
+
disabledRotate: makeBooleanProp(false),
|
|
37
|
+
/** canvas绘图参数 start **/
|
|
38
|
+
/**
|
|
39
|
+
* 目标文件的类型,wx.canvasToTempFilePath属性介绍
|
|
40
|
+
*/
|
|
41
|
+
fileType: makeStringProp('png'),
|
|
42
|
+
/**
|
|
43
|
+
* 生成的图片质量 wx.canvasToTempFilePath属性介绍
|
|
44
|
+
*/
|
|
45
|
+
quality: makeNumberProp(1),
|
|
46
|
+
/**
|
|
47
|
+
* 设置导出图片尺寸
|
|
48
|
+
*/
|
|
49
|
+
exportScale: makeNumberProp(2),
|
|
50
|
+
/** canvas绘图参数 end **/
|
|
51
|
+
/**
|
|
52
|
+
* 图片源路径
|
|
53
|
+
*/
|
|
54
|
+
imgSrc: makeStringProp(''),
|
|
55
|
+
/**
|
|
56
|
+
* 图片宽
|
|
57
|
+
*/
|
|
58
|
+
imgWidth: makeNumericProp(''),
|
|
59
|
+
/**
|
|
60
|
+
* 图片高
|
|
61
|
+
*/
|
|
62
|
+
imgHeight: makeNumericProp(''),
|
|
63
|
+
/**
|
|
64
|
+
* 最大缩放
|
|
65
|
+
*/
|
|
66
|
+
maxScale: makeNumberProp(3),
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type ImgCropperProps = ExtractPropTypes<typeof imgCropperProps>
|
|
70
|
+
|
|
71
|
+
export type ImgCropperExpose = {
|
|
72
|
+
/**
|
|
73
|
+
* 逆转是否使用动画
|
|
74
|
+
*/
|
|
75
|
+
revertIsAnimation: (animation: boolean) => void
|
|
76
|
+
/**
|
|
77
|
+
* 初始化图片的大小和角度以及距离
|
|
78
|
+
*/
|
|
79
|
+
resetImg: () => void
|
|
80
|
+
/**
|
|
81
|
+
* 控制旋转角度
|
|
82
|
+
* @param angle 角度
|
|
83
|
+
*/
|
|
84
|
+
setRoate: (angle: number) => void
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type ImgCropperInstance = ComponentPublicInstance<ImgCropperProps, ImgCropperExpose>
|