feat(runtime): 全站前端脚本统一接入 AksrtFrontend 全局 DOM 生命周期
- rehydrate.js 新增 boot()/aksrt:ready 事件,支持 boot 后晚注册立即以 init 触发 - aksrt-runtime.js 初始加载改走 AksrtFrontend.boot,tooltip/倒计时注册为组件 - 约 30 个前端脚本(首页、评论、支付、路由、页面叶子、widgets) 从直接 DOMContentLoaded 迁移为 AksrtFrontend.register,并加幂等标记 - section-navs 依赖改为 aksrt-runtime,保证注册时序 - 清理死代码:删除孤儿 loader.js/main.js 及 runtime/page-navs 遗留副本 - loader.js 移除已迁移模块的 tbquire 路径映射,main.js 相应瘦身 - build-public-assets.mjs 增加 runtime/main.min.js 自动压缩步骤 - 新增 4 个契约测试(homepage-dom/rehydrate-runtime/global-dom-init/ public-bundle-parity),3 个既有 harness 适配注册表初始化方式
This commit is contained in:
1 parent
5984d4e42d
commit
1f4a39d8f8
60 files changed
+1810
-1742
No files matched your search
+16
-39
@@ -1872,7 +1872,7 @@ function post_ajax(_this, con, jcon, item, loader, pag, next, trigger, replace,
|
||||
}
|
||||
|
||||
swiper_tab_AutoHeight($con);
|
||||
auto_fun();
|
||||
window.AksrtFrontend.rehydrate($con[0], 'ajax');
|
||||
},
|
||||
});
|
||||
return !1;
|
||||
@@ -1884,7 +1884,7 @@ _win.bd.on('click', '[remote-box]', function () {
|
||||
if (remote) {
|
||||
jQuery.post(remote, null, function (data) {
|
||||
_this.html(data).removeAttr('remote-box');
|
||||
auto_fun();
|
||||
window.AksrtFrontend.rehydrate(_this[0], 'ajax');
|
||||
_this.trigger('aksrt:remote-loaded');
|
||||
});
|
||||
}
|
||||
@@ -2176,7 +2176,7 @@ _win.bd.on('show.bs.modal loaded.bs.modal', '.modal:not(.flex)', function () {
|
||||
});
|
||||
|
||||
_win.bd.on('show.bs.modal loaded.bs.modal', '.modal', function () {
|
||||
auto_fun();
|
||||
window.AksrtFrontend.rehydrate(this, 'modal');
|
||||
});
|
||||
|
||||
_win.modal_z_index = 1050;
|
||||
@@ -2420,7 +2420,9 @@ function z_auto() {
|
||||
}
|
||||
}
|
||||
|
||||
window.auto_fun = debounce(z_auto_fun, 100);
|
||||
window.auto_fun = debounce(function (root) {
|
||||
window.AksrtFrontend.rehydrate(root && root.nodeType ? root : document, 'ajax');
|
||||
}, 100);
|
||||
function z_auto_fun() {
|
||||
jQuery(document).trigger('auto_fun');
|
||||
|
||||
@@ -2433,9 +2435,6 @@ function z_auto_fun() {
|
||||
//可复制
|
||||
jQuery('.cloneable').cloneable();
|
||||
|
||||
//倒计时
|
||||
jQuery('[data-countdown]').countdown();
|
||||
|
||||
auto_maxHeight();
|
||||
//兼容性图片懒加载
|
||||
jQuery('img[data-src]:not(.lazyload,.lazyloaded,.lazyloading,.swiper-lazy)').addClass('lazyload');
|
||||
@@ -2446,13 +2445,6 @@ function z_auto_fun() {
|
||||
});
|
||||
*/
|
||||
|
||||
jQuery('.dropdown-code,.dropdown-image,.dropdown-quick-often').length && tbquire(['input-expand']);
|
||||
/**上传图片 */
|
||||
jQuery('[aksrtupload]').length && tbquire(['mini-upload']);
|
||||
|
||||
//海报分享
|
||||
jQuery('[poster-share]').length && tbquire(['poster-share']); //海报分享
|
||||
|
||||
/* 提示工具*/
|
||||
jQuery("[data-toggle='tooltip']").tooltip({
|
||||
container: 'body',
|
||||
@@ -3095,21 +3087,6 @@ _win.bd.on('input focus', 'textarea[autoHeight]', function () {
|
||||
_win.bd.on('click', '.rewards', function () {
|
||||
jQuery('#rewards-popover').modal('show');
|
||||
});
|
||||
//用户中心
|
||||
_win.bd.hasClass('author') && tbquire(['author']);
|
||||
|
||||
//文章导航
|
||||
_win.bd.hasClass('page-template-postsnavs') && _win.bd.hasClass('logged-admin') && tbquire(['page-navs']);
|
||||
//前台编辑
|
||||
jQuery('#modal_admin_set').length && tbquire(['page-edit']);
|
||||
//评论
|
||||
jQuery('#commentform,#postcomments').length && tbquire(['comment']);
|
||||
//通用模板js文件
|
||||
_win.bd.hasClass('page-template') && tbquire(['page-template']);
|
||||
|
||||
//微信分享
|
||||
window.WeChatShareDate && tbquire(['weixin-share']);
|
||||
|
||||
//搜索关键词高亮
|
||||
if (_win.bd.hasClass('search')) {
|
||||
var val = jQuery('.search-desc-text .search-key').text();
|
||||
@@ -3520,7 +3497,7 @@ jQuery.fn.AutoSearch = function () {
|
||||
_this.removeClass(loading);
|
||||
_remind.html(result.remind || '');
|
||||
_icon.html(_icon_html);
|
||||
auto_fun();
|
||||
window.AksrtFrontend.rehydrate(_container[0], 'ajax');
|
||||
},
|
||||
'json'
|
||||
);
|
||||
@@ -3969,12 +3946,6 @@ function posts_limit_height() {
|
||||
}
|
||||
}
|
||||
|
||||
auto_fun();
|
||||
thumb_dplayer(_wid > 640 ? '.posts-item .item-thumbnail,.forum-lists-cover' : '.posts-item,.forum-posts', '.video-thumb-box[video-url]');
|
||||
|
||||
//页面加载之后自动点击
|
||||
jQuery('[load-click]').attr('no-scroll', true).click();
|
||||
|
||||
//图片延迟懒加载-ias自动加载
|
||||
jQuery(document).on('lazybeforeunveil', function (e) {
|
||||
var _this = jQuery(e.target);
|
||||
@@ -4553,7 +4524,7 @@ _win.bd.on('click', '.customize-preview-widget-edit', function (e) {
|
||||
});
|
||||
|
||||
//页面加载完毕之后加载的函数
|
||||
jQuery(document).ready(function () {
|
||||
function initLegacyDocumentReady() {
|
||||
setTimeout(function () {
|
||||
//页面加载完毕之后再延迟两秒加载的函数
|
||||
|
||||
@@ -4700,8 +4671,6 @@ jQuery(document).ready(function () {
|
||||
});
|
||||
|
||||
/*文章目录*/
|
||||
jQuery('[data-nav] h1,[data-nav] h2,[data-nav] h3,[data-nav] h4').length > 2 && tbquire(['section-navs']);
|
||||
|
||||
//手势控制
|
||||
jQuery('[mini-touch]').each(function () {
|
||||
var _this = jQuery(this);
|
||||
@@ -4718,4 +4687,12 @@ jQuery(document).ready(function () {
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
window.AksrtFrontend.register('aksrt-legacy-main', function (root, reason) {
|
||||
z_auto_fun();
|
||||
if (reason !== 'init') return;
|
||||
initLegacyDocumentReady();
|
||||
thumb_dplayer(_wid > 640 ? '.posts-item .item-thumbnail,.forum-lists-cover' : '.posts-item,.forum-posts', '.video-thumb-box[video-url]');
|
||||
jQuery('[load-click]').attr('no-scroll', true).click();
|
||||
});
|
||||
Reference in new issue
Block a user