support Notice
support Notice
This commit is contained in:
parent
6cadeba44f
commit
833501a4fa
7 changed files with 32 additions and 25 deletions
|
@ -85,7 +85,7 @@
|
|||
this.$parent.close(this.name);
|
||||
}
|
||||
},
|
||||
created () {
|
||||
mounted () {
|
||||
this.clearCloseTimer();
|
||||
|
||||
if (this.duration !== 0) {
|
||||
|
|
|
@ -7,7 +7,7 @@ const prefixKey = 'ivu_notice_key_';
|
|||
let top = 24;
|
||||
let defaultDuration = 4.5;
|
||||
let noticeInstance;
|
||||
let key = 1;
|
||||
let name = 1;
|
||||
|
||||
const iconTypes = {
|
||||
'info': 'information-circled',
|
||||
|
@ -19,7 +19,7 @@ const iconTypes = {
|
|||
function getNoticeInstance () {
|
||||
noticeInstance = noticeInstance || Notification.newInstance({
|
||||
prefixCls: prefixCls,
|
||||
style: {
|
||||
styles: {
|
||||
top: `${top}px`,
|
||||
right: 0
|
||||
}
|
||||
|
@ -31,12 +31,12 @@ function getNoticeInstance () {
|
|||
function notice (type, options) {
|
||||
const title = options.title || '';
|
||||
const desc = options.desc || '';
|
||||
const noticeKey = options.key || `${prefixKey}${key}`;
|
||||
const noticeKey = options.name || `${prefixKey}${name}`;
|
||||
const onClose = options.onClose || function () {};
|
||||
// todo const btn = options.btn || null;
|
||||
const duration = (options.duration === 0) ? 0 : options.duration || defaultDuration;
|
||||
|
||||
key++;
|
||||
name++;
|
||||
|
||||
let instance = getNoticeInstance();
|
||||
|
||||
|
@ -65,9 +65,9 @@ function notice (type, options) {
|
|||
}
|
||||
|
||||
instance.notice({
|
||||
key: noticeKey.toString(),
|
||||
name: noticeKey.toString(),
|
||||
duration: duration,
|
||||
style: {},
|
||||
styles: {},
|
||||
transitionName: 'move-notice',
|
||||
content: content,
|
||||
onClose: onClose,
|
||||
|
@ -99,11 +99,11 @@ export default {
|
|||
defaultDuration = options.duration;
|
||||
}
|
||||
},
|
||||
close (key) {
|
||||
if (key) {
|
||||
key = key.toString();
|
||||
close (name) {
|
||||
if (name) {
|
||||
name = name.toString();
|
||||
if (noticeInstance) {
|
||||
noticeInstance.remove(key);
|
||||
noticeInstance.remove(name);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -23,7 +23,7 @@ import LoadingBar from './components/loading-bar';
|
|||
import Menu from './components/menu';
|
||||
import Message from './components/message';
|
||||
import Modal from './components/modal';
|
||||
// import Notice from './components/notice';
|
||||
import Notice from './components/notice';
|
||||
import Page from './components/page';
|
||||
import Poptip from './components/poptip';
|
||||
import Progress from './components/progress';
|
||||
|
@ -82,7 +82,7 @@ const iview = {
|
|||
Submenu: Menu.Sub,
|
||||
Message,
|
||||
Modal,
|
||||
// Notice,
|
||||
Notice,
|
||||
iOption: Option,
|
||||
OptionGroup,
|
||||
Page,
|
||||
|
@ -124,7 +124,7 @@ const install = function (Vue, opts = {}) {
|
|||
Vue.prototype.$Loading = LoadingBar;
|
||||
Vue.prototype.$Message = Message;
|
||||
Vue.prototype.$Modal = Modal;
|
||||
// Vue.prototype.$Notice = Notice;
|
||||
Vue.prototype.$Notice = Notice;
|
||||
};
|
||||
|
||||
// auto install
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue