Format CSS and add border-left indicators for review items

This commit is contained in:
2026-05-09 12:28:39 +08:00
parent 4ec7b67ed0
commit 27a170ec0c
2 changed files with 463 additions and 324 deletions
+396 -310
View File
@@ -1,555 +1,641 @@
:root {
--primary: #4f46e5;
--primary-light: #818cf8;
--primary-bg: #eef2ff;
--success: #10b981;
--warning: #f59e0b;
--danger: #ef4444;
--bg: #f8fafc;
--card-bg: #ffffff;
--text: #1e293b;
--text-secondary: #64748b;
--border: #e2e8f0;
--sidebar-width: 220px;
--primary: #4f46e5;
--primary-light: #818cf8;
--primary-bg: #eef2ff;
--success: #10b981;
--warning: #f59e0b;
--danger: #ef4444;
--bg: #f8fafc;
--card-bg: #ffffff;
--text: #1e293b;
--text-secondary: #64748b;
--border: #e2e8f0;
--sidebar-width: 220px;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
background: var(--bg);
color: var(--text);
font-family:
-apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
"Microsoft YaHei", sans-serif;
background: var(--bg);
color: var(--text);
}
.app {
display: flex;
min-height: 100vh;
display: flex;
min-height: 100vh;
}
/* Sidebar */
.sidebar {
width: var(--sidebar-width);
background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
color: white;
display: flex;
flex-direction: column;
position: fixed;
top: 0;
left: 0;
bottom: 0;
z-index: 100;
width: var(--sidebar-width);
background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
color: white;
display: flex;
flex-direction: column;
position: fixed;
top: 0;
left: 0;
bottom: 0;
z-index: 100;
}
.sidebar-header {
padding: 24px 20px;
border-bottom: 1px solid rgba(255,255,255,0.1);
padding: 24px 20px;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.logo {
font-size: 22px;
font-weight: 700;
font-size: 22px;
font-weight: 700;
}
.logo-sub {
font-size: 11px;
color: rgba(255,255,255,0.5);
display: block;
margin-top: 4px;
font-size: 11px;
color: rgba(255, 255, 255, 0.5);
display: block;
margin-top: 4px;
}
.nav-links {
flex: 1;
padding: 12px 0;
flex: 1;
padding: 12px 0;
}
.nav-link {
display: flex;
align-items: center;
gap: 10px;
padding: 10px 20px;
color: rgba(255,255,255,0.65);
text-decoration: none;
font-size: 14px;
transition: all 0.2s;
position: relative;
display: flex;
align-items: center;
gap: 10px;
padding: 10px 20px;
color: rgba(255, 255, 255, 0.65);
text-decoration: none;
font-size: 14px;
transition: all 0.2s;
position: relative;
}
.nav-link:hover {
color: white;
background: rgba(255,255,255,0.08);
color: white;
background: rgba(255, 255, 255, 0.08);
}
.nav-link.active {
color: white;
background: rgba(255,255,255,0.12);
border-right: 3px solid var(--primary-light);
color: white;
background: rgba(255, 255, 255, 0.12);
border-right: 3px solid var(--primary-light);
}
.nav-link .badge {
margin-left: auto;
background: var(--danger);
color: white;
font-size: 11px;
padding: 2px 7px;
border-radius: 10px;
margin-left: auto;
background: var(--danger);
color: white;
font-size: 11px;
padding: 2px 7px;
border-radius: 10px;
}
.sidebar-footer {
padding: 16px 20px;
border-top: 1px solid rgba(255,255,255,0.1);
padding: 16px 20px;
border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.version {
font-size: 11px;
color: rgba(255,255,255,0.3);
font-size: 11px;
color: rgba(255, 255, 255, 0.3);
}
/* Main Content */
.main-content {
margin-left: var(--sidebar-width);
flex: 1;
padding: 24px 32px;
min-height: 100vh;
margin-left: var(--sidebar-width);
flex: 1;
padding: 24px 32px;
min-height: 100vh;
}
/* Page Header */
.page-header {
margin-bottom: 24px;
margin-bottom: 24px;
}
.page-header h2 {
font-size: 24px;
font-weight: 600;
font-size: 24px;
font-weight: 600;
}
.page-header p {
color: var(--text-secondary);
margin-top: 4px;
font-size: 14px;
color: var(--text-secondary);
margin-top: 4px;
font-size: 14px;
}
/* Cards */
.card {
background: var(--card-bg);
border-radius: 12px;
border: 1px solid var(--border);
padding: 20px;
margin-bottom: 20px;
background: var(--card-bg);
border-radius: 12px;
border: 1px solid var(--border);
padding: 20px;
margin-bottom: 20px;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
}
.card-header h3 {
font-size: 16px;
font-weight: 600;
font-size: 16px;
font-weight: 600;
}
/* Stats Grid */
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 16px;
margin-bottom: 24px;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 16px;
margin-bottom: 24px;
}
.stat-card {
background: var(--card-bg);
border-radius: 12px;
border: 1px solid var(--border);
padding: 20px;
background: var(--card-bg);
border-radius: 12px;
border: 1px solid var(--border);
padding: 20px;
}
.stat-card .stat-label {
font-size: 13px;
color: var(--text-secondary);
margin-bottom: 8px;
font-size: 13px;
color: var(--text-secondary);
margin-bottom: 8px;
}
.stat-card .stat-value {
font-size: 28px;
font-weight: 700;
font-size: 28px;
font-weight: 700;
}
.stat-card .stat-sub {
font-size: 12px;
color: var(--text-secondary);
margin-top: 4px;
font-size: 12px;
color: var(--text-secondary);
margin-top: 4px;
}
.stat-value.income { color: var(--success); }
.stat-value.expense { color: var(--danger); }
.stat-value.warning { color: var(--warning); }
.stat-value.primary { color: var(--primary); }
.stat-value.income {
color: var(--success);
}
.stat-value.expense {
color: var(--danger);
}
.stat-value.warning {
color: var(--warning);
}
.stat-value.primary {
color: var(--primary);
}
/* Buttons */
.btn {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 8px 16px;
border-radius: 8px;
border: none;
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s;
display: inline-flex;
align-items: center;
gap: 6px;
padding: 8px 16px;
border-radius: 8px;
border: none;
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s;
}
.btn-primary {
background: var(--primary);
color: white;
background: var(--primary);
color: white;
}
.btn-primary:hover { background: #4338ca; }
.btn-primary:hover {
background: #4338ca;
}
.btn-secondary {
background: var(--bg);
color: var(--text);
border: 1px solid var(--border);
background: var(--bg);
color: var(--text);
border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-secondary:hover {
background: var(--border);
}
.btn-success {
background: var(--success);
color: white;
background: var(--success);
color: white;
}
.btn-danger {
background: var(--danger);
color: white;
background: var(--danger);
color: white;
}
.btn-sm {
padding: 4px 10px;
font-size: 12px;
padding: 4px 10px;
font-size: 12px;
}
/* Form elements */
.form-group {
margin-bottom: 16px;
margin-bottom: 16px;
}
.form-group label {
display: block;
font-size: 13px;
font-weight: 500;
margin-bottom: 6px;
color: var(--text);
display: block;
font-size: 13px;
font-weight: 500;
margin-bottom: 6px;
color: var(--text);
}
.form-input, .form-select {
width: 100%;
padding: 9px 12px;
border: 1px solid var(--border);
border-radius: 8px;
font-size: 14px;
transition: border-color 0.2s;
background: white;
.form-input,
.form-select {
width: 100%;
padding: 9px 12px;
border: 1px solid var(--border);
border-radius: 8px;
font-size: 14px;
transition: border-color 0.2s;
background: white;
}
.form-input:focus, .form-select:focus {
outline: none;
border-color: var(--primary-light);
box-shadow: 0 0 0 3px var(--primary-bg);
.form-input:focus,
.form-select:focus {
outline: none;
border-color: var(--primary-light);
box-shadow: 0 0 0 3px var(--primary-bg);
}
/* Table */
.table-container {
overflow-x: auto;
overflow-x: auto;
}
table {
width: 100%;
border-collapse: collapse;
font-size: 13px;
width: 100%;
border-collapse: collapse;
font-size: 13px;
}
th {
text-align: left;
padding: 12px 12px;
background: var(--bg);
font-weight: 600;
color: var(--text-secondary);
border-bottom: 2px solid var(--border);
white-space: nowrap;
text-align: left;
padding: 12px 12px;
background: var(--bg);
font-weight: 600;
color: var(--text-secondary);
border-bottom: 2px solid var(--border);
white-space: nowrap;
}
td {
padding: 10px 12px;
border-bottom: 1px solid var(--border);
padding: 10px 12px;
border-bottom: 1px solid var(--border);
}
tr:hover { background: var(--bg); }
tr:hover {
background: var(--bg);
}
/* Tags */
.tag {
display: inline-block;
padding: 2px 8px;
border-radius: 4px;
font-size: 11px;
font-weight: 500;
display: inline-block;
padding: 2px 8px;
border-radius: 4px;
font-size: 11px;
font-weight: 500;
}
.tag-income { background: #d1fae5; color: #065f46; }
.tag-expense { background: #fee2e2; color: #991b1b; }
.tag-transfer { background: #dbeafe; color: #1e40af; }
.tag-matched { background: #e0e7ff; color: #3730a3; }
.tag-unreviewed { background: #fef3c7; color: #92400e; }
.tag-income {
background: #d1fae5;
color: #065f46;
}
.tag-expense {
background: #fee2e2;
color: #991b1b;
}
.tag-transfer {
background: #dbeafe;
color: #1e40af;
}
.tag-matched {
background: #e0e7ff;
color: #3730a3;
}
.tag-unreviewed {
background: #fef3c7;
color: #92400e;
}
/* Review items */
.review-item {
display: flex;
align-items: center;
padding: 14px 16px;
border: 1px solid var(--border);
border-radius: 10px;
margin-bottom: 10px;
gap: 14px;
transition: all 0.2s;
display: flex;
align-items: center;
padding: 14px 16px;
border: 1px solid var(--border);
border-radius: 10px;
margin-bottom: 10px;
gap: 14px;
transition: all 0.2s;
}
.review-item:hover {
border-color: var(--primary-light);
box-shadow: 0 2px 8px rgba(0,0,0,0.04);
border-color: var(--primary-light);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.review-item.reviewed {
opacity: 0.7;
background: var(--bg);
background: var(--bg);
}
.review-item.income-border {
border-left: 3px solid var(--success);
}
.review-item.expense-border {
border-left: 3px solid var(--danger);
}
.review-item .amount-col {
font-size: 18px;
font-weight: 700;
min-width: 110px;
font-size: 18px;
font-weight: 700;
min-width: 110px;
}
.review-item .info-col {
flex: 1;
min-width: 0;
flex: 1;
min-width: 0;
}
.review-item .info-col .title {
font-weight: 500;
font-size: 14px;
font-weight: 500;
font-size: 14px;
}
.review-item .info-col .meta {
color: var(--text-secondary);
font-size: 12px;
margin-top: 2px;
color: var(--text-secondary);
font-size: 12px;
margin-top: 2px;
}
.review-item .action-col {
display: flex;
gap: 8px;
align-items: center;
display: flex;
gap: 8px;
align-items: center;
}
/* Upload zone */
.upload-zone {
border: 2px dashed var(--border);
border-radius: 12px;
padding: 40px;
text-align: center;
cursor: pointer;
transition: all 0.2s;
border: 2px dashed var(--border);
border-radius: 12px;
padding: 40px;
text-align: center;
cursor: pointer;
transition: all 0.2s;
}
.upload-zone:hover, .upload-zone.drag-over {
border-color: var(--primary-light);
background: var(--primary-bg);
.upload-zone:hover,
.upload-zone.drag-over {
border-color: var(--primary-light);
background: var(--primary-bg);
}
.upload-zone .upload-icon {
font-size: 48px;
margin-bottom: 12px;
font-size: 48px;
margin-bottom: 12px;
}
/* Modal */
.modal-overlay {
position: fixed;
inset: 0;
background: rgba(0,0,0,0.4);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.4);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
}
.modal {
background: white;
border-radius: 16px;
padding: 24px;
max-width: 500px;
width: 90%;
max-height: 80vh;
overflow-y: auto;
background: white;
border-radius: 16px;
padding: 24px;
max-width: 500px;
width: 90%;
max-height: 80vh;
overflow-y: auto;
}
.modal h3 {
font-size: 18px;
margin-bottom: 16px;
font-size: 18px;
margin-bottom: 16px;
}
/* Filter bar */
.filter-bar {
display: flex;
gap: 12px;
flex-wrap: wrap;
align-items: flex-end;
margin-bottom: 20px;
display: flex;
gap: 12px;
flex-wrap: wrap;
align-items: flex-end;
margin-bottom: 20px;
}
.filter-bar .form-group {
margin-bottom: 0;
min-width: 150px;
margin-bottom: 0;
min-width: 150px;
}
/* Pagination */
.pagination {
display: flex;
gap: 8px;
align-items: center;
justify-content: center;
margin-top: 20px;
display: flex;
gap: 8px;
align-items: center;
justify-content: center;
margin-top: 20px;
}
.pagination button {
padding: 6px 12px;
border: 1px solid var(--border);
border-radius: 6px;
background: white;
cursor: pointer;
font-size: 13px;
padding: 6px 12px;
border: 1px solid var(--border);
border-radius: 6px;
background: white;
cursor: pointer;
font-size: 13px;
}
.pagination button.active {
background: var(--primary);
color: white;
border-color: var(--primary);
background: var(--primary);
color: white;
border-color: var(--primary);
}
.pagination button:disabled {
opacity: 0.4;
cursor: not-allowed;
opacity: 0.4;
cursor: not-allowed;
}
/* Empty state */
.empty-state {
text-align: center;
padding: 60px 0;
color: var(--text-secondary);
text-align: center;
padding: 60px 0;
color: var(--text-secondary);
}
.empty-state .icon {
font-size: 48px;
margin-bottom: 16px;
font-size: 48px;
margin-bottom: 16px;
}
/* Tabs */
.tabs {
display: flex;
gap: 0;
border-bottom: 2px solid var(--border);
margin-bottom: 20px;
display: flex;
gap: 0;
border-bottom: 2px solid var(--border);
margin-bottom: 20px;
}
.tab {
padding: 10px 20px;
cursor: pointer;
font-size: 14px;
font-weight: 500;
color: var(--text-secondary);
border-bottom: 2px solid transparent;
margin-bottom: -2px;
transition: all 0.2s;
padding: 10px 20px;
cursor: pointer;
font-size: 14px;
font-weight: 500;
color: var(--text-secondary);
border-bottom: 2px solid transparent;
margin-bottom: -2px;
transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab:hover {
color: var(--text);
}
.tab.active {
color: var(--primary);
border-bottom-color: var(--primary);
color: var(--primary);
border-bottom-color: var(--primary);
}
/* Source type labels */
.source-type-label {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 2px 8px;
border-radius: 4px;
font-size: 11px;
font-weight: 600;
display: inline-flex;
align-items: center;
gap: 4px;
padding: 2px 8px;
border-radius: 4px;
font-size: 11px;
font-weight: 600;
}
.source-alipay { background: #dbeafe; color: #1e40af; }
.source-wechat { background: #d1fae5; color: #065f46; }
.source-bank_debit { background: #fef3c7; color: #92400e; }
.source-bank_credit { background: #fef3c7; color: #92400e; }
.source-abc { background: #e0e7ff; color: #3730a3; }
.source-credit_card { background: #fee2e2; color: #991b1b; }
.source-alipay {
background: #dbeafe;
color: #1e40af;
}
.source-wechat {
background: #d1fae5;
color: #065f46;
}
.source-bank_debit {
background: #fef3c7;
color: #92400e;
}
.source-bank_credit {
background: #fef3c7;
color: #92400e;
}
.source-abc {
background: #e0e7ff;
color: #3730a3;
}
.source-credit_card {
background: #fee2e2;
color: #991b1b;
}
/* Loading */
.loading {
display: flex;
align-items: center;
justify-content: center;
padding: 40px;
color: var(--text-secondary);
display: flex;
align-items: center;
justify-content: center;
padding: 40px;
color: var(--text-secondary);
}
.spinner {
width: 24px;
height: 24px;
border: 3px solid var(--border);
border-top-color: var(--primary);
border-radius: 50%;
animation: spin 0.8s linear infinite;
margin-right: 10px;
width: 24px;
height: 24px;
border: 3px solid var(--border);
border-top-color: var(--primary);
border-radius: 50%;
animation: spin 0.8s linear infinite;
margin-right: 10px;
}
@keyframes spin {
to { transform: rotate(360deg); }
to {
transform: rotate(360deg);
}
}
/* Toast */
.toast {
position: fixed;
top: 20px;
right: 20px;
padding: 12px 20px;
border-radius: 10px;
color: white;
font-size: 14px;
z-index: 2000;
animation: slideIn 0.3s ease;
position: fixed;
top: 20px;
right: 20px;
padding: 12px 20px;
border-radius: 10px;
color: white;
font-size: 14px;
z-index: 2000;
animation: slideIn 0.3s ease;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-success {
background: var(--success);
}
.toast-error {
background: var(--danger);
}
@keyframes slideIn {
from { transform: translateX(100%); opacity: 0; }
to { transform: translateX(0); opacity: 1; }
from {
transform: translateX(100%);
opacity: 0;
}
to {
transform: translateX(0);
opacity: 1;
}
}
/* Responsive */
@media (max-width: 768px) {
.sidebar { width: 60px; }
.sidebar .nav-link span:not(.badge) { display: none; }
.sidebar .logo-sub { display: none; }
.main-content { margin-left: 60px; padding: 16px; }
.stats-grid { grid-template-columns: repeat(2, 1fr); }
.filter-bar { flex-direction: column; }
.sidebar {
width: 60px;
}
.sidebar .nav-link span:not(.badge) {
display: none;
}
.sidebar .logo-sub {
display: none;
}
.main-content {
margin-left: 60px;
padding: 16px;
}
.stats-grid {
grid-template-columns: repeat(2, 1fr);
}
.filter-bar {
flex-direction: column;
}
}
+67 -14
View File
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useRef, useCallback } from "react";
import { Edit3, Loader2 } from "lucide-react";
import { Edit3, Loader2, Check, X } from "lucide-react";
import {
getDeals,
updateDeal,
@@ -22,15 +22,25 @@ export default function Review() {
const [editingDeal, setEditingDeal] = useState(null);
const [showReviewed, setShowReviewed] = useState(true);
const [keyword, setKeyword] = useState("");
const [debouncedKeyword, setDebouncedKeyword] = useState("");
const [confirmingId, setConfirmingId] = useState(null);
const sentinelRef = useRef(null);
const debounceRef = useRef(null);
useEffect(() => {
loadCategories();
}, []);
// 搜索防抖 300ms
useEffect(() => {
if (debounceRef.current) clearTimeout(debounceRef.current);
debounceRef.current = setTimeout(() => setDebouncedKeyword(keyword), 300);
return () => clearTimeout(debounceRef.current);
}, [keyword]);
useEffect(() => {
loadReviewDeals(1, false);
}, [showReviewed, keyword]);
}, [showReviewed, debouncedKeyword]);
async function loadCategories() {
try {
@@ -57,7 +67,7 @@ export default function Review() {
sort_order: "DESC",
};
if (!showReviewed) params.reviewed = 0;
if (keyword) params.keyword = keyword;
if (debouncedKeyword) params.keyword = debouncedKeyword;
const result = await getDeals(params);
if (append) {
@@ -94,7 +104,7 @@ export default function Review() {
const handleLoadMore = useCallback(() => {
if (loadingMore || page >= totalPages) return;
loadReviewDeals(page + 1, true);
}, [loadingMore, page, totalPages, showReviewed, keyword]);
}, [loadingMore, page, totalPages, showReviewed, debouncedKeyword]);
// 自动滚动加载:哨兵元素进入视口时触发
useEffect(() => {
@@ -118,6 +128,16 @@ export default function Review() {
} catch (err) {}
}
// 行内快速确认:信任当前AI分类,一键标记已确认
async function handleQuickConfirm(deal) {
setConfirmingId(deal.id);
try {
await updateDeal(deal.id, { reviewed: 1 });
loadReviewDeals(1, false);
} catch (err) {}
setConfirmingId(null);
}
const hasMore = page < totalPages;
return (
@@ -184,7 +204,7 @@ export default function Review() {
{deals.map((deal) => (
<div
key={deal.id}
className={`review-item ${deal.reviewed ? "reviewed" : ""}`}
className={`review-item${deal.reviewed ? " reviewed" : ""}${deal.direction === "income" ? " income-border" : " expense-border"}`}
>
<div
className={`amount-col ${deal.direction === "income" ? "stat-value income" : "stat-value expense"}`}
@@ -199,17 +219,22 @@ export default function Review() {
{formatDate(deal.deal_date)} ·
{deal.counterparty && <span> {deal.counterparty} ·</span>}
{deal.category && (
<span
className="tag tag-matched"
style={{ marginLeft: 4 }}
>
{deal.category}
</span>
<span className="tag tag-matched">{deal.category}</span>
)}
{deal.reviewed === 1 && (
<span style={{ marginLeft: 6, color: "var(--success)" }}>
{deal.reviewed === 1 ? (
<span
className="tag tag-income"
style={{ marginLeft: 6 }}
>
✓ 已确认
</span>
) : (
<span
className="tag tag-unreviewed"
style={{ marginLeft: 6 }}
>
待确认
</span>
)}
{deal.match_count > 1 && (
<span
@@ -230,6 +255,23 @@ export default function Review() {
{deal.transactions.length}笔
</span>
)}
{deal.reviewed !== 1 && (
<button
className="btn btn-success btn-sm"
onClick={() => handleQuickConfirm(deal)}
disabled={confirmingId === deal.id}
>
{confirmingId === deal.id ? (
<Loader2
size={12}
style={{ animation: "spin 0.8s linear infinite" }}
/>
) : (
<Check size={12} />
)}
确认
</button>
)}
<button
className="btn btn-secondary btn-sm"
onClick={() => setEditingDeal({ ...deal })}
@@ -452,6 +494,17 @@ export default function Review() {
>
取消
</button>
<button
className="btn btn-secondary"
onClick={() =>
handleUpdateDeal(editingDeal.id, {
category: editingDeal.category,
ai_description: editingDeal.ai_description,
})
}
>
仅保存
</button>
<button
className="btn btn-primary"
onClick={() =>
@@ -462,7 +515,7 @@ export default function Review() {
})
}
>
保存并确认
<Check size={14} /> 保存并确认
</button>
</div>
</div>