Reorganize miniapp menu and fix legacy prototype React globals.
Move 安全培训扫码 under 小羚羚小程序 in the sidebar, eager-inject window.React before legacy page imports, and keep the sync script aligned with both behaviors. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -16,10 +16,13 @@ const sidebarPath = path.join(projectRoot, '.axhub/make/sidebar-tree.json');
|
||||
|
||||
const PAGE_ID_RE = /^[a-z0-9-]+$/u;
|
||||
|
||||
const XLL_MODULES = [
|
||||
{ slug: 'oneos-web-safety-training', title: '安全培训扫码', files: ['安全培训扫码.jsx'] },
|
||||
];
|
||||
|
||||
const MODULES = [
|
||||
{ slug: 'oneos-web-workbench', title: '工作台', files: ['工作台.jsx'] },
|
||||
{ slug: 'oneos-web-login', title: '登录', files: ['登录.jsx'] },
|
||||
{ slug: 'oneos-web-safety-training', title: '安全培训扫码', files: ['安全培训扫码.jsx'] },
|
||||
{ slug: 'oneos-web-vehicle-asset', title: '车辆管理', files: ['车辆管理.jsx', '车辆管理-查看.jsx'] },
|
||||
{ slug: 'oneos-web-contract-template', title: '合同模板管理', files: ['合同模板管理.jsx'] },
|
||||
{ slug: 'oneos-web-help-center', title: '帮助中心', dir: '帮助中心' },
|
||||
@@ -191,6 +194,7 @@ function writePrototype(module, pages) {
|
||||
* @name ${module.title}
|
||||
* 自 ONE-OS web端 原稿复刻(${pages.length} 个页面)
|
||||
*/
|
||||
import '../../common/oneosWebLegacy/legacyGlobals';
|
||||
import React from 'react';
|
||||
${importLines.join('\n')}
|
||||
import { OneosWebLegacyShell } from '../../common/oneosWebLegacy/OneosWebLegacyShell';
|
||||
@@ -219,25 +223,42 @@ function toComponentName(slug) {
|
||||
.join('');
|
||||
}
|
||||
|
||||
function updateSidebar(modules) {
|
||||
function toSidebarItem(module) {
|
||||
return {
|
||||
id: `item:prototypes:${module.slug}`,
|
||||
kind: 'item',
|
||||
title: module.title,
|
||||
itemKey: `prototypes/${module.slug}`,
|
||||
};
|
||||
}
|
||||
|
||||
function updateSidebar(webModules, xllModules) {
|
||||
const sidebar = JSON.parse(fs.readFileSync(sidebarPath, 'utf8'));
|
||||
const prefix = 'item:prototypes:oneos-web-';
|
||||
const existing = (sidebar.prototypes ?? []).filter((item) => !String(item.id).startsWith(prefix) && !String(item.itemKey).startsWith('prototypes/oneos-web-'));
|
||||
const existing = (sidebar.prototypes ?? []).filter(
|
||||
(item) =>
|
||||
item.id !== 'folder-prototypes-oneos-web'
|
||||
&& item.id !== 'folder-prototypes-xll-miniapp'
|
||||
&& !String(item.id).startsWith(prefix)
|
||||
&& !String(item.itemKey).startsWith('prototypes/oneos-web-'),
|
||||
);
|
||||
|
||||
const xllFolder = {
|
||||
id: 'folder-prototypes-xll-miniapp',
|
||||
kind: 'folder',
|
||||
title: '小羚羚小程序',
|
||||
children: xllModules.map(toSidebarItem),
|
||||
};
|
||||
|
||||
const oneosFolder = {
|
||||
id: 'folder-prototypes-oneos-web',
|
||||
kind: 'folder',
|
||||
title: 'ONE-OS Web 端',
|
||||
defaultExpanded: true,
|
||||
children: modules.map((module) => ({
|
||||
id: `item:prototypes:${module.slug}`,
|
||||
kind: 'item',
|
||||
title: module.title,
|
||||
itemKey: `prototypes/${module.slug}`,
|
||||
})),
|
||||
children: webModules.map(toSidebarItem),
|
||||
};
|
||||
|
||||
sidebar.prototypes = [...existing, oneosFolder];
|
||||
sidebar.prototypes = [...existing, xllFolder, oneosFolder];
|
||||
sidebar.updatedAt = new Date().toISOString();
|
||||
fs.writeFileSync(sidebarPath, `${JSON.stringify(sidebar, null, 2)}\n`, 'utf8');
|
||||
}
|
||||
@@ -248,7 +269,9 @@ function main() {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
for (const module of MODULES) {
|
||||
const allModules = [...XLL_MODULES, ...MODULES];
|
||||
|
||||
for (const module of allModules) {
|
||||
if (module.docsOnly) {
|
||||
writeRequirementsPrototype(module);
|
||||
console.log(`[ok] ${module.slug} (需求说明文档浏览)`);
|
||||
@@ -263,7 +286,7 @@ function main() {
|
||||
console.log(`[ok] ${module.slug} (${pages.length} pages)`);
|
||||
}
|
||||
|
||||
updateSidebar(MODULES);
|
||||
updateSidebar(MODULES, XLL_MODULES);
|
||||
console.log('已更新 .axhub/make/sidebar-tree.json');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user