From a02fc6a77fa1b35c6516b2d37108d80e260c6c85 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 07 十一月 2024 22:05:08 +0800
Subject: [PATCH] 2024-11-07

---
 src/menu/components/share/sourcecomponent/index.jsx |   46 ++++++++++++++++++++++++++++++++++++----------
 1 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/src/menu/components/share/sourcecomponent/index.jsx b/src/menu/components/share/sourcecomponent/index.jsx
index a5ed3e6..c8f515b 100644
--- a/src/menu/components/share/sourcecomponent/index.jsx
+++ b/src/menu/components/share/sourcecomponent/index.jsx
@@ -1,12 +1,13 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Radio, Icon, Modal } from 'antd'
+import { Radio, Modal } from 'antd'
+import { PaperClipOutlined, DeleteOutlined } from '@ant-design/icons'
 
 import InputForm from './inputform'
 import './index.scss'
 
-class CopyComponent extends Component {
+class SourceComponent extends Component {
   static propTpyes = {
     type: PropTypes.string,
     placement: PropTypes.any,
@@ -14,16 +15,29 @@
   }
 
   state = {
-    url: this.props.value,
+    url: '',
     visible: ''
   }
 
   UNSAFE_componentWillMount () {
+    const { value, initialValue } = this.props
+    let val = ''
 
+    if (value) {
+      val = value
+    } else if (initialValue) {
+      val = initialValue
+    } else if (this.props['data-__meta']) {
+      val = this.props['data-__meta'].initialValue || ''
+    }
+
+    this.setState({
+      url: val,
+    })
   }
 
   shouldComponentUpdate (nextProps, nextState) {
-    return !is(fromJS(this.state), fromJS(nextState))
+    return !is(fromJS(this.state), fromJS(nextState)) || nextProps.type !== this.props.type
   }
 
   deleteUrl = () => {
@@ -49,6 +63,7 @@
     const { url, visible } = this.state
     const { type } = this.props
     let name = url ? url.slice(url.lastIndexOf('/') + 1) : ''
+    // url !== '@icon@'
 
     return (
       <div className="mk-source-wrap">
@@ -57,16 +72,27 @@
           <Radio.Button value="upload" size="small" onClick={() => this.handleChange('upload')}>涓婁紶</Radio.Button>
           <Radio.Button value="system" size="small" onClick={() => this.handleChange('system')}>绯荤粺</Radio.Button>
         </Radio.Group> : null}
-        {url ? <div className="mk-source-item-info">
-          <Icon type="paper-clip" />
-          <a target="_blank" rel="noopener noreferrer" href={url}>{name}</a>
-          <Icon title="鍒犻櫎鏂囦欢" type="delete" onClick={this.deleteUrl}/>
+        {url && type === 'video' ? <div className="mk-source-item-info">
+          <PaperClipOutlined />
+          <a target="_blank" rel="noopener noreferrer" href={url.replace(/@mywebsite@\//ig, window.GLOB.baseurl)}>{name}</a>
+          <DeleteOutlined title="鍒犻櫎鏂囦欢" onClick={this.deleteUrl}/>
+        </div> : null}
+        {url && type !== 'video' && url !== '@icon@' ? <div className="mk-source-item-info picture">
+          <img src={url.replace(/@mywebsite@\//ig, window.GLOB.baseurl)} alt="" />
+          <a target="_blank" rel="noopener noreferrer" href={url.replace(/@mywebsite@\//ig, window.GLOB.baseurl)}>{name}</a>
+          <DeleteOutlined title="鍒犻櫎鏂囦欢" onClick={this.deleteUrl}/>
+        </div> : null}
+        {url && type !== 'video' && url === '@icon@' ? <div className="mk-source-item-info avatar">
+          <span className="mk-avatar">{name}</span>
+          <DeleteOutlined title="鍒犻櫎鏂囦欢" onClick={this.deleteUrl}/>
         </div> : null}
         <Modal
           visible={!!visible}
-          width={visible !== 'system' ? 600 : 1000}
+          width={visible !== 'system' ? 650 : 1000}
           closable={false}
           maskClosable={false}
+          okText="纭畾"
+          cancelText="鍙栨秷"
           onOk={this.popSubmit}
           onCancel={() => {this.setState({visible: ''})}}
           destroyOnClose
@@ -78,4 +104,4 @@
   }
 }
 
-export default CopyComponent
\ No newline at end of file
+export default SourceComponent
\ No newline at end of file

--
Gitblit v1.8.0