support Message
support Message
This commit is contained in:
parent
a538b6751f
commit
6cadeba44f
11 changed files with 59 additions and 67 deletions
|
@ -50,4 +50,9 @@ class 改为 className
|
||||||
### LoadingBar
|
### LoadingBar
|
||||||
部分 prop 移至 data
|
部分 prop 移至 data
|
||||||
### Modal
|
### Modal
|
||||||
visible 改为 value,使用 v-model,style 改为 styles,$Modal 的关闭有改动,建议后面在纯 html 模式下测试
|
visible 改为 value,使用 v-model,style 改为 styles,$Modal 的关闭有改动,建议后面在纯 html 模式下测试
|
||||||
|
### Table
|
||||||
|
i-table 改为 Table
|
||||||
|
### Message
|
||||||
|
notice.vue 的 key 改为了 name,style 改为 styles
|
||||||
|
notification.vue 的 key 改为了 name,style 改为 styles
|
|
@ -37,7 +37,7 @@
|
||||||
- [x] Form
|
- [x] Form
|
||||||
- [x] Alert
|
- [x] Alert
|
||||||
- [x] Card
|
- [x] Card
|
||||||
- [ ] Message
|
- [x] Message
|
||||||
- [ ] Notice
|
- [ ] Notice
|
||||||
- [x] Modal
|
- [x] Modal
|
||||||
- [x] Progress
|
- [x] Progress
|
||||||
|
|
|
@ -52,6 +52,7 @@ li + li { border-left: solid 1px #bbb; padding-left: 10px; margin-left: 10px; }
|
||||||
<li><router-link to="/table">Table</router-link></li>
|
<li><router-link to="/table">Table</router-link></li>
|
||||||
<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>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
|
|
|
@ -172,6 +172,10 @@ const router = new VueRouter({
|
||||||
{
|
{
|
||||||
path: '/modal',
|
path: '/modal',
|
||||||
component: require('./routers/modal.vue')
|
component: require('./routers/modal.vue')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/message',
|
||||||
|
component: require('./routers/message.vue')
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,44 +1,20 @@
|
||||||
<template>
|
<template>
|
||||||
<i-button @click="confirm">标准</i-button>
|
<i-button @click.native="time">显示一个10秒的提示</i-button>
|
||||||
<i-button @click="custom">自定义按钮文字</i-button>
|
|
||||||
<i-button @click="async">异步关闭</i-button>
|
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
confirm () {
|
time () {
|
||||||
this.$Modal.confirm({
|
this.$Message.info('我将在10秒后消失', 3, () => {
|
||||||
title: '确认对话框标题',
|
console.log(1111)
|
||||||
content: '<p>一些对话框内容</p><p>一些对话框内容</p>',
|
|
||||||
onOk: () => {
|
|
||||||
this.$Message.info('点击了确定');
|
|
||||||
},
|
|
||||||
onCancel: () => {
|
|
||||||
this.$Message.info('点击了取消');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
custom () {
|
|
||||||
this.$Modal.confirm({
|
|
||||||
title: '确认对话框标题',
|
|
||||||
content: '<p>一些对话框内容</p><p>一些对话框内容</p>',
|
|
||||||
okText: 'OK',
|
|
||||||
cancelText: 'Cancel'
|
|
||||||
});
|
|
||||||
},
|
|
||||||
async () {
|
|
||||||
this.$Modal.confirm({
|
|
||||||
title: '确认对话框标题',
|
|
||||||
content: '<p>对话框将在 2秒 后关闭</p>',
|
|
||||||
loading: true,
|
|
||||||
onOk: () => {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.$Modal.remove();
|
|
||||||
this.$Message.info('异步关闭了对话框');
|
|
||||||
}, 2000);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
this.$Message.config({
|
||||||
|
top: 50,
|
||||||
|
duration: 3
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -24,8 +24,8 @@ Notification.newInstance = properties => {
|
||||||
notice (noticeProps) {
|
notice (noticeProps) {
|
||||||
notification.add(noticeProps);
|
notification.add(noticeProps);
|
||||||
},
|
},
|
||||||
remove (key) {
|
remove (name) {
|
||||||
notification.close(key);
|
notification.close(name);
|
||||||
},
|
},
|
||||||
component: notification,
|
component: notification,
|
||||||
destroy () {
|
destroy () {
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="classes" :style="style" :transition="transitionName">
|
<transition :name="transitionName">
|
||||||
<div :class="[baseClass + '-content']" v-el:content>{{{ content }}}</div>
|
<div :class="classes" :style="styles">
|
||||||
<a :class="[baseClass + '-close']" @click="close" v-if="closable">
|
<div :class="[baseClass + '-content']" ref="content" v-html="content"></div>
|
||||||
<i class="ivu-icon ivu-icon-ios-close-empty"></i>
|
<a :class="[baseClass + '-close']" @click="close" v-if="closable">
|
||||||
</a>
|
<i class="ivu-icon ivu-icon-ios-close-empty"></i>
|
||||||
</div>
|
</a>
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
|
@ -21,7 +23,7 @@
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
},
|
},
|
||||||
style: {
|
styles: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: function() {
|
default: function() {
|
||||||
return {
|
return {
|
||||||
|
@ -36,7 +38,7 @@
|
||||||
className: {
|
className: {
|
||||||
type: String
|
type: String
|
||||||
},
|
},
|
||||||
key: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
|
@ -80,10 +82,10 @@
|
||||||
close () {
|
close () {
|
||||||
this.clearCloseTimer();
|
this.clearCloseTimer();
|
||||||
this.onClose();
|
this.onClose();
|
||||||
this.$parent.close(this.key);
|
this.$parent.close(this.name);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
compiled () {
|
created () {
|
||||||
this.clearCloseTimer();
|
this.clearCloseTimer();
|
||||||
|
|
||||||
if (this.duration !== 0) {
|
if (this.duration !== 0) {
|
||||||
|
@ -94,7 +96,7 @@
|
||||||
|
|
||||||
// check if with desc in Notice component
|
// check if with desc in Notice component
|
||||||
if (this.prefixCls === 'ivu-notice') {
|
if (this.prefixCls === 'ivu-notice') {
|
||||||
this.withDesc = this.$els.content.querySelectorAll(`.${this.prefixCls}-desc`)[0].innerHTML !== '';
|
this.withDesc = this.$refs.content.querySelectorAll(`.${this.prefixCls}-desc`)[0].innerHTML !== '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
|
|
|
@ -1,18 +1,21 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="classes" :style="style">
|
<div :class="classes" :style="styles">
|
||||||
<Notice v-for="notice in notices"
|
<Notice
|
||||||
|
v-for="notice in notices"
|
||||||
|
:key="notice"
|
||||||
:prefix-cls="prefixCls"
|
:prefix-cls="prefixCls"
|
||||||
:style="notice.style"
|
:styles="notice.styles"
|
||||||
:content="notice.content"
|
:content="notice.content"
|
||||||
:duration="notice.duration"
|
:duration="notice.duration"
|
||||||
:closable="notice.closable"
|
:closable="notice.closable"
|
||||||
:key="notice.key"
|
:name="notice.name"
|
||||||
:transition-name="notice.transitionName"
|
:transition-name="notice.transitionName"
|
||||||
:on-close="notice.onClose">
|
:on-close="notice.onClose">
|
||||||
</Notice>
|
</Notice>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
// todo :key="notice"
|
||||||
import Notice from './notice.vue';
|
import Notice from './notice.vue';
|
||||||
|
|
||||||
const prefixCls = 'ivu-notification';
|
const prefixCls = 'ivu-notification';
|
||||||
|
@ -30,7 +33,7 @@
|
||||||
type: String,
|
type: String,
|
||||||
default: prefixCls
|
default: prefixCls
|
||||||
},
|
},
|
||||||
style: {
|
styles: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: function () {
|
default: function () {
|
||||||
return {
|
return {
|
||||||
|
@ -63,25 +66,25 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
add (notice) {
|
add (notice) {
|
||||||
const key = notice.key || getUuid();
|
const name = notice.name || getUuid();
|
||||||
|
|
||||||
let _notice = Object.assign({
|
let _notice = Object.assign({
|
||||||
style: {
|
styles: {
|
||||||
right: '50%'
|
right: '50%'
|
||||||
},
|
},
|
||||||
content: '',
|
content: '',
|
||||||
duration: 1.5,
|
duration: 1.5,
|
||||||
closable: false,
|
closable: false,
|
||||||
key: key
|
name: name
|
||||||
}, notice);
|
}, notice);
|
||||||
|
|
||||||
this.notices.push(_notice);
|
this.notices.push(_notice);
|
||||||
},
|
},
|
||||||
close (key) {
|
close (name) {
|
||||||
const notices = this.notices;
|
const notices = this.notices;
|
||||||
|
|
||||||
for (let i = 0; i < notices.length; i++) {
|
for (let i = 0; i < notices.length; i++) {
|
||||||
if (notices[i].key === key) {
|
if (notices[i].name === name) {
|
||||||
this.notices.splice(i, 1);
|
this.notices.splice(i, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ const prefixKey = 'ivu_message_key_';
|
||||||
let defaultDuration = 1.5;
|
let defaultDuration = 1.5;
|
||||||
let top;
|
let top;
|
||||||
let messageInstance;
|
let messageInstance;
|
||||||
let key = 1;
|
let name = 1;
|
||||||
|
|
||||||
const iconTypes = {
|
const iconTypes = {
|
||||||
'info': 'information-circled',
|
'info': 'information-circled',
|
||||||
|
@ -20,7 +20,7 @@ const iconTypes = {
|
||||||
function getMessageInstance () {
|
function getMessageInstance () {
|
||||||
messageInstance = messageInstance || Notification.newInstance({
|
messageInstance = messageInstance || Notification.newInstance({
|
||||||
prefixCls: prefixCls,
|
prefixCls: prefixCls,
|
||||||
style: {
|
styles: {
|
||||||
top: `${top}px`
|
top: `${top}px`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -42,9 +42,9 @@ function notice (content, duration = defaultDuration, type, onClose) {
|
||||||
let instance = getMessageInstance();
|
let instance = getMessageInstance();
|
||||||
|
|
||||||
instance.notice({
|
instance.notice({
|
||||||
key: `${prefixKey}${key}`,
|
name: `${prefixKey}${name}`,
|
||||||
duration: duration,
|
duration: duration,
|
||||||
style: {},
|
styles: {},
|
||||||
transitionName: 'move-up',
|
transitionName: 'move-up',
|
||||||
content: `
|
content: `
|
||||||
<div class="${prefixCls}-custom-content ${prefixCls}-${type}">
|
<div class="${prefixCls}-custom-content ${prefixCls}-${type}">
|
||||||
|
@ -57,7 +57,7 @@ function notice (content, duration = defaultDuration, type, onClose) {
|
||||||
|
|
||||||
// 用于手动消除
|
// 用于手动消除
|
||||||
return (function () {
|
return (function () {
|
||||||
let target = key++;
|
let target = name++;
|
||||||
|
|
||||||
return function () {
|
return function () {
|
||||||
instance.remove(`${prefixKey}${target}`);
|
instance.remove(`${prefixKey}${target}`);
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
</table>
|
</table>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
// todo :key="row"
|
||||||
import Cell from './cell.vue';
|
import Cell from './cell.vue';
|
||||||
import Mixin from './mixin';
|
import Mixin from './mixin';
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import Input from './components/input';
|
||||||
import InputNumber from './components/input-number';
|
import InputNumber from './components/input-number';
|
||||||
import LoadingBar from './components/loading-bar';
|
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';
|
||||||
|
@ -80,7 +80,7 @@ const iview = {
|
||||||
MenuGroup: Menu.Group,
|
MenuGroup: Menu.Group,
|
||||||
MenuItem: Menu.Item,
|
MenuItem: Menu.Item,
|
||||||
Submenu: Menu.Sub,
|
Submenu: Menu.Sub,
|
||||||
// Message,
|
Message,
|
||||||
Modal,
|
Modal,
|
||||||
// Notice,
|
// Notice,
|
||||||
iOption: Option,
|
iOption: Option,
|
||||||
|
@ -122,7 +122,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;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue