Commit 34fe256f authored by 王玉鑫's avatar 王玉鑫

feat: message提示时长修改

parent f3bf8cd1
import { ElMessage } from 'element-plus'; import {
ElMessage,
type MessageOptionsWithType,
type MessageParamsWithType,
type messageType,
} from 'element-plus';
import 'element-plus/theme-chalk/el-message.css'; import 'element-plus/theme-chalk/el-message.css';
/** /**
* el-message提示 * el-message提示
*/ */
export function useMessage() { export function useMessage() {
const commonOptions: MessageOptionsWithType = {
offset: 50,
duration: 1000,
};
const fn = (type: messageType) => {
return (options: MessageParamsWithType) => {
return ElMessage[type]({
...commonOptions,
...(typeof options === 'string' ? { message: options } : options),
});
};
};
return { return {
message: { message: {
success: (message: string) => { success: fn('success'),
ElMessage({ error: fn('error'),
message, info: fn('info'),
offset: 50, warning: fn('warning'),
type: 'success',
});
},
error: (message: string) => {
ElMessage({
message,
offset: 50,
type: 'error',
});
},
warning: (message: string) => {
ElMessage({
message,
offset: 50,
type: 'warning',
});
},
info: (message: string) => {
ElMessage({
message,
offset: 50,
type: 'info',
});
},
}, },
}; };
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment