这是一个BILIBILI的弹幕姬,支持多房间、自定义弹幕样式、自主插件开发、直播数据统计及可视化等功能
YeuolyDanmu createPlugin
window.createPlugin({
label : '',
name : '',
id : 0
el_id : 'plugin_name'
default_boot : true,
boot : false,
run(controller){ /* do something */ },
mount(){ /* do something */ }
});
controller : {
setListenner : function(channel, cb),
removeListenner : function(channel, cb),
Vue : Class,
helper : {
HashList : Class,
axios : Object,
console : Object
getAvatar : function
}
}
setListennerchannel[ 'danmu', 'guard', 'sc' , 'gift', 'log']cbYeuolyDanmucb removeListennersetListenner
const dom = document.createElement('div');
/*
dom
**/
document.getElementById('#'+this.el_id).appendChild(dom);
controllerVueVueVue
window.createPlugin({
label : '',
name : 'timer',
id : 114514,
el_id : 'timer',
el : null,
default_boot : true,
boot : false,
run(controller){
this.el = new controller.Vue({
template : '<div>{{time}}</div>',
data : () => ({
time : 0
}),
created(){
setInterval(() => { this.time++; },1000);
}
});
this.boot = true;
},
mount(){
this.el.$mount('#'+this.el_id);
}
});
js
window.createPlugin({
label : '',
name : 'example',
id : 114514,
el_id : 'example',
data : {
time : 0
},
default_boot : true,
boot : false,
console : null,
run(controller){
this.console = controller.helper.console;
this.timer = setInterval(() => { this.data.time++; }, 1000);
this.boot = true;
},
mount(){
try{
const dom = document.getElementById(this.el_id);
dom.innerHTML = '' + this.data.time + '';
this.console.log('Example',this.data.time);
clearInterval(this.timer);
this.timer = setInterval(() => {
this.data.time++;
dom.innerHTML = '' + this.data.time + '';
},1000);
}catch(e){
this.console.error('Example',e);
}
}
});
jsjsVueReactAngularYeuolyDanmu
consoleconsolelog error waringExamplelogcolorgreen red greyYeuolyDanmutry catchconsole
getAvatar
getAvatar(uid, => {
. = ;
});