diff --git a/frontend/src/pages/Info.jsx b/frontend/src/pages/Info.jsx index a93782d..c9b4a77 100644 --- a/frontend/src/pages/Info.jsx +++ b/frontend/src/pages/Info.jsx @@ -1,9 +1,10 @@ import React, { useState, useEffect } from 'react' export default function Info() { - const [activeTab, setActiveTab] = useState('publish') + const [activeTab, setActiveTab] = useState('deal') const [showPublish, setShowPublish] = useState(false) const [myList, setMyList] = useState([]) + const [listFilter, setListFilter] = useState('all') const [loading, setLoading] = useState(false) const [editingItem, setEditingItem] = useState(null) @@ -13,15 +14,21 @@ export default function Info() { // content使用原生DOM useEffect(() => { - if (activeTab === 'manage') fetchMyList() + if (activeTab === 'deal') fetchMyList() }, [activeTab]) + + // Auto-fetch on mount (only if logged in) + useEffect(() => { + const token = localStorage.getItem('token') + if (token) fetchMyList() + }, []) // 自动生成标题 useEffect(() => { const now = new Date() const date = `${now.getFullYear()}/${now.getMonth() + 1}/${now.getDate()}` const gradeNote = formData.isGraded ? '(评级币)' : '(裸钞)' - const title = `「${date} ${formData.edition} ${formData.type} ${formData.category} 行情信息${gradeNote}」` + const title = `「${date} ${formData.edition} ${formData.type} ${formData.category} ${gradeNote}」` setFormData(prev => ({...prev, title})) }, [formData.edition, formData.type, formData.isGraded, formData.category]) @@ -43,7 +50,7 @@ export default function Info() { const token = localStorage.getItem('token') const res = await fetch(`${API_BASE}/api/information/`, { method: 'POST', headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' }, - body: JSON.stringify({ title: formData.title, content: document.getElementById('publishContent')?.value || '', info_type: formData.category === '成交' ? 'deal' : 'seek' }) + body: JSON.stringify({ title: formData.title, content: document.getElementById('publishContent')?.value || '', info_type: 'deal' }) }) const data = await res.json() if (data.id || data.code === 0) { @@ -110,16 +117,8 @@ export default function Info() { return (