@nocobase/flow-engine 2.0.11 → 2.0.13
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/ViewScopedFlowEngine.js +5 -1
- package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +16 -2
- package/lib/flowEngine.d.ts +19 -0
- package/lib/flowEngine.js +29 -1
- package/lib/utils/parsePathnameToViewParams.js +1 -1
- package/lib/views/useDialog.js +10 -0
- package/lib/views/useDrawer.js +10 -0
- package/package.json +4 -4
- package/src/ViewScopedFlowEngine.ts +4 -0
- package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +18 -2
- package/src/flowEngine.ts +33 -1
- package/src/utils/__tests__/parsePathnameToViewParams.test.ts +7 -0
- package/src/utils/parsePathnameToViewParams.ts +2 -2
- package/src/views/__tests__/useDialog.closeDestroy.test.tsx +1 -0
- package/src/views/useDialog.tsx +14 -0
- package/src/views/useDrawer.tsx +14 -0
- package/src/views/usePage.tsx +1 -0
|
@@ -65,7 +65,11 @@ function createViewScopedEngine(parent) {
|
|
|
65
65
|
"_previousEngine",
|
|
66
66
|
"_nextEngine",
|
|
67
67
|
// getModel 需要在本地执行以确保全局查找时正确遍历整个引擎栈
|
|
68
|
-
"getModel"
|
|
68
|
+
"getModel",
|
|
69
|
+
// 视图销毁回调需要在本地存储,每个视图引擎有自己的销毁逻辑
|
|
70
|
+
"_destroyView",
|
|
71
|
+
"setDestroyView",
|
|
72
|
+
"destroyView"
|
|
69
73
|
]);
|
|
70
74
|
const handler = {
|
|
71
75
|
get(target, prop, receiver) {
|
|
@@ -126,6 +126,15 @@ const openStepSettingsDialog = /* @__PURE__ */ __name(async ({
|
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
128
|
const openView = model.context.viewer[mode].bind(model.context.viewer);
|
|
129
|
+
const resolvedUiModeProps = (0, import_reactive.toJS)(uiModeProps) || {};
|
|
130
|
+
const { zIndex: uiModeZIndex, ...restUiModeProps } = resolvedUiModeProps;
|
|
131
|
+
const resolveDialogZIndex = /* @__PURE__ */ __name((rawZIndex) => {
|
|
132
|
+
var _a2, _b2;
|
|
133
|
+
const nextZIndex = typeof ((_a2 = model.context.viewer) == null ? void 0 : _a2.getNextZIndex) === "function" ? model.context.viewer.getNextZIndex() : (((_b2 = model.context.themeToken) == null ? void 0 : _b2.zIndexPopupBase) || 1e3) + 1;
|
|
134
|
+
const inputZIndex = Number(rawZIndex) || 0;
|
|
135
|
+
return Math.max(nextZIndex, inputZIndex);
|
|
136
|
+
}, "resolveDialogZIndex");
|
|
137
|
+
const mergedZIndex = resolveDialogZIndex(uiModeZIndex);
|
|
129
138
|
const form = (0, import_core.createForm)({
|
|
130
139
|
initialValues: (0, import_utils.compileUiSchema)(scopes, initialValues)
|
|
131
140
|
});
|
|
@@ -141,7 +150,8 @@ const openStepSettingsDialog = /* @__PURE__ */ __name(async ({
|
|
|
141
150
|
title: dialogTitle || t(title),
|
|
142
151
|
width: dialogWidth,
|
|
143
152
|
destroyOnClose: true,
|
|
144
|
-
...
|
|
153
|
+
...restUiModeProps,
|
|
154
|
+
zIndex: mergedZIndex,
|
|
145
155
|
// 透传 navigation,便于变量元信息根据真实视图栈推断父级弹窗
|
|
146
156
|
inputArgs,
|
|
147
157
|
onClose: /* @__PURE__ */ __name(() => {
|
|
@@ -155,7 +165,11 @@ const openStepSettingsDialog = /* @__PURE__ */ __name(async ({
|
|
|
155
165
|
(0, import_react2.useEffect)(() => {
|
|
156
166
|
return (0, import_reactive.autorun)(() => {
|
|
157
167
|
const dynamicProps = (0, import_reactive.toJS)(uiModeProps);
|
|
158
|
-
|
|
168
|
+
const { zIndex, ...restDynamicProps } = dynamicProps || {};
|
|
169
|
+
currentDialog.update({
|
|
170
|
+
...restDynamicProps,
|
|
171
|
+
zIndex: resolveDialogZIndex(zIndex)
|
|
172
|
+
});
|
|
159
173
|
});
|
|
160
174
|
}, []);
|
|
161
175
|
const compiledFormSchema = (0, import_utils.compileUiSchema)(scopes, formSchema);
|
package/lib/flowEngine.d.ts
CHANGED
|
@@ -83,6 +83,12 @@ export declare class FlowEngine {
|
|
|
83
83
|
*/
|
|
84
84
|
private _previousEngine?;
|
|
85
85
|
private _nextEngine?;
|
|
86
|
+
/**
|
|
87
|
+
* 视图销毁回调。由 useDrawer / useDialog 在创建弹窗视图时注册,
|
|
88
|
+
* 供外部(如 afterSuccess)通过引擎栈遍历来关闭多层弹窗。
|
|
89
|
+
* embed 视图(usePage)不注册此回调,因此 destroyView() 会自然跳过。
|
|
90
|
+
*/
|
|
91
|
+
private _destroyView?;
|
|
86
92
|
private _resources;
|
|
87
93
|
/**
|
|
88
94
|
* Data change registry used to coordinate "refresh on active" across view-scoped engines.
|
|
@@ -151,6 +157,18 @@ export declare class FlowEngine {
|
|
|
151
157
|
* 将当前引擎从栈中移除并修复相邻指针(用于视图关闭时)。
|
|
152
158
|
*/
|
|
153
159
|
unlinkFromStack(): void;
|
|
160
|
+
/**
|
|
161
|
+
* 注册视图销毁回调(由 useDrawer / useDialog 调用)。
|
|
162
|
+
*/
|
|
163
|
+
setDestroyView(fn: () => void): void;
|
|
164
|
+
/**
|
|
165
|
+
* 关闭当前引擎关联的弹窗视图。
|
|
166
|
+
* 路由触发的弹窗会先 navigation.back() 清理 URL,再 destroy() 移除元素;
|
|
167
|
+
* 非路由弹窗直接 destroy()。
|
|
168
|
+
* embed 视图不注册回调,调用时返回 false 自动跳过。
|
|
169
|
+
* @returns 是否成功执行
|
|
170
|
+
*/
|
|
171
|
+
destroyView(): boolean;
|
|
154
172
|
/**
|
|
155
173
|
* Get the flow engine context object.
|
|
156
174
|
* @returns {FlowEngineContext} Flow engine context
|
|
@@ -333,6 +351,7 @@ export declare class FlowEngine {
|
|
|
333
351
|
* @returns {Promise<T | null>} Model instance or null
|
|
334
352
|
*/
|
|
335
353
|
loadOrCreateModel<T extends FlowModel = FlowModel>(options: any, extra?: {
|
|
354
|
+
skipSave?: boolean;
|
|
336
355
|
delegateToParent?: boolean;
|
|
337
356
|
delegate?: FlowContext;
|
|
338
357
|
}): Promise<T | null>;
|
package/lib/flowEngine.js
CHANGED
|
@@ -119,6 +119,12 @@ const _FlowEngine = class _FlowEngine {
|
|
|
119
119
|
*/
|
|
120
120
|
__publicField(this, "_previousEngine");
|
|
121
121
|
__publicField(this, "_nextEngine");
|
|
122
|
+
/**
|
|
123
|
+
* 视图销毁回调。由 useDrawer / useDialog 在创建弹窗视图时注册,
|
|
124
|
+
* 供外部(如 afterSuccess)通过引擎栈遍历来关闭多层弹窗。
|
|
125
|
+
* embed 视图(usePage)不注册此回调,因此 destroyView() 会自然跳过。
|
|
126
|
+
*/
|
|
127
|
+
__publicField(this, "_destroyView");
|
|
122
128
|
__publicField(this, "_resources", /* @__PURE__ */ new Map());
|
|
123
129
|
/**
|
|
124
130
|
* Data change registry used to coordinate "refresh on active" across view-scoped engines.
|
|
@@ -258,6 +264,26 @@ const _FlowEngine = class _FlowEngine {
|
|
|
258
264
|
prev._nextEngine = void 0;
|
|
259
265
|
}
|
|
260
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* 注册视图销毁回调(由 useDrawer / useDialog 调用)。
|
|
269
|
+
*/
|
|
270
|
+
setDestroyView(fn) {
|
|
271
|
+
this._destroyView = fn;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* 关闭当前引擎关联的弹窗视图。
|
|
275
|
+
* 路由触发的弹窗会先 navigation.back() 清理 URL,再 destroy() 移除元素;
|
|
276
|
+
* 非路由弹窗直接 destroy()。
|
|
277
|
+
* embed 视图不注册回调,调用时返回 false 自动跳过。
|
|
278
|
+
* @returns 是否成功执行
|
|
279
|
+
*/
|
|
280
|
+
destroyView() {
|
|
281
|
+
if (this._destroyView) {
|
|
282
|
+
this._destroyView();
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
261
287
|
// (已移除)getModelGlobal/forEachModelGlobal/getAllModelsGlobal:不再维护冗余全局遍历 API
|
|
262
288
|
/**
|
|
263
289
|
* Get the flow engine context object.
|
|
@@ -829,7 +855,9 @@ const _FlowEngine = class _FlowEngine {
|
|
|
829
855
|
model = this.createModel(data, extra);
|
|
830
856
|
} else {
|
|
831
857
|
model = this.createModel(options, extra);
|
|
832
|
-
|
|
858
|
+
if (!(extra == null ? void 0 : extra.skipSave)) {
|
|
859
|
+
await model.save();
|
|
860
|
+
}
|
|
833
861
|
}
|
|
834
862
|
if (model.parent) {
|
|
835
863
|
const subModel = model.parent.findSubModel(model.subKey, (m2) => {
|
|
@@ -92,7 +92,7 @@ const parsePathnameToViewParams = /* @__PURE__ */ __name((pathname) => {
|
|
|
92
92
|
} catch (_) {
|
|
93
93
|
parsed = decoded;
|
|
94
94
|
}
|
|
95
|
-
} else if (decoded &&
|
|
95
|
+
} else if (decoded && /^[^=&]+=[^=&]*(?:&[^=&]+=[^=&]*)*$/.test(decoded)) {
|
|
96
96
|
parsed = parseKeyValuePairs(decoded);
|
|
97
97
|
}
|
|
98
98
|
currentView.filterByTk = parsed;
|
package/lib/views/useDialog.js
CHANGED
|
@@ -103,12 +103,15 @@ function useDialog() {
|
|
|
103
103
|
} else {
|
|
104
104
|
ctx.addDelegate(flowContext.engine.context);
|
|
105
105
|
}
|
|
106
|
+
let destroyed = false;
|
|
106
107
|
const currentDialog = {
|
|
107
108
|
type: "dialog",
|
|
108
109
|
inputArgs: config.inputArgs || {},
|
|
109
110
|
preventClose: !!config.preventClose,
|
|
110
111
|
destroy: /* @__PURE__ */ __name((result) => {
|
|
111
112
|
var _a2, _b2, _c2, _d;
|
|
113
|
+
if (destroyed) return;
|
|
114
|
+
destroyed = true;
|
|
112
115
|
(_a2 = config.onClose) == null ? void 0 : _a2.call(config);
|
|
113
116
|
(_b2 = dialogRef.current) == null ? void 0 : _b2.destroy();
|
|
114
117
|
closeFunc == null ? void 0 : closeFunc();
|
|
@@ -154,6 +157,13 @@ function useDialog() {
|
|
|
154
157
|
get: /* @__PURE__ */ __name(() => currentDialog, "get"),
|
|
155
158
|
resolveOnServer: (0, import_variablesParams.createViewRecordResolveOnServer)(ctx, () => (0, import_variablesParams.getViewRecordFromParent)(flowContext, ctx))
|
|
156
159
|
});
|
|
160
|
+
scopedEngine.setDestroyView(() => {
|
|
161
|
+
var _a2, _b2;
|
|
162
|
+
if (config.triggerByRouter && ((_b2 = (_a2 = config.inputArgs) == null ? void 0 : _a2.navigation) == null ? void 0 : _b2.back)) {
|
|
163
|
+
config.inputArgs.navigation.back();
|
|
164
|
+
}
|
|
165
|
+
currentDialog.destroy();
|
|
166
|
+
});
|
|
157
167
|
(0, import_createViewMeta.registerPopupVariable)(ctx, currentDialog);
|
|
158
168
|
const DialogWithContext = (0, import__.observer)(
|
|
159
169
|
() => {
|
package/lib/views/useDrawer.js
CHANGED
|
@@ -122,12 +122,15 @@ function useDrawer() {
|
|
|
122
122
|
} else {
|
|
123
123
|
ctx.addDelegate(flowContext.engine.context);
|
|
124
124
|
}
|
|
125
|
+
let destroyed = false;
|
|
125
126
|
const currentDrawer = {
|
|
126
127
|
type: "drawer",
|
|
127
128
|
inputArgs: config.inputArgs || {},
|
|
128
129
|
preventClose: !!config.preventClose,
|
|
129
130
|
destroy: /* @__PURE__ */ __name((result) => {
|
|
130
131
|
var _a2, _b2, _c, _d;
|
|
132
|
+
if (destroyed) return;
|
|
133
|
+
destroyed = true;
|
|
131
134
|
(_a2 = config.onClose) == null ? void 0 : _a2.call(config);
|
|
132
135
|
(_b2 = drawerRef.current) == null ? void 0 : _b2.destroy();
|
|
133
136
|
closeFunc == null ? void 0 : closeFunc();
|
|
@@ -173,6 +176,13 @@ function useDrawer() {
|
|
|
173
176
|
get: /* @__PURE__ */ __name(() => currentDrawer, "get"),
|
|
174
177
|
resolveOnServer: (0, import_variablesParams.createViewRecordResolveOnServer)(ctx, () => (0, import_variablesParams.getViewRecordFromParent)(flowContext, ctx))
|
|
175
178
|
});
|
|
179
|
+
scopedEngine.setDestroyView(() => {
|
|
180
|
+
var _a2, _b2;
|
|
181
|
+
if (config.triggerByRouter && ((_b2 = (_a2 = config.inputArgs) == null ? void 0 : _a2.navigation) == null ? void 0 : _b2.back)) {
|
|
182
|
+
config.inputArgs.navigation.back();
|
|
183
|
+
}
|
|
184
|
+
currentDrawer.destroy();
|
|
185
|
+
});
|
|
176
186
|
(0, import_createViewMeta.registerPopupVariable)(ctx, currentDrawer);
|
|
177
187
|
const DrawerWithContext = React.memo(
|
|
178
188
|
(0, import__.observer)((props) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/flow-engine",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.13",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A standalone flow engine for NocoBase, managing workflows, models, and actions.",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@formily/antd-v5": "1.x",
|
|
10
10
|
"@formily/reactive": "2.x",
|
|
11
|
-
"@nocobase/sdk": "2.0.
|
|
12
|
-
"@nocobase/shared": "2.0.
|
|
11
|
+
"@nocobase/sdk": "2.0.13",
|
|
12
|
+
"@nocobase/shared": "2.0.13",
|
|
13
13
|
"ahooks": "^3.7.2",
|
|
14
14
|
"dayjs": "^1.11.9",
|
|
15
15
|
"dompurify": "^3.0.2",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
],
|
|
37
37
|
"author": "NocoBase Team",
|
|
38
38
|
"license": "Apache-2.0",
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "3486d15dd3f821411f514b7e0b57e44d942917c9"
|
|
40
40
|
}
|
|
@@ -62,6 +62,10 @@ export function createViewScopedEngine(parent: FlowEngine): FlowEngine {
|
|
|
62
62
|
'_nextEngine',
|
|
63
63
|
// getModel 需要在本地执行以确保全局查找时正确遍历整个引擎栈
|
|
64
64
|
'getModel',
|
|
65
|
+
// 视图销毁回调需要在本地存储,每个视图引擎有自己的销毁逻辑
|
|
66
|
+
'_destroyView',
|
|
67
|
+
'setDestroyView',
|
|
68
|
+
'destroyView',
|
|
65
69
|
]);
|
|
66
70
|
|
|
67
71
|
const handler: ProxyHandler<FlowEngine> = {
|
|
@@ -134,6 +134,17 @@ const openStepSettingsDialog = async ({
|
|
|
134
134
|
};
|
|
135
135
|
|
|
136
136
|
const openView = model.context.viewer[mode].bind(model.context.viewer);
|
|
137
|
+
const resolvedUiModeProps = toJS(uiModeProps) || {};
|
|
138
|
+
const { zIndex: uiModeZIndex, ...restUiModeProps } = resolvedUiModeProps;
|
|
139
|
+
const resolveDialogZIndex = (rawZIndex?: number) => {
|
|
140
|
+
const nextZIndex =
|
|
141
|
+
typeof model.context.viewer?.getNextZIndex === 'function'
|
|
142
|
+
? model.context.viewer.getNextZIndex()
|
|
143
|
+
: (model.context.themeToken?.zIndexPopupBase || 1000) + 1;
|
|
144
|
+
const inputZIndex = Number(rawZIndex) || 0;
|
|
145
|
+
return Math.max(nextZIndex, inputZIndex);
|
|
146
|
+
};
|
|
147
|
+
const mergedZIndex = resolveDialogZIndex(uiModeZIndex);
|
|
137
148
|
|
|
138
149
|
const form = createForm({
|
|
139
150
|
initialValues: compileUiSchema(scopes, initialValues),
|
|
@@ -152,7 +163,8 @@ const openStepSettingsDialog = async ({
|
|
|
152
163
|
title: dialogTitle || t(title),
|
|
153
164
|
width: dialogWidth,
|
|
154
165
|
destroyOnClose: true,
|
|
155
|
-
...
|
|
166
|
+
...restUiModeProps,
|
|
167
|
+
zIndex: mergedZIndex,
|
|
156
168
|
// 透传 navigation,便于变量元信息根据真实视图栈推断父级弹窗
|
|
157
169
|
inputArgs,
|
|
158
170
|
onClose: () => {
|
|
@@ -165,7 +177,11 @@ const openStepSettingsDialog = async ({
|
|
|
165
177
|
useEffect(() => {
|
|
166
178
|
return autorun(() => {
|
|
167
179
|
const dynamicProps = toJS(uiModeProps);
|
|
168
|
-
|
|
180
|
+
const { zIndex, ...restDynamicProps } = dynamicProps || {};
|
|
181
|
+
currentDialog.update({
|
|
182
|
+
...restDynamicProps,
|
|
183
|
+
zIndex: resolveDialogZIndex(zIndex),
|
|
184
|
+
});
|
|
169
185
|
});
|
|
170
186
|
}, []);
|
|
171
187
|
|
package/src/flowEngine.ts
CHANGED
|
@@ -117,6 +117,13 @@ export class FlowEngine {
|
|
|
117
117
|
private _previousEngine?: FlowEngine;
|
|
118
118
|
private _nextEngine?: FlowEngine;
|
|
119
119
|
|
|
120
|
+
/**
|
|
121
|
+
* 视图销毁回调。由 useDrawer / useDialog 在创建弹窗视图时注册,
|
|
122
|
+
* 供外部(如 afterSuccess)通过引擎栈遍历来关闭多层弹窗。
|
|
123
|
+
* embed 视图(usePage)不注册此回调,因此 destroyView() 会自然跳过。
|
|
124
|
+
*/
|
|
125
|
+
private _destroyView?: () => void;
|
|
126
|
+
|
|
120
127
|
private _resources = new Map<string, typeof FlowResource>();
|
|
121
128
|
|
|
122
129
|
/**
|
|
@@ -282,6 +289,28 @@ export class FlowEngine {
|
|
|
282
289
|
}
|
|
283
290
|
}
|
|
284
291
|
|
|
292
|
+
/**
|
|
293
|
+
* 注册视图销毁回调(由 useDrawer / useDialog 调用)。
|
|
294
|
+
*/
|
|
295
|
+
public setDestroyView(fn: () => void): void {
|
|
296
|
+
this._destroyView = fn;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* 关闭当前引擎关联的弹窗视图。
|
|
301
|
+
* 路由触发的弹窗会先 navigation.back() 清理 URL,再 destroy() 移除元素;
|
|
302
|
+
* 非路由弹窗直接 destroy()。
|
|
303
|
+
* embed 视图不注册回调,调用时返回 false 自动跳过。
|
|
304
|
+
* @returns 是否成功执行
|
|
305
|
+
*/
|
|
306
|
+
public destroyView(): boolean {
|
|
307
|
+
if (this._destroyView) {
|
|
308
|
+
this._destroyView();
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
|
|
285
314
|
// (已移除)getModelGlobal/forEachModelGlobal/getAllModelsGlobal:不再维护冗余全局遍历 API
|
|
286
315
|
|
|
287
316
|
/**
|
|
@@ -959,6 +988,7 @@ export class FlowEngine {
|
|
|
959
988
|
async loadOrCreateModel<T extends FlowModel = FlowModel>(
|
|
960
989
|
options,
|
|
961
990
|
extra?: {
|
|
991
|
+
skipSave?: boolean;
|
|
962
992
|
delegateToParent?: boolean;
|
|
963
993
|
delegate?: FlowContext;
|
|
964
994
|
},
|
|
@@ -984,7 +1014,9 @@ export class FlowEngine {
|
|
|
984
1014
|
model = this.createModel<T>(data as any, extra);
|
|
985
1015
|
} else {
|
|
986
1016
|
model = this.createModel<T>(options, extra);
|
|
987
|
-
|
|
1017
|
+
if (!extra?.skipSave) {
|
|
1018
|
+
await model.save();
|
|
1019
|
+
}
|
|
988
1020
|
}
|
|
989
1021
|
if (model.parent) {
|
|
990
1022
|
const subModel = model.parent.findSubModel(model.subKey, (m) => {
|
|
@@ -109,6 +109,13 @@ describe('parsePathnameToViewParams', () => {
|
|
|
109
109
|
expect(result).toEqual([{ viewUid: 'xxx', filterByTk: { id: '1', tenant: 'ac' } }]);
|
|
110
110
|
});
|
|
111
111
|
|
|
112
|
+
test('should parse filterByTk from single key-value encoded segment into object', () => {
|
|
113
|
+
const kv = encodeURIComponent('id=1');
|
|
114
|
+
const path = `/admin/xxx/filterbytk/${kv}`;
|
|
115
|
+
const result = parsePathnameToViewParams(path);
|
|
116
|
+
expect(result).toEqual([{ viewUid: 'xxx', filterByTk: { id: '1' } }]);
|
|
117
|
+
});
|
|
118
|
+
|
|
112
119
|
test('should parse filterByTk from JSON object segment', () => {
|
|
113
120
|
const json = encodeURIComponent('{"id":"1","tenant":"ac"}');
|
|
114
121
|
const path = `/admin/xxx/filterbytk/${json}`;
|
|
@@ -116,8 +116,8 @@ export const parsePathnameToViewParams = (pathname: string): ViewParam[] => {
|
|
|
116
116
|
// 解析失败,按字符串保留
|
|
117
117
|
parsed = decoded;
|
|
118
118
|
}
|
|
119
|
-
} else if (decoded &&
|
|
120
|
-
// 形如 a=b&c=d 的整体段
|
|
119
|
+
} else if (decoded && /^[^=&]+=[^=&]*(?:&[^=&]+=[^=&]*)*$/.test(decoded)) {
|
|
120
|
+
// 形如 a=b 或 a=b&c=d 的整体段
|
|
121
121
|
parsed = parseKeyValuePairs(decoded);
|
|
122
122
|
}
|
|
123
123
|
currentView.filterByTk = parsed;
|
|
@@ -26,6 +26,7 @@ vi.mock('../../ViewScopedFlowEngine', () => ({
|
|
|
26
26
|
createViewScopedEngine: (engine) => ({
|
|
27
27
|
context: new FlowContext(),
|
|
28
28
|
unlinkFromStack: vi.fn(),
|
|
29
|
+
setDestroyView: vi.fn(),
|
|
29
30
|
// mimic real view stack linkage: previousEngine points to the last engine in chain
|
|
30
31
|
previousEngine: (engine as any)?.nextEngine || engine,
|
|
31
32
|
}),
|
package/src/views/useDialog.tsx
CHANGED
|
@@ -89,12 +89,17 @@ export function useDialog() {
|
|
|
89
89
|
ctx.addDelegate(flowContext.engine.context);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
// 幂等保护:防止 FlowPage 路由清理时二次调用 destroy
|
|
93
|
+
let destroyed = false;
|
|
94
|
+
|
|
92
95
|
// 构造 currentDialog 实例
|
|
93
96
|
const currentDialog = {
|
|
94
97
|
type: 'dialog' as const,
|
|
95
98
|
inputArgs: config.inputArgs || {},
|
|
96
99
|
preventClose: !!config.preventClose,
|
|
97
100
|
destroy: (result?: any) => {
|
|
101
|
+
if (destroyed) return;
|
|
102
|
+
destroyed = true;
|
|
98
103
|
config.onClose?.();
|
|
99
104
|
dialogRef.current?.destroy();
|
|
100
105
|
closeFunc?.();
|
|
@@ -140,6 +145,15 @@ export function useDialog() {
|
|
|
140
145
|
get: () => currentDialog,
|
|
141
146
|
resolveOnServer: createViewRecordResolveOnServer(ctx, () => getViewRecordFromParent(flowContext, ctx)),
|
|
142
147
|
});
|
|
148
|
+
// 注册视图销毁回调,供外部(如 afterSuccess)通过引擎栈遍历来关闭多层弹窗。
|
|
149
|
+
// 对路由触发的弹窗:先 navigation.back() 清理 URL(replace 方式),再 destroy() 立即移除元素;
|
|
150
|
+
// 对非路由弹窗:直接 destroy()。destroy() 已做幂等保护,FlowPage 后续清理不会重复执行。
|
|
151
|
+
scopedEngine.setDestroyView(() => {
|
|
152
|
+
if (config.triggerByRouter && config.inputArgs?.navigation?.back) {
|
|
153
|
+
config.inputArgs.navigation.back();
|
|
154
|
+
}
|
|
155
|
+
currentDialog.destroy();
|
|
156
|
+
});
|
|
143
157
|
// 顶层 popup 变量:弹窗记录/数据源/上级弹窗链(去重封装)
|
|
144
158
|
registerPopupVariable(ctx, currentDialog);
|
|
145
159
|
// 内部组件,在 Provider 内部计算 content
|
package/src/views/useDrawer.tsx
CHANGED
|
@@ -118,12 +118,17 @@ export function useDrawer() {
|
|
|
118
118
|
ctx.addDelegate(flowContext.engine.context);
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
// 幂等保护:防止 FlowPage 路由清理时二次调用 destroy
|
|
122
|
+
let destroyed = false;
|
|
123
|
+
|
|
121
124
|
// 构造 currentDrawer 实例
|
|
122
125
|
const currentDrawer = {
|
|
123
126
|
type: 'drawer' as const,
|
|
124
127
|
inputArgs: config.inputArgs || {},
|
|
125
128
|
preventClose: !!config.preventClose,
|
|
126
129
|
destroy: (result?: any) => {
|
|
130
|
+
if (destroyed) return;
|
|
131
|
+
destroyed = true;
|
|
127
132
|
config.onClose?.();
|
|
128
133
|
drawerRef.current?.destroy();
|
|
129
134
|
closeFunc?.();
|
|
@@ -169,6 +174,15 @@ export function useDrawer() {
|
|
|
169
174
|
get: () => currentDrawer,
|
|
170
175
|
resolveOnServer: createViewRecordResolveOnServer(ctx, () => getViewRecordFromParent(flowContext, ctx)),
|
|
171
176
|
});
|
|
177
|
+
// 注册视图销毁回调,供外部(如 afterSuccess)通过引擎栈遍历来关闭多层弹窗。
|
|
178
|
+
// 对路由触发的弹窗:先 navigation.back() 清理 URL(replace 方式),再 destroy() 立即移除元素;
|
|
179
|
+
// 对非路由弹窗:直接 destroy()。destroy() 已做幂等保护,FlowPage 后续清理不会重复执行。
|
|
180
|
+
scopedEngine.setDestroyView(() => {
|
|
181
|
+
if (config.triggerByRouter && config.inputArgs?.navigation?.back) {
|
|
182
|
+
config.inputArgs.navigation.back();
|
|
183
|
+
}
|
|
184
|
+
currentDrawer.destroy();
|
|
185
|
+
});
|
|
172
186
|
// 顶层 popup 变量:弹窗记录/数据源/上级弹窗链(去重封装)
|
|
173
187
|
registerPopupVariable(ctx, currentDrawer);
|
|
174
188
|
|
package/src/views/usePage.tsx
CHANGED
|
@@ -178,6 +178,7 @@ export function usePage() {
|
|
|
178
178
|
// 仅当访问关联字段或前端无本地记录数据时,才交给服务端解析
|
|
179
179
|
resolveOnServer: createViewRecordResolveOnServer(ctx, () => getViewRecordFromParent(flowContext, ctx)),
|
|
180
180
|
});
|
|
181
|
+
// embed 视图不注册 destroyView,afterSuccess 关闭弹窗时自然跳过
|
|
181
182
|
// 顶层 popup 变量:弹窗记录/数据源/上级弹窗链(去重封装)
|
|
182
183
|
registerPopupVariable(ctx, currentPage);
|
|
183
184
|
|