2018-04-13 08:19:50 +00:00
|
|
|
export function T () {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fix IE file.status problem
|
|
|
|
// via coping a new Object
|
|
|
|
export function fileToObject (file) {
|
|
|
|
return {
|
2018-09-05 13:28:54 +00:00
|
|
|
...file,
|
2018-04-13 08:19:50 +00:00
|
|
|
lastModified: file.lastModified,
|
|
|
|
lastModifiedDate: file.lastModifiedDate,
|
2018-09-05 13:28:54 +00:00
|
|
|
name: file.name,
|
2018-04-13 08:19:50 +00:00
|
|
|
size: file.size,
|
|
|
|
type: file.type,
|
|
|
|
uid: file.uid,
|
|
|
|
percent: 0,
|
|
|
|
originFileObj: file,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生成Progress percent: 0.1 -> 0.98
|
|
|
|
* - for ie
|
|
|
|
*/
|
|
|
|
export function genPercentAdd () {
|
|
|
|
let k = 0.1
|
|
|
|
const i = 0.01
|
|
|
|
const end = 0.98
|
|
|
|
return function (s) {
|
|
|
|
let start = s
|
|
|
|
if (start >= end) {
|
|
|
|
return start
|
|
|
|
}
|
|
|
|
|
|
|
|
start += k
|
|
|
|
k = k - i
|
|
|
|
if (k < 0.001) {
|
|
|
|
k = 0.001
|
|
|
|
}
|
2018-05-31 08:36:59 +00:00
|
|
|
return start
|
2018-04-13 08:19:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getFileItem (file, fileList) {
|
|
|
|
const matchKey = file.uid !== undefined ? 'uid' : 'name'
|
|
|
|
return fileList.filter(item => item[matchKey] === file[matchKey])[0]
|
|
|
|
}
|
|
|
|
|
|
|
|
export function removeFileItem (file, fileList) {
|
|
|
|
const matchKey = file.uid !== undefined ? 'uid' : 'name'
|
|
|
|
const removed = fileList.filter(item => item[matchKey] !== file[matchKey])
|
|
|
|
if (removed.length === fileList.length) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
return removed
|
|
|
|
}
|