@netang/quasar 0.2.6 → 0.2.8
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/dialog/img-viewer/index.vue +57 -17
- package/components/img/index.vue +0 -2
- package/components/uploader/index.vue +5 -0
- package/components/uploader-query/index.vue +18 -1
- package/package.json +1 -1
- package/utils/config.js +15 -7
- package/utils/getFile.js +9 -4
- package/utils/getImage.js +11 -2
- package/utils/index.js +2 -0
- package/utils/play.js +40 -0
- package/utils/uploader.js +578 -108
- package/utils/useFileUrl.js +4 -4
- package/utils/useUploader.js +0 -303
|
@@ -102,23 +102,44 @@
|
|
|
102
102
|
</div>
|
|
103
103
|
</div>
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
105
|
+
|
|
106
|
+
<!-- 图片列表(有点击事件) -->
|
|
107
|
+
<template v-if="isClickImg">
|
|
108
|
+
<div
|
|
109
|
+
v-for="(src, i) in currentImages"
|
|
110
|
+
:key="`${src}-${i}`"
|
|
111
|
+
class="non-selectable no-outline"
|
|
112
|
+
@click="onClickImg({ src })"
|
|
113
|
+
>
|
|
114
|
+
<img
|
|
115
|
+
:ref="(el) => (imgRefs[i] = el)"
|
|
116
|
+
:src="src"
|
|
117
|
+
:style="imgStyle"
|
|
118
|
+
@load="handleImgLoad"
|
|
119
|
+
@error="handleImgError"
|
|
120
|
+
v-show="i === activeIndex"
|
|
121
|
+
/>
|
|
122
|
+
</div>
|
|
123
|
+
</template>
|
|
124
|
+
<!-- 图片列表(点击跳转原图) -->
|
|
125
|
+
<template v-else>
|
|
126
|
+
<a
|
|
127
|
+
v-for="(src, i) in currentImages"
|
|
128
|
+
:key="`${src}-${i}`"
|
|
129
|
+
:href="src"
|
|
130
|
+
target="_blank"
|
|
131
|
+
class="non-selectable no-outline"
|
|
132
|
+
>
|
|
133
|
+
<img
|
|
134
|
+
:ref="(el) => (imgRefs[i] = el)"
|
|
135
|
+
:src="src"
|
|
136
|
+
:style="imgStyle"
|
|
137
|
+
@load="handleImgLoad"
|
|
138
|
+
@error="handleImgError"
|
|
139
|
+
v-show="i === activeIndex"
|
|
140
|
+
/>
|
|
141
|
+
</a>
|
|
142
|
+
</template>
|
|
122
143
|
|
|
123
144
|
</div>
|
|
124
145
|
</q-dialog>
|
|
@@ -128,10 +149,15 @@
|
|
|
128
149
|
import { computed, nextTick, onMounted, ref, watch } from 'vue'
|
|
129
150
|
import { useDialogPluginComponent } from 'quasar'
|
|
130
151
|
|
|
152
|
+
import $n_get from 'lodash/get'
|
|
153
|
+
|
|
131
154
|
import $n_forEach from '@netang/utils/forEach'
|
|
155
|
+
import $n_run from '@netang/utils/run'
|
|
132
156
|
|
|
133
157
|
import $n_getImage from '../../../utils/getImage'
|
|
134
158
|
|
|
159
|
+
import { configs } from '../../../utils/config'
|
|
160
|
+
|
|
135
161
|
export default {
|
|
136
162
|
|
|
137
163
|
/**
|
|
@@ -259,6 +285,9 @@ export default {
|
|
|
259
285
|
// 模式
|
|
260
286
|
const isContain = ref(true)
|
|
261
287
|
|
|
288
|
+
// 图片是否可点击
|
|
289
|
+
const isClickImg = ref($n_get(configs, 'components.imgViewer.isClickImg') === true)
|
|
290
|
+
|
|
262
291
|
// 转换效果
|
|
263
292
|
const transform = ref({
|
|
264
293
|
scale: 1,
|
|
@@ -519,6 +548,13 @@ export default {
|
|
|
519
548
|
}
|
|
520
549
|
}
|
|
521
550
|
|
|
551
|
+
/**
|
|
552
|
+
* 点击图片
|
|
553
|
+
*/
|
|
554
|
+
function onClickImg(e) {
|
|
555
|
+
$n_run($n_get(configs, 'components.imgViewer.onClickImg'))(e)
|
|
556
|
+
}
|
|
557
|
+
|
|
522
558
|
// ==========【声明周期】=========================================================================================
|
|
523
559
|
|
|
524
560
|
/**
|
|
@@ -551,6 +587,8 @@ export default {
|
|
|
551
587
|
isContain,
|
|
552
588
|
// 转换效果
|
|
553
589
|
transform,
|
|
590
|
+
// 图片是否可点击
|
|
591
|
+
isClickImg,
|
|
554
592
|
|
|
555
593
|
// 当前图片数组
|
|
556
594
|
currentImages,
|
|
@@ -583,6 +621,8 @@ export default {
|
|
|
583
621
|
handleActions,
|
|
584
622
|
// 点击遮蔽
|
|
585
623
|
onMask,
|
|
624
|
+
// 点击图片
|
|
625
|
+
onClickImg,
|
|
586
626
|
}
|
|
587
627
|
}
|
|
588
628
|
}
|
package/components/img/index.vue
CHANGED
|
@@ -39,6 +39,8 @@ export default {
|
|
|
39
39
|
props: {
|
|
40
40
|
// 值
|
|
41
41
|
modelValue: [String, Array],
|
|
42
|
+
// 上传器类型
|
|
43
|
+
uploaderType: String,
|
|
42
44
|
// 上传文件类型, 可选值 file image video audio
|
|
43
45
|
type: {
|
|
44
46
|
type: String,
|
|
@@ -99,6 +101,9 @@ export default {
|
|
|
99
101
|
|
|
100
102
|
// 创建上传器
|
|
101
103
|
const uploader = $n_uploader.create({
|
|
104
|
+
// 上传器类型
|
|
105
|
+
uploaderType: props.uploaderType,
|
|
106
|
+
// 上传文件类型, 可选值 file image video audio
|
|
102
107
|
type: props.type,
|
|
103
108
|
// 声明属性
|
|
104
109
|
props,
|
|
@@ -315,6 +315,21 @@
|
|
|
315
315
|
/>
|
|
316
316
|
|
|
317
317
|
<!-- 播放图标 -->
|
|
318
|
+
<n-thumbnail
|
|
319
|
+
class="rounded-borders cursor-pointer"
|
|
320
|
+
:src="fileItem.json.p"
|
|
321
|
+
:size="currentSize / 1.5"
|
|
322
|
+
title="播放"
|
|
323
|
+
@click.prevent.stop="uploader.play(fileItem)"
|
|
324
|
+
v-else-if="fileItem.json.p"
|
|
325
|
+
>
|
|
326
|
+
<div class="absolute-full no-padding row items-center justify-center">
|
|
327
|
+
<q-icon
|
|
328
|
+
name="play_circle"
|
|
329
|
+
:size="toPx(currentSize / 3)"
|
|
330
|
+
/>
|
|
331
|
+
</div>
|
|
332
|
+
</n-thumbnail>
|
|
318
333
|
<q-icon
|
|
319
334
|
class="n-uploader-query__item__icon__icon cursor-pointer"
|
|
320
335
|
name="play_circle"
|
|
@@ -431,13 +446,14 @@ import $n_getImage from '../../utils/getImage'
|
|
|
431
446
|
import $n_previewImage from '../../utils/previewImage'
|
|
432
447
|
|
|
433
448
|
import NDragger from '../dragger'
|
|
449
|
+
import NThumbnail from '../thumbnail'
|
|
434
450
|
|
|
435
451
|
import { NUploaderKey } from '../../utils/symbols'
|
|
436
452
|
|
|
437
453
|
import {
|
|
438
454
|
// 上传状态
|
|
439
455
|
UPLOAD_STATUS,
|
|
440
|
-
} from '../../utils/
|
|
456
|
+
} from '../../utils/uploader'
|
|
441
457
|
|
|
442
458
|
export default {
|
|
443
459
|
|
|
@@ -451,6 +467,7 @@ export default {
|
|
|
451
467
|
*/
|
|
452
468
|
components: {
|
|
453
469
|
NDragger,
|
|
470
|
+
NThumbnail,
|
|
454
471
|
},
|
|
455
472
|
|
|
456
473
|
/**
|
package/package.json
CHANGED
package/utils/config.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import $n_get from 'lodash/get'
|
|
2
|
+
import $n_merge from 'lodash/merge'
|
|
2
3
|
|
|
3
4
|
// 用户配置 参数
|
|
4
5
|
// userConfig: {
|
|
@@ -26,14 +27,21 @@ export const configs = {
|
|
|
26
27
|
routers: {},
|
|
27
28
|
// 表格配置
|
|
28
29
|
tablesConfig: {},
|
|
30
|
+
// 组件配置
|
|
31
|
+
components: {},
|
|
29
32
|
// 对话框组件
|
|
30
33
|
dialogComponents: {},
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
// 上传器配置
|
|
35
|
+
uploader: {
|
|
36
|
+
// 如果是 Minio 上传, 则在后面加上下划线
|
|
37
|
+
hasMinioSuffix: true,
|
|
38
|
+
// 格式化上传文件 hash
|
|
39
|
+
formatUploadFileHash: null,
|
|
40
|
+
// 格式化上传网络链接
|
|
41
|
+
formatUploadNet: null,
|
|
42
|
+
// 获取文件地址
|
|
43
|
+
getFileUrl: null,
|
|
44
|
+
},
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
/**
|
|
@@ -41,7 +49,7 @@ export const configs = {
|
|
|
41
49
|
* @param options
|
|
42
50
|
*/
|
|
43
51
|
export function settings(options) {
|
|
44
|
-
|
|
52
|
+
$n_merge(configs, options)
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
/**
|
package/utils/getFile.js
CHANGED
|
@@ -50,11 +50,16 @@ export default function getFile(src) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
const {
|
|
53
|
-
|
|
53
|
+
type,
|
|
54
54
|
domain,
|
|
55
|
-
} = $n_uploader.getUpload(
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
} = $n_uploader.getUpload(
|
|
56
|
+
null,
|
|
57
|
+
src && src.slice(-1) === '_'
|
|
58
|
+
? 'minio'
|
|
59
|
+
: ''
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
return useFileUrl({ type, domain, src })
|
|
58
63
|
}
|
|
59
64
|
}
|
|
60
65
|
|
package/utils/getImage.js
CHANGED
|
@@ -130,7 +130,16 @@ export default function getImage(src, options) {
|
|
|
130
130
|
const {
|
|
131
131
|
type,
|
|
132
132
|
domain,
|
|
133
|
-
} = $n_uploader.getUpload(
|
|
133
|
+
} = $n_uploader.getUpload(
|
|
134
|
+
null,
|
|
135
|
+
$n_has(options, 'upload')
|
|
136
|
+
? options.upload
|
|
137
|
+
: (
|
|
138
|
+
src && src.slice(-1) === '_'
|
|
139
|
+
? 'minio'
|
|
140
|
+
: ''
|
|
141
|
+
)
|
|
142
|
+
)
|
|
134
143
|
|
|
135
144
|
// 判断图片上传方式
|
|
136
145
|
switch (type) {
|
|
@@ -219,7 +228,7 @@ export default function getImage(src, options) {
|
|
|
219
228
|
// #endif
|
|
220
229
|
// --------------------------------------------------
|
|
221
230
|
|
|
222
|
-
return useFileUrl(domain, src)
|
|
231
|
+
return useFileUrl({ type, domain, src })
|
|
223
232
|
}
|
|
224
233
|
}
|
|
225
234
|
|
package/utils/index.js
CHANGED
|
@@ -24,6 +24,7 @@ import getImage from './getImage'
|
|
|
24
24
|
import getTime from './getTime'
|
|
25
25
|
import loading from './loading'
|
|
26
26
|
import notify from './notify'
|
|
27
|
+
import play from './play'
|
|
27
28
|
import previewImage from './previewImage'
|
|
28
29
|
import price from './price'
|
|
29
30
|
import timestamp from './timestamp'
|
|
@@ -57,6 +58,7 @@ export default {
|
|
|
57
58
|
getTime,
|
|
58
59
|
loading,
|
|
59
60
|
notify,
|
|
61
|
+
play,
|
|
60
62
|
previewImage,
|
|
61
63
|
price,
|
|
62
64
|
timestamp,
|
package/utils/play.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Platform, Screen, Dialog } from 'quasar'
|
|
2
|
+
|
|
3
|
+
import $n_getFile from './getFile'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 播放视频 / 音频
|
|
7
|
+
*/
|
|
8
|
+
export default function play(hash) {
|
|
9
|
+
|
|
10
|
+
const src = $n_getFile(hash)
|
|
11
|
+
|
|
12
|
+
let width
|
|
13
|
+
let height
|
|
14
|
+
let fullWidth = false
|
|
15
|
+
let fullHeight = false
|
|
16
|
+
let ok = true
|
|
17
|
+
let style = ''
|
|
18
|
+
|
|
19
|
+
if (Platform.is.mobile) {
|
|
20
|
+
width = Screen.width - 48 - 32
|
|
21
|
+
height = Screen.height - 48 - 32 - 6 - 52
|
|
22
|
+
fullWidth = true
|
|
23
|
+
fullHeight = true
|
|
24
|
+
} else {
|
|
25
|
+
width = 800 - 32
|
|
26
|
+
height = 400 - 32 - 6
|
|
27
|
+
ok = false
|
|
28
|
+
style = 'width:800px;max-width:800px;height:400px;max-height:400px;'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
Dialog.create({
|
|
32
|
+
message: `<video style="width:${width}px;height:${height}px;" playsinline autoplay controls src="${src}" type="video/mp4" muted="muted"></video>`,
|
|
33
|
+
style,
|
|
34
|
+
html: true,
|
|
35
|
+
dark: true,
|
|
36
|
+
ok,
|
|
37
|
+
fullWidth,
|
|
38
|
+
fullHeight,
|
|
39
|
+
})
|
|
40
|
+
}
|