From 57266ee8c62f0fddb42c18c705507fc0dc2416f6 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 18 八月 2023 17:42:39 +0800
Subject: [PATCH] 2023-08-18

---
 src/menu/picturecontroller/index.jsx |   69 ++++++++++++++++++++--------------
 1 files changed, 41 insertions(+), 28 deletions(-)

diff --git a/src/menu/picturecontroller/index.jsx b/src/menu/picturecontroller/index.jsx
index 164b0a0..f91da59 100644
--- a/src/menu/picturecontroller/index.jsx
+++ b/src/menu/picturecontroller/index.jsx
@@ -18,7 +18,7 @@
 const Video = asyncComponent(() => import('./video'))
 const Image = asyncComponent(() => import('@/components/Image'))
 
-class PasteController extends Component {
+class SourceController extends Component {
   state = {
     visible: false,
     editvisible: false,
@@ -39,29 +39,42 @@
   }
 
   trigger = () => {
-    let pictures = sessionStorage.getItem('app_pictures')
-    let videos = sessionStorage.getItem('app_videos')
-    let colorlist = sessionStorage.getItem('app_colors')
+    let deffers = []
 
-    if (!pictures) {
-      notification.warning({
-        top: 92,
-        message: '鏈幏鍙栧埌璧勬簮淇℃伅锛岃绋嶅悗鎴栧埛鏂伴噸璇曘��',
-        duration: 5
-      })
-      return
-    }
+    deffers.push(this.getSource('image', 'app_pictures', 0))
+    deffers.push(this.getSource('video', 'app_videos', 50))
+    deffers.push(this.getSource('color', 'app_colors', 100))
+    
+    Promise.all(deffers).then(result => {
+      this.open(...result)
+    })
+  }
 
-    try {
-      pictures = JSON.parse(pictures)
-      videos = JSON.parse(videos)
-      colorlist = JSON.parse(colorlist)
-    } catch (e) {
-      pictures = []
-      videos = []
-      colorlist = []
-    }
+  getSource = (type, sessionName, delay) => {
+    return new Promise(resolve => {
+      if (window.GLOB[sessionName]) {
+        resolve(window.GLOB[sessionName])
+      } else {
+        let param = {
+          func: 's_url_db_adduptdel',
+          PageIndex: 0,  // 0 浠h〃鍏ㄩ儴
+          PageSize: 0,   // 0 浠h〃鍏ㄩ儴
+          type: 'search',
+          typecharone: type
+        }
+        setTimeout(() => {
+          Api.getCloudConfig(param).then(res => {
+            let data = res.data || []
+            window.GLOB[sessionName] = data
+  
+            resolve(data)
+          })
+        }, delay)
+      }
+    })
+  }
 
+  open = (pictures, videos, colorlist) => {
     let filpictures = pictures
     let filvideos = videos
 
@@ -112,13 +125,13 @@
       }).then(result => {
         if (result.status) {
           if (card.typecharone === 'image') {
-            sessionStorage.setItem('app_pictures', JSON.stringify(result.data || []))
+            window.GLOB.app_pictures = result.data || []
             this.resetPicture(result.data || [])
           } else if (card.typecharone === 'video') {
-            sessionStorage.setItem('app_videos', JSON.stringify(result.data || []))
+            window.GLOB.app_videos = result.data || []
             this.resetVideo(result.data || [])
           } else if (card.typecharone === 'color') {
-            sessionStorage.setItem('app_colors', JSON.stringify(result.data || []))
+            window.GLOB.app_colors = result.data || []
             this.resetColor(result.data || [])
           }
           this.setState({editvisible: false})
@@ -166,13 +179,13 @@
           }).then(res => {
             if (res.status) {
               if (item.typecharone === 'image') {
-                sessionStorage.setItem('app_pictures', JSON.stringify(res.data || []))
+                window.GLOB.app_pictures = res.data || []
                 _this.resetPicture(res.data || [])
               } else if (item.typecharone === 'video') {
-                sessionStorage.setItem('app_videos', JSON.stringify(res.data || []))
+                window.GLOB.app_videos = res.data || []
                 _this.resetVideo(res.data || [])
               } else if (item.typecharone === 'color') {
-                sessionStorage.setItem('app_colors', JSON.stringify(res.data || []))
+                window.GLOB.app_colors = res.data || []
                 _this.resetColor(res.data || [])
               }
             } else {
@@ -381,4 +394,4 @@
   }
 }
 
-export default PasteController
\ No newline at end of file
+export default SourceController
\ No newline at end of file

--
Gitblit v1.8.0