alemonjs 2.1.0-alpha.47 → 2.1.0-alpha.48
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.
|
@@ -5,7 +5,7 @@ import 'yaml';
|
|
|
5
5
|
import { showErrorModule } from '../core/utils.js';
|
|
6
6
|
import { useMessage } from './hook-use-api.js';
|
|
7
7
|
|
|
8
|
-
const createCallHandler =
|
|
8
|
+
const createCallHandler = valueEvent => {
|
|
9
9
|
const [message] = useMessage(valueEvent);
|
|
10
10
|
// 开始处理 heandler
|
|
11
11
|
const callHandler = (currents, nextEvent) => {
|
|
@@ -33,6 +33,13 @@ const expendEventRoute = (valueEvent, select, nextCycle) => {
|
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
const node = nodes[idx - 1];
|
|
36
|
+
if (node?.selects) {
|
|
37
|
+
const selects = Array.isArray(node.selects) ? node.selects : [node.selects];
|
|
38
|
+
if (!selects.includes(select)) {
|
|
39
|
+
void nextNode();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
36
43
|
// 正则匹配
|
|
37
44
|
if (EventMessageText.includes(select) && node.regular) {
|
|
38
45
|
const reg = new RegExp(node.regular);
|
|
@@ -57,7 +64,7 @@ const expendEventRoute = (valueEvent, select, nextCycle) => {
|
|
|
57
64
|
try {
|
|
58
65
|
const currents = [];
|
|
59
66
|
for (const item of currentsAndMiddleware) {
|
|
60
|
-
const app = isAsyncFunction(item) ?
|
|
67
|
+
const app = isAsyncFunction(item) ? await item() : item();
|
|
61
68
|
// 没有 default。因为是 import x from './';
|
|
62
69
|
// 中间件也有 selects。
|
|
63
70
|
// 如果 发现 和当前要处理的 selects 不匹配。
|
|
@@ -90,10 +97,6 @@ const expendEventRoute = (valueEvent, select, nextCycle) => {
|
|
|
90
97
|
};
|
|
91
98
|
void nextNode();
|
|
92
99
|
};
|
|
93
|
-
if (routes.length === 0) {
|
|
94
|
-
nextCycle();
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
100
|
void processChildren(routes, [], nextCycle);
|
|
98
101
|
};
|
|
99
102
|
|
package/lib/app/load.js
CHANGED
|
@@ -12,17 +12,17 @@ type ChildrenCycle = {
|
|
|
12
12
|
* 创建时
|
|
13
13
|
* @returns
|
|
14
14
|
*/
|
|
15
|
-
onCreated?: () =>
|
|
15
|
+
onCreated?: () => void | Promise<void>;
|
|
16
16
|
/**
|
|
17
17
|
* 挂载时。得到属于自己的 store
|
|
18
18
|
* @returns
|
|
19
19
|
*/
|
|
20
|
-
onMounted?: (store: StroreParam) =>
|
|
20
|
+
onMounted?: (store: StroreParam) => void | Promise<void>;
|
|
21
21
|
/**
|
|
22
22
|
* 卸载时
|
|
23
23
|
* @returns
|
|
24
24
|
*/
|
|
25
|
-
unMounted?: (error: any) =>
|
|
25
|
+
unMounted?: (error: any) => void | Promise<void>;
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
28
|
* 控制生命周期
|
|
@@ -52,6 +52,7 @@ type OnMiddlewareValue<C, T extends EventKeys> = {
|
|
|
52
52
|
};
|
|
53
53
|
type ResponseRoute = {
|
|
54
54
|
regular?: RegExp;
|
|
55
|
+
selects?: EventKeys | EventKeys[];
|
|
55
56
|
handler: () => Promise<any>;
|
|
56
57
|
children?: ResponseRoute[];
|
|
57
58
|
};
|
|
@@ -62,7 +63,7 @@ type childrenCallbackRes = {
|
|
|
62
63
|
response?: ReturnType<DefineResponseFunc>;
|
|
63
64
|
};
|
|
64
65
|
type childrenCallback = ChildrenCycle & {
|
|
65
|
-
register?: () => (
|
|
66
|
+
register?: () => (childrenCallbackRes | void) | Promise<childrenCallbackRes | void>;
|
|
66
67
|
};
|
|
67
68
|
type DefineChildrenCallback = (() => Promise<childrenCallback> | childrenCallback) | childrenCallback;
|
|
68
69
|
/**
|