From e8ef7263819e847d55cd35e006aa02635fd7b82e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 14 五月 2025 17:54:21 +0800 Subject: [PATCH] 2025-05-14 --- src/menu/components/share/sourcecomponent/index.jsx | 43 +++++++++++++++++++++++++++++++++++-------- 1 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/menu/components/share/sourcecomponent/index.jsx b/src/menu/components/share/sourcecomponent/index.jsx index 012c84e..68b42cb 100644 --- a/src/menu/components/share/sourcecomponent/index.jsx +++ b/src/menu/components/share/sourcecomponent/index.jsx @@ -1,8 +1,8 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Radio, Modal } from 'antd' -import { PaperClipOutlined, DeleteOutlined } from '@ant-design/icons' +import { Radio, Modal, message } from 'antd' +import { PaperClipOutlined, DeleteOutlined, CopyOutlined } from '@ant-design/icons' import InputForm from './inputform' import './index.scss' @@ -20,11 +20,13 @@ } UNSAFE_componentWillMount () { - const { value } = this.props + 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 || '' } @@ -35,12 +37,24 @@ } shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.state), fromJS(nextState)) + return !is(fromJS(this.state), fromJS(nextState)) || nextProps.type !== this.props.type } deleteUrl = () => { this.setState({url: ''}) this.props.onChange('') + } + + copyUrl = () => { + const { url } = this.state + + let oInput = document.createElement('input') + oInput.value = url + document.body.appendChild(oInput) + oInput.select() + document.execCommand('Copy') + document.body.removeChild(oInput) + message.success('澶嶅埗鎴愬姛銆�') } handleChange = (key) => { @@ -61,6 +75,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"> @@ -69,16 +84,28 @@ <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' + (type !== 'video' ? ' picture' : '')}> - {type === 'video' ? <PaperClipOutlined /> : <img src={url} alt="" />} - <a target="_blank" rel="noopener noreferrer" href={url}>{name}</a> + {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> + <CopyOutlined title="澶嶅埗閾炬帴" onClick={this.copyUrl}/> + <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> + <CopyOutlined title="澶嶅埗閾炬帴" onClick={this.copyUrl}/> + <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 : 1200} closable={false} maskClosable={false} + centered={visible === 'system'} okText="纭畾" cancelText="鍙栨秷" onOk={this.popSubmit} -- Gitblit v1.8.0