style: auto-fix linting issues
This commit is contained in:
parent
10b7afc36e
commit
f3b9cfd2f0
2 changed files with 19 additions and 9 deletions
13
js/lyrics.js
13
js/lyrics.js
|
|
@ -12,13 +12,18 @@ import {
|
|||
import { sidePanelManager } from './side-panel.js';
|
||||
|
||||
const loadAmLyrics = () => {
|
||||
const images = Array.from(document.images).filter(img => !img.complete);
|
||||
const images = Array.from(document.images).filter((img) => !img.complete);
|
||||
if (images.length === 0) {
|
||||
import('@uimaxbai/am-lyrics/am-lyrics.js').catch(console.error);
|
||||
} else {
|
||||
Promise.all(images.map(img => new Promise(res => {
|
||||
img.onload = img.onerror = res;
|
||||
}))).then(() => import('@uimaxbai/am-lyrics/am-lyrics.js').catch(console.error));
|
||||
Promise.all(
|
||||
images.map(
|
||||
(img) =>
|
||||
new Promise((res) => {
|
||||
img.onload = img.onerror = res;
|
||||
})
|
||||
)
|
||||
).then(() => import('@uimaxbai/am-lyrics/am-lyrics.js').catch(console.error));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
15
js/player.js
15
js/player.js
|
|
@ -99,15 +99,20 @@ export class Player {
|
|||
}
|
||||
|
||||
const waitForImagesLoading = () => {
|
||||
const images = Array.from(document.images).filter(img => !img.complete);
|
||||
const images = Array.from(document.images).filter((img) => !img.complete);
|
||||
if (images.length === 0) return Promise.resolve();
|
||||
return Promise.all(images.map(img => new Promise(res => {
|
||||
img.onload = img.onerror = res;
|
||||
})));
|
||||
return Promise.all(
|
||||
images.map(
|
||||
(img) =>
|
||||
new Promise((res) => {
|
||||
img.onload = img.onerror = res;
|
||||
})
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (document.readyState !== 'complete') {
|
||||
await new Promise(resolve => window.addEventListener('load', resolve));
|
||||
await new Promise((resolve) => window.addEventListener('load', resolve));
|
||||
}
|
||||
await waitForImagesLoading();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue