@cloudbase/lowcode-builder 0.1.25 → 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/lib/builder/core/index.d.ts +1 -3
- package/lib/builder/core/index.js +42 -52
- package/lib/builder/h5/compile.d.ts +1 -1
- package/lib/builder/h5/compile.js +59 -20
- package/lib/builder/h5/copy.js +2 -4
- package/lib/builder/h5/generate.js +3 -3
- package/lib/builder/h5/index.d.ts +5 -4
- package/lib/builder/h5/index.js +25 -14
- package/lib/builder/h5/material.js +6 -11
- package/lib/builder/h5/npm.js +6 -5
- package/lib/builder/mp/index.js +38 -49
- package/lib/builder/mp/materials.js +25 -18
- package/lib/builder/mp/mixMode.js +7 -10
- package/lib/builder/mp/mp_config.js +2 -3
- package/lib/builder/mp/wxml.js +1 -1
- package/lib/builder/service/webpack.d.ts +7 -1
- package/lib/builder/service/webpack.js +97 -24
- package/lib/builder/types/common.d.ts +1 -1
- package/lib/builder/types/common.js +2 -1
- package/lib/builder/util/common.js +1 -4
- package/lib/builder/util/generateFiles.js +12 -10
- package/lib/builder/util/mp.js +2 -8
- package/lib/builder.web.js +71 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +6 -0
- package/lib/types.d.ts +1 -0
- package/lib/types.js +11 -0
- package/package.json +3 -8
- package/template/html/index.html.ejs +59 -29
- package/template/mp/app.js +2 -1
- package/template/mp/common/weapp-page.js +23 -1
- package/template/mp/common/weapp-sdk.js +35 -0
- package/template/mp/package.json +1 -1
- package/template/mp/page/index.js +2 -1
- package/template/package.json +5 -2
- package/template/webpack/getCSSModuleLocalIdent.js +28 -0
- package/template/webpack/web.prod.js +112 -103
- package/template/src/app/common.js +0 -13
- package/template/src/app/global-api.js +0 -99
- package/template/src/app/handlers.js +0 -13
- package/template/src/app/material-actions.js +0 -16
- package/template/src/app/mountAppApis.js +0 -25
- package/template/src/app/mountMpApis.js +0 -4
- package/template/src/datasources/config.js.tpl +0 -23
- package/template/src/datasources/dataset-profiles.js.tpl +0 -5
- package/template/src/datasources/datasource-profiles.js.tpl +0 -4
- package/template/src/datasources/index.js +0 -31
- package/template/src/handlers/FieldMiddleware/renderer.jsx +0 -331
- package/template/src/handlers/HotAreas.js +0 -36
- package/template/src/handlers/PositionHandler.jsx +0 -8
- package/template/src/handlers/actionHandler/utils.js +0 -149
- package/template/src/handlers/componentEventActionEmitter.js +0 -29
- package/template/src/handlers/componentNodeMap.js +0 -24
- package/template/src/handlers/controller.js +0 -5
- package/template/src/handlers/emitComponentEvent.js +0 -8
- package/template/src/handlers/eventListener/componentEventListener.js +0 -15
- package/template/src/handlers/eventListener/hotAreaEventListener.js +0 -32
- package/template/src/handlers/eventListener/index.js +0 -29
- package/template/src/handlers/eventListener/pageEventListener.js +0 -11
- package/template/src/handlers/eventListener/types.js +0 -32
- package/template/src/handlers/hooks/index.js +0 -14
- package/template/src/handlers/initWebEnv.js +0 -4
- package/template/src/handlers/injectStyle.js +0 -14
- package/template/src/handlers/instanceMap.js +0 -39
- package/template/src/handlers/lifecycle.js +0 -232
- package/template/src/handlers/render.jsx +0 -131
- package/template/src/handlers/utils/common.js +0 -151
- package/template/src/handlers/utils/eventProxy.js +0 -64
- package/template/src/handlers/utils/events.js +0 -8
- package/template/src/handlers/utils/index.js +0 -4
- package/template/src/handlers/utils/widgets.js +0 -320
- package/template/src/index.jsx +0 -142
- package/template/src/index.less +0 -119
- package/template/src/libraries/default-lib/wx_yypt_report_v2.js +0 -441
- package/template/src/pages/app.tpl +0 -124
- package/template/src/router/index.tpl +0 -28
- package/template/src/store/computed.js +0 -11
- package/template/src/store/index.js +0 -40
- package/template/src/utils/ScanCodeComponent.js +0 -396
- package/template/src/utils/date.js +0 -324
- package/template/src/utils/history.js +0 -72
- package/template/src/utils/index.js +0 -67
- package/template/src/utils/kbone.js +0 -18
- package/template/src/utils/monitor-jssdk.min.js +0 -763
- package/template/src/utils/request.js +0 -5
- package/template/src/utils/scan-code-action.js +0 -27
|
@@ -3,10 +3,12 @@ const webpack = require('webpack');
|
|
|
3
3
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
4
4
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
5
5
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
6
|
+
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
|
|
6
7
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
7
8
|
const themeVars = require('./themeVars');
|
|
9
|
+
const getCSSModuleLocalIdent = require('./getCSSModuleLocalIdent');
|
|
8
10
|
const HappyPack = require('happypack');
|
|
9
|
-
const core =
|
|
11
|
+
const core = 4;
|
|
10
12
|
const happyThreadPool = HappyPack.ThreadPool({ size: core });
|
|
11
13
|
|
|
12
14
|
const TS_LOADER_ID = 'ts-loader';
|
|
@@ -21,8 +23,9 @@ module.exports = function (options) {
|
|
|
21
23
|
resolveModules,
|
|
22
24
|
htmlTemplatePath,
|
|
23
25
|
definePlugin = {},
|
|
26
|
+
devtool = false,
|
|
24
27
|
} = options;
|
|
25
|
-
|
|
28
|
+
|
|
26
29
|
const babelLoader = {
|
|
27
30
|
loader: 'babel-loader',
|
|
28
31
|
options: {
|
|
@@ -35,7 +38,8 @@ module.exports = function (options) {
|
|
|
35
38
|
{
|
|
36
39
|
modules: false,
|
|
37
40
|
targets: {
|
|
38
|
-
esmodules: true,
|
|
41
|
+
// esmodules: true,
|
|
42
|
+
browsers: ['defaults', 'iOS >= 10', 'safari >= 10'],
|
|
39
43
|
},
|
|
40
44
|
},
|
|
41
45
|
],
|
|
@@ -60,27 +64,45 @@ module.exports = function (options) {
|
|
|
60
64
|
].filter(Boolean),
|
|
61
65
|
},
|
|
62
66
|
};
|
|
67
|
+
const typescriptLoader = {
|
|
68
|
+
loader: 'ts-loader',
|
|
69
|
+
options: {
|
|
70
|
+
compilerOptions: {
|
|
71
|
+
target: 'ESNext',
|
|
72
|
+
module: 'ESNext',
|
|
73
|
+
esModuleInterop: true,
|
|
74
|
+
},
|
|
75
|
+
happyPackMode: true,
|
|
76
|
+
transpileOnly: true,
|
|
77
|
+
},
|
|
78
|
+
};
|
|
63
79
|
|
|
64
80
|
let plugins = [
|
|
65
81
|
new HappyPack({
|
|
66
|
-
id:
|
|
82
|
+
id: 'vue',
|
|
83
|
+
cache: true,
|
|
84
|
+
verbose: true,
|
|
67
85
|
loaders: [
|
|
68
86
|
babelLoader,
|
|
87
|
+
typescriptLoader,
|
|
69
88
|
{
|
|
70
|
-
loader: '
|
|
89
|
+
loader: 'vue-loader',
|
|
71
90
|
options: {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
91
|
+
threadMode: true,
|
|
92
|
+
loaders: {
|
|
93
|
+
js: [babelLoader],
|
|
94
|
+
ts: [babelLoader, typescriptLoader],
|
|
76
95
|
},
|
|
77
|
-
happyPackMode: true,
|
|
78
|
-
transpileOnly: true,
|
|
79
96
|
},
|
|
80
97
|
},
|
|
81
98
|
],
|
|
82
99
|
threadPool: happyThreadPool,
|
|
83
100
|
}),
|
|
101
|
+
new HappyPack({
|
|
102
|
+
id: TS_LOADER_ID,
|
|
103
|
+
loaders: [babelLoader, typescriptLoader],
|
|
104
|
+
threadPool: happyThreadPool,
|
|
105
|
+
}),
|
|
84
106
|
new HappyPack({
|
|
85
107
|
id: 'babel',
|
|
86
108
|
loaders: [babelLoader],
|
|
@@ -94,7 +116,6 @@ module.exports = function (options) {
|
|
|
94
116
|
new MiniCssExtractPlugin({
|
|
95
117
|
filename: '[name].[contenthash].css',
|
|
96
118
|
chunkFilename: '[id].[contenthash].css',
|
|
97
|
-
ignoreOrder: true,
|
|
98
119
|
}),
|
|
99
120
|
new webpack.DefinePlugin(
|
|
100
121
|
Object.assign(
|
|
@@ -103,8 +124,8 @@ module.exports = function (options) {
|
|
|
103
124
|
'process.env.SSR': false,
|
|
104
125
|
'process.env.compileTool': `'webpack'`,
|
|
105
126
|
},
|
|
106
|
-
definePlugin
|
|
107
|
-
)
|
|
127
|
+
definePlugin,
|
|
128
|
+
),
|
|
108
129
|
),
|
|
109
130
|
new CopyWebpackPlugin({
|
|
110
131
|
patterns: [
|
|
@@ -115,31 +136,63 @@ module.exports = function (options) {
|
|
|
115
136
|
},
|
|
116
137
|
],
|
|
117
138
|
}),
|
|
139
|
+
new webpack.HashedModuleIdsPlugin({
|
|
140
|
+
hashFunction: 'sha256',
|
|
141
|
+
hashDigest: 'hex',
|
|
142
|
+
hashDigestLength: 20,
|
|
143
|
+
}),
|
|
144
|
+
new webpack.EnvironmentPlugin({
|
|
145
|
+
SSR: false,
|
|
146
|
+
WEBPACK_ENV: 'production',
|
|
147
|
+
}),
|
|
148
|
+
];
|
|
149
|
+
|
|
150
|
+
const commonCSSLoaders = [
|
|
151
|
+
MiniCssExtractPlugin.loader,
|
|
152
|
+
{
|
|
153
|
+
loader: 'css-loader',
|
|
154
|
+
options: {
|
|
155
|
+
modules: {
|
|
156
|
+
auto: true,
|
|
157
|
+
getLocalIdent: getCSSModuleLocalIdent,
|
|
158
|
+
},
|
|
159
|
+
importLoaders: 2,
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
loader: 'postcss-loader',
|
|
164
|
+
options: {
|
|
165
|
+
postcssOptions: {
|
|
166
|
+
plugins: [
|
|
167
|
+
[
|
|
168
|
+
'postcss-pxtorem',
|
|
169
|
+
{
|
|
170
|
+
rootValue: 14,
|
|
171
|
+
propList: ['*'],
|
|
172
|
+
// todo
|
|
173
|
+
selectorBlackList: ['.weui-picker__indicator'],
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
],
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
},
|
|
118
180
|
];
|
|
119
|
-
|
|
120
|
-
plugins = plugins.concat([
|
|
121
|
-
new webpack.HashedModuleIdsPlugin({
|
|
122
|
-
hashFunction: 'sha256',
|
|
123
|
-
hashDigest: 'hex',
|
|
124
|
-
hashDigestLength: 20,
|
|
125
|
-
}),
|
|
126
|
-
new webpack.EnvironmentPlugin({
|
|
127
|
-
SSR: false,
|
|
128
|
-
WEBPACK_ENV: 'production',
|
|
129
|
-
}),
|
|
130
|
-
]);
|
|
131
|
-
}
|
|
181
|
+
|
|
132
182
|
return {
|
|
133
183
|
context,
|
|
134
184
|
entry,
|
|
135
|
-
|
|
185
|
+
/**
|
|
186
|
+
* 只要是构建都开启 production 以使用精简
|
|
187
|
+
*/
|
|
188
|
+
mode: 'production',
|
|
136
189
|
watch,
|
|
137
190
|
output,
|
|
138
191
|
externals,
|
|
139
192
|
cache: {
|
|
140
193
|
type: 'memory',
|
|
141
194
|
},
|
|
142
|
-
devtool:
|
|
195
|
+
devtool: devtool,
|
|
143
196
|
resolve: {
|
|
144
197
|
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json', '.scss', '.css'],
|
|
145
198
|
modules: [...resolveModules],
|
|
@@ -151,6 +204,10 @@ module.exports = function (options) {
|
|
|
151
204
|
},
|
|
152
205
|
module: {
|
|
153
206
|
rules: [
|
|
207
|
+
{
|
|
208
|
+
test: /\.vue$/,
|
|
209
|
+
loader: 'happypack/loader?id=vue',
|
|
210
|
+
},
|
|
154
211
|
{
|
|
155
212
|
test: /\.tsx?$/,
|
|
156
213
|
exclude: /node_modules\/(?!@cloudbase\/weda-ui)|gsd-kbone-react/,
|
|
@@ -158,38 +215,13 @@ module.exports = function (options) {
|
|
|
158
215
|
},
|
|
159
216
|
{
|
|
160
217
|
test: /\.(js|jsx)$/,
|
|
161
|
-
exclude: /node_modules\/(
|
|
218
|
+
exclude: /node_modules\/(?!(@cloudbase\/weda-ui)|(@tcwd\/vuera)|(@tcwd\/weapps-core))|gsd-kbone-react/,
|
|
162
219
|
use: ['happypack/loader?id=babel'],
|
|
163
220
|
},
|
|
164
221
|
{
|
|
165
222
|
test: /\.(scss|sass)$/,
|
|
166
223
|
use: [
|
|
167
|
-
|
|
168
|
-
{
|
|
169
|
-
loader: 'css-loader',
|
|
170
|
-
options: {
|
|
171
|
-
modules: false,
|
|
172
|
-
importLoaders: 2,
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
loader: 'postcss-loader',
|
|
177
|
-
options: {
|
|
178
|
-
postcssOptions: {
|
|
179
|
-
plugins: [
|
|
180
|
-
[
|
|
181
|
-
'postcss-pxtorem',
|
|
182
|
-
{
|
|
183
|
-
rootValue: 14,
|
|
184
|
-
propList: ['*'],
|
|
185
|
-
// todo
|
|
186
|
-
selectorBlackList: ['.weui-picker__indicator'],
|
|
187
|
-
},
|
|
188
|
-
],
|
|
189
|
-
],
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
},
|
|
224
|
+
...commonCSSLoaders,
|
|
193
225
|
{
|
|
194
226
|
loader: 'sass-loader',
|
|
195
227
|
options: {
|
|
@@ -199,39 +231,19 @@ module.exports = function (options) {
|
|
|
199
231
|
],
|
|
200
232
|
},
|
|
201
233
|
{
|
|
202
|
-
test: /\.
|
|
234
|
+
test: /\.css$/,
|
|
235
|
+
use: [...cssLoaders],
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
test: /\.less$/,
|
|
203
239
|
use: [
|
|
204
|
-
|
|
205
|
-
{
|
|
206
|
-
loader: 'css-loader',
|
|
207
|
-
options: {
|
|
208
|
-
modules: false,
|
|
209
|
-
importLoaders: 2,
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
loader: 'postcss-loader',
|
|
214
|
-
options: {
|
|
215
|
-
postcssOptions: {
|
|
216
|
-
plugins: [
|
|
217
|
-
[
|
|
218
|
-
'postcss-pxtorem',
|
|
219
|
-
{
|
|
220
|
-
rootValue: 14,
|
|
221
|
-
propList: ['*'],
|
|
222
|
-
// todo
|
|
223
|
-
selectorBlackList: ['.weui-picker__indicator'],
|
|
224
|
-
},
|
|
225
|
-
],
|
|
226
|
-
],
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
},
|
|
240
|
+
...commonCSSLoaders,
|
|
230
241
|
{
|
|
231
242
|
loader: 'less-loader',
|
|
232
243
|
options: {
|
|
233
244
|
lessOptions: {
|
|
234
245
|
modifyVars: themeVars,
|
|
246
|
+
javascriptEnabled: true,
|
|
235
247
|
},
|
|
236
248
|
},
|
|
237
249
|
},
|
|
@@ -245,19 +257,21 @@ module.exports = function (options) {
|
|
|
245
257
|
},
|
|
246
258
|
plugins,
|
|
247
259
|
optimization: {
|
|
260
|
+
concatenateModules: true,
|
|
248
261
|
noEmitOnErrors: true,
|
|
249
|
-
removeEmptyChunks: true,
|
|
250
262
|
splitChunks: {
|
|
263
|
+
maxSize: 3000000,
|
|
251
264
|
cacheGroups: {
|
|
252
265
|
base: {
|
|
253
266
|
test: /(react|react-dom|react-router|react-router-dom|mobx|mobx-react-lite|@cloudbase\/js-sdk)/,
|
|
254
267
|
chunks: 'all',
|
|
255
|
-
|
|
268
|
+
minSize: 500000,
|
|
269
|
+
priority: 100, // 优先级
|
|
256
270
|
},
|
|
257
271
|
utils: {
|
|
258
|
-
test: /(lodash|dayjs|axios|kbone-api
|
|
272
|
+
test: /(lodash|dayjs|axios|kbone-api)/,
|
|
259
273
|
chunks: 'all',
|
|
260
|
-
priority: 100,
|
|
274
|
+
priority: 100, // 优先级
|
|
261
275
|
},
|
|
262
276
|
'async-commons': {
|
|
263
277
|
chunks: 'async',
|
|
@@ -271,22 +285,17 @@ module.exports = function (options) {
|
|
|
271
285
|
},
|
|
272
286
|
},
|
|
273
287
|
},
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
parallel: true,
|
|
286
|
-
sourceMap: false,
|
|
287
|
-
}),
|
|
288
|
-
],
|
|
289
|
-
}),
|
|
288
|
+
minimizer: [
|
|
289
|
+
new TerserPlugin({
|
|
290
|
+
test: /\.js(\?.*)?$/i,
|
|
291
|
+
cache: false,
|
|
292
|
+
parallel: true,
|
|
293
|
+
sourceMap: false,
|
|
294
|
+
terserOptions: {
|
|
295
|
+
safari10: true,
|
|
296
|
+
},
|
|
297
|
+
}),
|
|
298
|
+
],
|
|
290
299
|
},
|
|
291
300
|
};
|
|
292
301
|
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<% mods.forEach((mod) => {%>
|
|
2
|
-
import * as <%= mod %> from '../lowcode/common/<%= mod %>'<%}) %>
|
|
3
|
-
|
|
4
|
-
function getModule(targetModule) {
|
|
5
|
-
if(targetModule.__esModule) {
|
|
6
|
-
return targetModule.default ? targetModule.default : targetModule
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
<% mods.forEach((mod) => {%>
|
|
12
|
-
<%= mod %>: getModule(<%= mod %>),<%}) %>
|
|
13
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import * as sdk from '@tcwd/weapps-sdk';
|
|
2
|
-
import { createComputed } from 'utils';
|
|
3
|
-
import store, { subPackageName } from '../store';
|
|
4
|
-
import computed from '../store/computed';
|
|
5
|
-
import common from './common';
|
|
6
|
-
import { _isMobile } from '../utils';
|
|
7
|
-
import actionMap from './material-actions';
|
|
8
|
-
import { createWebApp, _ACTIONS_KEY as ACTIONS_KEY, _ROUTER_KEY as ROUTER_KEY } from '@cloudbase/weda-client';
|
|
9
|
-
import { createDataset, EXTRA_API } from '../datasources/index';
|
|
10
|
-
|
|
11
|
-
const mainAppKey = '__weappsMainApp';
|
|
12
|
-
const appGlobal = process.env.isMiniprogram ? getApp() : window;
|
|
13
|
-
|
|
14
|
-
export const app = createGlboalApi();
|
|
15
|
-
export const $page = createPageApi();
|
|
16
|
-
|
|
17
|
-
export function setCurrentPage(pageCtx) {
|
|
18
|
-
Object.assign($page, pageCtx);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function createGlboalApi() {
|
|
22
|
-
const mpApp = createWebApp();
|
|
23
|
-
const globalAPI = {
|
|
24
|
-
id: '<%= appId %>',
|
|
25
|
-
domain: '<%= domain %>',
|
|
26
|
-
formActions: {},
|
|
27
|
-
pages: {},
|
|
28
|
-
session: {
|
|
29
|
-
configure: sdk.configure,
|
|
30
|
-
request: sdk.request,
|
|
31
|
-
getSessionId: sdk.getSessionId,
|
|
32
|
-
},
|
|
33
|
-
state: store,
|
|
34
|
-
computed: createComputed(computed.global),
|
|
35
|
-
common,
|
|
36
|
-
...mpApp,
|
|
37
|
-
// ... other sdk apis & apis from mp
|
|
38
|
-
}; // The global api exposed to lowcode
|
|
39
|
-
|
|
40
|
-
const dataset = createDataset('$global');
|
|
41
|
-
globalAPI.dataset = dataset;
|
|
42
|
-
globalAPI.state.dataset = dataset;
|
|
43
|
-
globalAPI.setState = (userSetState) => {
|
|
44
|
-
Object.keys(userSetState).forEach((keyPath) => {
|
|
45
|
-
globalAPI.utils.set(globalAPI.dataset.state, keyPath, userSetState[keyPath]);
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* 内部通用的设置状态变量值的方法
|
|
50
|
-
* varPath 结构为 $global.<变量名> 即全局变量
|
|
51
|
-
* $page.<变量名> 即当前页面变量
|
|
52
|
-
* <pageId>.<变量名> 指定页面 pageId 的变量 (应当避免修改非当前页面的变量值)
|
|
53
|
-
*/
|
|
54
|
-
globalAPI._setStateVal = (config) => {
|
|
55
|
-
EXTRA_API.setState(config.varPath, config.val);
|
|
56
|
-
};
|
|
57
|
-
if (subPackageName) {
|
|
58
|
-
// is sub app
|
|
59
|
-
globalAPI.mainApp = appGlobal[mainAppKey];
|
|
60
|
-
} else {
|
|
61
|
-
// is mainApp
|
|
62
|
-
appGlobal.app = globalAPI;
|
|
63
|
-
appGlobal[mainAppKey] = globalAPI;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// 挂运营平台上报对象到app里
|
|
67
|
-
globalAPI.yyptReport = appGlobal.yyptReport;
|
|
68
|
-
|
|
69
|
-
// # expose some sdk modules
|
|
70
|
-
const sdkModsIncluded = ['flow', 'getPageOptions', 'getLaunchOptions'];
|
|
71
|
-
sdkModsIncluded.forEach((key) => {
|
|
72
|
-
globalAPI[key] = sdk[key];
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
return globalAPI;
|
|
76
|
-
}
|
|
77
|
-
function createPageApi() {
|
|
78
|
-
const $page = {
|
|
79
|
-
state: {},
|
|
80
|
-
computed: {},
|
|
81
|
-
handler: {},
|
|
82
|
-
props: {},
|
|
83
|
-
widgets: {},
|
|
84
|
-
// 页面数据源变量存储位置
|
|
85
|
-
dataVar: {},
|
|
86
|
-
};
|
|
87
|
-
return $page;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// 分app 和 wx 挂载app
|
|
91
|
-
export const mountAPIs = (sdks) => {
|
|
92
|
-
Object.keys(sdks).forEach((item) => {
|
|
93
|
-
let action = sdks[item];
|
|
94
|
-
if (!(item in ACTIONS_KEY) && !(item in ROUTER_KEY)) {
|
|
95
|
-
app[item] = action;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
return app;
|
|
99
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<%for(const pageId in pageModules) {
|
|
2
|
-
pageModules[pageId].filter(mod => mod.type === 'handler-fn' && mod.name !== '____index____').forEach(mod => {%>
|
|
3
|
-
import <%= pageId%>_<%= mod.name%> from '../lowcode/<%= pageId%>/handler/<%= mod.name%>'<%
|
|
4
|
-
})
|
|
5
|
-
}%>
|
|
6
|
-
|
|
7
|
-
<% for(const pageId in pageModules) {%>
|
|
8
|
-
export const $$_<%=pageId %> = {<%
|
|
9
|
-
pageModules[pageId].filter(mod => mod.type === 'handler-fn' && mod.name !== '____index____').forEach(mod => {%>
|
|
10
|
-
['<%= mod.name%>']: <%= pageId%>_<%= mod.name%>,<%
|
|
11
|
-
}) %>
|
|
12
|
-
}
|
|
13
|
-
<%}%>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// Imports all material actions
|
|
2
|
-
<% materials.map((material,index) => { if(material.entries && material.entries.actions){ %>
|
|
3
|
-
import * as <%= _.camelCase(material.name)%>Actions_<%= index%> from 'libraries/<%=material.name%>@<%= material.version %>/<%=material.entries.actions%>';
|
|
4
|
-
<% } else if(material.entries && material.entries.entry) {%>
|
|
5
|
-
import <%= _.camelCase(material.name)%>_<%= index%> from 'libraries/<%=material.name%>@<%= material.version %>/<%=material.entries.entry%>';
|
|
6
|
-
const <%= _.camelCase(material.name)%>Actions_<%= index%> = <%= _.camelCase(material.name)%>_<%= index%>.actions
|
|
7
|
-
<% } else { (material.actions || []).map(act => {%>
|
|
8
|
-
import <%= _.camelCase(material.name)%>_<%=act.name%> from 'libraries/<%=material.name%>@<%= material.version %>/actions/<%= act.name %>'
|
|
9
|
-
<% }) }}) %>
|
|
10
|
-
export default {
|
|
11
|
-
<% materials.map((material, index) => {
|
|
12
|
-
%> ['<%= material.name%>']:<% if(material.entries && (material.entries.entry || material.entries.actions)){ %> <%=_.camelCase(material.name)%>Actions_<%= index%>,
|
|
13
|
-
<% }else{ %> {<% (material.actions || []).map(act => { %>
|
|
14
|
-
['<%= act.name%>']: <%= _.camelCase(material.name)%>_<%=act.name%>,<%})%>
|
|
15
|
-
},
|
|
16
|
-
<%}}) %>}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { mountAPIs } from './global-api';
|
|
2
|
-
import sdk from '@tcwd/weapps-sdk/lib/app-h5-sdk';
|
|
3
|
-
|
|
4
|
-
mountAPIs(sdk);
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 适配 wx.navigateTo 用法
|
|
8
|
-
*/
|
|
9
|
-
function navigateTo({ url }) {
|
|
10
|
-
let paths = url.split('?');
|
|
11
|
-
let result = /pages\/([0-9a-zA-z_]+)\/index/.exec(paths[0]);
|
|
12
|
-
let hash = '';
|
|
13
|
-
if (result.length > 1) {
|
|
14
|
-
hash = `/${result[0]}`;
|
|
15
|
-
}
|
|
16
|
-
let path = `/${hash}`;
|
|
17
|
-
location.hash = `${path}${paths[1] ? `?${paths[1]}` : ''}`;
|
|
18
|
-
}
|
|
19
|
-
if (process.env.isApp) {
|
|
20
|
-
window.wx = {
|
|
21
|
-
...(window.wx || {}),
|
|
22
|
-
...sdk,
|
|
23
|
-
navigateTo,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import dataSourceProfiles from './datasource-profiles'
|
|
2
|
-
import datasetProfiles from './dataset-profiles'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 数据源基本配置
|
|
6
|
-
*/
|
|
7
|
-
export default {
|
|
8
|
-
/** 当前是否处于正式发布模式 */
|
|
9
|
-
isProd: <%= isProd %>,
|
|
10
|
-
/** 低码应用ID */
|
|
11
|
-
appID: '<%= appID %>',
|
|
12
|
-
/** 云开发环境ID */
|
|
13
|
-
envID: '<%= envID %>',
|
|
14
|
-
/** 应用端ID */
|
|
15
|
-
tcbClientId: '<%= clientID %>',
|
|
16
|
-
/** 数据源描述对象数组 */
|
|
17
|
-
dataSourceProfiles: dataSourceProfiles,
|
|
18
|
-
/**
|
|
19
|
-
* 新的dataset变量配置对象
|
|
20
|
-
* key 为页面ID(全局为$global), val 为变量配置数组
|
|
21
|
-
*/
|
|
22
|
-
datasetProfiles: datasetProfiles,
|
|
23
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { _WEDA_CLOUD_SDK as WEDA_CLOUD_SDK } from '@cloudbase/weda-client'
|
|
2
|
-
import config from './config';
|
|
3
|
-
|
|
4
|
-
const {
|
|
5
|
-
setConfig,
|
|
6
|
-
initTcb,
|
|
7
|
-
CLOUD_SDK,
|
|
8
|
-
createDataset,
|
|
9
|
-
createStateDataSourceVar,
|
|
10
|
-
generateParamsParser,
|
|
11
|
-
EXTRA_API,
|
|
12
|
-
DS_API,
|
|
13
|
-
DS_SDK,
|
|
14
|
-
getAccessToken,
|
|
15
|
-
} = WEDA_CLOUD_SDK
|
|
16
|
-
|
|
17
|
-
export {
|
|
18
|
-
createDataset,
|
|
19
|
-
createStateDataSourceVar,
|
|
20
|
-
generateParamsParser,
|
|
21
|
-
EXTRA_API,
|
|
22
|
-
CLOUD_SDK,
|
|
23
|
-
DS_API,
|
|
24
|
-
DS_SDK,
|
|
25
|
-
setConfig,
|
|
26
|
-
initTcb,
|
|
27
|
-
getAccessToken,
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
setConfig(config);
|
|
31
|
-
initTcb();
|