|
|
@@ -1,4 +1,4 @@
|
|
|
-import React, { useState } from 'react';
|
|
|
+import React, { useState, useEffect } from 'react';
|
|
|
import { useQuery } from '@tanstack/react-query';
|
|
|
import { Button } from '@/client/components/ui/button';
|
|
|
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/client/components/ui/dialog';
|
|
|
@@ -50,6 +50,13 @@ const AvatarSelector: React.FC<AvatarSelectorProps> = ({
|
|
|
enabled: !!value,
|
|
|
});
|
|
|
|
|
|
+ // 当对话框打开时,设置当前选中的头像
|
|
|
+ useEffect(() => {
|
|
|
+ if (isOpen && value && currentFile) {
|
|
|
+ setSelectedFile(currentFile);
|
|
|
+ }
|
|
|
+ }, [isOpen, value, currentFile]);
|
|
|
+
|
|
|
// 获取头像列表
|
|
|
const { data: filesData, isLoading } = useQuery({
|
|
|
queryKey: ['avatars-for-selection'] as const,
|