Add visual CMS, media library and product directory
This commit is contained in:
+15
-3
@@ -41,9 +41,12 @@ jQuery(function ($) {
|
||||
event.preventDefault();
|
||||
const $form = $(this);
|
||||
if ($form.attr('aria-busy') === 'true') return;
|
||||
const submitter = event.originalEvent?.submitter;
|
||||
if (submitter?.dataset.confirm && !window.confirm(submitter.dataset.confirm)) return;
|
||||
const action = $form.attr('action');
|
||||
const isLogin = action === '/admin/login';
|
||||
const $submit = $form.find(':submit');
|
||||
const $submit = $form.find(':submit:enabled');
|
||||
const multipart = $form.attr('enctype') === 'multipart/form-data';
|
||||
$form.attr('aria-busy', 'true').children('.ajax-feedback').prop('hidden', true);
|
||||
$submit.prop('disabled', true);
|
||||
|
||||
@@ -53,10 +56,18 @@ jQuery(function ($) {
|
||||
}
|
||||
|
||||
function submit(canRetryLogin) {
|
||||
$form.triggerHandler('studio:sync');
|
||||
const fields = multipart ? new FormData($form.get(0)) : $form.serializeArray();
|
||||
if (submitter?.name) {
|
||||
if (multipart) fields.append(submitter.name, submitter.value);
|
||||
else fields.push({name: submitter.name, value: submitter.value});
|
||||
}
|
||||
$.ajax({
|
||||
url: action,
|
||||
method: 'POST',
|
||||
data: $form.serialize(),
|
||||
data: fields,
|
||||
processData: !multipart,
|
||||
contentType: multipart ? false : 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
dataType: 'json'
|
||||
}).done(function (response) {
|
||||
if (response.redirect) {
|
||||
@@ -82,6 +93,7 @@ jQuery(function ($) {
|
||||
|
||||
$('[data-editor]').each(function () {
|
||||
const $editor = $(this);
|
||||
if ($editor.find('[data-rich-canvas]').length) return;
|
||||
const area = $editor.find('textarea').get(0);
|
||||
const format = $editor.data('format');
|
||||
const $preview = $editor.find('.editor-preview');
|
||||
@@ -116,7 +128,7 @@ jQuery(function ($) {
|
||||
if (status === 'abort') return;
|
||||
let feedback = request.responseJSON;
|
||||
if (!feedback && request.getResponseHeader('Content-Type')?.startsWith('application/json')) {
|
||||
feedback = JSON.parse(request.responseText);
|
||||
try { feedback = JSON.parse(request.responseText); } catch { /* Use the fallback feedback. */ }
|
||||
}
|
||||
refreshToken(feedback);
|
||||
$preview.text(feedback?.message || '预览无法加载,请重试。');
|
||||
|
||||
Reference in New Issue
Block a user