@cloudbase/lowcode-builder 1.8.73 → 1.8.75
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/config/index.d.ts +2 -5
- package/lib/builder/config/index.js +3 -6
- package/lib/builder/core/index.d.ts +2 -1
- package/lib/builder/core/index.js +15 -24
- package/lib/builder/core/plugin.d.ts +1 -7
- package/lib/builder/core/plugin.js +0 -2
- package/lib/builder/mp/BuildContext.d.ts +8 -0
- package/lib/builder/mp/index.d.ts +2 -2
- package/lib/builder/mp/index.js +179 -124
- package/lib/builder/mp/materials.d.ts +1 -1
- package/lib/builder/mp/materials.js +11 -19
- package/lib/builder/mp/mixMode.d.ts +9 -3
- package/lib/builder/mp/mixMode.js +70 -137
- package/lib/builder/mp/mp_config.d.ts +1 -1
- package/lib/builder/mp/mp_config.js +28 -20
- package/lib/builder/mp/wxml.js +19 -2
- package/lib/builder/service/webpack.js +1 -1
- package/lib/builder/util/common.d.ts +1 -0
- package/lib/builder/util/common.js +8 -1
- package/lib/builder/util/net.d.ts +10 -1
- package/lib/builder/util/net.js +47 -8
- package/lib/builder.web.js +13 -13
- package/package.json +6 -5
- package/template/html/index.html.ejs +2 -2
- package/template/mp/app/weapps-api.js +19 -1
- package/template/mp/app.js +3 -120
- package/template/mp/common/info/index.js +5 -4
- package/template/mp/common/info/index.wxml +2 -2
- package/template/mp/common/privacyModal/index.js +3 -2
- package/template/mp/common/util.js +24 -12
- package/template/mp/common/weapp-page.js +24 -9
- package/template/mp/component/index.wxss +2 -0
- package/template/mp/datasources/index.js.tpl +122 -2
- package/template/mp/package.json +2 -2
- package/template/mp/packages/$wd_system/pages/login/components/input/index.js +40 -0
- package/template/mp/packages/$wd_system/pages/login/components/input/index.json +4 -0
- package/template/mp/packages/$wd_system/pages/login/components/input/index.wxml +11 -0
- package/template/mp/packages/$wd_system/pages/login/index.js +161 -0
- package/template/mp/packages/$wd_system/pages/login/index.json +16 -0
- package/template/mp/packages/$wd_system/pages/login/index.wxml +60 -0
- package/template/mp/packages/$wd_system/pages/login/index.wxss +60 -0
- package/template/mp/packages/$wd_system/pages/login/methods/loginByPassword.js +55 -0
- package/template/mp/packages/$wd_system/pages/login/methods/loginByWXPhone.js +68 -0
- package/template/mp/packages/$wd_system/pages/login/methods/loginSuccessCallBack.js +20 -0
- package/template/mp/page/api.js +5 -6
- package/template/mp/page/index.js +4 -1
- package/template/package.json +6 -5
- package/template/webpack/web.dev.js +21 -0
|
@@ -26,155 +26,88 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.handleMixMode = void 0;
|
|
29
|
+
exports.handleSubApps = exports.handleMixMode = void 0;
|
|
30
30
|
const path_1 = __importDefault(require("path"));
|
|
31
31
|
const fs_extra_1 = __importStar(require("fs-extra"));
|
|
32
32
|
const mp_1 = require("../util/mp");
|
|
33
|
-
const plugin_1 = require("./plugin");
|
|
34
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
35
33
|
const generateFiles_1 = require("../util/generateFiles");
|
|
36
|
-
const webpack_1 = require("../service/webpack");
|
|
37
34
|
// 将 BUILD 目录往混合模式移动
|
|
38
|
-
async function handleMixMode({ buildContext, apps = [], miniprogramRoot,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
await (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
35
|
+
async function handleMixMode({ buildContext, apps = [], miniprogramRoot, wedaRoot, }) {
|
|
36
|
+
await handleSubApps({ buildContext, apps, miniprogramRoot, wedaRoot });
|
|
37
|
+
}
|
|
38
|
+
exports.handleMixMode = handleMixMode;
|
|
39
|
+
async function handleSubApps({ buildContext, apps = [], miniprogramRoot, wedaRoot, }) {
|
|
40
|
+
let modifiedAppJson = false;
|
|
41
|
+
const rootAppJosnPath = path_1.default.join(miniprogramRoot, 'app.json');
|
|
42
|
+
let rootAppJosn = await fs_extra_1.default.readJSON(rootAppJosnPath);
|
|
43
|
+
let modifiedPackageJosn = false;
|
|
44
|
+
const rootPackageJosnPath = path_1.default.join(wedaRoot, 'package.json');
|
|
45
|
+
let rootPackageJson = fs_extra_1.default.existsSync(rootPackageJosnPath)
|
|
46
|
+
? await fs_extra_1.default.readJson(rootPackageJosnPath)
|
|
47
|
+
: {
|
|
48
|
+
name: 'WeDa-app',
|
|
49
|
+
version: '1.0.0',
|
|
50
|
+
};
|
|
51
|
+
let mergeDependencies = {};
|
|
52
|
+
await Promise.all(apps
|
|
53
|
+
.filter((app) => app.rootPath)
|
|
54
|
+
.map(async (app) => {
|
|
55
|
+
const subAppPath = path_1.default.join(wedaRoot, ...(app.rootPath ? ['packages', app.rootPath] : ['']));
|
|
56
|
+
// 复制整个子包
|
|
57
|
+
// 新模式下已经生成,感觉无需进行复制 @royhyang
|
|
58
|
+
// const distDir = path.join(generateMpPath, app.rootPath || '')
|
|
59
|
+
// await fs.copy(subAppPath, distDir, { overwrite: true })
|
|
60
|
+
const appJsonPath = path_1.default.join(subAppPath, 'app.json');
|
|
61
|
+
if (fs_extra_1.default.existsSync(appJsonPath)) {
|
|
62
|
+
let appJson = await fs_extra_1.default.readJson(appJsonPath);
|
|
63
|
+
if (appJson) {
|
|
64
|
+
let { subpackages = [] } = rootAppJosn;
|
|
65
|
+
const subRoot = path_1.default.join('./', buildContext.wedaRoot || '', `packages/${app.rootPath}`);
|
|
66
|
+
const find = subpackages.find((item) => item.root === subRoot);
|
|
67
|
+
if (find) {
|
|
68
|
+
find.pages = appJson.pages;
|
|
62
69
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
// 复制主包的页面,需要判断是否有冲突
|
|
68
|
-
async function handleAppPages() {
|
|
69
|
-
// 需要特殊处理的
|
|
70
|
-
const srcDir = path_1.default.join(miniprogramRoot, 'pages');
|
|
71
|
-
const distDir = path_1.default.join(generateMpPath, 'pages');
|
|
72
|
-
const pageList = await fs_extra_1.default.readdir(srcDir);
|
|
73
|
-
await Promise.all(pageList.map(async (page) => {
|
|
74
|
-
const srcPageDir = path_1.default.join(srcDir, page);
|
|
75
|
-
const srcDistDir = path_1.default.join(distDir, page);
|
|
76
|
-
if (await fs_extra_1.default.pathExists(srcDistDir)) {
|
|
77
|
-
console.log(chalk_1.default.yellow(`【混合模式】 WeApps 中的 pages/${page} 与小程序 pages/${page} 重复,会以 WeApps 的为主`));
|
|
78
|
-
}
|
|
79
|
-
await fs_extra_1.default.copy(srcPageDir, srcDistDir);
|
|
80
|
-
}));
|
|
81
|
-
}
|
|
82
|
-
async function handleSubApps() {
|
|
83
|
-
let modifiedAppJson = false;
|
|
84
|
-
const rootAppJosnPath = path_1.default.join(miniprogramRoot, 'app.json');
|
|
85
|
-
let rootAppJosn = await fs_extra_1.default.readJSON(rootAppJosnPath);
|
|
86
|
-
let modifiedPackageJosn = false;
|
|
87
|
-
const rootPackageJosnPath = path_1.default.join(miniprogramRoot, 'package.json');
|
|
88
|
-
let rootPackageJson = fs_extra_1.default.existsSync(rootPackageJosnPath)
|
|
89
|
-
? await fs_extra_1.default.readJson(rootPackageJosnPath)
|
|
90
|
-
: {
|
|
91
|
-
name: 'WeDa-app',
|
|
92
|
-
version: '1.0.0',
|
|
93
|
-
};
|
|
94
|
-
let mergeDependencies = {};
|
|
95
|
-
await Promise.all(apps
|
|
96
|
-
.filter((app) => app.rootPath)
|
|
97
|
-
.map(async (app) => {
|
|
98
|
-
const subAppPath = path_1.default.join(miniprogramRoot, ...(app.rootPath ? ['packages', app.rootPath] : ['']));
|
|
99
|
-
// 复制整个子包
|
|
100
|
-
// 新模式下已经生成,感觉无需进行复制 @royhyang
|
|
101
|
-
// const distDir = path.join(generateMpPath, app.rootPath || '')
|
|
102
|
-
// await fs.copy(subAppPath, distDir, { overwrite: true })
|
|
103
|
-
const appJsonPath = path_1.default.join(subAppPath, 'app.json');
|
|
104
|
-
if (fs_extra_1.default.existsSync(appJsonPath)) {
|
|
105
|
-
let appJson = await fs_extra_1.default.readJson(appJsonPath);
|
|
106
|
-
if (appJson) {
|
|
107
|
-
let { subpackages = [] } = rootAppJosn;
|
|
108
|
-
const find = subpackages.find((item) => item.root === `packages/${app.rootPath}`);
|
|
109
|
-
if (find) {
|
|
110
|
-
find.pages = appJson.pages;
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
if (!rootAppJosn.subpackages) {
|
|
114
|
-
rootAppJosn.subpackages = [];
|
|
115
|
-
}
|
|
116
|
-
rootAppJosn.subpackages.push({
|
|
117
|
-
root: `packages/${app.rootPath}`,
|
|
118
|
-
pages: appJson.pages,
|
|
119
|
-
});
|
|
70
|
+
else {
|
|
71
|
+
if (!rootAppJosn.subpackages) {
|
|
72
|
+
rootAppJosn.subpackages = [];
|
|
120
73
|
}
|
|
121
|
-
|
|
74
|
+
rootAppJosn.subpackages.push({
|
|
75
|
+
root: subRoot,
|
|
76
|
+
pages: appJson.pages,
|
|
77
|
+
});
|
|
122
78
|
}
|
|
79
|
+
modifiedAppJson = true;
|
|
123
80
|
}
|
|
124
|
-
const packageJosnPath = path_1.default.join(subAppPath, 'package.json');
|
|
125
|
-
if (fs_extra_1.default.existsSync(packageJosnPath)) {
|
|
126
|
-
mergeDependencies = {
|
|
127
|
-
...mergeDependencies,
|
|
128
|
-
...(await (0, mp_1.mergePackageDependencies)(mergeDependencies, await fs_extra_1.default.readJson(packageJosnPath))),
|
|
129
|
-
};
|
|
130
|
-
modifiedPackageJosn = true;
|
|
131
|
-
}
|
|
132
|
-
await Promise.all([
|
|
133
|
-
'app.json',
|
|
134
|
-
'app.js',
|
|
135
|
-
'app.wxss',
|
|
136
|
-
'project.config.json',
|
|
137
|
-
'package.json',
|
|
138
|
-
'node_modules',
|
|
139
|
-
'miniprograme_npm',
|
|
140
|
-
].map((name) => {
|
|
141
|
-
let clearPath = path_1.default.join(subAppPath, name);
|
|
142
|
-
return name.includes('.') ? (0, generateFiles_1.removeFile)(clearPath) : (0, generateFiles_1.cleanDir)(clearPath, []);
|
|
143
|
-
}));
|
|
144
|
-
}));
|
|
145
|
-
if (modifiedAppJson) {
|
|
146
|
-
await (0, fs_extra_1.writeFile)(rootAppJosnPath, JSON.stringify(rootAppJosn, undefined, 2));
|
|
147
81
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
...
|
|
152
|
-
|
|
82
|
+
const packageJosnPath = path_1.default.join(subAppPath, 'package.json');
|
|
83
|
+
if (fs_extra_1.default.existsSync(packageJosnPath)) {
|
|
84
|
+
mergeDependencies = {
|
|
85
|
+
...mergeDependencies,
|
|
86
|
+
...(await (0, mp_1.mergePackageDependencies)(mergeDependencies, await fs_extra_1.default.readJson(packageJosnPath))),
|
|
87
|
+
};
|
|
88
|
+
modifiedPackageJosn = true;
|
|
153
89
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
await fs_extra_1.default.copy(pluginDir, distDir, { overwrite: true });
|
|
90
|
+
await Promise.all([
|
|
91
|
+
'app.json',
|
|
92
|
+
'app.js',
|
|
93
|
+
'app.wxss',
|
|
94
|
+
'project.config.json',
|
|
95
|
+
'package.json',
|
|
96
|
+
'node_modules',
|
|
97
|
+
'miniprograme_npm',
|
|
98
|
+
].map((name) => {
|
|
99
|
+
let clearPath = path_1.default.join(subAppPath, name);
|
|
100
|
+
return name.includes('.') ? (0, generateFiles_1.removeFile)(clearPath) : (0, generateFiles_1.cleanDir)(clearPath, []);
|
|
166
101
|
}));
|
|
102
|
+
}));
|
|
103
|
+
if (modifiedAppJson) {
|
|
104
|
+
await (0, fs_extra_1.writeFile)(rootAppJosnPath, JSON.stringify(rootAppJosn, undefined, 2));
|
|
167
105
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
async function handlePkgJson() {
|
|
175
|
-
const basePkgJsonPath = path_1.default.join(generateMpPath, 'package.json');
|
|
176
|
-
const mergePkgJsonPath = path_1.default.join(miniprogramRoot, 'package.json');
|
|
177
|
-
await (0, mp_1.mergePackageJson)(basePkgJsonPath, mergePkgJsonPath);
|
|
106
|
+
if (modifiedPackageJosn) {
|
|
107
|
+
await (0, fs_extra_1.writeFile)(rootPackageJosnPath, JSON.stringify({
|
|
108
|
+
...rootPackageJson,
|
|
109
|
+
...(0, mp_1.mergePackageDependencies)(mergeDependencies, rootPackageJson), // 主包优先
|
|
110
|
+
}, undefined, 2));
|
|
178
111
|
}
|
|
179
112
|
}
|
|
180
|
-
exports.
|
|
113
|
+
exports.handleSubApps = handleSubApps;
|
|
@@ -7,7 +7,7 @@ import { IBuildWedaApp } from '../core';
|
|
|
7
7
|
* @param kboneConfig https://wechat-miniprogram.github.io/kbone/docs/config/
|
|
8
8
|
* @param appConfigs app config from prop edit panel
|
|
9
9
|
*/
|
|
10
|
-
export declare function generateMpConfig(ctx: IBuildContext, weapps: IWeAppData[], options: {
|
|
10
|
+
export declare function generateMpConfig(ctx: Omit<IBuildContext, 'wedaRoot'>, weapps: IWeAppData[], options: {
|
|
11
11
|
mpAppId?: string;
|
|
12
12
|
mpConfig?: IBuildWedaApp['mpConfig'];
|
|
13
13
|
}): {
|
|
@@ -34,6 +34,7 @@ const weapps_core_1 = require("@cloudbase/lowcode-generator/lib/weapps-core");
|
|
|
34
34
|
const config_1 = require("../config");
|
|
35
35
|
const net_1 = require("../util/net");
|
|
36
36
|
const chalk_1 = __importDefault(require("chalk"));
|
|
37
|
+
const util_1 = require("../util");
|
|
37
38
|
/**
|
|
38
39
|
* generate app.json & page.json for mp
|
|
39
40
|
*
|
|
@@ -41,7 +42,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
41
42
|
* @param appConfigs app config from prop edit panel
|
|
42
43
|
*/
|
|
43
44
|
function generateMpConfig(ctx, weapps, options) {
|
|
44
|
-
var _a
|
|
45
|
+
var _a;
|
|
45
46
|
const appConfig = {
|
|
46
47
|
useExtendedLib: { weui: true },
|
|
47
48
|
};
|
|
@@ -66,9 +67,8 @@ function generateMpConfig(ctx, weapps, options) {
|
|
|
66
67
|
const kbConfig = (_a = weapps[0].lowCodes) === null || _a === void 0 ? void 0 : _a.find((m) => m.name === config_1.MP_CONFIG_MODULE_NAME);
|
|
67
68
|
const { tradingCapability, ...mainAppConfig } = weapps[0].appConfig || {};
|
|
68
69
|
// keep main app config only, ignore subapp config
|
|
69
|
-
const { subpackages, ...extra } = extractPages(weapps, pageConfigs);
|
|
70
70
|
const configs = (kbConfig ? [eval(`(${kbConfig.code.replace(/export\s+default/, '')})`)] : []).concat([
|
|
71
|
-
{ appJson:
|
|
71
|
+
{ appJson: mainAppConfig },
|
|
72
72
|
options.mpConfig,
|
|
73
73
|
]);
|
|
74
74
|
configs.forEach((config) => {
|
|
@@ -81,10 +81,12 @@ function generateMpConfig(ctx, weapps, options) {
|
|
|
81
81
|
parseTabConfig(appJson.tabBar, ctx.projDir);
|
|
82
82
|
}
|
|
83
83
|
(0, lodash_1.merge)(appConfig, appJson);
|
|
84
|
-
// # page.json
|
|
85
|
-
// merge(pageConfigs, pagesConfigJson)
|
|
86
84
|
}
|
|
87
85
|
});
|
|
86
|
+
// 若存在 wedaRoot,则正规化
|
|
87
|
+
if (projConfig.wedaRoot) {
|
|
88
|
+
projConfig.wedaRoot = (0, util_1.normalizeWedaRoot)(projConfig.wedaRoot);
|
|
89
|
+
}
|
|
88
90
|
/**
|
|
89
91
|
* 基础配置合并完成
|
|
90
92
|
* 开启特殊合并合并/覆盖逻辑
|
|
@@ -92,23 +94,28 @@ function generateMpConfig(ctx, weapps, options) {
|
|
|
92
94
|
projConfig.packOptions.ignore.push(...ctx.materialLibs
|
|
93
95
|
.filter((lib) => !lib.isComposite)
|
|
94
96
|
.reduce((arr, lib) => {
|
|
95
|
-
arr.push({
|
|
97
|
+
arr.push({
|
|
98
|
+
type: 'file',
|
|
99
|
+
value: path.posix.join(projConfig.wedaRoot || '', `materials/${lib.name}/meta.json`),
|
|
100
|
+
});
|
|
96
101
|
return arr;
|
|
97
102
|
}, []));
|
|
98
103
|
/**
|
|
99
|
-
*
|
|
104
|
+
* 合并追加系统页面子包
|
|
100
105
|
*/
|
|
106
|
+
const { subpackages, pages = [] } = extractPages(weapps, pageConfigs, { wedaRoot: projConfig.wedaRoot });
|
|
107
|
+
appConfig.pages = Array.from(new Set([...(appConfig.pages || []), ...pages]));
|
|
101
108
|
appConfig.subpackages = mergeSubPackages(appConfig.subpackages, [
|
|
102
109
|
{
|
|
103
|
-
root: 'packages/$wd_system',
|
|
110
|
+
root: path.posix.join(projConfig.wedaRoot || '', 'packages/$wd_system'),
|
|
104
111
|
name: 'wd-sys-module',
|
|
105
|
-
pages: [],
|
|
112
|
+
pages: ['pages/login/index'],
|
|
106
113
|
},
|
|
107
114
|
]
|
|
108
|
-
.concat(ctx.enableAsyncMaterials
|
|
115
|
+
.concat(ctx.enableAsyncMaterials
|
|
109
116
|
? [
|
|
110
117
|
{
|
|
111
|
-
root: config_1.materialsDirName,
|
|
118
|
+
root: path.posix.join(projConfig.wedaRoot || '', config_1.materialsDirName),
|
|
112
119
|
name: 'wd-sys-materials',
|
|
113
120
|
pages: [],
|
|
114
121
|
},
|
|
@@ -155,12 +162,12 @@ function generateMpConfig(ctx, weapps, options) {
|
|
|
155
162
|
projConfig.setting.packNpmManually = true;
|
|
156
163
|
projConfig.setting.packNpmRelationList = [
|
|
157
164
|
{
|
|
158
|
-
packageJsonPath: './package.json',
|
|
159
|
-
miniprogramNpmDistDir: './',
|
|
165
|
+
packageJsonPath: path.posix.join(projConfig.wedaRoot || './', 'package.json'),
|
|
166
|
+
miniprogramNpmDistDir: projConfig.wedaRoot || './',
|
|
160
167
|
},
|
|
161
168
|
{
|
|
162
|
-
packageJsonPath: './packages
|
|
163
|
-
miniprogramNpmDistDir: './packages
|
|
169
|
+
packageJsonPath: path.posix.join(projConfig.wedaRoot || './', 'packages', '$wd_system', 'package.json'),
|
|
170
|
+
miniprogramNpmDistDir: path.posix.join(projConfig.wedaRoot || './', 'packages', '$wd_system'),
|
|
164
171
|
},
|
|
165
172
|
];
|
|
166
173
|
if (process.env.IS_WEB_WORKER) {
|
|
@@ -173,13 +180,14 @@ function generateMpConfig(ctx, weapps, options) {
|
|
|
173
180
|
return { appConfig, projConfig, pageConfigs };
|
|
174
181
|
}
|
|
175
182
|
exports.generateMpConfig = generateMpConfig;
|
|
176
|
-
function extractPages(weapps, pageConfigs) {
|
|
183
|
+
function extractPages(weapps, pageConfigs, options) {
|
|
177
184
|
const pages = [];
|
|
178
185
|
const subpackages = [];
|
|
179
186
|
let homePage = '';
|
|
187
|
+
const { wedaRoot } = options || {};
|
|
180
188
|
weapps.forEach((weapp, index) => {
|
|
181
189
|
const { rootPath } = weapp;
|
|
182
|
-
const subPackage = { root: rootPath ? `packages/${rootPath}` : '', pages: [] };
|
|
190
|
+
const subPackage = { root: rootPath ? path.posix.join('./', wedaRoot || '', `packages/${rootPath}`) : '', pages: [] };
|
|
183
191
|
if (rootPath) {
|
|
184
192
|
subpackages.push(subPackage);
|
|
185
193
|
}
|
|
@@ -190,10 +198,10 @@ function extractPages(weapps, pageConfigs) {
|
|
|
190
198
|
subPackage.pages.push(`pages/${page.id}/${pageFileName}`);
|
|
191
199
|
}
|
|
192
200
|
else if (!page.isHome) {
|
|
193
|
-
pages.push(`pages/${page.id}/${pageFileName}`);
|
|
201
|
+
pages.push(path.posix.join('./', wedaRoot || '', `pages/${page.id}/${pageFileName}`));
|
|
194
202
|
}
|
|
195
203
|
else {
|
|
196
|
-
homePage = `pages/${page.id}/${pageFileName}
|
|
204
|
+
homePage = path.posix.join('./', wedaRoot || '', `pages/${page.id}/${pageFileName}`);
|
|
197
205
|
}
|
|
198
206
|
});
|
|
199
207
|
});
|
|
@@ -215,7 +223,7 @@ function transformDynamicData(originData) {
|
|
|
215
223
|
const temp = {};
|
|
216
224
|
for (const key in originData) {
|
|
217
225
|
const target = originData[key];
|
|
218
|
-
if (target === null || target === void 0 ? void 0 : target.value) {
|
|
226
|
+
if ((target === null || target === void 0 ? void 0 : target.value) && ((target === null || target === void 0 ? void 0 : target.type) === 'static' || !(target === null || target === void 0 ? void 0 : target.type))) {
|
|
219
227
|
temp[key] = target.value;
|
|
220
228
|
}
|
|
221
229
|
}
|
package/lib/builder/mp/wxml.js
CHANGED
|
@@ -12,6 +12,7 @@ const materials_1 = require("./materials");
|
|
|
12
12
|
const name_mangler_1 = __importDefault(require("@cloudbase/lowcode-generator/lib/generator/util/name-mangler"));
|
|
13
13
|
const config_1 = require("../config");
|
|
14
14
|
const util_1 = require("./util");
|
|
15
|
+
const path_1 = __importDefault(require("path"));
|
|
15
16
|
exports.WD_EMPTY_PLACEHOLDER = 'wd-ph';
|
|
16
17
|
const WD_INFO = 'wd-info';
|
|
17
18
|
exports.WD_RUNTIME_TAG = [exports.WD_EMPTY_PLACEHOLDER, WD_INFO];
|
|
@@ -36,9 +37,9 @@ function generateWxml(ctx, widgets, docTag, wxmlDataPrefix, usingComponents, com
|
|
|
36
37
|
const originElements = xmlJson.elements;
|
|
37
38
|
xmlJson.elements = [pageMeta];
|
|
38
39
|
// usingComponents['wd-privacy'] = '/common/privacyModal/index';
|
|
39
|
-
usingComponents[WD_INFO] = '/common/info/index';
|
|
40
|
+
usingComponents[WD_INFO] = path_1.default.posix.join('/', ctx.wedaRoot || '', '/common/info/index');
|
|
40
41
|
if (enableAsyncMaterials) {
|
|
41
|
-
usingComponents[exports.WD_EMPTY_PLACEHOLDER] = '/common/placeholder/index';
|
|
42
|
+
usingComponents[exports.WD_EMPTY_PLACEHOLDER] = path_1.default.posix.join('/', ctx.wedaRoot || '', '/common/placeholder/index');
|
|
42
43
|
}
|
|
43
44
|
if (disabled && ctx.pageUUID !== ctx.statusPageId) {
|
|
44
45
|
pageMeta.elements = [
|
|
@@ -127,6 +128,22 @@ function generateWxml(ctx, widgets, docTag, wxmlDataPrefix, usingComponents, com
|
|
|
127
128
|
_parent: pageMeta,
|
|
128
129
|
});
|
|
129
130
|
}
|
|
131
|
+
if (ctx.enableAd) {
|
|
132
|
+
const textNode = {
|
|
133
|
+
type: 'text',
|
|
134
|
+
text: '当前小程序正使用云开发免费版云模板,升级后即可免广告。',
|
|
135
|
+
};
|
|
136
|
+
pageMeta.elements.unshift({
|
|
137
|
+
type: 'element',
|
|
138
|
+
name: 'view',
|
|
139
|
+
attributes: {
|
|
140
|
+
style: 'position: fixed;top: 0;left: 0;right: 0;z-index:10000; background: rgba(255, 103, 112, 0.95); font-size: 12px; color: white; line-height: 2.5em;padding-left: .5em;',
|
|
141
|
+
},
|
|
142
|
+
elements: [textNode],
|
|
143
|
+
_order: -Infinity,
|
|
144
|
+
_parent: pageMeta,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
130
147
|
if (ctx.enableLoading) {
|
|
131
148
|
pageMeta.elements.push({
|
|
132
149
|
type: 'element',
|
|
@@ -127,7 +127,7 @@ function getWebpackWebBuildParams(appId, appBuildDir, publicPath = '/', mode = c
|
|
|
127
127
|
entry: path_1.default.resolve(appBuildDir, 'src/index.jsx'),
|
|
128
128
|
output: {
|
|
129
129
|
path: path_1.default.resolve(appBuildDir, exports.OUTPUT_DIR),
|
|
130
|
-
filename: '[name].[
|
|
130
|
+
filename: '[name].[hash].bundle.js',
|
|
131
131
|
chunkFilename: '[name].[contenthash].chunk.js',
|
|
132
132
|
publicPath: buildTypeList.includes(common_1.BuildType.APP) || buildTypeList.includes(common_1.BuildType.ADMIN_PORTAL) ? '' : publicPath,
|
|
133
133
|
pathinfo: false,
|
|
@@ -57,3 +57,4 @@ export declare function generateLowcodeImportor(lowcodes?: IWeAppCode[]): {
|
|
|
57
57
|
styles: IWeAppCode[];
|
|
58
58
|
};
|
|
59
59
|
export declare function normalizePackageName(packageName?: string | null): string | null | undefined;
|
|
60
|
+
export declare function normalizeWedaRoot(root?: string): string;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.normalizePackageName = exports.generateLowcodeImportor = exports.getCompileDirs = exports.deepDealComponentSchemaJson = exports.canUseVite = exports.isOfficialComponentLib = exports.readComponentLibMata = exports.writeLibCommonRes2file = exports.getYyptConfigInfo = exports.getComponentsInfo = exports.getInputProps = exports.removeRequireUncached = exports.requireUncached = exports.JsonToStringWithVariableName = exports.getSelfPackageJson = exports.getCurrentPackageJson = exports.promiseWrapper = exports.getFileNameByUrl = exports.deepDealSchema = exports.simpleDeepClone = exports.deepDeal = exports.isPlainObject = exports.isArray = exports.getMetaInfoBySourceKey = void 0;
|
|
6
|
+
exports.normalizeWedaRoot = exports.normalizePackageName = exports.generateLowcodeImportor = exports.getCompileDirs = exports.deepDealComponentSchemaJson = exports.canUseVite = exports.isOfficialComponentLib = exports.readComponentLibMata = exports.writeLibCommonRes2file = exports.getYyptConfigInfo = exports.getComponentsInfo = exports.getInputProps = exports.removeRequireUncached = exports.requireUncached = exports.JsonToStringWithVariableName = exports.getSelfPackageJson = exports.getCurrentPackageJson = exports.promiseWrapper = exports.getFileNameByUrl = exports.deepDealSchema = exports.simpleDeepClone = exports.deepDeal = exports.isPlainObject = exports.isArray = exports.getMetaInfoBySourceKey = void 0;
|
|
7
7
|
// import * as R from 'ramda'
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
@@ -301,3 +301,10 @@ function normalizePackageName(packageName) {
|
|
|
301
301
|
return packageName;
|
|
302
302
|
}
|
|
303
303
|
exports.normalizePackageName = normalizePackageName;
|
|
304
|
+
function normalizeWedaRoot(root = '') {
|
|
305
|
+
return root
|
|
306
|
+
.split('/')
|
|
307
|
+
.filter((item) => !!item && item !== '.')
|
|
308
|
+
.join('/');
|
|
309
|
+
}
|
|
310
|
+
exports.normalizeWedaRoot = normalizeWedaRoot;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IBuildWedaApp } from '../core';
|
|
1
2
|
export declare function downloadFile(url: string, filePath: string): Promise<void>;
|
|
2
3
|
/**
|
|
3
4
|
* Download zip file and extract to dstDir
|
|
@@ -23,4 +24,12 @@ export declare function downloadZipInBrowser(url: string, dstDir: string, noCach
|
|
|
23
24
|
* miniprogram_npm待微信提供端能力
|
|
24
25
|
* @param output
|
|
25
26
|
*/
|
|
26
|
-
export declare function downloadBrowserMaterial(
|
|
27
|
+
export declare function downloadBrowserMaterial({ runtimeEndpointType, browser, }: {
|
|
28
|
+
runtimeEndpointType: IBuildWedaApp['endpointType'];
|
|
29
|
+
browser?: boolean;
|
|
30
|
+
}): Promise<void>;
|
|
31
|
+
export declare function installBrowserDependencies({ type, path: outPath, runtimeEndpointType, }: {
|
|
32
|
+
type: 'wedaRoot' | '$weda_system';
|
|
33
|
+
path: string;
|
|
34
|
+
runtimeEndpointType: IBuildWedaApp['endpointType'];
|
|
35
|
+
}): Promise<void>;
|
package/lib/builder/util/net.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.downloadBrowserMaterial = exports.downloadZipInBrowser = exports.downloadZipInNode = exports.downloadZip = exports.downloadFile = void 0;
|
|
29
|
+
exports.installBrowserDependencies = exports.downloadBrowserMaterial = exports.downloadZipInBrowser = exports.downloadZipInNode = exports.downloadZip = exports.downloadFile = void 0;
|
|
30
30
|
const axios_1 = __importDefault(require("axios"));
|
|
31
31
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
32
32
|
const path = __importStar(require("path"));
|
|
@@ -118,14 +118,53 @@ async function saveFiles(files, dstDir) {
|
|
|
118
118
|
* miniprogram_npm待微信提供端能力
|
|
119
119
|
* @param output
|
|
120
120
|
*/
|
|
121
|
-
async function downloadBrowserMaterial(
|
|
121
|
+
async function downloadBrowserMaterial({ runtimeEndpointType, browser = true, }) {
|
|
122
|
+
const BUILD_TEMPLATES = require('../mp/template.json');
|
|
122
123
|
await Promise.all([
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
new Promise((resolve, reject) => {
|
|
125
|
+
try {
|
|
126
|
+
for (const key in BUILD_TEMPLATES) {
|
|
127
|
+
fs_extra_1.default.ensureFileSync(path.join(config_1.appTemplateDir, key));
|
|
128
|
+
fs_extra_1.default.writeFileSync(path.join(config_1.appTemplateDir, key), BUILD_TEMPLATES[key].code);
|
|
129
|
+
}
|
|
130
|
+
resolve(null);
|
|
131
|
+
}
|
|
132
|
+
catch (e) {
|
|
133
|
+
reject(e);
|
|
134
|
+
}
|
|
135
|
+
}),
|
|
136
|
+
runtimeEndpointType === 'tcb-api'
|
|
137
|
+
? downloadZip(config_1.cloudbaseMiniprogramURL, config_1.cloudbaseMiniprogramDir, browser)
|
|
138
|
+
: downloadZip(config_1.miniprogramURL, config_1.miniprogramDir, browser),
|
|
139
|
+
downloadZip(config_1.systemSubpackageMiniprogramURL, config_1.systemSubpackageMiniprogramDir, browser),
|
|
126
140
|
]);
|
|
127
|
-
// 必须先下载到.weapps-materials目录,因为.weapps-materials是默认下载目录,共享组件逻辑sharedMaterialsDir时会读取文件
|
|
128
|
-
(0, generateFiles_1.copyRecursiveSync)(config_1.miniprogramDir, path.join(output, 'miniprogram_npm'));
|
|
129
|
-
(0, generateFiles_1.copyRecursiveSync)(config_1.systemSubpackageMiniprogramDir, path.join(output, 'packages', '$wd_system', 'miniprogram_npm'));
|
|
130
141
|
}
|
|
131
142
|
exports.downloadBrowserMaterial = downloadBrowserMaterial;
|
|
143
|
+
async function installBrowserDependencies({ type, path: outPath, runtimeEndpointType, }) {
|
|
144
|
+
// 必须先下载到.weapps-materials目录,因为.weapps-materials是默认下载目录,共享组件逻辑sharedMaterialsDir时会读取文件
|
|
145
|
+
const MAP = {
|
|
146
|
+
wedaRoot: runtimeEndpointType === 'tcb-api'
|
|
147
|
+
? {
|
|
148
|
+
url: config_1.cloudbaseMiniprogramURL,
|
|
149
|
+
src: config_1.cloudbaseMiniprogramDir,
|
|
150
|
+
}
|
|
151
|
+
: {
|
|
152
|
+
url: config_1.miniprogramURL,
|
|
153
|
+
src: config_1.miniprogramDir,
|
|
154
|
+
},
|
|
155
|
+
['$weda_system']: {
|
|
156
|
+
url: config_1.systemSubpackageMiniprogramURL,
|
|
157
|
+
src: config_1.systemSubpackageMiniprogramDir,
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
const meta = MAP[type];
|
|
161
|
+
if (meta) {
|
|
162
|
+
if (!fs_extra_1.default.existsSync(meta.src)) {
|
|
163
|
+
await downloadZip(meta.url, path.join(outPath, 'miniprogram_npm'), true);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
(0, generateFiles_1.copyRecursiveSync)(meta.src, path.join(outPath, 'miniprogram_npm'));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
exports.installBrowserDependencies = installBrowserDependencies;
|