fix: 修复弹窗可多次点击问题 (#5284)

This commit is contained in:
liaoxuezhi 2022-09-01 21:35:06 +08:00 committed by RUNZE LU
parent 4cbb23b5aa
commit 478aef0fdb
3 changed files with 20 additions and 7 deletions

View File

@ -396,8 +396,8 @@ export class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
let props = {
...theme.getRendererConfig(renderer.name),
...restSchema,
...chainEvents(rest, restSchema),
...exprProps,
...chainEvents(rest, restSchema),
// value: defaultValue, // 备注: 此处并没有将value传递给渲染器
defaultData: restSchema.defaultData ?? defaultData,
defaultValue: restSchema.defaultValue ?? defaultValue,

View File

@ -245,18 +245,19 @@ export default class Dialog extends React.Component<DialogProps> {
handleActionSensor(p: Promise<any>) {
const {store} = this.props;
const origin = store.busying;
store.markBusying(true);
// clear error
store.updateMessage();
p.then(() => {
store.markBusying(false);
store.markBusying(origin);
}).catch(e => {
if (this.isDead) {
return;
}
store.updateMessage(e.message, true);
store.markBusying(false);
store.markBusying(origin);
});
}
@ -730,6 +731,9 @@ export class DialogRenderer extends Dialog {
}
if (targets.length) {
store.markBusying(true);
store.updateMessage();
Promise.all(
targets.map(target =>
target.doAction(
@ -755,10 +759,14 @@ export class DialogRenderer extends Dialog {
? this.handleSelfClose()
: this.closeTarget(action.close);
}
store.markBusying(false);
})
.catch(reason => {
if (this.isDead) {
return;
}
store.updateMessage(reason.message, true);
throw reason;
store.markBusying(false);
});
return true;

View File

@ -291,15 +291,16 @@ export default class Drawer extends React.Component<DrawerProps> {
handleActionSensor(p: Promise<any>) {
const {store} = this.props;
const origin = store.busying;
store.markBusying(true);
// clear error
store.updateMessage();
p.then(() => {
store.markBusying(false);
store.markBusying(origin);
}).catch(e => {
store.updateMessage(e.message, true);
store.markBusying(false);
store.markBusying(origin);
});
}
@ -734,6 +735,9 @@ export class DrawerRenderer extends Drawer {
}
if (targets.length) {
store.markBusying(true);
store.updateMessage();
Promise.all(
targets.map(target =>
target.doAction(
@ -759,10 +763,11 @@ export class DrawerRenderer extends Drawer {
? this.handleSelfClose()
: this.closeTarget(action.close);
}
store.markBusying(false);
})
.catch(reason => {
store.updateMessage(reason.message, true);
throw reason;
store.markBusying(false);
});
return true;