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:
@@ -10,10 +10,8 @@ const cssBuildDir = path.join(repoRoot, 'assets/css/build');
|
||||
const jsBuildDir = path.join(repoRoot, 'assets/js/build');
|
||||
|
||||
const cssBundles = {
|
||||
// bootstrap / fontawesome5 / main.min.css 由 PHP 单独入队,不在此重复打包。
|
||||
'public.css': [
|
||||
'assets/css/bootstrap.min.css',
|
||||
'assets/fontawesome5/css/all.min.css',
|
||||
'assets/css/main.min.css',
|
||||
'style.css',
|
||||
'assets/css/core/tokens.css',
|
||||
'assets/css/core/reset.css',
|
||||
@@ -61,14 +59,8 @@ const cssBundles = {
|
||||
],
|
||||
};
|
||||
|
||||
const publicScripts = [
|
||||
'assets/js/runtime/libs/bootstrap.min.js',
|
||||
'assets/js/runtime/loader.js',
|
||||
'assets/js/lazy-image-attr.js',
|
||||
'assets/js/rehydrate.js',
|
||||
const runtimePreludeScripts = [
|
||||
'assets/js/notyf.js',
|
||||
'assets/js/aksrt-runtime.js',
|
||||
'assets/js/grade.min.js',
|
||||
'assets/js/core/modal-telemetry.js',
|
||||
'assets/js/core/request.js',
|
||||
'assets/js/core/modal-cache.js',
|
||||
@@ -84,16 +76,20 @@ const publicScripts = [
|
||||
'assets/js/core/archive.js',
|
||||
'assets/js/core/footer-tabbar.js',
|
||||
'assets/js/core/misc.js',
|
||||
'assets/js/core/theme.js',
|
||||
'assets/js/follow.js',
|
||||
'assets/js/enhancements.js',
|
||||
'assets/js/enhancements2.js',
|
||||
'assets/js/color-extract.js',
|
||||
'assets/js/effects.js',
|
||||
'assets/js/runtime/main.min.js',
|
||||
'assets/js/captcha-front.js',
|
||||
'assets/js/instant-page.js',
|
||||
];
|
||||
|
||||
const imgboxScripts = [
|
||||
'assets/js/runtime/imgbox.js',
|
||||
];
|
||||
|
||||
function normalizePath(filePath) {
|
||||
return filePath.split(path.sep).join('/');
|
||||
}
|
||||
@@ -164,31 +160,25 @@ async function buildCssBundle(outputName, sources) {
|
||||
]);
|
||||
}
|
||||
|
||||
async function buildScriptBundle() {
|
||||
async function buildScriptBundle(sources, outputName) {
|
||||
const sections = [];
|
||||
for (const source of publicScripts) {
|
||||
for (const source of sources) {
|
||||
const content = (await readFile(path.join(repoRoot, source), 'utf8')).trimEnd();
|
||||
sections.push(`/* source: ${source} */\n${content}\n;`);
|
||||
}
|
||||
await writeFile(path.join(jsBuildDir, 'public.js'), `${sections.join('\n\n')}\n`, 'utf8');
|
||||
}
|
||||
|
||||
async function buildRuntimeMainMin() {
|
||||
const sourcePath = path.join(repoRoot, 'assets/js/runtime/main.js');
|
||||
const outputPath = path.join(repoRoot, 'assets/js/runtime/main.min.js');
|
||||
const source = await readFile(sourcePath, 'utf8');
|
||||
const minified = await transform(source, {
|
||||
const bundle = `${sections.join('\n\n')}\n`;
|
||||
const minified = await transform(bundle, {
|
||||
charset: 'utf8',
|
||||
legalComments: 'inline',
|
||||
loader: 'js',
|
||||
// 保留原始标识符:压缩产生的 `$` 局部变量会破坏「禁用美元别名」契约。
|
||||
minifyIdentifiers: false,
|
||||
minifySyntax: true,
|
||||
minifyWhitespace: true,
|
||||
sourcefile: 'runtime/main.js',
|
||||
sourcefile: outputName,
|
||||
});
|
||||
await writeFile(outputPath, minified.code, 'utf8');
|
||||
await writeFile(path.join(repoRoot, outputName), minified.code, 'utf8');
|
||||
}
|
||||
|
||||
// 评论区硬切换后 main.min.css 由 main.css 重新生成,保持两者同步。
|
||||
async function buildMainMin() {
|
||||
const sourcePath = path.join(repoRoot, 'assets/css/main.css');
|
||||
@@ -206,12 +196,12 @@ async function buildMainMin() {
|
||||
|
||||
await mkdir(cssBuildDir, { recursive: true });
|
||||
await mkdir(jsBuildDir, { recursive: true });
|
||||
await buildRuntimeMainMin();
|
||||
// 先刷新 main.min.css,public.css 打包时才能读到最新内容。
|
||||
await buildMainMin();
|
||||
for (const [outputName, sources] of Object.entries(cssBundles)) {
|
||||
await buildCssBundle(outputName, sources);
|
||||
}
|
||||
await buildScriptBundle();
|
||||
await buildScriptBundle([...runtimePreludeScripts, 'assets/js/runtime/main.js'], 'assets/js/runtime/main.min.js');
|
||||
await buildScriptBundle(imgboxScripts, 'assets/js/runtime/imgbox.min.js');
|
||||
|
||||
console.log('Built public CSS and JS bundles.');
|
||||
console.log('Built public CSS and runtime JS bundles.');
|
||||
|
||||
Reference in New Issue
Block a user