king
2025-04-21 f3d4db769ba9b51b799d981511a710fd443d0e08
src/menu/components/share/sourcecomponent/inputform/index.jsx
@@ -13,7 +13,6 @@
const { Search } = Input
const FileUpload = asyncComponent(() => import('@/tabviews/zshare/fileupload'))
const Video = asyncComponent(() => import('@/menu/picturecontroller/video'))
const Image = asyncComponent(() => import('@/components/Image'))
const EditForm = asyncComponent(() => import('@/menu/picturecontroller/editform'))
class PopSource extends Component {
@@ -24,6 +23,7 @@
  state = {
    url: '',
    list: [],
    icons: [],
    searchKey: '',
    selectId: '',
    editvisible: false,
@@ -84,7 +84,36 @@
  }
  init = (originlist) => {
    this.setState({list: originlist, url: '', searchKey: ''})
    const { type } = this.props
    this.setState({list: originlist, icons: window.GLOB.sIcons || [], url: '', searchKey: ''})
    if (type !== 'video' && !window.GLOB.sIcons && sessionStorage.getItem('getIcons') !== 'fail') {
      fetch(window.GLOB.baseurl + 'Content/static/data.json')
        .then(response => response.json())
        .catch(() => {
          sessionStorage.setItem('getIcons', 'fail')
        })
        .then(res => {
          if (res && res.list) {
            let icons = []
            res.list.forEach(item => {
              if (!item.url) return
              icons.push({
                linkurl: window.GLOB.baseurl + 'Content/static/' + item.url,
                remark: item.remark || '',
                id: Utils.getuuid()
              })
            })
            window.GLOB.sIcons = icons
            this.setState({icons})
          } else {
            sessionStorage.setItem('getIcons', 'fail')
          }
        })
    }
  }
  changeValue = (e) => {
@@ -96,8 +125,15 @@
  }
  selectItem = (item) => {
    const { type } = this.props
    const { icons } = this.state
    if (item.linkurl) {
      this.setState({url: item.linkurl, selectId: item.id})
      if (type !== 'video' && icons.findIndex(n => n.id === item.id) > -1) {
        this.setState({url: item.linkurl.replace(window.GLOB.baseurl, '@mywebsite@/'), selectId: item.id})
      } else {
        this.setState({url: item.linkurl, selectId: item.id})
      }
    }
  }
@@ -149,7 +185,7 @@
  render () {
    const { type, keyword } = this.props
    const { list, url, searchKey, selectId, editvisible, card } = this.state
    const { list, icons, url, searchKey, selectId, editvisible, card } = this.state
    
    if (keyword === 'input') {
      return <div className="mk-source-pop-wrap">
@@ -171,9 +207,11 @@
    }
    let pagelist = list
    let iconlist = icons
    if (searchKey) {
      pagelist = list.filter(item => item.remark && item.remark.indexOf(searchKey) > -1)
      iconlist = icons.filter(item => item.remark && item.remark.indexOf(searchKey) > -1)
    }
    return (
@@ -187,12 +225,22 @@
            <Col span={3} key={item.id}>
              <div className={'image-video-box' + (selectId === item.id ? ' active' : '')} onClick={() => this.selectItem(item)}>
                <div className="image-video-box-body">
                  {type !== 'video' ? <Image url={item.linkurl} /> : <Video value={item.linkurl} />}
                  {type !== 'video' ? <img src={item.linkurl} alt=""/> : <Video value={item.linkurl} />}
                </div>
              </div>
            </Col>
          ))}
          {!pagelist.length ? <Empty description={null}/> : null}
          {iconlist.length ? <div className="static-source">静态资源</div> : null}
          {iconlist.map(item => (
            <Col span={3} key={item.id}>
              <div className={'image-video-box' + (selectId === item.id ? ' active' : '')} onClick={() => this.selectItem(item)}>
                <div className="image-video-box-body">
                  <img src={item.linkurl} alt=""/>
                </div>
              </div>
            </Col>
          ))}
          {!pagelist.length && !iconlist.length ? <Empty description={null}/> : null}
        </Row>
        <Modal
          title="新建"