fix: update config method to allow initialization flag

- Modified the config method to accept an initialization flag, allowing for configuration during the initial setup without triggering unnecessary updates.
- Updated the call to config in the constructor to pass the new initialization flag.
This commit is contained in:
Harvey Zack committed 2025-06-15 18:15:48 +08:00
1 parent 20b62ad3e3
commit bf5a186375
3 files changed
+7 -7

No files matched your search

@@ -229,7 +229,7 @@ class Danmuku {
stop: []
};
// 初始化配置
this.config(option);
this.config(option, true);
// 创建 Web Worker, 用于计算弹幕的 top 值
const workerText2 = (0, _workerDefault.default).replace('export{e as default};', '');
const blob = new Blob([
@@ -520,13 +520,13 @@ class Danmuku {
return this;
}
// 动态配置
config(option) {
config(option, isInit = false) {
const { clamp } = this.utils;
const { $controlsCenter } = this.art.template;
// 判断配置项是否有变化
const changed = Object.keys(option).some((key)=>JSON.stringify(this.option[key]) !== JSON.stringify(option[key]));
// 没有变化则直接返回
if (!changed) return this;
if (!changed && !isInit) return this;
// 更新配置项
this.option = Object.assign({}, Danmuku.option, this.option, option);
this.validator(this.option, Danmuku.scheme);