@cloudbase/framework-plugin-low-code 1.0.3-beta.9 → 1.0.5
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/lowcode.d.ts.map +1 -1
- package/lib/builder/mp/lowcode.js +3 -7
- package/lib/builder/service/builder/generate.d.ts.map +1 -1
- package/lib/builder/service/builder/generate.js +3 -0
- package/lib/generator/core/generate.d.ts.map +1 -1
- package/lib/generator/core/generate.js +11 -17
- package/lib/utils/dataSource.d.ts +4 -0
- package/lib/utils/dataSource.d.ts.map +1 -1
- package/lib/utils/dataSource.js +27 -12
- package/lib/weapps-core/utils/file.d.ts +1 -1
- package/package.json +3 -3
- package/template/src/app/common.js +0 -13
- package/template/src/app/global-api.js +0 -132
- 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 -27
- 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.tpl +0 -27
- package/template/src/handlers/FieldMiddleware/renderer.jsx +0 -536
- package/template/src/handlers/HotAreas.js +0 -36
- package/template/src/handlers/PositionHandler.jsx +0 -8
- package/template/src/handlers/actionHandler/utils.js +0 -154
- 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 -15
- 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 -222
- package/template/src/handlers/render.jsx +0 -170
- package/template/src/handlers/utils/common.js +0 -298
- 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 -307
- package/template/src/index.jsx +0 -185
- 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 -200
- package/template/src/pages/composite.tpl +0 -171
- package/template/src/router/index.tpl +0 -29
- package/template/src/store/computed.js +0 -11
- package/template/src/store/index.js +0 -40
- package/template/src/utils/formatEnum.js +0 -42
- package/template/src/utils/history.js +0 -66
- package/template/src/utils/index.js +0 -82
- 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
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { observable, autorun, untracked } from 'mobx';
|
|
3
|
-
import { remove } from 'lodash';
|
|
4
|
-
import { checkVisible } from '../../utils/index';
|
|
5
|
-
|
|
6
|
-
export const WidgetsContext = React.createContext({ parent: null });
|
|
7
|
-
|
|
8
|
-
export function isSlot(comp) {
|
|
9
|
-
return !comp['x-props'];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// 实现和小程序一致的 API,以兼容多端
|
|
13
|
-
// widget.getDom({ rect: true })
|
|
14
|
-
// https://developers.weixin.qq.com/miniprogram/dev/api/wxml/NodesRef.fields.html
|
|
15
|
-
export function getDom(element, options) {
|
|
16
|
-
if (!element) {
|
|
17
|
-
console.warn('getDom 接口未传入有效的 element');
|
|
18
|
-
return Promise.resolve({});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
let result = {};
|
|
22
|
-
if (options.id) result.id = element.id;
|
|
23
|
-
if (options.dataset) result.dataset = element.dataset;
|
|
24
|
-
if (options.rect) {
|
|
25
|
-
const rect = element.getBoundingClientRect();
|
|
26
|
-
Object.assign(result, {
|
|
27
|
-
left: rect.left,
|
|
28
|
-
right: rect.right,
|
|
29
|
-
top: rect.top,
|
|
30
|
-
bottom: rect.bottom,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
if (options.size) {
|
|
34
|
-
const rect = element.getBoundingClientRect();
|
|
35
|
-
Object.assign(result, {
|
|
36
|
-
width: rect.width,
|
|
37
|
-
height: rect.height,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
if (options.scrollOffset) {
|
|
41
|
-
Object.assign(result, {
|
|
42
|
-
scrollLeft: element.scrollLeft,
|
|
43
|
-
scrollTop: element.scrollTop,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
if (options.properties && Array.isArray(options.properties)) {
|
|
47
|
-
options.properties.forEach((propName) => {
|
|
48
|
-
result[propName] = element.getAttribute(propName);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
if (options.computedStyle && Array.isArray(options.computedStyle)) {
|
|
52
|
-
const computedStyle = window.getComputedStyle(element);
|
|
53
|
-
options.computedStyle.forEach((propName) => {
|
|
54
|
-
result[propName] = computedStyle[propName];
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return Promise.resolve(result);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function findWidgets(widget, parentType, filterFn, includeInvisibleDescendants) {
|
|
62
|
-
if (!widget) return [];
|
|
63
|
-
|
|
64
|
-
let { children = [] } = widget;
|
|
65
|
-
let matched = children.filter(filterFn);
|
|
66
|
-
if (!includeInvisibleDescendants) {
|
|
67
|
-
children = children.filter((item) => checkVisible(item));
|
|
68
|
-
matched = matched.filter((item) => checkVisible(item));
|
|
69
|
-
}
|
|
70
|
-
children.forEach((child) => {
|
|
71
|
-
// 如果递归过程中发现了自己,则停止递归
|
|
72
|
-
if (child.widgetType === parentType) return;
|
|
73
|
-
matched = matched.concat(findWidgets(child, parentType, filterFn));
|
|
74
|
-
});
|
|
75
|
-
return matched;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const retryQueue = [];
|
|
79
|
-
// 递归执行
|
|
80
|
-
export function retryDataBinds(tryTime = 10) {
|
|
81
|
-
const fn = retryQueue.shift();
|
|
82
|
-
if (!fn || tryTime <= 0) return;
|
|
83
|
-
try {
|
|
84
|
-
fn({ showLog: tryTime <= 1 });
|
|
85
|
-
} catch (e) {
|
|
86
|
-
console.error('retryDataBinds', e);
|
|
87
|
-
}
|
|
88
|
-
setTimeout(() => {
|
|
89
|
-
retryDataBinds(tryTime - 1);
|
|
90
|
-
}, 0);
|
|
91
|
-
}
|
|
92
|
-
export function createWidgets(widgetProps, dataBinds, scopeContext = {}, context = {}) {
|
|
93
|
-
const nodeTree = createWidgetTree(widgetProps, dataBinds);
|
|
94
|
-
const widgets = runFor(nodeTree, {}, null, null, scopeContext, context);
|
|
95
|
-
return widgets;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
*
|
|
99
|
-
* @param {*} curForNode
|
|
100
|
-
* @param {*} forItems
|
|
101
|
-
* @param {*} parentLevelWidgets
|
|
102
|
-
* @param {*} parentWidget
|
|
103
|
-
* @param {*} scopeContext
|
|
104
|
-
* @param {*} context
|
|
105
|
-
* @returns top level widgets or for dispose
|
|
106
|
-
*/
|
|
107
|
-
function runFor(curForNode, forItems, parentLevelWidgets, parentWidget, scopeContext, context) {
|
|
108
|
-
const nodeId = curForNode.id;
|
|
109
|
-
if (!curForNode.value) {
|
|
110
|
-
return createSubTree(curForNode, {}, scopeContext, context);
|
|
111
|
-
}
|
|
112
|
-
const dispose = autorun(() => {
|
|
113
|
-
let forList = [];
|
|
114
|
-
try {
|
|
115
|
-
forList = dataBinds[nodeId]._waFor(forItems, undefined, context);
|
|
116
|
-
} catch (e) {
|
|
117
|
-
console.warn('waFor error', e);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (!Array.isArray(forList)) {
|
|
121
|
-
forList = [];
|
|
122
|
-
console.warn(nodeId, 'For 循环绑定的数据并不是数组,请检查');
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// 让 forList 进行监听
|
|
126
|
-
forList.forEach(() => {});
|
|
127
|
-
untracked(() => {
|
|
128
|
-
disposeWidgets(parentLevelWidgets[curForNode.id]);
|
|
129
|
-
|
|
130
|
-
// clean nodes of previouse for run
|
|
131
|
-
dfsTree(curForNode, (node) => {
|
|
132
|
-
const arr = parentLevelWidgets[node.id];
|
|
133
|
-
arr.splice(0, arr.length);
|
|
134
|
-
parentWidget && remove(parentWidget.children, ({ id }) => id === node.id);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
forList.forEach((item, index) => {
|
|
138
|
-
const subForItems = { ...forItems, [nodeId]: item };
|
|
139
|
-
createSubTree(curForNode, subForItems, scopeContext, context);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
// 非初始化时遇到需要重新构建 dataBinds
|
|
143
|
-
retryDataBinds();
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
return dispose;
|
|
148
|
-
|
|
149
|
-
function createSubTree(curForNode, subForItems, scopeContext, context) {
|
|
150
|
-
const widgets = {};
|
|
151
|
-
|
|
152
|
-
// traverse down the tree to set all widgets
|
|
153
|
-
dfsTree(curForNode, (node, parentNode) => {
|
|
154
|
-
if (node.forCount === curForNode.forCount) {
|
|
155
|
-
// Leaf node
|
|
156
|
-
const w = observable(widgetProps[node.id]);
|
|
157
|
-
w.id = node.id;
|
|
158
|
-
if (node === curForNode) {
|
|
159
|
-
w._disposers = [];
|
|
160
|
-
}
|
|
161
|
-
widgets[node.id] = w;
|
|
162
|
-
w.findWidgets = (type, includeInvisibleDescendants) =>
|
|
163
|
-
findWidgets(w, w.widgetType, type, includeInvisibleDescendants);
|
|
164
|
-
w.getWidgetsByType = (type, includeInvisibleDescendants) =>
|
|
165
|
-
w.findWidgets((currentWidget) => currentWidget.widgetType === type, includeInvisibleDescendants);
|
|
166
|
-
w.getOwnerWidget = () => null; // 寻找父widget,默认返回null, 后续会覆写
|
|
167
|
-
w._getInstanceRef = () => null; // 默认初始值
|
|
168
|
-
Object.defineProperty(w, '_methods', {
|
|
169
|
-
get() {
|
|
170
|
-
const instance = this._getInstanceRef();
|
|
171
|
-
return instance?.current?.methods;
|
|
172
|
-
},
|
|
173
|
-
});
|
|
174
|
-
// 提供一个给 Node 挂载 API 的方式
|
|
175
|
-
untracked(() => {
|
|
176
|
-
w.extends = (name, fnOrData) =>
|
|
177
|
-
Object.defineProperty(w, name, {
|
|
178
|
-
value: fnOrData,
|
|
179
|
-
writable: true,
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
w.children = [];
|
|
183
|
-
const parent = parentNode ? widgets[parentNode.id] : parentWidget;
|
|
184
|
-
if (parent) {
|
|
185
|
-
w.parent = parent;
|
|
186
|
-
// 只有可显示 visible 的才存入 children 里
|
|
187
|
-
if (checkVisible(w)) {
|
|
188
|
-
parent.children.push(w);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
parentLevelWidgets && parentLevelWidgets[node.id].push(w);
|
|
192
|
-
|
|
193
|
-
// Setup data binds
|
|
194
|
-
Object.keys(dataBinds[node.id] || {}).map((prop) => {
|
|
195
|
-
if (prop === '_waFor') {
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
function getBindData(options = {}) {
|
|
199
|
-
let disposeError = false;
|
|
200
|
-
const dispose = autorun(() => {
|
|
201
|
-
try {
|
|
202
|
-
// Computed data bind in the next tick since data bind may read widgets data
|
|
203
|
-
w[prop] = dataBinds[node.id][prop](subForItems, undefined, context, scopeContext);
|
|
204
|
-
disposeError = false;
|
|
205
|
-
} catch (e) {
|
|
206
|
-
options.showLog && console.error(e);
|
|
207
|
-
retryQueue.push(getBindData);
|
|
208
|
-
disposeError = true;
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
if (!!disposeError && curForNode.id) {
|
|
212
|
-
widgets[curForNode.id]._disposers.push(dispose);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
getBindData();
|
|
216
|
-
});
|
|
217
|
-
} else {
|
|
218
|
-
if (parentLevelWidgets) {
|
|
219
|
-
const len = parentLevelWidgets[node.id].push([]);
|
|
220
|
-
widgets[node.id] = parentLevelWidgets[node.id][len - 1];
|
|
221
|
-
} else {
|
|
222
|
-
widgets[node.id] = observable([]);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
// run for of next level
|
|
228
|
-
dfsTree(curForNode, (node, parentNode) => {
|
|
229
|
-
if (node.forCount === curForNode.forCount + 1 && dataBinds[node.id]?._waFor) {
|
|
230
|
-
widgets[node.id]._disposers = { dataBinds: [] };
|
|
231
|
-
const dispose = runFor(
|
|
232
|
-
node,
|
|
233
|
-
subForItems,
|
|
234
|
-
widgets,
|
|
235
|
-
node.parent && widgets[node.parent.id],
|
|
236
|
-
scopeContext,
|
|
237
|
-
context,
|
|
238
|
-
);
|
|
239
|
-
curForNode.id && widgets[curForNode.id]._disposers.push(dispose);
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
return widgets;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Add parent, children to widget
|
|
250
|
-
*/
|
|
251
|
-
function createWidgetTree(widgets, dataBinds) {
|
|
252
|
-
const virtualRoot = { children: [], forCount: 0 };
|
|
253
|
-
const nodes = Object.keys(widgets).reduce((result, id) => {
|
|
254
|
-
result[id] = {
|
|
255
|
-
id,
|
|
256
|
-
value: widgets[id],
|
|
257
|
-
children: [],
|
|
258
|
-
parent: null,
|
|
259
|
-
forCount: 0,
|
|
260
|
-
};
|
|
261
|
-
return result;
|
|
262
|
-
}, {});
|
|
263
|
-
|
|
264
|
-
// Create widgets tree API
|
|
265
|
-
Object.keys(nodes).map((id) => {
|
|
266
|
-
const curNode = nodes[id];
|
|
267
|
-
const parent = nodes[widgets[id]._parentId];
|
|
268
|
-
if (!parent) {
|
|
269
|
-
virtualRoot.children.push(curNode);
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
curNode.parent = parent;
|
|
273
|
-
parent.children.push(curNode);
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
virtualRoot.children.map(addForCount);
|
|
277
|
-
|
|
278
|
-
// dfs, add forCount
|
|
279
|
-
function addForCount(node) {
|
|
280
|
-
if (node.parent) {
|
|
281
|
-
node.forCount = node.parent.forCount;
|
|
282
|
-
}
|
|
283
|
-
if (dataBinds[node.id] && dataBinds[node.id]._waFor) {
|
|
284
|
-
node.forCount++;
|
|
285
|
-
}
|
|
286
|
-
node.children.map(addForCount);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
return virtualRoot;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function dfsTree(node, fn, parent) {
|
|
293
|
-
node.value && fn(node, parent);
|
|
294
|
-
node.children.map((e) => dfsTree(e, fn, node.value ? node : null));
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// dispose autorun
|
|
298
|
-
function disposeWidgets(widgets = []) {
|
|
299
|
-
widgets.forEach((widget) => {
|
|
300
|
-
const disposers = widget._disposers;
|
|
301
|
-
if (disposers) {
|
|
302
|
-
disposers.map((dispose) => dispose());
|
|
303
|
-
disposers.splice(0, disposers.length);
|
|
304
|
-
}
|
|
305
|
-
disposeWidgets(widget.children);
|
|
306
|
-
});
|
|
307
|
-
}
|
package/template/src/index.jsx
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 当本应用是乾坤子应用是,publicPath需要设置为子应用的相对路径
|
|
3
|
-
* 这个变量时序重要需要先初始化
|
|
4
|
-
*/
|
|
5
|
-
if (window.__POWERED_BY_QIANKUN__) {
|
|
6
|
-
__webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
import * as React from 'react'
|
|
10
|
-
import * as ReactDOM from 'react-dom'
|
|
11
|
-
import { _WEDA_CLOUD_SDK as WEDA_CLOUD_SDK, auth } from '@cloudbase/weda-client'
|
|
12
|
-
import App from './router'
|
|
13
|
-
import './utils/monitor-jssdk.min'
|
|
14
|
-
import './index.less'
|
|
15
|
-
// 引入数据源管理器并进行初始化
|
|
16
|
-
import './datasources'
|
|
17
|
-
import { initGlobalVar } from './handlers/initWebEnv'
|
|
18
|
-
import '@babel/polyfill/noConflict'
|
|
19
|
-
import { initWebConfig } from 'handlers/lifecycle'
|
|
20
|
-
const AppConfig = require('../webpack/miniprogram.config')
|
|
21
|
-
import { app } from './app/global-api'
|
|
22
|
-
import { redirectToLogin, getAuthConfig, checkAnonymous } from './handlers/utils'
|
|
23
|
-
// app 中注册配置页面以及app的全局配置miniprogram.config,h5里分app以及web页分别处理,使用process.env.isApp 区分判断
|
|
24
|
-
if (process.env.isApp) {
|
|
25
|
-
initWebConfig(app, AppConfig);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// 设置数据源请求的 loading 及 toast 处理
|
|
29
|
-
WEDA_CLOUD_SDK.setConfig({
|
|
30
|
-
beforeDSRequest: (cfg) => {
|
|
31
|
-
if (!cfg.options || !cfg.options.showLoading) return
|
|
32
|
-
app.showLoading()
|
|
33
|
-
},
|
|
34
|
-
beforeCallFunction: async (params) => {
|
|
35
|
-
try{
|
|
36
|
-
const { loginConfigVersion } = app.__internal__.getConfig();
|
|
37
|
-
let skip = false;
|
|
38
|
-
switch (params?.data?.methodName) {
|
|
39
|
-
case 'callWedaApi': {
|
|
40
|
-
if(['GetMiniProgramUserTicket', 'DescribeRuntimeResourceStrategy'].includes(params?.data?.params.action)){
|
|
41
|
-
skip = true;
|
|
42
|
-
}
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// 后续做过滤处理
|
|
48
|
-
if (!loginConfigVersion || (params?.data?.mode === 'c' && skip)) {
|
|
49
|
-
return params;
|
|
50
|
-
}
|
|
51
|
-
const { accessToken } = await auth.getAccessToken();
|
|
52
|
-
if (accessToken) {
|
|
53
|
-
params.data.accessToken = accessToken;
|
|
54
|
-
}
|
|
55
|
-
} catch (e) {
|
|
56
|
-
console.error('beforeCallFunction error', e);
|
|
57
|
-
}
|
|
58
|
-
return params;
|
|
59
|
-
},
|
|
60
|
-
afterDSRequest: (cfg, error, result) => {
|
|
61
|
-
if (!cfg.options) return
|
|
62
|
-
if (cfg.options.showLoading) app.hideLoading()
|
|
63
|
-
if (!cfg.options.showToast) return
|
|
64
|
-
const isSuccess = !error && result && !result.code
|
|
65
|
-
app.showToast({icon: isSuccess ? 'success' : 'error'})
|
|
66
|
-
},
|
|
67
|
-
async afterCallFunction(params, error, res) {
|
|
68
|
-
if(params?.data?.params?.action != 'DescribeRuntimeResourceStrategy' && ['InnerError.AuthFailure','InvalidAccessToken'].includes(res?.result?.code)) {
|
|
69
|
-
const { loginConfigVersion } = app.__internal__.getConfig();
|
|
70
|
-
if (loginConfigVersion) {
|
|
71
|
-
const authConfig = await getAuthConfig();
|
|
72
|
-
const isAnonymous = await checkAnonymous();
|
|
73
|
-
if (isAnonymous && authConfig.RejectStrategy == 'to_login') {
|
|
74
|
-
redirectToLogin();
|
|
75
|
-
} else if (authConfig.RejectStrategy == 'show_warning') {
|
|
76
|
-
app.showToast({
|
|
77
|
-
title: '接口无访问权限',
|
|
78
|
-
icon: 'error',
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
// window.app.yyptReport = window.yyptReport
|
|
86
|
-
|
|
87
|
-
if (yyptReport && typeof yyptReport.pgvMain == 'function') {
|
|
88
|
-
// report_url,appKey必填
|
|
89
|
-
yyptReport.pgvMain({
|
|
90
|
-
appKey: '<%= yyptAppKey %>', // 填入你申请的运营平台的应用key(必填)
|
|
91
|
-
report_url: '<%= reportUrl %><%= yyptAppKey %>', // 上报url(把后端上报接口需要先挂网关,该url填写网关地址)
|
|
92
|
-
autoReportPv: true, // 单页应用监听页面路径改变自动上报Pv,默认为false
|
|
93
|
-
stopReport: <%= stopReport %>, // 停止上报
|
|
94
|
-
// 其他参数说明
|
|
95
|
-
// customUserPrams: null, // 用户自定义的额外属性--对于小马的用户属性,比如用户的部门编码(customUserPrams: { deptno: 1100 })需要在小马系统事先配置好
|
|
96
|
-
//userKey: "user_id", // cookie里面用户的唯一标示
|
|
97
|
-
//autoWatchClick: true, // 默认开启自动监听hottag
|
|
98
|
-
//isWxEnv: false// 是否微信环境,微信环境会通过wx.getNetworkType获取网络环境
|
|
99
|
-
// 通过传入函数,可以让业务方写代码传入要上报的属性,比如返回自定义属性,这里主要也是自定义属性,让sdk获取并且进行上报,减少重复编码
|
|
100
|
-
//getCusParams: function () {
|
|
101
|
-
// return {kv:{money:1}}; //kv:Key-Value,自定义事件Key-Value参数对 map JSON格式,在报表页面的事件参数分析页和页面参数分析页中可以看到上报的kv值
|
|
102
|
-
//},
|
|
103
|
-
})
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
initGlobalVar()
|
|
107
|
-
;(function() {
|
|
108
|
-
function flex() {
|
|
109
|
-
try {
|
|
110
|
-
let htmlDom = document.documentElement
|
|
111
|
-
let width = window.innerWidth || htmlDom.clientWidth
|
|
112
|
-
let fontSize = width / (375 / 14)
|
|
113
|
-
if (
|
|
114
|
-
!navigator.userAgent.match(
|
|
115
|
-
/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|IEMobile)/i
|
|
116
|
-
) &&
|
|
117
|
-
fontSize > 14
|
|
118
|
-
) {
|
|
119
|
-
htmlDom.style.fontSize = `14px`
|
|
120
|
-
} else {
|
|
121
|
-
htmlDom.style.fontSize = fontSize + `px`
|
|
122
|
-
}
|
|
123
|
-
} catch (e) {
|
|
124
|
-
console.error(e)
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
flex()
|
|
129
|
-
window.addEventListener('resize', flex)
|
|
130
|
-
})()
|
|
131
|
-
|
|
132
|
-
// 使用HMR
|
|
133
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
134
|
-
if (module.hot) {
|
|
135
|
-
module.hot.accept()
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function render(props){
|
|
140
|
-
const target = props && props.container ? props.container.querySelector('#react-body') : document.getElementById('react-body');
|
|
141
|
-
ReactDOM.render(
|
|
142
|
-
<App />,
|
|
143
|
-
target
|
|
144
|
-
)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// if (!process.env.isAdminPortal) {
|
|
148
|
-
if (!window.__POWERED_BY_QIANKUN__) {
|
|
149
|
-
render()
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* bootstrap 只会在微应用初始化的时候调用一次,下次微应用重新进入时会直接调用 mount 钩子,不会再重复触发 bootstrap。
|
|
154
|
-
* 通常我们可以在这里做一些全局变量的初始化,比如不会在 unmount 阶段被销毁的应用级别的缓存等。
|
|
155
|
-
*/
|
|
156
|
-
async function bootstrap() {
|
|
157
|
-
console.log('react app bootstraped')
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* 应用每次进入都会调用 mount 方法,通常我们在这里触发应用的渲染方法
|
|
162
|
-
*/
|
|
163
|
-
async function mount(props) {
|
|
164
|
-
render(props)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* 应用每次切出/卸载 会调用的方法,通常在这里我们会卸载微应用的应用实例
|
|
169
|
-
*/
|
|
170
|
-
async function unmount(props) {
|
|
171
|
-
console.log('unmount')
|
|
172
|
-
ReactDOM.unmountComponentAtNode(
|
|
173
|
-
props.container ? props.container.querySelector('#react-body') : document.getElementById('react-body')
|
|
174
|
-
)
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
<% if(adminPortalKey){ %>
|
|
178
|
-
((global) => {
|
|
179
|
-
global['<%= adminPortalKey %>'] = {
|
|
180
|
-
bootstrap,
|
|
181
|
-
mount,
|
|
182
|
-
unmount,
|
|
183
|
-
};
|
|
184
|
-
})(window);
|
|
185
|
-
<% } %>
|
package/template/src/index.less
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
// 针对小程序样式做适配
|
|
2
|
-
// 请注意与weapps/src/pages/editor/components/Main/EditAndPreview/index.iframe.scss的一致性,以确保小程序端样式与
|
|
3
|
-
body {
|
|
4
|
-
margin: 0;
|
|
5
|
-
padding: 0;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
#weapp-scancode-video {
|
|
9
|
-
width: 100%;
|
|
10
|
-
height: 100%;
|
|
11
|
-
object-fit: cover;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.weapp-scancode {
|
|
15
|
-
&-close-button {
|
|
16
|
-
background: white;
|
|
17
|
-
color: black;
|
|
18
|
-
display: flex;
|
|
19
|
-
position: absolute;
|
|
20
|
-
top: 14px;
|
|
21
|
-
left: 14px;
|
|
22
|
-
width: 24px;
|
|
23
|
-
height: 24px;
|
|
24
|
-
border-radius: 50%;
|
|
25
|
-
cursor: pointer;
|
|
26
|
-
justify-content: center;
|
|
27
|
-
align-items: center;
|
|
28
|
-
z-index: 500;
|
|
29
|
-
}
|
|
30
|
-
&-modal {
|
|
31
|
-
position: fixed;
|
|
32
|
-
background-color: black;
|
|
33
|
-
left: 0px;
|
|
34
|
-
right: 0px;
|
|
35
|
-
top: 0px;
|
|
36
|
-
bottom: 0px;
|
|
37
|
-
&-main {
|
|
38
|
-
height: 100%;
|
|
39
|
-
position: relative;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
&-scan {
|
|
43
|
-
&-wrapper {
|
|
44
|
-
display: flex;
|
|
45
|
-
flex-direction: column;
|
|
46
|
-
justify-content: center;
|
|
47
|
-
align-items: center;
|
|
48
|
-
height: 100%;
|
|
49
|
-
width: 100%;
|
|
50
|
-
position: absolute;
|
|
51
|
-
top: 0;
|
|
52
|
-
left: 0;
|
|
53
|
-
}
|
|
54
|
-
&-square {
|
|
55
|
-
--square-size: 16rem;
|
|
56
|
-
width: var(--square-size);
|
|
57
|
-
height: var(--square-size);
|
|
58
|
-
position: relative;
|
|
59
|
-
}
|
|
60
|
-
&-bar {
|
|
61
|
-
position: absolute;
|
|
62
|
-
height: 10px;
|
|
63
|
-
width: 100%;
|
|
64
|
-
background: linear-gradient(90deg, transparent, #07c160 50%, transparent);
|
|
65
|
-
top: 0%;
|
|
66
|
-
border-top-left-radius: 50%;
|
|
67
|
-
border-top-right-radius: 50%;
|
|
68
|
-
animation: slideinout-top-down 2s;
|
|
69
|
-
animation-direction: normal;
|
|
70
|
-
animation-timing-function: linear;
|
|
71
|
-
animation-iteration-count: infinite;
|
|
72
|
-
}
|
|
73
|
-
&-tip {
|
|
74
|
-
margin-top: 10rem;
|
|
75
|
-
color: white;
|
|
76
|
-
}
|
|
77
|
-
&-not-found {
|
|
78
|
-
color: white;
|
|
79
|
-
}
|
|
80
|
-
&-not-found + p {
|
|
81
|
-
color: #999;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
&-img-selector {
|
|
86
|
-
position: absolute;
|
|
87
|
-
bottom: 32px;
|
|
88
|
-
right: 32px;
|
|
89
|
-
z-index: 500;
|
|
90
|
-
}
|
|
91
|
-
&-img-picker {
|
|
92
|
-
z-index: 500;
|
|
93
|
-
padding: 5px;
|
|
94
|
-
display: block;
|
|
95
|
-
cursor: pointer;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
@keyframes slideinout-top-down {
|
|
100
|
-
// use transform to prevent relayout
|
|
101
|
-
0% {
|
|
102
|
-
transform: translateY(0px);
|
|
103
|
-
opacity: 0;
|
|
104
|
-
}
|
|
105
|
-
50% {
|
|
106
|
-
transform: translateY(calc(var(--square-size) / 2));
|
|
107
|
-
opacity: 0.5;
|
|
108
|
-
}
|
|
109
|
-
100% {
|
|
110
|
-
transform: translateY(var(--square-size));
|
|
111
|
-
opacity: 0;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
@media (min-width: 1024px) {
|
|
116
|
-
.weda-responsive_flex_flow {
|
|
117
|
-
flex-flow: row !important;
|
|
118
|
-
}
|
|
119
|
-
}
|