support Notice
support Notice
This commit is contained in:
parent
6cadeba44f
commit
833501a4fa
7 changed files with 32 additions and 25 deletions
|
@ -38,7 +38,7 @@
|
||||||
- [x] Alert
|
- [x] Alert
|
||||||
- [x] Card
|
- [x] Card
|
||||||
- [x] Message
|
- [x] Message
|
||||||
- [ ] Notice
|
- [x] Notice
|
||||||
- [x] Modal
|
- [x] Modal
|
||||||
- [x] Progress
|
- [x] Progress
|
||||||
- [x] Badge
|
- [x] Badge
|
||||||
|
|
|
@ -53,6 +53,7 @@ li + li { border-left: solid 1px #bbb; padding-left: 10px; margin-left: 10px; }
|
||||||
<li><router-link to="/loading-bar">LoadingBar</router-link></li>
|
<li><router-link to="/loading-bar">LoadingBar</router-link></li>
|
||||||
<li><router-link to="/modal">Modal</router-link></li>
|
<li><router-link to="/modal">Modal</router-link></li>
|
||||||
<li><router-link to="/message">Message</router-link></li>
|
<li><router-link to="/message">Message</router-link></li>
|
||||||
|
<li><router-link to="/notice">Notice</router-link></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
|
|
|
@ -176,6 +176,10 @@ const router = new VueRouter({
|
||||||
{
|
{
|
||||||
path: '/message',
|
path: '/message',
|
||||||
component: require('./routers/message.vue')
|
component: require('./routers/message.vue')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/notice',
|
||||||
|
component: require('./routers/notice.vue')
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,19 +1,21 @@
|
||||||
<template>
|
<template>
|
||||||
<i-button @click="pop">Pop</i-button>
|
<i-button type="primary" @click.native="time">打开提醒</i-button>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
pop () {
|
time () {
|
||||||
for (let i = 0; i < 6; i++) {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.$Notice.open({
|
this.$Notice.open({
|
||||||
title: 'test',
|
title: '这是通知标题',
|
||||||
duration: 1.5 + i
|
desc: '这条通知不会自动关闭,需要点击关闭按钮才可以关闭。'
|
||||||
});
|
});
|
||||||
}, i * 500);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
this.$Notice.config({
|
||||||
|
top: 150,
|
||||||
|
duration: 3
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
this.$parent.close(this.name);
|
this.$parent.close(this.name);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
mounted () {
|
||||||
this.clearCloseTimer();
|
this.clearCloseTimer();
|
||||||
|
|
||||||
if (this.duration !== 0) {
|
if (this.duration !== 0) {
|
||||||
|
|
|
@ -7,7 +7,7 @@ const prefixKey = 'ivu_notice_key_';
|
||||||
let top = 24;
|
let top = 24;
|
||||||
let defaultDuration = 4.5;
|
let defaultDuration = 4.5;
|
||||||
let noticeInstance;
|
let noticeInstance;
|
||||||
let key = 1;
|
let name = 1;
|
||||||
|
|
||||||
const iconTypes = {
|
const iconTypes = {
|
||||||
'info': 'information-circled',
|
'info': 'information-circled',
|
||||||
|
@ -19,7 +19,7 @@ const iconTypes = {
|
||||||
function getNoticeInstance () {
|
function getNoticeInstance () {
|
||||||
noticeInstance = noticeInstance || Notification.newInstance({
|
noticeInstance = noticeInstance || Notification.newInstance({
|
||||||
prefixCls: prefixCls,
|
prefixCls: prefixCls,
|
||||||
style: {
|
styles: {
|
||||||
top: `${top}px`,
|
top: `${top}px`,
|
||||||
right: 0
|
right: 0
|
||||||
}
|
}
|
||||||
|
@ -31,12 +31,12 @@ function getNoticeInstance () {
|
||||||
function notice (type, options) {
|
function notice (type, options) {
|
||||||
const title = options.title || '';
|
const title = options.title || '';
|
||||||
const desc = options.desc || '';
|
const desc = options.desc || '';
|
||||||
const noticeKey = options.key || `${prefixKey}${key}`;
|
const noticeKey = options.name || `${prefixKey}${name}`;
|
||||||
const onClose = options.onClose || function () {};
|
const onClose = options.onClose || function () {};
|
||||||
// todo const btn = options.btn || null;
|
// todo const btn = options.btn || null;
|
||||||
const duration = (options.duration === 0) ? 0 : options.duration || defaultDuration;
|
const duration = (options.duration === 0) ? 0 : options.duration || defaultDuration;
|
||||||
|
|
||||||
key++;
|
name++;
|
||||||
|
|
||||||
let instance = getNoticeInstance();
|
let instance = getNoticeInstance();
|
||||||
|
|
||||||
|
@ -65,9 +65,9 @@ function notice (type, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.notice({
|
instance.notice({
|
||||||
key: noticeKey.toString(),
|
name: noticeKey.toString(),
|
||||||
duration: duration,
|
duration: duration,
|
||||||
style: {},
|
styles: {},
|
||||||
transitionName: 'move-notice',
|
transitionName: 'move-notice',
|
||||||
content: content,
|
content: content,
|
||||||
onClose: onClose,
|
onClose: onClose,
|
||||||
|
@ -99,11 +99,11 @@ export default {
|
||||||
defaultDuration = options.duration;
|
defaultDuration = options.duration;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
close (key) {
|
close (name) {
|
||||||
if (key) {
|
if (name) {
|
||||||
key = key.toString();
|
name = name.toString();
|
||||||
if (noticeInstance) {
|
if (noticeInstance) {
|
||||||
noticeInstance.remove(key);
|
noticeInstance.remove(name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import LoadingBar from './components/loading-bar';
|
||||||
import Menu from './components/menu';
|
import Menu from './components/menu';
|
||||||
import Message from './components/message';
|
import Message from './components/message';
|
||||||
import Modal from './components/modal';
|
import Modal from './components/modal';
|
||||||
// import Notice from './components/notice';
|
import Notice from './components/notice';
|
||||||
import Page from './components/page';
|
import Page from './components/page';
|
||||||
import Poptip from './components/poptip';
|
import Poptip from './components/poptip';
|
||||||
import Progress from './components/progress';
|
import Progress from './components/progress';
|
||||||
|
@ -82,7 +82,7 @@ const iview = {
|
||||||
Submenu: Menu.Sub,
|
Submenu: Menu.Sub,
|
||||||
Message,
|
Message,
|
||||||
Modal,
|
Modal,
|
||||||
// Notice,
|
Notice,
|
||||||
iOption: Option,
|
iOption: Option,
|
||||||
OptionGroup,
|
OptionGroup,
|
||||||
Page,
|
Page,
|
||||||
|
@ -124,7 +124,7 @@ const install = function (Vue, opts = {}) {
|
||||||
Vue.prototype.$Loading = LoadingBar;
|
Vue.prototype.$Loading = LoadingBar;
|
||||||
Vue.prototype.$Message = Message;
|
Vue.prototype.$Message = Message;
|
||||||
Vue.prototype.$Modal = Modal;
|
Vue.prototype.$Modal = Modal;
|
||||||
// Vue.prototype.$Notice = Notice;
|
Vue.prototype.$Notice = Notice;
|
||||||
};
|
};
|
||||||
|
|
||||||
// auto install
|
// auto install
|
||||||
|
|
Loading…
Add table
Reference in a new issue