对小工具进行了一些修复

This commit is contained in:
2026-08-26 08:41:24 +08:00
parent e877ceb560
commit bb9413cba6
15 changed files with 463 additions and 136 deletions
+7 -4
View File
@@ -81,12 +81,15 @@
}
function evaluateDependencies($form) {
$form.find('[data-dependency]').each(function () {
$form.find('[data-dependency]').each(function () {
const rule = core.parseDependency(this.dataset.dependency || '[]');
const $row = $(this).closest('.aksrt-widget-repeater__row');
const current = fieldValue($row.length ? $row : $form, String(rule[0]));
const scope = $row.length ? $row : $form;
const ids = Array.isArray(rule[0]) ? rule[0].map((part) => part[0]) : String(rule[0] || '').split('|');
const current = {};
ids.forEach((id) => { current[id] = fieldValue(scope, id); });
this.hidden = !core.dependencyVisible(rule, current);
});
});
}
$(document)
@@ -116,7 +119,7 @@
})
.on('click', '.aksrt-widget-upload__choose', function () {
const $wrap = $(this).closest('.aksrt-widget-upload');
const frame = wp.media({ title: '选择媒体', multiple: false });
const frame = wp.media({ title: $wrap.data('media-library') === 'video' ? '选择视频' : '选择图片', library: $wrap.data('media-library') ? { type: $wrap.data('media-library') } : undefined, multiple: false });
frame.on('select', () => {
const attachment = frame.state().get('selection').first().toJSON();
$wrap.find('input[type="url"]').val(attachment.url).trigger('change');