v1.2.48 一尘看板阶段性稳定版:删除Info面板一尘看板tab
This commit is contained in:
parent
97cc727547
commit
195d779e79
|
|
@ -1 +1 @@
|
|||
VERSION=1.2.47
|
||||
VERSION=1.2.48
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<title>甲辰收藏 v1.2.47</title>
|
||||
<title>甲辰收藏 v1.2.48</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="icon" type="image/png" href="/static/icons/favicon.png" />
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export default function Info() {
|
|||
}
|
||||
|
||||
// 顶部tab:寻配号发布 / 发布管理
|
||||
const [activeTab, setActiveTab] = useState('yichens')
|
||||
const [activeTab, setActiveTab] = useState('manage')
|
||||
const [showPublish, setShowPublish] = useState(false)
|
||||
const [publishType, setPublishType] = useState('deal') // 'seek' 或 'deal'
|
||||
const [myList, setMyList] = useState([])
|
||||
|
|
@ -227,8 +227,7 @@ export default function Info() {
|
|||
<div style={{ position: 'sticky', top: 0, background: 'rgba(15,23,42,0.95)', backdropFilter: 'blur(10px)', padding: '16px 20px', borderBottom: '1px solid #1e293b', zIndex: 100 }}>
|
||||
<div style={{ display: 'flex', gap: '8px', background: '#1e293b', borderRadius: '12px', padding: '4px' }}>
|
||||
{[
|
||||
{ key: 'manage', label: '📋 发布管理' },
|
||||
{ key: 'yichens', label: '📊 一尘看板' }
|
||||
{ key: 'manage', label: '📋 发布管理' }
|
||||
].map(tab => (
|
||||
<div
|
||||
key={tab.key}
|
||||
|
|
@ -673,165 +672,9 @@ export default function Info() {
|
|||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 一尘看板页 */}
|
||||
{activeTab === 'yichens' && (
|
||||
<YichensBoard />
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
// ============ 一尘看板组件 ============
|
||||
function YichensBoard() {
|
||||
const [stats, setStats] = useState({ posts: null, categories: [], users: null })
|
||||
const [posts, setPosts] = useState([])
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [expandedPosts, setExpandedPosts] = useState({})
|
||||
const [postTypeFilter, setPostTypeFilter] = useState('all')
|
||||
|
||||
const API_BASE = localStorage.getItem('API_BASE') || ''
|
||||
|
||||
useEffect(() => {
|
||||
fetchStats()
|
||||
fetchPosts()
|
||||
}, [])
|
||||
|
||||
const fetchStats = async () => {
|
||||
try {
|
||||
const [postsRes, catRes, usersRes] = await Promise.all([
|
||||
fetch(`${API_BASE}/api/yichens/stats/posts?days=30`),
|
||||
fetch(`${API_BASE}/api/yichens/stats/categories?days=30`),
|
||||
fetch(`${API_BASE}/api/yichens/stats/users`)
|
||||
])
|
||||
const postsData = await postsRes.json()
|
||||
const catData = await catRes.json()
|
||||
const usersData = await usersRes.json()
|
||||
setStats({ posts: postsData, categories: catData, users: usersData })
|
||||
} catch (e) {
|
||||
console.error('获取统计失败:', e)
|
||||
}
|
||||
}
|
||||
|
||||
const fetchPosts = async () => {
|
||||
setLoading(true)
|
||||
try {
|
||||
let url = `${API_BASE}/api/yichens/posts?limit=50`
|
||||
if (postTypeFilter !== 'all') url += `&post_type=${postTypeFilter}`
|
||||
const res = await fetch(url)
|
||||
const data = await res.json()
|
||||
setPosts(data || [])
|
||||
} catch (e) {
|
||||
console.error('获取帖子失败:', e)
|
||||
}
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
const togglePostExpand = (postId) => {
|
||||
setExpandedPosts(prev => ({ ...prev, [postId]: !prev[postId] }))
|
||||
}
|
||||
|
||||
const filteredPosts = postTypeFilter === 'all'
|
||||
? posts
|
||||
: posts.filter(p => p.post_type === postTypeFilter)
|
||||
|
||||
return (
|
||||
<div style={{ padding: '0' }}>
|
||||
{stats.posts && (
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: '12px', marginBottom: '20px' }}>
|
||||
<div style={{ background: 'linear-gradient(145deg, #1f2937 0%, #111827 100%)', borderRadius: '12px', padding: '16px', border: '1px solid #374151' }}>
|
||||
<div style={{ color: '#9ca3af', fontSize: '12px', marginBottom: '4px' }}>30天帖子</div>
|
||||
<div style={{ color: '#fff', fontSize: '24px', fontWeight: 'bold' }}>{stats.posts.total_posts}</div>
|
||||
<div style={{ color: '#6b7280', fontSize: '11px' }}>出售{stats.posts.total_deals} 求购{stats.posts.total_wants}</div>
|
||||
</div>
|
||||
<div style={{ background: 'linear-gradient(145deg, #1f2937 0%, #111827 100%)', borderRadius: '12px', padding: '16px', border: '1px solid #374151' }}>
|
||||
<div style={{ color: '#9ca3af', fontSize: '12px', marginBottom: '4px' }}>浏览量</div>
|
||||
<div style={{ color: '#fff', fontSize: '24px', fontWeight: 'bold' }}>{(stats.posts.total_views / 10000).toFixed(1)}万</div>
|
||||
<div style={{ color: '#6b7280', fontSize: '11px' }}>回复{stats.posts.total_replies}</div>
|
||||
</div>
|
||||
<div style={{ background: 'linear-gradient(145deg, #1f2937 0%, #111827 100%)', borderRadius: '12px', padding: '16px', border: '1px solid #374151' }}>
|
||||
<div style={{ color: '#9ca3af', fontSize: '12px', marginBottom: '4px' }}>用户数</div>
|
||||
<div style={{ color: '#fff', fontSize: '24px', fontWeight: 'bold' }}>{stats.users?.total_users || 0}</div>
|
||||
<div style={{ color: '#6b7280', fontSize: '11px' }}>今日新增{stats.users?.new_users_today || 0}</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div style={{ background: 'linear-gradient(145deg, #1f2937 0%, #111827 100%)', borderRadius: '12px', padding: '16px', marginBottom: '20px', border: '1px solid #374151' }}>
|
||||
<div style={{ color: '#f9fafb', fontSize: '14px', fontWeight: '600', marginBottom: '12px' }}>📊 分类统计</div>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '8px' }}>
|
||||
{stats.categories.map(cat => (
|
||||
<span key={cat.category} style={{ padding: '4px 12px', background: 'rgba(59,130,246,0.2)', borderRadius: '20px', color: '#93c5fd', fontSize: '12px' }}>
|
||||
{cat.category} ({cat.count})
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', gap: '8px', marginBottom: '16px' }}>
|
||||
{[
|
||||
{ key: 'all', label: '全部' },
|
||||
{ key: 'deal', label: '出售' },
|
||||
{ key: 'want', label: '求购' }
|
||||
].map(ft => (
|
||||
<button
|
||||
key={ft.key}
|
||||
onClick={() => { setPostTypeFilter(ft.key); fetchPosts() }}
|
||||
style={{
|
||||
padding: '8px 16px',
|
||||
borderRadius: '8px',
|
||||
border: 'none',
|
||||
background: postTypeFilter === ft.key ? 'linear-gradient(135deg, #3b82f6 0%, #2563eb 100%)' : '#374151',
|
||||
color: '#fff',
|
||||
cursor: 'pointer',
|
||||
fontSize: '13px'
|
||||
}}
|
||||
>
|
||||
{ft.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{loading ? (
|
||||
<div style={{ textAlign: 'center', color: '#9ca3af', padding: '40px' }}>加载中...</div>
|
||||
) : (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
|
||||
{filteredPosts.map(post => (
|
||||
<div key={post.post_id} style={{ background: 'linear-gradient(145deg, #1f2937 0%, #111827 100%)', borderRadius: '12px', padding: '16px', border: '1px solid #374151' }}>
|
||||
<div onClick={() => togglePostExpand(post.post_id)} style={{ cursor: 'pointer' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '8px' }}>
|
||||
<span style={{ color: '#fff', fontSize: '15px', fontWeight: '500' }}>{post.title || '无标题'}</span>
|
||||
<span style={{ color: post.post_type === 'deal' ? '#10b981' : post.post_type === 'want' ? '#f59e0b' : '#9ca3af', fontSize: '12px' }}>
|
||||
{post.post_type === 'deal' ? '出售' : post.post_type === 'want' ? '求购' : '普通'}
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', color: '#9ca3af', fontSize: '12px' }}>
|
||||
<span>{post.author_username || '未知'}</span>
|
||||
<span>{post.post_time ? post.post_time.substring(0, 16) : ''}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{expandedPosts[post.post_id] && (
|
||||
<div style={{ marginTop: '12px', paddingTop: '12px', borderTop: '1px solid #374151' }}>
|
||||
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '8px', fontSize: '13px' }}>
|
||||
<div><span style={{ color: '#6b7280' }}>分类: </span><span style={{ color: '#fff' }}>{post.category || '-'}</span></div>
|
||||
<div><span style={{ color: '#6b7280' }}>价格: </span><span style={{ color: '#10b981' }}>{post.price ? post.price.toLocaleString() + '元' : '待询'}</span></div>
|
||||
<div><span style={{ color: '#6b7280' }}>浏览: </span><span style={{ color: '#fff' }}>{post.view_count || 0}</span></div>
|
||||
<div><span style={{ color: '#6b7280' }}>回复: </span><span style={{ color: '#fff' }}>{post.reply_count || 0}</span></div>
|
||||
</div>
|
||||
{post.url && (
|
||||
<a href={post.url} target="_blank" rel="noopener noreferrer" style={{ display: 'inline-block', marginTop: '12px', padding: '8px 16px', background: 'rgba(59,130,246,0.2)', borderRadius: '8px', color: '#60a5fa', fontSize: '13px', textDecoration: 'none' }}>
|
||||
查看原帖
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue