Merge pull request 'v1.2.10 - 统计页筛选优化,全量数据筛选' (#3) from release/v1.2.10 into main

Reviewed-on: http://47.253.189.47:3000/coolbot/jiachenlong/pulls/3
This commit is contained in:
酷博特 2026-03-22 15:41:22 +00:00
commit d045e436de
2 changed files with 15 additions and 2 deletions

View File

@ -15,6 +15,7 @@ export default function List() {
const [key, setKey] = useState(0) const [key, setKey] = useState(0)
const [search, setSearch] = useState('') const [search, setSearch] = useState('')
const [isAdmin, setIsAdmin] = useState(false) const [isAdmin, setIsAdmin] = useState(false)
const [page, setPage] = useState(1)
useEffect(() => { useEffect(() => {
// //
@ -63,7 +64,16 @@ export default function List() {
setLoading(true) setLoading(true)
const token = localStorage.getItem('token') const token = localStorage.getItem('token')
try { try {
const res = await fetch('/api/collections?limit=100', { // URL
const params = new URLSearchParams(window.location.hash.split('?')[1] || '')
const urlFilterType = params.get('filter') || ''
const urlFilterValue = params.get('value') ? decodeURIComponent(params.get('value')) : ''
let api = '/api/collections?page=' + page + '&limit=50&sortBy=' + sortField + '&sortOrder=' + sortOrder
if (urlFilterType && urlFilterValue) {
api += '&' + urlFilterType + '=' + encodeURIComponent(urlFilterValue)
}
const res = await fetch(api, {
headers: token ? { 'Authorization': 'Bearer ' + token } : {} headers: token ? { 'Authorization': 'Bearer ' + token } : {}
}) })

View File

@ -88,6 +88,9 @@ export default function Stats() {
gradingCompany: 'gradingCompany', gradingCompany: 'gradingCompany',
gradingScore: 'gradingScore', gradingScore: 'gradingScore',
specialMark: 'specialMark', specialMark: 'specialMark',
numberCategory: 'numberCategory',
gradingCompany: 'gradingCompany',
gradingScore: 'gradingScore',
profitLoss: 'profitLoss' profitLoss: 'profitLoss'
} }
return map[type] || type return map[type] || type
@ -159,7 +162,7 @@ export default function Stats() {
<div style={{ background: 'rgba(255,255,255,0.03)', borderRadius: '12px', padding: '16px', marginBottom: '12px' }}> <div style={{ background: 'rgba(255,255,255,0.03)', borderRadius: '12px', padding: '16px', marginBottom: '12px' }}>
<div style={{ color: '#fbbf24', fontSize: '14px', fontWeight: 'bold', marginBottom: '12px' }}>{title}</div> <div style={{ color: '#fbbf24', fontSize: '14px', fontWeight: 'bold', marginBottom: '12px' }}>{title}</div>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: '8px' }}> <div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: '8px' }}>
{getSortedData(data, type).slice(0, 6).map((item, index) => { {getSortedData(data, type).map((item, index) => {
const value = item[valueKey] const value = item[valueKey]
const label = getLabel(type, item[labelKey] || value) const label = getLabel(type, item[labelKey] || value)
const color = getColor(type, value) const color = getColor(type, value)