@cloudbase/framework-plugin-low-code 0.6.54 → 0.6.57
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/index.d.ts.map +1 -1
- package/lib/builder/mp/index.js +1 -0
- package/lib/builder/service/builder/generate.d.ts.map +1 -1
- package/lib/builder/service/builder/generate.js +6 -4
- package/package.json +2 -2
- package/template/mp/common/weapp-page.js +23 -11
- package/template/mp/common/weapp-sdk.js +35 -0
- package/template/mp/component/index.js +2 -2
- package/template/mp/page/index.js +2 -2
- package/template/package.json +1 -0
- package/template/src/pages/app.tpl +53 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/builder/mp/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,aAAa,EACb,UAAU,EAEV,OAAO,EAIR,MAAM,mBAAmB,CAAC;AAU3B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAkB/C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAEL,SAAS,EACT,YAAY,EACZ,UAAU,EACX,MAAM,iBAAiB,CAAC;AAUzB,wBAAsB,YAAY,CAAC,EACjC,MAAM,EACN,OAAO,EACP,KAAK,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,YAAY,EACZ,UAAU,EACV,SAAS,EACT,SAAS,EACT,OAAO,EACP,aAAa,GACd,EAAE;IACD,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,WAAW,CAAC;IACxB,SAAS,EAAE,GAAG,CAAC;IACf,SAAS,EAAE,OAAO,C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;AA4KD,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,aAAa,iBAgCnB;AAYD,wBAAgB,oBAAoB,CAAC,EACnC,YAAY,EACZ,MAAM,EACN,SAAS,GACV,EAAE;IACD,YAAY,EAAE,aAAa,CAAC;IAC5B,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,SAAS,EAAE,aAAa,EAAE,CAAC;CAC5B;;;EA0CA"}
|
package/lib/builder/mp/index.js
CHANGED
|
@@ -258,6 +258,7 @@ function generatePkg(weapp, appRoot, ctx, pageConfigs) {
|
|
|
258
258
|
widgetProps: util_2.createWidgetProps(page.componentInstances, ctx),
|
|
259
259
|
pageUUID: rootPath ? `${rootPath}/${page.id}` : page.id,
|
|
260
260
|
pageName: page.id,
|
|
261
|
+
pageSource: page.data.src || '',
|
|
261
262
|
eventHanlders: util_2.createEventHanlders(page.componentInstances, '$page', ctx),
|
|
262
263
|
dataBinds: util_2.createDataBinds(page.componentInstances, ctx),
|
|
263
264
|
debug: !ctx.isProduction,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../src/builder/service/builder/generate.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAGxD,OAAO,EACL,aAAa,EACb,aAAa,EACb,iBAAiB,EAEjB,oBAAoB,EACpB,eAAe,EAEf,aAAa,EAEb,kBAAkB,EAWlB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAgB9B,OAAO,EAIL,SAAS,EACT,kBAAkB,EAEnB,MAAM,oBAAoB,CAAC;AAQ5B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAGxF,MAAM,WAAW,cAAe,SAAQ,kBAAkB;CAAG;AAE7D,wBAAsB,wBAAwB,CAC5C,cAAc,EAAE,kBAAkB,EAAE,EACpC,WAAW,EAAE,MAAM,iBAwBpB;AAED,wBAAsB,qBAAqB,CACzC,SAAS,oBAAa,EACtB,WAAW,EAAE,MAAM,iBAiBpB;AAED,wBAAsB,sBAAsB,CAC1C,gBAAgB,EAAE,aAAa,EAAE,EACjC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,YAAY,6BAAsB,EAClC,SAAS;iBACM,OAAO;eACT,GAAG;aAIf,EACD,aAAa,EAAE,GAAG,EAAE,iBAcrB;AAED,wBAAsB,yBAAyB,CAC7C,YAAY,EAAE,aAAa,EAC3B,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,YAAY,6BAAsB,EAClC,SAAS;iBACM,OAAO;eACT,GAAG;aAIf,EACD,aAAa,EAAE,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../src/builder/service/builder/generate.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAGxD,OAAO,EACL,aAAa,EACb,aAAa,EACb,iBAAiB,EAEjB,oBAAoB,EACpB,eAAe,EAEf,aAAa,EAEb,kBAAkB,EAWlB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAgB9B,OAAO,EAIL,SAAS,EACT,kBAAkB,EAEnB,MAAM,oBAAoB,CAAC;AAQ5B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAGxF,MAAM,WAAW,cAAe,SAAQ,kBAAkB;CAAG;AAE7D,wBAAsB,wBAAwB,CAC5C,cAAc,EAAE,kBAAkB,EAAE,EACpC,WAAW,EAAE,MAAM,iBAwBpB;AAED,wBAAsB,qBAAqB,CACzC,SAAS,oBAAa,EACtB,WAAW,EAAE,MAAM,iBAiBpB;AAED,wBAAsB,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AC1B,SAAS,KAAA,iBAsFV"}
|
|
@@ -112,6 +112,7 @@ function generateSinglePageJsxFile(pageInstance, appBuildDir, rootPath, dependen
|
|
|
112
112
|
const templateData = {
|
|
113
113
|
pageUUID: rootPath ? `${rootPath}/${pageInstance.id}` : pageInstance.id,
|
|
114
114
|
pageName: pageInstance.id,
|
|
115
|
+
pageSource: pageInstance.data.src || '',
|
|
115
116
|
pageStyleText: pageStyleString,
|
|
116
117
|
entryImports: entryImportStringArr.join(';\n'),
|
|
117
118
|
componentImports: componentImportStringArr.join(';\n'),
|
|
@@ -713,21 +714,22 @@ function writeLowCodeFilesForCompositeComp(compositeGroups, appBuildDir) {
|
|
|
713
714
|
exports.writeLowCodeFilesForCompositeComp = writeLowCodeFilesForCompositeComp;
|
|
714
715
|
function generateCodeFromTpl(appData, appBuildDir, dependencies, appKey, rootPath, deployMode, buildTypeList, extraData) {
|
|
715
716
|
return __awaiter(this, void 0, void 0, function* () {
|
|
716
|
-
const
|
|
717
|
+
const computedPageIds = [];
|
|
717
718
|
const pageModules = {};
|
|
718
719
|
weapps_core_1.loopDealWithFn(appData.pageInstanceList, (p) => {
|
|
719
|
-
pageIds.push(p.id);
|
|
720
720
|
pageModules[p.id] = p.codeModules;
|
|
721
|
+
if (p.codeModules.find((item) => item.type === 'computed')) {
|
|
722
|
+
computedPageIds.push(p.id);
|
|
723
|
+
}
|
|
721
724
|
});
|
|
722
725
|
const yyptConfig = yield util_2.getYyptConfigInfo(extraData);
|
|
723
726
|
const templatesData = {
|
|
724
727
|
'store/index.js': {
|
|
725
|
-
pageIds,
|
|
726
728
|
appId: appKey,
|
|
727
729
|
rootPath: rootPath,
|
|
728
730
|
},
|
|
729
731
|
'store/computed.js': {
|
|
730
|
-
pageIds,
|
|
732
|
+
pageIds: computedPageIds,
|
|
731
733
|
},
|
|
732
734
|
'app/handlers.js': {
|
|
733
735
|
pageModules,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/framework-plugin-low-code",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.57",
|
|
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",
|
|
@@ -87,4 +87,4 @@
|
|
|
87
87
|
"jest": "^26.0.1",
|
|
88
88
|
"typescript": "^3.8.3"
|
|
89
89
|
}
|
|
90
|
-
}
|
|
90
|
+
}
|
|
@@ -15,16 +15,6 @@ export function createPage(
|
|
|
15
15
|
$page,
|
|
16
16
|
context,
|
|
17
17
|
) {
|
|
18
|
-
$page.state = observable(pageState);
|
|
19
|
-
let dataset = createDataset($page.uuid);
|
|
20
|
-
$page.dataset = dataset;
|
|
21
|
-
$page.state.dataset = dataset;
|
|
22
|
-
$page.computed = createComputed(pageComputed);
|
|
23
|
-
$page.setState = (userSetState) => {
|
|
24
|
-
Object.keys(userSetState).forEach((keyPath) => {
|
|
25
|
-
app.utils.set($page.dataset.state, keyPath, userSetState[keyPath]);
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
18
|
const evtHandlers = createEventHandlers(evtListeners, context);
|
|
29
19
|
|
|
30
20
|
function extractLifecyles() {
|
|
@@ -57,6 +47,7 @@ export function createPage(
|
|
|
57
47
|
data: createInitData(widgetProps, dataBinds),
|
|
58
48
|
lifetimes: {
|
|
59
49
|
attached() {
|
|
50
|
+
const $page = this.getWeAppInst()
|
|
60
51
|
// createWidgets 从上面移到这里是为了 i18n 切换语言的时候页面能生效
|
|
61
52
|
$page.widgets = {};
|
|
62
53
|
const { rootWidget, widgets } = createWidgets(widgetProps, dataBinds, $page.widgets, context);
|
|
@@ -83,6 +74,8 @@ export function createPage(
|
|
|
83
74
|
...evtHandlers,
|
|
84
75
|
...mergeRenderer,
|
|
85
76
|
onLoad(options) {
|
|
77
|
+
const $page = this.getWeAppInst()
|
|
78
|
+
|
|
86
79
|
app.activePage = $page;
|
|
87
80
|
setConfig({ currentPageId: $page.uuid });
|
|
88
81
|
this._pageActive = true;
|
|
@@ -95,12 +88,14 @@ export function createPage(
|
|
|
95
88
|
hook && hook.call(this, query);
|
|
96
89
|
},
|
|
97
90
|
onUnload() {
|
|
91
|
+
const $page = this.getWeAppInst()
|
|
98
92
|
this._disposers.forEach(dispose => dispose());
|
|
99
93
|
|
|
100
94
|
const hook = lifecycle.onUnload || lifecycle.onPageUnload;
|
|
101
95
|
hook && hook.call(this);
|
|
102
96
|
},
|
|
103
97
|
async onShow() {
|
|
98
|
+
const $page = this.getWeAppInst()
|
|
104
99
|
app.activePage = $page;
|
|
105
100
|
setConfig({ currentPageId: $page.uuid });
|
|
106
101
|
$page.widgets = this._widgets;
|
|
@@ -117,12 +112,29 @@ export function createPage(
|
|
|
117
112
|
}
|
|
118
113
|
},
|
|
119
114
|
onHide() {
|
|
115
|
+
const $page = this.getWeAppInst()
|
|
120
116
|
const hook = lifecycle.onHide || lifecycle.onPageHide;
|
|
121
117
|
hook && hook.call(this);
|
|
122
118
|
this._pageActive = false;
|
|
123
119
|
},
|
|
124
120
|
|
|
125
|
-
getWeAppInst
|
|
121
|
+
getWeAppInst() {
|
|
122
|
+
if(!this.$WEAPPS_PAGE){
|
|
123
|
+
$page.state = observable(pageState);
|
|
124
|
+
let dataset = createDataset($page.uuid);
|
|
125
|
+
$page.dataset = dataset;
|
|
126
|
+
$page.state.dataset = dataset;
|
|
127
|
+
$page.computed = createComputed(pageComputed);
|
|
128
|
+
$page.setState = (userSetState) => {
|
|
129
|
+
Object.keys(userSetState).forEach((keyPath) => {
|
|
130
|
+
app.utils.set($page.dataset.state, keyPath, userSetState[keyPath]);
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
this.$WEAPPS_PAGE = $page;
|
|
135
|
+
}
|
|
136
|
+
return this.$WEAPPS_PAGE
|
|
137
|
+
},
|
|
126
138
|
},
|
|
127
139
|
});
|
|
128
140
|
}
|
|
@@ -15,6 +15,12 @@ function createNavigatorFn(fnName) {
|
|
|
15
15
|
? `/${packageName}/pages/${pageId}/index`
|
|
16
16
|
: `/pages/${pageId}/index`
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
if (fnName === 'navigateTo') {
|
|
20
|
+
navigateToFn(urlJoinParams(url, params), { events, success, fail, complete});
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
18
24
|
wx[fnName]({
|
|
19
25
|
url: urlJoinParams(url, params),
|
|
20
26
|
events,
|
|
@@ -25,6 +31,35 @@ function createNavigatorFn(fnName) {
|
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
|
|
34
|
+
/**
|
|
35
|
+
* 页面堆栈10以内使用wx.navigateTo,超过10则使用wx.redirectTo
|
|
36
|
+
* @param url
|
|
37
|
+
* @param param1
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
function navigateToFn(url, { events, success, fail, complete}) {
|
|
41
|
+
const pages = getCurrentPages();
|
|
42
|
+
if(pages && pages.length >= 10) {
|
|
43
|
+
wx.redirectTo({
|
|
44
|
+
url,
|
|
45
|
+
success,
|
|
46
|
+
fail,
|
|
47
|
+
complete
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
wx.navigateTo({
|
|
53
|
+
url,
|
|
54
|
+
// @types/weixin-app@2.9.3没有events的定义,但实际上官方文档有:https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.navigateTo.html
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
events,
|
|
57
|
+
success,
|
|
58
|
+
fail,
|
|
59
|
+
complete
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
28
63
|
const navigateTo = createNavigatorFn('navigateTo')
|
|
29
64
|
const reLaunch = createNavigatorFn('reLaunch')
|
|
30
65
|
const redirectTo = createNavigatorFn('redirectTo')
|
|
@@ -25,7 +25,7 @@ const evtListeners = {<% Object.entries(eventHandlers).map(([handlerName, listen
|
|
|
25
25
|
handler: <% if (l.type == 'rematch') {%> _handler<%= l.handler %> <%} else {%> <%= l.handler %> <%} %>,
|
|
26
26
|
data: <%= stringifyObj(l.data, {depth: null}) %>,
|
|
27
27
|
boundData: {<% Object.entries(l.boundData).map(([prop, expr])=>{%>'<%= prop %>':(lists, forItems, event, $context) => {const $for=forItems; return (
|
|
28
|
-
<%= expr %>
|
|
28
|
+
<%= expr === ''? 'undefined': expr %>
|
|
29
29
|
)},
|
|
30
30
|
<%}) %>}
|
|
31
31
|
},<%})%>
|
|
@@ -55,7 +55,7 @@ const handler = {<% handlers.forEach(h => {%>
|
|
|
55
55
|
const dataBinds = {<% Object.entries(dataBinds).map(([id, widgetBinds])=>{%>
|
|
56
56
|
<%= id %>: { <% Object.entries(widgetBinds).map(([prop, expr]) => { %>
|
|
57
57
|
<%= prop %>: function (lists, forItems, event, $context) {const $for=forItems; return (
|
|
58
|
-
<%= expr %>
|
|
58
|
+
<%= expr === '' ? 'undefined': expr %>
|
|
59
59
|
); },<% }) %>
|
|
60
60
|
},<%}) %>
|
|
61
61
|
}
|
|
@@ -20,7 +20,7 @@ const evtListeners = {<% Object.entries(eventHanlders).map(([handlerName, listen
|
|
|
20
20
|
handler: <% if (l.type === 'rematch') {%> handlers.<%= l.handler %> <%} else if (l.type == 'material') {%> function(...args) { return require('../../materials/<%= l.handlerModule %>/actions/<%= l.handler %>/index').default(...args) } <%} else {%> <%= l.handler %> <%} %>,
|
|
21
21
|
data: <%= stringifyObj(l.data, {depth: null}) %>,
|
|
22
22
|
boundData: {<% Object.entries(l.boundData).map(([prop, expr])=>{%>'<%= prop %>':(lists, forItems, event, $context) => {const $for = forItems; return (
|
|
23
|
-
<%= expr %>
|
|
23
|
+
<%= expr === '' ? 'undefined': expr %>
|
|
24
24
|
)},
|
|
25
25
|
<%}) %>}
|
|
26
26
|
},<%})%>
|
|
@@ -29,7 +29,7 @@ const evtListeners = {<% Object.entries(eventHanlders).map(([handlerName, listen
|
|
|
29
29
|
const dataBinds = {<% Object.entries(dataBinds).map(([id, widgetBinds])=>{%>
|
|
30
30
|
<%= id %>: { <% Object.entries(widgetBinds).map(([prop, expr]) => { %>
|
|
31
31
|
<%= prop %>: function (lists, forItems, event, $context) {const $for = forItems; return (
|
|
32
|
-
<%= expr %>
|
|
32
|
+
<%= expr === '' ? 'undefined': expr %>
|
|
33
33
|
); },<% }) %>
|
|
34
34
|
},<%}) %>
|
|
35
35
|
}
|
package/template/package.json
CHANGED
|
@@ -6,9 +6,6 @@ import { initLifeCycle, pageLifeCycleMount } from 'handlers/lifecycle'
|
|
|
6
6
|
import { createComputed } from 'utils'
|
|
7
7
|
import AppLifeCycle from 'lowcode/lifecycle'
|
|
8
8
|
import { createDataset, createStateDataSourceVar, generateParamsParser, EXTRA_API } from '../../datasources'
|
|
9
|
-
import PageLifeCycle from '../../lowcode/<%= pageName %>/lifecycle'
|
|
10
|
-
import initPageState from '../../lowcode/<%= pageName %>/state'
|
|
11
|
-
import computed from '../../lowcode/<%= pageName %>/computed'
|
|
12
9
|
import { $$_<%= pageName %> as handler } from '../../app/handlers'
|
|
13
10
|
import { app as mainApp } from 'app/global-api' // 取主包app
|
|
14
11
|
import { app, $page } from '../../app/global-api' // 取对应子包app
|
|
@@ -16,6 +13,23 @@ import { createWidgets, retryDataBinds, resolveComponentProps, checkAuth, report
|
|
|
16
13
|
import { useScrollTop } from 'handlers/hooks'
|
|
17
14
|
import { get } from "lodash";
|
|
18
15
|
import './index.less'
|
|
16
|
+
<% if(pageSource){ %>
|
|
17
|
+
import { loadMicroApp } from 'qiankun';
|
|
18
|
+
const PageLifeCycle = {};
|
|
19
|
+
const initPageState = {};
|
|
20
|
+
const computed = {}
|
|
21
|
+
<% } else { %>
|
|
22
|
+
import PageLifeCycle from '../../lowcode/<%= pageName %>/lifecycle'
|
|
23
|
+
import initPageState from '../../lowcode/<%= pageName %>/state'
|
|
24
|
+
import computed from '../../lowcode/<%= pageName %>/computed'
|
|
25
|
+
function loadMicroApp(){
|
|
26
|
+
return new Proxy({}, {
|
|
27
|
+
get(obj, prop) {
|
|
28
|
+
return (...args) => {};
|
|
29
|
+
},
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
<% } %>
|
|
19
33
|
|
|
20
34
|
let ReactDOMServer;
|
|
21
35
|
|
|
@@ -65,6 +79,10 @@ export default function App() {
|
|
|
65
79
|
// 检查权限
|
|
66
80
|
const [weDaHasLogin, setWeDaHasLogin] = React.useState(false);
|
|
67
81
|
const context = React.useRef(observable({})).current;
|
|
82
|
+
const containerRef = React.useRef(null);
|
|
83
|
+
const microApp = React.useRef(null);
|
|
84
|
+
const pureSrc = '<%= pageSource %>';
|
|
85
|
+
const isPure = !!pureSrc;
|
|
68
86
|
|
|
69
87
|
/**
|
|
70
88
|
* 更新数据容器的上下文的方法
|
|
@@ -107,6 +125,11 @@ export default function App() {
|
|
|
107
125
|
app.utils.set($page.dataset.state, keyPath, userSetState[keyPath]);
|
|
108
126
|
});
|
|
109
127
|
};
|
|
128
|
+
return () => {
|
|
129
|
+
if (microApp.current) {
|
|
130
|
+
microApp.current.unmount();
|
|
131
|
+
}
|
|
132
|
+
};
|
|
110
133
|
}, []);
|
|
111
134
|
|
|
112
135
|
React.useEffect(() => {
|
|
@@ -123,23 +146,42 @@ export default function App() {
|
|
|
123
146
|
pageLifeCycleMount(React.useEffect, PageLifeCycle, app)
|
|
124
147
|
}
|
|
125
148
|
|
|
149
|
+
React.useEffect(() => {
|
|
150
|
+
if (isPure) {
|
|
151
|
+
if (weDaHasLogin) {
|
|
152
|
+
if (!microApp.current) {
|
|
153
|
+
microApp.current = loadMicroApp({
|
|
154
|
+
name: '<%= pageName %>',
|
|
155
|
+
entry: pureSrc,
|
|
156
|
+
container: containerRef.current,
|
|
157
|
+
});
|
|
158
|
+
} else {
|
|
159
|
+
microApp.current.mount?.();
|
|
160
|
+
}
|
|
161
|
+
} else if (microApp.current) {
|
|
162
|
+
microApp.current.unmount();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}, [weDaHasLogin]);
|
|
166
|
+
|
|
126
167
|
useScrollTop();
|
|
127
168
|
|
|
128
169
|
return (
|
|
129
|
-
<div className="weapps-page">
|
|
170
|
+
<div className="weapps-page" ref={containerRef}>
|
|
130
171
|
<style
|
|
131
172
|
type="text/css"
|
|
132
173
|
dangerouslySetInnerHTML={{
|
|
133
174
|
__html: `<%= pageStyleText %>`,
|
|
134
175
|
}}
|
|
135
176
|
/>
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
177
|
+
{weDaHasLogin && !isPure && (
|
|
178
|
+
<AppRender pageListenerInstances={pageListenerInstances}
|
|
179
|
+
virtualFields={virtualFields}
|
|
180
|
+
componentSchema={componentSchema}
|
|
181
|
+
context={context}
|
|
182
|
+
updateContext={updateContext}
|
|
183
|
+
/>
|
|
184
|
+
)}
|
|
143
185
|
</div>
|
|
144
186
|
);
|
|
145
187
|
}
|