mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-11-26 23:27:00 +00:00
Show parsed file details and list Quark and UC as supported (#299)
The home page now shows the filename, size, and disk name after a successful parse, and the supported-disk copy includes Quark and UC. Bump the app version to 0.4.10. Co-authored-by: Cursor Agent <[email protected]>
This commit is contained in:
1 parent
24c22fad7f
commit
a7d41b0107
7 files changed
+137
-10
No files matched your search
@@ -0,0 +1,52 @@
|
||||
const PAN_NAMES = {
|
||||
qk: '夸克网盘',
|
||||
uc: 'UC网盘',
|
||||
lz: '蓝奏云',
|
||||
iz: '蓝奏云优享',
|
||||
fj: '小飞机盘',
|
||||
ye: '123云盘',
|
||||
ec: '移动云空间',
|
||||
le: '联想乐云',
|
||||
qqsc: 'QQ闪传',
|
||||
pic: 'iCloud'
|
||||
}
|
||||
|
||||
/** 与专业版摘要一致:169.1 M,而不是 169.1MB。 */
|
||||
function formatByteSize(bytes) {
|
||||
const value = Number(bytes)
|
||||
if (!Number.isFinite(value) || value < 0) return ''
|
||||
const units = ['B', 'K', 'M', 'G', 'T']
|
||||
let size = value
|
||||
let index = 0
|
||||
while (size >= 1024 && index < units.length - 1) {
|
||||
size /= 1024
|
||||
index += 1
|
||||
}
|
||||
const text = index === 0 ? String(Math.round(size)) : size.toFixed(1)
|
||||
return `${text} ${units[index]}`
|
||||
}
|
||||
|
||||
function panDisplayName(panType, panList) {
|
||||
const type = String(panType || '').toLowerCase()
|
||||
if (!type) return ''
|
||||
const found = (panList || []).find(item => String(item.type || '').toLowerCase() === type)
|
||||
if (found && found.name) return found.name
|
||||
return PAN_NAMES[type] || type
|
||||
}
|
||||
|
||||
/** 单文件解析成功摘要:文件名、大小、网盘类型。 */
|
||||
function buildParseFileMeta({ fileName, size, sizeStr, panType, panList } = {}) {
|
||||
const meta = []
|
||||
if (fileName) meta.push(String(fileName))
|
||||
const sizeText = sizeStr || formatByteSize(size)
|
||||
if (sizeText) meta.push(sizeText)
|
||||
const pan = panDisplayName(panType, panList)
|
||||
if (pan) meta.push(pan)
|
||||
return meta
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
formatByteSize,
|
||||
panDisplayName,
|
||||
buildParseFileMeta
|
||||
}
|
||||
Reference in new issue
Block a user