@cloudbase/framework-plugin-low-code 0.6.31 → 0.6.34
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.js +2 -5
- package/lib/builder/core/copy.d.ts.map +1 -1
- package/lib/builder/mp/materials.d.ts.map +1 -1
- package/lib/builder/mp/materials.js +21 -5
- package/lib/generator/template.d.ts +1 -101
- package/lib/generator/template.d.ts.map +1 -1
- package/lib/generator/template.js +1 -101
- package/package.json +5 -3
- package/template/webpack/web.prod.js +66 -85
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/cookie.js +0 -286
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/history.js +0 -133
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/local-storage.js +0 -103
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/location.js +0 -588
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/miniprogram.js +0 -101
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/navigator.js +0 -80
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/performance.js +0 -28
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/screen.js +0 -31
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/session-storage.js +0 -96
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/xml-http-request.js +0 -290
- package/template/dist/mp/miniprogram_npm/miniprogram-render/document.js +0 -396
- package/template/dist/mp/miniprogram_npm/miniprogram-render/event/custom-event.js +0 -12
- package/template/dist/mp/miniprogram_npm/miniprogram-render/event/event-target.js +0 -389
- package/template/dist/mp/miniprogram_npm/miniprogram-render/event/event.js +0 -186
- package/template/dist/mp/miniprogram_npm/miniprogram-render/index.js +0 -41
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/attribute.js +0 -226
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/class-list.js +0 -153
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/comment.js +0 -80
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/a.js +0 -165
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/canvas.js +0 -138
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/image.js +0 -177
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/input.js +0 -181
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/not-support.js +0 -60
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/option.js +0 -126
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/select.js +0 -155
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/textarea.js +0 -178
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/video.js +0 -165
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/wx-component.js +0 -84
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/wx-custom-component.js +0 -64
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element.js +0 -970
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/node.js +0 -140
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/style-list.js +0 -28
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/style.js +0 -158
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/text-node.js +0 -127
- package/template/dist/mp/miniprogram_npm/miniprogram-render/tree/parser.js +0 -269
- package/template/dist/mp/miniprogram_npm/miniprogram-render/tree/query-selector.js +0 -420
- package/template/dist/mp/miniprogram_npm/miniprogram-render/tree/tree.js +0 -130
- package/template/dist/mp/miniprogram_npm/miniprogram-render/util/cache.js +0 -95
- package/template/dist/mp/miniprogram_npm/miniprogram-render/util/pool.js +0 -24
- package/template/dist/mp/miniprogram_npm/miniprogram-render/util/tool.js +0 -131
- package/template/dist/mp/miniprogram_npm/miniprogram-render/window.js +0 -651
- package/template/generator/app/common.js +0 -17
- package/template/generator/app/global-api.js +0 -163
- package/template/generator/app/handlers.js +0 -13
- package/template/generator/datasources/config.js.tpl +0 -21
- package/template/generator/datasources/dataset-profiles.js.tpl +0 -5
- package/template/generator/datasources/datasource-profiles.js.tpl +0 -4
- package/template/generator/datasources/index.js.tpl +0 -14
- package/template/generator/handlers/NodeRenderer.jsx +0 -471
- package/template/generator/handlers/RenderWrapper.jsx +0 -145
- package/template/generator/index.jsx +0 -116
- package/template/generator/index.less +0 -120
- package/template/generator/pages/app.tpl +0 -181
- package/template/generator/pages/composite.tpl +0 -267
- package/template/generator/router/index.tpl +0 -49
- package/template/generator/store/computed.js +0 -11
- package/template/generator/store/index.js +0 -5
- package/template/generator/utils/ScanCodeComponent.js +0 -345
- package/template/generator/utils/actionHandler.js +0 -119
- package/template/generator/utils/common.js +0 -225
- package/template/generator/utils/computed.js +0 -9
- package/template/generator/utils/date.js +0 -324
- package/template/generator/utils/error.jsx +0 -14
- package/template/generator/utils/eventProxy.js +0 -64
- package/template/generator/utils/history.js +0 -35
- package/template/generator/utils/hooks.js +0 -10
- package/template/generator/utils/index.js +0 -41
- package/template/generator/utils/initGlobalVar.js +0 -14
- package/template/generator/utils/lifecycle.js +0 -158
- package/template/generator/utils/monitor-jssdk.min.js +0 -881
- package/template/generator/utils/page.js +0 -10
- package/template/generator/utils/scan-code-action.js +0 -27
- package/template/generator/utils/style.js +0 -81
- package/template/generator/utils/widgets.js +0 -343
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useRef } from 'react';
|
|
3
|
-
import { CompRenderer } from './NodeRenderer';
|
|
4
|
-
import lodashSet from 'lodash.set';
|
|
5
|
-
import cloneDeep from 'lodash.clonedeep';
|
|
6
|
-
import { isScopeSlot } from '../utils/common';
|
|
7
|
-
|
|
8
|
-
function getComponentChildren(component) {
|
|
9
|
-
const { properties } = component;
|
|
10
|
-
if (!properties) {
|
|
11
|
-
return [];
|
|
12
|
-
}
|
|
13
|
-
return Object.values(properties).sort(
|
|
14
|
-
(a, b) => (a['x-index'] || 0) - (b['x-index'] || 0)
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function AppRender(props) {
|
|
19
|
-
const {
|
|
20
|
-
className,
|
|
21
|
-
virtualFields,
|
|
22
|
-
componentSchema,
|
|
23
|
-
renderSlot,
|
|
24
|
-
rootNode = true,
|
|
25
|
-
codeContext,
|
|
26
|
-
scopeContext = {},
|
|
27
|
-
context = {},
|
|
28
|
-
updateContext,
|
|
29
|
-
} = props;
|
|
30
|
-
const {
|
|
31
|
-
'x-props': xProps,
|
|
32
|
-
properties = {},
|
|
33
|
-
genericComp = {},
|
|
34
|
-
} = componentSchema;
|
|
35
|
-
// 判断是否为 slot
|
|
36
|
-
const isSlot = !xProps;
|
|
37
|
-
if (isSlot && !(renderSlot || rootNode)) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const preClassName = useRef();
|
|
42
|
-
|
|
43
|
-
// wrapperClass
|
|
44
|
-
const containerEl = Object.values(properties)[0];
|
|
45
|
-
if (containerEl && containerEl['x-props'] && className) {
|
|
46
|
-
let { classNameList = [] } = containerEl['x-props'];
|
|
47
|
-
|
|
48
|
-
// 先替换掉先前计算出来的className部分
|
|
49
|
-
if (preClassName.current) {
|
|
50
|
-
if (preClassName.current !== className) {
|
|
51
|
-
classNameList = classNameList.filter(
|
|
52
|
-
(clsName) => clsName !== preClassName.current
|
|
53
|
-
);
|
|
54
|
-
preClassName.current = className;
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
preClassName.current = className;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
containerEl['x-props'].classNameList = [className, ...classNameList];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (xProps && xProps.sourceKey) {
|
|
64
|
-
const { sourceKey } = xProps;
|
|
65
|
-
const Field = virtualFields[sourceKey];
|
|
66
|
-
if (!Field) {
|
|
67
|
-
return (
|
|
68
|
-
<div style={{ color: 'red' }}>
|
|
69
|
-
组件<em>{sourceKey}</em>未找到
|
|
70
|
-
</div>
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
const children = getComponentChildren(componentSchema);
|
|
75
|
-
const slots = {};
|
|
76
|
-
// eslint-disable-next-line guard-for-in
|
|
77
|
-
for (const key in properties) {
|
|
78
|
-
const child = properties[key];
|
|
79
|
-
if (!child['x-props'] && child.properties) {
|
|
80
|
-
slots[key] = isScopeSlot(componentSchema, key) ? (
|
|
81
|
-
(props) => {
|
|
82
|
-
let clonedScopeContext = cloneDeep(scopeContext);
|
|
83
|
-
lodashSet(
|
|
84
|
-
clonedScopeContext,
|
|
85
|
-
`${componentSchema.key}.${child.key}`,
|
|
86
|
-
props
|
|
87
|
-
);
|
|
88
|
-
return (
|
|
89
|
-
<AppRender
|
|
90
|
-
key={child.key}
|
|
91
|
-
componentSchema={child}
|
|
92
|
-
renderSlot
|
|
93
|
-
virtualFields={virtualFields}
|
|
94
|
-
codeContext={codeContext}
|
|
95
|
-
scopeContext={clonedScopeContext}
|
|
96
|
-
context={context}
|
|
97
|
-
updateContext={updateContext}
|
|
98
|
-
/>
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
) : (
|
|
102
|
-
<AppRender
|
|
103
|
-
key={child.key}
|
|
104
|
-
componentSchema={child}
|
|
105
|
-
renderSlot
|
|
106
|
-
virtualFields={virtualFields}
|
|
107
|
-
codeContext={codeContext}
|
|
108
|
-
scopeContext={scopeContext}
|
|
109
|
-
context={context}
|
|
110
|
-
updateContext={updateContext}
|
|
111
|
-
/>
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return (
|
|
117
|
-
<CompRenderer
|
|
118
|
-
id={componentSchema.key}
|
|
119
|
-
xProps={xProps}
|
|
120
|
-
emitEvents={componentSchema.emitEvents || []}
|
|
121
|
-
componentSchema={componentSchema}
|
|
122
|
-
virtualFields={virtualFields}
|
|
123
|
-
slots={slots}
|
|
124
|
-
codeContext={codeContext}
|
|
125
|
-
scopeContext={scopeContext}
|
|
126
|
-
genericComp={genericComp}
|
|
127
|
-
context={context}
|
|
128
|
-
updateContext={updateContext}
|
|
129
|
-
>
|
|
130
|
-
{children.map((comp) => (
|
|
131
|
-
<AppRender
|
|
132
|
-
key={comp.key}
|
|
133
|
-
componentSchema={comp}
|
|
134
|
-
rootNode={false}
|
|
135
|
-
renderSlot={false}
|
|
136
|
-
virtualFields={virtualFields}
|
|
137
|
-
codeContext={codeContext}
|
|
138
|
-
scopeContext={scopeContext}
|
|
139
|
-
context={context}
|
|
140
|
-
updateContext={updateContext}
|
|
141
|
-
/>
|
|
142
|
-
))}
|
|
143
|
-
</CompRenderer>
|
|
144
|
-
);
|
|
145
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
import * as ReactDOM from 'react-dom'
|
|
3
|
-
import { setConfig } from '@cloudbase/weda-cloud-sdk/dist/h5'
|
|
4
|
-
import App from './router'
|
|
5
|
-
<% if(!isSandbox){ %>
|
|
6
|
-
import './utils/monitor-jssdk.min'
|
|
7
|
-
<% } %>
|
|
8
|
-
import './lowcode/style.css'
|
|
9
|
-
// 引入数据源管理器并进行初始化
|
|
10
|
-
import './datasources'
|
|
11
|
-
import './utils/initGlobalVar'
|
|
12
|
-
// import i18nData from './i18n/index.js'
|
|
13
|
-
import { initAppLifeCycle } from './utils/lifecycle'
|
|
14
|
-
<% subAppDataList.forEach(subApp => { %>
|
|
15
|
-
import './packages/<%= subApp.rootPath %>/lowcode/style.css'
|
|
16
|
-
<% }) %>
|
|
17
|
-
|
|
18
|
-
<% if(!isSandbox){ %>
|
|
19
|
-
import attachFastClick from 'fastclick'
|
|
20
|
-
attachFastClick && attachFastClick.attach && attachFastClick.attach(document.body)
|
|
21
|
-
<% } %>
|
|
22
|
-
import { app } from './app/global-api'
|
|
23
|
-
import { createStateDataSourceVar, generateParamsParser, EXTRA_API } from './datasources'
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// 初始化应用生命周期
|
|
27
|
-
initAppLifeCycle(app,{
|
|
28
|
-
beforeCustomLaunch: (query)=>{
|
|
29
|
-
EXTRA_API.setParams('$global', query || {})
|
|
30
|
-
createStateDataSourceVar('$global',generateParamsParser({app}))
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
<% if(!isSandbox && isBuildApp){ %>
|
|
35
|
-
// app 中注册配置页面以及app的全局配置miniprogram.config,h5里分app以及web页分别处理,使用process.env.isApp 区分判断
|
|
36
|
-
import { initWebConfig } from './utils/lifecycle'
|
|
37
|
-
import AppConfig from '../webpack/miniprogram.config'
|
|
38
|
-
initWebConfig(app, AppConfig);
|
|
39
|
-
<% } %>
|
|
40
|
-
// 设置数据源请求的 loading 及 toast 处理
|
|
41
|
-
setConfig({
|
|
42
|
-
beforeDSRequest: (cfg) => {
|
|
43
|
-
if (!cfg.options || !cfg.options.showLoading) return
|
|
44
|
-
app.showLoading()
|
|
45
|
-
},
|
|
46
|
-
afterDSRequest: (cfg, error, result) => {
|
|
47
|
-
if (!cfg.options) return
|
|
48
|
-
if (cfg.options.showLoading) app.hideLoading()
|
|
49
|
-
if (!cfg.options.showToast) return
|
|
50
|
-
const isSuccess = !error && result && !result.code
|
|
51
|
-
app.showToast({icon: isSuccess ? 'success' : 'error'})
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
<% if(!isSandbox){ %>
|
|
57
|
-
if (yyptReport && typeof yyptReport.pgvMain == 'function') {
|
|
58
|
-
// report_url,appKey必填
|
|
59
|
-
yyptReport.pgvMain({
|
|
60
|
-
appKey: '<%= yyptAppKey %>', // 填入你申请的运营平台的应用key(必填)
|
|
61
|
-
report_url: '<%= reportUrl %><%= yyptAppKey %>', // 上报url(把后端上报接口需要先挂网关,该url填写网关地址)
|
|
62
|
-
autoReportPv: true, // 单页应用监听页面路径改变自动上报Pv,默认为false
|
|
63
|
-
stopReport: <%= stopReport %>, // 停止上报
|
|
64
|
-
// 其他参数说明
|
|
65
|
-
// customUserPrams: null, // 用户自定义的额外属性--对于小马的用户属性,比如用户的部门编码(customUserPrams: { deptno: 1100 })需要在小马系统事先配置好
|
|
66
|
-
//userKey: "user_id", // cookie里面用户的唯一标示
|
|
67
|
-
//autoWatchClick: true, // 默认开启自动监听hottag
|
|
68
|
-
//isWxEnv: false// 是否微信环境,微信环境会通过wx.getNetworkType获取网络环境
|
|
69
|
-
// 通过传入函数,可以让业务方写代码传入要上报的属性,比如返回自定义属性,这里主要也是自定义属性,让sdk获取并且进行上报,减少重复编码
|
|
70
|
-
//getCusParams: function () {
|
|
71
|
-
// return {kv:{money:1}}; //kv:Key-Value,自定义事件Key-Value参数对 map JSON格式,在报表页面的事件参数分析页和页面参数分析页中可以看到上报的kv值
|
|
72
|
-
//},
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
<% } %>
|
|
76
|
-
|
|
77
|
-
;(function() {
|
|
78
|
-
function flex() {
|
|
79
|
-
try {
|
|
80
|
-
let htmlDom = document.documentElement
|
|
81
|
-
let width = window.innerWidth || htmlDom.clientWidth
|
|
82
|
-
let fontSize = width / (375 / 14)
|
|
83
|
-
if (
|
|
84
|
-
!navigator.userAgent.match(
|
|
85
|
-
/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|IEMobile)/i
|
|
86
|
-
) &&
|
|
87
|
-
fontSize > 14
|
|
88
|
-
) {
|
|
89
|
-
htmlDom.style.fontSize = `14px`
|
|
90
|
-
} else {
|
|
91
|
-
htmlDom.style.fontSize = fontSize + `px`
|
|
92
|
-
}
|
|
93
|
-
} catch (e) {
|
|
94
|
-
console.error(e)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
flex()
|
|
99
|
-
window.addEventListener('resize', flex)
|
|
100
|
-
})()
|
|
101
|
-
ReactDOM.render(<App/>, document.getElementById('root'))
|
|
102
|
-
|
|
103
|
-
<% if(!isSandbox){ %>
|
|
104
|
-
// 使用HMR
|
|
105
|
-
if(process.env.compileTool === 'vite') {
|
|
106
|
-
if (import.meta.hot) {
|
|
107
|
-
import.meta.hot.accept()
|
|
108
|
-
}
|
|
109
|
-
} else {
|
|
110
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
111
|
-
if (module.hot) {
|
|
112
|
-
module.hot.accept()
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
<% } %>
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
// 针对小程序样式做适配
|
|
2
|
-
// 请注意与weapps/src/pages/editor/components/Main/EditAndPreview/index.iframe.scss的一致性,以确保小程序端样式与
|
|
3
|
-
|
|
4
|
-
body {
|
|
5
|
-
margin: 0;
|
|
6
|
-
padding: 0;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
#weapp-scancode-video {
|
|
10
|
-
width: 100%;
|
|
11
|
-
height: 100%;
|
|
12
|
-
object-fit: cover;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.weapp-scancode {
|
|
16
|
-
&-close-button {
|
|
17
|
-
background: white;
|
|
18
|
-
color: black;
|
|
19
|
-
display: flex;
|
|
20
|
-
position: absolute;
|
|
21
|
-
top: 14px;
|
|
22
|
-
left: 14px;
|
|
23
|
-
width: 24px;
|
|
24
|
-
height: 24px;
|
|
25
|
-
border-radius: 50%;
|
|
26
|
-
cursor: pointer;
|
|
27
|
-
justify-content: center;
|
|
28
|
-
align-items: center;
|
|
29
|
-
z-index: 500;
|
|
30
|
-
}
|
|
31
|
-
&-modal {
|
|
32
|
-
position: fixed;
|
|
33
|
-
background-color: black;
|
|
34
|
-
left: 0px;
|
|
35
|
-
right: 0px;
|
|
36
|
-
top: 0px;
|
|
37
|
-
bottom: 0px;
|
|
38
|
-
&-main {
|
|
39
|
-
height: 100%;
|
|
40
|
-
position: relative;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
&-scan {
|
|
44
|
-
&-wrapper {
|
|
45
|
-
display: flex;
|
|
46
|
-
flex-direction: column;
|
|
47
|
-
justify-content: center;
|
|
48
|
-
align-items: center;
|
|
49
|
-
height: 100%;
|
|
50
|
-
width: 100%;
|
|
51
|
-
position: absolute;
|
|
52
|
-
top: 0;
|
|
53
|
-
left: 0;
|
|
54
|
-
}
|
|
55
|
-
&-square {
|
|
56
|
-
--square-size: 16rem;
|
|
57
|
-
width: var(--square-size);
|
|
58
|
-
height: var(--square-size);
|
|
59
|
-
position: relative;
|
|
60
|
-
}
|
|
61
|
-
&-bar {
|
|
62
|
-
position: absolute;
|
|
63
|
-
height: 10px;
|
|
64
|
-
width: 100%;
|
|
65
|
-
background: linear-gradient(90deg, transparent, #07c160 50%, transparent);
|
|
66
|
-
top: 0%;
|
|
67
|
-
border-top-left-radius: 50%;
|
|
68
|
-
border-top-right-radius: 50%;
|
|
69
|
-
animation: slideinout-top-down 2s;
|
|
70
|
-
animation-direction: normal;
|
|
71
|
-
animation-timing-function: linear;
|
|
72
|
-
animation-iteration-count: infinite;
|
|
73
|
-
}
|
|
74
|
-
&-tip {
|
|
75
|
-
margin-top: 10rem;
|
|
76
|
-
color: white;
|
|
77
|
-
}
|
|
78
|
-
&-not-found {
|
|
79
|
-
color: white;
|
|
80
|
-
}
|
|
81
|
-
&-not-found + p {
|
|
82
|
-
color: #999;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
&-img-selector {
|
|
87
|
-
position: absolute;
|
|
88
|
-
bottom: 32px;
|
|
89
|
-
right: 32px;
|
|
90
|
-
z-index: 500;
|
|
91
|
-
}
|
|
92
|
-
&-img-picker {
|
|
93
|
-
z-index: 500;
|
|
94
|
-
padding: 5px;
|
|
95
|
-
display: block;
|
|
96
|
-
cursor: pointer;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
@keyframes slideinout-top-down {
|
|
101
|
-
// use transform to prevent relayout
|
|
102
|
-
0% {
|
|
103
|
-
transform: translateY(0px);
|
|
104
|
-
opacity: 0;
|
|
105
|
-
}
|
|
106
|
-
50% {
|
|
107
|
-
transform: translateY(calc(var(--square-size) / 2));
|
|
108
|
-
opacity: 0.5;
|
|
109
|
-
}
|
|
110
|
-
100% {
|
|
111
|
-
transform: translateY(var(--square-size));
|
|
112
|
-
opacity: 0;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
@media (min-width: 1024px) {
|
|
117
|
-
.weda-responsive_flex_flow {
|
|
118
|
-
flex-flow: row !important;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
// Import Libs and Handlers
|
|
2
|
-
import * as React from 'react'
|
|
3
|
-
import { observable, autorun, reaction } from 'mobx'
|
|
4
|
-
import { observer } from "mobx-react-lite";
|
|
5
|
-
import get from 'lodash.get'
|
|
6
|
-
import { app } from '../../app/global-api' // 取对应子包app
|
|
7
|
-
import '../../utils/initGlobalVar'
|
|
8
|
-
import { AppRender } from '/src/handlers/RenderWrapper'
|
|
9
|
-
import { createDataset, createStateDataSourceVar, generateParamsParser, EXTRA_API } from '../../datasources'
|
|
10
|
-
import { createComputed, createWidgets, retryDataBinds, bindFuncObj, resolveComponentProps } from '/src/utils/index'
|
|
11
|
-
import { pageLifeCycleMount } from '/src/utils/lifecycle'
|
|
12
|
-
import { useScrollTop } from '/src/utils/hooks'
|
|
13
|
-
import PageLifeCycle from '../../lowcode/<%= pageName %>/lifecycle'
|
|
14
|
-
import initPageState from '../../lowcode/<%= pageName %>/state'
|
|
15
|
-
import computed from '../../lowcode/<%= pageName %>/computed'
|
|
16
|
-
import pageAPI from '../../lowcode/<%= pageName %>/index';
|
|
17
|
-
import { $$_<%= pageName %> as handler } from '../../app/handlers'
|
|
18
|
-
import { createPageApi } from '/src/app/global-api' // 取主包app
|
|
19
|
-
|
|
20
|
-
import '../../lowcode/<%= pageName %>/style.css'
|
|
21
|
-
|
|
22
|
-
// Import Components
|
|
23
|
-
<% useComponents.forEach(compItem => {%>
|
|
24
|
-
<% if(isSandbox) { %>
|
|
25
|
-
const <%= upperFirst(compItem.variableName) %> = window["@weapps-materials-main-<%= compItem.materialName %>"].components["<%= compItem.name %>"];
|
|
26
|
-
<% } else if(!isSandbox) { %>
|
|
27
|
-
import <%= upperFirst(compItem.variableName) %> from "/src/libraries/<%= compItem.materialName %>@<%= compItem.materialVersion %>/components/<%= compItem.name %>";
|
|
28
|
-
<% }}) %>
|
|
29
|
-
|
|
30
|
-
// Import Actions
|
|
31
|
-
<% useActions.forEach(action => {%>
|
|
32
|
-
<% if(isSandbox) { %>
|
|
33
|
-
const <%= action.variableName %> = window["@weapps-materials-main-<%= action.materialName %>"].actions["<%= action.name %>"];
|
|
34
|
-
<% } else { %>
|
|
35
|
-
import <%= action.variableName %> from "/src/libraries/<%= action.materialName %>@<%= action.materialVersion %>/actions/<%= action.name %>";
|
|
36
|
-
<% }}) %>
|
|
37
|
-
|
|
38
|
-
const virtualFields = {
|
|
39
|
-
<% useComponents.forEach(compItem => {%>
|
|
40
|
-
<% if(compItem.isPlainProps) { %>
|
|
41
|
-
'<%= compItem.materialName %>:<%= compItem.name %>': (props) => <<%= upperFirst(compItem.variableName) %> {...resolveComponentProps(props, 1)} pageVirtualFields={virtualFields}/>,
|
|
42
|
-
<% } else { %>
|
|
43
|
-
'<%= compItem.materialName %>:<%= compItem.name %>': (props) => <<%= upperFirst(compItem.variableName) %> {...resolveComponentProps(props, 0)} pageVirtualFields={virtualFields}/>,
|
|
44
|
-
<% }}) %>
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// Init
|
|
48
|
-
export default function App() {
|
|
49
|
-
// 检查权限
|
|
50
|
-
// const [weDaHasLogin, setWeDaHasLogin] = React.useState(false);
|
|
51
|
-
const [context, setContext] = React.useState({});
|
|
52
|
-
// 兼容 this.state / $page.state 两种模式
|
|
53
|
-
const pageCodeContext = createPageApi()
|
|
54
|
-
const $page = pageCodeContext
|
|
55
|
-
Object.defineProperty(pageCodeContext, '$page', {
|
|
56
|
-
get() {
|
|
57
|
-
return pageCodeContext
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
const widgetsContext = <%= widgets %>;
|
|
62
|
-
const dataBinds = $page._dataBinds = <%= dataBinds %>;
|
|
63
|
-
const componentSchema = <%= componentSchema %>;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* 更新数据容器的上下文的方法
|
|
67
|
-
* 会传递到事件emit的地方,将从组件获取到的数据data赋值给上下文
|
|
68
|
-
* 当组件卸载时,传过来的data为undefined即可
|
|
69
|
-
* {
|
|
70
|
-
* id1: [{...}],
|
|
71
|
-
* id2: {...},
|
|
72
|
-
* id3: undefined,
|
|
73
|
-
* id4: null,
|
|
74
|
-
* ...
|
|
75
|
-
* }
|
|
76
|
-
* @param id
|
|
77
|
-
* @param data
|
|
78
|
-
*/
|
|
79
|
-
const updateContext = (id, data) => {
|
|
80
|
-
if(id) {
|
|
81
|
-
context[id] = { data };
|
|
82
|
-
}
|
|
83
|
-
setContext({ ...context });
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
Object.assign($page, {
|
|
87
|
-
id:'<%= pageName %>',
|
|
88
|
-
state: observable(initPageState),
|
|
89
|
-
computed: createComputed(computed, pageCodeContext),
|
|
90
|
-
handler: bindFuncObj(handler, pageCodeContext)
|
|
91
|
-
})
|
|
92
|
-
let dataset = createDataset('<%= pageName %>', {app, $page: pageCodeContext})
|
|
93
|
-
$page.dataset = dataset
|
|
94
|
-
$page.state.dataset = dataset
|
|
95
|
-
$page.setState = (userSetState) => {
|
|
96
|
-
Object.keys(userSetState).forEach((keyPath) => {
|
|
97
|
-
app.utils.set($page.dataset.state, keyPath, userSetState[keyPath]);
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
$page.widgets = createWidgets(widgetsContext, dataBinds, context)
|
|
102
|
-
// widgets 内的 dataBinds 可能需要关联 widgets,需要重新执行 dataBinds
|
|
103
|
-
retryDataBinds()
|
|
104
|
-
|
|
105
|
-
// Web 环境页面级别生命周期
|
|
106
|
-
React.useEffect(() => {
|
|
107
|
-
document.title = "<%= title %>";
|
|
108
|
-
initWatchMethods(pageCodeContext)
|
|
109
|
-
/*checkAuth(app, app.id, '<%= pageName %>').then((checkAuthResult) =>
|
|
110
|
-
setWeDaHasLogin(checkAuthResult)
|
|
111
|
-
);*/
|
|
112
|
-
}, [])
|
|
113
|
-
|
|
114
|
-
pageLifeCycleMount(
|
|
115
|
-
React.useEffect,
|
|
116
|
-
{
|
|
117
|
-
...PageLifeCycle,
|
|
118
|
-
beforePageCustomLaunch: (query) => {
|
|
119
|
-
EXTRA_API.setParams('<%= pageName %>', query || {})
|
|
120
|
-
createStateDataSourceVar('<%= pageName %>', generateParamsParser({ app, $page: pageCodeContext }))
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
app,
|
|
124
|
-
pageCodeContext
|
|
125
|
-
)
|
|
126
|
-
// 切换页面滚动到顶部
|
|
127
|
-
useScrollTop()
|
|
128
|
-
return (
|
|
129
|
-
<div className="weapps-page weapps-page-<%= pageClass %>">
|
|
130
|
-
<style
|
|
131
|
-
type="text/css"
|
|
132
|
-
dangerouslySetInnerHTML={{
|
|
133
|
-
__html: `<%= pageStyleText %>`,
|
|
134
|
-
}}
|
|
135
|
-
/>
|
|
136
|
-
<AppRender
|
|
137
|
-
virtualFields={virtualFields}
|
|
138
|
-
componentSchema={componentSchema}
|
|
139
|
-
codeContext={pageCodeContext}
|
|
140
|
-
context={context}
|
|
141
|
-
updateContext={updateContext}
|
|
142
|
-
/>
|
|
143
|
-
</div>
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
function initWatchMethods(pageContext) {
|
|
147
|
-
const { watch = {}, watchState = {}, watchWidget = {}, watchEffects = {}} = pageAPI
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
// # watch effect
|
|
151
|
-
const watchEffectDisposers = Object.keys(watchEffects).map(fnName => {
|
|
152
|
-
return autorun(watchEffects[fnName].bind(pageContext))
|
|
153
|
-
})
|
|
154
|
-
const disposers = watchEffectDisposers
|
|
155
|
-
|
|
156
|
-
// # watch state
|
|
157
|
-
Object.keys(watchState).map(key => runWatcher(parseWatcher(watchState[key]), pageContext.state, key, 'watchState'))
|
|
158
|
-
|
|
159
|
-
// # watch widgets
|
|
160
|
-
Object.keys(watchWidget).map(key => runWatcher(parseWatcher(watchWidget[key]), pageContext.widgets, key, 'watchWidgets'))
|
|
161
|
-
|
|
162
|
-
function runWatcher({ handler, immediate } = {}, target, key, label) {
|
|
163
|
-
if (!handler) {
|
|
164
|
-
console.error(`Invalid ${label}(${key}) of ${pageContext.node.widgetType}, watch must a function or {handler: function}`)
|
|
165
|
-
return
|
|
166
|
-
}
|
|
167
|
-
const disposer = reaction(() => get(target, key), handler.bind(pageContext), { fireImmediately: immediate })
|
|
168
|
-
disposers.push(disposer)
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function parseWatcher(watcher) {
|
|
174
|
-
if (!watcher) return
|
|
175
|
-
if (watcher instanceof Function) {
|
|
176
|
-
return { handler: watcher, immediate: false }
|
|
177
|
-
}
|
|
178
|
-
const { handler, immediate = false } = watcher
|
|
179
|
-
if (!(handler instanceof Function)) return
|
|
180
|
-
return { handler, immediate }
|
|
181
|
-
}
|