mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
feat: 新增forceSilenceInsideError环境变量支持屏蔽组件中展示msg信息 (#8722)
* feat: 支持屏蔽组件中展示msg信息,默认展示 * feat: 提交遗漏字段 * 修改字段名,增加注释 --------- Co-authored-by: zhaojianhui <zhaojianhui@baidu.com>
This commit is contained in:
parent
1f1ce12d73
commit
e44425b356
@ -28,6 +28,8 @@ export interface wsObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface RendererEnv {
|
export interface RendererEnv {
|
||||||
|
/* 强制隐藏组件内部的报错信息,会覆盖组件内部属性 */
|
||||||
|
forceSilenceInsideError?: boolean;
|
||||||
session?: string;
|
session?: string;
|
||||||
fetcher: (api: Api, data?: any, options?: object) => Promise<Payload>;
|
fetcher: (api: Api, data?: any, options?: object) => Promise<Payload>;
|
||||||
isCancel: (val: any) => boolean;
|
isCancel: (val: any) => boolean;
|
||||||
|
@ -50,5 +50,7 @@ export const env: RenderOptions = {
|
|||||||
toast[type]
|
toast[type]
|
||||||
? toast[type](msg, type === 'error' ? '系统错误' : '系统消息')
|
? toast[type](msg, type === 'error' ? '系统错误' : '系统消息')
|
||||||
: console.warn('[Notify]', type, msg);
|
: console.warn('[Notify]', type, msg);
|
||||||
}
|
},
|
||||||
|
/* 强制隐藏组件内部的报错信息,会覆盖组件内部属性 */
|
||||||
|
forceSilenceInsideError: false
|
||||||
};
|
};
|
||||||
|
@ -500,6 +500,7 @@ export default class Dialog extends React.Component<DialogProps> {
|
|||||||
const {
|
const {
|
||||||
store,
|
store,
|
||||||
render,
|
render,
|
||||||
|
env,
|
||||||
classnames: cx,
|
classnames: cx,
|
||||||
showErrorMsg,
|
showErrorMsg,
|
||||||
showLoading,
|
showLoading,
|
||||||
@ -514,7 +515,9 @@ export default class Dialog extends React.Component<DialogProps> {
|
|||||||
{showLoading !== false ? (
|
{showLoading !== false ? (
|
||||||
<Spinner size="sm" key="info" show={store.loading} />
|
<Spinner size="sm" key="info" show={store.loading} />
|
||||||
) : null}
|
) : null}
|
||||||
{store.error && showErrorMsg !== false ? (
|
{!env.forceSilenceInsideError &&
|
||||||
|
store.error &&
|
||||||
|
showErrorMsg !== false ? (
|
||||||
<span className={cx('Dialog-error')}>{store.msg}</span>
|
<span className={cx('Dialog-error')}>{store.msg}</span>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
@ -491,6 +491,7 @@ export default class Drawer extends React.Component<DrawerProps> {
|
|||||||
const {
|
const {
|
||||||
store,
|
store,
|
||||||
render,
|
render,
|
||||||
|
env,
|
||||||
classnames: cx,
|
classnames: cx,
|
||||||
showErrorMsg,
|
showErrorMsg,
|
||||||
footerClassName
|
footerClassName
|
||||||
@ -501,7 +502,7 @@ export default class Drawer extends React.Component<DrawerProps> {
|
|||||||
{store.loading || store.error ? (
|
{store.loading || store.error ? (
|
||||||
<div className={cx('Drawer-info')}>
|
<div className={cx('Drawer-info')}>
|
||||||
<Spinner size="sm" key="info" show={store.loading} />
|
<Spinner size="sm" key="info" show={store.loading} />
|
||||||
{showErrorMsg && store.error ? (
|
{!env.forceSilenceInsideError && showErrorMsg && store.error ? (
|
||||||
<span className={cx('Drawer-error')}>{store.msg}</span>
|
<span className={cx('Drawer-error')}>{store.msg}</span>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
@ -853,6 +853,7 @@ export default class Page extends React.Component<PageProps> {
|
|||||||
body,
|
body,
|
||||||
bodyClassName,
|
bodyClassName,
|
||||||
render,
|
render,
|
||||||
|
env,
|
||||||
aside,
|
aside,
|
||||||
asideClassName,
|
asideClassName,
|
||||||
classnames: cx,
|
classnames: cx,
|
||||||
@ -896,7 +897,9 @@ export default class Page extends React.Component<PageProps> {
|
|||||||
loadingConfig={loadingConfig}
|
loadingConfig={loadingConfig}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{store.error && showErrorMsg !== false ? (
|
{!env.forceSilenceInsideError &&
|
||||||
|
store.error &&
|
||||||
|
showErrorMsg !== false ? (
|
||||||
<Alert
|
<Alert
|
||||||
level="danger"
|
level="danger"
|
||||||
showCloseButton
|
showCloseButton
|
||||||
|
@ -785,6 +785,7 @@ export default class Service extends React.Component<ServiceProps> {
|
|||||||
style,
|
style,
|
||||||
store,
|
store,
|
||||||
render,
|
render,
|
||||||
|
env,
|
||||||
classPrefix: ns,
|
classPrefix: ns,
|
||||||
classnames: cx,
|
classnames: cx,
|
||||||
loadingConfig,
|
loadingConfig,
|
||||||
@ -793,7 +794,9 @@ export default class Service extends React.Component<ServiceProps> {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cx(`${ns}Service`, className)} style={style}>
|
<div className={cx(`${ns}Service`, className)} style={style}>
|
||||||
{store.error && showErrorMsg !== false ? (
|
{!env.forceSilenceInsideError &&
|
||||||
|
store.error &&
|
||||||
|
showErrorMsg !== false ? (
|
||||||
<Alert
|
<Alert
|
||||||
level="danger"
|
level="danger"
|
||||||
showCloseButton
|
showCloseButton
|
||||||
|
Loading…
Reference in New Issue
Block a user