功能迭代

This commit is contained in:
张锐 committed 2026-11-30 18:31:22 +08:00
1 parent 8e03c99cab
commit 9e87a4002a
23 files changed
+553 -38

No files matched your search

+56 -15
View File
@@ -222,6 +222,11 @@ function App({
const [categoryFilter, setCategoryFilter] = useState("");
const [statusFilter, setStatusFilter] = useState("");
const [categories, setCategories] = useState<CategoryOption[]>([]);
const [pageNo, setPageNo] = useState(1);
const [pageSize, setPageSize] = useState(20);
const [total, setTotal] = useState(0);
const [totalPages, setTotalPages] = useState(0);
const [previewImage, setPreviewImage] = useState("");
const [open, setOpen] = useState(false);
const [saving, setSaving] = useState(false);
const [siteDialogOpen, setSiteDialogOpen] = useState(false);
@@ -319,6 +324,8 @@ function App({
siteCode: SITE,
primaryCategoryCode: categoryFilter || null,
status: statusFilter || null,
pageNo,
pageSize,
})
: section === "pages"
? await post("/pages/list", { siteCode: SITE })
@@ -333,16 +340,22 @@ function App({
contentType: section,
primaryCategoryCode: categoryFilter || null,
status: statusFilter || null,
pageNo,
pageSize,
});
setItems(data.items || []);
setTotal(data.total || 0);
setTotalPages(data.totalPages || 0);
} catch (e) {
setError(e instanceof Error ? e.message : "加载失败");
setItems([]);
setTotal(0);
setTotalPages(0);
}
};
/** 加载产品、新闻或案例列表所需的分类筛选项。 */
const loadCategoryFilters = async () => {
if (!["products", "NEWS", "CASE"].includes(section)) {
if (!["products", "NEWS", "CASE", "HELP"].includes(section)) {
setCategories([]);
return;
}
@@ -361,11 +374,12 @@ function App({
};
useEffect(() => {
void load();
}, [section, categoryFilter, statusFilter]);
}, [section, categoryFilter, statusFilter, pageNo, pageSize]);
useEffect(() => {
setQuery("");
setCategoryFilter("");
setStatusFilter("");
setPageNo(1);
void loadCategoryFilters();
}, [section]);
useEffect(() => {
@@ -896,13 +910,13 @@ function App({
placeholder={`搜索${title}名称或路径`}
/>
</div>
{["products", "NEWS", "CASE"].includes(section) && (
{["products", "NEWS", "CASE", "HELP"].includes(section) && (
<div className="list-filters">
<select
aria-label="按分类筛选"
value={categoryFilter}
onChange={(event) =>
setCategoryFilter(event.target.value)
(setCategoryFilter(event.target.value), setPageNo(1))
}
>
<option value="">全部分类</option>
@@ -919,7 +933,7 @@ function App({
aria-label="按上下架状态筛选"
value={statusFilter}
onChange={(event) =>
setStatusFilter(event.target.value)
(setStatusFilter(event.target.value), setPageNo(1))
}
>
<option value="">全部状态</option>
@@ -936,7 +950,7 @@ function App({
</div>
)}
<section
className={`table ${section === "inquiries" ? "inquiry-table" : ""} ${section === "products" ? "product-list-table" : ["NEWS", "CASE"].includes(section) ? "content-list-table" : ""}`}
className={`table ${section === "inquiries" ? "inquiry-table" : ""} ${section === "products" ? "product-list-table" : ["NEWS", "CASE", "HELP"].includes(section) ? "content-list-table" : ""}`}
>
<div className="thead">
{section === "inquiries" ? (
@@ -960,7 +974,7 @@ function App({
<span>发布时间</span>
<span>操作</span>
</>
) : ["NEWS", "CASE"].includes(section) ? (
) : ["NEWS", "CASE", "HELP"].includes(section) ? (
<>
<span>图片</span>
<span>名称</span>
@@ -1035,17 +1049,22 @@ function App({
</>
) : (
<>
{["products", "NEWS", "CASE"].includes(
{["products", "NEWS", "CASE", "HELP"].includes(
section,
) && (
<span className="list-cover">
{item.coverMediaUrl ? (
<img
src={assetUrl(item.coverMediaUrl)}
alt={
item.productName || item.title || "封面"
}
/>
<button
type="button"
className="image-preview-trigger"
onClick={() => setPreviewImage(assetUrl(item.coverMediaUrl!))}
aria-label="放大查看图片"
>
<img
src={assetUrl(item.coverMediaUrl)}
alt={item.productName || item.title || "封面"}
/>
</button>
) : (
<span className="list-cover-empty">
暂无图片
@@ -1069,7 +1088,7 @@ function App({
{section === "products" && (
<code>{item.productCode || "--"}</code>
)}
{["products", "NEWS", "CASE"].includes(
{["products", "NEWS", "CASE", "HELP"].includes(
section,
) && (
<span>{item.primaryCategoryName || "未分类"}</span>
@@ -1149,6 +1168,22 @@ function App({
))
)}
</section>
{["products", "NEWS", "CASE", "HELP"].includes(section) && totalPages > 0 && (
<nav className="list-pagination" aria-label={`${title}分页`}>
<span>共 {total} 条</span>
<button type="button" disabled={pageNo <= 1} onClick={() => setPageNo(pageNo - 1)}>上一页</button>
<strong>{pageNo} / {totalPages}</strong>
<button type="button" disabled={pageNo >= totalPages} onClick={() => setPageNo(pageNo + 1)}>下一页</button>
<label>
每页
<select value={pageSize} onChange={(event) => (setPageSize(Number(event.target.value)), setPageNo(1))}>
<option value={10}>10</option>
<option value={20}>20</option>
<option value={50}>50</option>
</select>
</label>
</nav>
)}
</>
)}
</>
@@ -1257,6 +1292,12 @@ function App({
</section>
</div>
)}
{previewImage && (
<div className="image-preview-mask" onClick={() => setPreviewImage("")}>
<button type="button" aria-label="关闭图片预览" onClick={() => setPreviewImage("")}><X size={22} /></button>
<img src={previewImage} alt="图片放大预览" onClick={(event) => event.stopPropagation()} />
</div>
)}
{siteDialogOpen && (
<div className="mask" onMouseDown={() => setSiteDialogOpen(false)}>
<section
+1
View File
@@ -460,4 +460,5 @@ header p {
@media(max-width:900px){.specification-row{grid-template-columns:1fr 1fr}.specification-values{grid-column:1/-1}.specification-row button{grid-column:2;justify-self:end;width:42px}}
.template-editor-layout{max-width:1500px;margin:auto;display:grid;gap:20px}.template-editor-tip,.template-selection-note{margin:0;color:#73817d;font-size:13px;line-height:1.6}.template-table .thead,.template-table .row{grid-template-columns:minmax(0,2fr) 130px 90px 180px}.template-table .row-actions{display:flex;justify-content:flex-end;gap:12px}.template-table .row-actions .danger{color:#a93636}.template-table button svg{vertical-align:middle;margin-right:4px}@media(max-width:760px){.template-table .thead{display:none}.template-table .row{grid-template-columns:1fr}.template-table .row-actions{justify-content:flex-start}}
.media-filters{display:flex;gap:10px}.media-result-summary{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px;color:#66757b;font-size:13px}.media-result-summary label{display:flex;align-items:center;gap:8px}.media-result-summary select{height:34px;border:1px solid #d8dee3;border-radius:4px;background:#fff;padding:0 8px}.media-tag{height:30px;border:1px dashed #b9c7c3;background:#f8faf9;color:#647570;border-radius:4px;padding:0 8px;display:flex;align-items:center;gap:6px;justify-content:center;cursor:pointer;overflow:hidden}.media-tag.assigned{border-style:solid;background:#e9f3ef;color:#176b5b}.media-tag-editor{display:grid;grid-template-columns:minmax(0,1fr) 30px 30px;gap:5px}.media-tag-editor input{min-width:0;border:1px solid #b8c6c2;border-radius:4px;padding:6px 8px}.media-tag-editor button{border:1px solid #d5ddda;background:#fff;border-radius:4px;display:grid;place-items:center;cursor:pointer}.media-pagination{display:flex;align-items:center;justify-content:center;gap:6px;margin-top:20px}.media-pagination button{width:36px;height:36px;border:1px solid #d5ddda;background:#fff;border-radius:4px;display:grid;place-items:center;cursor:pointer}.media-pagination button.active{background:#176b5b;border-color:#176b5b;color:#fff}.media-pagination button:disabled{opacity:.45;cursor:not-allowed}.media-pagination span{margin-left:8px;color:#718087;font-size:13px}@media(max-width:760px){.media-filters{display:grid}.media-result-summary{align-items:flex-start}.media-pagination{flex-wrap:wrap}}
.image-preview-trigger{display:block;width:100%;height:100%;padding:0;border:0;background:transparent;cursor:zoom-in}.image-preview-trigger img{display:block;width:100%;height:100%;object-fit:cover}.image-preview-mask{position:fixed;inset:0;z-index:3000;display:grid;place-items:center;padding:48px;background:rgba(10,18,24,.84)}.image-preview-mask>button{position:absolute;top:20px;right:24px;width:40px;height:40px;border:0;border-radius:50%;display:grid;place-items:center;background:#fff;color:#17242d;cursor:pointer}.image-preview-mask>img{max-width:min(94vw,1400px);max-height:90vh;object-fit:contain;border-radius:6px;box-shadow:0 18px 60px rgba(0,0,0,.45)}.list-pagination{display:flex;align-items:center;justify-content:flex-end;gap:10px;margin:18px 0 4px;color:#66757b;font-size:13px}.list-pagination button,.list-pagination select{height:34px;border:1px solid #d5ddda;border-radius:4px;background:#fff;padding:0 12px}.list-pagination button{cursor:pointer}.list-pagination button:disabled{opacity:.45;cursor:not-allowed}.list-pagination label{display:flex;align-items:center;gap:6px}
.dashboard-page{padding:34px 38px 48px;max-width:1600px;margin:0 auto}.dashboard-header{display:flex;align-items:flex-start;justify-content:space-between;margin-bottom:26px}.dashboard-header h1{font-size:30px;margin:0 0 7px;letter-spacing:0}.dashboard-header p{margin:0;color:#76827f}.dashboard-updated{display:flex;align-items:center;gap:12px;color:#7b8784;font-size:13px}.dashboard-updated button{width:38px;height:38px;border:1px solid #d9e0dd;background:#fff;display:grid;place-items:center;color:#176b5b}.spin{animation:dashboard-spin 1s linear infinite}@keyframes dashboard-spin{to{transform:rotate(360deg)}}.dashboard-inline-error{padding:10px 14px;margin-bottom:18px;background:#fff3f1;color:#a43d31;border-left:3px solid #c95043}.dashboard-kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));border:1px solid #dfe5e2;background:#fff;margin-bottom:20px}.dashboard-metric{min-width:0;height:132px;border:0;border-right:1px solid #e5e9e7;background:#fff;padding:24px;display:flex;align-items:flex-start;gap:16px;text-align:left;color:#182522}.dashboard-metric:last-child{border-right:0}.dashboard-metric:not(:disabled){cursor:pointer}.dashboard-metric:not(:disabled):hover{background:#f7faf9}.dashboard-metric>span:nth-child(2){display:grid;gap:4px}.dashboard-metric small{color:#74817d;font-size:12px}.dashboard-metric strong{font-size:29px;letter-spacing:0}.dashboard-metric em{font-style:normal;color:#697672;font-size:12px}.dashboard-metric>svg{margin-left:auto;color:#176b5b}.metric-icon{width:38px;height:38px;display:grid;place-items:center;background:#e9f3ef;color:#176b5b}.metric-icon svg{width:19px}.dashboard-grid{display:grid;gap:20px;margin-bottom:20px}.dashboard-primary-grid{grid-template-columns:minmax(0,1.7fr) minmax(320px,.8fr)}.dashboard-secondary-grid{grid-template-columns:minmax(0,1.35fr) minmax(250px,.7fr) minmax(0,1.15fr)}.dashboard-panel{background:#fff;border:1px solid #dfe5e2;padding:24px;min-width:0}.dashboard-panel-title{height:30px;display:flex;align-items:start;justify-content:space-between}.dashboard-panel-title h2{font-size:17px;margin:0;letter-spacing:0}.dashboard-panel-title>span,.dashboard-panel-title button{font-size:12px;color:#7b8784}.dashboard-panel-title button{border:0;background:transparent;display:flex;align-items:center;gap:4px;cursor:pointer}.traffic-legend{display:flex;justify-content:flex-end;gap:16px;font-size:11px;color:#77837f}.traffic-legend span{display:flex;align-items:center;gap:5px}.traffic-legend i{width:8px;height:8px}.traffic-legend .pv,.traffic-bars .pv{background:#176b5b}.traffic-legend .uv,.traffic-bars .uv{background:#b9d6cc}.traffic-chart{height:230px;display:flex;align-items:end;gap:9px;border-bottom:1px solid #dfe5e2;padding-top:24px}.traffic-day{height:100%;flex:1;min-width:0;display:grid;grid-template-rows:1fr 22px;gap:8px}.traffic-bars{display:flex;align-items:end;justify-content:center;gap:3px}.traffic-bars i{width:min(12px,40%);min-height:3px}.traffic-day>span{text-align:center;font-size:10px;color:#83908c;white-space:nowrap}.content-stat-list{display:grid;gap:20px;margin-top:22px}.content-stat-list button{border:0;background:transparent;padding:0;text-align:left;cursor:pointer}.content-stat-list button>span{display:flex;justify-content:space-between}.content-stat-list b{font-size:13px}.content-stat-list small{color:#76827f}.content-stat-list i,.device-list i{display:block;height:5px;background:#edf1ef;margin-top:8px}.content-stat-list em,.device-list em{display:block;height:100%;background:#176b5b}.publish-summary{display:flex;gap:8px;align-items:center;margin-top:24px;padding-top:18px;border-top:1px solid #e2e7e5;color:#52615d;font-size:12px}.top-page-list{margin-top:14px}.top-page-list>div{display:grid;grid-template-columns:28px minmax(0,1fr) auto;gap:10px;align-items:center;padding:11px 0;border-bottom:1px solid #edf0ef}.top-page-list>div>b{color:#9aa5a1;font-size:11px}.top-page-list span{min-width:0;display:grid}.top-page-list strong,.top-page-list small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.top-page-list strong{font-size:13px}.top-page-list small{font-size:11px;color:#86918e}.top-page-list em{font-style:normal;font-size:12px;color:#52615d}.device-list{display:grid;gap:20px;margin-top:22px}.device-list>div{display:grid;grid-template-columns:1fr auto;align-items:center}.device-list span{display:flex;gap:7px;align-items:center;font-size:12px}.device-list b{font-size:12px}.device-list i{grid-column:1/-1}.recent-inquiries{margin-top:12px}.recent-inquiries button{width:100%;border:0;border-bottom:1px solid #edf0ef;background:transparent;padding:12px 0;display:flex;justify-content:space-between;gap:12px;text-align:left;cursor:pointer}.recent-inquiries button:hover strong{color:#176b5b}.recent-inquiries span,.recent-inquiries em{display:grid;gap:3px;min-width:0}.recent-inquiries strong{font-size:13px}.recent-inquiries small{font-size:11px;color:#83908c;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.recent-inquiries emLine truncated