From 295b93984fd94a11d0337637f76ff91b5a618215 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 24 四月 2023 09:49:26 +0800
Subject: [PATCH] 2023-04-24

---
 src/views/mobdesign/index.jsx |   35 +++++++++++++++++++++++------------
 1 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/src/views/mobdesign/index.jsx b/src/views/mobdesign/index.jsx
index dc5675f..1504072 100644
--- a/src/views/mobdesign/index.jsx
+++ b/src/views/mobdesign/index.jsx
@@ -1384,8 +1384,14 @@
     })
 
     setTimeout(() => {
-      if (config.enabled && this.verifyConfig()) {
+      let _pass = this.verifyConfig(config)
+
+      if (config.enabled && !_pass) {
         config.enabled = false
+        config.force = true
+      } else if (!config.enabled && config.force && _pass) {
+        config.enabled = true
+        delete config.force
       }
 
       if (config.cacheUseful !== 'true') {
@@ -1713,17 +1719,22 @@
   onEnabledChange = () => {
     const { config } = this.state
 
-    if (!config || (!config.enabled && this.verifyConfig(true))) {
-      return
-    }
+    let _config = {...config, enabled: !config.enabled}
 
-    this.setState({
-      config: {...config, enabled: !config.enabled}
-    })
+    delete _config.force
+
+    if (!_config.enabled) {
+      this.setState({
+        config: _config
+      })
+    } else if (this.verifyConfig(_config)) {
+      this.setState({
+        config: _config
+      })
+    }
   }
 
-  verifyConfig = (show) => {
-    const { config } = this.state
+  verifyConfig = (config) => {
     let error = ''
     let searchSum = 0
     let swipes = []
@@ -1790,7 +1801,7 @@
       }
     }
 
-    if (show && error) {
+    if (config.enabled && error) {
       notification.warning({
         top: 92,
         message: error,
@@ -1798,7 +1809,7 @@
       })
     }
 
-    return error
+    return error === ''
   }
 
   // 鏇存柊閰嶇疆淇℃伅
@@ -2091,7 +2102,7 @@
               </div>
               <div className="wrap">
                 <Button type="primary" className={needUpdate ? 'update-tip' : ''} onClick={this.submitConfig} id="save-config" loading={menuloading}>淇濆瓨</Button>
-                <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={config && config.enabled} onChange={this.onEnabledChange} />
+                {config ? <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={config.enabled} onChange={this.onEnabledChange} /> : null}
                 <ArrowLeftOutlined title="鍚庨��" className="back-view" onClick={this.backView}/>
                 <Button className="mk-border-purple" onClick={() => this.setState({eyeopen: !eyeopen})}>{!eyeopen ? <EyeOutlined /> : <EyeInvisibleOutlined />} 缁勪欢鍚�</Button>
                 <CreateView resetmenu={this.getAppMenus} />

--
Gitblit v1.8.0