2019-06-23 03:35:23 -07:00
|
|
|
import Vue from 'vue';
|
|
|
|
|
|
|
|
import { Notification } from 'element-ui';
|
|
|
|
import { ElNotificationOptions } from 'element-ui/types/notification';
|
2021-05-05 17:46:33 -07:00
|
|
|
import mixins from 'vue-typed-mixins';
|
|
|
|
|
|
|
|
import { externalHooks } from '@/components/mixins/externalHooks';
|
|
|
|
|
2019-06-23 03:35:23 -07:00
|
|
|
|
|
|
|
// export const showMessage = {
|
2021-05-05 17:46:33 -07:00
|
|
|
export const showMessage = mixins(externalHooks).extend({
|
2019-06-23 03:35:23 -07:00
|
|
|
methods: {
|
|
|
|
$showMessage (messageData: ElNotificationOptions) {
|
|
|
|
messageData.dangerouslyUseHTMLString = true;
|
|
|
|
if (messageData.position === undefined) {
|
|
|
|
messageData.position = 'bottom-right';
|
|
|
|
}
|
|
|
|
|
|
|
|
return Notification(messageData);
|
|
|
|
},
|
|
|
|
$showError (error: Error, title: string, message: string) {
|
|
|
|
this.$showMessage({
|
|
|
|
title,
|
|
|
|
message: `${message}<br /><i>${error.message}</i>`,
|
|
|
|
type: 'error',
|
|
|
|
duration: 0,
|
|
|
|
});
|
2021-05-05 17:46:33 -07:00
|
|
|
this.$externalHooks().run('showMessage.showError', { title, message, errorMessage: error.message });
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|