mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-24 23:51:20 -08:00
chore: Update danmuku plugin configuration handling and improve performance
This commit is contained in:
1 parent
5cee83817a
commit
58846384c8
5 files changed
+6
-27
No files matched your search
@@ -198,6 +198,7 @@ export default class Danmuku {
|
||||
const $ref = this.$refs.pop() || document.createElement('div');
|
||||
$ref.style.cssText = Danmuku.cssText;
|
||||
$ref.dataset.mode = '';
|
||||
$ref.className = '';
|
||||
return $ref;
|
||||
}
|
||||
|
||||
@@ -299,7 +300,6 @@ export default class Danmuku {
|
||||
time: '?number', // 弹幕时间
|
||||
border: '?boolean', // 弹幕是否有边框
|
||||
style: '?object', // 弹幕额外样式
|
||||
escape: '?boolean', // 弹幕文本是否转义
|
||||
});
|
||||
|
||||
// 弹幕文本为空则直接忽略
|
||||
@@ -322,11 +322,6 @@ export default class Danmuku {
|
||||
danmu.style = {};
|
||||
}
|
||||
|
||||
// 设置弹幕弹幕是否转义,如果没有则默认为 true,即不会显示 HTML 标签
|
||||
if (danmu.escape === undefined) {
|
||||
danmu.escape = true;
|
||||
}
|
||||
|
||||
// 设置弹幕颜色,如果没有则默认为全局配置
|
||||
if (danmu.color === undefined) {
|
||||
danmu.color = this.option.color;
|
||||
@@ -490,13 +485,7 @@ export default class Danmuku {
|
||||
if (state) {
|
||||
const { clientWidth, clientHeight } = this.$player;
|
||||
danmu.$ref = this.$ref; // 获取弹幕DOM节点
|
||||
|
||||
// 设置弹幕文本
|
||||
if (danmu.escape) {
|
||||
danmu.$ref.innerText = danmu.text;
|
||||
} else {
|
||||
danmu.$ref.innerHTML = danmu.text;
|
||||
}
|
||||
danmu.$ref.innerText = danmu.text; // 设置弹幕文本
|
||||
|
||||
// 提前添加到弹幕层中,用于计算top值
|
||||
this.$danmuku.appendChild(danmu.$ref);
|
||||
|
||||
@@ -45,11 +45,6 @@ type Danmu = {
|
||||
* 弹幕自定义样式
|
||||
*/
|
||||
style?: Partial<CSSStyleDeclaration>;
|
||||
|
||||
/**
|
||||
* 弹幕文本是否转义, 默认为 true
|
||||
*/
|
||||
escape?: boolean;
|
||||
};
|
||||
|
||||
type Option = {
|
||||
|
||||
@@ -52,7 +52,6 @@ https://unpkg.com/artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.js
|
||||
color: '#FFFFFF', // 弹幕颜色,默认为白色
|
||||
border: false, // 弹幕是否有描边, 默认为 false
|
||||
style: {}, // 弹幕自定义样式, 默认为空对象
|
||||
escape: true, // 弹幕文本是否转义, 默认为 true
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in new issue
Block a user