Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xiaomai-cloud-class-web
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiaomai-cloud-class
xiaomai-cloud-class-web
Commits
5b730428
Commit
5b730428
authored
Jun 30, 2021
by
zhangleyuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:处理图片裁剪
parent
9122c758
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
31 deletions
+49
-31
src/components/ImgClipModal.jsx
+32
-23
src/components/ImgClipModal.less
+6
-0
src/modules/course-manage/components/AddLiveBasic.jsx
+3
-2
src/modules/course-manage/video-course/AddVideoCourse.jsx
+8
-6
No files found.
src/components/ImgCli
c
pModal.jsx
→
src/components/ImgClipModal.jsx
View file @
5b730428
...
...
@@ -2,25 +2,34 @@ import React from 'react';
import
{
Modal
,
Button
}
from
'antd'
;
import
Cropper
from
'react-cropper'
;
import
'cropperjs/dist/cropper.css'
;
class
ImgCclipModal
extends
React
.
Component
{
import
'./ImgClipModal.less'
;
class
ImgClipModal
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
hasImgReady
:
false
,
// 图片是否上传成功
}
}
render
()
{
const
{
imgUrl
,
title
=
"设置图片"
,
visible
,
onClose
,
reUpload
,
modalWidth
=
1080
,
cutContentWidth
,
cutContentHeight
,
width
=
550
,
needReUpload
=
false
,
visible
,
clipContentWidth
=
'500px'
,
clipContentHeight
=
'430px'
,
aspectRatio
=
16
/
9
,
cropBoxWidth
=
500
,
cropBoxHeight
=
282
,
previewBoxWidth
=
'500px'
,
previewBoxHeight
=
'282px'
,
}
=
this
.
props
;
const
{
hasImgReady
,
cropperInstace
}
=
this
.
state
;
return
(
<
Modal
title=
"设置图片"
width=
{
1080
}
className=
"img-clip-modal"
title=
{
title
}
width=
{
modalWidth
}
visible=
{
visible
}
maskClosable=
{
false
}
closeIcon=
{
<
span
className=
"icon iconfont modal-close-icon"
>

</
span
>
}
...
...
@@ -54,18 +63,18 @@ class ImgCclipModal extends React.Component {
<
div
className=
"clip-box"
>
<
div
style=
{
{
width
:
"500px"
,
height
:
"430px"
,
width
:
clipContentWidth
,
height
:
clipContentHeight
,
marginBottom
:
0
,
}
}
>
<
Cropper
style=
{
{
height
:
400
,
width
:
'100%'
}
}
style=
{
{
height
:
"100%'"
,
width
:
'100%'
}
}
className=
"cropper__box"
zoomTo=
{
2
}
aspectRatio=
{
16
/
9
}
aspectRatio=
{
aspectRatio
}
preview=
".preview-url-box"
src=
'https://image.xiaomaiketang.com/xm/GEyiHbWB8W.png'
src=
{
imgUrl
}
viewMode=
{
1
}
guides=
{
true
}
background=
{
false
}
...
...
@@ -82,10 +91,10 @@ class ImgCclipModal extends React.Component {
this
.
setState
({
hasImgReady
:
true
})
this
.
state
.
cropperInstace
.
setCropBoxData
({
width
:
500
,
height
:
282
})
c
onst
that
=
this
;
cropperInstace
.
setCanvasData
({
width
:
'100%'
});
c
ropperInstace
.
setCropBoxData
({
width
:
cropBoxWidth
,
height
:
cropBoxHeight
})
document
.
querySelector
(
'.cropper__box'
).
addEventListener
(
'dblclick'
,
function
(
e
)
{
that
.
state
.
cropperInstace
.
rotate
(
90
)
cropperInstace
.
rotate
(
90
)
});
}
}
/>
...
...
@@ -93,7 +102,7 @@ class ImgCclipModal extends React.Component {
<
div
id=
"clipBtn"
style=
{
{
display
:
"none"
}
}
ref=
"hiddenBtn"
></
div
>
<
div
className=
"preview-img"
>
<
div
className=
"title"
>
效果预览
</
div
>
<
div
id=
"preview-url-box"
style=
{
{
width
:
'500px'
,
height
:
'282px'
}
}
className=
"preview-url-box"
>
<
div
id=
"preview-url-box"
style=
{
{
width
:
previewBoxWidth
,
height
:
previewBoxHeight
}
}
className=
"preview-url-box"
>
</
div
>
<
div
className=
"tip-box"
>
...
...
@@ -108,4 +117,4 @@ class ImgCclipModal extends React.Component {
}
}
export
default
ImgCutModal
;
\ No newline at end of file
export
default
ImgClipModal
;
\ No newline at end of file
src/components/ImgClipModal.less
View file @
5b730428
.img-clip-modal{
.preview-url-box{
overflow: hidden;
}
}
src/modules/course-manage/components/AddLiveBasic.jsx
View file @
5b730428
...
...
@@ -362,7 +362,7 @@ class AddLiveBasic extends React.Component {
}
}
>
<
Cropper
style=
{
{
height
:
400
,
width
:
'100%'
}
}
style=
{
{
height
:
'100%'
,
width
:
'100%'
}
}
className=
"cropper__box"
zoomTo=
{
2
}
aspectRatio=
{
16
/
9
}
...
...
@@ -384,7 +384,8 @@ class AddLiveBasic extends React.Component {
this
.
setState
({
hasImgReady
:
true
})
this
.
state
.
cropperInstace
.
setCropBoxData
({
width
:
500
,
height
:
282
})
this
.
state
.
cropperInstace
.
setCanvasData
({
width
:
500
});
this
.
state
.
cropperInstace
.
setCropBoxData
({
width
:
500
,
height
:
282
});
const
that
=
this
;
document
.
querySelector
(
'.cropper__box'
).
addEventListener
(
'dblclick'
,
function
(
e
)
{
that
.
state
.
cropperInstace
.
rotate
(
90
)
...
...
src/modules/course-manage/video-course/AddVideoCourse.jsx
View file @
5b730428
/*
* @Author: 吴文洁
* @Date: 2020-08-05 10:07:47
* @LastEditors:
wufan
* @LastEditTime: 2021-0
5-30 20:35:49
* @LastEditors:
Please set LastEditors
* @LastEditTime: 2021-0
6-30 18:07:32
* @Description: 视频课新增/编辑页
* @Copyright: 杭州杰竞科技有限公司 版权所有
*/
...
...
@@ -11,7 +11,6 @@ import React from 'react'
import
{
Button
,
Input
,
Radio
,
message
,
Modal
,
Cascader
}
from
'antd'
import
{
DISK_MAP
,
FileTypeIcon
,
FileVerifyMap
}
from
'@/common/constants/academic/lessonEnum'
import
{
ImgCutModalNew
}
from
'@/components'
import
ShowTips
from
'@/components/ShowTips'
import
Breadcrumbs
from
'@/components/Breadcrumbs'
...
...
@@ -26,8 +25,8 @@ import User from '@/common/js/user'
import
_
from
'underscore'
import
Upload
from
'@/core/upload'
import
{
randomString
}
from
'@/domains/basic-domain/utils'
import
ImgClipModal
from
'@/components/ImgClipModal'
import
$
from
'jquery'
// import PhotoClip from 'photoclip';
import
'./AddVideoCourse.less'
const
EDIT_BOX_KEY
=
Math
.
random
()
...
...
@@ -727,7 +726,10 @@ class AddVideoCourse extends React.Component {
onSelect=
{
this
.
handleSelectCover
}
/>
)
}
<
Modal
{
visible
&&
<
ImgClipModal
visible=
{
visible
}
/>
}
{
/* <Modal
title='设置图片'
width={1080}
visible={visible}
...
...
@@ -781,7 +783,7 @@ class AddVideoCourse extends React.Component {
</div>
</div>
</div>
</
Modal
>
</Modal>
*/
}
{
this
.
state
.
previewCourseModal
}
</
div
>
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment