From cb1ae34f1120d2555ff039fc945235c3f45e13a8 Mon Sep 17 00:00:00 2001 From: vben Date: Thu, 12 Nov 2020 22:55:30 +0800 Subject: [PATCH] fix: fix notify type error --- src/components/Menu/src/MenuContent.tsx | 9 +++--- src/hooks/web/useMessage.tsx | 41 ++++++++----------------- src/router/index.ts | 2 +- 3 files changed, 17 insertions(+), 35 deletions(-) diff --git a/src/components/Menu/src/MenuContent.tsx b/src/components/Menu/src/MenuContent.tsx index d4321a14..22d10a28 100644 --- a/src/components/Menu/src/MenuContent.tsx +++ b/src/components/Menu/src/MenuContent.tsx @@ -40,8 +40,8 @@ export default defineComponent({ } function renderTag() { - const { item, showTitle } = props; - if (!item || showTitle) return null; + const { item, showTitle, isTop } = props; + if (!item || showTitle || isTop) return null; const { tag } = item; if (!tag) return null; @@ -60,16 +60,15 @@ export default defineComponent({ if (!props.item) { return null; } - const { showTitle, isTop } = props; + const { showTitle } = props; const { name, icon } = props.item; const searchValue = props.searchValue || ''; const index = name.indexOf(searchValue); const beforeStr = name.substr(0, index); const afterStr = name.substr(index + searchValue.length); - let cls = showTitle ? ['show-title'] : ['basic-menu__name']; + const cls = showTitle ? ['show-title'] : ['basic-menu__name']; - isTop && !showTitle && (cls = []); return ( <> {renderIcon(icon!)} diff --git a/src/hooks/web/useMessage.tsx b/src/hooks/web/useMessage.tsx index e6cf5b43..a2380ec1 100644 --- a/src/hooks/web/useMessage.tsx +++ b/src/hooks/web/useMessage.tsx @@ -1,43 +1,26 @@ import type { ModalFunc, ModalFuncProps } from 'ant-design-vue/lib/modal/Modal'; import type { MessageApi } from 'ant-design-vue/lib/message'; -import type { VNodeTypes, CSSProperties } from 'vue'; import { Modal, message as Message, notification } from 'ant-design-vue'; import { InfoCircleFilled, CheckCircleFilled, CloseCircleFilled } from '@ant-design/icons-vue'; import { useSetting } from '/@/hooks/core/useSetting'; +import { ArgsProps, ConfigProps } from 'ant-design-vue/lib/notification'; -export interface ArgsProps { - message: VNodeTypes; - description?: VNodeTypes; - btn?: VNodeTypes; - key?: string; - onClose?: () => void; - duration?: number | null; - icon?: VNodeTypes; - placement?: NotificationPlacement; - style?: CSSProperties; - prefixCls?: string; - class?: string; - readonly type?: IconType; - onClick?: () => void; - top?: number; - bottom?: number; - getContainer?: () => HTMLElement; - closeIcon?: VNodeTypes; +export interface NotifyApi { + info(config: ArgsProps): void; + success(config: ArgsProps): void; + error(config: ArgsProps): void; + warn(config: ArgsProps): void; + warning(config: ArgsProps): void; + open(args: ArgsProps): void; + close(key: String): void; + config(options: ConfigProps): void; + destroy(): void; } export declare type NotificationPlacement = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight'; export declare type IconType = 'success' | 'info' | 'error' | 'warning'; -export interface ConfigProps { - top?: string | number; - bottom?: string | number; - duration?: number; - placement?: NotificationPlacement; - getContainer?: () => HTMLElement; - closeIcon?: VNodeTypes; -} - export interface ModalOptionsEx extends Omit { iconType: 'warning' | 'success' | 'error' | 'info'; } @@ -118,7 +101,7 @@ notification.config({ export function useMessage() { return { createMessage: Message as MessageApi, - notification: notification as (arg: ArgsProps) => void, + notification: notification as NotifyApi, createConfirm: createConfirm, createSuccessModal, createErrorModal, diff --git a/src/router/index.ts b/src/router/index.ts index dfd697ef..54246eca 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -37,7 +37,7 @@ export function resetRouter() { router.getRoutes().forEach((route) => { const { name } = route; if (name && !resetWhiteNameList.includes(name as string)) { - router.removeRoute(name); + router.hasRoute(name) && router.removeRoute(name); } }); } -- GitLab