Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit5ae49dc

Browse files
authored
refactor: new oss upload (#1185)
* refactor(uploader): use new FC version* refactor(user-profile): banner pad align adjust* refactor(oss-uploader): add upload icon effect* refactor(oss uploader): add turbo loading effect* refactor(oss-uploader): user avatar works* refactor(works-editor): cover done
1 parent9fbfee0 commit5ae49dc

File tree

32 files changed

+1650
-427
lines changed

32 files changed

+1650
-427
lines changed

‎package-lock.json‎

Lines changed: 1307 additions & 26 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"@tippyjs/react":"4.2.5",
5151
"@zeit/next-source-maps":"0.0.4-canary.1",
5252
"accepts":"^1.3.4",
53+
"ali-oss":"^5.3.2",
5354
"babel-plugin-add-react-displayname":"^0.0.5",
5455
"babel-plugin-styled-components":"^1.12.0",
5556
"cacheable-response":"^2.0.9",

‎src/containers/digest/ArticleDigest/DesktopView/WorksLayout.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const WorksLayout: FC<TProps> = ({ metric = METRIC.ARTICLE, article, tab }) => {
5151
<Fragment>
5252
<Mainmetric={metric}>
5353
<WorksWrapper>
54-
<Coversrc="https://avatars.githubusercontent.com/u/2041385?s=64&v=4"/>
54+
<Coversrc={article.cover}/>
5555
<Intro>
5656
<Title>
5757
<WorkName>{title}</WorkName>

‎src/containers/editor/AccountEditor/index.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import { closeDrawer } from '@/utils/helper'
1212

1313
importSubmitButtonfrom'@/widgets/Buttons/SubmitButton'
1414
importTooltipfrom'@/widgets/Tooltip'
15-
import{Divider,SpaceGrow}from'@/widgets/Common'
15+
import{Divider,SpaceGrow,Br}from'@/widgets/Common'
16+
importOSSUploaderfrom'@/widgets/OSSUploader'
1617

1718
importSexInputerfrom'./SexInputer'
1819
importSocialInputerfrom'./SocialInputer'
@@ -52,7 +53,12 @@ const AccountEditorContainer: FC<TProps> = ({ accountEditor: store }) => {
5253

5354
return(
5455
<WrapperclassName="normal-form">
55-
{profile.avatar&&<AvatarPicsrc={profile.avatar}/>}
56+
<OSSUploaderonUploadDone={(url)=>inputOnChange(url,'avatar')}>
57+
{profile.avatar&&<AvatarPicsrc={profile.avatar}/>}
58+
</OSSUploader>
59+
60+
<Brbottom={50}/>
61+
5662
<FormsWrapper>
5763
<LoginSection>
5864
<Label>登入名称</Label>

‎src/containers/editor/AccountEditor/styles/index.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export const AvatarPic = styled(Img)`
2525
border-radius: 42%;
2626
border: 4px solid;
2727
border-color: #043443;
28-
margin-bottom: 50px;
2928
margin-left: -5px;
3029
`
3130
exportconstFormsWrapper=styled.div`

‎src/containers/editor/WorksEditor/Content/BasicInfoPart/CoverUploader.tsx‎

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,38 @@
11
import{FC,memo}from'react'
22

3-
import{ICON}from'@/config'
3+
importOSSUploaderfrom'@/widgets/OSSUploader'
4+
import{nilOrEmpty}from'@/utils/validator'
45

56
import{
67
Wrapper,
7-
IntroImgHolder,
8+
HolderWrapper,
89
HolderIcon,
10+
RealCover,
911
Section,
1012
Title,
1113
Desc,
1214
}from'../../styles/content/basic_info_part/cover_uploader'
15+
import{inputOnChange}from'../../logic'
1316

14-
constCoverUploader:FC=()=>{
17+
typeTProps={
18+
cover?:string|null
19+
}
20+
21+
constCoverUploader:FC<TProps>=({ cover})=>{
1522
return(
1623
<Wrapper>
17-
<IntroImgHolder>
18-
<HolderIconsrc={`${ICON}/shape/add-square.svg`}/>
19-
</IntroImgHolder>
24+
<OSSUploaderonUploadDone={(url)=>inputOnChange(url,'cover')}>
25+
{nilOrEmpty(cover) ?(
26+
<HolderWrapper>
27+
<HolderIcon/>
28+
</HolderWrapper>
29+
) :(
30+
<RealCoversrc={cover}/>
31+
)}
32+
</OSSUploader>
2033
<Section>
21-
<Title>介绍图片</Title>
22-
<Desc>上传图片或输入图片URL,请确保图片比例为 1:1,上限300 KB</Desc>
34+
<Title>封面图片</Title>
35+
<Desc>展示图片的比例为 1:1, 最大不超过300 KB, 支持常见图片格式。</Desc>
2336
</Section>
2437
</Wrapper>
2538
)

‎src/containers/editor/WorksEditor/Content/BasicInfoPart/index.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ type TProps = {
5757

5858
constBasicInfoPart:FC<TProps>=({ inputData, socialOptions})=>{
5959
const{
60+
cover,
6061
title,
6162
homeLink,
6263
desc,
@@ -70,7 +71,7 @@ const BasicInfoPart: FC<TProps> = ({ inputData, socialOptions }) => {
7071
return(
7172
<Wrapper>
7273
<Section>
73-
<CoverUploader/>
74+
<CoverUploadercover={cover}/>
7475
</Section>
7576
<Section>
7677
<Label>主页地址</Label>

‎src/containers/editor/WorksEditor/schema.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { P } from '@/schemas'
33

44
constcreateWorks=gql`
55
mutation (
6+
$cover: String!
67
$title: String!
8+
$homeLink: String!
9+
$desc: String
710
$body: String
811
$communityId: ID!
912
$profitMode: ProfitMode
@@ -15,7 +18,10 @@ const createWorks = gql`
1518
$articleTags: [Id]
1619
) {
1720
createWorks(
21+
cover: $cover
1822
title: $title
23+
desc: $desc
24+
homeLink: $homeLink
1925
body: $body
2026
communityId: $communityId
2127
profitMode: $profitMode
@@ -36,6 +42,7 @@ const updateWorks = gql`
3642
mutation (
3743
$id: ID!
3844
$title: String
45+
$cover: String
3946
$desc: String
4047
$homeLink: String
4148
$body: String
@@ -50,6 +57,7 @@ const updateWorks = gql`
5057
updateWorks(
5158
id: $id
5259
title: $title
60+
cover: $cover
5361
desc: $desc
5462
homeLink: $homeLink
5563
body: $body

‎src/containers/editor/WorksEditor/spec.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type TSocialInfo = {
99

1010
exporttypeTInputData={
1111
title:string
12+
cover:string
1213
desc:string
1314
body:string
1415
homeLink:string

‎src/containers/editor/WorksEditor/store.ts‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const WorksEditor = T.model('WorksEditor', {
5050
community:T.optional(Community,{}),
5151

5252
id:T.maybeNull(T.string),
53+
cover:T.maybeNull(T.string),
5354
title:T.maybeNull(T.string),
5455
body:T.optional(T.string,'{}'),
5556
desc:T.optional(T.string,''),
@@ -90,7 +91,7 @@ const WorksEditor = T.model('WorksEditor', {
9091
getpreviewData():TWorks{
9192
constslf=selfasTStore
9293
const{ techCommunities}=slf
93-
constbasic=pick(['title','desc'],slf)
94+
constbasic=pick(['cover','title','desc'],slf)
9495

9596
const{ lang, framework, database, devOps, design}=techCommunities
9697

@@ -128,7 +129,15 @@ const WorksEditor = T.model('WorksEditor', {
128129
constslf=selfasTStore
129130
const{ socialInfo, cities, techstacks, teammates, community}=slf
130131
constbasic=pick(
131-
['title','desc','body','homeLink','profitMode','workingMode'],
132+
[
133+
'cover',
134+
'title',
135+
'desc',
136+
'body',
137+
'homeLink',
138+
'profitMode',
139+
'workingMode',
140+
],
132141
slf,
133142
)
134143

@@ -184,9 +193,9 @@ const WorksEditor = T.model('WorksEditor', {
184193
return!nilOrEmpty(self.title)
185194
},
186195
getisBasicInfoValid():boolean{
187-
const{ homeLink, desc}=self
196+
const{cover,homeLink, desc}=self
188197

189-
return!nilOrEmpty(desc)&&isURL(homeLink)
198+
return!nilOrEmpty(cover)&&!nilOrEmpty(desc)&&isURL(homeLink)
190199
},
191200
getisTechStackValid():boolean{
192201
constslf=selfasTStore
@@ -308,6 +317,7 @@ const WorksEditor = T.model('WorksEditor', {
308317

309318
reset():void{
310319
self.mode='publish'
320+
self.cover=null
311321
self.title=''
312322
self.body='{}'
313323

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp