v1.2.79 - 优化一尘看板
This commit is contained in:
parent
550fc8f7da
commit
abc8c7bd08
|
|
@ -1 +1 @@
|
||||||
VERSION=1.2.77
|
VERSION=1.2.79
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
<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">
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
<title>甲辰收藏 v=1.2.72</title>
|
<title>甲辰收藏 v=1.2.78</title>
|
||||||
|
|
||||||
<!-- Favicon -->
|
<!-- Favicon -->
|
||||||
<link rel="icon" type="image/png" href="/static/icons/favicon.png" />
|
<link rel="icon" type="image/png" href="/static/icons/favicon.png" />
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "jiachenlong-frontend",
|
"name": "jiachenlong-frontend",
|
||||||
"version": "1.2.12",
|
"version": "1.2.72",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "jiachenlong-frontend",
|
"name": "jiachenlong-frontend",
|
||||||
"version": "1.2.12",
|
"version": "1.2.72",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.7.9",
|
"axios": "^1.7.9",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ export default function Home() {
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: '12px' }}>
|
<div style={{ display: 'flex', alignItems: 'center', gap: '12px' }}>
|
||||||
<img src="/static/images/jiachenlong-logo.png" alt="甲辰收藏" style={{ width: '48px', height: '48px', borderRadius: '50%', objectFit: 'cover' }} />
|
<img src="/static/images/jiachenlong-logo.png" alt="甲辰收藏" style={{ width: '48px', height: '48px', borderRadius: '50%', objectFit: 'cover' }} />
|
||||||
<div>
|
<div>
|
||||||
<div style={{ color: '#fff', fontSize: '18px', fontWeight: '600' }}>{user?.username || '用户'}</div>
|
<div style={{ color: '#fff', fontSize: '18px', fontWeight: '600' }}>{user?.username || '用户'} <span style={{ color: 'rgba(255,255,255,0.4)', fontSize: '11px', fontWeight: 'normal' }}>ID:{user?.user_code || '-'}</span></div>
|
||||||
<div style={{ color: 'rgba(255,255,255,0.6)', fontSize: '12px' }}>欢迎回来 👋</div>
|
<div style={{ color: 'rgba(255,255,255,0.6)', fontSize: '12px' }}>欢迎回来 👋</div>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ marginLeft: 'auto', display: 'flex', alignItems: 'center', gap: '12px' }}>
|
<div style={{ marginLeft: 'auto', display: 'flex', alignItems: 'center', gap: '12px' }}>
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,28 @@ export default function YichensBoard() {
|
||||||
const res = await fetch(url)
|
const res = await fetch(url)
|
||||||
if (!res.ok) throw new Error('posts API error: ' + res.status)
|
if (!res.ok) throw new Error('posts API error: ' + res.status)
|
||||||
let data = await res.json() || []
|
let data = await res.json() || []
|
||||||
|
// 确保data是数组
|
||||||
|
if (!Array.isArray(data)) {
|
||||||
|
data = data.posts || data.data || []
|
||||||
|
}
|
||||||
console.log('YichensBoard: posts data count', data.length)
|
console.log('YichensBoard: posts data count', data.length)
|
||||||
if (currentCat) {
|
if (currentCat && Array.isArray(data)) {
|
||||||
|
if (currentCat === '龙') {
|
||||||
|
data = data.filter(p => p.category && (p.category.includes('龙') || p.category.includes('纪念钞')))
|
||||||
|
} else if (currentCat === '蛇') {
|
||||||
|
data = data.filter(p => p.category && p.category.includes('蛇'))
|
||||||
|
} else if (currentCat === '马') {
|
||||||
|
data = data.filter(p => p.category && p.category.includes('马'))
|
||||||
|
} else if (currentCat === '其他') {
|
||||||
|
data = data.filter(p => p.category && !p.category.includes('龙') && !p.category.includes('纪念钞') && !p.category.includes('蛇') && !p.category.includes('马'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 确保data是数组
|
||||||
|
if (!Array.isArray(data)) {
|
||||||
|
data = data.posts || data.data || []
|
||||||
|
}
|
||||||
|
console.log('YichensBoard: posts data count', data.length)
|
||||||
|
if (currentCat && Array.isArray(data)) {
|
||||||
if (currentCat === '龙') {
|
if (currentCat === '龙') {
|
||||||
data = data.filter(p => p.category && (p.category.includes('龙') || p.category.includes('纪念钞')))
|
data = data.filter(p => p.category && (p.category.includes('龙') || p.category.includes('纪念钞')))
|
||||||
} else if (currentCat === '蛇') {
|
} else if (currentCat === '蛇') {
|
||||||
|
|
@ -66,7 +86,7 @@ export default function YichensBoard() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 支持新格式 {posts:[], total:xxx} 或旧格式 [{},{}]
|
// 支持新格式 {posts:[], total:xxx} 或旧格式 [{},{}]
|
||||||
const postsArray = data.posts || data
|
const postsArray = Array.isArray(data) ? data : (data.posts || [])
|
||||||
const totalCount = data.total || todayStats.total || postsArray.length
|
const totalCount = data.total || todayStats.total || postsArray.length
|
||||||
setPosts(postsArray)
|
setPosts(postsArray)
|
||||||
setTotalPosts(totalCount)
|
setTotalPosts(totalCount)
|
||||||
|
|
@ -74,26 +94,27 @@ export default function YichensBoard() {
|
||||||
console.error('YichensBoard: fetchPosts error', e)
|
console.error('YichensBoard: fetchPosts error', e)
|
||||||
setError(e.message)
|
setError(e.message)
|
||||||
setPosts([])
|
setPosts([])
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
}
|
}
|
||||||
setLoading(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (todayStats.total > 0) {
|
if (todayStats.total > 0) {
|
||||||
// fetchTodayCategory()
|
fetchPosts(1, categoryFilter, searchKeyword)
|
||||||
fetchPosts(1, '')
|
|
||||||
}
|
}
|
||||||
}, [todayStats])
|
}, [todayStats, categoryFilter, postTypeFilter])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setPage(1)
|
setPage(1)
|
||||||
fetchPosts(1, '')
|
fetchPosts(1, categoryFilter, searchKeyword)
|
||||||
}, [searchKeyword])
|
}, [searchKeyword])
|
||||||
|
|
||||||
const togglePost = id => setExpandedPosts(p => ({ ...p, [id]: !p[id] }))
|
const togglePost = id => setExpandedPosts(p => ({ ...p, [id]: !p[id] }))
|
||||||
|
|
||||||
const StatCard = ({ label, value, color, onClick }) => (
|
const StatCard = ({ label, value, color, onClick }) => (
|
||||||
<div onClick={onClick} style={{
|
<div onClick={() => { setLoading(true); if (onClick) onClick(); }}
|
||||||
|
style={{
|
||||||
background: 'linear-gradient(145deg, #1f2937 0%, #111827 100%)',
|
background: 'linear-gradient(145deg, #1f2937 0%, #111827 100%)',
|
||||||
borderRadius: 12, padding: '12px 8px', border: '1px solid #374151',
|
borderRadius: 12, padding: '12px 8px', border: '1px solid #374151',
|
||||||
cursor: onClick ? 'pointer' : 'default',
|
cursor: onClick ? 'pointer' : 'default',
|
||||||
|
|
@ -122,10 +143,10 @@ export default function YichensBoard() {
|
||||||
📈 连体钞/纪念钞 <span style={{ color: '#9ca3af', fontWeight: 400 }}>{dateStr}</span>
|
📈 连体钞/纪念钞 <span style={{ color: '#9ca3af', fontWeight: 400 }}>{dateStr}</span>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 8 }}>
|
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 8 }}>
|
||||||
<StatCard label='全部' value={todayStats.total} color='#3b82f6' onClick={() => { setPostTypeFilter('all'); setCategoryFilter(''); setPage(1); fetchPosts(1, '') }} />
|
<StatCard label='全部' value={todayStats.total} color='#3b82f6' onClick={() => { setPostTypeFilter('all'); setCategoryFilter(''); setPage(1); }} />
|
||||||
<StatCard label='出售' value={todayStats.deals} color='#10b981' onClick={() => { setPostTypeFilter('deal'); setCategoryFilter(''); setPage(1); fetchPosts(1, '') }} />
|
<StatCard label='出售' value={todayStats.deals} color='#10b981' onClick={() => { setPostTypeFilter('deal'); setCategoryFilter(''); setPage(1); }} />
|
||||||
<StatCard label='求购' value={todayStats.wants} color='#f59e0b' onClick={() => { setPostTypeFilter('want'); setCategoryFilter(''); setPage(1); fetchPosts(1, '') }} />
|
<StatCard label='求购' value={todayStats.wants} color='#f59e0b' onClick={() => { setPostTypeFilter('want'); setCategoryFilter(''); setPage(1); }} />
|
||||||
<StatCard label='其他' value={todayStats.others || 0} color='#8b5cf6' onClick={() => { setPostTypeFilter('other'); setCategoryFilter(''); setPage(1); fetchPosts(1, '') }} />
|
<StatCard label='其他' value={todayStats.others || 0} color='#8b5cf6' onClick={() => { setPostTypeFilter('other'); setCategoryFilter(''); setPage(1); }} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -154,7 +175,7 @@ export default function YichensBoard() {
|
||||||
|
|
||||||
<div style={{ display: 'flex', gap: 8, marginBottom: 12 }}>
|
<div style={{ display: 'flex', gap: 8, marginBottom: 12 }}>
|
||||||
{[{key:'all',label:'全部'},{key:'deal',label:'出售'},{key:'want',label:'求购'},{key:'other',label:'其他'}].map(k => (
|
{[{key:'all',label:'全部'},{key:'deal',label:'出售'},{key:'want',label:'求购'},{key:'other',label:'其他'}].map(k => (
|
||||||
<button key={k.key} onClick={() => { setPostTypeFilter(k.key==='other'?'other':k.key); setCategoryFilter(''); setPage(1); fetchPosts(1, '') }}
|
<button key={k.key} onClick={() => { setPostTypeFilter(k.key==='other'?'other':k.key); setCategoryFilter(''); setPage(1); }}
|
||||||
style={{ padding: '8px 16px', borderRadius: 8, border: 'none',
|
style={{ padding: '8px 16px', borderRadius: 8, border: 'none',
|
||||||
background: postTypeFilter===k.key ? 'linear-gradient(135deg, #3b82f6 0%, #2563eb 100%)' : '#374151', color: '#fff', cursor: 'pointer', fontSize: 13 }}>
|
background: postTypeFilter===k.key ? 'linear-gradient(135deg, #3b82f6 0%, #2563eb 100%)' : '#374151', color: '#fff', cursor: 'pointer', fontSize: 13 }}>
|
||||||
{k.label}
|
{k.label}
|
||||||
|
|
@ -164,7 +185,7 @@ export default function YichensBoard() {
|
||||||
|
|
||||||
<div style={{ display: 'flex', gap: 8, marginBottom: 16 }}>
|
<div style={{ display: 'flex', gap: 8, marginBottom: 16 }}>
|
||||||
{[{key:'',label:'全部'},{key:'龙',label:'龙钞'},{key:'蛇',label:'蛇钞'},{key:'马',label:'马钞'},{key:'其他',label:'其他'}].map(k => (
|
{[{key:'',label:'全部'},{key:'龙',label:'龙钞'},{key:'蛇',label:'蛇钞'},{key:'马',label:'马钞'},{key:'其他',label:'其他'}].map(k => (
|
||||||
<button key={k.key} onClick={() => { setCategoryFilter(k.key); setPage(1); fetchPosts(1, k.key) }}
|
<button key={k.key} onClick={() => { setCategoryFilter(k.key); setPage(1); }}
|
||||||
style={{ padding: '8px 16px', borderRadius: 8, border: 'none',
|
style={{ padding: '8px 16px', borderRadius: 8, border: 'none',
|
||||||
background: categoryFilter===k.key ? 'linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%)' : '#374151', color: '#fff', cursor: 'pointer', fontSize: 13 }}>
|
background: categoryFilter===k.key ? 'linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%)' : '#374151', color: '#fff', cursor: 'pointer', fontSize: 13 }}>
|
||||||
{k.label}
|
{k.label}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue