From 5e07b02c9ceab10efa0c2aa53904176ed3b07e93 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sun, 26 Jun 2022 11:38:49 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=A2=9E=E5=BC=BA=E4=BA=86tailchat?= =?UTF-8?q?.d.ts=E7=9A=84=E7=B1=BB=E5=9E=8B=E5=A3=B0=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/plugin/component/index.tsx | 2 ++ web/src/utils/jwt-helper.ts | 3 ++- web/tailchat.d.ts | 39 +++++++++++++++++++++++++++--- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/web/src/plugin/component/index.tsx b/web/src/plugin/component/index.tsx index 690a6e34..246f7f01 100644 --- a/web/src/plugin/component/index.tsx +++ b/web/src/plugin/component/index.tsx @@ -10,6 +10,7 @@ export { Table, Switch, Tooltip, + notification, } from 'antd'; export { Avatar } from 'tailchat-design'; export const TextArea = Input.TextArea; @@ -46,3 +47,4 @@ export { GroupPanelSelector } from '@/components/GroupPanelSelector'; export { Emoji } from '@/components/Emoji'; export { PortalAdd, PortalRemove } from '@/components/Portal'; export { ErrorBoundary } from '@/components/ErrorBoundary'; +export { UserName } from '@/components/UserName'; diff --git a/web/src/utils/jwt-helper.ts b/web/src/utils/jwt-helper.ts index a8932e29..10b20220 100644 --- a/web/src/utils/jwt-helper.ts +++ b/web/src/utils/jwt-helper.ts @@ -46,8 +46,9 @@ export async function getUserJWT(): Promise { } export interface JWTUserInfoData { + _id?: string; nickname?: string; - uuid?: string; + email?: string; avatar?: string; } /** diff --git a/web/tailchat.d.ts b/web/tailchat.d.ts index 879a292a..cc4badf7 100644 --- a/web/tailchat.d.ts +++ b/web/tailchat.d.ts @@ -51,7 +51,12 @@ declare module '@capital/common' { export const getGlobalState: any; - export const getJWTUserInfo: any; + export const getJWTUserInfo: () => Promise<{ + _id?: string; + nickname?: string; + email?: string; + avatar?: string; + }>; export const dataUrlToFile: any; @@ -65,7 +70,17 @@ declare module '@capital/common' { export const getServiceUrl: () => string; - export const getCachedUserInfo: any; + export const getCachedUserInfo: ( + userId: string, + refetch?: boolean + ) => Promise<{ + _id: string; + email: string; + nickname: string; + discriminator: string; + avatar: string | null; + temporary: boolean; + }>; export const getCachedConverseInfo: any; @@ -107,7 +122,10 @@ declare module '@capital/common' { export const useCurrentUserInfo: any; - export const createPluginRequest: any; + export const createPluginRequest: (pluginName: string) => { + get: (actionName: string, config?: any) => Promise; + post: (actionName: string, data?: any, config?: any) => Promise; + }; export const postRequest: any; @@ -137,7 +155,10 @@ declare module '@capital/common' { export const regChatInputAction: any; - export const regSocketEventListener: any; + export const regSocketEventListener: (item: { + eventName: string; + eventFn: (...args: any[]) => void; + }) => void; export const pluginColorScheme: any; @@ -182,6 +203,11 @@ declare module '@capital/component' { export const Tooltip: any; + /** + * @link https://ant.design/components/notification-cn/ + */ + export const notification: any; + export const Avatar: any; export const TextArea: any; @@ -237,4 +263,9 @@ declare module '@capital/component' { export const PortalRemove: any; export const ErrorBoundary: any; + + export const UserName: React.FC<{ + userId: string; + className?: string; + }>; }