diff --git a/web2/src/pages/MyProfile.tsx b/web2/src/pages/MyProfile.tsx
index b4f4071..be29485 100644
--- a/web2/src/pages/MyProfile.tsx
+++ b/web2/src/pages/MyProfile.tsx
@@ -1,5 +1,5 @@
import { useEffect, useState, useCallback } from 'react'
-import { UserCircle, History, ChevronRight, ArrowLeft, ChevronDown, Pencil } from 'lucide-react'
+import { UserCircle, History, ChevronRight, ArrowLeft, ChevronDown, Pencil, Plus, Trash2 } from 'lucide-react'
import { PageLayout } from '@/components/common/PageLayout'
import { EmptyState } from '@/components/common/EmptyState'
import { LoadingState } from '@/components/common/LoadingState'
@@ -432,6 +432,9 @@ export function MyProfile() {
const [editing, setEditing] = useState<{ field: string; label: string; value: string; type: 'select' | 'text' } | null>(null)
const [editValue, setEditValue] = useState('')
const [saving, setSaving] = useState(false)
+ const [addingFact, setAddingFact] = useState(false)
+ const [newFactKey, setNewFactKey] = useState('')
+ const [newFactValue, setNewFactValue] = useState('')
const load = useCallback(async () => {
setLoading(true)
@@ -492,6 +495,39 @@ export function MyProfile() {
}
}
+ /** 删除画像特征 */
+ const handleDeleteFact = async (key: string) => {
+ if (!profile) return
+ try {
+ // 通过更新空值来删除
+ const newFacts = { ...profile.key_facts }
+ delete newFacts[key]
+ await api.updateProfile({ key_facts: newFacts })
+ setProfile((prev) => prev ? { ...prev, key_facts: newFacts } : prev)
+ } catch (e) {
+ setError(e instanceof Error ? e.message : '删除失败')
+ }
+ }
+
+ /** 添加画像特征 */
+ const handleAddFact = async () => {
+ if (!newFactKey.trim() || !newFactValue.trim() || !profile) return
+ setSaving(true)
+ try {
+ const key = newFactKey.trim()
+ const newFacts = { ...profile.key_facts, [key]: newFactValue.trim() }
+ await api.updateProfile({ key_facts: newFacts })
+ setProfile((prev) => prev ? { ...prev, key_facts: newFacts } : prev)
+ setAddingFact(false)
+ setNewFactKey('')
+ setNewFactValue('')
+ } catch (e) {
+ setError(e instanceof Error ? e.message : '添加失败')
+ } finally {
+ setSaving(false)
+ }
+ }
+
if (loading) return
画像特征
+画像特征
+ +