update setting

This commit is contained in:
Harvey committed 2022-02-11 13:47:44 +08:00
1 parent 292516ab89
commit a56553c6f6
3 files changed
+11 -15

No files matched your search

+5 -6
View File
@@ -120,10 +120,7 @@ export default class Setting extends Component {
proxy($item, 'click', (event) => {
if (hasChildren) {
this.init(item.selector);
if (item.width) {
setStyle(this.$parent, 'width', `${item.width}px`);
}
this.init(item.selector, item.width);
} else {
inverseClass($item, 'art-current');
if (item.onSelect) {
@@ -144,20 +141,22 @@ export default class Setting extends Component {
this.init(this.option);
}
init(option) {
setStyle(this.$parent, 'width', `${this.width}px`);
init(option, width) {
if (this.cache.has(option)) {
const $panel = this.cache.get(option);
inverseClass($panel, 'art-current');
setStyle(this.$parent, 'width', `${$panel.dataset.width}px`);
} else {
const $panel = document.createElement('div');
addClass($panel, 'art-setting-panel');
for (let index = 0; index < option.length; index++) {
append($panel, this.creatItem(option[index]));
}
$panel.dataset.width = width || this.width;
append(this.$parent, $panel);
this.cache.set(option, $panel);
inverseClass($panel, 'art-current');
setStyle(this.$parent, 'width', `${$panel.dataset.width}px`);
}
}
}