zhangxc преди 5 години
родител
ревизия
7c37684b3d
променени са 3 файла, в които са добавени 13 реда и са изтрити 14 реда
  1. 8 8
      src/common/components/Notify/index.js
  2. 4 4
      src/common/components/Notify/index.less
  3. 1 2
      src/common/components/Notify/notify.js

+ 8 - 8
src/common/components/Notify/index.js

@@ -29,19 +29,19 @@ function createNotification() {
 }
 
 let notification
-const notice = (type, content, duration=2000, onClose) => {
+const notice = (type, content, duration=2000, onClose, showClose=true) => {
     if (!notification) notification = createNotification()
-    return notification.addNotice({ type, content, duration, onClose })
+    return notification.addNotice({ type, content, duration, onClose,showClose })
 }
 
 export default {
-    info(content, duration, onClose) {
-        return notice('info', content, duration, onClose)
+    info(content, duration, onClose, showClose) {
+        return notice('info', content, duration, onClose, showClose)
     },
-    success(content = '操作成功', duration, onClose) {
-        return notice('success', content, duration, onClose)
+    success(content = '操作成功', duration, onClose, showClose) {
+        return notice('success', content, duration, onClose, showClose)
     },
-    error(content, duration , onClose) {
-        return notice('error', content, duration, onClose)
+    error(content, duration , onClose, showClose) {
+        return notice('error', content, duration, onClose, showClose)
     }
 }

+ 4 - 4
src/common/components/Notify/index.less

@@ -11,10 +11,10 @@
 }
 .notify-box {
   min-width: 350px;
-  height:70px;
+  // height:70px;
   position: fixed;
   padding-right: 90px;
-  top:30%;
+  top:40%;
   left:50%;
   transform: translate(-50%, -50%);
   // margin:-35px 0 0  -175px;
@@ -26,9 +26,9 @@
 }
 .notify-text {
   min-width: 224px;
-  height: 70px;
+  max-height: 280px;
   padding:  0 40px 0 0;
-  // overflow: hidden;
+  overflow-y: auto;
   position: relative;
   left: 66px;
   top: 0;

+ 1 - 2
src/common/components/Notify/notify.js

@@ -22,7 +22,6 @@ class NotifyBox extends Component {
 
         // notices.push(notice);//展示所有的提示
         notices[0] = notice;//仅展示最后一个提示
-        
         this.setState({ notices })
         if (notice.duration > 0) {
             clearTimeout(this.state.timer);
@@ -70,7 +69,7 @@ class NotifyBox extends Component {
                             <div className={style['notify-box']} style={styles[notice.type]}>
                                 <div className={style[`${icons[notice.type]}`]}></div>
                                 <div className={style['notify-text']}>{notice.content}</div>
-                                <img  className={style['notify-close']} onClick={()=>{this.removeNotice(notice.key)}} src={close}/>
+                                {notice.showClose&&<img  className={style['notify-close']} onClick={()=>{this.removeNotice(notice.key)}} src={close}/>}
                             </div>
                         </div>
                     ))