mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-22 21:31:20 -08:00
refactor(core): CORE-01 migrate utility contracts to TypeScript
This commit is contained in:
1 parent
e005e5f249
commit
d3c695024a
33 files changed
+1269
-305
No files matched your search
@@ -0,0 +1,19 @@
|
||||
export function getExt(url: string): string {
|
||||
const end = url.search(/[?#]/)
|
||||
const clean = (end < 0 ? url : url.slice(0, end)).trim().toLowerCase()
|
||||
return clean.slice(clean.lastIndexOf('.') + 1)
|
||||
}
|
||||
|
||||
export function download(url: string, name: string): void {
|
||||
const elink = document.createElement('a')
|
||||
elink.style.display = 'none'
|
||||
elink.href = url
|
||||
elink.download = name
|
||||
document.body.appendChild(elink)
|
||||
try {
|
||||
elink.click()
|
||||
}
|
||||
finally {
|
||||
elink.remove()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user