From 49f09cc6f8ff8c30a75ed1a9d6f510b69b73962a Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 12 十二月 2023 21:05:37 +0800
Subject: [PATCH] 2023-12-12

---
 src/components/keyInterface/index.jsx |   89 +++++++++++++++++++++++++++++++++-----------
 1 files changed, 66 insertions(+), 23 deletions(-)

diff --git a/src/components/keyInterface/index.jsx b/src/components/keyInterface/index.jsx
index 80074b2..4e11761 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 = {
@@ -18,6 +19,7 @@
     url: '',
     key: '',
     visible: false,
+    apptoken: '',
     setting: null
   }
 
@@ -45,9 +47,18 @@
 
     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 || {}})
+    this.setState({visible: true, setting: _setting || {ssoInterface: 'http://sso.mk9h.cn/cloud/webapi/dostars'}})
   }
 
   decrypt = (token, value) => {
@@ -64,12 +75,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,8 +90,22 @@
         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})
+        this.setState({key: key, apptoken: values.apptoken, setting: _setting})
         return
       }
 
@@ -117,30 +137,50 @@
 
       this.props.onChange(content)
 
-      this.setState({setting: message, url: values.interface, visible: false})
+      this.setState({setting: message, url: values.interface, apptoken: '', 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: ''})
     } else {
-      this.setState({key: '', setting: null, url: ''})
+      this.setState({key: '', apptoken: '', setting: null, url: ''})
     }
 
     this.props.onChange('')
   }
 
+  cancel = () => {
+    const { type } = this.props
+
+    if (type !== 'develop') {
+      this.setState({key: '', apptoken: ''})
+    }
+    this.setState({visible: false})
+  }
+
   render() {
+    const { type } = this.props
     const { getFieldDecorator } = this.props.form
-    const { url, visible, setting, key } = this.state
+    const { url, visible, setting, key, apptoken } = this.state
 
     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,38 +188,41 @@
           maskClosable={false}
           width={650}
           onOk={this.handleConfirm}
-          onCancel={() => this.setState({visible: false})}
+          onCancel={this.cancel}
           destroyOnClose
         >
           {key && setting ?
             <Form>
+              {apptoken && type !== 'develop' ? <Form.Item style={{color: 'red'}} label="姝e紡绯荤粺appkey">
+                {apptoken}
+              </Form.Item> : null}
               <Form.Item label="鎺ュ彛鍦板潃">
                 {getFieldDecorator('interface', {
-                  initialValue: setting.interface,
+                  initialValue: setting.interface || 'http://******/webapi/dostars',
                   rules: [
                     {
                       required: true,
                       message: '璇疯緭鍏ユ帴鍙e湴鍧�!'
                     },
                     {
-                      pattern: /^[0-9a-zA-Z:_./]+$/,
-                      message: '鍙彲浣跨敤鑻辨枃銆佹暟瀛椾互鍙�:_./'
+                      pattern: /^[0-9a-zA-Z:_\-./]+$/,
+                      message: '鍙彲浣跨敤鑻辨枃銆佹暟瀛椾互鍙�:_-./'
                     }
                   ]
-                })(<TextArea rows={2}/>)}
+                })(<TextArea placeholder="http://******/webapi/dostars" rows={2}/>)}
               </Form.Item>
               <Form.Item label="sso鍦板潃">
                 {getFieldDecorator('ssoInterface', {
                   initialValue: setting.ssoInterface || '',
                   rules: [
                     {
-                      pattern: /^[0-9a-zA-Z:_./]+$/,
-                      message: '鍙彲浣跨敤鑻辨枃銆佹暟瀛椾互鍙�:_./'
+                      pattern: /^[0-9a-zA-Z:_\-./]+$/,
+                      message: '鍙彲浣跨敤鑻辨枃銆佹暟瀛椾互鍙�:_-./'
                     }
                   ]
-                })(<TextArea rows={2}/>)}
+                })(<TextArea placeholder="http://sso.mk9h.cn/cloud/webapi/dostars" rows={2}/>)}
               </Form.Item>
-              <Form.Item label="appkey">
+              <Form.Item label="鐩爣绯荤粺appkey">
                 {getFieldDecorator('appkey', {
                   initialValue: setting.appkey || '',
                   rules: [
@@ -196,7 +239,7 @@
                       message: '涓嶅彲灏忎簬16浣嶏紒'
                     }
                   ]
-                })(<Input placeholder="璇疯緭鍏ppkey" autoComplete="off" />)}
+                })(<Input placeholder="璇疯緭鍏ョ洰鏍囩郴缁焌ppkey" autoComplete="off" />)}
               </Form.Item>
               <Form.Item label="鐢ㄦ埛鍚�">
                 {getFieldDecorator('username', {
@@ -244,7 +287,7 @@
               </Form.Item>
             </Form> : null}
           {!key ? <Form style={{marginTop: '20px', marginBottom: '50px'}}>
-            <Form.Item label="apptoken">
+            <Form.Item label="姝e紡绯荤粺appkey">
               {getFieldDecorator('apptoken', {
                 initialValue: '',
                 rules: [

--
Gitblit v1.8.0