feat(widgets): complete phase 3 atomic integration

This commit is contained in:
2026-08-17 18:21:47 +08:00
parent 7c3f4221fe
commit d5dfeb7102
89 changed files with 843 additions and 12886 deletions
+33
View File
@@ -159,6 +159,39 @@
.aksrt-widget-form-lazy__status { margin-top: 0; color: #646970; }
.aksrt-widget-placement-hint {
display: flex;
gap: 6px;
align-items: flex-start;
margin: 10px 0 0;
padding: 8px;
border-left: 3px solid #72aee6;
background: #f0f6fc;
color: #50575e;
}
.aksrt-widget-placement-hint.is-warning {
border-color: #dba617;
background: #fcf9e8;
color: #614200;
}
.aksrt-widget-transfer { margin: 16px 20px 16px 0; }
.aksrt-widget-transfer__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.aksrt-widget-transfer form { display: grid; align-content: start; gap: 9px; padding: 12px; border: 1px solid #dcdcde; border-radius: 6px; }
.aksrt-widget-transfer form h3 { margin: 0 0 3px; }
.aksrt-widget-transfer select,
.aksrt-widget-transfer input[type="file"] { width: 100%; }
.aksrt-widget-transfer__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.aksrt-widget-template-preview-output { grid-column: 1 / -1; max-height: 520px; overflow: auto; padding: 14px; border: 1px solid #dcdcde; background: #fff; }
.aksrt-widget-template-preview__area { margin-bottom: 18px; }
.aksrt-widget-template-preview__module { margin: 10px 0; padding: 12px; border: 1px dashed #c3c4c7; border-radius: 6px; }
@media (max-width: 1100px) {
.aksrt-widget-transfer__grid { grid-template-columns: 1fr; }
.aksrt-widget-template-preview-output { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) {
.aksrt-widget-switch span,
.aksrt-widget-switch span::after { transition: none; }
+41 -2
View File
@@ -16,8 +16,29 @@
if (output) this.addEventListener('input', () => { output.textContent = this.value; });
});
evaluateDependencies($root);
updateWidgetTitle($root);
updatePlacementWarning($root);
}
function updateWidgetTitle(root) {
const $root = $(root);
const title = String($root.find('.aksrt-widget-field[data-field-id="title"] input').first().val() || '').trim();
if (!title) return;
$root.closest('.widget').find('.widget-title h3, .widget-title-action + h3').first().contents().filter(function () {
return this.nodeType === Node.TEXT_NODE;
}).first().replaceWith(`${title} `);
}
function updatePlacementWarning(root) {
const $widget = $(root).closest('.widget');
const $hint = $widget.find('.aksrt-widget-placement-hint').first();
if (!$hint.length) return;
const size = String($hint.data('widget-size') || 'any');
const area = String($widget.closest('.widgets-sortables').attr('id') || '');
const isSidebar = /sidebar/.test(area);
$hint.toggleClass('is-warning', (size === 'wide' && isSidebar) || (size === 'sidebar' && !isSidebar && area !== ''));
}
function loadForm(container) {
const $container = $(container);
if ($container.data('loading') || $container.data('loaded')) return;
@@ -82,7 +103,11 @@
$(document)
.on('click', '.aksrt-widget-form-lazy__load', function () { loadForm($(this).closest('.aksrt-widget-form-lazy')); })
.on('click', '.widget.open .aksrt-widget-form-lazy', function () { loadForm(this); })
.on('change input', '.aksrt-widget-form input, .aksrt-widget-form select, .aksrt-widget-form textarea', function () { evaluateDependencies($(this).closest('.aksrt-widget-form')); })
.on('change input', '.aksrt-widget-form input, .aksrt-widget-form select, .aksrt-widget-form textarea', function () {
const $form = $(this).closest('.aksrt-widget-form');
evaluateDependencies($form);
updateWidgetTitle($form);
})
.on('click', '.aksrt-widget-repeater__add', function () {
const $repeater = $(this).closest('.aksrt-widget-repeater');
const max = Number($repeater.data('max-items') || 50);
@@ -116,10 +141,24 @@
const $wrap = $(this).closest('.aksrt-widget-upload');
$wrap.find('input[type="url"]').val('').trigger('change');
$wrap.find('img').remove();
});
})
.on('click', '.aksrt-widget-template-preview', function () {
const $form = $(this).closest('form');
const $output = $('.aksrt-widget-template-preview-output').first();
$output.prop('hidden', false).html('<p>正在生成预览…</p>');
$.post(config.ajaxUrl, {
action: 'aksrt_widgets_template_preview',
nonce: config.transferNonce,
template: $form.find('[name="template"]').val(),
}).done((response) => {
if (!response?.success) throw new Error('Invalid response');
$output.html(response.data.html || '<p>模板为空。</p>');
}).fail(() => $output.html('<p class="notice notice-error">预览加载失败。</p>'));
});
$(document).on('widget-added widget-updated', function (_event, widget) {
$(widget).find('.aksrt-widget-form-lazy').each(function () { loadForm(this); });
updatePlacementWarning(widget);
});
$(function () {
File diff suppressed because one or more lines are too long
+15
View File
@@ -0,0 +1,15 @@
# Widget third-party assets
Only libraries requested by the 37-widget registry are shipped. The five player/tilt files are pinned byte-for-byte from the frozen reference directory `C:\Users\Xing\Desktop\zibll\js\libs`; Swiper was already bundled by AKSRT and is shared with the new widget runtime.
| Asset | Upstream | License | SHA-256 |
|---|---|---|---|
| `DPlayer.min.js` | [DPlayer](https://github.com/DIYgod/DPlayer) | MIT | `361689807fc1e856f868df91036e41195d2c255619bd1c5526849c5ad7491241` |
| `hls.min.js` | [hls.js](https://github.com/video-dev/hls.js) | Apache-2.0 | `e876282a26116e323c8ed3e86bed3838a80dbbe3a2faa09f834bee86963ff760` |
| `flv.min.js` | [flv.js](https://github.com/bilibili/flv.js) | Apache-2.0 | `0668d36757cdc17804d5c0bd6fe8956d76370e73a733bf5bbc0eddbfbca2c6cc` |
| `dash.all.min.js` | [dash.js](https://github.com/Dash-Industry-Forum/dash.js) | BSD-3-Clause | `3e753969c16a2a78f420a25d24869f14721eb1d284418f9f22d35a31c3693cd9` |
| `vanilla-tilt.min.js` | [vanilla-tilt.js](https://github.com/micku7zu/vanilla-tilt.js) | MIT | `de6fa8d3f40dbae2726a72f7d1ae46bb0588267af05355bef1d128f737f4a282` |
| `../../js/swiper-bundle.min.js` | [Swiper 11.2.10](https://github.com/nolimits4web/swiper) | MIT | `985f1224c0eeec99d367a9db35e58e44b21e7eb9ce45831b15b4c108e41fd97f` |
| `../../css/frontend/swiper-bundle.min.css` | [Swiper 11.2.10](https://github.com/nolimits4web/swiper) | MIT | `74ca6aae5468dbc924790c3b4d219a089b90a34bad53a0f7ca3a73e73b6f5ab8` |
The hashes are the release contract. Do not replace these files through a CDN or silently update them.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long