@macrowing/inbiz-codegen 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +592 -2
- package/bin/inbiz-codegen.mjs +7 -0
- package/package.json +32 -4
- package/scripts/prepare-templates.mjs +35 -0
- package/src/backend/init.mjs +170 -0
- package/src/config.mjs +150 -0
- package/src/favicon.mjs +100 -0
- package/src/generate.mjs +935 -0
- package/src/generated-output.mjs +107 -0
- package/src/index.mjs +346 -0
- package/src/menu/build.mjs +252 -0
- package/src/menu/check.mjs +163 -0
- package/src/menu/command.mjs +179 -0
- package/src/migrate-runtime.mjs +106 -0
- package/src/platform/client.mjs +167 -0
- package/src/platform/command.mjs +386 -0
- package/src/platform/pack.mjs +591 -0
- package/src/platform/recover.mjs +236 -0
- package/src/platform/startup.mjs +343 -0
- package/src/platform/state.mjs +116 -0
- package/src/platform/update.mjs +157 -0
- package/src/platform/zip.mjs +134 -0
- package/src/pull.mjs +284 -0
- package/src/scaffold/commands.mjs +349 -0
- package/src/scaffold/init.mjs +392 -0
- package/src/scaffold/template-files.mjs +40 -0
- package/src/scaffold/template-source.mjs +235 -0
- package/src/scaffold/template-sync.mjs +335 -0
- package/src/transform/heaviness.mjs +380 -0
- package/src/transform/preview-props.mjs +108 -0
- package/src/transform/published-page-links.mjs +61 -0
- package/src/transform/published-script.mjs +110 -0
- package/src/transform/registry.mjs +781 -0
- package/src/transform/schema-to-jsx.mjs +1708 -0
- package/src/util/des.mjs +10 -0
- package/templates/README.md +34 -0
- package/templates/backend/Directory.Build.props +19 -0
- package/templates/backend/Directory.Packages.props +49 -0
- package/templates/backend/Macrowing.Scaffold.slnx +13 -0
- package/templates/backend/host/Macrowing.Start/Init/app.json +8 -0
- package/templates/backend/host/Macrowing.Start/Init/menus.json +4 -0
- package/templates/backend/host/Macrowing.Start/Initialization/InitializationDefinition.cs +245 -0
- package/templates/backend/host/Macrowing.Start/Initialization/InitializationEndpoints.cs +57 -0
- package/templates/backend/host/Macrowing.Start/Initialization/InitializationHostedService.cs +63 -0
- package/templates/backend/host/Macrowing.Start/Initialization/InitializationOptions.cs +44 -0
- package/templates/backend/host/Macrowing.Start/Initialization/InitializationRunner.cs +294 -0
- package/templates/backend/host/Macrowing.Start/Initialization/InitializationState.cs +72 -0
- package/templates/backend/host/Macrowing.Start/Initialization/MenuFactory.cs +118 -0
- package/templates/backend/host/Macrowing.Start/Initialization/PackageBuilder.cs +317 -0
- package/templates/backend/host/Macrowing.Start/Initialization/PlatformAppImporter.cs +371 -0
- package/templates/backend/host/Macrowing.Start/Macrowing.Start.csproj +26 -0
- package/templates/backend/host/Macrowing.Start/Program.cs +33 -0
- package/templates/backend/host/Macrowing.Start/StartModule.cs +67 -0
- package/templates/backend/host/Macrowing.Start/appsettings.json +38 -0
- package/templates/backend/modules/Macrowing.Generated/Application/GeneratedApplicationAutoMapperProfile.cs +42 -0
- package/templates/backend/modules/Macrowing.Generated/Domain/Entities/GeneratedEntityBase.cs +72 -0
- package/templates/backend/modules/Macrowing.Generated/Domain/GeneratedConsts.cs +50 -0
- package/templates/backend/modules/Macrowing.Generated/EntityFrameworkCore/GeneratedDbContext.cs +55 -0
- package/templates/backend/modules/Macrowing.Generated/EntityFrameworkCore/GeneratedDbContextModelBuilderExtensions.cs +61 -0
- package/templates/backend/modules/Macrowing.Generated/EntityFrameworkCore/IGeneratedDbContext.cs +32 -0
- package/templates/backend/modules/Macrowing.Generated/GeneratedModule.cs +89 -0
- package/templates/backend/modules/Macrowing.Generated/Macrowing.Generated.csproj +22 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Cms/CmsClient.cs +95 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Cms/CmsModels.cs +81 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Dictionary/DictionaryClient.cs +44 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/InBizSdkModule.cs +16 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/InterfaceEngine/InterfaceEngineClient.cs +50 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Localization/LocalizationClient.cs +28 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Macrowing.InBiz.SDK.csproj +16 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Message/MessageClient.cs +99 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Message/MessageModels.cs +63 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Model/ModelClient.cs +131 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Model/ModelQuery.cs +108 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Model/ModelWrite.cs +44 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Permission/PermissionClient.cs +86 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Platform/InBizPlatformException.cs +42 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Platform/InBizPlatformRegistration.cs +60 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Platform/InBizPlatformTransport.cs +96 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Platform/InBizRequestContext.cs +27 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/README.md +117 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Details/WorkFlowDetailsClient.cs +35 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Details/WorkFlowDetailsQuery.cs +20 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Operations/WorkFlowOperationRequests.cs +105 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Operations/WorkFlowOperationsClient.cs +53 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/README.md +132 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Tracking/WorkFlowTrackingClient.cs +50 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Upgrade/WorkFlowUpgradeClient.cs +78 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Upgrade/WorkFlowUpgradeModels.cs +34 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/WorkFlowContracts.cs +88 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/WorkFlowRegistration.cs +59 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/WorkFlowTransport.cs +163 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Workbench/WorkFlowWorkbenchClient.cs +59 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Workbench/WorkFlowWorkbenchModels.cs +76 -0
- package/templates/backend/modules/Macrowing.OC.SDK/Macrowing.OC.SDK.csproj +20 -0
- package/templates/backend/modules/Macrowing.OC.SDK/OcSdkModule.cs +18 -0
- package/templates/backend/modules/Macrowing.OC.SDK/Protos/README.md +22 -0
- package/templates/backend/tests/Macrowing.InBiz.SDK.Tests/Macrowing.InBiz.SDK.Tests.csproj +14 -0
- package/templates/backend/tests/Macrowing.InBiz.SDK.Tests/PlatformContractTests.cs +288 -0
- package/templates/backend/tests/Macrowing.InBiz.SDK.Tests/PlatformLiveTests.cs +173 -0
- package/templates/backend/tests/Macrowing.InBiz.SDK.Tests/WorkFlowHttpServer.cs +113 -0
- package/templates/backend/tests/Macrowing.InBiz.SDK.Tests/WorkFlowLiveTests.cs +269 -0
- package/templates/backend/tests/Macrowing.InBiz.SDK.Tests/WorkFlowOperationsTests.cs +80 -0
- package/templates/backend/tests/Macrowing.InBiz.SDK.Tests/WorkFlowQueryTests.cs +163 -0
- package/templates/backend/tests/Macrowing.InBiz.SDK.Tests/WorkFlowTransportTests.cs +111 -0
- package/templates/backend/tests/Macrowing.InBiz.SDK.Tests/WorkFlowUpgradeTests.cs +87 -0
- package/templates/frontend/components/README.md +39 -0
- package/templates/frontend/components/app-components/README.md +33 -0
- package/templates/frontend/components/app-components/common/.gitkeep +0 -0
- package/templates/frontend/components/app-components/components/.gitkeep +0 -0
- package/templates/frontend/components/app-components/package.json +20 -0
- package/templates/frontend/mgt/.umirc.ts +574 -0
- package/templates/frontend/mgt/package.json +96 -0
- package/templates/frontend/mgt/src/app-extends.ts +9 -0
- package/templates/frontend/mgt/src/app.tsx +20 -0
- package/templates/frontend/mgt/src/config/app.ts +31 -0
- package/templates/frontend/mgt/src/layout/header.tsx +14 -0
- package/templates/frontend/mgt/src/layout/index.tsx +11 -0
- package/templates/frontend/mgt/src/layout/sidebar.tsx +14 -0
- package/templates/frontend/mgt/src/locales.ts +8 -0
- package/templates/frontend/mgt/src/pages/.gitkeep +0 -0
- package/templates/frontend/mgt/src/root.tsx +12 -0
- package/templates/frontend/mgt/src/route-view.tsx +3 -0
- package/templates/frontend/mgt/src/runtime.ts +21 -0
- package/templates/frontend/mgt/src/styles/app.css +1 -0
- package/templates/frontend/mgt/src/styles/layout.less +79 -0
- package/templates/frontend/mgt/tsconfig.json +65 -0
- package/templates/frontend/mgt/typings.d.ts +57 -0
- package/templates/frontend/wap/.umirc.ts +574 -0
- package/templates/frontend/wap/package.json +73 -0
- package/templates/frontend/wap/src/app-extends.ts +9 -0
- package/templates/frontend/wap/src/app.tsx +28 -0
- package/templates/frontend/wap/src/config/app.ts +31 -0
- package/templates/frontend/wap/src/layout/header.tsx +14 -0
- package/templates/frontend/wap/src/layout/index.tsx +18 -0
- package/templates/frontend/wap/src/layout/sidebar.tsx +14 -0
- package/templates/frontend/wap/src/locales.ts +8 -0
- package/templates/frontend/wap/src/pages/.gitkeep +0 -0
- package/templates/frontend/wap/src/root.tsx +12 -0
- package/templates/frontend/wap/src/route-view.tsx +3 -0
- package/templates/frontend/wap/src/runtime.ts +21 -0
- package/templates/frontend/wap/src/styles/adaptation.less +190 -0
- package/templates/frontend/wap/src/styles/app.css +7 -0
- package/templates/frontend/wap/src/styles/global.less +81 -0
- package/templates/frontend/wap/src/styles/layout.less +92 -0
- package/templates/frontend/wap/tsconfig.json +66 -0
- package/templates/frontend/wap/typings.d.ts +24 -0
- package/templates/frontend/web/.umirc.ts +574 -0
- package/templates/frontend/web/package.json +26 -0
- package/templates/frontend/web/src/app-extends.ts +9 -0
- package/templates/frontend/web/src/app.tsx +25 -0
- package/templates/frontend/web/src/config/app.ts +31 -0
- package/templates/frontend/web/src/layout/header.tsx +14 -0
- package/templates/frontend/web/src/layout/index.tsx +11 -0
- package/templates/frontend/web/src/layout/sidebar.tsx +14 -0
- package/templates/frontend/web/src/locales.ts +8 -0
- package/templates/frontend/web/src/root.tsx +12 -0
- package/templates/frontend/web/src/route-view.tsx +3 -0
- package/templates/frontend/web/src/runtime.ts +21 -0
- package/templates/frontend/web/src/styles/app.css +104 -0
- package/templates/frontend/web/src/styles/layout.less +124 -0
- package/templates/frontend/web/tsconfig.json +91 -0
- package/templates/frontend/web/typings.d.ts +46 -0
- package/templates/package.json +14 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 应用更新与发布(已存在应用的菜单同步)。
|
|
3
|
+
*
|
|
4
|
+
* 和 `recover.mjs`(只创建、不覆盖)互补:应用已经在线上了,菜单改名/改图标/
|
|
5
|
+
* 新增分组要走这条路径。
|
|
6
|
+
*
|
|
7
|
+
* 顺序(每一步都对着后端源码核对过,不是猜的):
|
|
8
|
+
*
|
|
9
|
+
* 上传(importZipUpdated,appId 走 header)
|
|
10
|
+
* → 更新规则校验({id}/validateUpdateRule)→ 轮询
|
|
11
|
+
* → 正式更新({id}/updateImport)→ 轮询
|
|
12
|
+
* → 查询工作版本(app/info?getVersionInfo=true)
|
|
13
|
+
* → 发布(appSite/publish)
|
|
14
|
+
*
|
|
15
|
+
* 两个必须记住的事实:
|
|
16
|
+
* - 导入只写**工作版本**,前端读的是**已发布版本**,不发布等于没导;
|
|
17
|
+
* - 发布接口只认工作版本的 dataVersionId(getVersionInfo=true 才拿得到)。
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { createPlatformClient, platformError, ERR } from './client.mjs';
|
|
21
|
+
import { waitForTask, POLL } from './recover.mjs';
|
|
22
|
+
|
|
23
|
+
const API = {
|
|
24
|
+
appInfo: '/inbiz/api/services/front/engines/v3/app/info',
|
|
25
|
+
importZipUpdated: '/inbiz/api/services/init/v3/app/importZipUpdated',
|
|
26
|
+
validateUpdateRule: (appId) => `/inbiz/api/services/init/v3/app/${encodeURIComponent(appId)}/validateUpdateRule`,
|
|
27
|
+
updateImport: (appId) => `/inbiz/api/services/init/v3/app/${encodeURIComponent(appId)}/updateImport`,
|
|
28
|
+
publish: '/inbiz/api/services/engines/v3/appSite/publish',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/** 端名 → 平台 SiteType(0=Web / 1=Wap / 2=Mgt)。 */
|
|
32
|
+
export const END_TO_SITE_TYPE = { web: 0, wap: 1, mgt: 2 };
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 按端挑站点;对不上时退回第一个(单端应用是常态)。
|
|
36
|
+
*
|
|
37
|
+
* `siteType` 允许传数字(平台的 SiteType)或端名(web/wap/mgt)——
|
|
38
|
+
* 传字符串时 `Number('web')` 是 NaN,不能拿它去比对。
|
|
39
|
+
*/
|
|
40
|
+
export function pickSite(info, end, siteType) {
|
|
41
|
+
const sites = Array.isArray(info?.Sites) ? info.Sites : [];
|
|
42
|
+
if (!sites.length) return null;
|
|
43
|
+
|
|
44
|
+
let wanted = null;
|
|
45
|
+
if (siteType !== undefined && siteType !== null && String(siteType).trim() !== '') {
|
|
46
|
+
const numeric = Number(siteType);
|
|
47
|
+
if (Number.isFinite(numeric)) {
|
|
48
|
+
wanted = numeric;
|
|
49
|
+
} else {
|
|
50
|
+
wanted = END_TO_SITE_TYPE[String(siteType).toLowerCase()] ?? null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (wanted === null && end) {
|
|
54
|
+
wanted = END_TO_SITE_TYPE[String(end).toLowerCase()] ?? null;
|
|
55
|
+
}
|
|
56
|
+
if (wanted !== null) {
|
|
57
|
+
const byType = sites.find((site) => Number(site?.SiteType) === wanted);
|
|
58
|
+
if (byType) return byType;
|
|
59
|
+
}
|
|
60
|
+
return sites[0];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** 取工作版本信息(发布要的 siteOutId / dataVersionId 只有这份里有)。 */
|
|
64
|
+
export async function getWorkingVersion({ baseUrl, token, domain, fetchImpl }) {
|
|
65
|
+
const client = createPlatformClient({ baseUrl, fetchImpl, token, skipAppId: true });
|
|
66
|
+
return client.get(API.appInfo, { domain, getVersionInfo: 'true' });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 发布站点版本。
|
|
71
|
+
*
|
|
72
|
+
* @param {{baseUrl: string, token: string, appId: string, siteOutId: string,
|
|
73
|
+
* dataVersionId: string, remarks?: string, fetchImpl?: Function}} options
|
|
74
|
+
* @returns {Promise<{versionId: string}>} 平台生成的新工作版本
|
|
75
|
+
*/
|
|
76
|
+
export async function publishSite({ baseUrl, token, appId, siteOutId, dataVersionId, remarks = '', fetchImpl }) {
|
|
77
|
+
if (!siteOutId || !dataVersionId) {
|
|
78
|
+
throw platformError(ERR.UNEXPECTED, '发布需要 siteOutId 与工作版本 dataVersionId');
|
|
79
|
+
}
|
|
80
|
+
const client = createPlatformClient({ baseUrl, fetchImpl, token, appId });
|
|
81
|
+
try {
|
|
82
|
+
const json = await client.post(API.publish, { siteOutId, dataVersionId, remarks });
|
|
83
|
+
const versionId = json?.Id || json?.id || '';
|
|
84
|
+
if (!versionId) throw platformError(ERR.SERVER, '发布成功但未返回版本号');
|
|
85
|
+
return { versionId, alreadyPublished: false };
|
|
86
|
+
} catch (error) {
|
|
87
|
+
/**
|
|
88
|
+
* 「当前版本已发布」不是失败。
|
|
89
|
+
*
|
|
90
|
+
* 应用导入接口在导入流程末尾就会发布一次(后端源码
|
|
91
|
+
* `AppImportExportManager.PublishAsync`),所以导入完再调发布,平台会回
|
|
92
|
+
* 这个错误。菜单改动此时**已经生效**,当成成功处理,不能把它报成失败。
|
|
93
|
+
*/
|
|
94
|
+
if (/当前版本已发布/.test(error.message || '')) {
|
|
95
|
+
return { versionId: '', alreadyPublished: true };
|
|
96
|
+
}
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 覆盖导入已有应用的菜单包(不删除包里没有的菜单)。
|
|
103
|
+
*
|
|
104
|
+
* @param {{baseUrl: string, token: string, appId: string,
|
|
105
|
+
* package: {buffer: Buffer, contains?: number},
|
|
106
|
+
* fetchImpl?: Function, poll?: object, sleep?: Function, log?: Function}} options
|
|
107
|
+
* @returns {Promise<{tempFolderName: string, key: string}>}
|
|
108
|
+
*/
|
|
109
|
+
export async function updateApplication({
|
|
110
|
+
baseUrl, token, appId, package: pkg,
|
|
111
|
+
fetchImpl, poll = POLL, sleep = defaultSleep, log = () => {},
|
|
112
|
+
}) {
|
|
113
|
+
if (!appId) throw platformError(ERR.UNEXPECTED, '更新应用必须提供 appId');
|
|
114
|
+
if (!pkg?.buffer?.length) throw platformError(ERR.UNEXPECTED, '更新包为空');
|
|
115
|
+
|
|
116
|
+
const client = createPlatformClient({ baseUrl, fetchImpl, token, appId });
|
|
117
|
+
|
|
118
|
+
// 1) 上传。AppId 走 header(DTO 上是 [FromHeader]),body 只放文件。
|
|
119
|
+
const form = new FormData();
|
|
120
|
+
form.set('file', new Blob([pkg.buffer], { type: 'application/zip' }), 'app-update.zip');
|
|
121
|
+
form.set('isVsCode', 'true');
|
|
122
|
+
const uploaded = await client.postForm(API.importZipUpdated, form);
|
|
123
|
+
const tempFolderName = uploaded?.TempFolderName;
|
|
124
|
+
if (!tempFolderName) throw platformError(ERR.SERVER, '上传成功但未返回 TempFolderName');
|
|
125
|
+
log(`· 已上传更新包(tempFolderName=${tempFolderName})`);
|
|
126
|
+
|
|
127
|
+
// 2) 更新规则校验
|
|
128
|
+
const validated = await client.post(API.validateUpdateRule(appId), {
|
|
129
|
+
tempFolderName,
|
|
130
|
+
contains: Number(pkg.contains ?? uploaded?.Contains ?? 0),
|
|
131
|
+
});
|
|
132
|
+
const validateKey = validated?.ValidateKey;
|
|
133
|
+
if (validateKey) {
|
|
134
|
+
await waitForTask({ baseUrl, token, key: validateKey, what: '更新规则校验', fetchImpl, poll, sleep });
|
|
135
|
+
log('· 更新规则校验通过');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// 3) 正式更新。overwrite 决定业务属性(名称/图标)是否被包覆盖 —— 少了它就是「导入了但没生效」。
|
|
139
|
+
const updated = await client.post(API.updateImport(appId), {
|
|
140
|
+
tempFolderName,
|
|
141
|
+
overwrite: true,
|
|
142
|
+
isCover: false,
|
|
143
|
+
});
|
|
144
|
+
const key = updated?.Key;
|
|
145
|
+
if (key) {
|
|
146
|
+
await waitForTask({ baseUrl, token, key, what: '应用更新', fetchImpl, poll, sleep });
|
|
147
|
+
log('· 应用更新完成');
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return { tempFolderName, key: key || '' };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function defaultSleep(ms) {
|
|
154
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export { API as UPDATE_API };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 极简 ZIP 写入 / 读取(store 方式,不压缩)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么不用第三方库:恢复包只装 JSON 与少量静态资源,压缩收益很小;
|
|
5
|
+
* 而 CLI 的依赖越少,出错的环节越少(参见 templates 那条「依赖缺失要修来源,
|
|
6
|
+
* 不能降级掩盖」的约束)。store 方式是 ZIP 规范里最基础的一种,
|
|
7
|
+
* 平台侧的 .NET 解压实现无条件支持。
|
|
8
|
+
*
|
|
9
|
+
* 只实现到恢复需要的程度:多文件、目录项(由路径隐含,不单独写)、UTF-8 文件名。
|
|
10
|
+
* 不实现 deflate、加密、ZIP64。
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const CRC_TABLE = (() => {
|
|
14
|
+
const table = new Uint32Array(256);
|
|
15
|
+
for (let i = 0; i < 256; i += 1) {
|
|
16
|
+
let c = i;
|
|
17
|
+
for (let k = 0; k < 8; k += 1) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
|
|
18
|
+
table[i] = c >>> 0;
|
|
19
|
+
}
|
|
20
|
+
return table;
|
|
21
|
+
})();
|
|
22
|
+
|
|
23
|
+
export function crc32(buffer) {
|
|
24
|
+
let crc = 0xffffffff;
|
|
25
|
+
for (let i = 0; i < buffer.length; i += 1) crc = CRC_TABLE[(crc ^ buffer[i]) & 0xff] ^ (crc >>> 8);
|
|
26
|
+
return (crc ^ 0xffffffff) >>> 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function dosDateTime(date = new Date()) {
|
|
30
|
+
const year = Math.max(1980, date.getFullYear());
|
|
31
|
+
const time = (date.getHours() << 11) | (date.getMinutes() << 5) | Math.floor(date.getSeconds() / 2);
|
|
32
|
+
const day = ((year - 1980) << 9) | ((date.getMonth() + 1) << 5) | date.getDate();
|
|
33
|
+
return { time, day };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @param {{ name: string, data: Buffer | string }[]} entries
|
|
38
|
+
* @param {Date} [modifiedAt]
|
|
39
|
+
* @returns {Buffer}
|
|
40
|
+
*/
|
|
41
|
+
export function writeZip(entries, modifiedAt = new Date()) {
|
|
42
|
+
const { time, day } = dosDateTime(modifiedAt);
|
|
43
|
+
const locals = [];
|
|
44
|
+
const centrals = [];
|
|
45
|
+
let offset = 0;
|
|
46
|
+
|
|
47
|
+
for (const entry of entries) {
|
|
48
|
+
// ZIP 规范用 '/' 分隔;Windows 路径必须归一化,否则平台侧解出扁平文件名
|
|
49
|
+
const name = Buffer.from(entry.name.replace(/\\/g, '/'), 'utf8');
|
|
50
|
+
const data = Buffer.isBuffer(entry.data) ? entry.data : Buffer.from(entry.data, 'utf8');
|
|
51
|
+
const crc = crc32(data);
|
|
52
|
+
|
|
53
|
+
const local = Buffer.alloc(30);
|
|
54
|
+
local.writeUInt32LE(0x04034b50, 0);
|
|
55
|
+
local.writeUInt16LE(20, 4); // version needed
|
|
56
|
+
local.writeUInt16LE(0x0800, 6); // UTF-8 文件名
|
|
57
|
+
local.writeUInt16LE(0, 8); // store
|
|
58
|
+
local.writeUInt16LE(time, 10);
|
|
59
|
+
local.writeUInt16LE(day, 12);
|
|
60
|
+
local.writeUInt32LE(crc, 14);
|
|
61
|
+
local.writeUInt32LE(data.length, 18);
|
|
62
|
+
local.writeUInt32LE(data.length, 22);
|
|
63
|
+
local.writeUInt16LE(name.length, 26);
|
|
64
|
+
local.writeUInt16LE(0, 28);
|
|
65
|
+
locals.push(local, name, data);
|
|
66
|
+
|
|
67
|
+
const central = Buffer.alloc(46);
|
|
68
|
+
central.writeUInt32LE(0x02014b50, 0);
|
|
69
|
+
central.writeUInt16LE(20, 4); // version made by
|
|
70
|
+
central.writeUInt16LE(20, 6); // version needed
|
|
71
|
+
central.writeUInt16LE(0x0800, 8);
|
|
72
|
+
central.writeUInt16LE(0, 10);
|
|
73
|
+
central.writeUInt16LE(time, 12);
|
|
74
|
+
central.writeUInt16LE(day, 14);
|
|
75
|
+
central.writeUInt32LE(crc, 16);
|
|
76
|
+
central.writeUInt32LE(data.length, 20);
|
|
77
|
+
central.writeUInt32LE(data.length, 24);
|
|
78
|
+
central.writeUInt16LE(name.length, 28);
|
|
79
|
+
central.writeUInt16LE(0, 30); // extra
|
|
80
|
+
central.writeUInt16LE(0, 32); // comment
|
|
81
|
+
central.writeUInt16LE(0, 34); // disk
|
|
82
|
+
central.writeUInt16LE(0, 36); // internal attrs
|
|
83
|
+
central.writeUInt32LE(0, 38); // external attrs
|
|
84
|
+
central.writeUInt32LE(offset, 42);
|
|
85
|
+
centrals.push(central, name);
|
|
86
|
+
|
|
87
|
+
offset += local.length + name.length + data.length;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const centralBuffer = Buffer.concat(centrals);
|
|
91
|
+
const end = Buffer.alloc(22);
|
|
92
|
+
end.writeUInt32LE(0x06054b50, 0);
|
|
93
|
+
end.writeUInt16LE(0, 4);
|
|
94
|
+
end.writeUInt16LE(0, 6);
|
|
95
|
+
end.writeUInt16LE(entries.length, 8);
|
|
96
|
+
end.writeUInt16LE(entries.length, 10);
|
|
97
|
+
end.writeUInt32LE(centralBuffer.length, 12);
|
|
98
|
+
end.writeUInt32LE(offset, 16);
|
|
99
|
+
end.writeUInt16LE(0, 20);
|
|
100
|
+
|
|
101
|
+
return Buffer.concat([...locals, centralBuffer, end]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 只读目录:给测试与自检用(确认包里有该有的文件、没有不该有的)。
|
|
106
|
+
* @returns {{ name: string, size: number, crc: number, method: number }[]}
|
|
107
|
+
*/
|
|
108
|
+
export function readZipEntries(buffer) {
|
|
109
|
+
const endSignature = 0x06054b50;
|
|
110
|
+
let endOffset = -1;
|
|
111
|
+
for (let i = buffer.length - 22; i >= 0; i -= 1) {
|
|
112
|
+
if (buffer.readUInt32LE(i) === endSignature) {
|
|
113
|
+
endOffset = i;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (endOffset < 0) throw new Error('不是合法的 ZIP:找不到目录结束标记');
|
|
118
|
+
const count = buffer.readUInt16LE(endOffset + 10);
|
|
119
|
+
let cursor = buffer.readUInt32LE(endOffset + 16);
|
|
120
|
+
const out = [];
|
|
121
|
+
for (let i = 0; i < count; i += 1) {
|
|
122
|
+
if (buffer.readUInt32LE(cursor) !== 0x02014b50) throw new Error('不是合法的 ZIP:中央目录损坏');
|
|
123
|
+
const method = buffer.readUInt16LE(cursor + 10);
|
|
124
|
+
const crc = buffer.readUInt32LE(cursor + 16);
|
|
125
|
+
const size = buffer.readUInt32LE(cursor + 24);
|
|
126
|
+
const nameLength = buffer.readUInt16LE(cursor + 28);
|
|
127
|
+
const extraLength = buffer.readUInt16LE(cursor + 30);
|
|
128
|
+
const commentLength = buffer.readUInt16LE(cursor + 32);
|
|
129
|
+
const name = buffer.slice(cursor + 46, cursor + 46 + nameLength).toString('utf8');
|
|
130
|
+
out.push({ name, size, crc, method });
|
|
131
|
+
cursor += 46 + nameLength + extraLength + commentLength;
|
|
132
|
+
}
|
|
133
|
+
return out;
|
|
134
|
+
}
|
package/src/pull.mjs
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { loadConfig, ensureDir, DATA_DIR, WEB_DIR } from './config.mjs';
|
|
4
|
+
import { encryptData } from './util/des.mjs';
|
|
5
|
+
import { pullFavicon } from './favicon.mjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 拉取:登录平台 → 取应用信息 / 布局 / 菜单 / 语言包 / 页面列表与详情。
|
|
9
|
+
*
|
|
10
|
+
* 只调用平台的**只读**接口,不修改 InBiz 服务端任何数据。
|
|
11
|
+
* 结果落在 scaffolds/frontend/web/.inbiz/,作为 generate 的输入。
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
function makeClient(cfg, cookieHolder) {
|
|
15
|
+
const call = async (url, { method = 'GET', headers = {}, body } = {}) => {
|
|
16
|
+
const res = await fetch(cfg.baseUrl + url, {
|
|
17
|
+
method,
|
|
18
|
+
headers: {
|
|
19
|
+
appId: cfg.appId,
|
|
20
|
+
Accept: 'application/json',
|
|
21
|
+
...(cookieHolder.cookie ? { cookie: cookieHolder.cookie } : {}),
|
|
22
|
+
...headers,
|
|
23
|
+
},
|
|
24
|
+
body,
|
|
25
|
+
redirect: 'manual',
|
|
26
|
+
});
|
|
27
|
+
const text = await res.text();
|
|
28
|
+
let json;
|
|
29
|
+
try {
|
|
30
|
+
json = JSON.parse(text);
|
|
31
|
+
} catch {
|
|
32
|
+
json = null;
|
|
33
|
+
}
|
|
34
|
+
if (res.status >= 400) {
|
|
35
|
+
throw new Error(`${method} ${url} → HTTP ${res.status}: ${text.slice(0, 200)}`);
|
|
36
|
+
}
|
|
37
|
+
return json ?? text;
|
|
38
|
+
};
|
|
39
|
+
return { call };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function login(cfg, client) {
|
|
43
|
+
const body = new URLSearchParams({
|
|
44
|
+
account: encryptData(cfg.account),
|
|
45
|
+
password: encryptData(cfg.password),
|
|
46
|
+
rememberAccount: 'false',
|
|
47
|
+
validateCode: '',
|
|
48
|
+
secure: 'true',
|
|
49
|
+
validateCodeSms: '',
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const res = await fetch(cfg.baseUrl + '/inbiz/auth/api/auth/login', {
|
|
53
|
+
method: 'POST',
|
|
54
|
+
headers: {
|
|
55
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
56
|
+
Accept: 'application/json',
|
|
57
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
58
|
+
},
|
|
59
|
+
body: body.toString(),
|
|
60
|
+
redirect: 'manual',
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const json = await res.json().catch(() => ({}));
|
|
64
|
+
if (!json?.Successed) {
|
|
65
|
+
throw new Error('登录失败:' + (json?.Message || `HTTP ${res.status}`));
|
|
66
|
+
}
|
|
67
|
+
const setCookie = res.headers.getSetCookie ? res.headers.getSetCookie() : [];
|
|
68
|
+
const cookie = setCookie.map((c) => c.split(';')[0]).join('; ');
|
|
69
|
+
if (!cookie) throw new Error('登录成功但未拿到 Cookie');
|
|
70
|
+
return cookie;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 拉取指定应用的平台数据。
|
|
75
|
+
*
|
|
76
|
+
* 支持指定目录与指定应用:一个仓库里可以并存多个出码工程,
|
|
77
|
+
* 也可以对同一个 `.env` 临时用 `--app-id` 切到另一个应用出码。
|
|
78
|
+
*
|
|
79
|
+
* @param {{ dir?: string, appId?: string, siteType?: number, siteOutId?: string,
|
|
80
|
+
* dataVersionId?: string, account?: string, password?: string }} [options]
|
|
81
|
+
*/
|
|
82
|
+
export async function pull(options = {}) {
|
|
83
|
+
const dir = options.dir || WEB_DIR;
|
|
84
|
+
const dataDir = dir === WEB_DIR ? DATA_DIR : path.join(dir, '.inbiz');
|
|
85
|
+
const cfg = loadConfig(dir, options);
|
|
86
|
+
if (!cfg.account || !cfg.password) {
|
|
87
|
+
throw new Error('pull 需要平台账号:请在 .env 配置 INBIZ_PREVIEW_ACCOUNT / INBIZ_PREVIEW_PASSWORD');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
ensureDir(dataDir);
|
|
91
|
+
console.log(`→ 登录 ${cfg.baseUrl} …`);
|
|
92
|
+
const cookieHolder = { cookie: '' };
|
|
93
|
+
const client = makeClient(cfg, cookieHolder);
|
|
94
|
+
cookieHolder.cookie = await login(cfg, client);
|
|
95
|
+
console.log(' ✓ 已登录');
|
|
96
|
+
|
|
97
|
+
// 1) 应用信息
|
|
98
|
+
const appInfo = await client.call(`/inbiz/api/services/engines/v3/app/${cfg.appId}`);
|
|
99
|
+
const favicon = await pullFavicon({
|
|
100
|
+
logoPath: appInfo.App?.LogoPath,
|
|
101
|
+
baseUrl: cfg.baseUrl,
|
|
102
|
+
appId: appInfo.AppId || cfg.appId,
|
|
103
|
+
cookie: cookieHolder.cookie,
|
|
104
|
+
});
|
|
105
|
+
const site =
|
|
106
|
+
(appInfo.Sites || []).find((s) => Number(s.SiteType) === cfg.siteType) || appInfo.Sites?.[0];
|
|
107
|
+
if (!site) throw new Error('应用没有可用站点');
|
|
108
|
+
console.log(` ✓ 应用 ${appInfo.App?.AppName} / 站点 SiteType=${site.SiteType} WapSiteType=${site.WapSiteType}`);
|
|
109
|
+
|
|
110
|
+
// 2) 布局(框架层)
|
|
111
|
+
const layoutQs = new URLSearchParams({
|
|
112
|
+
siteOutId: site.OutId || cfg.siteOutId,
|
|
113
|
+
dataVersionId: cfg.dataVersionId || site.DataVersionId,
|
|
114
|
+
});
|
|
115
|
+
const layoutRaw = await client.call(
|
|
116
|
+
`/inbiz/api/services/front/engines/v3/appSite/layout?${layoutQs}`,
|
|
117
|
+
);
|
|
118
|
+
console.log(` ✓ 布局 ${Object.keys(JSON.parse(layoutRaw.LayoutInfo || '{}')).join('/')}`);
|
|
119
|
+
|
|
120
|
+
// 3) 菜单
|
|
121
|
+
//
|
|
122
|
+
// 平台 `GetMenuListAsync` 不带 `ParentId` 时**只返回第一层**(返回前又按
|
|
123
|
+
// ParentId 为空过滤了一次),所以一次请求拿不到整棵树 —— 必须按
|
|
124
|
+
// `IsHaveChild` 递归下去。之前只取一层,导致 Init/menus.json 和出码数据里
|
|
125
|
+
// 只剩一级菜单,二级三级全丢。
|
|
126
|
+
const menuQs = new URLSearchParams({
|
|
127
|
+
appId: cfg.appId,
|
|
128
|
+
siteOutId: site.OutId || cfg.siteOutId,
|
|
129
|
+
dataVersionId: cfg.dataVersionId || site.DataVersionId,
|
|
130
|
+
});
|
|
131
|
+
const menuList = await fetchMenuTree(client, menuQs);
|
|
132
|
+
console.log(` ✓ 菜单 ${menuList.length} 项`);
|
|
133
|
+
|
|
134
|
+
// 4) 语言包(把 i18n-xxx 词条还原成文本)
|
|
135
|
+
const kindCode = appInfo.Language?.Kinds?.find((k) => k.IsDefault)?.Code || 'zh-cn';
|
|
136
|
+
let messages = {};
|
|
137
|
+
try {
|
|
138
|
+
messages = await client.call(
|
|
139
|
+
`/inbiz/api/services/languagengine/v3/language/json/${cfg.appId}?kindCode=${kindCode}`,
|
|
140
|
+
);
|
|
141
|
+
console.log(` ✓ 语言包 ${Object.keys(messages || {}).length} 条(${kindCode})`);
|
|
142
|
+
} catch (e) {
|
|
143
|
+
console.warn(` ! 语言包拉取失败:${e.message}`);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 4.5) 应用级扩展:全局 CSS / JS(isoNav 这类定制样式都在这里)
|
|
147
|
+
let extend = { CssContent: '', OnLoadBefore: '', OnLoaded: '' };
|
|
148
|
+
try {
|
|
149
|
+
const qs = new URLSearchParams({
|
|
150
|
+
appId: cfg.appId,
|
|
151
|
+
siteOutId: site.OutId || cfg.siteOutId,
|
|
152
|
+
dataVersionId: cfg.dataVersionId || site.DataVersionId,
|
|
153
|
+
});
|
|
154
|
+
extend = await client.call(
|
|
155
|
+
`/inbiz/api/services/front/engines/v3/appSite/extend?${qs}`,
|
|
156
|
+
);
|
|
157
|
+
console.log(
|
|
158
|
+
` ✓ 应用级扩展:CSS ${(extend.CssContent || '').length} 字符,` +
|
|
159
|
+
`JS ${(extend.OnLoadBefore || '').length} 字符`,
|
|
160
|
+
);
|
|
161
|
+
} catch (e) {
|
|
162
|
+
console.warn(` ! 应用级扩展拉取失败:${e.message}`);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// 5) 页面树 → 逐个取页面详情
|
|
166
|
+
// 注意:菜单项的 OutId 是「菜单」ID,不是「页面」ID,二者不同。
|
|
167
|
+
// 页面必须从页面树里取,再用其 outId 调 loadDetail。
|
|
168
|
+
const treeQs = new URLSearchParams({
|
|
169
|
+
siteOutId: site.OutId || cfg.siteOutId,
|
|
170
|
+
dataVersionId: cfg.dataVersionId || site.DataVersionId,
|
|
171
|
+
});
|
|
172
|
+
let pageTree = [];
|
|
173
|
+
try {
|
|
174
|
+
const tree = await client.call(
|
|
175
|
+
`/inbiz/api/services/front/engines/v3/page/loadPageGroupTreeList?${treeQs}`,
|
|
176
|
+
);
|
|
177
|
+
pageTree = flattenPageTree(tree);
|
|
178
|
+
console.log(` ✓ 页面树 ${pageTree.length} 页`);
|
|
179
|
+
} catch (e) {
|
|
180
|
+
console.warn(` ! 页面树拉取失败:${e.message}`);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const pages = [];
|
|
184
|
+
for (const p of pageTree) {
|
|
185
|
+
if (!p.outId) continue;
|
|
186
|
+
try {
|
|
187
|
+
const qs = new URLSearchParams({
|
|
188
|
+
siteOutId: site.OutId || cfg.siteOutId,
|
|
189
|
+
dataVersionId: cfg.dataVersionId || site.DataVersionId,
|
|
190
|
+
outId: p.outId,
|
|
191
|
+
kindCode,
|
|
192
|
+
});
|
|
193
|
+
const detail = await client.call(
|
|
194
|
+
`/inbiz/api/services/front/engines/v3/page/loadDetail?${qs}`,
|
|
195
|
+
);
|
|
196
|
+
pages.push({ route: p.route, outId: p.outId, name: p.name, detail });
|
|
197
|
+
console.log(` ✓ 页面 ${p.route}`);
|
|
198
|
+
} catch (e) {
|
|
199
|
+
console.warn(` ! 页面 ${p.route} 拉取失败:${e.message}`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const dump = {
|
|
204
|
+
pulledAt: new Date().toISOString(),
|
|
205
|
+
app: appInfo.App,
|
|
206
|
+
favicon,
|
|
207
|
+
site,
|
|
208
|
+
language: { kindCode, messages },
|
|
209
|
+
extend,
|
|
210
|
+
layout: JSON.parse(layoutRaw.LayoutInfo || '{}'),
|
|
211
|
+
menu: menuList,
|
|
212
|
+
pages,
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const out = path.join(dataDir, 'app.json');
|
|
216
|
+
fs.writeFileSync(out, JSON.stringify(dump, null, 2), 'utf8');
|
|
217
|
+
fs.writeFileSync(path.join(dataDir, 'layout.raw.json'), JSON.stringify(layoutRaw), 'utf8');
|
|
218
|
+
console.log(`\n已写入 ${out}`);
|
|
219
|
+
return dump;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* 递归拉取整棵菜单树。
|
|
224
|
+
*
|
|
225
|
+
* 平台的 `menu/menuList` 是**逐层**接口:传 ParentId 返回该节点下一层,
|
|
226
|
+
* 不传只返回根层。子菜单只能这样一层层取 —— 平台自己的前端也是展开时才请求。
|
|
227
|
+
*
|
|
228
|
+
* `ShowHidden=true`:出码/初始化要的是「菜单的完整期望态」,
|
|
229
|
+
* 隐藏菜单也是线上真实存在的一条,由 `IsVisible` 表达它的可见性。
|
|
230
|
+
*/
|
|
231
|
+
async function fetchMenuTree(client, baseQs, parentId = '', seen = new Set()) {
|
|
232
|
+
const qs = new URLSearchParams(baseQs);
|
|
233
|
+
if (parentId) qs.set('ParentId', parentId);
|
|
234
|
+
qs.set('ShowHidden', 'true');
|
|
235
|
+
|
|
236
|
+
const res = await client.call(`/inbiz/api/services/front/engines/v3/menu/menuList?${qs}`);
|
|
237
|
+
const list = res?.MenuList || [];
|
|
238
|
+
const out = [];
|
|
239
|
+
for (const item of list) {
|
|
240
|
+
const outId = item?.OutId;
|
|
241
|
+
// 防御:数据坏了也只会少一条,不会无限递归
|
|
242
|
+
if (outId && seen.has(outId)) continue;
|
|
243
|
+
if (outId) seen.add(outId);
|
|
244
|
+
out.push(item);
|
|
245
|
+
if (item?.IsHaveChild) {
|
|
246
|
+
out.push(...await fetchMenuTree(client, baseQs, outId, seen));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return out;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* 页面树拍平:保留分组层级,生成 `分组路由/页面路由`。
|
|
254
|
+
*
|
|
255
|
+
* 平台把页面挂在分组下(如 file-maneger/file-list)。分组节点本身不是页面,
|
|
256
|
+
* 直接调 loadDetail 会返回「页面:不存在或已删除」。所以这里只收集叶子节点,
|
|
257
|
+
* 并把父级路由拼进路径,产物目录才能和平台结构一致。
|
|
258
|
+
*/
|
|
259
|
+
function flattenPageTree(node, parentRoute = '', out = []) {
|
|
260
|
+
if (!node) return out;
|
|
261
|
+
if (Array.isArray(node)) {
|
|
262
|
+
for (const n of node) flattenPageTree(n, parentRoute, out);
|
|
263
|
+
return out;
|
|
264
|
+
}
|
|
265
|
+
if (typeof node !== 'object') return out;
|
|
266
|
+
|
|
267
|
+
const route = node.Route || node.route;
|
|
268
|
+
const children = node.Children || node.children || node.Items || node.items;
|
|
269
|
+
const fullRoute = route ? (parentRoute ? parentRoute + '/' + route : route) : parentRoute;
|
|
270
|
+
|
|
271
|
+
if (Array.isArray(children) && children.length) {
|
|
272
|
+
// 分组节点:继续下钻;若它自身也带页面 id,同时收进来
|
|
273
|
+
const outId = node.OutId || node.outId || node.Id;
|
|
274
|
+
if (outId && route) out.push({ route: fullRoute, outId, name: node.Name || node.name || route, isGroup: true });
|
|
275
|
+
flattenPageTree(children, fullRoute, out);
|
|
276
|
+
return out;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const outId = node.OutId || node.outId || node.Id;
|
|
280
|
+
if (outId && route) {
|
|
281
|
+
out.push({ route: fullRoute, outId, name: node.Name || node.name || route });
|
|
282
|
+
}
|
|
283
|
+
return out;
|
|
284
|
+
}
|