mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
feat: 支持屏蔽组件中展示msg信息,默认展示 (#8751)
Co-authored-by: zhaojianhui <zhaojianhui@baidu.com>
This commit is contained in:
parent
90ec85977d
commit
58a66fbdf7
@ -28,6 +28,8 @@ export interface WsObject {
|
||||
}
|
||||
|
||||
export interface RendererEnv {
|
||||
/* 强制隐藏组件内部的报错信息,会覆盖组件内部属性 */
|
||||
forceSilenceInsideError?: boolean;
|
||||
session?: string;
|
||||
fetcher: (api: Api, data?: any, options?: object) => Promise<Payload>;
|
||||
isCancel: (val: any) => boolean;
|
||||
|
@ -51,5 +51,7 @@ export const env: RenderOptions = {
|
||||
toast[type]
|
||||
? toast[type](msg, type === 'error' ? '系统错误' : '系统消息')
|
||||
: console.warn('[Notify]', type, msg);
|
||||
}
|
||||
},
|
||||
/* 强制隐藏组件内部的报错信息,会覆盖组件内部属性 */
|
||||
forceSilenceInsideError: false
|
||||
};
|
||||
|
@ -502,6 +502,7 @@ export default class Dialog extends React.Component<DialogProps> {
|
||||
const {
|
||||
store,
|
||||
render,
|
||||
env,
|
||||
classnames: cx,
|
||||
showErrorMsg,
|
||||
showLoading,
|
||||
@ -517,7 +518,9 @@ export default class Dialog extends React.Component<DialogProps> {
|
||||
{showLoading !== false ? (
|
||||
<Spinner size="sm" key="info" show={store.loading} />
|
||||
) : null}
|
||||
{store.error && showErrorMsg !== false ? (
|
||||
{!env.forceSilenceInsideError &&
|
||||
store.error &&
|
||||
showErrorMsg !== false ? (
|
||||
<span className={cx('Dialog-error')}>{store.msg}</span>
|
||||
) : null}
|
||||
</div>
|
||||
|
@ -497,6 +497,7 @@ export default class Drawer extends React.Component<DrawerProps> {
|
||||
const {
|
||||
store,
|
||||
render,
|
||||
env,
|
||||
classnames: cx,
|
||||
showErrorMsg,
|
||||
footerClassName,
|
||||
@ -515,7 +516,7 @@ export default class Drawer extends React.Component<DrawerProps> {
|
||||
{store.loading || store.error ? (
|
||||
<div className={cx('Drawer-info')}>
|
||||
<Spinner size="sm" key="info" show={store.loading} />
|
||||
{showErrorMsg && store.error ? (
|
||||
{!env.forceSilenceInsideError && showErrorMsg && store.error ? (
|
||||
<span className={cx('Drawer-error')}>{store.msg}</span>
|
||||
) : null}
|
||||
</div>
|
||||
|
@ -924,7 +924,9 @@ export default class Page extends React.Component<PageProps> {
|
||||
loadingConfig={loadingConfig}
|
||||
/>
|
||||
|
||||
{store.error && showErrorMsg !== false ? (
|
||||
{!env.forceSilenceInsideError &&
|
||||
store.error &&
|
||||
showErrorMsg !== false ? (
|
||||
<Alert
|
||||
level="danger"
|
||||
showCloseButton
|
||||
|
@ -793,6 +793,7 @@ export default class Service extends React.Component<ServiceProps> {
|
||||
style,
|
||||
store,
|
||||
render,
|
||||
env,
|
||||
classPrefix: ns,
|
||||
classnames: cx,
|
||||
loadingConfig,
|
||||
@ -801,7 +802,9 @@ export default class Service extends React.Component<ServiceProps> {
|
||||
|
||||
return (
|
||||
<div className={cx(`${ns}Service`, className)} style={style}>
|
||||
{store.error && showErrorMsg !== false ? (
|
||||
{!env.forceSilenceInsideError &&
|
||||
store.error &&
|
||||
showErrorMsg !== false ? (
|
||||
<Alert
|
||||
level="danger"
|
||||
showCloseButton
|
||||
|
Loading…
Reference in New Issue
Block a user