@netang/quasar 0.0.47 → 0.0.49
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/index.vue +10 -10
- package/components/dialog-table/index.vue +1 -1
- package/components/dragger/index.vue +2 -2
- package/components/drawer/index.vue +7 -7
- package/components/field-date/index.vue +35 -35
- package/components/field-table/index.vue +39 -41
- package/components/field-text/index.vue +2 -2
- package/components/field-tree/index.vue +19 -19
- package/components/input-number/index.vue +2 -2
- package/components/list-menu/index.vue +2 -2
- package/components/private/components/move-to-tree/index.vue +2 -2
- package/components/private/edit-power-data/index.vue +50 -50
- package/components/private/table-visible-columns-button/index.vue +2 -2
- package/components/render/index.vue +6 -6
- package/components/search/index.vue +2 -2
- package/components/search-item/index.vue +5 -5
- package/components/select/index.vue +2 -2
- package/components/splitter/index.vue +7 -7
- package/components/table/index.vue +5 -5
- package/components/table-splitter/index.vue +22 -11
- package/components/table-summary/index.vue +3 -3
- package/components/thumbnail/index.vue +6 -6
- package/components/uploader/index.vue +1 -1
- package/components/uploader-query/index.vue +25 -25
- package/components/value-format/index.vue +65 -38
- package/package.json +1 -1
- package/utils/$area.js +13 -13
- package/utils/$auth.js +6 -6
- package/utils/$dialog.js +3 -3
- package/utils/$form.js +2 -2
- package/utils/$power.js +124 -117
- package/utils/$rule.js +4 -4
- package/utils/$search.js +50 -50
- package/utils/$table.js +76 -76
- package/utils/$tree.js +43 -43
- package/utils/$uploader.js +47 -47
- package/utils/alert.js +1 -1
- package/utils/arr.js +2 -2
- package/utils/bus.js +1 -1
- package/utils/config.js +4 -4
- package/utils/confrim.js +1 -1
- package/utils/dict.js +5 -5
- package/utils/getData.js +9 -9
- package/utils/getFile.js +5 -5
- package/utils/getImage.js +12 -12
- package/utils/getTime.js +4 -4
- package/utils/http.js +20 -20
- package/utils/loading.js +1 -1
- package/utils/notify.js +1 -1
- package/utils/previewImage.js +2 -2
- package/utils/price.js +3 -3
- package/utils/timestamp.js +1 -1
- package/utils/toast.js +1 -1
- package/utils/uploader/qiniu.js +11 -11
- package/utils/useAuth.js +2 -2
- package/utils/useRouter.js +4 -4
- package/components/input-format/index.vue +0 -268
package/utils/$tree.js
CHANGED
|
@@ -29,7 +29,7 @@ function getTreeNode(data, nodeId) {
|
|
|
29
29
|
*/
|
|
30
30
|
function getChildren(data, callback) {
|
|
31
31
|
for (const item of data) {
|
|
32
|
-
if (
|
|
32
|
+
if ($n.run(callback)(item) === false) {
|
|
33
33
|
return false
|
|
34
34
|
}
|
|
35
35
|
// 如果是父节点
|
|
@@ -75,24 +75,24 @@ function create(params) {
|
|
|
75
75
|
}, params)
|
|
76
76
|
|
|
77
77
|
// 获取权限注入
|
|
78
|
-
const $power =
|
|
78
|
+
const $power = $n.has(params, '$power') ? params.$power : inject(NPowerKey)
|
|
79
79
|
const hasPowr = !! $power
|
|
80
80
|
|
|
81
81
|
// 获取权限路由
|
|
82
|
-
const $route =
|
|
82
|
+
const $route = $n.isValidString(path) ?
|
|
83
83
|
// 如果为自定义路由
|
|
84
|
-
|
|
84
|
+
$n.router.resolve({
|
|
85
85
|
path,
|
|
86
86
|
query,
|
|
87
87
|
})
|
|
88
88
|
// 否则获取当前路由
|
|
89
|
-
: (hasPowr ? $power.getRoute() :
|
|
89
|
+
: (hasPowr ? $power.getRoute() : $n.router.getRoute())
|
|
90
90
|
|
|
91
91
|
// 权限按钮
|
|
92
92
|
const powerBtns = hasPowr ? $power.powerBtns : ref([])
|
|
93
93
|
|
|
94
94
|
// 是否有展开节点
|
|
95
|
-
const hasExpanded = !
|
|
95
|
+
const hasExpanded = ! $n.isNil(expanded) && isRef(expanded)
|
|
96
96
|
|
|
97
97
|
// 如果开启展开节点缓存
|
|
98
98
|
if (hasExpanded && cache) {
|
|
@@ -138,7 +138,7 @@ function create(params) {
|
|
|
138
138
|
function updateNode(data) {
|
|
139
139
|
|
|
140
140
|
// 获取 id
|
|
141
|
-
const id =
|
|
141
|
+
const id = $n.get(formData.value, 'id')
|
|
142
142
|
|
|
143
143
|
// 更新表单数据
|
|
144
144
|
formData.value = Object.assign({}, formData.value, data)
|
|
@@ -158,7 +158,7 @@ function create(params) {
|
|
|
158
158
|
// 否则为新增节点
|
|
159
159
|
} else if (
|
|
160
160
|
// 如果为新增节点
|
|
161
|
-
|
|
161
|
+
$n.get(data, 'id')
|
|
162
162
|
// 没有节点存在
|
|
163
163
|
&& ! nodeItem
|
|
164
164
|
) {
|
|
@@ -185,7 +185,7 @@ function create(params) {
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
// 获取节点索引
|
|
188
|
-
const nodeIndex =
|
|
188
|
+
const nodeIndex = $n.findIndex(parentNodeItem.children, { id })
|
|
189
189
|
if (nodeIndex > -1) {
|
|
190
190
|
parentNodeItem.children.splice(nodeIndex, 1)
|
|
191
191
|
}
|
|
@@ -213,18 +213,18 @@ function create(params) {
|
|
|
213
213
|
|
|
214
214
|
const allPowerBtn = {}
|
|
215
215
|
for (const item of powerBtns.value) {
|
|
216
|
-
if (
|
|
216
|
+
if ($n.has(maps, $n.get(item, 'name'))) {
|
|
217
217
|
allPowerBtn[maps[item.name]] = item
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
return {
|
|
222
|
-
all:
|
|
223
|
-
update:
|
|
224
|
-
move:
|
|
225
|
-
copy:
|
|
226
|
-
delete:
|
|
227
|
-
status:
|
|
222
|
+
all: $n.isValidObject(allPowerBtn),
|
|
223
|
+
update: $n.has(allPowerBtn, 'update'),
|
|
224
|
+
move: $n.has(allPowerBtn, 'move'),
|
|
225
|
+
copy: $n.has(allPowerBtn, 'copy'),
|
|
226
|
+
delete: $n.has(allPowerBtn, 'delete'),
|
|
227
|
+
status: $n.has(allPowerBtn, 'status'),
|
|
228
228
|
allPowerBtn,
|
|
229
229
|
}
|
|
230
230
|
}
|
|
@@ -234,7 +234,7 @@ function create(params) {
|
|
|
234
234
|
*/
|
|
235
235
|
function confirmMenu(callback) {
|
|
236
236
|
// 确认框
|
|
237
|
-
|
|
237
|
+
$n.confirm({
|
|
238
238
|
message: '确认要执行该操作吗?',
|
|
239
239
|
})
|
|
240
240
|
// 点击确认执行
|
|
@@ -272,13 +272,13 @@ function create(params) {
|
|
|
272
272
|
// 移至节点下
|
|
273
273
|
case 'moveDown':
|
|
274
274
|
|
|
275
|
-
if (!
|
|
275
|
+
if (! $n.get(o.menuStatus, 'value.allPowerBtn.move.url')) {
|
|
276
276
|
console.error('没有找到复制地址')
|
|
277
277
|
return
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
// 创建对话框
|
|
281
|
-
|
|
281
|
+
$n.$dialog.create({
|
|
282
282
|
// 标题
|
|
283
283
|
title: `移动至节点的${o.type === 'moveUp' ? '上方' : (o.type === 'moveDown' ? '下方' : '内部')}`,
|
|
284
284
|
// 宽度
|
|
@@ -298,8 +298,8 @@ function create(params) {
|
|
|
298
298
|
async onConfirm({ value: moveNodeId }) {
|
|
299
299
|
|
|
300
300
|
// 是否为正确的 id
|
|
301
|
-
if (!
|
|
302
|
-
|
|
301
|
+
if (! $n.hasId(moveNodeId)) {
|
|
302
|
+
$n.toast({
|
|
303
303
|
message: '请选择节点',
|
|
304
304
|
})
|
|
305
305
|
return false
|
|
@@ -307,7 +307,7 @@ function create(params) {
|
|
|
307
307
|
|
|
308
308
|
// 如果节点是自己
|
|
309
309
|
if (moveNodeId === o.node.id) {
|
|
310
|
-
|
|
310
|
+
$n.toast({
|
|
311
311
|
message: '不能选择当前节点',
|
|
312
312
|
})
|
|
313
313
|
return false
|
|
@@ -316,14 +316,14 @@ function create(params) {
|
|
|
316
316
|
// 获取需移动至的节点
|
|
317
317
|
const moveNodeItem = getNode(moveNodeId)
|
|
318
318
|
if (! moveNodeItem) {
|
|
319
|
-
|
|
319
|
+
$n.alert({
|
|
320
320
|
message: '移动至的节点不存在',
|
|
321
321
|
})
|
|
322
322
|
return false
|
|
323
323
|
}
|
|
324
324
|
|
|
325
325
|
// 克隆当前树列表数据
|
|
326
|
-
const nodesClone =
|
|
326
|
+
const nodesClone = $n.cloneDeep(nodes.value)
|
|
327
327
|
|
|
328
328
|
// 获取当前节点
|
|
329
329
|
const nodeItem = getNode(o.node.id)
|
|
@@ -358,7 +358,7 @@ function create(params) {
|
|
|
358
358
|
})
|
|
359
359
|
|
|
360
360
|
// 将本节点从原父节点中删除
|
|
361
|
-
const nodeItemIndex =
|
|
361
|
+
const nodeItemIndex = $n.findIndex(parentNodeItem.children, { id: nodeItem.id })
|
|
362
362
|
parentNodeItem.children.splice(nodeItemIndex, 1)
|
|
363
363
|
|
|
364
364
|
// 将本节点添加至移动至的节点的子节点中
|
|
@@ -383,11 +383,11 @@ function create(params) {
|
|
|
383
383
|
})
|
|
384
384
|
|
|
385
385
|
// 将本节点从原父节点中删除
|
|
386
|
-
const nodeItemIndex =
|
|
386
|
+
const nodeItemIndex = $n.findIndex(parentNodeItem.children, { id: nodeItem.id })
|
|
387
387
|
parentNodeItem.children.splice(nodeItemIndex, 1)
|
|
388
388
|
|
|
389
389
|
// 获取移动至节点的索引
|
|
390
|
-
const moveNodeItemIndex =
|
|
390
|
+
const moveNodeItemIndex = $n.findIndex(moveParentNodeItem.children, { id: moveNodeId })
|
|
391
391
|
|
|
392
392
|
for (let i = moveNodeItemIndex + (o.type === 'moveUp' ? 0 : 1); i < moveParentNodeItem.children.length; i++) {
|
|
393
393
|
const item = moveParentNodeItem.children[i]
|
|
@@ -404,7 +404,7 @@ function create(params) {
|
|
|
404
404
|
}
|
|
405
405
|
|
|
406
406
|
// 请求 - 移动
|
|
407
|
-
const { status } = await
|
|
407
|
+
const { status } = await $n.http({
|
|
408
408
|
url: o.menuStatus.value.allPowerBtn.move.url,
|
|
409
409
|
data: {
|
|
410
410
|
data: moveLists,
|
|
@@ -424,7 +424,7 @@ function create(params) {
|
|
|
424
424
|
// 确认菜单
|
|
425
425
|
confirmMenu(async function() {
|
|
426
426
|
|
|
427
|
-
if (!
|
|
427
|
+
if (! $n.get(o.menuStatus, 'value.allPowerBtn.copy.url')) {
|
|
428
428
|
console.error('没有找到复制地址')
|
|
429
429
|
return
|
|
430
430
|
}
|
|
@@ -448,7 +448,7 @@ function create(params) {
|
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
// 请求 - 复制
|
|
451
|
-
const { status, data: res } = await
|
|
451
|
+
const { status, data: res } = await $n.http({
|
|
452
452
|
url: o.menuStatus.value.allPowerBtn.copy.url,
|
|
453
453
|
data: {
|
|
454
454
|
data: copyLists,
|
|
@@ -462,7 +462,7 @@ function create(params) {
|
|
|
462
462
|
if (isLeafNode) {
|
|
463
463
|
|
|
464
464
|
// 如果返回了 id
|
|
465
|
-
if (
|
|
465
|
+
if ($n.hasId(res)) {
|
|
466
466
|
|
|
467
467
|
// 更新数据
|
|
468
468
|
Object.assign(newAttr, res)
|
|
@@ -487,7 +487,7 @@ function create(params) {
|
|
|
487
487
|
}
|
|
488
488
|
|
|
489
489
|
// 轻提示
|
|
490
|
-
|
|
490
|
+
$n.toast({
|
|
491
491
|
type: 'positive',
|
|
492
492
|
message: '复制成功',
|
|
493
493
|
})
|
|
@@ -500,13 +500,13 @@ function create(params) {
|
|
|
500
500
|
// 如果有子节点
|
|
501
501
|
if (o.node.children.length) {
|
|
502
502
|
// 提示框
|
|
503
|
-
|
|
503
|
+
$n.alert({
|
|
504
504
|
message: '请先删除该节点下的子节点',
|
|
505
505
|
})
|
|
506
506
|
return
|
|
507
507
|
}
|
|
508
508
|
|
|
509
|
-
if (!
|
|
509
|
+
if (! $n.get(o.menuStatus, 'value.allPowerBtn.delete.url')) {
|
|
510
510
|
console.error('没有找到删除地址')
|
|
511
511
|
return
|
|
512
512
|
}
|
|
@@ -515,7 +515,7 @@ function create(params) {
|
|
|
515
515
|
confirmMenu(async function() {
|
|
516
516
|
|
|
517
517
|
// 请求 - 删除
|
|
518
|
-
const { status } = await
|
|
518
|
+
const { status } = await $n.http({
|
|
519
519
|
url: o.menuStatus.value.allPowerBtn.delete.url,
|
|
520
520
|
data: {
|
|
521
521
|
id: o.node.id,
|
|
@@ -529,7 +529,7 @@ function create(params) {
|
|
|
529
529
|
deleteNode(o.node)
|
|
530
530
|
|
|
531
531
|
// 轻提示
|
|
532
|
-
|
|
532
|
+
$n.toast({
|
|
533
533
|
type: 'positive',
|
|
534
534
|
message: '删除成功',
|
|
535
535
|
})
|
|
@@ -541,7 +541,7 @@ function create(params) {
|
|
|
541
541
|
// 全部正常
|
|
542
542
|
case 'statusNormal':
|
|
543
543
|
|
|
544
|
-
if (!
|
|
544
|
+
if (! $n.get(o.menuStatus, 'value.allPowerBtn.status.url')) {
|
|
545
545
|
console.error('没有找到状态地址')
|
|
546
546
|
return
|
|
547
547
|
}
|
|
@@ -566,7 +566,7 @@ function create(params) {
|
|
|
566
566
|
}
|
|
567
567
|
|
|
568
568
|
// 请求 - 全部禁用/正常
|
|
569
|
-
const { status } = await
|
|
569
|
+
const { status } = await $n.http({
|
|
570
570
|
url: o.menuStatus.value.allPowerBtn.status.url,
|
|
571
571
|
data: {
|
|
572
572
|
// ids
|
|
@@ -590,7 +590,7 @@ function create(params) {
|
|
|
590
590
|
}
|
|
591
591
|
|
|
592
592
|
// 轻提示
|
|
593
|
-
|
|
593
|
+
$n.toast({
|
|
594
594
|
type: 'positive',
|
|
595
595
|
message: '恭喜您,操作成功',
|
|
596
596
|
})
|
|
@@ -604,8 +604,8 @@ function create(params) {
|
|
|
604
604
|
*/
|
|
605
605
|
function getExpandedCache(defaultValue = []) {
|
|
606
606
|
// 获取展开节点缓存
|
|
607
|
-
const res =
|
|
608
|
-
return
|
|
607
|
+
const res = $n.storage.get('tree_expanded_' + $route.fullPath)
|
|
608
|
+
return $n.isValidArray(res) ? res : defaultValue
|
|
609
609
|
}
|
|
610
610
|
|
|
611
611
|
/**
|
|
@@ -613,7 +613,7 @@ function create(params) {
|
|
|
613
613
|
*/
|
|
614
614
|
function setExpandedCache(expanded) {
|
|
615
615
|
// 设置展开节点缓存(永久缓存)
|
|
616
|
-
|
|
616
|
+
$n.storage.set('tree_expanded_' + $route.fullPath, expanded, 0)
|
|
617
617
|
}
|
|
618
618
|
|
|
619
619
|
return {
|
|
@@ -639,7 +639,7 @@ function create(params) {
|
|
|
639
639
|
/**
|
|
640
640
|
* 树业务
|
|
641
641
|
*/
|
|
642
|
-
|
|
642
|
+
$n.$tree = {
|
|
643
643
|
// 创建树实例
|
|
644
644
|
create,
|
|
645
645
|
}
|
package/utils/$uploader.js
CHANGED
|
@@ -60,10 +60,10 @@ function create(params) {
|
|
|
60
60
|
loadInfo: false,
|
|
61
61
|
// 单文件上传提示
|
|
62
62
|
confirm: false,
|
|
63
|
-
},
|
|
63
|
+
}, $n.get(params, 'props'))
|
|
64
64
|
|
|
65
65
|
// 上传文件列表
|
|
66
|
-
const uploadFileLists =
|
|
66
|
+
const uploadFileLists = $n.has(params, 'uploadFileLists') && isRef(params.uploadFileLists) ? params.uploadFileLists : ref([])
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* 上传配置
|
|
@@ -72,12 +72,12 @@ function create(params) {
|
|
|
72
72
|
{
|
|
73
73
|
type: 'local',
|
|
74
74
|
},
|
|
75
|
-
|
|
75
|
+
$n.config('uploader.upload')
|
|
76
76
|
)
|
|
77
77
|
const configLimit = Object.assign({
|
|
78
78
|
maxSize: 100,
|
|
79
79
|
exts: [],
|
|
80
|
-
},
|
|
80
|
+
}, $n.config('uploader.limit.' + props.type))
|
|
81
81
|
|
|
82
82
|
// 如果有单个文件的最大大小
|
|
83
83
|
if (props.maxSize) {
|
|
@@ -85,7 +85,7 @@ function create(params) {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
// 如果有单个文件的限制后缀
|
|
88
|
-
if (
|
|
88
|
+
if ($n.isValidArray(props.exts)) {
|
|
89
89
|
configLimit.exts = props.exts
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -121,7 +121,7 @@ function create(params) {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
const hashsString =
|
|
124
|
+
const hashsString = $n.join(hashs, ',')
|
|
125
125
|
|
|
126
126
|
return {
|
|
127
127
|
value: props.valueArray ? hashs : hashsString,
|
|
@@ -140,10 +140,10 @@ function create(params) {
|
|
|
140
140
|
const result = getValue()
|
|
141
141
|
|
|
142
142
|
// 更新值
|
|
143
|
-
|
|
143
|
+
$n.run(onUpdateModelValue)(result)
|
|
144
144
|
|
|
145
145
|
// 更新
|
|
146
|
-
|
|
146
|
+
$n.run(onUpdate)(result)
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
/**
|
|
@@ -151,23 +151,23 @@ function create(params) {
|
|
|
151
151
|
*/
|
|
152
152
|
function update() {
|
|
153
153
|
// 更新
|
|
154
|
-
|
|
154
|
+
$n.run(onUpdate)(getValue())
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
/**
|
|
158
158
|
* 初始化上传列表
|
|
159
159
|
*/
|
|
160
160
|
async function initUploadFileLists() {
|
|
161
|
-
if (
|
|
161
|
+
if ($n.isRequired(props.modelValue)) {
|
|
162
162
|
|
|
163
163
|
// 获取值数组
|
|
164
|
-
const hashs = props.valueArray ? props.modelValue :
|
|
164
|
+
const hashs = props.valueArray ? props.modelValue : $n.split(props.modelValue, ',')
|
|
165
165
|
|
|
166
166
|
// 如果类型不是图片 || 初始加载文件信息, 则请求文件信息
|
|
167
167
|
if (props.type !== 'image' || props.loadInfo) {
|
|
168
168
|
|
|
169
169
|
// 请求 - 获取文件
|
|
170
|
-
const { status, data: resExisted } = await
|
|
170
|
+
const { status, data: resExisted } = await $n.http({
|
|
171
171
|
url: REQUEST_URL + 'get_file',
|
|
172
172
|
data: {
|
|
173
173
|
hashs,
|
|
@@ -177,7 +177,7 @@ function create(params) {
|
|
|
177
177
|
})
|
|
178
178
|
if (status) {
|
|
179
179
|
|
|
180
|
-
|
|
180
|
+
$n.forEach(resExisted, function (existedItem) {
|
|
181
181
|
|
|
182
182
|
// 创建原始单个文件
|
|
183
183
|
const fileItem = createRawFileItem()
|
|
@@ -197,7 +197,7 @@ function create(params) {
|
|
|
197
197
|
return
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
$n.forEach(hashs, function(hash) {
|
|
201
201
|
|
|
202
202
|
// 添加至上传文件列表
|
|
203
203
|
uploadFileLists.value.push(Object.assign(createRawFileItem(), {
|
|
@@ -271,7 +271,7 @@ function create(params) {
|
|
|
271
271
|
if (props.confirm) {
|
|
272
272
|
|
|
273
273
|
// 确认框
|
|
274
|
-
|
|
274
|
+
$n.confirm({
|
|
275
275
|
message: '最多只能上传1个文件,确认上传并替换吗?',
|
|
276
276
|
})
|
|
277
277
|
// 点击确认执行
|
|
@@ -301,7 +301,7 @@ function create(params) {
|
|
|
301
301
|
&& uploadFileLists.value.length >= props.count
|
|
302
302
|
) {
|
|
303
303
|
// 轻提示
|
|
304
|
-
|
|
304
|
+
$n.toast({
|
|
305
305
|
message: `最多只能上传${props.count}个文件,请先删除后再上传`,
|
|
306
306
|
})
|
|
307
307
|
return
|
|
@@ -319,8 +319,8 @@ function create(params) {
|
|
|
319
319
|
} catch (e) {
|
|
320
320
|
|
|
321
321
|
// 错误提示
|
|
322
|
-
|
|
323
|
-
message:
|
|
322
|
+
$n.alert({
|
|
323
|
+
message: $n.getThrowMessage(e),
|
|
324
324
|
})
|
|
325
325
|
}
|
|
326
326
|
|
|
@@ -369,13 +369,13 @@ function create(params) {
|
|
|
369
369
|
async function upload() {
|
|
370
370
|
try {
|
|
371
371
|
if (! _upload) {
|
|
372
|
-
const run =
|
|
372
|
+
const run = $n.get(UPLOADERS, configUpload.type)
|
|
373
373
|
if (run) {
|
|
374
374
|
_upload = (await run()).default
|
|
375
375
|
}
|
|
376
376
|
if (! _upload) {
|
|
377
377
|
// 错误提示
|
|
378
|
-
|
|
378
|
+
$n.alert({
|
|
379
379
|
message: '没有定义上传器',
|
|
380
380
|
})
|
|
381
381
|
return
|
|
@@ -406,8 +406,8 @@ function create(params) {
|
|
|
406
406
|
|
|
407
407
|
} catch (e) {
|
|
408
408
|
// 错误提示
|
|
409
|
-
|
|
410
|
-
message:
|
|
409
|
+
$n.alert({
|
|
410
|
+
message: $n.getThrowMessage(e),
|
|
411
411
|
})
|
|
412
412
|
}
|
|
413
413
|
}
|
|
@@ -504,10 +504,10 @@ function create(params) {
|
|
|
504
504
|
// 如果开启去重
|
|
505
505
|
props.unique
|
|
506
506
|
// 如果该文件 hash 在上传文件列表中
|
|
507
|
-
&&
|
|
507
|
+
&& $n.findIndex(uploadFileLists.value, { hash }) > -1
|
|
508
508
|
) {
|
|
509
509
|
// 轻提示
|
|
510
|
-
|
|
510
|
+
$n.toast({
|
|
511
511
|
message: '该文件已存在,不可重复上传',
|
|
512
512
|
})
|
|
513
513
|
|
|
@@ -573,7 +573,7 @@ function create(params) {
|
|
|
573
573
|
! ext
|
|
574
574
|
// 如果后缀名不在允许范围内, 则无效
|
|
575
575
|
|| (
|
|
576
|
-
|
|
576
|
+
$n.isValidArray(exts)
|
|
577
577
|
&& exts.indexOf(ext) === -1
|
|
578
578
|
)
|
|
579
579
|
) {
|
|
@@ -623,10 +623,10 @@ function create(params) {
|
|
|
623
623
|
}
|
|
624
624
|
|
|
625
625
|
// 请求 - 检查文件是否存在 hash
|
|
626
|
-
const { status, data: resExisted } = await
|
|
626
|
+
const { status, data: resExisted } = await $n.http({
|
|
627
627
|
url: REQUEST_URL + 'check_exist',
|
|
628
628
|
data: {
|
|
629
|
-
hashs:
|
|
629
|
+
hashs: $n.uniq(checkHashs),
|
|
630
630
|
},
|
|
631
631
|
// 关闭错误
|
|
632
632
|
warn: false,
|
|
@@ -648,7 +648,7 @@ function create(params) {
|
|
|
648
648
|
}
|
|
649
649
|
|
|
650
650
|
// 如果有存在的文件列表
|
|
651
|
-
if (
|
|
651
|
+
if ($n.isValidArray(resExisted)) {
|
|
652
652
|
|
|
653
653
|
// 已存在文件数量
|
|
654
654
|
let existedNum = 0
|
|
@@ -658,11 +658,11 @@ function create(params) {
|
|
|
658
658
|
for (const fileItem of checkFileLists) {
|
|
659
659
|
|
|
660
660
|
// 如果文件已存在(已经上传过了, 就是检查是否秒传文件)
|
|
661
|
-
const existedItem =
|
|
661
|
+
const existedItem = $n.find(resExisted, { hash: fileItem.hash })
|
|
662
662
|
if (existedItem) {
|
|
663
663
|
|
|
664
664
|
// 如果 类型为文件, 则不受限制 || 文件类型正确
|
|
665
|
-
if (props.type === 'file' || fileItem.type ===
|
|
665
|
+
if (props.type === 'file' || fileItem.type === $n.get(existedItem, 'type')) {
|
|
666
666
|
|
|
667
667
|
// 设置已存在文件
|
|
668
668
|
setExistedFileItem(fileItem, existedItem)
|
|
@@ -763,10 +763,10 @@ function create(params) {
|
|
|
763
763
|
// 如果开启去重
|
|
764
764
|
props.unique
|
|
765
765
|
// 如果该文件 key 在上传文件列表中
|
|
766
|
-
&&
|
|
766
|
+
&& $n.findIndex(uploadFileLists.value, { key }) > -1
|
|
767
767
|
) {
|
|
768
768
|
// 轻提示
|
|
769
|
-
|
|
769
|
+
$n.toast({
|
|
770
770
|
message: '该文件已存在,不可重复上传',
|
|
771
771
|
})
|
|
772
772
|
|
|
@@ -782,7 +782,7 @@ function create(params) {
|
|
|
782
782
|
const index = name.lastIndexOf('.')
|
|
783
783
|
if (index > -1) {
|
|
784
784
|
title = name.substring(0, index)
|
|
785
|
-
ext =
|
|
785
|
+
ext = $n.toLower(name.substring(index + 1))
|
|
786
786
|
}
|
|
787
787
|
|
|
788
788
|
// 创建单个文件
|
|
@@ -843,7 +843,7 @@ function create(params) {
|
|
|
843
843
|
json,
|
|
844
844
|
} = existedItem
|
|
845
845
|
|
|
846
|
-
const fileJson =
|
|
846
|
+
const fileJson = $n.json.parse(json)
|
|
847
847
|
|
|
848
848
|
// 设置文件
|
|
849
849
|
Object.assign(fileItem, {
|
|
@@ -858,7 +858,7 @@ function create(params) {
|
|
|
858
858
|
// 大小
|
|
859
859
|
size,
|
|
860
860
|
// 信息
|
|
861
|
-
json:
|
|
861
|
+
json: $n.isValidObject(fileJson) ? fileJson : {},
|
|
862
862
|
// 状态
|
|
863
863
|
status: UPLOAD_STATUS.success,
|
|
864
864
|
// 进度
|
|
@@ -890,7 +890,7 @@ function create(params) {
|
|
|
890
890
|
* 删除单个文件
|
|
891
891
|
*/
|
|
892
892
|
function deleteFileItem(fileItem) {
|
|
893
|
-
const index =
|
|
893
|
+
const index = $n.findIndex(uploadFileLists.value, { id: fileItem.id })
|
|
894
894
|
if (index > -1) {
|
|
895
895
|
|
|
896
896
|
const {
|
|
@@ -917,7 +917,7 @@ function create(params) {
|
|
|
917
917
|
function previewImage(fileItem) {
|
|
918
918
|
// 预览图片
|
|
919
919
|
if (fileItem.type === FilE_TYPE.image) {
|
|
920
|
-
|
|
920
|
+
$n.previewImage($n.has(fileItem, '__img') ? fileItem.__img : fileItem.hash)
|
|
921
921
|
}
|
|
922
922
|
}
|
|
923
923
|
|
|
@@ -926,9 +926,9 @@ function create(params) {
|
|
|
926
926
|
*/
|
|
927
927
|
async function editFileTitle(newTitle, fileItem) {
|
|
928
928
|
|
|
929
|
-
if (
|
|
929
|
+
if ($n.isValidValue(newTitle)) {
|
|
930
930
|
|
|
931
|
-
newTitle =
|
|
931
|
+
newTitle = $n.trimString(newTitle)
|
|
932
932
|
|
|
933
933
|
const {
|
|
934
934
|
hash,
|
|
@@ -943,7 +943,7 @@ function create(params) {
|
|
|
943
943
|
fileItem.title = newTitle
|
|
944
944
|
|
|
945
945
|
// 请求 - 修改文件名
|
|
946
|
-
const { status } = await
|
|
946
|
+
const { status } = await $n.http({
|
|
947
947
|
url: REQUEST_URL + 'edit_file_title',
|
|
948
948
|
data: {
|
|
949
949
|
hash,
|
|
@@ -959,7 +959,7 @@ function create(params) {
|
|
|
959
959
|
}
|
|
960
960
|
|
|
961
961
|
// 轻提示
|
|
962
|
-
|
|
962
|
+
$n.toast({
|
|
963
963
|
type: 'positive',
|
|
964
964
|
message: '修改成功',
|
|
965
965
|
})
|
|
@@ -971,7 +971,7 @@ function create(params) {
|
|
|
971
971
|
*/
|
|
972
972
|
function play(fileItem) {
|
|
973
973
|
// 轻提示
|
|
974
|
-
|
|
974
|
+
$n.toast({
|
|
975
975
|
message: '播放还没做',
|
|
976
976
|
})
|
|
977
977
|
}
|
|
@@ -983,12 +983,12 @@ function create(params) {
|
|
|
983
983
|
|
|
984
984
|
const url = fileItem.type === FilE_TYPE.image ?
|
|
985
985
|
// 如果是图片
|
|
986
|
-
|
|
986
|
+
$n.getImage(fileItem.hash)
|
|
987
987
|
// 否则是文件
|
|
988
|
-
:
|
|
988
|
+
: $n.getFile(fileItem.hash)
|
|
989
989
|
|
|
990
|
-
if (
|
|
991
|
-
|
|
990
|
+
if ($n.isValidString(url)) {
|
|
991
|
+
$n.copy(url, '复制地址成功')
|
|
992
992
|
}
|
|
993
993
|
}
|
|
994
994
|
|
|
@@ -1023,7 +1023,7 @@ function create(params) {
|
|
|
1023
1023
|
/**
|
|
1024
1024
|
* 上传器
|
|
1025
1025
|
*/
|
|
1026
|
-
|
|
1026
|
+
$n.$uploader = {
|
|
1027
1027
|
// 创建对话框
|
|
1028
1028
|
create,
|
|
1029
1029
|
}
|
package/utils/alert.js
CHANGED
package/utils/arr.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* 操作数组
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
$n.arr = {
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* 增加
|
|
8
8
|
*/
|
|
9
9
|
add(children, index, newItem) {
|
|
10
10
|
if (Array.isArray(children)) {
|
|
11
|
-
children.splice(index + 1, 0,
|
|
11
|
+
children.splice(index + 1, 0, $n.isFunction(newItem) ? newItem() : newItem)
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
|
package/utils/bus.js
CHANGED