Commit 154ebc3d96f73bb3ceab99ea0229a3619d585aba

Authored by 无木
1 parent 0acc4ab2

fix(use-message): `content` not support vNode

修复封装的`useMessage`部分函数中`content`不支持vNode类型以及`createConfirm`不支持html的问题
Showing 1 changed file with 7 additions and 1 deletions
src/hooks/web/useMessage.tsx
... ... @@ -5,6 +5,7 @@ import { InfoCircleFilled, CheckCircleFilled, CloseCircleFilled } from '@ant-des
5 5  
6 6 import { ArgsProps, ConfigProps } from 'ant-design-vue/lib/notification';
7 7 import { useI18n } from './useI18n';
  8 +import { isString } from '/@/utils/is';
8 9  
9 10 export interface NotifyApi {
10 11 info(config: ArgsProps): void;
... ... @@ -46,7 +47,11 @@ function getIcon(iconType: string) {
46 47 }
47 48  
48 49 function renderContent({ content }: Pick<ModalOptionsEx, 'content'>) {
49   - return <div innerHTML={`<div>${content as string}</div>`}></div>;
  50 + if (isString(content)) {
  51 + return <div innerHTML={`<div>${content as string}</div>`}></div>;
  52 + } else {
  53 + return content;
  54 + }
50 55 }
51 56  
52 57 /**
... ... @@ -59,6 +64,7 @@ function createConfirm(options: ModalOptionsEx): ConfirmOptions {
59 64 centered: true,
60 65 icon: getIcon(iconType),
61 66 ...options,
  67 + content: renderContent(options),
62 68 };
63 69 return Modal.confirm(opt) as unknown as ConfirmOptions;
64 70 }
... ...