From d6270296f0f5c816fdc36557043e9d7c8d15d2f7 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 20 十月 2021 16:58:44 +0800
Subject: [PATCH] 2021-10-20

---
 src/tabviews/zshare/automatic/index.jsx |   35 +++++++++++++++++++++++++++++------
 1 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/src/tabviews/zshare/automatic/index.jsx b/src/tabviews/zshare/automatic/index.jsx
index 067bd17..8145aa3 100644
--- a/src/tabviews/zshare/automatic/index.jsx
+++ b/src/tabviews/zshare/automatic/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Button } from 'antd'
+import { Button, message } from 'antd'
 
 import MKEmitter from '@/utils/events.js'
 import './index.scss'
@@ -21,7 +21,9 @@
   timer = null
 
   componentDidMount () {
+    MKEmitter.addListener('modifyTabs', this.breakOff)
     MKEmitter.addListener('autoGetData', this.autoGetData)
+    MKEmitter.addListener('resetActiveMenu', this.breakOff)
     MKEmitter.addListener('autoExecOver', this.autoExecOver)
     MKEmitter.addListener('autoMaticOver', this.autoMaticOver)
     MKEmitter.addListener('autoMaticError', this.autoMaticError)
@@ -40,11 +42,20 @@
       return
     }
     clearTimeout(this.timer)
+    MKEmitter.removeListener('modifyTabs', this.breakOff)
     MKEmitter.removeListener('autoGetData', this.autoGetData)
+    MKEmitter.removeListener('resetActiveMenu', this.breakOff)
     MKEmitter.removeListener('autoExecOver', this.autoExecOver)
     MKEmitter.removeListener('autoMaticOver', this.autoMaticOver)
     MKEmitter.removeListener('autoMaticError', this.autoMaticError)
     MKEmitter.removeListener('autoTransSelectData', this.autoTransSelectData)
+  }
+
+  breakOff = () => {
+    if (this.state.running) {
+      this.setState({running: false})
+      clearTimeout(this.timer)
+    }
   }
 
   autoExecOver = (btnId, type) => {
@@ -52,17 +63,19 @@
 
     if (!this.state.running || btnId !== autoMatic.action) return
 
-    if (type === 'error') {
+    if (this.state.line >= 1000) {
+      this.breakOff()
+    } else if (type === 'error') {
       if (autoMatic.onFail === 'next') {
         this.setState({line: this.state.line + 1}, () => {
           setTimeout(() => {
             MKEmitter.emit('autoQueryData', config.MenuID, this.state.line)
-          }, 1000)
+          }, 2000)
         })
       } else if (autoMatic.onFail === 'stay') {
         setTimeout(() => {
           MKEmitter.emit('autoQueryData', config.MenuID, this.state.line)
-        }, 1000)
+        }, 2000)
       } else {
         this.setState({running: false})
       }
@@ -71,12 +84,12 @@
         this.setState({line: this.state.line + 1}, () => {
           setTimeout(() => {
             MKEmitter.emit('autoQueryData', config.MenuID, this.state.line)
-          }, 1000)
+          }, 2000)
         })
       } else if (autoMatic.onSuccess === 'stay') {
         setTimeout(() => {
           MKEmitter.emit('autoQueryData', config.MenuID, this.state.line)
-        }, 1000)
+        }, 2000)
       } else {
         this.setState({running: false})
       }
@@ -130,6 +143,16 @@
 
     this.setState({running: running, line: 1})
     clearTimeout(this.timer)
+
+    message.info('鎸塃sc閿粓姝㈣繍琛屻��')
+
+    document.onkeydown = (event) => {
+      let e = event || window.event
+
+      if (e.key === 'Escape') {
+        this.breakOff()
+      }
+    }
   }
 
   autoMaticOver = (MenuID) => {

--
Gitblit v1.8.0