feat(showcase): use blob instead of base64
This commit is contained in:
@@ -93,7 +93,7 @@ export default class Music {
|
|||||||
|
|
||||||
setMusic(data, type) {
|
setMusic(data, type) {
|
||||||
this.#audioLoopEl.src = data
|
this.#audioLoopEl.src = data
|
||||||
this.#audioLoopEl.querySelector('source').type = `audio/${type}`
|
this.#audioLoopEl.querySelector('source').type = type
|
||||||
this.#isUsingCustomMusic = true
|
this.#isUsingCustomMusic = true
|
||||||
this.#playMusic()
|
this.#playMusic()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,23 +138,19 @@ export default class Settings {
|
|||||||
this.functionInsights("setLogo", this.isWallpaperEngine)
|
this.functionInsights("setLogo", this.isWallpaperEngine)
|
||||||
}
|
}
|
||||||
|
|
||||||
#readFile(e, onload, callback = () => { }) {
|
#readFile(e, callback = () => { }) {
|
||||||
const file = e.target.files[0]
|
const file = e.target.files[0]
|
||||||
if (!file) return
|
if (!file) return
|
||||||
const reader = new FileReader()
|
callback(URL.createObjectURL(file.slice()), file.type)
|
||||||
reader.readAsDataURL(file);
|
|
||||||
reader.onload = readerEvent => onload(readerEvent)
|
|
||||||
callback()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setLogoImage(e) {
|
setLogoImage(e) {
|
||||||
this.#readFile(
|
this.#readFile(
|
||||||
e,
|
e,
|
||||||
(readerEvent) => {
|
(blobURL, type) => {
|
||||||
const content = readerEvent.target.result;
|
this.setLogo(blobURL, false)
|
||||||
this.setLogo(content, false)
|
document.getElementById("logo_image_clear").disabled = false
|
||||||
},
|
}
|
||||||
() => document.getElementById("logo_image_clear").disabled = false
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,11 +194,10 @@ export default class Settings {
|
|||||||
setBackground(e) {
|
setBackground(e) {
|
||||||
this.#readFile(
|
this.#readFile(
|
||||||
e,
|
e,
|
||||||
(readerEvent) => {
|
(blobURL, type) => {
|
||||||
const content = readerEvent.target.result;
|
this.setBackgoundImage(`url("${blobURL}")`)
|
||||||
this.setBackgoundImage(`url("${content}")`)
|
document.getElementById("custom_background_clear").disabled = false
|
||||||
},
|
}
|
||||||
() => document.getElementById("custom_background_clear").disabled = false
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,12 +354,10 @@ export default class Settings {
|
|||||||
setMusic(e) {
|
setMusic(e) {
|
||||||
this.#readFile(
|
this.#readFile(
|
||||||
e,
|
e,
|
||||||
(readerEvent) => {
|
(blobURL, type) => {
|
||||||
const content = readerEvent.target.result;
|
window.music.setMusic(blobURL, type)
|
||||||
const type = content.split(";")[0].split(":")[1]
|
document.getElementById("custom_music_clear").disabled = false
|
||||||
window.music.setMusic(content, type)
|
}
|
||||||
},
|
|
||||||
() => document.getElementById("custom_music_clear").disabled = false
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user