@netang/quasar 0.1.63 → 0.1.65
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/uploader-query/index.vue +64 -18
- package/package.json +1 -1
- package/utils/$power.js +32 -0
- package/utils/uploader.js +42 -13
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
@dragend="dragEnd"
|
|
78
78
|
>
|
|
79
79
|
<n-img
|
|
80
|
-
:src="
|
|
80
|
+
:src="currentQuery[fileItemIndex].src"
|
|
81
81
|
:spinner-size="toPx(currentSize / 2)"
|
|
82
82
|
:width="toPx(currentSize)"
|
|
83
83
|
:height="toPx(currentSize)"
|
|
@@ -146,9 +146,9 @@
|
|
|
146
146
|
name="search"
|
|
147
147
|
:size="settingsIconSize"
|
|
148
148
|
title="预览"
|
|
149
|
-
@click="
|
|
149
|
+
@click="previewImage(fileItemIndex)"
|
|
150
150
|
v-bind="settingsIconProps"
|
|
151
|
-
v-if="! noPreview &&
|
|
151
|
+
v-if="! noPreview && currentQuery[fileItemIndex].preview_src"
|
|
152
152
|
/>
|
|
153
153
|
|
|
154
154
|
<!-- 删除 -->
|
|
@@ -361,10 +361,12 @@ import $n_has from 'lodash/has'
|
|
|
361
361
|
import $n_get from 'lodash/get'
|
|
362
362
|
|
|
363
363
|
import $n_px from '@netang/utils/px'
|
|
364
|
+
import $n_forEach from '@netang/utils/forEach'
|
|
364
365
|
import $n_isValidArray from '@netang/utils/isValidArray'
|
|
365
366
|
import $n_isValidString from '@netang/utils/isValidString'
|
|
366
367
|
|
|
367
368
|
import $n_getImage from '../../utils/getImage'
|
|
369
|
+
import $n_previewImage from '../../utils/previewImage'
|
|
368
370
|
|
|
369
371
|
import NDragger from '../dragger'
|
|
370
372
|
|
|
@@ -463,12 +465,55 @@ export default {
|
|
|
463
465
|
|
|
464
466
|
// ==========【计算属性】=========================================================================================
|
|
465
467
|
|
|
468
|
+
/**
|
|
469
|
+
* 当前上传文件队列
|
|
470
|
+
*/
|
|
471
|
+
const currentQuery = computed(function () {
|
|
472
|
+
|
|
473
|
+
// 如果不是图片
|
|
474
|
+
if (uploaderProps.type !== 'image') {
|
|
475
|
+
if ($n_isValidArray(query.value)) {
|
|
476
|
+
return query.value
|
|
477
|
+
}
|
|
478
|
+
return []
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
const lists = []
|
|
482
|
+
|
|
483
|
+
$n_forEach(query.value, function (fileItem) {
|
|
484
|
+
const newItem = Object.assign({}, fileItem)
|
|
485
|
+
|
|
486
|
+
let src = ''
|
|
487
|
+
let preview_src = ''
|
|
488
|
+
|
|
489
|
+
if ($n_has(fileItem, '__img')) {
|
|
490
|
+
src = fileItem.__img
|
|
491
|
+
preview_src = src
|
|
492
|
+
} else if ($n_isValidString(fileItem.hash)) {
|
|
493
|
+
src = $n_getImage(fileItem.hash, { w: $q.platform.is.mobile ? currentSize.value * 2 : currentSize.value })
|
|
494
|
+
if (src) {
|
|
495
|
+
// 预览地址
|
|
496
|
+
preview_src = fileItem.hash
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
lists.push(Object.assign(newItem, {
|
|
501
|
+
// 图片地址
|
|
502
|
+
src,
|
|
503
|
+
// 预览地址
|
|
504
|
+
preview_src,
|
|
505
|
+
}))
|
|
506
|
+
})
|
|
507
|
+
|
|
508
|
+
return lists
|
|
509
|
+
})
|
|
510
|
+
|
|
511
|
+
|
|
466
512
|
/**
|
|
467
513
|
* 当前是否开启拖拽
|
|
468
514
|
*/
|
|
469
515
|
const currentDrag = computed(function() {
|
|
470
516
|
return props.drag
|
|
471
|
-
&& $n_isValidArray(query.value)
|
|
472
517
|
&& query.value.length > 1
|
|
473
518
|
&& ! props.readonly
|
|
474
519
|
&& ! props.disable
|
|
@@ -500,8 +545,8 @@ export default {
|
|
|
500
545
|
const showSquareButton = computed(function () {
|
|
501
546
|
// 自动显示方块按钮 && 有上传文件限制数量
|
|
502
547
|
return props.autoShowSquareButton && uploaderProps.count > 0 ?
|
|
503
|
-
// 如果
|
|
504
|
-
|
|
548
|
+
// 如果 当前上传文件队列数量 < 上传文件限制数量
|
|
549
|
+
currentQuery.value.length < uploaderProps.count
|
|
505
550
|
// 始终显示
|
|
506
551
|
: true
|
|
507
552
|
})
|
|
@@ -509,16 +554,15 @@ export default {
|
|
|
509
554
|
// ==========【方法】=============================================================================================
|
|
510
555
|
|
|
511
556
|
/**
|
|
512
|
-
*
|
|
557
|
+
* 预览图片
|
|
513
558
|
*/
|
|
514
|
-
function
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
: (
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
)
|
|
559
|
+
function previewImage(startPosition) {
|
|
560
|
+
$n_previewImage({
|
|
561
|
+
// 需要预览的图片 URL 数组
|
|
562
|
+
images: currentQuery.value.map(e => e.preview_src),
|
|
563
|
+
// 图片预览起始位置索引
|
|
564
|
+
startPosition,
|
|
565
|
+
})
|
|
522
566
|
}
|
|
523
567
|
|
|
524
568
|
/**
|
|
@@ -538,8 +582,10 @@ export default {
|
|
|
538
582
|
type: uploaderProps.type,
|
|
539
583
|
// 上传文件数量(0:不限)
|
|
540
584
|
count: uploaderProps.count,
|
|
541
|
-
//
|
|
585
|
+
// 文件队列
|
|
542
586
|
query,
|
|
587
|
+
// 当前上传文件队列
|
|
588
|
+
currentQuery,
|
|
543
589
|
|
|
544
590
|
// 当前是否开启拖拽
|
|
545
591
|
currentDrag,
|
|
@@ -553,8 +599,8 @@ export default {
|
|
|
553
599
|
// 上传器
|
|
554
600
|
uploader,
|
|
555
601
|
|
|
556
|
-
//
|
|
557
|
-
|
|
602
|
+
// 预览图片
|
|
603
|
+
previewImage,
|
|
558
604
|
// 获取文件名称
|
|
559
605
|
getFileName,
|
|
560
606
|
|
package/package.json
CHANGED
package/utils/$power.js
CHANGED
|
@@ -1358,6 +1358,36 @@ function getPageData($route) {
|
|
|
1358
1358
|
})
|
|
1359
1359
|
}
|
|
1360
1360
|
|
|
1361
|
+
/**
|
|
1362
|
+
* 新窗口
|
|
1363
|
+
*/
|
|
1364
|
+
function routerPush({ path, query, pageTitle, fromPage }) {
|
|
1365
|
+
|
|
1366
|
+
if (! $n_isValidObject(query)) {
|
|
1367
|
+
query = {}
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
// 如果有标题
|
|
1371
|
+
pageTitle = $n_trimString(pageTitle)
|
|
1372
|
+
if (pageTitle) {
|
|
1373
|
+
query.n_page_title = pageTitle
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
// 来源页面
|
|
1377
|
+
if (fromPage) {
|
|
1378
|
+
if (fromPage === true) {
|
|
1379
|
+
fromPage = $n_router.getRoute().fullPath
|
|
1380
|
+
}
|
|
1381
|
+
// 来源页面是指定路由的完整路径
|
|
1382
|
+
query.n_from_page = encodeURIComponent(fromPage)
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
$n_router.push({
|
|
1386
|
+
path,
|
|
1387
|
+
query,
|
|
1388
|
+
})
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1361
1391
|
/**
|
|
1362
1392
|
* 权限业务
|
|
1363
1393
|
*/
|
|
@@ -1374,6 +1404,8 @@ const $power = {
|
|
|
1374
1404
|
formatBtns,
|
|
1375
1405
|
// 请求
|
|
1376
1406
|
request,
|
|
1407
|
+
// 新窗口
|
|
1408
|
+
routerPush,
|
|
1377
1409
|
}
|
|
1378
1410
|
|
|
1379
1411
|
export default $power
|
package/utils/uploader.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ref, isRef, } from 'vue'
|
|
2
|
+
import { useQuasar } from 'quasar'
|
|
2
3
|
import SparkMD5 from 'spark-md5'
|
|
3
4
|
|
|
4
5
|
import $n_has from 'lodash/has'
|
|
@@ -57,6 +58,9 @@ function create(options) {
|
|
|
57
58
|
|
|
58
59
|
// ==========【数据】=========================================================================================
|
|
59
60
|
|
|
61
|
+
// quasar 对象
|
|
62
|
+
const $q = useQuasar()
|
|
63
|
+
|
|
60
64
|
const {
|
|
61
65
|
// 上传文件输入框节点
|
|
62
66
|
fileRef,
|
|
@@ -1387,25 +1391,50 @@ function create(options) {
|
|
|
1387
1391
|
/**
|
|
1388
1392
|
* 播放
|
|
1389
1393
|
*/
|
|
1390
|
-
function play(
|
|
1391
|
-
|
|
1392
|
-
$
|
|
1393
|
-
|
|
1394
|
+
function play({ hash, __img }) {
|
|
1395
|
+
|
|
1396
|
+
const src = __img ? __img : $n_getFile(hash)
|
|
1397
|
+
|
|
1398
|
+
let width
|
|
1399
|
+
let height
|
|
1400
|
+
let fullWidth = false
|
|
1401
|
+
let fullHeight = false
|
|
1402
|
+
let ok = true
|
|
1403
|
+
let style = ''
|
|
1404
|
+
|
|
1405
|
+
if ($q.platform.is.mobile) {
|
|
1406
|
+
width = $q.screen.width - 48 - 32
|
|
1407
|
+
height = $q.screen.height - 48 - 32 - 6 - 52
|
|
1408
|
+
fullWidth = true
|
|
1409
|
+
fullHeight = true
|
|
1410
|
+
} else {
|
|
1411
|
+
width = 800 - 32
|
|
1412
|
+
height = 400 - 32 - 6
|
|
1413
|
+
ok = false
|
|
1414
|
+
style = 'width:800px;max-width:800px;height:400px;max-height:400px;'
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
$q.dialog({
|
|
1418
|
+
message: `<video style="width:${width}px;height:${height}px;" playsinline autoplay controls src="${src}" type="video/mp4" muted="muted"></video>`,
|
|
1419
|
+
style,
|
|
1420
|
+
html: true,
|
|
1421
|
+
dark: true,
|
|
1422
|
+
ok,
|
|
1423
|
+
fullWidth,
|
|
1424
|
+
fullHeight,
|
|
1394
1425
|
})
|
|
1395
1426
|
}
|
|
1396
1427
|
|
|
1397
1428
|
/**
|
|
1398
1429
|
* 复制地址
|
|
1399
1430
|
*/
|
|
1400
|
-
function copyUrl({ type, hash
|
|
1401
|
-
|
|
1402
|
-
const _url =
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
: $n_getFile(hash)
|
|
1408
|
-
)
|
|
1431
|
+
function copyUrl({ type, hash }) {
|
|
1432
|
+
|
|
1433
|
+
const _url = type === FilE_TYPE.image ?
|
|
1434
|
+
// 如果是图片
|
|
1435
|
+
$n_getImage(hash)
|
|
1436
|
+
// 否则是文件
|
|
1437
|
+
: $n_getFile(hash)
|
|
1409
1438
|
|
|
1410
1439
|
if ($n_isValidString(_url)) {
|
|
1411
1440
|
copy(_url, '复制地址成功')
|