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';
/**
* el-message提示
*/
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 {
message: {
success: (message: string) => {
ElMessage({
message,
offset: 50,
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',
});
},
success: fn('success'),
error: fn('error'),
info: fn('info'),
warning: fn('warning'),
},
};
}
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