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 | 50 | ### LoadingBar |
51 | 51 | 部分 prop 移至 data |
52 | 52 | ### Modal |
53 | -visible 改为 value,使用 v-model,style 改为 styles,$Modal 的关闭有改动,建议后面在纯 html 模式下测试 | |
54 | 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 | 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 | 52 | <li><router-link to="/table">Table</router-link></li> |
53 | 53 | <li><router-link to="/loading-bar">LoadingBar</router-link></li> |
54 | 54 | <li><router-link to="/modal">Modal</router-link></li> |
55 | + <li><router-link to="/message">Message</router-link></li> | |
55 | 56 | </ul> |
56 | 57 | </nav> |
57 | 58 | <router-view></router-view> | ... | ... |
examples/main.js
examples/routers/message.vue
1 | 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 | 3 | </template> |
6 | 4 | <script> |
7 | 5 | export default { |
8 | 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 | 20 | </script> | ... | ... |
src/components/base/notification/index.js
... | ... | @@ -24,8 +24,8 @@ Notification.newInstance = properties => { |
24 | 24 | notice (noticeProps) { |
25 | 25 | notification.add(noticeProps); |
26 | 26 | }, |
27 | - remove (key) { | |
28 | - notification.close(key); | |
27 | + remove (name) { | |
28 | + notification.close(name); | |
29 | 29 | }, |
30 | 30 | component: notification, |
31 | 31 | destroy () { | ... | ... |
src/components/base/notification/notice.vue
1 | 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 | 10 | </template> |
9 | 11 | <script> |
10 | 12 | export default { |
... | ... | @@ -21,7 +23,7 @@ |
21 | 23 | type: String, |
22 | 24 | default: '' |
23 | 25 | }, |
24 | - style: { | |
26 | + styles: { | |
25 | 27 | type: Object, |
26 | 28 | default: function() { |
27 | 29 | return { |
... | ... | @@ -36,7 +38,7 @@ |
36 | 38 | className: { |
37 | 39 | type: String |
38 | 40 | }, |
39 | - key: { | |
41 | + name: { | |
40 | 42 | type: String, |
41 | 43 | required: true |
42 | 44 | }, |
... | ... | @@ -80,10 +82,10 @@ |
80 | 82 | close () { |
81 | 83 | this.clearCloseTimer(); |
82 | 84 | this.onClose(); |
83 | - this.$parent.close(this.key); | |
85 | + this.$parent.close(this.name); | |
84 | 86 | } |
85 | 87 | }, |
86 | - compiled () { | |
88 | + created () { | |
87 | 89 | this.clearCloseTimer(); |
88 | 90 | |
89 | 91 | if (this.duration !== 0) { |
... | ... | @@ -94,7 +96,7 @@ |
94 | 96 | |
95 | 97 | // check if with desc in Notice component |
96 | 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 | 102 | beforeDestroy () { | ... | ... |
src/components/base/notification/notification.vue
1 | 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 | 6 | :prefix-cls="prefixCls" |
5 | - :style="notice.style" | |
7 | + :styles="notice.styles" | |
6 | 8 | :content="notice.content" |
7 | 9 | :duration="notice.duration" |
8 | 10 | :closable="notice.closable" |
9 | - :key="notice.key" | |
11 | + :name="notice.name" | |
10 | 12 | :transition-name="notice.transitionName" |
11 | 13 | :on-close="notice.onClose"> |
12 | 14 | </Notice> |
13 | 15 | </div> |
14 | 16 | </template> |
15 | 17 | <script> |
18 | + // todo :key="notice" | |
16 | 19 | import Notice from './notice.vue'; |
17 | 20 | |
18 | 21 | const prefixCls = 'ivu-notification'; |
... | ... | @@ -30,7 +33,7 @@ |
30 | 33 | type: String, |
31 | 34 | default: prefixCls |
32 | 35 | }, |
33 | - style: { | |
36 | + styles: { | |
34 | 37 | type: Object, |
35 | 38 | default: function () { |
36 | 39 | return { |
... | ... | @@ -63,25 +66,25 @@ |
63 | 66 | }, |
64 | 67 | methods: { |
65 | 68 | add (notice) { |
66 | - const key = notice.key || getUuid(); | |
69 | + const name = notice.name || getUuid(); | |
67 | 70 | |
68 | 71 | let _notice = Object.assign({ |
69 | - style: { | |
72 | + styles: { | |
70 | 73 | right: '50%' |
71 | 74 | }, |
72 | 75 | content: '', |
73 | 76 | duration: 1.5, |
74 | 77 | closable: false, |
75 | - key: key | |
78 | + name: name | |
76 | 79 | }, notice); |
77 | 80 | |
78 | 81 | this.notices.push(_notice); |
79 | 82 | }, |
80 | - close (key) { | |
83 | + close (name) { | |
81 | 84 | const notices = this.notices; |
82 | 85 | |
83 | 86 | for (let i = 0; i < notices.length; i++) { |
84 | - if (notices[i].key === key) { | |
87 | + if (notices[i].name === name) { | |
85 | 88 | this.notices.splice(i, 1); |
86 | 89 | break; |
87 | 90 | } | ... | ... |
src/components/message/index.js
... | ... | @@ -7,7 +7,7 @@ const prefixKey = 'ivu_message_key_'; |
7 | 7 | let defaultDuration = 1.5; |
8 | 8 | let top; |
9 | 9 | let messageInstance; |
10 | -let key = 1; | |
10 | +let name = 1; | |
11 | 11 | |
12 | 12 | const iconTypes = { |
13 | 13 | 'info': 'information-circled', |
... | ... | @@ -20,7 +20,7 @@ const iconTypes = { |
20 | 20 | function getMessageInstance () { |
21 | 21 | messageInstance = messageInstance || Notification.newInstance({ |
22 | 22 | prefixCls: prefixCls, |
23 | - style: { | |
23 | + styles: { | |
24 | 24 | top: `${top}px` |
25 | 25 | } |
26 | 26 | }); |
... | ... | @@ -42,9 +42,9 @@ function notice (content, duration = defaultDuration, type, onClose) { |
42 | 42 | let instance = getMessageInstance(); |
43 | 43 | |
44 | 44 | instance.notice({ |
45 | - key: `${prefixKey}${key}`, | |
45 | + name: `${prefixKey}${name}`, | |
46 | 46 | duration: duration, |
47 | - style: {}, | |
47 | + styles: {}, | |
48 | 48 | transitionName: 'move-up', |
49 | 49 | content: ` |
50 | 50 | <div class="${prefixCls}-custom-content ${prefixCls}-${type}"> |
... | ... | @@ -57,7 +57,7 @@ function notice (content, duration = defaultDuration, type, onClose) { |
57 | 57 | |
58 | 58 | // 用于手动消除 |
59 | 59 | return (function () { |
60 | - let target = key++; | |
60 | + let target = name++; | |
61 | 61 | |
62 | 62 | return function () { |
63 | 63 | instance.remove(`${prefixKey}${target}`); | ... | ... |
src/components/table/table-body.vue
src/index.js
... | ... | @@ -21,7 +21,7 @@ import Input from './components/input'; |
21 | 21 | import InputNumber from './components/input-number'; |
22 | 22 | import LoadingBar from './components/loading-bar'; |
23 | 23 | import Menu from './components/menu'; |
24 | -// import Message from './components/message'; | |
24 | +import Message from './components/message'; | |
25 | 25 | import Modal from './components/modal'; |
26 | 26 | // import Notice from './components/notice'; |
27 | 27 | import Page from './components/page'; |
... | ... | @@ -80,7 +80,7 @@ const iview = { |
80 | 80 | MenuGroup: Menu.Group, |
81 | 81 | MenuItem: Menu.Item, |
82 | 82 | Submenu: Menu.Sub, |
83 | - // Message, | |
83 | + Message, | |
84 | 84 | Modal, |
85 | 85 | // Notice, |
86 | 86 | iOption: Option, |
... | ... | @@ -122,7 +122,7 @@ const install = function (Vue, opts = {}) { |
122 | 122 | }); |
123 | 123 | |
124 | 124 | Vue.prototype.$Loading = LoadingBar; |
125 | - // Vue.prototype.$Message = Message; | |
125 | + Vue.prototype.$Message = Message; | |
126 | 126 | Vue.prototype.$Modal = Modal; |
127 | 127 | // Vue.prototype.$Notice = Notice; |
128 | 128 | }; | ... | ... |