Commit 6cadeba44f0eccce5af738bf34626aa8c2a4152f
1 parent
a538b675
support Message
support Message
Showing
11 changed files
with
59 additions
and
67 deletions
Show diff stats
CHANGE.md
@@ -50,4 +50,9 @@ class 改为 className | @@ -50,4 +50,9 @@ class 改为 className | ||
50 | ### LoadingBar | 50 | ### LoadingBar |
51 | 部分 prop 移至 data | 51 | 部分 prop 移至 data |
52 | ### Modal | 52 | ### Modal |
53 | -visible 改为 value,使用 v-model,style 改为 styles,$Modal 的关闭有改动,建议后面在纯 html 模式下测试 | ||
54 | \ No newline at end of file | 53 | \ No newline at end of file |
54 | +visible 改为 value,使用 v-model,style 改为 styles,$Modal 的关闭有改动,建议后面在纯 html 模式下测试 | ||
55 | +### Table | ||
56 | +i-table 改为 Table | ||
57 | +### Message | ||
58 | +notice.vue 的 key 改为了 name,style 改为 styles | ||
59 | +notification.vue 的 key 改为了 name,style 改为 styles | ||
55 | \ No newline at end of file | 60 | \ No newline at end of file |
README.md
examples/app.vue
@@ -52,6 +52,7 @@ li + li { border-left: solid 1px #bbb; padding-left: 10px; margin-left: 10px; } | @@ -52,6 +52,7 @@ li + li { border-left: solid 1px #bbb; padding-left: 10px; margin-left: 10px; } | ||
52 | <li><router-link to="/table">Table</router-link></li> | 52 | <li><router-link to="/table">Table</router-link></li> |
53 | <li><router-link to="/loading-bar">LoadingBar</router-link></li> | 53 | <li><router-link to="/loading-bar">LoadingBar</router-link></li> |
54 | <li><router-link to="/modal">Modal</router-link></li> | 54 | <li><router-link to="/modal">Modal</router-link></li> |
55 | + <li><router-link to="/message">Message</router-link></li> | ||
55 | </ul> | 56 | </ul> |
56 | </nav> | 57 | </nav> |
57 | <router-view></router-view> | 58 | <router-view></router-view> |
examples/main.js
@@ -172,6 +172,10 @@ const router = new VueRouter({ | @@ -172,6 +172,10 @@ const router = new VueRouter({ | ||
172 | { | 172 | { |
173 | path: '/modal', | 173 | path: '/modal', |
174 | component: require('./routers/modal.vue') | 174 | component: require('./routers/modal.vue') |
175 | + }, | ||
176 | + { | ||
177 | + path: '/message', | ||
178 | + component: require('./routers/message.vue') | ||
175 | } | 179 | } |
176 | ] | 180 | ] |
177 | }); | 181 | }); |
examples/routers/message.vue
1 | <template> | 1 | <template> |
2 | - <i-button @click="confirm">标准</i-button> | ||
3 | - <i-button @click="custom">自定义按钮文字</i-button> | ||
4 | - <i-button @click="async">异步关闭</i-button> | 2 | + <i-button @click.native="time">显示一个10秒的提示</i-button> |
5 | </template> | 3 | </template> |
6 | <script> | 4 | <script> |
7 | export default { | 5 | export default { |
8 | methods: { | 6 | methods: { |
9 | - confirm () { | ||
10 | - this.$Modal.confirm({ | ||
11 | - title: '确认对话框标题', | ||
12 | - content: '<p>一些对话框内容</p><p>一些对话框内容</p>', | ||
13 | - onOk: () => { | ||
14 | - this.$Message.info('点击了确定'); | ||
15 | - }, | ||
16 | - onCancel: () => { | ||
17 | - this.$Message.info('点击了取消'); | ||
18 | - } | ||
19 | - }); | ||
20 | - }, | ||
21 | - custom () { | ||
22 | - this.$Modal.confirm({ | ||
23 | - title: '确认对话框标题', | ||
24 | - content: '<p>一些对话框内容</p><p>一些对话框内容</p>', | ||
25 | - okText: 'OK', | ||
26 | - cancelText: 'Cancel' | ||
27 | - }); | ||
28 | - }, | ||
29 | - async () { | ||
30 | - this.$Modal.confirm({ | ||
31 | - title: '确认对话框标题', | ||
32 | - content: '<p>对话框将在 2秒 后关闭</p>', | ||
33 | - loading: true, | ||
34 | - onOk: () => { | ||
35 | - setTimeout(() => { | ||
36 | - this.$Modal.remove(); | ||
37 | - this.$Message.info('异步关闭了对话框'); | ||
38 | - }, 2000); | ||
39 | - } | 7 | + time () { |
8 | + this.$Message.info('我将在10秒后消失', 3, () => { | ||
9 | + console.log(1111) | ||
40 | }); | 10 | }); |
41 | } | 11 | } |
12 | + }, | ||
13 | + mounted () { | ||
14 | + this.$Message.config({ | ||
15 | + top: 50, | ||
16 | + duration: 3 | ||
17 | + }); | ||
42 | } | 18 | } |
43 | } | 19 | } |
44 | </script> | 20 | </script> |
src/components/base/notification/index.js
@@ -24,8 +24,8 @@ Notification.newInstance = properties => { | @@ -24,8 +24,8 @@ Notification.newInstance = properties => { | ||
24 | notice (noticeProps) { | 24 | notice (noticeProps) { |
25 | notification.add(noticeProps); | 25 | notification.add(noticeProps); |
26 | }, | 26 | }, |
27 | - remove (key) { | ||
28 | - notification.close(key); | 27 | + remove (name) { |
28 | + notification.close(name); | ||
29 | }, | 29 | }, |
30 | component: notification, | 30 | component: notification, |
31 | destroy () { | 31 | destroy () { |
src/components/base/notification/notice.vue
1 | <template> | 1 | <template> |
2 | - <div :class="classes" :style="style" :transition="transitionName"> | ||
3 | - <div :class="[baseClass + '-content']" v-el:content>{{{ content }}}</div> | ||
4 | - <a :class="[baseClass + '-close']" @click="close" v-if="closable"> | ||
5 | - <i class="ivu-icon ivu-icon-ios-close-empty"></i> | ||
6 | - </a> | ||
7 | - </div> | 2 | + <transition :name="transitionName"> |
3 | + <div :class="classes" :style="styles"> | ||
4 | + <div :class="[baseClass + '-content']" ref="content" v-html="content"></div> | ||
5 | + <a :class="[baseClass + '-close']" @click="close" v-if="closable"> | ||
6 | + <i class="ivu-icon ivu-icon-ios-close-empty"></i> | ||
7 | + </a> | ||
8 | + </div> | ||
9 | + </transition> | ||
8 | </template> | 10 | </template> |
9 | <script> | 11 | <script> |
10 | export default { | 12 | export default { |
@@ -21,7 +23,7 @@ | @@ -21,7 +23,7 @@ | ||
21 | type: String, | 23 | type: String, |
22 | default: '' | 24 | default: '' |
23 | }, | 25 | }, |
24 | - style: { | 26 | + styles: { |
25 | type: Object, | 27 | type: Object, |
26 | default: function() { | 28 | default: function() { |
27 | return { | 29 | return { |
@@ -36,7 +38,7 @@ | @@ -36,7 +38,7 @@ | ||
36 | className: { | 38 | className: { |
37 | type: String | 39 | type: String |
38 | }, | 40 | }, |
39 | - key: { | 41 | + name: { |
40 | type: String, | 42 | type: String, |
41 | required: true | 43 | required: true |
42 | }, | 44 | }, |
@@ -80,10 +82,10 @@ | @@ -80,10 +82,10 @@ | ||
80 | close () { | 82 | close () { |
81 | this.clearCloseTimer(); | 83 | this.clearCloseTimer(); |
82 | this.onClose(); | 84 | this.onClose(); |
83 | - this.$parent.close(this.key); | 85 | + this.$parent.close(this.name); |
84 | } | 86 | } |
85 | }, | 87 | }, |
86 | - compiled () { | 88 | + created () { |
87 | this.clearCloseTimer(); | 89 | this.clearCloseTimer(); |
88 | 90 | ||
89 | if (this.duration !== 0) { | 91 | if (this.duration !== 0) { |
@@ -94,7 +96,7 @@ | @@ -94,7 +96,7 @@ | ||
94 | 96 | ||
95 | // check if with desc in Notice component | 97 | // check if with desc in Notice component |
96 | if (this.prefixCls === 'ivu-notice') { | 98 | if (this.prefixCls === 'ivu-notice') { |
97 | - this.withDesc = this.$els.content.querySelectorAll(`.${this.prefixCls}-desc`)[0].innerHTML !== ''; | 99 | + this.withDesc = this.$refs.content.querySelectorAll(`.${this.prefixCls}-desc`)[0].innerHTML !== ''; |
98 | } | 100 | } |
99 | }, | 101 | }, |
100 | beforeDestroy () { | 102 | beforeDestroy () { |
src/components/base/notification/notification.vue
1 | <template> | 1 | <template> |
2 | - <div :class="classes" :style="style"> | ||
3 | - <Notice v-for="notice in notices" | 2 | + <div :class="classes" :style="styles"> |
3 | + <Notice | ||
4 | + v-for="notice in notices" | ||
5 | + :key="notice" | ||
4 | :prefix-cls="prefixCls" | 6 | :prefix-cls="prefixCls" |
5 | - :style="notice.style" | 7 | + :styles="notice.styles" |
6 | :content="notice.content" | 8 | :content="notice.content" |
7 | :duration="notice.duration" | 9 | :duration="notice.duration" |
8 | :closable="notice.closable" | 10 | :closable="notice.closable" |
9 | - :key="notice.key" | 11 | + :name="notice.name" |
10 | :transition-name="notice.transitionName" | 12 | :transition-name="notice.transitionName" |
11 | :on-close="notice.onClose"> | 13 | :on-close="notice.onClose"> |
12 | </Notice> | 14 | </Notice> |
13 | </div> | 15 | </div> |
14 | </template> | 16 | </template> |
15 | <script> | 17 | <script> |
18 | + // todo :key="notice" | ||
16 | import Notice from './notice.vue'; | 19 | import Notice from './notice.vue'; |
17 | 20 | ||
18 | const prefixCls = 'ivu-notification'; | 21 | const prefixCls = 'ivu-notification'; |
@@ -30,7 +33,7 @@ | @@ -30,7 +33,7 @@ | ||
30 | type: String, | 33 | type: String, |
31 | default: prefixCls | 34 | default: prefixCls |
32 | }, | 35 | }, |
33 | - style: { | 36 | + styles: { |
34 | type: Object, | 37 | type: Object, |
35 | default: function () { | 38 | default: function () { |
36 | return { | 39 | return { |
@@ -63,25 +66,25 @@ | @@ -63,25 +66,25 @@ | ||
63 | }, | 66 | }, |
64 | methods: { | 67 | methods: { |
65 | add (notice) { | 68 | add (notice) { |
66 | - const key = notice.key || getUuid(); | 69 | + const name = notice.name || getUuid(); |
67 | 70 | ||
68 | let _notice = Object.assign({ | 71 | let _notice = Object.assign({ |
69 | - style: { | 72 | + styles: { |
70 | right: '50%' | 73 | right: '50%' |
71 | }, | 74 | }, |
72 | content: '', | 75 | content: '', |
73 | duration: 1.5, | 76 | duration: 1.5, |
74 | closable: false, | 77 | closable: false, |
75 | - key: key | 78 | + name: name |
76 | }, notice); | 79 | }, notice); |
77 | 80 | ||
78 | this.notices.push(_notice); | 81 | this.notices.push(_notice); |
79 | }, | 82 | }, |
80 | - close (key) { | 83 | + close (name) { |
81 | const notices = this.notices; | 84 | const notices = this.notices; |
82 | 85 | ||
83 | for (let i = 0; i < notices.length; i++) { | 86 | for (let i = 0; i < notices.length; i++) { |
84 | - if (notices[i].key === key) { | 87 | + if (notices[i].name === name) { |
85 | this.notices.splice(i, 1); | 88 | this.notices.splice(i, 1); |
86 | break; | 89 | break; |
87 | } | 90 | } |
src/components/message/index.js
@@ -7,7 +7,7 @@ const prefixKey = 'ivu_message_key_'; | @@ -7,7 +7,7 @@ const prefixKey = 'ivu_message_key_'; | ||
7 | let defaultDuration = 1.5; | 7 | let defaultDuration = 1.5; |
8 | let top; | 8 | let top; |
9 | let messageInstance; | 9 | let messageInstance; |
10 | -let key = 1; | 10 | +let name = 1; |
11 | 11 | ||
12 | const iconTypes = { | 12 | const iconTypes = { |
13 | 'info': 'information-circled', | 13 | 'info': 'information-circled', |
@@ -20,7 +20,7 @@ const iconTypes = { | @@ -20,7 +20,7 @@ const iconTypes = { | ||
20 | function getMessageInstance () { | 20 | function getMessageInstance () { |
21 | messageInstance = messageInstance || Notification.newInstance({ | 21 | messageInstance = messageInstance || Notification.newInstance({ |
22 | prefixCls: prefixCls, | 22 | prefixCls: prefixCls, |
23 | - style: { | 23 | + styles: { |
24 | top: `${top}px` | 24 | top: `${top}px` |
25 | } | 25 | } |
26 | }); | 26 | }); |
@@ -42,9 +42,9 @@ function notice (content, duration = defaultDuration, type, onClose) { | @@ -42,9 +42,9 @@ function notice (content, duration = defaultDuration, type, onClose) { | ||
42 | let instance = getMessageInstance(); | 42 | let instance = getMessageInstance(); |
43 | 43 | ||
44 | instance.notice({ | 44 | instance.notice({ |
45 | - key: `${prefixKey}${key}`, | 45 | + name: `${prefixKey}${name}`, |
46 | duration: duration, | 46 | duration: duration, |
47 | - style: {}, | 47 | + styles: {}, |
48 | transitionName: 'move-up', | 48 | transitionName: 'move-up', |
49 | content: ` | 49 | content: ` |
50 | <div class="${prefixCls}-custom-content ${prefixCls}-${type}"> | 50 | <div class="${prefixCls}-custom-content ${prefixCls}-${type}"> |
@@ -57,7 +57,7 @@ function notice (content, duration = defaultDuration, type, onClose) { | @@ -57,7 +57,7 @@ function notice (content, duration = defaultDuration, type, onClose) { | ||
57 | 57 | ||
58 | // 用于手动消除 | 58 | // 用于手动消除 |
59 | return (function () { | 59 | return (function () { |
60 | - let target = key++; | 60 | + let target = name++; |
61 | 61 | ||
62 | return function () { | 62 | return function () { |
63 | instance.remove(`${prefixKey}${target}`); | 63 | instance.remove(`${prefixKey}${target}`); |
src/components/table/table-body.vue
src/index.js
@@ -21,7 +21,7 @@ import Input from './components/input'; | @@ -21,7 +21,7 @@ import Input from './components/input'; | ||
21 | import InputNumber from './components/input-number'; | 21 | import InputNumber from './components/input-number'; |
22 | import LoadingBar from './components/loading-bar'; | 22 | import LoadingBar from './components/loading-bar'; |
23 | import Menu from './components/menu'; | 23 | import Menu from './components/menu'; |
24 | -// import Message from './components/message'; | 24 | +import Message from './components/message'; |
25 | import Modal from './components/modal'; | 25 | import Modal from './components/modal'; |
26 | // import Notice from './components/notice'; | 26 | // import Notice from './components/notice'; |
27 | import Page from './components/page'; | 27 | import Page from './components/page'; |
@@ -80,7 +80,7 @@ const iview = { | @@ -80,7 +80,7 @@ const iview = { | ||
80 | MenuGroup: Menu.Group, | 80 | MenuGroup: Menu.Group, |
81 | MenuItem: Menu.Item, | 81 | MenuItem: Menu.Item, |
82 | Submenu: Menu.Sub, | 82 | Submenu: Menu.Sub, |
83 | - // Message, | 83 | + Message, |
84 | Modal, | 84 | Modal, |
85 | // Notice, | 85 | // Notice, |
86 | iOption: Option, | 86 | iOption: Option, |
@@ -122,7 +122,7 @@ const install = function (Vue, opts = {}) { | @@ -122,7 +122,7 @@ const install = function (Vue, opts = {}) { | ||
122 | }); | 122 | }); |
123 | 123 | ||
124 | Vue.prototype.$Loading = LoadingBar; | 124 | Vue.prototype.$Loading = LoadingBar; |
125 | - // Vue.prototype.$Message = Message; | 125 | + Vue.prototype.$Message = Message; |
126 | Vue.prototype.$Modal = Modal; | 126 | Vue.prototype.$Modal = Modal; |
127 | // Vue.prototype.$Notice = Notice; | 127 | // Vue.prototype.$Notice = Notice; |
128 | }; | 128 | }; |