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:
1 parent
1cd81fb61a
commit
5fd7c212ed
124 files changed
+2128
-17328
No files matched your search
+28
-10
@@ -6,7 +6,8 @@
|
||||
|
||||
function initCommentSystem() {
|
||||
var form = document.querySelector("#commentform");
|
||||
if (!form) return;
|
||||
if (!form || form.dataset.aksrtCommentInit === "1") return;
|
||||
form.dataset.aksrtCommentInit = "1";
|
||||
|
||||
// 修复:同时匹配 button 和 input 元素
|
||||
var submitBtn = form.querySelector('[type="submit"]');
|
||||
@@ -338,7 +339,9 @@
|
||||
notyf('评论发布成功', 'success');
|
||||
}
|
||||
|
||||
if (window.AksrtFrontend) AksrtFrontend.rehydrate(newComment, 'ajax');
|
||||
// legacy 事件顺序:先 post_ajax.ed,再全局 auto_fun 重扫
|
||||
newComment.dispatchEvent(new CustomEvent('post_ajax.ed', { bubbles: true }));
|
||||
if (typeof window.auto_fun === 'function') window.auto_fun();
|
||||
updateCommentCount(1);
|
||||
}
|
||||
|
||||
@@ -523,7 +526,9 @@
|
||||
var currentCount = commentsArea.querySelector(".title-theme small");
|
||||
if (currentCount && data.count_text) currentCount.textContent = data.count_text;
|
||||
|
||||
if (window.AksrtFrontend) AksrtFrontend.rehydrate(commentsArea, "ajax");
|
||||
// legacy 事件顺序:先 post_ajax.ed,再全局 auto_fun 重扫
|
||||
newListWrap.dispatchEvent(new CustomEvent("post_ajax.ed", { bubbles: true }));
|
||||
if (typeof window.auto_fun === "function") window.auto_fun();
|
||||
}
|
||||
|
||||
function fetchCommentFragment(opts) {
|
||||
@@ -575,7 +580,7 @@
|
||||
|
||||
/* ====== 评论排序(最新 / 最早) ====== */
|
||||
/**
|
||||
* Locate #id within a rehydrate root.
|
||||
* Locate #id within the given scope.
|
||||
* Document has getElementById; Element roots (AJAX panels) only have querySelector.
|
||||
*/
|
||||
function findInScope(scope, id) {
|
||||
@@ -596,9 +601,8 @@
|
||||
function initCommentOrder(root) {
|
||||
var scope = root || document;
|
||||
var commentsArea = findInScope(scope, "comments");
|
||||
if (!commentsArea) return;
|
||||
// Event delegation survives filter HTML replacement after AJAX rehydrate.
|
||||
if (commentsArea.dataset.orderInit === "1") return;
|
||||
if (!commentsArea || commentsArea.dataset.orderInit === "1") return;
|
||||
// Event delegation survives filter HTML replacement after AJAX refresh.
|
||||
commentsArea.dataset.orderInit = "1";
|
||||
|
||||
function renderLoadingState() {
|
||||
@@ -683,6 +687,8 @@
|
||||
|
||||
|
||||
/* ====== 数字分页跳页(legacy pag-jump) ====== */
|
||||
var commentPageJumpBound = false;
|
||||
|
||||
function jumpToCommentPage(page) {
|
||||
loadCommentPage(page).catch(function (error) {
|
||||
console.error("[AKSRT Comment] 跳页失败:", error);
|
||||
@@ -691,6 +697,8 @@
|
||||
}
|
||||
|
||||
function initCommentPageJump() {
|
||||
if (commentPageJumpBound) return;
|
||||
commentPageJumpBound = true;
|
||||
document.addEventListener("click", function (e) {
|
||||
var jump = e.target.closest ? e.target.closest("#comments .pag-jump") : null;
|
||||
if (!jump) return;
|
||||
@@ -708,12 +716,22 @@
|
||||
});
|
||||
}
|
||||
|
||||
window.AksrtFrontend.register("aksrt-comment-system", function () {
|
||||
function init() {
|
||||
stripCommentUrlParams();
|
||||
initCommentSystem();
|
||||
initCommentPageJump();
|
||||
});
|
||||
window.AksrtFrontend.register("aksrt-comment-order", function (root) { initCommentOrder(root); });
|
||||
initCommentOrder();
|
||||
}
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", init);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
// AJAX 注入新内容后由 auto_fun 重扫(form/commentsArea 均带 data 标记,重复调用幂等)。
|
||||
if (window.jQuery) {
|
||||
window.jQuery(document).on("auto_fun", init);
|
||||
}
|
||||
|
||||
// 供 pagination.js 等模块复用:评论页码加载 / 列表刷新(局部 DOM,无 ? 参数)。
|
||||
window.AksrtComments = {
|
||||
|
||||
Reference in new issue
Block a user