This commit is contained in:
Harvey committed 2022-05-13 12:42:27 +08:00
1 parent 737b667c1b
commit 0aeb1262db
5 files changed
+2 -155

No files matched your search

-82
View File
@@ -283,88 +283,6 @@ export default class Setting extends Component {
return $item;
}
creatSwitch(item) {
const {
icons,
events: { proxy },
} = this.art;
const $item = document.createElement('div');
addClass($item, 'art-setting-item');
const $left = append($item, '<div class="art-setting-item-left"></div>');
const $right = append($item, '<div class="art-setting-item-right"></div>');
const $icon = document.createElement('div');
addClass($icon, 'art-setting-item-left-icon');
append($icon, item.icon || icons.config);
append($left, $icon);
item._$icon = $icon;
def(item, 'icon', {
get() {
return $icon.innerHTML;
},
set(value) {
if (typeof value === 'string' || typeof value === 'number') {
$icon.innerHTML = value;
}
},
});
const $html = document.createElement('div');
addClass($html, 'art-setting-item-left-text');
append($html, item.html || '');
append($left, $html);
item._$html = $html;
def(item, 'html', {
get() {
return $html.innerHTML;
},
set(value) {
if (typeof value === 'string' || typeof value === 'number') {
$html.innerHTML = value;
}
},
});
const $switch = document.createElement('div');
addClass($switch, 'art-setting-item-right-icon');
const $switchOn = append($switch, icons.switchOn);
const $switchOff = append($switch, icons.switchOff);
setStyle(item.switch ? $switchOff : $switchOn, 'display', 'none');
append($right, $switch);
item._$switch = item.switch;
def(item, 'switch', {
get() {
return item._$switch;
},
set(value) {
item._$switch = value;
if (value) {
setStyle($switchOff, 'display', 'none');
setStyle($switchOn, 'display', null);
} else {
setStyle($switchOff, 'display', null);
setStyle($switchOn, 'display', 'none');
}
},
});
const event = proxy($item, 'click', async (event) => {
if (item.onSwitch) {
item.switch = await item.onSwitch.call(this.art, item, $item, event);
}
});
this.events.push(event);
return $item;
}
init(option, width) {
const { constructor } = this.art;