修改多实例时的图标bug

This commit is contained in:
Harvey Zack committed 2019-04-16 14:26:16 +08:00
1 parent 1573364202
commit 381a7e657e
7 files changed
+170 -138

No files matched your search

+14 -11
View File
@@ -13,17 +13,8 @@ import pip from './pip.svg';
import prev from './prev.svg';
import next from './next.svg';
function creatDomFromSvg(map) {
const result = {};
Object.keys(map).forEach(name => {
const tmp = document.createElement('div');
tmp.innerHTML = `<i class="art-icon art-icon-${name}">${map[name]}</i>`;
[result[name]] = tmp.childNodes;
});
return result;
}
export default creatDomFromSvg({
const icons = {};
const svgs = {
loading,
playBig,
play,
@@ -38,4 +29,16 @@ export default creatDomFromSvg({
pip,
prev,
next,
};
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;
+30 -24
View File
@@ -1,4 +1,4 @@
import { getExt, sleep } from '../utils';
import { getExt, sleep, errorHandle } from '../utils';
export default function attachUrlMix(art, player) {
const {
@@ -7,31 +7,37 @@ export default function attachUrlMix(art, player) {
} = art;
Object.defineProperty(player, 'attachUrl', {
value: url => sleep().then(() => {
function attachUrl(videoUrl) {
const typeName = type || getExt(videoUrl);
const typeCallback = customType[typeName];
if (typeName && typeCallback) {
art.loading.show();
art.emit('beforeCustomType', typeName);
typeCallback.call(art, $video, videoUrl, art);
art.emit('afterCustomType', typeName);
} else {
art.emit('beforeAttachUrl');
$video.src = videoUrl;
art.emit('afterAttachUrl');
value: url =>
sleep().then(() => {
function attachUrl(videoUrl) {
const typeName = type || getExt(videoUrl);
const typeCallback = customType[typeName];
if (typeName && typeCallback) {
art.loading.show();
art.emit('beforeCustomType', typeName);
typeCallback.call(art, $video, videoUrl, art);
art.emit('afterCustomType', typeName);
} else {
art.emit('beforeAttachUrl');
$video.src = videoUrl;
art.emit('afterAttachUrl');
}
return Promise.resolve(videoUrl);
}
return Promise.resolve(videoUrl);
}
if (typeof url === 'function') {
return url.call(art).then(videoUrl => {
art.loading.show();
return attachUrl(videoUrl);
});
}
if (typeof url === 'function') {
const result = url.call(art);
errorHandle(
typeof result.then === 'function',
'If url is a function, it needs to return a promise.',
);
return result.then(videoUrl => {
art.loading.show();
return attachUrl(videoUrl);
});
}
return attachUrl(url);
}),
return attachUrl(url);
}),
});
}