@cloudbase/lowcode-builder 0.0.4 → 0.1.2
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 +2 -0
- package/lib/builder/core/index.js +7 -1
- package/lib/builder/h5/copy.js +17 -3
- package/lib/builder/mp/wxml.js +5 -1
- package/lib/tests/build.d.ts +1 -0
- package/lib/tests/build.js +19 -0
- package/lib/tests/build.test.d.ts +1 -0
- package/lib/tests/build.test.js +22 -0
- package/lib/tests/data.d.ts +18 -0
- package/lib/tests/data.js +94216 -0
- package/package.json +4 -3
- package/template/html/index.html.ejs +6 -9
- package/template/mp/app/weapps-api.js +17 -45
- package/template/mp/app.js +66 -66
- package/template/mp/common/weapp-page.js +3 -1
- package/template/mp/datasources/index.js +13 -4
- package/template/mp/package.json +12 -10
- package/template/package.json +4 -2
- package/template/src/app/global-api.js +6 -83
- package/template/src/app/material-actions.js +15 -13
- package/template/src/datasources/index.js +15 -2
- package/template/src/index.jsx +1 -1
- package/template/webpack/web.prod.js +62 -41
- package/template/src/pages/composite.tpl +0 -151
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
|
|
5
5
|
"author": "yhsunshining@gmail.com",
|
|
6
6
|
"homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"develop": "tsc -w",
|
|
28
28
|
"build": "tsc",
|
|
29
29
|
"test": "jest",
|
|
30
|
-
"test:
|
|
30
|
+
"test:build": "ts-node ./__test__/build.ts"
|
|
31
31
|
},
|
|
32
32
|
"bugs": {
|
|
33
33
|
"url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@cloudbase/cals": "0.3.3",
|
|
37
|
-
"@cloudbase/lowcode-generator": "0.
|
|
37
|
+
"@cloudbase/lowcode-generator": "^0.6.13",
|
|
38
38
|
"axios": "^0.21.0",
|
|
39
39
|
"chalk": "^2.4.2",
|
|
40
40
|
"compare-versions": "^3.6.0",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"csstype": "^2.6.10",
|
|
66
66
|
"jest": "^26.0.1",
|
|
67
67
|
"ts-jest": "^27.0.5",
|
|
68
|
+
"ts-node": "^10.4.0",
|
|
68
69
|
"typescript": "^4.4.2"
|
|
69
70
|
}
|
|
70
71
|
}
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
<% if(mode !== 'production'){ %>
|
|
27
27
|
<!-- <script src="https://cdn.bootcdn.net/ajax/libs/vConsole/3.3.4/vconsole.min.js"></script>
|
|
28
28
|
<script>new VConsole()</script> -->
|
|
29
|
-
<% }%> <% Array.isArray(jsApis) &&
|
|
30
|
-
|
|
29
|
+
<% }%> <% Array.isArray(jsApis) && jsApis.filter(function(item){return
|
|
30
|
+
!!item}).forEach(function(jsApi){%>
|
|
31
31
|
<script src="<%=jsApi %>"></script>
|
|
32
32
|
<% })%>
|
|
33
33
|
|
|
@@ -373,10 +373,8 @@
|
|
|
373
373
|
<div id="root" class="main-wrap"></div>
|
|
374
374
|
<% if(canUseVite){ %>
|
|
375
375
|
<script type="module" src="/src/index.jsx"></script>
|
|
376
|
-
<% } %>
|
|
377
|
-
|
|
378
|
-
<% if(!isAdminPortal){ %>
|
|
379
|
-
<script src="//imgcache.qq.com/qcloud/cloudbase-js-sdk/1.5.3-alpha.0/cloudbase.full.js"></script>
|
|
376
|
+
<% } %> <% if(!isAdminPortal){ %>
|
|
377
|
+
<script src="https://imgcache.qq.com/qcloud/cloudbase-js-sdk/1.5.3-alpha.0/cloudbase.full.js"></script>
|
|
380
378
|
<% }%>
|
|
381
379
|
<script>
|
|
382
380
|
if (window.cloudbase) {
|
|
@@ -431,10 +429,9 @@
|
|
|
431
429
|
}
|
|
432
430
|
</script>
|
|
433
431
|
<script
|
|
434
|
-
src="
|
|
432
|
+
src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.2/_url/ajax/libs/mobx/5.15.7/mobx.umd.js"
|
|
435
433
|
crossorigin="anonymous"
|
|
436
434
|
></script>
|
|
437
|
-
<script src="
|
|
438
|
-
<script src="//qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.2/_url/npm/@zxing/library@0.18.6/umd/index.min.js"></script>
|
|
435
|
+
<script src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.2/_url/npm/@zxing/library@0.18.6/umd/index.min.js"></script>
|
|
439
436
|
</body>
|
|
440
437
|
</html>
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { observable } from 'mobx'
|
|
2
|
-
import {
|
|
2
|
+
import { createMpApp } from '@cloudbase/weda-client';
|
|
3
|
+
import { createComputed } from '<%= subLevelPath %>../common/util'
|
|
3
4
|
import process from '<%= subLevelPath %>../common/process'
|
|
4
|
-
import { DS_SDK, CLOUD_SDK, createDataset, EXTRA_API } from '<%= subLevelPath %>../datasources/index'
|
|
5
5
|
import appGlobal from '<%= subLevelPath %>../app/app-global'
|
|
6
|
-
import
|
|
6
|
+
import { createDataset, EXTRA_API } from '<%= subLevelPath %>../datasources/index'
|
|
7
7
|
|
|
8
8
|
<% if (!isBare) {%>
|
|
9
9
|
import state from '../lowcode/state'
|
|
10
|
-
import computed from '../lowcode/computed'
|
|
11
|
-
import common from './common'
|
|
10
|
+
import computed from '../lowcode/computed'
|
|
11
|
+
import common from './common'
|
|
12
12
|
<%} else {%>
|
|
13
13
|
const state = {}
|
|
14
|
-
const computed ={}
|
|
15
|
-
const common = {}
|
|
16
|
-
<%}%>
|
|
14
|
+
const computed = {}
|
|
15
|
+
const common = {}
|
|
16
|
+
<%}%>
|
|
17
17
|
|
|
18
18
|
const mainAppKey = '__weappsMainApp'
|
|
19
19
|
|
|
@@ -21,12 +21,11 @@ export const app = createGlboalApi()
|
|
|
21
21
|
export { process }
|
|
22
22
|
|
|
23
23
|
function createGlboalApi() {
|
|
24
|
+
const mpApp = createMpApp();
|
|
24
25
|
const globalAPI = {
|
|
25
26
|
id: '<%= appId %>',
|
|
26
27
|
domain: '<%= domain %>',
|
|
27
|
-
platform: 'MINIPROGRAME',
|
|
28
28
|
activePage: null,
|
|
29
|
-
dataSources: DS_SDK,
|
|
30
29
|
pages: {},
|
|
31
30
|
session: {
|
|
32
31
|
//configure: sdk.configure,
|
|
@@ -36,11 +35,7 @@ function createGlboalApi() {
|
|
|
36
35
|
state: observable(state),
|
|
37
36
|
computed: createComputed(computed),
|
|
38
37
|
common,
|
|
39
|
-
|
|
40
|
-
formatDate,
|
|
41
|
-
get: getter,
|
|
42
|
-
set: setter,
|
|
43
|
-
},
|
|
38
|
+
...mpApp
|
|
44
39
|
// ... other sdk apis & apis from mp
|
|
45
40
|
} // The global api exposed to lowcode
|
|
46
41
|
|
|
@@ -52,18 +47,16 @@ function createGlboalApi() {
|
|
|
52
47
|
globalAPI.utils.set(globalAPI.dataset.state, keyPath, userSetState[keyPath]);
|
|
53
48
|
});
|
|
54
49
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
/**
|
|
51
|
+
* 内部通用的设置状态变量值的方法
|
|
52
|
+
* varPath 结构为 $global.<变量名> 即全局变量
|
|
53
|
+
* $page.<变量名> 即当前页面变量
|
|
54
|
+
* <pageId>.<变量名> 指定页面 pageId 的变量 (应当避免修改非当前页面的变量值)
|
|
55
|
+
*/
|
|
61
56
|
globalAPI._setStateVal = (config) => {
|
|
62
57
|
// @ts-ignore
|
|
63
58
|
EXTRA_API.setState(config.varPath, config.val);
|
|
64
59
|
};
|
|
65
|
-
// mount wx apis
|
|
66
|
-
Object.assign(globalAPI, weappApis)
|
|
67
60
|
|
|
68
61
|
const subPackageName = '<%= subPackageName %>'
|
|
69
62
|
if (subPackageName) {
|
|
@@ -75,33 +68,12 @@ function createGlboalApi() {
|
|
|
75
68
|
// is mainApp
|
|
76
69
|
appGlobal[mainAppKey] = globalAPI
|
|
77
70
|
}
|
|
78
|
-
// 避免被wx.cloud 覆盖
|
|
79
|
-
globalAPI.cloud = CLOUD_SDK
|
|
80
71
|
|
|
81
72
|
// # expose some sdk modules
|
|
82
73
|
/* const sdkModsIncluded = ['flow', 'getPageOptions', 'getLaunchOptions']
|
|
83
74
|
sdkModsIncluded.forEach(key => {
|
|
84
75
|
globalAPI[key] = sdk[key]
|
|
85
76
|
}) */
|
|
86
|
-
|
|
87
|
-
globalAPI.scanCode = (options) => {
|
|
88
|
-
const {enableDefaultBehavior, ...restOptions} = options;
|
|
89
|
-
const shouldReturnPromise = (!restOptions.success && !restOptions.complete && !restOptions.fail);
|
|
90
|
-
if(shouldReturnPromise) {
|
|
91
|
-
return new Promise((resolve, reject) => {
|
|
92
|
-
scanCode(restOptions).then((res) => {
|
|
93
|
-
if(enableDefaultBehavior) {
|
|
94
|
-
globalAPI.showModal({
|
|
95
|
-
title: '扫描到以下内容',
|
|
96
|
-
content: res.result,
|
|
97
|
-
showCancel: false,
|
|
98
|
-
})
|
|
99
|
-
}
|
|
100
|
-
resolve(res)
|
|
101
|
-
})
|
|
102
|
-
.catch(reject)
|
|
103
|
-
})
|
|
104
|
-
}
|
|
105
|
-
}
|
|
77
|
+
|
|
106
78
|
return globalAPI
|
|
107
79
|
}
|
package/template/mp/app.js
CHANGED
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
import { setConfig } from '
|
|
1
|
+
import { setConfig } from './datasources/index'
|
|
2
2
|
import lifeCycle from './lowcode/lifecycle'
|
|
3
3
|
import { app } from './app/weapps-api'
|
|
4
4
|
import WxReportV2 from './common/wx_yypt_report_v2'
|
|
5
5
|
// 引入数据源管理器并进行初始化
|
|
6
6
|
import { EXTRA_API, createStateDataSourceVar, generateParamsParser } from './datasources/index'
|
|
7
7
|
const $app = app;
|
|
8
|
-
<% if(yyptConfig.yyptAppKey) { %>
|
|
8
|
+
<% if (yyptConfig.yyptAppKey) { %>
|
|
9
9
|
const wxReport = new WxReportV2({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
appKey: '<%= yyptConfig.yyptAppKey %>', // 填入你申请的运营平台的应用key(必填)
|
|
11
|
+
reportUrl: '<%= yyptConfig.reportUrl %><%= yyptConfig.yyptAppKey %>', // 上报url(把后端上报接口需要先挂网关,该url填写网关地址)
|
|
12
|
+
autoReportPV: true, // 是否自动上报页面PV
|
|
13
|
+
// getRemoteParamsUrl获取远程参数url,主要用于获取intervalTime、reportLogsNum和stopReport参数,
|
|
14
|
+
// 返回格式{stopReport:true,intervalTime:3,reportLogsNum:5}
|
|
15
|
+
getRemoteParamsUrl: '',
|
|
16
|
+
stopReport: <%= yyptConfig.stopReport %>, // 停止上报
|
|
17
|
+
intervalTime: 3, // 间隔多久执行一次上报,默认3秒
|
|
18
|
+
reportLogsNum: 5, // 每次合并上报记录条数,默认5次
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
// 设置数据源请求的 loading 及 toast 处理
|
|
22
|
-
setConfig({
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
<% }%>
|
|
37
|
-
App({
|
|
38
|
-
onLaunch(options) {
|
|
39
|
-
this.app = app
|
|
40
|
-
const onLaunch = lifeCycle.onLaunch || lifeCycle.onAppLaunch
|
|
41
|
-
let { query={} } = options
|
|
42
|
-
EXTRA_API.setParams('$global', query )
|
|
43
|
-
createStateDataSourceVar('$global', generateParamsParser({app}))
|
|
21
|
+
// 设置数据源请求的 loading 及 toast 处理
|
|
22
|
+
setConfig({
|
|
23
|
+
beforeDSRequest: (cfg) => {
|
|
24
|
+
if (!cfg.options || !cfg.options.showLoading) return
|
|
25
|
+
app.showLoading()
|
|
26
|
+
},
|
|
27
|
+
afterDSRequest: (cfg, error, result) => {
|
|
28
|
+
if (!cfg.options) return
|
|
29
|
+
if (cfg.options.showLoading) app.hideLoading()
|
|
30
|
+
if (!cfg.options.showToast) return
|
|
31
|
+
const isSuccess = !error && result && !result.code
|
|
32
|
+
app.showToast({ icon: isSuccess ? 'success' : 'error' })
|
|
33
|
+
}
|
|
34
|
+
})
|
|
44
35
|
|
|
45
|
-
onLaunch && onLaunch.call(this, options)
|
|
46
|
-
<% if(yyptConfig.yyptAppKey) { %>
|
|
47
|
-
// 挂运营平台上报对象到app里
|
|
48
|
-
app.yyptReport = wxReport
|
|
49
36
|
<% }%>
|
|
37
|
+
App({
|
|
38
|
+
onLaunch(options) {
|
|
39
|
+
this.app = app
|
|
40
|
+
const onLaunch = lifeCycle.onLaunch || lifeCycle.onAppLaunch
|
|
41
|
+
let { query = {} } = options
|
|
42
|
+
EXTRA_API.setParams('$global', query)
|
|
43
|
+
createStateDataSourceVar('$global', generateParamsParser({ app }))
|
|
50
44
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const fn = lifeCycle.onError || lifeCycle.onAppError
|
|
69
|
-
fn && fn.call(this, msg)
|
|
70
|
-
},
|
|
71
|
-
onPageNotFound() {
|
|
72
|
-
const fn = lifeCycle.onPageNotFound || lifeCycle.onAppPageNotFound
|
|
73
|
-
fn && fn.call(this)
|
|
74
|
-
},
|
|
75
|
-
onUnhandledRejection() {
|
|
76
|
-
const fn = lifeCycle.onUnhandledRejection || lifeCycle.onAppUnhandledRejection
|
|
77
|
-
fn && fn.call(this)
|
|
45
|
+
onLaunch && onLaunch.call(this, options)
|
|
46
|
+
<% if (yyptConfig.yyptAppKey) { %>
|
|
47
|
+
// 挂运营平台上报对象到app里
|
|
48
|
+
app.yyptReport = wxReport
|
|
49
|
+
<% }%>
|
|
50
|
+
|
|
51
|
+
// 初始私有全局数据
|
|
52
|
+
this.$$global = {
|
|
53
|
+
homePageId: '<%= appConfig.homePageId %>'
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
onShow(options) {
|
|
57
|
+
const fn = lifeCycle.onShow || lifeCycle.onAppShow
|
|
58
|
+
fn && fn.call(this, options)
|
|
59
|
+
<% if (yyptConfig.yyptAppKey) { %>
|
|
60
|
+
wxReport.startReport()
|
|
61
|
+
<% }%>
|
|
78
62
|
},
|
|
79
|
-
|
|
63
|
+
onHide() {
|
|
64
|
+
const fn = lifeCycle.onHide || lifeCycle.onAppHide
|
|
65
|
+
fn && fn.call(this)
|
|
66
|
+
},
|
|
67
|
+
onError(msg) {
|
|
68
|
+
const fn = lifeCycle.onError || lifeCycle.onAppError
|
|
69
|
+
fn && fn.call(this, msg)
|
|
70
|
+
},
|
|
71
|
+
onPageNotFound() {
|
|
72
|
+
const fn = lifeCycle.onPageNotFound || lifeCycle.onAppPageNotFound
|
|
73
|
+
fn && fn.call(this)
|
|
74
|
+
},
|
|
75
|
+
onUnhandledRejection() {
|
|
76
|
+
const fn = lifeCycle.onUnhandledRejection || lifeCycle.onAppUnhandledRejection
|
|
77
|
+
fn && fn.call(this)
|
|
78
|
+
},
|
|
79
|
+
})
|
|
@@ -2,7 +2,7 @@ import { observable } from 'mobx';
|
|
|
2
2
|
import { createComputed, createEventHandlers, checkAuth } from './util';
|
|
3
3
|
import { createWidgets, createInitData, disposeWidget } from './widget';
|
|
4
4
|
import mergeRenderer from './merge-renderer';
|
|
5
|
-
import { createDataset, EXTRA_API, createStateDataSourceVar, generateParamsParser } from '../datasources/index';
|
|
5
|
+
import { createDataset, EXTRA_API, createStateDataSourceVar, generateParamsParser, setConfig } from '../datasources/index';
|
|
6
6
|
import { runWatchers } from './watch'
|
|
7
7
|
|
|
8
8
|
export function createPage(
|
|
@@ -71,6 +71,7 @@ export function createPage(
|
|
|
71
71
|
...mergeRenderer,
|
|
72
72
|
onLoad(options) {
|
|
73
73
|
const $page = this.getWeAppInst()
|
|
74
|
+
setConfig({ currentPageId: $page.uuid });
|
|
74
75
|
app.activePage = $page;
|
|
75
76
|
this._pageActive = true;
|
|
76
77
|
|
|
@@ -97,6 +98,7 @@ export function createPage(
|
|
|
97
98
|
},
|
|
98
99
|
async onShow() {
|
|
99
100
|
const $page = this.getWeAppInst()
|
|
101
|
+
setConfig({ currentPageId: $page.uuid });
|
|
100
102
|
app.activePage = $page;
|
|
101
103
|
this._pageActive = true;
|
|
102
104
|
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WEDA_CLOUD_SDK } from '@cloudbase/weda-client'
|
|
2
|
+
const {
|
|
2
3
|
setConfig,
|
|
3
4
|
initTcb,
|
|
4
|
-
CLOUD_SDK
|
|
5
|
-
|
|
5
|
+
CLOUD_SDK,
|
|
6
|
+
createDataset,
|
|
7
|
+
createStateDataSourceVar,
|
|
8
|
+
generateParamsParser,
|
|
9
|
+
EXTRA_API,
|
|
10
|
+
DS_API,
|
|
11
|
+
DS_SDK
|
|
12
|
+
} = WEDA_CLOUD_SDK
|
|
13
|
+
|
|
6
14
|
export {
|
|
7
15
|
createDataset,
|
|
8
16
|
createStateDataSourceVar,
|
|
@@ -11,7 +19,8 @@ export {
|
|
|
11
19
|
CLOUD_SDK,
|
|
12
20
|
DS_API,
|
|
13
21
|
DS_SDK,
|
|
14
|
-
|
|
22
|
+
setConfig
|
|
23
|
+
}
|
|
15
24
|
|
|
16
25
|
import config from './config'
|
|
17
26
|
|
package/template/mp/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lcap-<%= appId%>",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"scripts": {
|
|
3
|
+
"version": "1.0.8",
|
|
4
|
+
"scripts": {},
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@cloudbase/weda-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
6
|
+
"@cloudbase/weda-client": "stable",
|
|
7
|
+
"mobx": "^5.15.4",
|
|
8
|
+
"lodash.get": "^4.4.2",
|
|
9
|
+
"lodash.set": "^4.3.2",
|
|
10
|
+
"miniprogram-gesture": "^1.0.6",
|
|
11
|
+
"miniprogram-api-promise": "^1.0.4"<% Object.keys(extraDeps).map(depName => {%>,
|
|
12
|
+
"<%= depName%>": "<%= extraDeps[depName]%>"<%
|
|
13
|
+
})
|
|
12
14
|
%>
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
+
}
|
|
16
|
+
}
|
package/template/package.json
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@cloudbase/js-sdk": "1.5.3-alpha.0",
|
|
9
|
-
"@cloudbase/weda-cloud-sdk": "stable",
|
|
10
9
|
"@tcwd/weapps-core": "2.2.6",
|
|
11
10
|
"@tcwd/weapps-sdk": "1.2.9",
|
|
12
11
|
"@zxing/library": "^0.18.6",
|
|
12
|
+
"@cloudbase/weda-client": "stable",
|
|
13
13
|
"fastclick": "^1.0.6",
|
|
14
14
|
"lodash": "^4.17.19",
|
|
15
15
|
"mobx": "^5.15.4",
|
|
@@ -54,8 +54,10 @@
|
|
|
54
54
|
"mini-css-extract-plugin": "^0.8.0",
|
|
55
55
|
"hard-source-webpack-plugin": "^0.13.1",
|
|
56
56
|
"html-webpack-plugin": "^3.2.0",
|
|
57
|
+
"ts-loader": "^8.3.0",
|
|
58
|
+
"typescript": "^4.4.4",
|
|
57
59
|
"webpack": "^4.41.4",
|
|
58
60
|
"webpack-cli": "^4.2.0",
|
|
59
61
|
"webpack-dev-server": "^3.11.0"
|
|
60
62
|
}
|
|
61
|
-
}
|
|
63
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as sdk from '@tcwd/weapps-sdk';
|
|
2
2
|
import { createComputed } from 'utils';
|
|
3
|
-
import { DS_SDK, CLOUD_SDK, createDataset, EXTRA_API } from '../datasources';
|
|
4
3
|
import store, { subPackageName } from '../store';
|
|
5
4
|
import computed from '../store/computed';
|
|
6
5
|
import common from './common';
|
|
@@ -8,6 +7,8 @@ import { formatDate } from '../utils/date';
|
|
|
8
7
|
import { getter, setter, _isMobile } from '../utils';
|
|
9
8
|
import actionMap from './material-actions';
|
|
10
9
|
import { scanCodeApi } from '../utils/scan-code-action';
|
|
10
|
+
import { createWebApp, ACTIONS_KEY, ROUTER_KEY } from '@cloudbase/weda-client';
|
|
11
|
+
import { createDataset, EXTRA_API } from '../datasources/index'
|
|
11
12
|
|
|
12
13
|
const mainAppKey = '__weappsMainApp';
|
|
13
14
|
const appGlobal = process.env.isMiniprogram ? getApp() : window;
|
|
@@ -20,10 +21,10 @@ export function setCurrentPage(pageCtx) {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
function createGlboalApi() {
|
|
24
|
+
const mpApp = createWebApp();
|
|
23
25
|
const globalAPI = {
|
|
24
26
|
id: '<%= appId %>',
|
|
25
27
|
domain: '<%= domain %>',
|
|
26
|
-
platform: 'WEB',
|
|
27
28
|
formActions: {},
|
|
28
29
|
pages: {},
|
|
29
30
|
session: {
|
|
@@ -34,12 +35,7 @@ function createGlboalApi() {
|
|
|
34
35
|
state: store,
|
|
35
36
|
computed: createComputed(computed.global),
|
|
36
37
|
common,
|
|
37
|
-
|
|
38
|
-
utils: {
|
|
39
|
-
formatDate,
|
|
40
|
-
get: getter,
|
|
41
|
-
set: setter,
|
|
42
|
-
},
|
|
38
|
+
...mpApp
|
|
43
39
|
// ... other sdk apis & apis from mp
|
|
44
40
|
}; // The global api exposed to lowcode
|
|
45
41
|
|
|
@@ -81,8 +77,6 @@ function createGlboalApi() {
|
|
|
81
77
|
sdkModsIncluded.forEach((key) => {
|
|
82
78
|
globalAPI[key] = sdk[key];
|
|
83
79
|
});
|
|
84
|
-
// 避免被wx.cloud 覆盖
|
|
85
|
-
globalAPI.cloud = CLOUD_SDK;
|
|
86
80
|
|
|
87
81
|
return globalAPI;
|
|
88
82
|
}
|
|
@@ -103,80 +97,9 @@ function createPageApi() {
|
|
|
103
97
|
export const mountAPIs = (sdks) => {
|
|
104
98
|
Object.keys(sdks).forEach((item) => {
|
|
105
99
|
let action = sdks[item];
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
case 'showToast': {
|
|
109
|
-
action = function (obj) {
|
|
110
|
-
if (obj.icon === 'error' && !obj.image) {
|
|
111
|
-
return sdks[item]({
|
|
112
|
-
...obj,
|
|
113
|
-
image:
|
|
114
|
-
'data:image/svg+xml,%3Csvg%20width%3D%22120%22%20height%3D%22120%22%20viewBox%3D%220,0,24,24%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M12%2010.586l5.657-5.657%201.414%201.414L13.414%2012l5.657%205.657-1.414%201.414L12%2013.414l-5.657%205.657-1.414-1.414L10.586%2012%204.929%206.343%206.343%204.93%2012%2010.586z%22%20fill-rule%3D%22evenodd%22%20fill%3D%22white%22%2F%3E%3C%2Fsvg%3E',
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
return sdks[item](obj);
|
|
118
|
-
};
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
case 'showModal': {
|
|
122
|
-
const OFFICIAL_COMPONENT_LIB = 'gsd-h5-react';
|
|
123
|
-
const showModal =
|
|
124
|
-
actionMap[OFFICIAL_COMPONENT_LIB] &&
|
|
125
|
-
actionMap[OFFICIAL_COMPONENT_LIB].showModal;
|
|
126
|
-
if (!_isMobile() && showModal) {
|
|
127
|
-
action = function (params) {
|
|
128
|
-
return showModal({ data: params });
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
case 'scanCode': {
|
|
134
|
-
action = (options) => {
|
|
135
|
-
if (
|
|
136
|
-
!options ||
|
|
137
|
-
(!options.success && !options.fail && !options.complete)
|
|
138
|
-
) {
|
|
139
|
-
return new Promise((resolve, reject) => {
|
|
140
|
-
scanCodeApi({
|
|
141
|
-
...options,
|
|
142
|
-
success: resolve,
|
|
143
|
-
fail: reject,
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
scanCodeApi(options);
|
|
148
|
-
};
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
case 'navigateTo':
|
|
152
|
-
case 'reLaunch':
|
|
153
|
-
case 'redirectTo': {
|
|
154
|
-
action = function (obj) {
|
|
155
|
-
if (obj.mode === 'web' && process.env.isMiniprogram) {
|
|
156
|
-
console.warn('url navigation can only be used in h5 build');
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
const { url, ...restOpts } = obj;
|
|
160
|
-
if (obj.mode === 'web') {
|
|
161
|
-
if (item === 'navigateTo') {
|
|
162
|
-
window.open(url);
|
|
163
|
-
} else {
|
|
164
|
-
window.location.href = url;
|
|
165
|
-
}
|
|
166
|
-
} else {
|
|
167
|
-
return sdks[item]({
|
|
168
|
-
...restOpts,
|
|
169
|
-
pageId: restOpts.pageId
|
|
170
|
-
? restOpts.pageId.replace(/^(\.)?\//, '')
|
|
171
|
-
: restOpts.pageId,
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
100
|
+
if (!(item in ACTIONS_KEY) && !(item in ROUTER_KEY)) {
|
|
101
|
+
app[item] = action;
|
|
177
102
|
}
|
|
178
|
-
|
|
179
|
-
app[item] = action;
|
|
180
103
|
});
|
|
181
104
|
return app;
|
|
182
105
|
};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
// Imports all material actions
|
|
2
|
-
<% materials.map((material,index) => { if(material.
|
|
3
|
-
import <%= _.camelCase(material.name)%>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<% }
|
|
8
|
-
|
|
9
|
-
<%
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
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,6 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WEDA_CLOUD_SDK } from '@cloudbase/weda-client'
|
|
2
2
|
import config from './config';
|
|
3
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
|
+
} = WEDA_CLOUD_SDK
|
|
15
|
+
|
|
4
16
|
export {
|
|
5
17
|
createDataset,
|
|
6
18
|
createStateDataSourceVar,
|
|
@@ -9,7 +21,8 @@ export {
|
|
|
9
21
|
CLOUD_SDK,
|
|
10
22
|
DS_API,
|
|
11
23
|
DS_SDK,
|
|
12
|
-
|
|
24
|
+
setConfig
|
|
25
|
+
}
|
|
13
26
|
|
|
14
27
|
setConfig(config);
|
|
15
28
|
initTcb();
|
package/template/src/index.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import * as ReactDOM from 'react-dom'
|
|
3
|
-
import { setConfig } from '
|
|
3
|
+
import { setConfig } from './datasources/index'
|
|
4
4
|
import App from './router'
|
|
5
5
|
import './utils/monitor-jssdk.min'
|
|
6
6
|
import './index.less'
|