Browse Source

feat: notify

shenqistart 5 years ago
parent
commit
fb151ba379

+ 8 - 10
src/packages/notify/__test__/notify.spec.js

@@ -21,14 +21,12 @@ describe('notify.vue', () => {
             expect(wrapper.find('.nut-notify').hasStyle('background', '#ffe1e1')).toBe(true);
             expect(wrapper.find('.nut-notify').hasStyle('background', '#ffe1e1')).toBe(true);
         })
         })
     });
     });
-    // it('自定义时长', () => {
-    //     wrapper.setProps({
-    //         color: '#ad0000',
-    //         background: '#ffe1e1'
-    //     });
-    //     return Vue.nextTick().then(function () {
-    //         expect(wrapper.find('.nut-notify').hasStyle('color', '#ad0000')).toBe(true);
-    //         expect(wrapper.find('.nut-notify').hasStyle('background', '#ffe1e1')).toBe(true);
-    //     })
-    // });
+    it('主要通知', () => {
+        wrapper.setProps({
+            type: 'primary'
+        });
+        return Vue.nextTick().then(function () {
+            expect(wrapper.classes('nut-notify--primary')).toBe(true)
+        })
+    });
 });
 });

+ 1 - 6
src/packages/notify/demo.vue

@@ -61,7 +61,7 @@
         </span>
         </span>
       </nut-cell>
       </nut-cell>
       <nut-notify :showPopup="show" type="success" msg="hello" duration="10000">
       <nut-notify :showPopup="show" type="success" msg="hello" duration="10000">
-        <!-- <span>hello</span> -->
+        <span>hello</span>
       </nut-notify>
       </nut-notify>
     </div>
     </div>
     <h4>修改默认配置</h4>
     <h4>修改默认配置</h4>
@@ -71,13 +71,11 @@
           <label>更改所有Notify展示时长设置为5000毫秒</label>
           <label>更改所有Notify展示时长设置为5000毫秒</label>
         </span>
         </span>
       </nut-cell>
       </nut-cell>
-      <nut-notify :showPopup="show" type="success"></nut-notify>
       <nut-cell :showIcon="true" :isLink="true" @click.native="resetDefaultOptions">
       <nut-cell :showIcon="true" :isLink="true" @click.native="resetDefaultOptions">
         <span slot="title">
         <span slot="title">
           <label>恢复所有Toast提示默认配置</label>
           <label>恢复所有Toast提示默认配置</label>
         </span>
         </span>
       </nut-cell>
       </nut-cell>
-      <nut-notify :showPopup="show" type="success"></nut-notify>
     </div>
     </div>
   </div>
   </div>
 </template>
 </template>
@@ -127,9 +125,6 @@ export default {
     },
     },
     showNotify() {
     showNotify() {
       this.show = true;
       this.show = true;
-      setTimeout(() => {
-        this.show = false;
-      }, 200);
     },
     },
     defaultNotify() {
     defaultNotify() {
       this.$notify.setDefaultOptions({
       this.$notify.setDefaultOptions({

+ 0 - 3
src/packages/notify/doc.md

@@ -73,9 +73,6 @@ export default {
 ```javascript
 ```javascript
     mounted(){
     mounted(){
       this.show = true;
       this.show = true;
-      setTimeout(() => {
-        this.show = false;
-      }, 2000);
     }
     }
 ```
 ```
 ## 修改默认配置
 ## 修改默认配置

+ 1 - 2
src/packages/notify/index.js

@@ -3,9 +3,8 @@ import NotifyVue from './notify.vue';
 import './notify.scss';
 import './notify.scss';
 
 
 const NotifyArr = [Notify, NotifyVue];
 const NotifyArr = [Notify, NotifyVue];
-// console.log(NotifyArr, Notify.text('Notify'));
 NotifyArr.install = function (Vue) {
 NotifyArr.install = function (Vue) {
-  // Vue.prototype['$notify'] = Notify;
+  Vue.prototype['$notify'] = Notify;
   Vue.component(NotifyVue.name, NotifyVue);
   Vue.component(NotifyVue.name, NotifyVue);
 };
 };
 
 

+ 0 - 1
src/packages/notify/notify.vue

@@ -88,7 +88,6 @@ export default {
       } else {
       } else {
         this.textTimer = setTimeout(() => {
         this.textTimer = setTimeout(() => {
           clearTimeout(this.textTimer);
           clearTimeout(this.textTimer);
-          // this.msg = '';
         }, 300);
         }, 300);
       }
       }
     },
     },