Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivManage
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
CivManage
Commits
4fbf5765
Commit
4fbf5765
authored
Dec 04, 2020
by
张烨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style: 优化图片库样式
parent
0096bd1f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
24 deletions
+65
-24
context.js
src/components/Upload/context.js
+19
-7
index.less
src/components/Upload/index.less
+26
-6
index.tsx
src/components/Upload/index.tsx
+20
-11
No files found.
src/components/Upload/context.js
View file @
4fbf5765
...
...
@@ -2,17 +2,29 @@ import { getImageBases } from '@/services/common/api';
import
React
,
{
useEffect
,
useState
}
from
'react'
;
const
UploadContext
=
React
.
createContext
();
const
sleep
=
time
=>
new
Promise
((
res
,
rej
)
=>
{
setTimeout
(()
=>
{
res
();
},
time
);
});
const
PictureWallProvider
=
props
=>
{
const
{
children
,
...
rest
}
=
props
;
const
[
imgBed
,
setImgBed
]
=
useState
([]);
const
update
=
()
=>
{
getImageBases
(
''
).
then
(
res
=>
{
if
(
res
.
code
===
0
)
{
setImgBed
(
res
.
data
);
}
});
};
const
update
=
()
=>
getImageBases
(
''
)
.
then
(
res
=>
{
if
(
res
.
code
===
0
)
{
setImgBed
(
res
.
data
);
}
})
.
catch
(
err
=>
{
// eslint-disable-next-line no-console
console
.
error
(
err
);
return
sleep
(
3000
).
then
(
update
);
});
useEffect
(()
=>
{
update
();
...
...
src/components/Upload/index.less
View file @
4fbf5765
...
...
@@ -41,19 +41,39 @@
overflow: auto;
.imgItem {
flex: 0 0
50
px;
flex: 0 0
75
px;
position: relative;
flex-direction: column;
max-width: 75px;
// margin-right: 16px;
// margin-bottom: 16px;
margin: 10px;
width: 50px;
max-height: 50px;
overflow: hidden;
max-height: 100px;
// overflow: hidden;
cursor: pointer;
background-color: rgba(238,238,238,1);
display: flex;
>div{
flex: 1;
display: flex;
max-height: 78px;
}
>span{
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
&:hover>span{
color: #2f54eb;
}
img {
margin: auto;
width: 100%;
height: 100%;
object-fit: contain;
max-height: 100%;
}
.svgGray{
background-color: rgba(238,238,238,1);
}
&:hover,
&.seleted {
...
...
src/components/Upload/index.tsx
View file @
4fbf5765
...
...
@@ -221,6 +221,11 @@ class PicturesWall extends React.Component<PicturesWallType> {
return
`
${
window
.
location
.
origin
}
/
${
path
}
`
.
replace
(
/
\\
/g
,
'/'
)
}
getFileName
(
path
:
string
){
const
match
=
path
.
match
(
/
(?<
=
[\/\\])([^\\\/\.]
*
)(\.?\w
*
)
$/
)
return
match
&&
match
[
1
]
||
''
}
render
()
{
const
{
previewVisible
,
...
...
@@ -323,18 +328,22 @@ class PicturesWall extends React.Component<PicturesWallType> {
<
div
className=
{
styles
.
imgBox
}
>
{
item
.
child
?.
map
(
m
=>
m
.
fileUrls
).
flat
(
Infinity
).
map
((
item
:
string
,
i
:
number
)
=>
{
return
(
<
div
className=
{
classnames
(
styles
.
imgItem
,
curSelectedImg
===
item
?
styles
.
seleted
:
''
,
)
}
<
div
className=
{
styles
.
imgItem
}
key=
{
i
}
onClick=
{
()
=>
this
.
handleImgSelected
(
item
)
}
>
<
img
src=
{
this
.
getImageUrl
(
item
)
}
alt=
"熊猫运维中台系统"
/>
<
span
className=
{
styles
.
iconBtn
}
>
<
CheckCircleFilled
/>
</
span
>
onClick=
{
()
=>
this
.
handleImgSelected
(
item
)
}
>
<
div
className=
{
classnames
(
curSelectedImg
===
item
?
styles
.
seleted
:
''
,
)
}
>
<
img
className=
{
classnames
({[
styles
.
svgGray
]:
/
\
.
svg$
/
.
test
(
item
)})
}
src=
{
this
.
getImageUrl
(
item
)
}
title=
{
item
}
alt=
"熊猫运维中台系统"
/>
<
span
className=
{
styles
.
iconBtn
}
>
<
CheckCircleFilled
/>
</
span
>
</
div
>
<
span
>
{
this
.
getFileName
(
item
)
}
</
span
>
</
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