@cloudbase/lowcode-builder 1.8.102 → 1.8.103
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/lib/builder/mp/BuildContext.d.ts +22 -0
- package/lib/builder/mp/index.js +7 -2
- package/lib/builder/mp/mp_config.d.ts +1 -1
- package/lib/builder/mp/mp_config.js +5 -1
- package/lib/builder/mp/util.d.ts +2 -1
- package/lib/builder/mp/util.js +38 -1
- package/lib/builder.web.js +7 -7
- package/package.json +3 -3
- package/template/html/index.html.ejs +1 -1
|
@@ -19,6 +19,24 @@ export interface ICommonBuildContext {
|
|
|
19
19
|
*/
|
|
20
20
|
isPrivateMode?: boolean;
|
|
21
21
|
}
|
|
22
|
+
export interface IDefaultAppWindowConfig {
|
|
23
|
+
navigationBarBackgroundColor?: string;
|
|
24
|
+
navigationBarTextStyle?: 'white' | 'black';
|
|
25
|
+
navigationBarTitleText?: string;
|
|
26
|
+
navigationStyle?: 'default' | 'custom';
|
|
27
|
+
homeButton?: boolean;
|
|
28
|
+
backgroundColor?: string;
|
|
29
|
+
backgroundTextStyle?: 'dark' | 'light';
|
|
30
|
+
backgroundColorTop?: string;
|
|
31
|
+
backgroundColorBottom?: string;
|
|
32
|
+
enablePullDownRefresh?: boolean;
|
|
33
|
+
onReachBottomDistance?: number;
|
|
34
|
+
pageOrientation?: 'portrait' | 'auto' | 'landscape';
|
|
35
|
+
restartStrategy?: string;
|
|
36
|
+
initialRenderingCache?: 'static' | 'dynamic';
|
|
37
|
+
visualEffectInBackground?: 'none' | 'hidden';
|
|
38
|
+
handleWebviewPreload?: 'static' | 'manual' | 'auto';
|
|
39
|
+
}
|
|
22
40
|
export interface IAppCommonBuildContext extends ICommonBuildContext {
|
|
23
41
|
/**
|
|
24
42
|
* 应用id
|
|
@@ -82,4 +100,8 @@ export interface IBuildContext extends IAppCommonBuildContext, IMpCommonBuildCon
|
|
|
82
100
|
* weda 默认自身root
|
|
83
101
|
*/
|
|
84
102
|
wedaRoot?: string;
|
|
103
|
+
/**
|
|
104
|
+
* app.json文件window配置
|
|
105
|
+
*/
|
|
106
|
+
defaultAppWindowConfig?: IDefaultAppWindowConfig;
|
|
85
107
|
}
|
package/lib/builder/mp/index.js
CHANGED
|
@@ -375,6 +375,8 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
|
|
|
375
375
|
// path.join(miniprogramRoot, buildContext.wedaRoot || '', materialsDirName),
|
|
376
376
|
// );
|
|
377
377
|
// }
|
|
378
|
+
const appJsonPath = path_1.default.join(miniprogramRoot, 'app.json');
|
|
379
|
+
const appJson = await fs.readJson(appJsonPath);
|
|
378
380
|
// 生成子包
|
|
379
381
|
await Promise.all(weapps.map(async (app, index) => {
|
|
380
382
|
if (index === 0) {
|
|
@@ -386,6 +388,9 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
|
|
|
386
388
|
...buildContext,
|
|
387
389
|
rootPath: app.rootPath,
|
|
388
390
|
};
|
|
391
|
+
if (appJson === null || appJson === void 0 ? void 0 : appJson.window) {
|
|
392
|
+
subpackageBuildCtx.defaultAppWindowConfig = appJson.window;
|
|
393
|
+
}
|
|
389
394
|
await generatePkg(subpackageBuildCtx, { cals: calses[index], weapp: app }, subpackageRootPath, pageConfigs[index], cssVarMap);
|
|
390
395
|
await generateFramework(subpackageBuildCtx, { cals: calses[index], weapp: app }, subpackageRootPath, {
|
|
391
396
|
deployOptions,
|
|
@@ -500,7 +505,7 @@ async function generatePkg(ctx, { cals, weapp }, appRoot, pageConfigs, cssVarMap
|
|
|
500
505
|
var _a;
|
|
501
506
|
const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!ctx.isProduction);
|
|
502
507
|
console.log(`Generating ${em(weapp.rootPath ? 'subApp' : 'app')} to ${appRoot}`);
|
|
503
|
-
const { processCssUnit = 'rpx' } = ctx;
|
|
508
|
+
const { processCssUnit = 'rpx', defaultAppWindowConfig = {} } = ctx;
|
|
504
509
|
if (weapp.mpPkgUrl) {
|
|
505
510
|
// 清空历史文件,使用zip覆盖
|
|
506
511
|
console.log(`Removing ${appRoot}`);
|
|
@@ -604,7 +609,7 @@ async function generatePkg(ctx, { cals, weapp }, appRoot, pageConfigs, cssVarMap
|
|
|
604
609
|
usingComponents,
|
|
605
610
|
componentGenerics,
|
|
606
611
|
componentPlaceholder,
|
|
607
|
-
extra: getAppendableJson(pageConfigs[page.id]),
|
|
612
|
+
extra: getAppendableJson((0, util_2.cleanWindowDefultConfig)(pageConfigs[page.id], defaultAppWindowConfig)),
|
|
608
613
|
},
|
|
609
614
|
[`index.wxml|${pageFileName}.wxml`]: {
|
|
610
615
|
content: wxml,
|
|
@@ -12,8 +12,8 @@ export declare function generateMpConfig(ctx: Omit<IBuildContext, 'wedaRoot'>, w
|
|
|
12
12
|
mpAppId?: string;
|
|
13
13
|
mpConfig?: IBuildWedaApp['mpConfig'];
|
|
14
14
|
}): Promise<{
|
|
15
|
-
appConfig: any;
|
|
16
15
|
projConfig: any;
|
|
16
|
+
appConfig: any;
|
|
17
17
|
pageConfigs: {}[];
|
|
18
18
|
}>;
|
|
19
19
|
interface ISubpackage {
|
|
@@ -35,6 +35,7 @@ const config_1 = require("../config");
|
|
|
35
35
|
const net_1 = require("../util/net");
|
|
36
36
|
const chalk_1 = __importDefault(require("chalk"));
|
|
37
37
|
const util_1 = require("../util");
|
|
38
|
+
const util_2 = require("./util");
|
|
38
39
|
/**
|
|
39
40
|
* generate app.json & page.json for mp
|
|
40
41
|
*
|
|
@@ -162,6 +163,9 @@ async function generateMpConfig(ctx, weapps, calses, options) {
|
|
|
162
163
|
});
|
|
163
164
|
}
|
|
164
165
|
});
|
|
166
|
+
if (appConfig === null || appConfig === void 0 ? void 0 : appConfig.window) {
|
|
167
|
+
appConfig.window = (0, util_2.cleanWindowDefultConfig)(appConfig);
|
|
168
|
+
}
|
|
165
169
|
if (!projConfig.setting) {
|
|
166
170
|
projConfig.setting = {};
|
|
167
171
|
}
|
|
@@ -181,7 +185,7 @@ async function generateMpConfig(ctx, weapps, calses, options) {
|
|
|
181
185
|
projConfig.appId = options.mpAppId;
|
|
182
186
|
}
|
|
183
187
|
// merge(pageConfigs, extractAllPagesConfig())
|
|
184
|
-
return {
|
|
188
|
+
return { projConfig, appConfig, pageConfigs };
|
|
185
189
|
}
|
|
186
190
|
exports.generateMpConfig = generateMpConfig;
|
|
187
191
|
function extractPages(weapps, pageConfigs, options) {
|
package/lib/builder/mp/util.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IDynamicValue, IWeAppComponentInstance, ActionType, ICompositedComponent, IWeAppPage, IEventListener, IQueryData } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
2
|
-
import { IMpCommonBuildContext } from './BuildContext';
|
|
2
|
+
import { IMpCommonBuildContext, IDefaultAppWindowConfig } from './BuildContext';
|
|
3
3
|
export declare function generatedDynamicData(data: {
|
|
4
4
|
[key: string]: IDynamicValue;
|
|
5
5
|
}, compInfo?: ICompositedComponent, filterBuiltInProps?: boolean): {
|
|
@@ -53,3 +53,4 @@ export declare function isRepeaterWidget(w: {
|
|
|
53
53
|
componentType?: string;
|
|
54
54
|
};
|
|
55
55
|
}, repeaterComponentName: string): true | undefined;
|
|
56
|
+
export declare function cleanWindowDefultConfig(jsonConfig: IDefaultAppWindowConfig, appConfig?: IDefaultAppWindowConfig): IDefaultAppWindowConfig;
|
package/lib/builder/mp/util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isRepeaterWidget = exports.generateScopedStyleText = exports.findComponentInfo = exports.processRepeaterSchema = exports.setDataBind = exports.createDataBinds = exports.generateArgsDynamicValueFromData = exports.createTemplateEventFlows = exports.createTemplateQuery = exports.generateDataContainerListeners = exports.generateSyncListeners = exports.createEventHandlers = exports.createWidgetProps = exports.generatedDynamicData = void 0;
|
|
3
|
+
exports.cleanWindowDefultConfig = exports.isRepeaterWidget = exports.generateScopedStyleText = exports.findComponentInfo = exports.processRepeaterSchema = exports.setDataBind = exports.createDataBinds = exports.generateArgsDynamicValueFromData = exports.createTemplateEventFlows = exports.createTemplateQuery = exports.generateDataContainerListeners = exports.generateSyncListeners = exports.createEventHandlers = exports.createWidgetProps = exports.generatedDynamicData = void 0;
|
|
4
4
|
const weapps_core_1 = require("@cloudbase/lowcode-generator/lib/weapps-core");
|
|
5
5
|
const lowcode_generator_1 = require("@cloudbase/lowcode-generator");
|
|
6
6
|
const weapp_1 = require("@cloudbase/lowcode-generator/lib/generator/util/weapp");
|
|
@@ -585,3 +585,40 @@ function checkRepeaterComponent(xComponent) {
|
|
|
585
585
|
}
|
|
586
586
|
return false;
|
|
587
587
|
}
|
|
588
|
+
// 小程序app.json window属性默认配置
|
|
589
|
+
const defaultConfig = {
|
|
590
|
+
navigationBarBackgroundColor: '#000000',
|
|
591
|
+
navigationBarTextStyle: 'white',
|
|
592
|
+
navigationBarTitleText: '',
|
|
593
|
+
navigationStyle: 'default',
|
|
594
|
+
homeButton: false,
|
|
595
|
+
backgroundColor: '#FFFFFF',
|
|
596
|
+
backgroundTextStyle: 'dark',
|
|
597
|
+
backgroundColorTop: '#FFFFFF',
|
|
598
|
+
backgroundColorBottom: '#FFFFFF',
|
|
599
|
+
enablePullDownRefresh: false,
|
|
600
|
+
onReachBottomDistance: 50,
|
|
601
|
+
pageOrientation: 'portrait',
|
|
602
|
+
restartStrategy: 'homePage',
|
|
603
|
+
visualEffectInBackground: 'none',
|
|
604
|
+
handleWebviewPreload: 'static',
|
|
605
|
+
};
|
|
606
|
+
// 筛选传入参数中与默认参数重复的部分,兼容大小写。
|
|
607
|
+
function removeDuplicatedSettings(customConfig, defaultConfig, appConfig) {
|
|
608
|
+
const resultConfig = {};
|
|
609
|
+
for (const key in customConfig) {
|
|
610
|
+
const customVal = typeof customConfig[key] === 'string' ? customConfig[key].toLowerCase() : customConfig[key];
|
|
611
|
+
const defaultVal = typeof defaultConfig[key] === 'string' ? defaultConfig[key].toLowerCase() : defaultConfig[key];
|
|
612
|
+
const appVal = typeof appConfig[key] === 'string' ? appConfig[key].toLowerCase() : appConfig[key];
|
|
613
|
+
// 逻辑为若appVal存在,则对比app,不存在情况下对比全局默认
|
|
614
|
+
if (customVal !== (appVal || defaultVal)) {
|
|
615
|
+
resultConfig[key] = customConfig[key];
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
return resultConfig;
|
|
619
|
+
}
|
|
620
|
+
// 删除传入配置中与默认值或者在index.json中与app.json相同的属性
|
|
621
|
+
function cleanWindowDefultConfig(jsonConfig, appConfig = {}) {
|
|
622
|
+
return removeDuplicatedSettings(jsonConfig, defaultConfig, appConfig);
|
|
623
|
+
}
|
|
624
|
+
exports.cleanWindowDefultConfig = cleanWindowDefultConfig;
|