dpzvc3-ui 3.0.0
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 +20 -0
- package/README.md +175 -0
- package/build-style.js +58 -0
- package/dist/dpzvc3.esm.js +17676 -0
- package/dist/dpzvc3.esm.js.map +1 -0
- package/dist/dpzvc3.esm.min.js +2 -0
- package/dist/dpzvc3.esm.min.js.map +1 -0
- package/dist/dpzvc3.js +15200 -0
- package/dist/dpzvc3.js.map +1 -0
- package/dist/dpzvc3.min.js +2 -0
- package/dist/dpzvc3.min.js.map +1 -0
- package/dist/styles/base/font.css +1 -0
- package/dist/styles/base/reset.css +1 -0
- package/dist/styles/base/variable.css +0 -0
- package/dist/styles/components/actionSheet.css +1 -0
- package/dist/styles/components/badge.css +1 -0
- package/dist/styles/components/button.css +1 -0
- package/dist/styles/components/card.css +1 -0
- package/dist/styles/components/cell-swipe.css +1 -0
- package/dist/styles/components/cell.css +1 -0
- package/dist/styles/components/checkBox.css +1 -0
- package/dist/styles/components/editor.css +1 -0
- package/dist/styles/components/header.css +1 -0
- package/dist/styles/components/indicator.css +1 -0
- package/dist/styles/components/loadmore.css +1 -0
- package/dist/styles/components/message.css +1 -0
- package/dist/styles/components/modal.css +1 -0
- package/dist/styles/components/number.css +1 -0
- package/dist/styles/components/picker.css +1 -0
- package/dist/styles/components/popup.css +1 -0
- package/dist/styles/components/progress.css +1 -0
- package/dist/styles/components/prompt.css +1 -0
- package/dist/styles/components/radioBox.css +1 -0
- package/dist/styles/components/slide-Bar.css +1 -0
- package/dist/styles/components/spinner.css +1 -0
- package/dist/styles/components/swipe.css +1 -0
- package/dist/styles/components/switchBar.css +1 -0
- package/dist/styles/components/tab.css +1 -0
- package/dist/styles/components/text.css +1 -0
- package/dist/styles/components/toTop.css +1 -0
- package/dist/styles/components/upload.css +1 -0
- package/dist/styles/dpzvc3.css +1 -0
- package/dist/styles/utils/1px.css +1 -0
- package/dist/styles/utils/animation.css +1 -0
- package/dist/styles/utils/nowrap.css +1 -0
- package/dist-prod/91.9d79b442ec3131707419.js +3 -0
- package/dist-prod/91.9d79b442ec3131707419.js.LICENSE.txt +25 -0
- package/dist-prod/91.9d79b442ec3131707419.js.map +1 -0
- package/dist-prod/actionsheet.e2f7c32d0120f5147a4f.chunk.js +2 -0
- package/dist-prod/actionsheet.e2f7c32d0120f5147a4f.chunk.js.map +1 -0
- package/dist-prod/badge.6038c4ccc54ffb56a645.chunk.js +2 -0
- package/dist-prod/badge.6038c4ccc54ffb56a645.chunk.js.map +1 -0
- package/dist-prod/button.28b491339fbba29c3f16.chunk.js +2 -0
- package/dist-prod/button.28b491339fbba29c3f16.chunk.js.map +1 -0
- package/dist-prod/card.3ad847f07bebc1391125.chunk.js +2 -0
- package/dist-prod/card.3ad847f07bebc1391125.chunk.js.map +1 -0
- package/dist-prod/cell.8920796a9ebd2d84bbd3.chunk.js +2 -0
- package/dist-prod/cell.8920796a9ebd2d84bbd3.chunk.js.map +1 -0
- package/dist-prod/cellswipe.53b0178e4638c201dcf1.chunk.js +2 -0
- package/dist-prod/cellswipe.53b0178e4638c201dcf1.chunk.js.map +1 -0
- package/dist-prod/checkbox.87403976981ee0f64f4a.chunk.js +2 -0
- package/dist-prod/checkbox.87403976981ee0f64f4a.chunk.js.map +1 -0
- package/dist-prod/guide.5195c74796a7a0e37f7b.chunk.js +2 -0
- package/dist-prod/guide.5195c74796a7a0e37f7b.chunk.js.map +1 -0
- package/dist-prod/header.e3cecc6d60f801c1c105.chunk.js +2 -0
- package/dist-prod/header.e3cecc6d60f801c1c105.chunk.js.map +1 -0
- package/dist-prod/index.html +19 -0
- package/dist-prod/indicator.6b0c7a91ca254c3586e8.chunk.js +2 -0
- package/dist-prod/indicator.6b0c7a91ca254c3586e8.chunk.js.map +1 -0
- package/dist-prod/loadmore.ba86c35311fc68ee215b.chunk.js +2 -0
- package/dist-prod/loadmore.ba86c35311fc68ee215b.chunk.js.map +1 -0
- package/dist-prod/main.2e9aaa9095e329ea2d7b.js +2 -0
- package/dist-prod/main.2e9aaa9095e329ea2d7b.js.map +1 -0
- package/dist-prod/message.e57fa263a214006f7191.chunk.js +2 -0
- package/dist-prod/message.e57fa263a214006f7191.chunk.js.map +1 -0
- package/dist-prod/modal.1172c8ba7d90503fc8e8.chunk.js +2 -0
- package/dist-prod/modal.1172c8ba7d90503fc8e8.chunk.js.map +1 -0
- package/dist-prod/picker.4ff114161c5c3f8df57a.chunk.js +2 -0
- package/dist-prod/picker.4ff114161c5c3f8df57a.chunk.js.map +1 -0
- package/dist-prod/popup.8f92c027932e4d47fa59.chunk.js +2 -0
- package/dist-prod/popup.8f92c027932e4d47fa59.chunk.js.map +1 -0
- package/dist-prod/progress.1e0d785044aecadc5615.chunk.js +2 -0
- package/dist-prod/progress.1e0d785044aecadc5615.chunk.js.map +1 -0
- package/dist-prod/prompt.c2b442c3dd0e6d8319bc.chunk.js +2 -0
- package/dist-prod/prompt.c2b442c3dd0e6d8319bc.chunk.js.map +1 -0
- package/dist-prod/radiobox.479703c69b75d473e85d.chunk.js +2 -0
- package/dist-prod/radiobox.479703c69b75d473e85d.chunk.js.map +1 -0
- package/dist-prod/rater.939e0e7e770728f684c3.chunk.js +2 -0
- package/dist-prod/rater.939e0e7e770728f684c3.chunk.js.map +1 -0
- package/dist-prod/slidebar.3d3f48a631f03a2210c9.chunk.js +2 -0
- package/dist-prod/slidebar.3d3f48a631f03a2210c9.chunk.js.map +1 -0
- package/dist-prod/spinner.f20e3bd8cec27d26afe0.chunk.js +2 -0
- package/dist-prod/spinner.f20e3bd8cec27d26afe0.chunk.js.map +1 -0
- package/dist-prod/swipe.2e5b0acc3bbb2bf49dd5.chunk.js +2 -0
- package/dist-prod/swipe.2e5b0acc3bbb2bf49dd5.chunk.js.map +1 -0
- package/dist-prod/switchbar.56d03d96c275ff4c65a1.chunk.js +2 -0
- package/dist-prod/switchbar.56d03d96c275ff4c65a1.chunk.js.map +1 -0
- package/dist-prod/tab.4c391211c41b7d12b585.chunk.js +2 -0
- package/dist-prod/tab.4c391211c41b7d12b585.chunk.js.map +1 -0
- package/dist-prod/text.ee2804ba87e6a460aa7d.chunk.js +2 -0
- package/dist-prod/text.ee2804ba87e6a460aa7d.chunk.js.map +1 -0
- package/dist-prod/totop.c6f9dce152bb6abe5cb2.chunk.js +2 -0
- package/dist-prod/totop.c6f9dce152bb6abe5cb2.chunk.js.map +1 -0
- package/dist-prod/upload.ec7a954970889869d93e.chunk.js +2 -0
- package/dist-prod/upload.ec7a954970889869d93e.chunk.js.map +1 -0
- package/images/IMG_2614 2 2.JPG +0 -0
- package/images/IMG_2614.JPG +0 -0
- package/images/IMG_2615 2.JPG +0 -0
- package/images/IMG_2615.JPG +0 -0
- package/package.json +113 -0
- package/postcss.config.js +5 -0
- package/src/components/Indicator/Indicator.vue +82 -0
- package/src/components/Indicator/index.js +86 -0
- package/src/components/Text/Number.vue +167 -0
- package/src/components/Text/index.js +7 -0
- package/src/components/Text/textBar.vue +122 -0
- package/src/components/action-sheet/actionSheet.vue +93 -0
- package/src/components/action-sheet/index.js +5 -0
- package/src/components/app.vue +61 -0
- package/src/components/badge/badge.vue +80 -0
- package/src/components/badge/index.js +5 -0
- package/src/components/button/button.vue +111 -0
- package/src/components/button/index.js +5 -0
- package/src/components/card/card.vue +49 -0
- package/src/components/card/index.js +5 -0
- package/src/components/cell/cell.vue +93 -0
- package/src/components/cell/index.js +5 -0
- package/src/components/cell-swipe/cell-swipe.vue +169 -0
- package/src/components/cell-swipe/index.js +5 -0
- package/src/components/checkBox/checkbox-group.vue +74 -0
- package/src/components/checkBox/checkbox.vue +117 -0
- package/src/components/checkBox/index.js +8 -0
- package/src/components/header/header.vue +130 -0
- package/src/components/header/index.js +5 -0
- package/src/components/loadMore/index.js +5 -0
- package/src/components/loadMore/loadmore.vue +258 -0
- package/src/components/message/confirm.js +60 -0
- package/src/components/message/index.js +111 -0
- package/src/components/message/message.vue +137 -0
- package/src/components/message/messageGroup.vue +82 -0
- package/src/components/modal/confirm.js +122 -0
- package/src/components/modal/index.js +52 -0
- package/src/components/modal/modal.vue +138 -0
- package/src/components/picker/area-picker/area-picker.vue +230 -0
- package/src/components/picker/area-picker/props.js +17 -0
- package/src/components/picker/date-picker/date-picker.vue +191 -0
- package/src/components/picker/date-picker/props.js +24 -0
- package/src/components/picker/index.js +5 -0
- package/src/components/picker/normal-picker/normal-picker.vue +120 -0
- package/src/components/picker/normal-picker/props.js +20 -0
- package/src/components/picker/picker-slot.vue +217 -0
- package/src/components/picker/picker.vue +111 -0
- package/src/components/popup/index.js +5 -0
- package/src/components/popup/popup.vue +91 -0
- package/src/components/progress/index.js +5 -0
- package/src/components/progress/progress.vue +86 -0
- package/src/components/prompt/confirm.js +91 -0
- package/src/components/prompt/index.js +53 -0
- package/src/components/prompt/prompt.vue +125 -0
- package/src/components/radioBox/index.js +8 -0
- package/src/components/radioBox/radiobox-group.vue +66 -0
- package/src/components/radioBox/radiobox.vue +88 -0
- package/src/components/rater/index.js +5 -0
- package/src/components/rater/rater.vue +118 -0
- package/src/components/slideBar/index.js +6 -0
- package/src/components/slideBar/slideBar.vue +207 -0
- package/src/components/spinner/behavior/blade.vue +42 -0
- package/src/components/spinner/behavior/double-bounce.vue +38 -0
- package/src/components/spinner/behavior/fading-circle.vue +55 -0
- package/src/components/spinner/behavior/snake.vue +41 -0
- package/src/components/spinner/behavior/triple-bounce.vue +52 -0
- package/src/components/spinner/index.js +5 -0
- package/src/components/spinner/props.js +28 -0
- package/src/components/spinner/spinner.vue +78 -0
- package/src/components/swipe/index.js +5 -0
- package/src/components/swipe/swipe.vue +281 -0
- package/src/components/switchbar/index.js +5 -0
- package/src/components/switchbar/switchbar.vue +79 -0
- package/src/components/tab/index.js +6 -0
- package/src/components/tab/tab.vue +89 -0
- package/src/components/toTop/index.js +5 -0
- package/src/components/toTop/topTop.vue +78 -0
- package/src/components/upload/index.js +5 -0
- package/src/components/upload/upload.vue +166 -0
- package/src/config/config.js +16 -0
- package/src/directives/clickoutside.js +42 -0
- package/src/directives/tranferDom.js +66 -0
- package/src/index.js +149 -0
- package/src/lib/MegaPixImage.js +163 -0
- package/src/lib/MegaPixImageOld.js +153 -0
- package/src/lib/exif-js.js +235 -0
- package/src/lib/exif.js +789 -0
- package/src/main.js +31 -0
- package/src/mixin/emitter.js +72 -0
- package/src/mixin/input.js +41 -0
- package/src/router.js +36 -0
- package/src/styles/base/font.less +99 -0
- package/src/styles/base/reset.less +135 -0
- package/src/styles/base/variable.less +108 -0
- package/src/styles/components/actionSheet.less +43 -0
- package/src/styles/components/badge.less +81 -0
- package/src/styles/components/button.less +124 -0
- package/src/styles/components/card.less +31 -0
- package/src/styles/components/cell-swipe.less +20 -0
- package/src/styles/components/cell.less +75 -0
- package/src/styles/components/checkBox.less +113 -0
- package/src/styles/components/editor.less +3 -0
- package/src/styles/components/header.less +72 -0
- package/src/styles/components/indicator.less +39 -0
- package/src/styles/components/loadmore.less +48 -0
- package/src/styles/components/message.less +57 -0
- package/src/styles/components/modal.less +84 -0
- package/src/styles/components/number.less +60 -0
- package/src/styles/components/picker.less +152 -0
- package/src/styles/components/popup.less +46 -0
- package/src/styles/components/progress.less +52 -0
- package/src/styles/components/prompt.less +37 -0
- package/src/styles/components/radioBox.less +138 -0
- package/src/styles/components/slide-Bar.less +149 -0
- package/src/styles/components/spinner.less +329 -0
- package/src/styles/components/swipe.less +125 -0
- package/src/styles/components/switchBar.less +88 -0
- package/src/styles/components/tab.less +71 -0
- package/src/styles/components/text.less +82 -0
- package/src/styles/components/toTop.less +28 -0
- package/src/styles/components/upload.less +23 -0
- package/src/styles/index.less +38 -0
- package/src/styles/utils/1px.less +206 -0
- package/src/styles/utils/animation.less +165 -0
- package/src/styles/utils/nowrap.less +19 -0
- package/src/template/index.ejs +40 -0
- package/src/utils/util.js +202 -0
- package/src/vconsole-resources.min.js +6 -0
- package/src/vconsole-sources.min.js +6 -0
- package/src/vconsole.min.js +7 -0
- package/src/views/ActionSheet.vue +46 -0
- package/src/views/Badge.vue +51 -0
- package/src/views/Button.vue +69 -0
- package/src/views/Card.vue +88 -0
- package/src/views/Cell.vue +30 -0
- package/src/views/CellSwipe.vue +68 -0
- package/src/views/CheckBox.vue +77 -0
- package/src/views/Header.vue +70 -0
- package/src/views/Indicator.vue +82 -0
- package/src/views/LoadMore.vue +73 -0
- package/src/views/Message.vue +61 -0
- package/src/views/Modal.vue +69 -0
- package/src/views/Picker.vue +140 -0
- package/src/views/Popup.vue +97 -0
- package/src/views/Progress.vue +47 -0
- package/src/views/Prompt.vue +43 -0
- package/src/views/RadioBox.vue +68 -0
- package/src/views/Rater.vue +49 -0
- package/src/views/SlideBar.vue +55 -0
- package/src/views/Spinner.vue +15 -0
- package/src/views/Swipe.vue +59 -0
- package/src/views/SwitchBar.vue +47 -0
- package/src/views/Tab.vue +53 -0
- package/src/views/Text.vue +93 -0
- package/src/views/ToTop.vue +17 -0
- package/src/views/Upload.vue +61 -0
- package/src/views/guide.vue +164 -0
- package/src/views/index.vue +554 -0
- package/webpack.base.config.js +65 -0
- package/webpack.dev.config.js +42 -0
- package/webpack.dist.dev.config.js +75 -0
- package/webpack.dist.prod.config.js +89 -0
- package/webpack.prod.config.js +51 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
v-show="show"
|
|
4
|
+
:class="classes"
|
|
5
|
+
:style="getStyles"
|
|
6
|
+
>
|
|
7
|
+
<ul>
|
|
8
|
+
<li
|
|
9
|
+
v-for="(item, index) in items"
|
|
10
|
+
:key="index"
|
|
11
|
+
>
|
|
12
|
+
<!-- 外部链接 -->
|
|
13
|
+
<template v-if="/(http|https)/i.test(item.path)">
|
|
14
|
+
<a
|
|
15
|
+
:href="item.path"
|
|
16
|
+
:class="itemClass(index)"
|
|
17
|
+
>
|
|
18
|
+
<span v-html="getIconHtml(index)" />
|
|
19
|
+
<p>{{ item.name }}</p>
|
|
20
|
+
</a>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<!-- 内部路由 -->
|
|
24
|
+
<template v-else>
|
|
25
|
+
<router-link
|
|
26
|
+
:to="item.path"
|
|
27
|
+
:class="itemClass(index)"
|
|
28
|
+
>
|
|
29
|
+
<slot name="item">
|
|
30
|
+
<span v-html="getIconHtml(index)" />
|
|
31
|
+
<p>{{ item.name }}</p>
|
|
32
|
+
</slot>
|
|
33
|
+
</router-link>
|
|
34
|
+
</template>
|
|
35
|
+
</li>
|
|
36
|
+
</ul>
|
|
37
|
+
</div>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<script>
|
|
41
|
+
import { defineComponent, ref, computed, watch } from 'vue'
|
|
42
|
+
|
|
43
|
+
const prefixCls = 'dpzvc3-tab'
|
|
44
|
+
|
|
45
|
+
export default defineComponent({
|
|
46
|
+
name: 'Dpzvc3Tab',
|
|
47
|
+
props: {
|
|
48
|
+
items: { type: Array, default: () => [] },
|
|
49
|
+
modelValue: { type: Boolean, default: true },
|
|
50
|
+
index: { type: [Number, String], default: 0 },
|
|
51
|
+
border: { type: Boolean, default: true },
|
|
52
|
+
styles: { type: Object, default: () => ({}) }
|
|
53
|
+
},
|
|
54
|
+
setup (props) {
|
|
55
|
+
// 控制显示
|
|
56
|
+
const show = ref(props.modelValue)
|
|
57
|
+
|
|
58
|
+
watch(() => props.modelValue, (val) => {
|
|
59
|
+
show.value = val
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
// 计算类名和样式
|
|
63
|
+
const classes = computed(() => [prefixCls])
|
|
64
|
+
const getStyles = computed(() => ({ ...props.styles }))
|
|
65
|
+
|
|
66
|
+
// tab item 样式
|
|
67
|
+
const itemClass = (index) => {
|
|
68
|
+
const _class = [`tab-item-${index}`]
|
|
69
|
+
if (Number(props.index) === Number(index)) _class.push('cur')
|
|
70
|
+
return _class
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// icon 显示
|
|
74
|
+
const getIconHtml = (index) => {
|
|
75
|
+
const item = props.items[index]
|
|
76
|
+
if (!item) return ''
|
|
77
|
+
return Number(props.index) === Number(index) ? (item.iconCur || item.icon) : item.icon
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
show,
|
|
82
|
+
classes,
|
|
83
|
+
getStyles,
|
|
84
|
+
itemClass,
|
|
85
|
+
getIconHtml
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
</script>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
v-show="back"
|
|
4
|
+
:class="classes"
|
|
5
|
+
:style="positionStyles"
|
|
6
|
+
@click="toTop"
|
|
7
|
+
>
|
|
8
|
+
<slot>
|
|
9
|
+
<div :class="wrapperClasses" />
|
|
10
|
+
</slot>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
import { ref, computed, onMounted, onBeforeUnmount, defineComponent } from 'vue'
|
|
16
|
+
import { scrollTop } from '../../utils/util'
|
|
17
|
+
|
|
18
|
+
const prefixCls = 'dpzvc3-toTop'
|
|
19
|
+
|
|
20
|
+
export default defineComponent({
|
|
21
|
+
name: 'ToTop',
|
|
22
|
+
props: {
|
|
23
|
+
distance: {
|
|
24
|
+
type: Number,
|
|
25
|
+
default: 200
|
|
26
|
+
},
|
|
27
|
+
bottom: {
|
|
28
|
+
type: [Number, String],
|
|
29
|
+
default: 30
|
|
30
|
+
},
|
|
31
|
+
right: {
|
|
32
|
+
type: [Number, String],
|
|
33
|
+
default: 30
|
|
34
|
+
},
|
|
35
|
+
duration: {
|
|
36
|
+
type: Number,
|
|
37
|
+
default: 1000
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
setup (props) {
|
|
41
|
+
const back = ref(false)
|
|
42
|
+
|
|
43
|
+
const classes = computed(() => [prefixCls])
|
|
44
|
+
const wrapperClasses = computed(() => [`${prefixCls}-wrapper`])
|
|
45
|
+
const positionStyles = computed(() => ({
|
|
46
|
+
bottom: props.bottom + 'px',
|
|
47
|
+
right: props.right + 'px'
|
|
48
|
+
}))
|
|
49
|
+
|
|
50
|
+
// 滚动监听
|
|
51
|
+
const scroll = () => {
|
|
52
|
+
back.value = window.pageYOffset > props.distance
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const toTop = () => {
|
|
56
|
+
scrollTop(window, window.pageYOffset, 0, props.duration)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
onMounted(() => {
|
|
60
|
+
window.addEventListener('scroll', scroll, false)
|
|
61
|
+
window.addEventListener('resize', scroll, false)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
onBeforeUnmount(() => {
|
|
65
|
+
window.removeEventListener('scroll', scroll, false)
|
|
66
|
+
window.removeEventListener('resize', scroll, false)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
back,
|
|
71
|
+
classes,
|
|
72
|
+
wrapperClasses,
|
|
73
|
+
positionStyles,
|
|
74
|
+
toTop
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
</script>
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="classes"
|
|
4
|
+
:style="styles"
|
|
5
|
+
>
|
|
6
|
+
<slot>
|
|
7
|
+
<div :class="wrapperClasses">
|
|
8
|
+
图片上传
|
|
9
|
+
</div>
|
|
10
|
+
</slot>
|
|
11
|
+
<input
|
|
12
|
+
ref="upload"
|
|
13
|
+
type="file"
|
|
14
|
+
:accept="accept"
|
|
15
|
+
:multiple="multiple"
|
|
16
|
+
@change="showPhoto"
|
|
17
|
+
>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script>
|
|
22
|
+
import { ref, computed, defineComponent, getCurrentInstance, watch } from 'vue'
|
|
23
|
+
import exifr from 'exifr'
|
|
24
|
+
import MegaPixImage from '../../lib/MegaPixImage'
|
|
25
|
+
import { JPEG } from '../../utils/util'
|
|
26
|
+
|
|
27
|
+
const prefixCls = 'dpzvc3-upload'
|
|
28
|
+
|
|
29
|
+
export default defineComponent({
|
|
30
|
+
name: 'Dpzvc3Upload',
|
|
31
|
+
props: {
|
|
32
|
+
multiple: { type: Boolean, default: false },
|
|
33
|
+
accept: { type: String, default: 'image/*' },
|
|
34
|
+
styles: { type: Object, default: () => ({}) }
|
|
35
|
+
},
|
|
36
|
+
setup (props, { emit }) {
|
|
37
|
+
const { proxy } = getCurrentInstance()
|
|
38
|
+
// const $Indicator = appContext.config.globalProperties.$Indicator
|
|
39
|
+
|
|
40
|
+
const files = ref([])
|
|
41
|
+
const fileLength = ref(0)
|
|
42
|
+
const upload = ref(null)
|
|
43
|
+
|
|
44
|
+
const classes = computed(() => [prefixCls])
|
|
45
|
+
const wrapperClasses = computed(() => [`${prefixCls}-wrapper`])
|
|
46
|
+
|
|
47
|
+
watch(files, (val) => {
|
|
48
|
+
emit('on-change-file', val)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
const showPhoto = async (e) => {
|
|
52
|
+
proxy.$Indicator.snake({ text: '上传中' })
|
|
53
|
+
files.value = []
|
|
54
|
+
const fileList = e.target.files
|
|
55
|
+
fileLength.value = fileList.length
|
|
56
|
+
|
|
57
|
+
for (let i = 0; i < fileList.length; i++) {
|
|
58
|
+
const file = fileList[i]
|
|
59
|
+
try {
|
|
60
|
+
const Orientation = await exifr.orientation(file)
|
|
61
|
+
const dataURL = await new Promise((resolve, reject) => {
|
|
62
|
+
const reader = new FileReader()
|
|
63
|
+
reader.readAsDataURL(file)
|
|
64
|
+
reader.onload = () => resolve(reader.result)
|
|
65
|
+
reader.onerror = (err) => reject(err)
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const img = new Image()
|
|
69
|
+
img.src = dataURL
|
|
70
|
+
|
|
71
|
+
await new Promise((resolve) => {
|
|
72
|
+
img.onload = () => {
|
|
73
|
+
create(img, Orientation)
|
|
74
|
+
resolve()
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
} catch (err) {
|
|
78
|
+
console.error('读取图片或 EXIF 失败', err)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
e.target.value = ''
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const create = (file, Orientation) => {
|
|
86
|
+
let data = null
|
|
87
|
+
const img = new Image()
|
|
88
|
+
const mpImg = new MegaPixImage(file)
|
|
89
|
+
|
|
90
|
+
mpImg.render(img, { maxWidth: 600, quality: 0.8 })
|
|
91
|
+
img.onload = function () {
|
|
92
|
+
const canvas = document.createElement('canvas')
|
|
93
|
+
const ctx = canvas.getContext('2d')
|
|
94
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height)
|
|
95
|
+
canvas.width = img.width
|
|
96
|
+
canvas.height = img.height
|
|
97
|
+
ctx.drawImage(this, 0, 0, canvas.width, canvas.height)
|
|
98
|
+
data = canvas.toDataURL('image/jpeg', 0.8)
|
|
99
|
+
|
|
100
|
+
if (navigator.userAgent.match(/iphone/i)) {
|
|
101
|
+
if (Orientation && Orientation !== 1) {
|
|
102
|
+
switch (Orientation) {
|
|
103
|
+
case 6: rotateImg(this, 'left', canvas); break
|
|
104
|
+
case 8: rotateImg(this, 'right', canvas); break
|
|
105
|
+
case 3:
|
|
106
|
+
rotateImg(this, 'right', canvas)
|
|
107
|
+
rotateImg(this, 'right', canvas)
|
|
108
|
+
break
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
data = canvas.toDataURL('image/jpeg', 0.8)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (navigator.userAgent.match(/Android/i)) {
|
|
115
|
+
const JPEGEncoder = JPEG.JPEGEncoder
|
|
116
|
+
const encoder = new JPEGEncoder()
|
|
117
|
+
data = encoder.encode(ctx.getImageData(0, 0, canvas.width, canvas.height), 80)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const result = {
|
|
121
|
+
base64: data,
|
|
122
|
+
clearBase64: data.substr(data.indexOf(',') + 1)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
files.value.push(result)
|
|
126
|
+
|
|
127
|
+
if (files.value.length === fileLength.value) {
|
|
128
|
+
proxy.$Indicator.remove()
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const rotateImg = (img, direction, canvas) => {
|
|
134
|
+
const minStep = 0
|
|
135
|
+
const maxStep = 3
|
|
136
|
+
if (!img) return
|
|
137
|
+
const height = img.height
|
|
138
|
+
const width = img.width
|
|
139
|
+
let step = 2
|
|
140
|
+
if (direction === 'right') {
|
|
141
|
+
step++
|
|
142
|
+
step > maxStep && (step = minStep)
|
|
143
|
+
} else {
|
|
144
|
+
step--
|
|
145
|
+
step < minStep && (step = maxStep)
|
|
146
|
+
}
|
|
147
|
+
const degree = (step * 90 * Math.PI) / 180
|
|
148
|
+
const ctx = canvas.getContext('2d')
|
|
149
|
+
switch (step) {
|
|
150
|
+
case 0: canvas.width = width; canvas.height = height; ctx.drawImage(img, 0, 0, canvas.width, canvas.height); break
|
|
151
|
+
case 1: canvas.width = height; canvas.height = width; ctx.rotate(degree); ctx.drawImage(img, 0, -height, canvas.height, canvas.width); break
|
|
152
|
+
case 2: canvas.width = width; canvas.height = height; ctx.rotate(degree); ctx.drawImage(img, -width, -height, canvas.width, canvas.height); break
|
|
153
|
+
case 3: canvas.width = height; canvas.height = width; ctx.rotate(degree); ctx.drawImage(img, -width, 0, canvas.height, canvas.width); break
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
files,
|
|
159
|
+
classes,
|
|
160
|
+
wrapperClasses,
|
|
161
|
+
upload,
|
|
162
|
+
showPhoto
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
</script>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by yishide on 16/7/18.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const config = {
|
|
6
|
+
env: process.env.NODE_ENV,
|
|
7
|
+
PROJECT: 'dpzvc3',
|
|
8
|
+
VERSION: '3.0',
|
|
9
|
+
doc_title: '',
|
|
10
|
+
baseUrl: '',
|
|
11
|
+
isIPad: /ipad/i.test(window.navigator.userAgent),
|
|
12
|
+
isIphone: /iphone|ipad|ipod/i.test(window.navigator.userAgent),
|
|
13
|
+
isWechat: /MicroMessenger/i.test(window.navigator.userAgent),
|
|
14
|
+
isUCBrowser: /UCWEB|UCBrowser/i.test(window.navigator.userAgent)
|
|
15
|
+
}
|
|
16
|
+
export default config
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const clickoutsideContext = '@@clickoutsideContext'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
beforeMount (el, binding) {
|
|
5
|
+
// document 事件处理函数
|
|
6
|
+
const documentHandler = (e) => {
|
|
7
|
+
// 如果点击元素本身或其子元素,则不触发
|
|
8
|
+
if (!el.contains(e.target)) {
|
|
9
|
+
// 调用传入的方法
|
|
10
|
+
if (typeof binding.value === 'function') {
|
|
11
|
+
binding.value(e)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// 保存上下文信息到 el 上,方便解绑
|
|
17
|
+
el[clickoutsideContext] = {
|
|
18
|
+
documentHandler,
|
|
19
|
+
event: binding.arg || 'click'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
document.addEventListener(el[clickoutsideContext].event, documentHandler)
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
updated (el, binding) {
|
|
26
|
+
// 可以在更新时替换方法
|
|
27
|
+
// binding.value 已经是最新函数
|
|
28
|
+
el[clickoutsideContext].documentHandler = (e) => {
|
|
29
|
+
if (!el.contains(e.target) && typeof binding.value === 'function') {
|
|
30
|
+
binding.value(e)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
unmounted (el) {
|
|
36
|
+
document.removeEventListener(
|
|
37
|
+
el[clickoutsideContext].event,
|
|
38
|
+
el[clickoutsideContext].documentHandler
|
|
39
|
+
)
|
|
40
|
+
delete el[clickoutsideContext]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by admin on 2017/5/5.
|
|
3
|
+
*/
|
|
4
|
+
function getTarget (node) {
|
|
5
|
+
// eslint-disable-next-line no-void
|
|
6
|
+
if (node === void 0) {
|
|
7
|
+
node = document.body
|
|
8
|
+
}
|
|
9
|
+
if (node === true) { return document.body }
|
|
10
|
+
return node instanceof window.Node ? node : document.querySelector(node)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const directive = {
|
|
14
|
+
inserted (el, { value }, vnode) {
|
|
15
|
+
el.className = el.className ? el.className + ' v-transfer-dom' : 'v-transfer-dom'
|
|
16
|
+
const parentNode = el.parentNode
|
|
17
|
+
const home = document.createComment('')
|
|
18
|
+
let hasMovedOut = false
|
|
19
|
+
|
|
20
|
+
if (value !== false) {
|
|
21
|
+
parentNode.replaceChild(home, el) // moving out, el is no longer in the document
|
|
22
|
+
getTarget(value).appendChild(el) // moving into new place
|
|
23
|
+
hasMovedOut = true
|
|
24
|
+
}
|
|
25
|
+
if (!el.__transferDomData) {
|
|
26
|
+
el.__transferDomData = {
|
|
27
|
+
parentNode,
|
|
28
|
+
home,
|
|
29
|
+
target: getTarget(value),
|
|
30
|
+
hasMovedOut
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
componentUpdated (el, { value }) {
|
|
35
|
+
// need to make sure children are done updating (vs. `update`)
|
|
36
|
+
const ref$1 = el.__transferDomData
|
|
37
|
+
// homes.get(el)
|
|
38
|
+
const parentNode = ref$1.parentNode
|
|
39
|
+
const home = ref$1.home
|
|
40
|
+
const hasMovedOut = ref$1.hasMovedOut // recall where home is
|
|
41
|
+
|
|
42
|
+
if (!hasMovedOut && value) {
|
|
43
|
+
// remove from document and leave placeholder
|
|
44
|
+
parentNode.replaceChild(home, el)
|
|
45
|
+
// append to target
|
|
46
|
+
getTarget(value).appendChild(el)
|
|
47
|
+
el.__transferDomData = Object.assign({}, el.__transferDomData, { hasMovedOut: true, target: getTarget(value) })
|
|
48
|
+
} else if (hasMovedOut && value === false) {
|
|
49
|
+
// previously moved, coming back home
|
|
50
|
+
parentNode.replaceChild(el, home)
|
|
51
|
+
el.__transferDomData = Object.assign({}, el.__transferDomData, { hasMovedOut: false, target: getTarget(value) })
|
|
52
|
+
} else if (value) {
|
|
53
|
+
// already moved, going somewhere else
|
|
54
|
+
getTarget(value).appendChild(el)
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
unbind: function unbind (el, binding) {
|
|
58
|
+
el.className = el.className.replace('v-transfer-dom', '')
|
|
59
|
+
if (el.__transferDomData.hasMovedOut === true) {
|
|
60
|
+
el.__transferDomData.parentNode && el.__transferDomData.parentNode.appendChild(el)
|
|
61
|
+
}
|
|
62
|
+
el.__transferDomData = null
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default directive
|
package/src/index.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by admin on 2025/12/25.
|
|
3
|
+
* Vue 3 version
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* ========= 组件引入 ========= */
|
|
7
|
+
|
|
8
|
+
import VButton from './components/button'
|
|
9
|
+
import CheckBox from './components/checkBox'
|
|
10
|
+
import DpHeader from './components/header'
|
|
11
|
+
import Message from './components/message'
|
|
12
|
+
import Modal from './components/modal'
|
|
13
|
+
import Picker from './components/picker'
|
|
14
|
+
import RadioBox from './components/radioBox'
|
|
15
|
+
import Swipe from './components/swipe'
|
|
16
|
+
import Tab from './components/tab'
|
|
17
|
+
import Prompt from './components/prompt'
|
|
18
|
+
import SlideBar from './components/slideBar'
|
|
19
|
+
import TextBar from './components/Text'
|
|
20
|
+
import Upload from './components/upload'
|
|
21
|
+
import ActionSheet from './components/action-sheet'
|
|
22
|
+
import SwitchBar from './components/switchbar'
|
|
23
|
+
import Rater from './components/rater'
|
|
24
|
+
import Spinner from './components/spinner'
|
|
25
|
+
import LoadMore from './components/loadMore'
|
|
26
|
+
import Popup from './components/popup'
|
|
27
|
+
import Indicator from './components/Indicator'
|
|
28
|
+
import Progress from './components/progress'
|
|
29
|
+
import ToTop from './components/toTop'
|
|
30
|
+
import Cell from './components/cell'
|
|
31
|
+
import CellSwipe from './components/cell-swipe'
|
|
32
|
+
import Badge from './components/badge'
|
|
33
|
+
import Card from './components/card'
|
|
34
|
+
|
|
35
|
+
/* ========= 组件集合 ========= */
|
|
36
|
+
|
|
37
|
+
const components = {
|
|
38
|
+
VButton,
|
|
39
|
+
CheckBox,
|
|
40
|
+
CheckBoxGroup: CheckBox.group,
|
|
41
|
+
RadioBox,
|
|
42
|
+
RadioBoxGroup: RadioBox.group,
|
|
43
|
+
DpHeader,
|
|
44
|
+
Picker,
|
|
45
|
+
Swipe,
|
|
46
|
+
Tab,
|
|
47
|
+
SlideBar,
|
|
48
|
+
TextBar,
|
|
49
|
+
Number: TextBar.Number,
|
|
50
|
+
Upload,
|
|
51
|
+
ActionSheet,
|
|
52
|
+
SwitchBar,
|
|
53
|
+
Rater,
|
|
54
|
+
Spinner,
|
|
55
|
+
LoadMore,
|
|
56
|
+
Popup,
|
|
57
|
+
DpProgress: Progress,
|
|
58
|
+
ToTop,
|
|
59
|
+
Cell,
|
|
60
|
+
CellSwipe,
|
|
61
|
+
Badge,
|
|
62
|
+
Card
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* ========= 服务组件 ========= */
|
|
66
|
+
|
|
67
|
+
const services = {
|
|
68
|
+
Message,
|
|
69
|
+
Modal,
|
|
70
|
+
Prompt,
|
|
71
|
+
Indicator
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* ========= 给单个组件补 install(Vue 3 写法) ========= */
|
|
75
|
+
|
|
76
|
+
Object.keys(components).forEach(key => {
|
|
77
|
+
const component = components[key]
|
|
78
|
+
if (component && !component.install) {
|
|
79
|
+
component.install = (app) => {
|
|
80
|
+
app.component(key, component)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
Object.keys(services).forEach(key => {
|
|
86
|
+
const service = services[key]
|
|
87
|
+
if (service && !service.install) {
|
|
88
|
+
service.install = (app) => {
|
|
89
|
+
app.config.globalProperties[`$${key}`] = service
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
/* ========= 全量 install ========= */
|
|
95
|
+
|
|
96
|
+
const install = (app) => {
|
|
97
|
+
// if (install.installed) return
|
|
98
|
+
// install.installed = true
|
|
99
|
+
if (!app) {
|
|
100
|
+
console.warn('dpzvc3 install: app is undefined, ensure you are using Vue 3 createApp')
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
// 注册组件
|
|
104
|
+
Object.keys(components).forEach(key => {
|
|
105
|
+
app.component(key, components[key])
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
// 注册服务
|
|
109
|
+
Object.keys(services).forEach(key => {
|
|
110
|
+
app.config.globalProperties[`$${key}`] = services[key]
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* ========= 按需导出 ========= */
|
|
115
|
+
|
|
116
|
+
export {
|
|
117
|
+
VButton,
|
|
118
|
+
CheckBox,
|
|
119
|
+
DpHeader,
|
|
120
|
+
Message,
|
|
121
|
+
Modal,
|
|
122
|
+
Prompt,
|
|
123
|
+
Picker,
|
|
124
|
+
RadioBox,
|
|
125
|
+
Swipe,
|
|
126
|
+
Tab,
|
|
127
|
+
SlideBar,
|
|
128
|
+
TextBar,
|
|
129
|
+
Upload,
|
|
130
|
+
ActionSheet,
|
|
131
|
+
SwitchBar,
|
|
132
|
+
Rater,
|
|
133
|
+
Spinner,
|
|
134
|
+
LoadMore,
|
|
135
|
+
Popup,
|
|
136
|
+
Indicator,
|
|
137
|
+
Progress,
|
|
138
|
+
ToTop,
|
|
139
|
+
Cell,
|
|
140
|
+
CellSwipe,
|
|
141
|
+
Badge,
|
|
142
|
+
Card
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/* ========= 默认导出 ========= */
|
|
146
|
+
|
|
147
|
+
export default {
|
|
148
|
+
install
|
|
149
|
+
}
|