mirror of https://github.com/msgbyte/tailchat
refactor: 错误抛出与样式管理
parent
2af5f16e73
commit
6339efcba5
@ -0,0 +1,31 @@
|
|||||||
|
import { buildRegFn } from './buildRegFn';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用UI api设置
|
||||||
|
*/
|
||||||
|
|
||||||
|
type ToastsType = 'info' | 'success' | 'error' | 'warning';
|
||||||
|
export const [showToasts, setToasts] =
|
||||||
|
buildRegFn<(message: string, type?: ToastsType) => void>('toasts');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一个封装方法, 用于直接抛出错误
|
||||||
|
* @param error 错误信息
|
||||||
|
*/
|
||||||
|
export function showErrorToasts(error: Error) {
|
||||||
|
let msg = '';
|
||||||
|
if (error instanceof Error) {
|
||||||
|
msg = error.message;
|
||||||
|
} else {
|
||||||
|
msg = String(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
showToasts(msg, 'error');
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AlertOptions {
|
||||||
|
message: React.ReactNode;
|
||||||
|
onConfirm?: () => void | Promise<void>;
|
||||||
|
}
|
||||||
|
export const [showAlert, setAlert] =
|
||||||
|
buildRegFn<(options: AlertOptions) => void>('alert');
|
@ -0,0 +1,2 @@
|
|||||||
|
@import "./overwrite.less";
|
||||||
|
@import "./dark.less";
|
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* 这里主要是处理tailwindcss与 antd 一起用的时候的兼容问题
|
||||||
|
* 与重写部分antd的样式
|
||||||
|
*/
|
||||||
|
|
||||||
|
.ant-message .anticon {
|
||||||
|
vertical-align: text-top;
|
||||||
|
}
|
Loading…
Reference in New Issue