king
2023-08-27 da64ab0923bf8817fc8599a6e37b953ce38f64c8
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 代表全部
          PageSize: 0,   // 0 代表全部
          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
@@ -100,7 +113,7 @@
        res.id = Utils.getuuid()
      }
      Api.getSystemConfig({
      Api.getCloudConfig({
        func: 's_url_db_adduptdel',
        id: res.id,
        PageIndex: 0, // 0 代表全部
@@ -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})
@@ -154,7 +167,7 @@
      content: '',
      onOk() {
        return new Promise((resolve) => {
          Api.getSystemConfig({
          Api.getCloudConfig({
            func: 's_url_db_adduptdel',
            id: item.id,
            PageIndex: 0, // 0 代表全部
@@ -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
export default SourceController