mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-17 18:11:20 -08:00
26 lines
588 B
JavaScript
26 lines
588 B
JavaScript
export default class Notice {
|
|
constructor(art) {
|
|
this.art = art;
|
|
this.timer = null;
|
|
}
|
|
|
|
show(msg, autoHide) {
|
|
const { $notice } = this.art.refs;
|
|
$notice.style.display = 'block';
|
|
$notice.innerHTML = msg instanceof Error ? msg.message.trim() : msg;
|
|
if (autoHide) {
|
|
clearTimeout(this.timer);
|
|
this.timer = setTimeout(() => {
|
|
this.hide();
|
|
}, 1000);
|
|
}
|
|
this.art.emit('notice:show', $notice);
|
|
}
|
|
|
|
hide() {
|
|
const { $notice } = this.art.refs;
|
|
$notice.style.display = 'none';
|
|
this.art.emit('notice:hide', $notice);
|
|
}
|
|
}
|