add useSSR

This commit is contained in:
Harvey committed 2021-10-29 17:33:06 +08:00
1 parent 7eeba80319
commit d5b4851a8f
9 files changed
+306 -44

No files matched your search

+10 -5
View File
@@ -4,13 +4,18 @@ import Component from './utils/component';
export default class Info extends Component {
constructor(art) {
super(art);
this.art = art;
this.name = 'info';
if (this.art.template.$info) {
this.init();
}
}
init() {
const {
template: { $infoPanel, $infoClose, $video },
events: { proxy },
} = art;
} = this.art;
proxy($infoClose, 'click', () => {
this.show = false;
@@ -19,12 +24,12 @@ export default class Info extends Component {
let timer = null;
const types = queryAll('[data-video]', $infoPanel);
art.on('destroy', () => {
this.art.on('destroy', () => {
clearTimeout(timer);
});
function loop() {
types.forEach(item => {
types.forEach((item) => {
const value = $video[item.dataset.video];
item.innerText = typeof value === 'number' ? value.toFixed(2) : value;
});
@@ -33,7 +38,7 @@ export default class Info extends Component {
}, 1000);
}
art.on('info', value => {
this.art.on('info', (value) => {
clearTimeout(timer);
if (value) {
loop();