From 91e232bb0b910f3670bdbccd65cc218d55e1eda9 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 06 十二月 2022 16:08:20 +0800
Subject: [PATCH] Merge branch 'develop'

---
 src/components/keyInterface/index.jsx |   58 ++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 48 insertions(+), 10 deletions(-)

diff --git a/src/components/keyInterface/index.jsx b/src/components/keyInterface/index.jsx
index 80074b2..517b091 100644
--- a/src/components/keyInterface/index.jsx
+++ b/src/components/keyInterface/index.jsx
@@ -7,6 +7,7 @@
 import './index.scss'
 
 const { TextArea } = Input
+const { confirm } = Modal
 
 class KeyInterface extends Component {
   static propTpyes = {
@@ -45,6 +46,15 @@
 
     if (this.state.key && _setting && typeof(_setting) === 'string') {
       _setting = this.decrypt(this.state.key, _setting)
+
+      if (!_setting) {
+        notification.warning({
+          top: 92,
+          message: '淇℃伅瑙f瀽澶辫触!',
+          duration: 5
+        })
+        this.props.onChange('')
+      }
     }
 
     this.setState({visible: true, setting: _setting || {}})
@@ -64,12 +74,7 @@
   
       setting = JSON.parse(window.decodeURIComponent(window.atob(setting)))
     } catch (e) {
-      notification.warning({
-        top: 92,
-        message: '淇℃伅瑙f瀽澶辫触!',
-        duration: 5
-      })
-      setting = {}
+      setting = null
     }
 
     return setting
@@ -84,6 +89,20 @@
         let _setting = this.state.setting
         if (_setting && typeof(_setting) === 'string') {
           _setting = this.decrypt(key, _setting)
+
+          if (!_setting) {
+            const that = this
+            confirm({
+              title: '淇℃伅瑙f瀽澶辫触!',
+              content: '鐐瑰嚮纭畾浼氭竻闄ら厤缃俊鎭紝鐐瑰嚮鍙栨秷鍙噸鏂拌緭鍏ppkey銆�',
+              onOk() {
+                that.setState({key: key, setting: {}, url: ''})
+                that.props.onChange('')
+              },
+              onCancel() {}
+            })
+            return
+          }
         }
         this.setState({key: key, setting: _setting})
         return
@@ -118,11 +137,18 @@
       this.props.onChange(content)
 
       this.setState({setting: message, url: values.interface, visible: false})
+
+      if (this.props.type !== 'develop') {
+        this.setState({key: ''})
+      }
     })
   }
 
   delKey = () => {
+    const { url } = this.state
     const { type } = this.props
+
+    if (!url) return
 
     if (type === 'develop') {
       this.setState({setting: null, url: ''})
@@ -133,6 +159,15 @@
     this.props.onChange('')
   }
 
+  cancel = () => {
+    const { type } = this.props
+
+    if (type !== 'develop') {
+      this.setState({key: ''})
+    }
+    this.setState({visible: false})
+  }
+
   render() {
     const { getFieldDecorator } = this.props.form
     const { url, visible, setting, key } = this.state
@@ -140,7 +175,10 @@
     return (
       <div className="mk-key-wrap">
         <TextArea value={url} rows={2} readOnly={true}/>
-        <div className="mk-key-edit"><EditOutlined onClick={this.editKey}/><DeleteOutlined onClick={this.delKey}/></div>
+        <div className="mk-key-edit">
+          <EditOutlined onClick={this.editKey}/>
+          <DeleteOutlined className={!url ? 'disable' : ''} onClick={this.delKey}/>
+        </div>
         <Modal
           wrapClassName='mk-key-modal'
           visible={visible}
@@ -148,7 +186,7 @@
           maskClosable={false}
           width={650}
           onOk={this.handleConfirm}
-          onCancel={() => this.setState({visible: false})}
+          onCancel={this.cancel}
           destroyOnClose
         >
           {key && setting ?
@@ -196,7 +234,7 @@
                       message: '涓嶅彲灏忎簬16浣嶏紒'
                     }
                   ]
-                })(<Input placeholder="璇疯緭鍏ppkey" autoComplete="off" />)}
+                })(<Input placeholder="璇疯緭鍏ョ洰鏍囩郴缁焌ppkey" autoComplete="off" />)}
               </Form.Item>
               <Form.Item label="鐢ㄦ埛鍚�">
                 {getFieldDecorator('username', {
@@ -244,7 +282,7 @@
               </Form.Item>
             </Form> : null}
           {!key ? <Form style={{marginTop: '20px', marginBottom: '50px'}}>
-            <Form.Item label="apptoken">
+            <Form.Item label="appkey">
               {getFieldDecorator('apptoken', {
                 initialValue: '',
                 rules: [

--
Gitblit v1.8.0