uview-plus 3.8.49 → 3.8.86
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/changelog.md +2043 -1827
- package/components/u-action-sheet/props.js +3 -1
- package/components/u-action-sheet/u-action-sheet.vue +1 -0
- package/components/u-album/props.js +3 -1
- package/components/u-alert/props.js +4 -2
- package/components/u-avatar/props.js +4 -1
- package/components/u-avatar-group/props.js +4 -1
- package/components/u-back-top/props.js +4 -1
- package/components/u-badge/props.js +4 -1
- package/components/u-barcode/u-barcode.vue +46 -15
- package/components/u-box/props.js +5 -2
- package/components/u-button/props.js +4 -1
- package/components/u-button/vue.scss +3 -3
- package/components/u-calendar/calendar.js +14 -2
- package/components/u-calendar/month.vue +41 -6
- package/components/u-calendar/props.js +63 -1
- package/components/u-calendar/u-calendar.vue +311 -2
- package/components/u-calendar-strip/props.js +3 -1
- package/components/u-canvas/u-canvas.vue +734 -423
- package/components/u-car-keyboard/props.js +3 -1
- package/components/u-card/props.js +3 -1
- package/components/u-cell/props.js +4 -1
- package/components/u-cell/u-cell.vue +1 -1
- package/components/u-cell-group/props.js +4 -1
- package/components/u-checkbox/props.js +4 -1
- package/components/u-checkbox/u-checkbox.vue +7 -3
- package/components/u-checkbox-group/props.js +3 -1
- package/components/u-circle-progress/props.js +4 -1
- package/components/u-code/props.js +4 -1
- package/components/u-code-input/props.js +4 -1
- package/components/u-col/props.js +4 -1
- package/components/u-collapse/props.js +4 -1
- package/components/u-collapse-item/props.js +4 -1
- package/components/u-color-picker/u-color-picker.vue +1 -0
- package/components/u-column-notice/props.js +4 -1
- package/components/u-count-down/props.js +4 -1
- package/components/u-count-to/props.js +4 -1
- package/components/u-cropper/u-cropper.vue +95 -51
- package/components/u-datetime-picker/props.js +4 -1
- package/components/u-divider/props.js +4 -1
- package/components/u-dragsort/u-dragsort.vue +2 -1
- package/components/u-dropdown/props.js +3 -1
- package/components/u-dropdown-item/props.js +3 -1
- package/components/u-empty/props.js +4 -1
- package/components/u-form/props.js +4 -1
- package/components/u-form-item/props.js +4 -1
- package/components/u-gap/props.js +4 -1
- package/components/u-grid/props.js +4 -1
- package/components/u-grid-item/props.js +4 -1
- package/components/u-guide/props.js +3 -1
- package/components/u-icon/props.js +4 -1
- package/components/u-icon/u-icon.vue +2 -2
- package/components/u-icon/upicon.ttf +0 -0
- package/components/u-icon/util.js +29 -7
- package/components/u-image/props.js +4 -1
- package/components/u-image/u-image.vue +280 -267
- package/components/u-index-anchor/props.js +4 -1
- package/components/u-index-item/props.js +2 -1
- package/components/u-index-list/props.js +4 -1
- package/components/u-input/props.js +3 -1
- package/components/u-input/u-input.vue +10 -1
- package/components/u-keyboard/props.js +4 -1
- package/components/u-line/props.js +4 -1
- package/components/u-line-progress/props.js +6 -3
- package/components/u-link/props.js +4 -1
- package/components/u-list/props.js +4 -1
- package/components/u-list-item/props.js +4 -1
- package/components/u-loading-icon/props.js +4 -1
- package/components/u-loading-page/props.js +3 -1
- package/components/u-loadmore/props.js +4 -1
- package/components/u-markdown/u-markdown.vue +45 -3
- package/components/u-modal/props.js +4 -1
- package/components/u-navbar/props.js +4 -2
- package/components/u-navbar/u-navbar.vue +15 -9
- package/components/u-no-network/props.js +4 -1
- package/components/u-notice-bar/props.js +4 -1
- package/components/u-notify/props.js +4 -1
- package/components/u-number-box/props.js +4 -1
- package/components/u-number-box/u-number-box.vue +2 -2
- package/components/u-number-keyboard/props.js +4 -1
- package/components/u-overlay/props.js +4 -1
- package/components/u-pagination/u-pagination.vue +60 -39
- package/components/u-parse/props.js +4 -1
- package/components/u-picker/props.js +4 -1
- package/components/u-picker/u-picker.vue +15 -0
- package/components/u-picker-column/props.js +3 -1
- package/components/u-popover/props.js +2 -1
- package/components/u-popup/props.js +4 -1
- package/components/u-poster/u-poster.vue +29 -14
- package/components/u-qrcode/qrcode.js +88 -87
- package/components/u-qrcode/u-qrcode.vue +138 -256
- package/components/u-radio/props.js +4 -1
- package/components/u-radio/u-radio.vue +7 -3
- package/components/u-radio-group/props.js +4 -1
- package/components/u-rate/props.js +4 -1
- package/components/u-read-more/props.js +4 -1
- package/components/u-row/props.js +4 -1
- package/components/u-row-notice/props.js +4 -1
- package/components/u-safe-bottom/props.js +2 -1
- package/components/u-scroll-list/props.js +4 -1
- package/components/u-search/props.js +3 -1
- package/components/u-skeleton/props.js +4 -1
- package/components/u-slider/props.js +3 -1
- package/components/u-slider/u-slider.vue +70 -28
- package/components/u-status-bar/props.js +4 -1
- package/components/u-steps/props.js +4 -1
- package/components/u-steps-item/props.js +4 -1
- package/components/u-sticky/props.js +4 -1
- package/components/u-sticky/u-sticky.vue +11 -0
- package/components/u-subsection/props.js +3 -1
- package/components/u-swipe-action/props.js +4 -1
- package/components/u-swipe-action-item/props.js +4 -1
- package/components/u-swipe-action-item/u-swipe-action-item.vue +14 -0
- package/components/u-swiper/props.js +9 -1
- package/components/u-swiper/swiper.js +1 -0
- package/components/u-swiper/u-swiper.vue +2 -0
- package/components/u-swiper-indicator/props.js +4 -1
- package/components/u-switch/props.js +4 -1
- package/components/u-tabbar/props.js +3 -1
- package/components/u-tabbar-item/props.js +4 -1
- package/components/u-table/props.js +3 -1
- package/components/u-table2/tableRow.vue +155 -69
- package/components/u-table2/u-table2.vue +328 -140
- package/components/u-tabs/props.js +4 -1
- package/components/u-tabs-item/props.js +3 -1
- package/components/u-tag/props.js +4 -1
- package/components/u-td/props.js +3 -1
- package/components/u-text/props.js +4 -1
- package/components/u-textarea/props.js +3 -1
- package/components/u-textarea/u-textarea.vue +16 -5
- package/components/u-th/props.js +3 -1
- package/components/u-toolbar/props.js +4 -1
- package/components/u-tooltip/props.js +10 -2
- package/components/u-tooltip/tooltip.js +2 -1
- package/components/u-tooltip/u-tooltip.vue +31 -3
- package/components/u-tr/props.js +3 -1
- package/components/u-transition/nvue-ani-map.js +75 -68
- package/components/u-transition/props.js +4 -1
- package/components/u-transition/transitionMixin.js +164 -163
- package/components/u-upload/props.js +4 -1
- package/components/u-upload/u-upload.vue +47 -40
- package/components/u-waterfall/u-waterfall.vue +50 -51
- package/index.js +65 -8
- package/libs/config/props.js +179 -204
- package/libs/css/components.scss +3 -0
- package/libs/function/uni-api-shims.js +29 -0
- package/libs/i18n/index.js +71 -36
- package/libs/i18n/locale-packs.js +11 -0
- package/libs/i18n/locales/all.js +23 -0
- package/libs/i18n/locales/{de.json → de.js} +1 -1
- package/libs/i18n/locales/{en.json → en.js} +2 -2
- package/libs/i18n/locales/{es.json → es.js} +1 -1
- package/libs/i18n/locales/{fr.json → fr.js} +2 -2
- package/libs/i18n/locales/{ja.json → ja.js} +1 -1
- package/libs/i18n/locales/{ko.json → ko.js} +1 -1
- package/libs/i18n/locales/{ru.json → ru.js} +1 -1
- package/libs/i18n/locales/{th.json → th.js} +1 -1
- package/libs/i18n/locales/{zh-Hans.json → zh-Hans.js} +1 -1
- package/libs/i18n/locales/{zh-Hant.json → zh-Hant.js} +1 -1
- package/libs/mixin/mixin.js +14 -4
- package/libs/util/gcanvas/bridge/bridge-weex.js +10 -5
- package/package.json +4 -5
- package/tsconfig.json +18 -0
- package/types/comps/calendar.d.ts +57 -0
- package/types/comps/checkbox.d.ts +12 -0
- package/types/comps/lineProgress.d.ts +5 -0
- package/types/comps/navbar.d.ts +3 -3
- package/types/comps/swiper.d.ts +5 -0
- package/types/comps/tooltip.d.ts +36 -1
- /package/components/u-markdown/{marked.esm.js → marked.esm.mjs} +0 -0
|
@@ -1,163 +1,164 @@
|
|
|
1
|
-
// 定义一个一定时间后自动成功的promise,让调用nextTick方法处,进入下一个then方法
|
|
2
|
-
const waitTick = () => new Promise(resolve => setTimeout(resolve, 1000 / 50))
|
|
3
|
-
// nvue动画模块实现细节抽离在外部文件
|
|
4
|
-
// #ifdef APP-NVUE
|
|
5
|
-
import animationMap from './nvue-ani-map.js'
|
|
6
|
-
// #endif
|
|
7
|
-
|
|
8
|
-
// #ifndef APP-NVUE
|
|
9
|
-
// 定义类名,通过给元素动态切换类名,赋予元素一定的css动画样式
|
|
10
|
-
const getClassNames = (name) => ({
|
|
11
|
-
enter: `u-${name}-enter u-${name}-enter-active`,
|
|
12
|
-
'enter-to': `u-${name}-enter-to u-${name}-enter-active`,
|
|
13
|
-
leave: `u-${name}-leave u-${name}-leave-active`,
|
|
14
|
-
'leave-to': `u-${name}-leave-to u-${name}-leave-active`
|
|
15
|
-
})
|
|
16
|
-
// #endif
|
|
17
|
-
|
|
18
|
-
// #ifdef APP-NVUE
|
|
19
|
-
// 引入nvue(weex)的animation动画模块,文档见:
|
|
20
|
-
// https://weex.apache.org/zh/docs/modules/animation.html#transition
|
|
21
|
-
const animation = uni.requireNativePlugin('animation')
|
|
22
|
-
const getStyle = (name) => animationMap[name]
|
|
23
|
-
// #endif
|
|
24
|
-
|
|
25
|
-
import { nextTick } from 'vue'
|
|
26
|
-
import { sleep } from '../../libs/function/index';
|
|
27
|
-
export default {
|
|
28
|
-
methods: {
|
|
29
|
-
// 组件被点击发出事件
|
|
30
|
-
clickHandler() {
|
|
31
|
-
this.$emit('click')
|
|
32
|
-
},
|
|
33
|
-
// #ifndef APP-NVUE
|
|
34
|
-
// vue版本的组件进场处理
|
|
35
|
-
async vueEnter() {
|
|
36
|
-
// 动画进入时的类名
|
|
37
|
-
const classNames = getClassNames(this.mode)
|
|
38
|
-
// 定义状态和发出动画进入前事件
|
|
39
|
-
this.status = 'enter'
|
|
40
|
-
this.$emit('beforeEnter')
|
|
41
|
-
this.inited = true
|
|
42
|
-
this.display = true
|
|
43
|
-
this.classes = classNames.enter
|
|
44
|
-
await nextTick();
|
|
45
|
-
{
|
|
46
|
-
// https://github.com/umicro/uView2.0/issues/545
|
|
47
|
-
await sleep(20)
|
|
48
|
-
// 标识动画尚未结束
|
|
49
|
-
this.$emit('enter')
|
|
50
|
-
this.transitionEnded = false
|
|
51
|
-
// 组件动画进入后触发的事件
|
|
52
|
-
this.$emit('afterEnter')
|
|
53
|
-
// 赋予组件enter-to类名
|
|
54
|
-
this.classes = classNames['enter-to']
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
// 动画离场处理
|
|
58
|
-
async vueLeave() {
|
|
59
|
-
// 如果不是展示状态,无需执行逻辑
|
|
60
|
-
if (!this.display) return
|
|
61
|
-
const classNames = getClassNames(this.mode)
|
|
62
|
-
// 标记离开状态和发出事件
|
|
63
|
-
this.status = 'leave'
|
|
64
|
-
this.$emit('beforeLeave')
|
|
65
|
-
// 获得类名
|
|
66
|
-
this.classes = classNames.leave
|
|
67
|
-
|
|
68
|
-
await nextTick();
|
|
69
|
-
{
|
|
70
|
-
// 动画正在离场的状态
|
|
71
|
-
this.transitionEnded = false
|
|
72
|
-
this.$emit('leave')
|
|
73
|
-
// 组件执行动画,到了执行的执行时间后,执行一些额外处理
|
|
74
|
-
setTimeout(this.onTransitionEnd, this.duration)
|
|
75
|
-
this.classes = classNames['leave-to']
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
// #endif
|
|
79
|
-
// #ifdef APP-NVUE
|
|
80
|
-
// nvue版本动画进场
|
|
81
|
-
async nvueEnter() {
|
|
82
|
-
// 获得样式的名称
|
|
83
|
-
const currentStyle = getStyle(this.mode)
|
|
84
|
-
// 组件动画状态和发出事件
|
|
85
|
-
this.status = 'enter'
|
|
86
|
-
this.$emit('beforeEnter')
|
|
87
|
-
// 展示生成组件元素
|
|
88
|
-
this.inited = true
|
|
89
|
-
this.display = true
|
|
90
|
-
// 在nvue安卓上,由于渲染速度慢,在弹窗,键盘,日历等组件中,渲染其中的内容需要时间
|
|
91
|
-
// 导致出现弹窗卡顿,这里让其一开始为透明状态,等一定时间渲染完成后,再让其隐藏起来,再让其按正常逻辑出现
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
.then(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
this
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
.then(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
//
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
this.transitionEnded
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
this.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
1
|
+
// 定义一个一定时间后自动成功的promise,让调用nextTick方法处,进入下一个then方法
|
|
2
|
+
const waitTick = () => new Promise(resolve => setTimeout(resolve, 1000 / 50))
|
|
3
|
+
// nvue动画模块实现细节抽离在外部文件
|
|
4
|
+
// #ifdef APP-NVUE
|
|
5
|
+
import animationMap from './nvue-ani-map.js'
|
|
6
|
+
// #endif
|
|
7
|
+
|
|
8
|
+
// #ifndef APP-NVUE
|
|
9
|
+
// 定义类名,通过给元素动态切换类名,赋予元素一定的css动画样式
|
|
10
|
+
const getClassNames = (name) => ({
|
|
11
|
+
enter: `u-${name}-enter u-${name}-enter-active`,
|
|
12
|
+
'enter-to': `u-${name}-enter-to u-${name}-enter-active`,
|
|
13
|
+
leave: `u-${name}-leave u-${name}-leave-active`,
|
|
14
|
+
'leave-to': `u-${name}-leave-to u-${name}-leave-active`
|
|
15
|
+
})
|
|
16
|
+
// #endif
|
|
17
|
+
|
|
18
|
+
// #ifdef APP-NVUE
|
|
19
|
+
// 引入nvue(weex)的animation动画模块,文档见:
|
|
20
|
+
// https://weex.apache.org/zh/docs/modules/animation.html#transition
|
|
21
|
+
const animation = uni.requireNativePlugin('animation')
|
|
22
|
+
const getStyle = (name) => animationMap[name]
|
|
23
|
+
// #endif
|
|
24
|
+
|
|
25
|
+
import { nextTick } from 'vue'
|
|
26
|
+
import { sleep } from '../../libs/function/index';
|
|
27
|
+
export default {
|
|
28
|
+
methods: {
|
|
29
|
+
// 组件被点击发出事件
|
|
30
|
+
clickHandler() {
|
|
31
|
+
this.$emit('click')
|
|
32
|
+
},
|
|
33
|
+
// #ifndef APP-NVUE
|
|
34
|
+
// vue版本的组件进场处理
|
|
35
|
+
async vueEnter() {
|
|
36
|
+
// 动画进入时的类名
|
|
37
|
+
const classNames = getClassNames(this.mode)
|
|
38
|
+
// 定义状态和发出动画进入前事件
|
|
39
|
+
this.status = 'enter'
|
|
40
|
+
this.$emit('beforeEnter')
|
|
41
|
+
this.inited = true
|
|
42
|
+
this.display = true
|
|
43
|
+
this.classes = classNames.enter
|
|
44
|
+
await nextTick();
|
|
45
|
+
{
|
|
46
|
+
// https://github.com/umicro/uView2.0/issues/545
|
|
47
|
+
await sleep(20)
|
|
48
|
+
// 标识动画尚未结束
|
|
49
|
+
this.$emit('enter')
|
|
50
|
+
this.transitionEnded = false
|
|
51
|
+
// 组件动画进入后触发的事件
|
|
52
|
+
this.$emit('afterEnter')
|
|
53
|
+
// 赋予组件enter-to类名
|
|
54
|
+
this.classes = classNames['enter-to']
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
// 动画离场处理
|
|
58
|
+
async vueLeave() {
|
|
59
|
+
// 如果不是展示状态,无需执行逻辑
|
|
60
|
+
if (!this.display) return
|
|
61
|
+
const classNames = getClassNames(this.mode)
|
|
62
|
+
// 标记离开状态和发出事件
|
|
63
|
+
this.status = 'leave'
|
|
64
|
+
this.$emit('beforeLeave')
|
|
65
|
+
// 获得类名
|
|
66
|
+
this.classes = classNames.leave
|
|
67
|
+
|
|
68
|
+
await nextTick();
|
|
69
|
+
{
|
|
70
|
+
// 动画正在离场的状态
|
|
71
|
+
this.transitionEnded = false
|
|
72
|
+
this.$emit('leave')
|
|
73
|
+
// 组件执行动画,到了执行的执行时间后,执行一些额外处理
|
|
74
|
+
setTimeout(this.onTransitionEnd, this.duration)
|
|
75
|
+
this.classes = classNames['leave-to']
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
// #endif
|
|
79
|
+
// #ifdef APP-NVUE
|
|
80
|
+
// nvue版本动画进场
|
|
81
|
+
async nvueEnter() {
|
|
82
|
+
// 获得样式的名称
|
|
83
|
+
const currentStyle = getStyle(this.mode) || getStyle('none')
|
|
84
|
+
// 组件动画状态和发出事件
|
|
85
|
+
this.status = 'enter'
|
|
86
|
+
this.$emit('beforeEnter')
|
|
87
|
+
// 展示生成组件元素
|
|
88
|
+
this.inited = true
|
|
89
|
+
this.display = true
|
|
90
|
+
// 在nvue安卓上,由于渲染速度慢,在弹窗,键盘,日历等组件中,渲染其中的内容需要时间
|
|
91
|
+
// 导致出现弹窗卡顿,这里让其一开始为透明状态,等一定时间渲染完成后,再让其隐藏起来,再让其按正常逻辑出现
|
|
92
|
+
// none 模式为页面内常驻展示,不需要预置透明
|
|
93
|
+
this.viewStyle = this.mode === 'none' ? { opacity: 1 } : {
|
|
94
|
+
opacity: 0
|
|
95
|
+
}
|
|
96
|
+
// 等待弹窗内容渲染完成
|
|
97
|
+
await nextTick();
|
|
98
|
+
{
|
|
99
|
+
// 合并样式
|
|
100
|
+
this.viewStyle = currentStyle.enter
|
|
101
|
+
Promise.resolve()
|
|
102
|
+
.then(waitTick)
|
|
103
|
+
.then(() => {
|
|
104
|
+
// 组件开始进入前的事件
|
|
105
|
+
this.$emit('enter')
|
|
106
|
+
// nvue的transition动画模块需要通过ref调用组件,注意此处的ref不同于vue的this.$refs['u-transition']用法
|
|
107
|
+
animation.transition(this.$refs['u-transition'].ref, {
|
|
108
|
+
styles: currentStyle['enter-to'],
|
|
109
|
+
duration: this.mode === 'none' ? 0 : this.duration,
|
|
110
|
+
timingFunction: this.timingFunction,
|
|
111
|
+
needLayout: false,
|
|
112
|
+
delay: 0
|
|
113
|
+
}, () => {
|
|
114
|
+
// 动画执行完毕,发出事件
|
|
115
|
+
this.$emit('afterEnter')
|
|
116
|
+
})
|
|
117
|
+
})
|
|
118
|
+
.catch(() => {})
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
nvueLeave() {
|
|
122
|
+
if (!this.display) {
|
|
123
|
+
return
|
|
124
|
+
}
|
|
125
|
+
const currentStyle = getStyle(this.mode) || getStyle('none')
|
|
126
|
+
// 定义状态和事件
|
|
127
|
+
this.status = 'leave'
|
|
128
|
+
this.$emit('beforeLeave')
|
|
129
|
+
// 合并样式
|
|
130
|
+
this.viewStyle = currentStyle.leave
|
|
131
|
+
// 放到promise中处理执行过程
|
|
132
|
+
Promise.resolve()
|
|
133
|
+
.then(waitTick) // 等待几十ms
|
|
134
|
+
.then(() => {
|
|
135
|
+
this.transitionEnded = false
|
|
136
|
+
// 动画正在离场的状态
|
|
137
|
+
this.$emit('leave')
|
|
138
|
+
animation.transition(this.$refs['u-transition'].ref, {
|
|
139
|
+
styles: currentStyle['leave-to'],
|
|
140
|
+
duration: this.mode === 'none' ? 0 : this.duration,
|
|
141
|
+
timingFunction: this.timingFunction,
|
|
142
|
+
needLayout: false,
|
|
143
|
+
delay: 0
|
|
144
|
+
}, () => {
|
|
145
|
+
this.onTransitionEnd()
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
.catch(() => {})
|
|
149
|
+
},
|
|
150
|
+
// #endif
|
|
151
|
+
// 完成过渡后触发
|
|
152
|
+
onTransitionEnd() {
|
|
153
|
+
// 如果已经是结束的状态,无需再处理
|
|
154
|
+
if (this.transitionEnded) return
|
|
155
|
+
this.transitionEnded = true
|
|
156
|
+
// 发出组件动画执行后的事件
|
|
157
|
+
this.$emit(this.status === 'leave' ? 'afterLeave' : 'afterEnter')
|
|
158
|
+
if (!this.show && this.display) {
|
|
159
|
+
this.display = false
|
|
160
|
+
this.inited = false
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
2
|
+
import UploadDefaultProps from './upload'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
4
|
+
|
|
5
|
+
const defProps = registerComponentProps(UploadDefaultProps)
|
|
3
6
|
export const props = defineMixin({
|
|
4
7
|
props: {
|
|
5
8
|
// 接受的文件类型, 可选值为all media image file video
|
|
@@ -141,8 +141,14 @@
|
|
|
141
141
|
</slot>
|
|
142
142
|
</view>
|
|
143
143
|
</template>
|
|
144
|
-
<canvas
|
|
145
|
-
|
|
144
|
+
<up-canvas
|
|
145
|
+
ref="videoThumbCanvas"
|
|
146
|
+
class="u-upload__hidden-canvas"
|
|
147
|
+
:canvas-id="videoThumbCanvasId"
|
|
148
|
+
:width="videoThumbCanvasWidth"
|
|
149
|
+
:height="videoThumbCanvasHeight"
|
|
150
|
+
bg-color="transparent"
|
|
151
|
+
></up-canvas>
|
|
146
152
|
<template v-if="isInCount">
|
|
147
153
|
<view
|
|
148
154
|
v-if="$slots.trigger"
|
|
@@ -257,7 +263,10 @@
|
|
|
257
263
|
lists: [],
|
|
258
264
|
isInCount: true,
|
|
259
265
|
popupShow: false,
|
|
260
|
-
currentItemIndex: -1
|
|
266
|
+
currentItemIndex: -1,
|
|
267
|
+
videoThumbCanvasId: 'u-upload-video-thumb-' + Math.random().toString(36).substr(2, 9),
|
|
268
|
+
videoThumbCanvasWidth: 100,
|
|
269
|
+
videoThumbCanvasHeight: 150
|
|
261
270
|
}
|
|
262
271
|
},
|
|
263
272
|
watch: {
|
|
@@ -314,47 +323,37 @@
|
|
|
314
323
|
return;
|
|
315
324
|
}
|
|
316
325
|
// 截取第一帧作为封面,oss等云存储场景直接使用拼接参数。
|
|
317
|
-
|
|
318
|
-
|
|
326
|
+
const w = this.lists[this.currentItemIndex].width;
|
|
327
|
+
const h = this.lists[this.currentItemIndex].height;
|
|
319
328
|
const dpr = uni.getSystemInfoSync().pixelRatio;
|
|
320
329
|
uni.createSelectorQuery().select('#myVideo').context(res => {
|
|
321
330
|
console.log('select video', res)
|
|
322
331
|
const myVideo = res.context
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
console.error('Failed to export image:', err)
|
|
349
|
-
}
|
|
350
|
-
})
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
// Capture the first frame
|
|
354
|
-
setInterval(() => {
|
|
355
|
-
ctx1.drawImage(myVideo, 0, 0, w * dpr, h * dpr);
|
|
356
|
-
}, 1000 / 24)
|
|
357
|
-
}).exec()
|
|
332
|
+
this.videoThumbCanvasWidth = w
|
|
333
|
+
this.videoThumbCanvasHeight = h
|
|
334
|
+
this.$nextTick(async () => {
|
|
335
|
+
const canvas = this.$refs.videoThumbCanvas
|
|
336
|
+
if (!canvas || !myVideo) return
|
|
337
|
+
await canvas.initCanvas(true)
|
|
338
|
+
const ctx1 = canvas.getRawContext()
|
|
339
|
+
if (!ctx1) return
|
|
340
|
+
setTimeout(async () => {
|
|
341
|
+
try {
|
|
342
|
+
ctx1.drawImage(myVideo, 0, 0, w, h)
|
|
343
|
+
const result = await canvas.toTempFilePath({
|
|
344
|
+
width: w,
|
|
345
|
+
height: h,
|
|
346
|
+
destWidth: w * dpr,
|
|
347
|
+
destHeight: h * dpr
|
|
348
|
+
})
|
|
349
|
+
console.log('First frame image path:', result.tempFilePath)
|
|
350
|
+
this.fileList[this.currentItemIndex].thumb = result.tempFilePath
|
|
351
|
+
this.$emit('update:fileList', this.fileList)
|
|
352
|
+
} catch (err) {
|
|
353
|
+
console.error('Failed to export image:', err)
|
|
354
|
+
}
|
|
355
|
+
}, 500)
|
|
356
|
+
})
|
|
358
357
|
}).exec()
|
|
359
358
|
},
|
|
360
359
|
formatFileList() {
|
|
@@ -822,6 +821,14 @@
|
|
|
822
821
|
}
|
|
823
822
|
}
|
|
824
823
|
}
|
|
824
|
+
|
|
825
|
+
&__hidden-canvas {
|
|
826
|
+
position: fixed;
|
|
827
|
+
top: -10000px;
|
|
828
|
+
left: -10000px;
|
|
829
|
+
z-index: -1;
|
|
830
|
+
}
|
|
831
|
+
|
|
825
832
|
&__wrap__play {
|
|
826
833
|
position: absolute;
|
|
827
834
|
top: 0px;
|
|
@@ -247,59 +247,58 @@
|
|
|
247
247
|
|
|
248
248
|
// 分配新数据到最短的列
|
|
249
249
|
for (let item of newData) {
|
|
250
|
-
const minHeightIndex =
|
|
251
|
-
// console.log('this.columnList', this.columnList)
|
|
252
|
-
this.columnList[minHeightIndex].push(item);
|
|
253
|
-
|
|
254
|
-
// 获取实际渲染后的元素高度而不是估算
|
|
255
|
-
await sleep(this.addTime)
|
|
256
|
-
await this.$nextTick(
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
// this.$nextTick(async () => {
|
|
274
|
-
// try {
|
|
275
|
-
// // 等待DOM更新后获取实际高度
|
|
276
|
-
// const lastIndex = this.columnList[minHeightIndex].length - 1;
|
|
277
|
-
// const el = this.$refs[`u-column-${minHeightIndex}`][0].children[lastIndex];
|
|
278
|
-
// if (el) {
|
|
279
|
-
// const rect = await this.$uGetRect(el);
|
|
280
|
-
// const actualHeight = rect.height || 100;
|
|
281
|
-
// columnHeights[minHeightIndex] += actualHeight;
|
|
282
|
-
// } else {
|
|
283
|
-
// // 备用方案:如果无法获取实际高度,则使用默认值
|
|
284
|
-
// columnHeights[minHeightIndex] += 100;
|
|
285
|
-
// }
|
|
286
|
-
// } catch (e) {
|
|
287
|
-
// // 出错时使用默认高度
|
|
288
|
-
// console.log(e)
|
|
289
|
-
// columnHeights[minHeightIndex] += 100;
|
|
290
|
-
// }
|
|
291
|
-
// });
|
|
292
|
-
}
|
|
250
|
+
const minHeightIndex = this.getMinHeightColumnIndex(columnHeights);
|
|
251
|
+
// console.log('this.columnList', this.columnList)
|
|
252
|
+
this.columnList[minHeightIndex].push(item);
|
|
253
|
+
|
|
254
|
+
// 获取实际渲染后的元素高度而不是估算
|
|
255
|
+
await sleep(this.addTime);
|
|
256
|
+
await this.$nextTick();
|
|
257
|
+
try {
|
|
258
|
+
const rect = await this.$uGetRect(`#u-column-${minHeightIndex}`);
|
|
259
|
+
// console.log(`#u-column-${minHeightIndex}`, rect.height)
|
|
260
|
+
if (rect.height) {
|
|
261
|
+
columnHeights[minHeightIndex] = rect.height;
|
|
262
|
+
// 加载一个后置事件
|
|
263
|
+
this.$emit('after-add-one', {
|
|
264
|
+
...item,
|
|
265
|
+
height: rect.height
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
} catch (e) {
|
|
269
|
+
// console.log(e)
|
|
270
|
+
// columnHeights[i] = 0;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
293
273
|
// 加载所有后置事件
|
|
294
274
|
this.$emit('after-add-all', {
|
|
295
275
|
columnHeights: columnHeights,
|
|
296
|
-
newData: newData
|
|
297
|
-
});
|
|
298
|
-
},
|
|
299
|
-
|
|
300
|
-
//
|
|
301
|
-
|
|
302
|
-
|
|
276
|
+
newData: newData
|
|
277
|
+
});
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
// 获取最短列;高度相同或暂不可测时按列数据量打散,避免全部落到第一列
|
|
281
|
+
getMinHeightColumnIndex(columnHeights) {
|
|
282
|
+
let minIndex = 0;
|
|
283
|
+
for (let i = 1; i < columnHeights.length; i++) {
|
|
284
|
+
const currentHeight = Number(columnHeights[i]) || 0;
|
|
285
|
+
const minHeight = Number(columnHeights[minIndex]) || 0;
|
|
286
|
+
if (currentHeight < minHeight) {
|
|
287
|
+
minIndex = i;
|
|
288
|
+
} else if (currentHeight === minHeight) {
|
|
289
|
+
const currentLength = this.columnList[i] ? this.columnList[i].length : 0;
|
|
290
|
+
const minLength = this.columnList[minIndex] ? this.columnList[minIndex].length : 0;
|
|
291
|
+
if (currentLength < minLength) {
|
|
292
|
+
minIndex = i;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return minIndex;
|
|
297
|
+
},
|
|
298
|
+
|
|
299
|
+
// 复制而不是引用对象和数组
|
|
300
|
+
cloneData(data) {
|
|
301
|
+
return JSON.parse(JSON.stringify(data));
|
|
303
302
|
},
|
|
304
303
|
|
|
305
304
|
// 清空数据列表
|
|
@@ -413,4 +412,4 @@
|
|
|
413
412
|
max-width: 100%;
|
|
414
413
|
/* #endif */
|
|
415
414
|
}
|
|
416
|
-
</style>
|
|
415
|
+
</style>
|