123456789101112131415161718192021222324252627 |
- import { ElMessage } from 'element-plus';
- let msgBoxInstance: any = null;
- /**
- * [showMessage 统一封装消息]
- *
- * @return {[params]} [return description]
- */
- export const showMessage = (params: {
- type: string;
- message: string;
- icon?: string;
- duration?: number;
- }) => {
- if (msgBoxInstance) {
- msgBoxInstance.close();
- }
- msgBoxInstance = ElMessage(params as any);
- };
- export const safeJsonParse = (val: string, defaultValue?: any) => {
- try {
- return JSON.parse(val);
- } catch {
- return defaultValue ?? {};
- }
- };
|