mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-18 19:01:20 -08:00
Refactor Setting class to update and append items
This commit is contained in:
1 parent
5e09d2e513
commit
6cf85b2f39
3 files changed
+27
-29
No files matched your search
@@ -4667,19 +4667,18 @@ class Setting extends (0, _componentDefault.default) {
|
||||
if (target.$item) (0, _utils.remove)(target.$item);
|
||||
this.render();
|
||||
}
|
||||
update(setting) {
|
||||
const target = this.find(setting.name);
|
||||
update(item) {
|
||||
const target = this.find(item.name);
|
||||
if (target) {
|
||||
Object.assign(target, setting);
|
||||
Object.assign(target, item);
|
||||
this.format();
|
||||
this.render();
|
||||
} else this.add(setting);
|
||||
} else this.add(item);
|
||||
}
|
||||
add(setting) {
|
||||
this.option.push(setting);
|
||||
add(item, option = this.option) {
|
||||
option.push(item);
|
||||
this.format();
|
||||
const { $panel } = this.option;
|
||||
this.append($panel, setting);
|
||||
this.append(option, item);
|
||||
this.render();
|
||||
}
|
||||
creatHeader(item) {
|
||||
@@ -4875,11 +4874,11 @@ class Setting extends (0, _componentDefault.default) {
|
||||
item.$item = $item;
|
||||
return $item;
|
||||
}
|
||||
append($panel, item) {
|
||||
if (!$panel) return;
|
||||
if ((0, _utils.has)(item, "switch")) (0, _utils.append)($panel, this.creatItem("switch", item));
|
||||
else if ((0, _utils.has)(item, "range")) (0, _utils.append)($panel, this.creatItem("range", item));
|
||||
else (0, _utils.append)($panel, this.creatItem("selector", item));
|
||||
append(option, item) {
|
||||
if (!option.$panel) return;
|
||||
if ((0, _utils.has)(item, "switch")) (0, _utils.append)(option.$panel, this.creatItem("switch", item));
|
||||
else if ((0, _utils.has)(item, "range")) (0, _utils.append)(option.$panel, this.creatItem("range", item));
|
||||
else (0, _utils.append)(option.$panel, this.creatItem("selector", item));
|
||||
}
|
||||
render(option = this.option) {
|
||||
this.active = option;
|
||||
@@ -4891,7 +4890,7 @@ class Setting extends (0, _componentDefault.default) {
|
||||
(0, _utils.addClass)($panel, "art-setting-panel");
|
||||
option.$panel = $panel;
|
||||
if (option[0]?.$parent) (0, _utils.append)($panel, this.creatHeader(option[0]));
|
||||
for(let index = 0; index < option.length; index++)this.append($panel, option[index]);
|
||||
for(let index = 0; index < option.length; index++)this.append(option, option[index]);
|
||||
(0, _utils.append)(this.$parent, $panel);
|
||||
this.cache.set(option, $panel);
|
||||
(0, _utils.inverseClass)($panel, "art-current");
|
||||
|
||||
Reference in new issue
Block a user