fix(runtime): 按参考主题硬切换为 loader/main/auto_fun 单一 DOM 生命周期
- 删除 AksrtFrontend registry/rehydrate 双路架构及 build/public.js 拼包入口,
前台唯一初始路径为 PHP 本地栈(jQuery 1.9.1 → Bootstrap 3.4.1)
→ loader_js(_win/aksrtData 唯一注入)→ tbquire(['main']) → runtime/main.min.js
- window.auto_fun = debounce(z_auto_fun, 100) 为唯一重扫入口;所有模块改为
执行一次 + off/on('auto_fun.aksrt-*') 命名空间重扫,data/class 标记幂等
- 局部更新协议统一:HTML 注入 → post_ajax.ed → auto_fun();
远程 modal → loaded.bs.modal → auto_fun();JSON 成功 → zib_ajax.success
- 灯箱恢复 Miniimgbox/imgbox 唯一 owner(imgbox-container、a[data-imgbox]、
imgbox_data),删除 AksrtLightbox/data-aksrt-lightbox 第二实现及 CSS/overlay,
_win.imgbox* 重新接上 post-display 设置
- 死代码清理:runtime 下 11 组被自有实现替代的旧模块副本、无消费 vendored 库、
顶层 grade.min.js、revenue.js、无调用方的 aksrt_get_win_runtime_config(),
以及 loader 中 16 条死 mapping
- PHP 入队改为本地栈 + loader_js,routed/widget/submit 依赖统一换绑;
用户卡片发布按钮恢复 nav_user_newposts_btn 设置门控
- 测试对齐:新增 frontend-lifecycle-contract,重写 navigation/lazyload/toast/
auth-source/comment/page-display/post-visual 等断言为目标架构契约
验证:node --test widget-system+navigation 223 通过 0 失败;
构建脚本重建 main/imgbox min 与 CSS bundles;改动 PHP php -l、JS node --check
全部通过;git diff --check 干净;credits 重入 harness 通过。
This commit is contained in:
+45
-71
@@ -15,21 +15,6 @@
|
||||
return;
|
||||
}
|
||||
var activePoll = null;
|
||||
var balancesRefreshed = false;
|
||||
|
||||
function elementsIn(root, selector) {
|
||||
var elements = [];
|
||||
root = root || document;
|
||||
if (root.nodeType === 1 && root.matches(selector)) elements.push(root);
|
||||
if (root.querySelectorAll) root.querySelectorAll(selector).forEach(function (element) { elements.push(element); });
|
||||
return elements;
|
||||
}
|
||||
|
||||
function firstIn(root, selector) {
|
||||
root = root || document;
|
||||
if (root.nodeType === 1 && root.matches(selector)) return root;
|
||||
return root.querySelector ? root.querySelector(selector) : null;
|
||||
}
|
||||
|
||||
function operationKey(owner) {
|
||||
if (!owner.dataset.aksrtOperationKey) {
|
||||
@@ -104,12 +89,8 @@
|
||||
}
|
||||
|
||||
// Task-list "去签到" → scroll + click the real asset-card sign-in button.
|
||||
function initSigninGoto(root) {
|
||||
root = root || document;
|
||||
var items = [];
|
||||
if (root.nodeType === 1 && root.matches('[data-aksrt-signin-goto]')) items.push(root);
|
||||
if (root.querySelectorAll) root.querySelectorAll('[data-aksrt-signin-goto]').forEach(function (el) { items.push(el); });
|
||||
items.forEach(function (el) {
|
||||
function initSigninGoto() {
|
||||
document.querySelectorAll('[data-aksrt-signin-goto]').forEach(function (el) {
|
||||
if (el.dataset.aksrtSigninGotoInitialized === '1') return;
|
||||
el.dataset.aksrtSigninGotoInitialized = '1';
|
||||
el.addEventListener('click', function (e) {
|
||||
@@ -132,8 +113,8 @@
|
||||
}
|
||||
|
||||
// ===== Forward-only affiliate revenue center =====
|
||||
function initAffiliateRevenue(scope) {
|
||||
var root = firstIn(scope, '[data-aksrt-revenue-page]');
|
||||
function initAffiliateRevenue() {
|
||||
var root = document.querySelector('[data-aksrt-revenue-page]');
|
||||
if (!root || root.dataset.affiliateBound) return;
|
||||
root.dataset.affiliateBound = '1';
|
||||
var input = root.querySelector('[data-affiliate-link]');
|
||||
@@ -168,10 +149,9 @@
|
||||
|
||||
|
||||
// ===== VIP 积分兑换 =====
|
||||
function initVipPointsExchange(scope) {
|
||||
var root = firstIn(scope, '[data-aksrt-vip-points]');
|
||||
if (!root || root.dataset.aksrtVipPointsBound === '1') return;
|
||||
root.dataset.aksrtVipPointsBound = '1';
|
||||
function initVipPointsExchange() {
|
||||
var root = document.querySelector('[data-aksrt-vip-points]');
|
||||
if (!root) return;
|
||||
var tip = root.querySelector('[data-aksrt-vip-points-tip]');
|
||||
var busy = false;
|
||||
var coordinator = window.AksrtVipPurchaseCoordinator;
|
||||
@@ -211,10 +191,9 @@
|
||||
}
|
||||
|
||||
// ===== VIP 开通 =====
|
||||
function initVipShop(scope) {
|
||||
var root = firstIn(scope, '[data-aksrt-vip-shop]');
|
||||
if (!root || root.dataset.aksrtVipShopBound === '1') return;
|
||||
root.dataset.aksrtVipShopBound = '1';
|
||||
function initVipShop() {
|
||||
var root = document.querySelector('[data-aksrt-vip-shop]');
|
||||
if (!root) return;
|
||||
var tip = root.querySelector('[data-aksrt-vip-tip]');
|
||||
var busy = false;
|
||||
var coordinator = window.AksrtVipPurchaseCoordinator;
|
||||
@@ -286,13 +265,11 @@
|
||||
}
|
||||
|
||||
// ===== 卡密兑换(余额 / 会员) =====
|
||||
function initCardPass(scope) {
|
||||
var roots = elementsIn(scope, '[data-aksrt-card-pass]');
|
||||
function initCardPass() {
|
||||
var roots = document.querySelectorAll('[data-aksrt-card-pass]');
|
||||
if (!roots || !roots.length) return;
|
||||
|
||||
Array.prototype.forEach.call(roots, function (root) {
|
||||
if (root.dataset.aksrtCardPassBound === '1') return;
|
||||
root.dataset.aksrtCardPassBound = '1';
|
||||
var tip = root.querySelector('[data-aksrt-card-tip]');
|
||||
var busy = false;
|
||||
resetOperationKeyOnChange(root);
|
||||
@@ -403,8 +380,8 @@
|
||||
return handle;
|
||||
}
|
||||
|
||||
function initBalanceCharge(scope) {
|
||||
var modal = firstIn(scope, '[data-aksrt-charge-modal]');
|
||||
function initBalanceCharge() {
|
||||
var modal = document.querySelector('[data-aksrt-charge-modal]');
|
||||
if (!modal || modal.dataset.aksrtChargeInitialized === '1') return;
|
||||
modal.dataset.aksrtChargeInitialized = '1';
|
||||
var form = modal.querySelector('[data-aksrt-charge-form]');
|
||||
@@ -481,8 +458,8 @@
|
||||
});
|
||||
}
|
||||
|
||||
function initTransfer(scope) {
|
||||
var modal = firstIn(scope, '[data-aksrt-transfer-modal]');
|
||||
function initTransfer() {
|
||||
var modal = document.querySelector('[data-aksrt-transfer-modal]');
|
||||
if (!modal || modal.dataset.aksrtTransferInitialized === '1') return;
|
||||
modal.dataset.aksrtTransferInitialized = '1';
|
||||
var form = modal.querySelector('[data-aksrt-transfer-form]');
|
||||
@@ -613,8 +590,8 @@
|
||||
});
|
||||
}
|
||||
|
||||
function initPointsExchange(scope) {
|
||||
var modal = firstIn(scope, '[data-aksrt-points-exchange-modal]');
|
||||
function initPointsExchange() {
|
||||
var modal = document.querySelector('[data-aksrt-points-exchange-modal]');
|
||||
if (!modal || modal.dataset.aksrtPointsExchangeInitialized === '1') return;
|
||||
modal.dataset.aksrtPointsExchangeInitialized = '1';
|
||||
var form = modal.querySelector('[data-aksrt-points-exchange-form]');
|
||||
@@ -673,8 +650,8 @@
|
||||
});
|
||||
}
|
||||
|
||||
function initWithdraw(scope) {
|
||||
var modal = firstIn(scope, '[data-aksrt-withdraw-modal]');
|
||||
function initWithdraw() {
|
||||
var modal = document.querySelector('[data-aksrt-withdraw-modal]');
|
||||
if (!modal || modal.dataset.aksrtWithdrawInitialized === '1') return;
|
||||
modal.dataset.aksrtWithdrawInitialized = '1';
|
||||
var form = modal.querySelector('[data-aksrt-withdraw-form]');
|
||||
@@ -748,7 +725,8 @@
|
||||
.then(function (payload) {
|
||||
if (!payload || !payload.success || !payload.data || typeof payload.data.html !== 'string') return;
|
||||
panel.innerHTML = payload.data.html;
|
||||
if (window.AksrtFrontend && typeof window.AksrtFrontend.rehydrate === 'function') window.AksrtFrontend.rehydrate(panel, 'ajax');
|
||||
if (window.jQuery) jQuery(document).trigger('post_ajax.ed', [panel]);
|
||||
if (typeof window.auto_fun === 'function') window.auto_fun();
|
||||
});
|
||||
}
|
||||
}).catch(function () {
|
||||
@@ -758,28 +736,27 @@
|
||||
});
|
||||
}
|
||||
|
||||
function initAssetTabs(root) {
|
||||
var nav = elementsIn(root, '[data-aksrt-asset-tab]');
|
||||
function initAssetTabs() {
|
||||
var nav = document.querySelectorAll('[data-aksrt-asset-tab]');
|
||||
if (!nav.length) return;
|
||||
var scope = root || document;
|
||||
nav.forEach(function (link) {
|
||||
if (link.dataset.aksrtAssetTabBound === 'true') return;
|
||||
link.dataset.aksrtAssetTabBound = 'true';
|
||||
link.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
var key = link.getAttribute('data-aksrt-asset-tab');
|
||||
elementsIn(scope, '[data-aksrt-asset-tab]').forEach(function (a) {
|
||||
document.querySelectorAll('.uc-asset-tabs__nav [data-aksrt-asset-tab]').forEach(function (a) {
|
||||
var li = a.closest('li');
|
||||
if (!li) return;
|
||||
var aKey = a.getAttribute('data-aksrt-asset-tab');
|
||||
var on = aKey === key || (key === 'points_date' && aKey === 'points_free');
|
||||
li.classList.toggle('active', on);
|
||||
});
|
||||
var tabs = firstIn(scope, '.uc-asset-tabs');
|
||||
var tabs = document.querySelector('.uc-asset-tabs');
|
||||
if (tabs && typeof tabs.scrollIntoView === 'function') {
|
||||
tabs.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
}
|
||||
elementsIn(scope, '[data-aksrt-asset-pane]').forEach(function (pane) {
|
||||
document.querySelectorAll('[data-aksrt-asset-pane]').forEach(function (pane) {
|
||||
var on = pane.getAttribute('data-aksrt-asset-pane') === key;
|
||||
pane.classList.toggle('is-active', on);
|
||||
pane.hidden = !on;
|
||||
@@ -789,8 +766,8 @@
|
||||
}
|
||||
|
||||
|
||||
function initWithdrawHistory(scope) {
|
||||
var modal = firstIn(scope, '[data-aksrt-withdraw-history-modal]');
|
||||
function initWithdrawHistory() {
|
||||
var modal = document.querySelector('[data-aksrt-withdraw-history-modal]');
|
||||
if (!modal || modal.dataset.aksrtWithdrawHistoryInitialized === '1') return;
|
||||
modal.dataset.aksrtWithdrawHistoryInitialized = '1';
|
||||
function open() { modal.hidden = false; document.body.classList.add('uc-modal-open'); }
|
||||
@@ -809,25 +786,22 @@
|
||||
refresh: refreshAssetBalances
|
||||
};
|
||||
|
||||
function bootAssets(root, reason) {
|
||||
if (!balancesRefreshed && reason === 'init') {
|
||||
balancesRefreshed = true;
|
||||
refreshAssetBalances();
|
||||
}
|
||||
initSigninGoto(root);
|
||||
initAffiliateRevenue(root);
|
||||
initVipShop(root);
|
||||
initVipPointsExchange(root);
|
||||
initCardPass(root);
|
||||
initBalanceCharge(root);
|
||||
initTransfer(root);
|
||||
initPointsExchange(root);
|
||||
initWithdraw(root);
|
||||
initWithdrawHistory(root);
|
||||
initAssetTabs(root);
|
||||
function bootAssets() {
|
||||
refreshAssetBalances();
|
||||
initSigninGoto();
|
||||
initAffiliateRevenue();
|
||||
initVipShop();
|
||||
initVipPointsExchange();
|
||||
initCardPass();
|
||||
initBalanceCharge();
|
||||
initTransfer();
|
||||
initPointsExchange();
|
||||
initWithdraw();
|
||||
initWithdrawHistory();
|
||||
initAssetTabs();
|
||||
}
|
||||
|
||||
if (window.AksrtFrontend && typeof window.AksrtFrontend.register === 'function') {
|
||||
window.AksrtFrontend.register('credits', bootAssets);
|
||||
}
|
||||
jQuery(document).off('auto_fun.aksrt-credits').on('auto_fun.aksrt-credits', function () {
|
||||
bootAssets();
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user