diff --git a/eslint-suppressions.json b/eslint-suppressions.json index f87754ce6a..e8bb421f11 100644 --- a/eslint-suppressions.json +++ b/eslint-suppressions.json @@ -1151,7 +1151,7 @@ }, "web/app/components/base/icons/src/vender/line/general/index.ts": { "no-barrel-files/no-barrel-files": { - "count": 12 + "count": 11 } }, "web/app/components/base/icons/src/vender/line/images/index.ts": { diff --git a/web/app/account/(commonLayout)/account-page/AvatarWithEdit.tsx b/web/app/account/(commonLayout)/account-page/AvatarWithEdit.tsx index 429eece383..8aaf6c8ad5 100644 --- a/web/app/account/(commonLayout)/account-page/AvatarWithEdit.tsx +++ b/web/app/account/(commonLayout)/account-page/AvatarWithEdit.tsx @@ -8,7 +8,6 @@ import { Avatar } from '@langgenius/dify-ui/avatar' import { Button } from '@langgenius/dify-ui/button' import { Dialog, DialogContent } from '@langgenius/dify-ui/dialog' import { toast } from '@langgenius/dify-ui/toast' -import { RiDeleteBin5Line, RiPencilLine } from '@remixicon/react' import * as React from 'react' import { useCallback, useState } from 'react' import { useTranslation } from 'react-i18next' @@ -29,9 +28,9 @@ const AvatarWithEdit = ({ onSave, ...props }: AvatarWithEditProps) => { const [isShowAvatarPicker, setIsShowAvatarPicker] = useState(false) const [uploading, setUploading] = useState(false) const [isShowDeleteConfirm, setIsShowDeleteConfirm] = useState(false) - const [hoverArea, setHoverArea] = useState('left') const [onAvatarError, setOnAvatarError] = useState(false) + const canDeleteAvatar = !!props.avatar && !onAvatarError const handleImageInput: OnImageInput = useCallback(async (isCropped: boolean, fileOrTempUrl: string | File, croppedAreaPixels?: Area, fileName?: string) => { setInputImageInfo( @@ -65,11 +64,16 @@ const AvatarWithEdit = ({ onSave, ...props }: AvatarWithEditProps) => { } }, [onSave, t]) + const handleDeleteAvatarClick = useCallback(() => { + setIsShowAvatarPicker(false) + setIsShowDeleteConfirm(true) + }, []) + const { handleLocalFileUpload } = useLocalFileUploader({ limit: 3, disabled: false, onUpload: (imageFile: ImageFile) => { - if (imageFile.progress === 100) { + if (imageFile.progress === 100 && imageFile.fileId) { setUploading(false) setInputImageInfo(undefined) handleSaveAvatar(imageFile.fileId) @@ -100,36 +104,17 @@ const AvatarWithEdit = ({ onSave, ...props }: AvatarWithEditProps) => { return ( <>
-
+
+ + +
!open && setIsShowAvatarPicker(false)}> @@ -138,11 +123,16 @@ const AvatarWithEdit = ({ onSave, ...props }: AvatarWithEditProps) => {
- + )} + -
diff --git a/web/app/account/(commonLayout)/avatar.tsx b/web/app/account/(commonLayout)/avatar.tsx index ef1c4b7e8c..b0cdd853eb 100644 --- a/web/app/account/(commonLayout)/avatar.tsx +++ b/web/app/account/(commonLayout)/avatar.tsx @@ -10,7 +10,6 @@ import { import { useSuspenseQuery } from '@tanstack/react-query' import { useTranslation } from 'react-i18next' import { resetUser } from '@/app/components/base/amplitude/utils' -import { LogOut01 } from '@/app/components/base/icons/src/vender/line/general' import PremiumBadge from '@/app/components/base/premium-badge' import { useProviderContext } from '@/context/provider-context' import { useRouter } from '@/next/navigation' @@ -44,8 +43,8 @@ export default function AppSelector() { @@ -77,7 +76,7 @@ export default function AppSelector() { className="h-9 justify-start px-3" onClick={handleLogout} > - +