diff --git a/public/react/src/common/educoder.js b/public/react/src/common/educoder.js index 263e08808..749d2a1e5 100644 --- a/public/react/src/common/educoder.js +++ b/public/react/src/common/educoder.js @@ -50,3 +50,4 @@ export { default as DMDEditor } from './components/markdown/DMDEditor' +export { default as ImageLayerHook } from './hooks/ImageLayerHook' \ No newline at end of file diff --git a/public/react/src/common/hooks/ImageLayerHook.js b/public/react/src/common/hooks/ImageLayerHook.js new file mode 100644 index 000000000..c9f0a14a4 --- /dev/null +++ b/public/react/src/common/hooks/ImageLayerHook.js @@ -0,0 +1,47 @@ +import React, { useState, useEffect, memo } from 'react' +import ImageLayer from '../../modules/page/layers/ImageLayer' +import { isImageExtension } from 'educoder' +function ImageLayerHook(props) { + const [showImage, setShowImage] = useState(false) + const [imageSrc, setImageSrc] = useState('') + + const { parentSel, childSel, watchPropsArray } = props + + const onImageLayerClose = () => { + setShowImage(false) + setImageSrc('') + } + const onDelegateClick = (event) => { + const imageSrc = event.target.src || event.target.getAttribute('src') || event.target.getAttribute('href') + // 判断imageSrc是否是图片 + const fileName = event.target.innerHTML.trim() + if (isImageExtension(imageSrc.trim()) || isImageExtension(fileName) || event.target.tagName == 'IMG' || imageSrc.indexOf('base64,') != -1) { + // 非回复里的头像图片; 非emoticons + if (imageSrc.indexOf('/images/avatars/User') === -1 && + imageSrc.indexOf('kindeditor/plugins/emoticons') === -1 ) { + setShowImage(true) + setImageSrc(imageSrc) + } + event.stopPropagation() + event.preventDefault && event.preventDefault() + event.originalEvent.preventDefault() + // event.originalEvent.stopPropagation() + // event.originalEvent.cancelBubble = true + return false; + } + } + useEffect(() => { + $(parentSel) + .delegate(childSel, "click", onDelegateClick); + + return () => { + $(parentSel).undelegate(childSel, "click", onDelegateClick ) + } + }) + + return ( + + ) +} + +export default memo(ImageLayerHook) \ No newline at end of file diff --git a/public/react/src/modules/courses/members/modal/CourseGroupChooserModal.js b/public/react/src/modules/courses/members/modal/CourseGroupChooserModal.js index dc3044cc0..3f4f1a0ca 100644 --- a/public/react/src/modules/courses/members/modal/CourseGroupChooserModal.js +++ b/public/react/src/modules/courses/members/modal/CourseGroupChooserModal.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect, useRef, memo } from 'react' +import React, { useState, useEffect, useRef, useMemo } from 'react' import { trigger } from 'educoder' import { Input, Checkbox } from "antd"; import CourseGroupChooser from '../CourseGroupChooser' @@ -105,4 +105,4 @@ function CourseGroupChooserModal({ course_groups = [], isAdminOrCreator, item, i ) } -export default memo(CourseGroupChooserModal) \ No newline at end of file +export default useMemo(CourseGroupChooserModal) \ No newline at end of file diff --git a/public/react/src/modules/page/main/CodeEvaluateView.css b/public/react/src/modules/page/main/CodeEvaluateView.css index bd0427d7b..137174d95 100644 --- a/public/react/src/modules/page/main/CodeEvaluateView.css +++ b/public/react/src/modules/page/main/CodeEvaluateView.css @@ -126,4 +126,5 @@ display: inline-block; height: 10px; margin: 5px 0; + float: right; } \ No newline at end of file diff --git a/public/react/src/modules/user/modal/RealNameCertificationModal.js b/public/react/src/modules/user/modal/RealNameCertificationModal.js index ccb301a32..6c92423cd 100644 --- a/public/react/src/modules/user/modal/RealNameCertificationModal.js +++ b/public/react/src/modules/user/modal/RealNameCertificationModal.js @@ -2,7 +2,7 @@ import React, { Component } from "react"; import { message, Icon, Input, Form, Upload} from "antd"; import axios from 'axios' import ModalWrapper from "../../courses/common/ModalWrapper" -import { City, getUploadActionUrl,getImageUrl } from 'educoder' +import { City, getUploadActionUrl, getImageUrl, ImageLayerHook } from 'educoder' import '../account/common.css' import authImg from '../../../images/account/auth.png' @@ -201,7 +201,11 @@ class RealNameCertificationModal extends Component{ } .applyForModal .ant-form-item-label label { color: #979797 + } + .applyForModal .ant-upload.ant-upload-drag .ant-upload { + padding: 0px; } + .certificationModal .ant-modal-body{ padding:20px; } @@ -295,9 +299,9 @@ class RealNameCertificationModal extends Component{ {imageUrl2 ? - + // avatar - : + :

@@ -311,7 +315,9 @@ class RealNameCertificationModal extends Component{

示例图片 - 查看大图 + + 查看大图