Skip to content

Commit

Permalink
fix: image upload
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed May 7, 2023
1 parent 593760b commit 4bc9e94
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 18 deletions.
12 changes: 6 additions & 6 deletions src/GZCTF/ClientApp/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions src/GZCTF/ClientApp/src/components/TeamEditModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,18 @@ const TeamEditModal: FC<TeamEditModalProps> = (props) => {
mutateTeams((teams) => teams?.map((x) => (x.id === teamInfo.id ? newTeamInfo : x)), {
revalidate: false,
})
setDisabled(false)
setDropzoneOpened(false)
})
.catch((err) => {
showErrorNotification(err)
.catch(() => {
updateNotification({
id: 'upload-avatar',
color: 'red',
message: '头像更新失败',
icon: <Icon path={mdiClose} size={1} />,
autoClose: true,
})
})
.finally(() => {
setDisabled(false)
setDropzoneOpened(false)
})
}
Expand Down
14 changes: 11 additions & 3 deletions src/GZCTF/ClientApp/src/pages/account/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,18 @@ const Profile: FC = () => {
setDisabled(false)
mutate({ ...user }, { revalidate: false })
setAvatarFile(null)
setDropzoneOpened(false)
})
.catch((err) => {
showErrorNotification(err)
.catch(() => {
updateNotification({
id: 'upload-avatar',
color: 'red',
message: '头像更新失败',
icon: <Icon path={mdiClose} size={1} />,
autoClose: true,
})
})
.finally(() => {
setDisabled(false)
setDropzoneOpened(false)
})
}
Expand Down
14 changes: 12 additions & 2 deletions src/GZCTF/ClientApp/src/pages/admin/games/[id]/Info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,20 @@ const GameInfoEdit: FC = () => {
icon: <Icon path={mdiCheck} size={1} />,
autoClose: true,
})
setDisabled(false)
mutate({ ...game, poster: res.data })
})
.catch(showErrorNotification)
.catch(() => {
updateNotification({
id: 'upload-poster',
color: 'red',
message: '比赛海报更新失败',
icon: <Icon path={mdiClose} size={1} />,
autoClose: true,
})
})
.finally(() => {
setDisabled(false)
})
}
}

Expand Down
12 changes: 9 additions & 3 deletions src/GZCTF/ClientApp/src/utils/ThemeOverride.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,15 @@ export const useIsMobile = (limit?: number) => {
return isMobile
}

export const ACCEPT_IMAGE_MIME_TYPE = {
'image/*': ['.png', '.gif', '.jpeg', '.jpg', '.webp'],
}
export const ACCEPT_IMAGE_MIME_TYPE = [
'image/png',
'image/gif',
'image/jpeg',
'image/gif',
'image/webp',
'image/bmp',
'image/tiff',
]

interface FixedButtonProps {
right?: string
Expand Down

0 comments on commit 4bc9e94

Please sign in to comment.