mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-28 02:01:20 -08:00
优化整体结构
This commit is contained in:
1 parent
9f9cb0e036
commit
487e865017
34 files changed
+505
-427
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { errorHandle } from '../utils';
|
||||
import loading from './loading.svg';
|
||||
import playBig from './play-big.svg';
|
||||
import play from './play.svg';
|
||||
@@ -13,32 +14,35 @@ import pip from './pip.svg';
|
||||
import prev from './prev.svg';
|
||||
import next from './next.svg';
|
||||
|
||||
const icons = {};
|
||||
const svgs = {
|
||||
loading,
|
||||
playBig,
|
||||
play,
|
||||
pause,
|
||||
volume,
|
||||
volumeClose,
|
||||
subtitle,
|
||||
screenshot,
|
||||
setting,
|
||||
fullscreen,
|
||||
fullscreenWeb,
|
||||
pip,
|
||||
prev,
|
||||
next,
|
||||
};
|
||||
export default class Icons {
|
||||
constructor(art) {
|
||||
const icons = Object.assign(
|
||||
{
|
||||
loading,
|
||||
playBig,
|
||||
play,
|
||||
pause,
|
||||
volume,
|
||||
volumeClose,
|
||||
subtitle,
|
||||
screenshot,
|
||||
setting,
|
||||
fullscreen,
|
||||
fullscreenWeb,
|
||||
pip,
|
||||
prev,
|
||||
next,
|
||||
},
|
||||
art.option.icons,
|
||||
);
|
||||
|
||||
Object.keys(svgs).forEach(key => {
|
||||
Object.defineProperty(icons, key, {
|
||||
get() {
|
||||
const tmp = document.createElement('div');
|
||||
tmp.innerHTML = `<i class="art-icon art-icon-${key}">${svgs[key]}</i>`;
|
||||
return tmp.childNodes[0];
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
export default icons;
|
||||
Object.keys(icons).forEach(key => {
|
||||
errorHandle(typeof icons[key] === 'string', 'Custom icon values only support string types.');
|
||||
const icon = document.createElement('i');
|
||||
icon.classList.add('art-icon');
|
||||
icon.classList.add(`art-icon-${key}`);
|
||||
icon.innerHTML = icons[key];
|
||||
this[key] = icon;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user