refactor(modal): remove legacy compatibility paths
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bdfe3a461d
commit
34150f3358
18 files changed
+188
-380
No files matched your search
+16
-29
@@ -3,15 +3,12 @@
|
||||
*
|
||||
* User-center modal: category-grouped medal card grid + in-modal detail
|
||||
* view (medal-background card, obtain time, wear action). Also provides the
|
||||
* global wear handler used inside remote (AJAX HTML) badge modals.
|
||||
* global wear handler used inside runtime-loaded badge modals.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
function api(path, options) {
|
||||
if (!window.AksrtRequest || typeof window.AksrtRequest.request !== 'function') {
|
||||
return Promise.resolve({ ok: false, status: 0, json: { message: '请求适配器未加载' } });
|
||||
}
|
||||
return window.AksrtRequest.request(path, options || {}).then(function (response) {
|
||||
return { ok: response.ok, status: response.status, json: response.json || {} };
|
||||
}).catch(function (error) {
|
||||
@@ -25,15 +22,7 @@
|
||||
}
|
||||
|
||||
function toast(msg, type) {
|
||||
if (typeof window.AksrtToast === 'function') {
|
||||
window.AksrtToast(msg, type || 'info');
|
||||
return;
|
||||
}
|
||||
if (typeof window.aksrtNotify === 'function') {
|
||||
window.aksrtNotify(msg, type || 'info');
|
||||
return;
|
||||
}
|
||||
try { console.log('[AKSRT badges]', msg); } catch (_) {}
|
||||
window.AksrtToast(msg, type || 'info');
|
||||
}
|
||||
|
||||
function escapeHtml(s) {
|
||||
@@ -260,9 +249,7 @@
|
||||
return;
|
||||
}
|
||||
toast((r.json && r.json.message) || '已佩戴徽章', 'success');
|
||||
if (window.AksrtModalRuntime && typeof window.AksrtModalRuntime.invalidate === 'function') {
|
||||
window.AksrtModalRuntime.invalidate(['badges', 'identity']);
|
||||
}
|
||||
window.AksrtModalRuntime.invalidate(['badges', 'identity']);
|
||||
state.data = (r.json && r.json.data) || state.data;
|
||||
renderHead();
|
||||
renderGrid();
|
||||
@@ -352,9 +339,7 @@
|
||||
return;
|
||||
}
|
||||
toast((r.json && r.json.message) || '已佩戴徽章', 'success');
|
||||
if (window.AksrtModalRuntime && typeof window.AksrtModalRuntime.invalidate === 'function') {
|
||||
window.AksrtModalRuntime.invalidate(['badges', 'identity']);
|
||||
}
|
||||
window.AksrtModalRuntime.invalidate(['badges', 'identity']);
|
||||
// Re-open the refreshed single-badge modal so state stays in sync.
|
||||
var refreshed = null;
|
||||
try {
|
||||
@@ -362,19 +347,21 @@
|
||||
var data = r.json && r.json.data;
|
||||
var isSelf = data && data.is_self;
|
||||
if (isSelf && data.wear) {
|
||||
refreshed = (window.aksrtData && aksrtData.ajaxUrl)
|
||||
? aksrtData.ajaxUrl + '?action=aksrt_single_badge_info_modal&name=' + encodeURIComponent(data.wear) + '&user_id=' + (uid || 0)
|
||||
refreshed = (window.aksrtData && window.aksrtData.ajaxUrl)
|
||||
? window.aksrtData.ajaxUrl + '?action=aksrt_single_badge_info_modal&name=' + encodeURIComponent(data.wear) + '&user_id=' + (uid || 0)
|
||||
: null;
|
||||
}
|
||||
} catch (_) {}
|
||||
try {
|
||||
if (refreshed && window.AksrtRemoteModal && typeof window.AksrtRemoteModal.openRemote === 'function') {
|
||||
window.AksrtRemoteModal.openRemote({ url: refreshed, className: 'modal-mini', mobileBottom: true });
|
||||
} else {
|
||||
document.dispatchEvent(new CustomEvent('aksrt:remote-modal:close'));
|
||||
}
|
||||
} catch (_) {
|
||||
try { document.dispatchEvent(new CustomEvent('aksrt:remote-modal:close')); } catch (__) {}
|
||||
if (refreshed) {
|
||||
window.AksrtModalRuntime.openRemote({
|
||||
url: refreshed,
|
||||
className: 'modal-mini',
|
||||
mobileBottom: true,
|
||||
kind: 'badges',
|
||||
cache: false,
|
||||
});
|
||||
} else {
|
||||
window.AksrtModalRuntime.close('badge-wear');
|
||||
}
|
||||
}).catch(function () {
|
||||
toast('网络错误', 'error');
|
||||
|
||||
Reference in new issue
Block a user