@tencentcloud/chat-uikit-uniapp
Version:
TUIKit 是基于 IM SDK 实现的一套 UI 组件,其包含会话、聊天、群组、个人资料等功能,基于这些精心设计的 UI 组件,您可以快速构建优雅的、可靠的、可扩展的 Chat 应用。
37 lines (32 loc) • 749 B
text/typescript
import { TUIGlobal } from '@tencentcloud/universal-api';
import TOAST_TYPE from './type';
interface IToast {
message: string;
type?: string;
duration?: number;
}
const Toast = (options: IToast): void => {
TUIGlobal.showToast({
title: options.message || 'Toast',
duration: options.duration || 1500,
icon: handleIconType(options.type),
});
};
const handleIconType = (type: string | undefined) => {
if (!type) {
return 'none';
}
switch (type) {
case TOAST_TYPE.ERROR:
return 'none';
case TOAST_TYPE.WARNING:
return 'none';
case TOAST_TYPE.SUCCESS:
return 'success';
case TOAST_TYPE.NORMAL:
return 'none';
default:
return 'none';
}
};
export { Toast, TOAST_TYPE };