Skip to content

FEATURE: prompt组件增加确认和取消注入或回调 #5946

Closed
@dongivan

Description

@dongivan

Version

Vben Admin V5

Description

现在prompt弹出后只能用鼠标点击确认。

Proposed Solution

  1. 建议增加 provide 注入确认和取消方法,这样可以在组件内 inject 后在合适的时机调用。

  2. 建议接口增加一个重载:

export async function prompt<T = any>(
  (confirm: (value?: T) => void, cancel: () => void) => Omit<AlertProps, 'beforeClose'> & {
    beforeClose?: (
      scope: BeforeCloseScope & {
        /** 输入组件的当前值 */
        value: T;
      },
    ) => boolean | Promise<boolean | undefined> | undefined;
    component?: Component;
    componentProps?: Recordable<any>;
    defaultValue?: T;
    modelPropName?: string;
  },
): Promise<T | undefined>;

这样,可以在 componentProps 中增加事件响应,比如监听 Input 的回车后提交。

Alternatives Considered

No response

Additional Context

No response

Validations

  • Read the docs
  • Ensure the code is up to date. (Some issues have been fixed in the latest version)
  • I have searched the existing issues and checked that my issue does not duplicate any existing issues.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions