@cloudbase/lowcode-builder 1.6.4 → 1.7.0
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/h5/index.js +3 -3
- package/lib/builder/mp/mixMode.js +2 -2
- package/lib/builder/service/webpack.js +1 -1
- package/lib/builder/util/mp.d.ts +1 -1
- package/lib/builder/util/mp.js +4 -4
- package/lib/event-emitter.d.ts +32 -0
- package/lib/event-emitter.js +88 -0
- package/lib/flow.d.ts +30 -0
- package/lib/flow.js +63 -0
- package/lib/query.d.ts +47 -0
- package/lib/query.js +175 -0
- package/package.json +3 -3
- package/template/html/index.html.ejs +8 -2
- package/template/mp/app.js +6 -2
- package/template/mp/common/util.js +102 -32
- package/template/mp/common/weapp-component.js +4 -1
- package/template/mp/common/weapp-page.js +7 -2
- package/template/mp/page/api.js +3 -1
- package/template/webpack/web.prod.js +2 -1
package/lib/builder/h5/index.js
CHANGED
|
@@ -92,7 +92,7 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals, buildType
|
|
|
92
92
|
const runHandleMaterialTag = '🚥 buildWebApp-runHandleMaterial';
|
|
93
93
|
console.time(runHandleMaterialTag);
|
|
94
94
|
// 精简只使用用到的组件库,并获取补齐json格式
|
|
95
|
-
const
|
|
95
|
+
const processedDependencies = await (0, material_1.runHandleMaterial)(h5BuildDir, dependencies.filter((lib) => {
|
|
96
96
|
// 注意需要包涵官方的(gsd),部分平台方法需要由其补充
|
|
97
97
|
return lib.name === config_1.OFFICIAL_LIB_KEY || !!allAppUsedComps[lib.name];
|
|
98
98
|
}), materialsDir, runtime, ignoreInstall);
|
|
@@ -101,7 +101,7 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals, buildType
|
|
|
101
101
|
const runGenerateTag = '🚥 buildWebApp-generateProjectFiles';
|
|
102
102
|
console.time(runGenerateTag);
|
|
103
103
|
await (0, generate_1.generateProjectFiles)({
|
|
104
|
-
dependencies:
|
|
104
|
+
dependencies: processedDependencies,
|
|
105
105
|
cals,
|
|
106
106
|
mainAppData,
|
|
107
107
|
subAppDataList,
|
|
@@ -125,7 +125,7 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals, buildType
|
|
|
125
125
|
mainAppData,
|
|
126
126
|
subAppDataList,
|
|
127
127
|
appBuildDir: h5BuildDir,
|
|
128
|
-
dependencies:
|
|
128
|
+
dependencies: processedDependencies,
|
|
129
129
|
mode,
|
|
130
130
|
devTool,
|
|
131
131
|
ignoreInstall,
|
|
@@ -126,7 +126,7 @@ async function handleMixMode({ buildContext, apps = [], miniprogramRoot, plugins
|
|
|
126
126
|
if (fs_extra_1.default.existsSync(packageJosnPath)) {
|
|
127
127
|
mergeDependencies = {
|
|
128
128
|
...mergeDependencies,
|
|
129
|
-
...(await (0, mp_1.
|
|
129
|
+
...(await (0, mp_1.mergePackageDependencies)(mergeDependencies, await fs_extra_1.default.readJson(packageJosnPath))),
|
|
130
130
|
};
|
|
131
131
|
modifiedPackageJosn = true;
|
|
132
132
|
}
|
|
@@ -149,7 +149,7 @@ async function handleMixMode({ buildContext, apps = [], miniprogramRoot, plugins
|
|
|
149
149
|
if (modifiedPackageJosn) {
|
|
150
150
|
await (0, fs_extra_1.writeFile)(rootPackageJosnPath, JSON.stringify({
|
|
151
151
|
...rootPackageJson,
|
|
152
|
-
...(0, mp_1.
|
|
152
|
+
...(0, mp_1.mergePackageDependencies)(mergeDependencies, rootPackageJson), // 主包优先
|
|
153
153
|
}, undefined, 2));
|
|
154
154
|
}
|
|
155
155
|
}
|
|
@@ -298,7 +298,7 @@ function getWebpackWebBuildParams(appId, appBuildDir, publicPath = '/', mode = c
|
|
|
298
298
|
'process.env.buildType': `"${buildTypeList[0]}"`,
|
|
299
299
|
...extraDefine,
|
|
300
300
|
},
|
|
301
|
-
devtool: ['app-nvzcvt10', 'app-msa2ihs9'].includes(appId)
|
|
301
|
+
devtool: ['app-nvzcvt10', 'app-msa2ihs9', 'app-PMoFiTuX'].includes(appId)
|
|
302
302
|
? 'source-map'
|
|
303
303
|
: mode !== common_1.WebpackModeType.PRODUCTION
|
|
304
304
|
? 'eval'
|
package/lib/builder/util/mp.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare function mergeSubPackages(baseAppJsonPath: string, mergeAppJsonPath: string): Promise<void>;
|
|
2
2
|
export declare function mergePackageJson(basePkgJsonPath: string, mergePkgJsonPath: string): Promise<void>;
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function mergePackageDependencies(baseJson: any, mergeJson: any): any;
|
|
4
4
|
export declare function mergePages(baseAppJsonPath: string, mergeAppJsonPath: string): Promise<void>;
|
package/lib/builder/util/mp.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.mergePages = exports.
|
|
26
|
+
exports.mergePages = exports.mergePackageDependencies = exports.mergePackageJson = exports.mergeSubPackages = void 0;
|
|
27
27
|
/**
|
|
28
28
|
* Tencent is pleased to support the open source community by making CloudBaseFramework - 云原生一体化部署工具 available.
|
|
29
29
|
*
|
|
@@ -60,13 +60,13 @@ async function mergePackageJson(basePkgJsonPath, mergePkgJsonPath) {
|
|
|
60
60
|
const mergeJson = fs.readJSONSync(mergePkgJsonPath);
|
|
61
61
|
baseJson = {
|
|
62
62
|
...baseJson,
|
|
63
|
-
...
|
|
63
|
+
...mergePackageDependencies(baseJson, mergeJson),
|
|
64
64
|
};
|
|
65
65
|
await fs.writeJSON(basePkgJsonPath, baseJson, { spaces: 2 });
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
exports.mergePackageJson = mergePackageJson;
|
|
69
|
-
function
|
|
69
|
+
function mergePackageDependencies(baseJson, mergeJson) {
|
|
70
70
|
baseJson.dependencies = {
|
|
71
71
|
...(baseJson.dependencies || {}),
|
|
72
72
|
...(mergeJson.dependencies || {}),
|
|
@@ -77,7 +77,7 @@ function mergePackageDependiences(baseJson, mergeJson) {
|
|
|
77
77
|
};
|
|
78
78
|
return baseJson;
|
|
79
79
|
}
|
|
80
|
-
exports.
|
|
80
|
+
exports.mergePackageDependencies = mergePackageDependencies;
|
|
81
81
|
async function mergePages(baseAppJsonPath, mergeAppJsonPath) {
|
|
82
82
|
const baseJson = fs.readJSONSync(baseAppJsonPath);
|
|
83
83
|
const mergeJson = fs.readJSONSync(mergeAppJsonPath);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export default class EventEmitter {
|
|
2
|
+
constructor();
|
|
3
|
+
on(eventName: any, listener: any): void;
|
|
4
|
+
off(eventName: any, listener: any): void;
|
|
5
|
+
emit(eventName: any, ...args: any[]): void;
|
|
6
|
+
clear(): void;
|
|
7
|
+
}
|
|
8
|
+
export declare class Event {
|
|
9
|
+
type: string;
|
|
10
|
+
detail: any;
|
|
11
|
+
/**
|
|
12
|
+
* 类别应当为 typeof UserWidget
|
|
13
|
+
* 当前类别为 typeof $page.widgets.xxxx
|
|
14
|
+
* 添加上报确定用量
|
|
15
|
+
*/
|
|
16
|
+
currentTarget: any;
|
|
17
|
+
target?: any;
|
|
18
|
+
/**
|
|
19
|
+
* 内部实现
|
|
20
|
+
* 外部不应该进行访问
|
|
21
|
+
*/
|
|
22
|
+
_isCapturePhase: boolean;
|
|
23
|
+
origin: Event;
|
|
24
|
+
constructor({ type, detail, currentTarget, target, _isCapturePhase, origin, }: {
|
|
25
|
+
type: string;
|
|
26
|
+
currentTarget: any;
|
|
27
|
+
target?: any;
|
|
28
|
+
detail?: any;
|
|
29
|
+
_isCapturePhase?: boolean;
|
|
30
|
+
origin?: Event;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Event = void 0;
|
|
4
|
+
function checkFunc(listener) {
|
|
5
|
+
if (!listener instanceof Function) {
|
|
6
|
+
throw new Error(' The listener argument must be of type Function. ');
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
class EventEmitter {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.listeners = {};
|
|
12
|
+
}
|
|
13
|
+
on(eventName, listener) {
|
|
14
|
+
checkFunc(listener);
|
|
15
|
+
let listeners = this.listeners[eventName];
|
|
16
|
+
if (!listeners) {
|
|
17
|
+
this.listeners[eventName] = [listener];
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
listeners.push(listener);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
off(eventName, listener) {
|
|
24
|
+
let listeners = this.listeners[eventName];
|
|
25
|
+
if (listeners && listeners.length) {
|
|
26
|
+
const index = listeners.indexOf(listener);
|
|
27
|
+
index > -1 && listeners.splice(index, 1);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
emit(eventName, ...args) {
|
|
31
|
+
let listeners = this.listeners[eventName] || [];
|
|
32
|
+
listeners.forEach((fn) => {
|
|
33
|
+
try {
|
|
34
|
+
fn.call(this, ...args);
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
console.error(err);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
clear() {
|
|
42
|
+
this.listeners = {};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.default = EventEmitter;
|
|
46
|
+
class Event {
|
|
47
|
+
constructor({ type = '', detail = undefined, currentTarget = undefined, target = undefined, _isCapturePhase = false, origin, }) {
|
|
48
|
+
function proxyWrapper(target, key) {
|
|
49
|
+
try {
|
|
50
|
+
return new Proxy(target, {
|
|
51
|
+
get(target, p) {
|
|
52
|
+
if (p !== 'id') {
|
|
53
|
+
// reportEvent(`event.${key}.${String(p)}`);
|
|
54
|
+
}
|
|
55
|
+
return target[p];
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
return target;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
this.type = type;
|
|
64
|
+
this.detail = detail;
|
|
65
|
+
this.currentTarget = proxyWrapper(currentTarget, 'currentTarget');
|
|
66
|
+
this.target = proxyWrapper(target, 'target');
|
|
67
|
+
this.origin = proxyWrapper(origin, 'origin');
|
|
68
|
+
this._isCapturePhase = _isCapturePhase;
|
|
69
|
+
return new Proxy(this, {
|
|
70
|
+
get(target, prop) {
|
|
71
|
+
switch (prop) {
|
|
72
|
+
case 'name': {
|
|
73
|
+
console.warn('[deprecated] event.name 将在未来版本放弃支持,请使用 event.type 替代');
|
|
74
|
+
return target.type;
|
|
75
|
+
}
|
|
76
|
+
case 'origin':
|
|
77
|
+
case 'target':
|
|
78
|
+
case 'currentTarget': {
|
|
79
|
+
return target[prop];
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return target[prop];
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.Event = Event;
|
package/lib/flow.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
declare type IGenerateContext = any;
|
|
2
|
+
export interface IEventFlowContext extends IGenerateContext {
|
|
3
|
+
$w?: any;
|
|
4
|
+
target?: any;
|
|
5
|
+
}
|
|
6
|
+
interface IMPEventFlowGenerateOptions {
|
|
7
|
+
looseError?: boolean;
|
|
8
|
+
isComposite?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class EventFlow {
|
|
11
|
+
id: string;
|
|
12
|
+
description: string;
|
|
13
|
+
private _eventHandlerMap;
|
|
14
|
+
private _context;
|
|
15
|
+
constructor({ schema, context, options, }: {
|
|
16
|
+
schema: {
|
|
17
|
+
id?: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
/**
|
|
20
|
+
* 预处理后 event handler listeners
|
|
21
|
+
*/
|
|
22
|
+
listeners?: any[];
|
|
23
|
+
};
|
|
24
|
+
context: IEventFlowContext;
|
|
25
|
+
options?: IMPEventFlowGenerateOptions;
|
|
26
|
+
});
|
|
27
|
+
trigger(additionalScope: any, options?: Partial<IEventFlowContext>): any;
|
|
28
|
+
}
|
|
29
|
+
export declare function generateEventFlows(flows: never[] | undefined, context: IEventFlowContext, options?: IMPEventFlowGenerateOptions): {};
|
|
30
|
+
export {};
|
package/lib/flow.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateEventFlows = exports.EventFlow = void 0;
|
|
4
|
+
const util_1 = require("./util");
|
|
5
|
+
const event_emitter_1 = require("./event-emitter");
|
|
6
|
+
class EventFlow {
|
|
7
|
+
constructor({ schema, context, options, }) {
|
|
8
|
+
this._eventHandlerMap = {};
|
|
9
|
+
this._context = context;
|
|
10
|
+
const { id, description, listeners = [] } = schema || {};
|
|
11
|
+
const startNode = listeners[0];
|
|
12
|
+
const [_, eventFlowId] = (startNode === null || startNode === void 0 ? void 0 : startNode.eventName.match(/(.*?)\.start/)) || [];
|
|
13
|
+
this.id = id || eventFlowId;
|
|
14
|
+
this.description = description || (startNode === null || startNode === void 0 ? void 0 : startNode.description) || '';
|
|
15
|
+
const handlers = (0, util_1.createEventHandlers)(listeners, {
|
|
16
|
+
looseError: (options === null || options === void 0 ? void 0 : options.looseError) || false,
|
|
17
|
+
isComposite: (options === null || options === void 0 ? void 0 : options.isComposite) || false,
|
|
18
|
+
});
|
|
19
|
+
this._eventHandlerMap = Object.entries(handlers).reduce((map, [key, fn]) => {
|
|
20
|
+
map[key] = fn.bind(this);
|
|
21
|
+
return map;
|
|
22
|
+
}, {
|
|
23
|
+
_getInstance: () => this._context.$page || this._context.$app,
|
|
24
|
+
});
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
trigger(additionalScope, options = {}) {
|
|
28
|
+
const mergedContext = {
|
|
29
|
+
...this._context,
|
|
30
|
+
...options,
|
|
31
|
+
};
|
|
32
|
+
const { $w, target } = mergedContext;
|
|
33
|
+
return this._eventHandlerMap[(0, util_1.getMpEventHandlerName)(this.id, 'start')](new event_emitter_1.Event({
|
|
34
|
+
type: `${this.id}.start`,
|
|
35
|
+
detail: additionalScope,
|
|
36
|
+
target,
|
|
37
|
+
currentTarget: target,
|
|
38
|
+
}));
|
|
39
|
+
// const emit = (trigger, eventData, originalEvent?) =>
|
|
40
|
+
// generateEmit($w, target)(
|
|
41
|
+
// trigger,
|
|
42
|
+
// this._listenerInstances,
|
|
43
|
+
// eventData,
|
|
44
|
+
// forContext,
|
|
45
|
+
// originalEvent,
|
|
46
|
+
// scopeContext,
|
|
47
|
+
// dataContext,
|
|
48
|
+
// $w.page.id,
|
|
49
|
+
// true,
|
|
50
|
+
// );
|
|
51
|
+
// return emit(`${this.id}.start`, additionalScope);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.EventFlow = EventFlow;
|
|
55
|
+
function generateEventFlows(flows = [], context, options) {
|
|
56
|
+
const result = {};
|
|
57
|
+
return result;
|
|
58
|
+
for (let flow of flows) {
|
|
59
|
+
result[flow.id] = new EventFlow({ schema: flow, context, options });
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
exports.generateEventFlows = generateEventFlows;
|
package/lib/query.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
interface IMPDataSourceQuery {
|
|
2
|
+
id: string;
|
|
3
|
+
label?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
trigger: 'auto' | 'manual';
|
|
6
|
+
type: 'model' | 'apis' | 'sql';
|
|
7
|
+
dataSourceName: string;
|
|
8
|
+
methodName: string;
|
|
9
|
+
data: object;
|
|
10
|
+
dataBinds: Record<string, Function>;
|
|
11
|
+
/**
|
|
12
|
+
* 预处理后 event handler listeners
|
|
13
|
+
*/
|
|
14
|
+
listeners?: any[];
|
|
15
|
+
}
|
|
16
|
+
declare type IQueryContext = any;
|
|
17
|
+
declare type IGenerateOptions = any;
|
|
18
|
+
export declare class Query {
|
|
19
|
+
private _schema;
|
|
20
|
+
private _context;
|
|
21
|
+
private _disposes;
|
|
22
|
+
private _dataBinds;
|
|
23
|
+
private _triggered;
|
|
24
|
+
private _action;
|
|
25
|
+
private _paramsRef;
|
|
26
|
+
private _currentRequestKey;
|
|
27
|
+
private _observableValue;
|
|
28
|
+
private _eventHandlerMap;
|
|
29
|
+
constructor({ schema, context, options, }: {
|
|
30
|
+
schema: IMPDataSourceQuery;
|
|
31
|
+
context: IQueryContext;
|
|
32
|
+
options?: IGenerateOptions;
|
|
33
|
+
});
|
|
34
|
+
get id(): string;
|
|
35
|
+
get label(): string;
|
|
36
|
+
get description(): string;
|
|
37
|
+
get data(): any;
|
|
38
|
+
get error(): Error | null;
|
|
39
|
+
trigger(additionalScope?: any, options?: {}): Promise<any>;
|
|
40
|
+
_innerTrigger(data: any, additionalScope?: any, options?: {}): Promise<any>;
|
|
41
|
+
private _debounceTrigger;
|
|
42
|
+
destroy(): void;
|
|
43
|
+
private _resolveParams;
|
|
44
|
+
private _emit;
|
|
45
|
+
}
|
|
46
|
+
export declare function generateDatasetQuery(schema: any, context: IQueryContext, options: IGenerateOptions): {};
|
|
47
|
+
export {};
|
package/lib/query.js
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateDatasetQuery = exports.Query = void 0;
|
|
4
|
+
const mobx_1 = require("mobx");
|
|
5
|
+
const util_1 = require("./util");
|
|
6
|
+
const event_emitter_1 = require("./event-emitter");
|
|
7
|
+
class Query {
|
|
8
|
+
constructor({ schema, context, options, }) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
this._disposes = [];
|
|
11
|
+
this._dataBinds = {};
|
|
12
|
+
this._triggered = false;
|
|
13
|
+
this._paramsRef = (0, mobx_1.observable)({ current: null });
|
|
14
|
+
this._currentRequestKey = null;
|
|
15
|
+
this._observableValue = (0, mobx_1.observable)({ data: null, error: null });
|
|
16
|
+
this._eventHandlerMap = {};
|
|
17
|
+
this._debounceTrigger = (function () {
|
|
18
|
+
let timer = null;
|
|
19
|
+
return function (...args) {
|
|
20
|
+
if (timer) {
|
|
21
|
+
clearTimeout(timer);
|
|
22
|
+
}
|
|
23
|
+
timer = setTimeout(() => {
|
|
24
|
+
this._innerTrigger(...args);
|
|
25
|
+
}, 300);
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
const { looseError = false, useScopeWidgetData = false } = options;
|
|
29
|
+
const { $w, $app, $page } = context;
|
|
30
|
+
this._schema = schema;
|
|
31
|
+
this._context = context;
|
|
32
|
+
if (((_a = this._schema) === null || _a === void 0 ? void 0 : _a.trigger) === 'auto') {
|
|
33
|
+
this._disposes.push((0, mobx_1.autorun)((r) => {
|
|
34
|
+
try {
|
|
35
|
+
const data = this._resolveParams();
|
|
36
|
+
if (this._triggered) {
|
|
37
|
+
this._debounceTrigger(data);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
console.error(e);
|
|
42
|
+
}
|
|
43
|
+
}, { delay: 50 }));
|
|
44
|
+
}
|
|
45
|
+
const baseParam = {
|
|
46
|
+
dataSourceName: this._schema.dataSourceName,
|
|
47
|
+
};
|
|
48
|
+
if (((_b = this._schema) === null || _b === void 0 ? void 0 : _b.type) === 'sql') {
|
|
49
|
+
baseParam.sqlTemplateId = this._schema.methodName;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
baseParam.methodName = this._schema.methodName;
|
|
53
|
+
}
|
|
54
|
+
this._paramsRef.current = this._schema.data;
|
|
55
|
+
this._dataBinds = this._schema.dataBinds;
|
|
56
|
+
this._action = async (data) => {
|
|
57
|
+
return $w.cloud.callDataSource({
|
|
58
|
+
...baseParam,
|
|
59
|
+
params: data,
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
this._eventHandlerMap = Object.entries((0, util_1.createEventHandlers)(this._schema.listeners || [], {
|
|
63
|
+
looseError: looseError,
|
|
64
|
+
isComposite: false,
|
|
65
|
+
})).reduce((map, [key, fn]) => {
|
|
66
|
+
map[key] = fn.bind(this);
|
|
67
|
+
return map;
|
|
68
|
+
}, {
|
|
69
|
+
_getInstance: () => this._context.$page || this._context.$app,
|
|
70
|
+
});
|
|
71
|
+
// this._emit = async (trigger, eventData, originalEvent?) =>
|
|
72
|
+
// generateEmit($w)(
|
|
73
|
+
// trigger,
|
|
74
|
+
// generateListnerInstances(
|
|
75
|
+
// {
|
|
76
|
+
// $app,
|
|
77
|
+
// $page,
|
|
78
|
+
// actionsMap: (this._context as any).actionsMap,
|
|
79
|
+
// },
|
|
80
|
+
// this._schema.listeners || [],
|
|
81
|
+
// ),
|
|
82
|
+
// eventData,
|
|
83
|
+
// {},
|
|
84
|
+
// originalEvent,
|
|
85
|
+
// {},
|
|
86
|
+
// {},
|
|
87
|
+
// $w.page.id,
|
|
88
|
+
// true,
|
|
89
|
+
// );
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
get id() {
|
|
93
|
+
var _a;
|
|
94
|
+
return ((_a = this._schema) === null || _a === void 0 ? void 0 : _a.id) || '';
|
|
95
|
+
}
|
|
96
|
+
get label() {
|
|
97
|
+
var _a;
|
|
98
|
+
return ((_a = this._schema) === null || _a === void 0 ? void 0 : _a.label) || '';
|
|
99
|
+
}
|
|
100
|
+
get description() {
|
|
101
|
+
var _a;
|
|
102
|
+
return ((_a = this._schema) === null || _a === void 0 ? void 0 : _a.description) || '';
|
|
103
|
+
}
|
|
104
|
+
get data() {
|
|
105
|
+
return this._observableValue.data;
|
|
106
|
+
}
|
|
107
|
+
get error() {
|
|
108
|
+
return this._observableValue.error;
|
|
109
|
+
}
|
|
110
|
+
async trigger(additionalScope, options = {}) {
|
|
111
|
+
this._triggered = true;
|
|
112
|
+
return this._innerTrigger(this._resolveParams(), additionalScope, options);
|
|
113
|
+
}
|
|
114
|
+
async _innerTrigger(data, additionalScope, options = {}) {
|
|
115
|
+
this._currentRequestKey = Date.now();
|
|
116
|
+
const key = this._currentRequestKey;
|
|
117
|
+
try {
|
|
118
|
+
const res = await this._action(data);
|
|
119
|
+
if (key === this._currentRequestKey) {
|
|
120
|
+
this._observableValue.data = res;
|
|
121
|
+
this._observableValue.error = null;
|
|
122
|
+
this._emit(`success`, res);
|
|
123
|
+
}
|
|
124
|
+
return res;
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
if (key === this._currentRequestKey) {
|
|
128
|
+
this._observableValue.data = null;
|
|
129
|
+
this._observableValue.error = e;
|
|
130
|
+
this._emit(`fail`, e);
|
|
131
|
+
}
|
|
132
|
+
throw e;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
destroy() {
|
|
136
|
+
this._disposes.forEach((dispose) => dispose());
|
|
137
|
+
}
|
|
138
|
+
_resolveParams() {
|
|
139
|
+
var _a;
|
|
140
|
+
/**
|
|
141
|
+
* 这里万一其中某个字段计算失败
|
|
142
|
+
* 好像会阻塞其他字段的计算
|
|
143
|
+
* 从而导致 autorun 没有添加依赖
|
|
144
|
+
*/
|
|
145
|
+
return (_a = (0, util_1.mergeDynamic2StaticData)((0, mobx_1.toJS)(this._paramsRef.current), this._dataBinds, {
|
|
146
|
+
codeContext: {
|
|
147
|
+
/**
|
|
148
|
+
* $page 或 $comp 实例
|
|
149
|
+
*/
|
|
150
|
+
instance: this._context.$page,
|
|
151
|
+
},
|
|
152
|
+
$w: this._context.$w,
|
|
153
|
+
// may be additional scope
|
|
154
|
+
})) === null || _a === void 0 ? void 0 : _a.params;
|
|
155
|
+
}
|
|
156
|
+
async _emit(eventName, data) {
|
|
157
|
+
var _a, _b;
|
|
158
|
+
return (_b = (_a = this._eventHandlerMap)[(0, util_1.getMpEventHandlerName)(this.id, eventName)]) === null || _b === void 0 ? void 0 : _b.call(_a, new event_emitter_1.Event({
|
|
159
|
+
type: eventName,
|
|
160
|
+
detail: data,
|
|
161
|
+
target: undefined,
|
|
162
|
+
currentTarget: undefined,
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.Query = Query;
|
|
167
|
+
function generateDatasetQuery(schema, context, options) {
|
|
168
|
+
const result = {};
|
|
169
|
+
return result;
|
|
170
|
+
for (const key in schema) {
|
|
171
|
+
result[key] = new Query({ schema: schema[key], context, options });
|
|
172
|
+
}
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
175
|
+
exports.generateDatasetQuery = generateDatasetQuery;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
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",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@cloudbase/cals": "^1.0.
|
|
42
|
-
"@cloudbase/lowcode-generator": "^1.
|
|
41
|
+
"@cloudbase/cals": "^1.0.5",
|
|
42
|
+
"@cloudbase/lowcode-generator": "^1.7.1",
|
|
43
43
|
"axios": "^0.21.0",
|
|
44
44
|
"browserfs": "^1.4.3",
|
|
45
45
|
"browserify-zlib": "^0.2.0",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
content="width=device-width,initial-scale=1.0,user-scalable=no<% if(!isBuildApp) {%>,viewport-fit=cover<%}%>"
|
|
10
10
|
/>
|
|
11
11
|
<meta name="format-detection" content="telephone=no" />
|
|
12
|
-
<meta name="description" content="<%= desc %>" />
|
|
12
|
+
<!-- <meta name="description" content="<%= desc %>" /> -->
|
|
13
13
|
<link
|
|
14
14
|
rel="stylesheet"
|
|
15
15
|
href="<%=
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
reportAssetSpeed: true, // 静态资源测速
|
|
29
29
|
spa: true,
|
|
30
30
|
ext1: '<%=appId%>',
|
|
31
|
+
version: '0.0.1',
|
|
31
32
|
});
|
|
32
33
|
<% } else {%>
|
|
33
34
|
const _aegis = new Aegis({
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
reportAssetSpeed: false, // 静态资源测速
|
|
37
38
|
spa: true,
|
|
38
39
|
ext1: '<%=appId%>',
|
|
40
|
+
version: '0.0.1',
|
|
39
41
|
});
|
|
40
42
|
<% }%>
|
|
41
43
|
window._aegis = _aegis;
|
|
@@ -523,6 +525,10 @@
|
|
|
523
525
|
cdnEndpoints.cdngo
|
|
524
526
|
%>/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.29/dist/h5.browser.js"
|
|
525
527
|
></script>
|
|
528
|
+
<script
|
|
529
|
+
crossorigin
|
|
530
|
+
src="<%= cdnEndpoints.cdngo %>/lcap/lcap-resource-cdngo/-/release/_npm/acorn@8.0.4/dist/acorn.js"
|
|
531
|
+
></script>
|
|
526
532
|
<script>
|
|
527
533
|
// zxing polifill
|
|
528
534
|
if (!this.globalThis) {
|
|
@@ -543,7 +549,7 @@
|
|
|
543
549
|
crossorigin
|
|
544
550
|
src="<%=
|
|
545
551
|
cdnEndpoints.cdngo
|
|
546
|
-
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.
|
|
552
|
+
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.bd132ac7897700329255.bundle.js"
|
|
547
553
|
></script>
|
|
548
554
|
</body>
|
|
549
555
|
</html>
|
package/template/mp/app.js
CHANGED
|
@@ -68,8 +68,12 @@ setConfig({
|
|
|
68
68
|
const loginPage = findLoginPage();
|
|
69
69
|
if (loginPage) {
|
|
70
70
|
const authConfig = await getAuthConfig();
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
if (authConfig.RejectStrategy == 'to_login') {
|
|
72
|
+
if (['InnerError.AuthFailure'].includes(res?.result?.code)) {
|
|
73
|
+
const isAnonymous = await checkAnonymous();
|
|
74
|
+
if (!isAnonymous) return;
|
|
75
|
+
// 匿名用户越权去登录
|
|
76
|
+
}
|
|
73
77
|
redirectToLogin();
|
|
74
78
|
} else if (authConfig.RejectStrategy == 'show_warning') {
|
|
75
79
|
app.showToast({
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable no-restricted-syntax */
|
|
1
2
|
'use strict';
|
|
2
3
|
import { generateForContextOfWidget, generateWidgetAPIContext, getWidget } from './widget';
|
|
3
4
|
import { observable, untracked } from 'mobx';
|
|
@@ -33,7 +34,7 @@ export function generateDataContext(widget) {
|
|
|
33
34
|
while (widget?._scope) {
|
|
34
35
|
const current = widget;
|
|
35
36
|
// 此处采用代理的方式,是为了可以获取到最新的 _scope.dataContext 防止 dataContext 引用被重新赋值
|
|
36
|
-
if(current?._scope?.id){
|
|
37
|
+
if (current?._scope?.id) {
|
|
37
38
|
Object.defineProperty(dataContext, current._scope.id, {
|
|
38
39
|
get() {
|
|
39
40
|
return current?._scope?.dataContext;
|
|
@@ -53,9 +54,10 @@ export function createEventHandlers(
|
|
|
53
54
|
evtListeners,
|
|
54
55
|
options = {
|
|
55
56
|
looseError: false,
|
|
57
|
+
isComposite: false,
|
|
56
58
|
},
|
|
57
59
|
) {
|
|
58
|
-
const { looseError = false } = options;
|
|
60
|
+
const { looseError = false, isComposite = false } = options;
|
|
59
61
|
const evtHandlers = {};
|
|
60
62
|
for (const name in evtListeners) {
|
|
61
63
|
const listeners = evtListeners[name];
|
|
@@ -73,41 +75,103 @@ export function createEventHandlers(
|
|
|
73
75
|
const dataContext = untracked(() => generateDataContext(currentTarget));
|
|
74
76
|
const $w = untracked(() => generateWidgetAPIContext(owner?.__internal__?.$w, currentTarget, forContext));
|
|
75
77
|
|
|
76
|
-
|
|
78
|
+
function checkPageActive(pageId, currentPageContext, listener) {
|
|
79
|
+
/**
|
|
80
|
+
* 复合组件自身不中断校验
|
|
81
|
+
*/
|
|
82
|
+
if (isComposite) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
const { id, __internal__ } = currentPageContext || {};
|
|
86
|
+
if (pageId && id) {
|
|
87
|
+
if (pageId !== id || (__internal__ && !__internal__.active)) {
|
|
88
|
+
console.error(`Action error: [${name}] 页面生命周期结束,链式调用中断`);
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
|
|
77
95
|
listeners.forEach(async (l) => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
96
|
+
/**
|
|
97
|
+
* 调用前置校验
|
|
98
|
+
* 是否仍可调用方法
|
|
99
|
+
*/
|
|
100
|
+
if (!checkPageActive(owner.id, app.__internal__?.activePage, l)) {
|
|
101
|
+
return;
|
|
81
102
|
}
|
|
103
|
+
|
|
82
104
|
let { data = {}, boundData = {} } = l;
|
|
83
105
|
data = { ...data };
|
|
106
|
+
const nextEventHandles = [
|
|
107
|
+
{
|
|
108
|
+
handlerName: '',
|
|
109
|
+
event: {
|
|
110
|
+
...event,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
];
|
|
114
|
+
let error = false;
|
|
115
|
+
const isIfAction = l.sourceKey === 'platform:utils.If';
|
|
116
|
+
const isShowModalAction = l.sourceKey === 'platform:showModal';
|
|
84
117
|
try {
|
|
85
118
|
for (const k in boundData) {
|
|
86
119
|
set(data, k, boundData[k].call(owner, owner, lists, forItems, event, dataContext, $w));
|
|
87
120
|
}
|
|
88
121
|
let res = await l.handler.call(owner, { event, data });
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
122
|
+
nextEventHandles[0].handlerName =
|
|
123
|
+
prefix && l.key ? `${prefix}$${l.key}${!isIfAction || res ? '_success' : '_fail'}` : '';
|
|
124
|
+
nextEventHandles[0].event.detail = isIfAction ? event.detail : res;
|
|
125
|
+
if (isShowModalAction) {
|
|
126
|
+
let handlerName = '';
|
|
127
|
+
|
|
128
|
+
if (res.cancel) {
|
|
129
|
+
handlerName = `${prefix}$${l.key}_cancel`;
|
|
130
|
+
} else if (res.confirm) {
|
|
131
|
+
handlerName = `${prefix}$${l.key}_confirm`;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (handlerName) {
|
|
135
|
+
nextEventHandles.push({
|
|
136
|
+
handlerName,
|
|
137
|
+
event: {
|
|
138
|
+
...event,
|
|
139
|
+
detail: res,
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
95
144
|
} catch (e) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
145
|
+
nextEventHandles[0].handlerName = l.key ? `${prefix}$${l.key}_fail` : '';
|
|
146
|
+
nextEventHandles[0].event.detail = isIfAction ? event.detail : e;
|
|
147
|
+
error = e;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 调用后置校验
|
|
152
|
+
* 是否触发后置事件
|
|
153
|
+
*/
|
|
154
|
+
if (checkPageActive(owner.id, app.__internal__?.activePage, l)) {
|
|
155
|
+
const nextHandler = nextEventHandles[0];
|
|
156
|
+
|
|
157
|
+
if (!self[nextHandler.handlerName] && error) {
|
|
158
|
+
console.error(`Action error: [${trigger}:${l.key}]`, error);
|
|
104
159
|
if (!looseError) {
|
|
105
160
|
app.showToast({
|
|
106
161
|
icon: 'error',
|
|
107
162
|
title: `事件响应失败`,
|
|
108
163
|
});
|
|
109
164
|
}
|
|
110
|
-
throw
|
|
165
|
+
throw error;
|
|
166
|
+
} else {
|
|
167
|
+
await Promise.all(
|
|
168
|
+
nextEventHandles.map(async (nextHandler) => {
|
|
169
|
+
if (self[nextHandler.handlerName]) {
|
|
170
|
+
return self[nextHandler.handlerName](nextHandler.event);
|
|
171
|
+
}
|
|
172
|
+
return null;
|
|
173
|
+
}),
|
|
174
|
+
);
|
|
111
175
|
}
|
|
112
176
|
}
|
|
113
177
|
});
|
|
@@ -312,8 +376,13 @@ async function getAccessPermission(app, appId, pageId) {
|
|
|
312
376
|
if (Array.isArray(res)) {
|
|
313
377
|
const resourceInfo = res.find((i) => i.ResourceId === cacheKey);
|
|
314
378
|
const isAccess = !!resourceInfo?.IsAccess;
|
|
315
|
-
|
|
316
|
-
|
|
379
|
+
|
|
380
|
+
_AUTH_CACHE_MAP[cacheKey] = {
|
|
381
|
+
isAccess,
|
|
382
|
+
roleId: resourceInfo?.RoleId,
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
return _AUTH_CACHE_MAP[cacheKey];
|
|
317
386
|
} else {
|
|
318
387
|
throw new Error(`鉴权接口返回参数不正确 - ${JSON.stringify(res)}`);
|
|
319
388
|
}
|
|
@@ -330,7 +399,7 @@ export async function checkAnonymous() {
|
|
|
330
399
|
const scope = await loginScope();
|
|
331
400
|
isAnonymous = scope === 'anonymous';
|
|
332
401
|
}
|
|
333
|
-
} catch (e) {
|
|
402
|
+
} catch (e) {}
|
|
334
403
|
return isAnonymous;
|
|
335
404
|
}
|
|
336
405
|
|
|
@@ -359,17 +428,17 @@ export async function checkAuth(app, appId, $page) {
|
|
|
359
428
|
requestList.push(getAuthConfig(app));
|
|
360
429
|
}
|
|
361
430
|
try {
|
|
362
|
-
const [
|
|
431
|
+
const [accessData, authConfig] = await Promise.all(requestList);
|
|
363
432
|
app.hideNavigationBarLoading();
|
|
364
433
|
|
|
365
434
|
const isAnonymousUser = await checkAnonymous();
|
|
366
435
|
|
|
367
|
-
if (!isAccess) {
|
|
436
|
+
if (!accessData?.isAccess) {
|
|
368
437
|
if (isAnonymousUser && loginPage && (authConfig.NeedLogin || authConfig.RejectStrategy == 'to_login')) {
|
|
369
438
|
redirectToLogin($page);
|
|
370
439
|
} else {
|
|
371
440
|
app.showToast({
|
|
372
|
-
title: '页面无访问权限',
|
|
441
|
+
title: ['-2', '-4'].includes(accessData?.roleId) ? '默认访客无权限' : '页面无访问权限',
|
|
373
442
|
icon: 'error',
|
|
374
443
|
});
|
|
375
444
|
}
|
|
@@ -378,14 +447,14 @@ export async function checkAuth(app, appId, $page) {
|
|
|
378
447
|
try {
|
|
379
448
|
if (isAnonymousUser) {
|
|
380
449
|
redirectToLogin($page);
|
|
381
|
-
return false
|
|
450
|
+
return false;
|
|
382
451
|
}
|
|
383
452
|
} catch (e) {
|
|
384
453
|
redirectToLogin($page);
|
|
385
|
-
return false
|
|
454
|
+
return false;
|
|
386
455
|
}
|
|
387
456
|
}
|
|
388
|
-
return isAccess;
|
|
457
|
+
return accessData?.isAccess;
|
|
389
458
|
} catch (e) {
|
|
390
459
|
app.showModal({
|
|
391
460
|
title: '页面鉴权失败',
|
|
@@ -471,8 +540,9 @@ async function getGeneralOptions(optionName) {
|
|
|
471
540
|
|
|
472
541
|
export function getMpEventHandlerName(widgetId, evtName, modifier = {}) {
|
|
473
542
|
// Only builtin events have will bubble
|
|
474
|
-
return `on${widgetId}$${evtName.replace(/\./g, '_')}${modifier.isCapturePhase ? '$cap' : ''}${
|
|
475
|
-
|
|
543
|
+
return `on${widgetId}$${evtName.replace(/\./g, '_')}${modifier.isCapturePhase ? '$cap' : ''}${
|
|
544
|
+
modifier.noPropagation ? '$cat' : ''
|
|
545
|
+
}`;
|
|
476
546
|
}
|
|
477
547
|
|
|
478
548
|
function isPlainObject(src) {
|
|
@@ -56,6 +56,7 @@ export function createComponent(key, behaviors, properties, events, handler, dat
|
|
|
56
56
|
attached() {
|
|
57
57
|
const $comp = this._getInstance()
|
|
58
58
|
if(!$comp) return
|
|
59
|
+
$comp.__internal__.active = this._pageActive
|
|
59
60
|
|
|
60
61
|
$comp.props.events = createPropEvents(events, this)
|
|
61
62
|
const { widgets, rootWidget: virtualRootWidget } = createWidgets(widgetProps, dataBinds, this, $comp.widgets)
|
|
@@ -92,6 +93,8 @@ export function createComponent(key, behaviors, properties, events, handler, dat
|
|
|
92
93
|
detached() {
|
|
93
94
|
const $comp = this._getInstance()
|
|
94
95
|
if(!$comp) return
|
|
96
|
+
this._pageActive = false
|
|
97
|
+
$comp.__internal__.active = this._pageActive
|
|
95
98
|
|
|
96
99
|
$comp.widgets = null
|
|
97
100
|
$comp.node._eventListeners.clear();
|
|
@@ -123,7 +126,7 @@ export function createComponent(key, behaviors, properties, events, handler, dat
|
|
|
123
126
|
},
|
|
124
127
|
|
|
125
128
|
methods: {
|
|
126
|
-
...createEventHandlers(evtListeners, { looseError: true }),
|
|
129
|
+
...createEventHandlers(evtListeners, { looseError: true, isComposite: true }),
|
|
127
130
|
...mergeRenderer,
|
|
128
131
|
_getInstance() {
|
|
129
132
|
if(!this.$WEAPPS_COMP){
|
|
@@ -112,6 +112,8 @@ export function createPage(
|
|
|
112
112
|
detached() {
|
|
113
113
|
const $page = this._getInstance();
|
|
114
114
|
this._pageActive = false;
|
|
115
|
+
$page.__internal__.active = this._pageActive;
|
|
116
|
+
|
|
115
117
|
disposeWidget($page._rootWidget);
|
|
116
118
|
this._disposers.forEach((dispose) => dispose());
|
|
117
119
|
},
|
|
@@ -152,8 +154,9 @@ export function createPage(
|
|
|
152
154
|
async onLoad(options) {
|
|
153
155
|
const $page = this._getInstance();
|
|
154
156
|
setConfig({ currentPageId: $page.uuid });
|
|
155
|
-
app.__internal__.activePage = $page;
|
|
156
157
|
this._pageActive = true;
|
|
158
|
+
$page.__internal__.active = this._pageActive;
|
|
159
|
+
app.__internal__.activePage = $page;
|
|
157
160
|
|
|
158
161
|
this._query = decodePageQuery(options || {});
|
|
159
162
|
|
|
@@ -184,8 +187,9 @@ export function createPage(
|
|
|
184
187
|
async onShow() {
|
|
185
188
|
const $page = this._getInstance();
|
|
186
189
|
setConfig({ currentPageId: $page.uuid });
|
|
187
|
-
app.__internal__.activePage = $page;
|
|
188
190
|
this._pageActive = true;
|
|
191
|
+
$page.__internal__.active = this._pageActive;
|
|
192
|
+
app.__internal__.activePage = $page;
|
|
189
193
|
|
|
190
194
|
await this.beforePageCustomLaunch?.(this._query)
|
|
191
195
|
|
|
@@ -198,6 +202,7 @@ export function createPage(
|
|
|
198
202
|
const hook = lifecycle.onHide || lifecycle.onPageHide;
|
|
199
203
|
hook?.call?.($page);
|
|
200
204
|
this._pageActive = false;
|
|
205
|
+
$page.__internal__.active = this._pageActive;
|
|
201
206
|
|
|
202
207
|
// 触发页面节点事件
|
|
203
208
|
this.invokeEventHandler(id, 'hide');
|
package/template/mp/page/api.js
CHANGED
|
@@ -180,7 +180,8 @@ module.exports = function (options) {
|
|
|
180
180
|
},
|
|
181
181
|
{
|
|
182
182
|
test: /\.(js|jsx)$/,
|
|
183
|
-
exclude:
|
|
183
|
+
exclude:
|
|
184
|
+
/node_modules\/(?!(@cloudbase\/weda-ui)|(@tcwd\/vuera)|(@tcwd\/weapps-core)|(@react-spring)|(@react-hookz))|gsd-kbone-react/,
|
|
184
185
|
use: ['happypack/loader?id=babel'],
|
|
185
186
|
},
|
|
186
187
|
{
|