feat: add media center and email campaign schema

This commit is contained in:
张锐 committed 2026-11-21 14:52:58 +08:00
1 parent 81e990ea39
commit 74504cda1b
10 files changed
+60 -9

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
import { useEffect, useState } from "react";
import { Image, Search } from "lucide-react";
const API="http://localhost:8081/api/admin/v1";const SITE="SIT0000000000001";
type Media={mediaCode:string;mediaType:string;originalFileName:string;url:string;altText?:string};
/** 素材中心页面。 */
export default function MediaCenter(){const [items,setItems]=useState<Media[]>([]);const [type,setType]=useState("ALL");const [query,setQuery]=useState("");useEffect(()=>{fetch(API+"/media/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({siteCode:SITE,mediaType:type})}).then(r=>r.json()).then(d=>setItems(d.items||[])).catch(()=>setItems([]))},[type]);const filtered=items.filter(x=>x.originalFileName.toLowerCase().includes(query.toLowerCase()));return <div className="content-page"><header><div><h1>素材中心</h1><p>集中管理上传过的图片和视频,编辑内容时可直接复用</p></div></header><section className="toolbar"><div className="search"><Search size={17}/><input placeholder="搜索文件名" value={query} onChange={e=>setQuery(e.target.value)}/></div><select value={type} onChange={e=>setType(e.target.value)}><option value="ALL">全部素材</option><option value="IMAGE">图片</option><option value="VIDEO">视频</option></select></section><section className="media-grid">{filtered.map(item=><article className="media-card" key={item.mediaCode}>{item.mediaType==="VIDEO"?<video src={item.url} controls/>:<img src={`http://localhost:8081${item.url}`} alt={item.altText||item.originalFileName}/>}<strong title={item.originalFileName}>{item.originalFileName}</strong><small>{item.mediaCode}</small><button className="link" onClick={()=>navigator.clipboard.writeText(item.url)}>复制地址</button></article>)}</section></div>}
+6 -3
View File
@@ -7,6 +7,7 @@ import {
FileText,
FolderTree,
HelpCircle,
Image,
Mail,
Newspaper,
PanelsTopLeft,
@@ -25,11 +26,12 @@ import InquirySettingsPanel from "./InquirySettingsPanel";
import PageEditor from "./PageEditor";
import DecorationEditor from "./DecorationEditor";
import CustomCodeManager from "./CustomCodeManager";
import MediaCenter from "./MediaCenter";
const API = "http://localhost:8081/api/admin/v1";
const SITE_WEB = "http://localhost:5174";
const SITE = "SIT0000000000001";
type Section = "products" | "product-categories" | "NEWS" | "NEWS-categories" | "CASE" | "CASE-categories" | "HELP" | "HELP-categories" | "pages" | "decoration" | "custom-code" | "inquiries" | "inquiry-settings";
type Section = "products" | "product-categories" | "NEWS" | "NEWS-categories" | "CASE" | "CASE-categories" | "HELP" | "HELP-categories" | "pages" | "decoration" | "custom-code" | "media" | "inquiries" | "inquiry-settings";
type EditorialSection = "NEWS" | "CASE" | "HELP";
type ContentEditorState = { contentType: EditorialSection; contentCode: string };
type Item = {
@@ -66,12 +68,13 @@ const menus = [
{ key: "pages" as Section, label: "页面", icon: FileText },
{ key: "decoration" as Section, label: "店铺装修", icon: Paintbrush },
{ key: "custom-code" as Section, label: "自定义代码", icon: Code2 },
{ key: "media" as Section, label: "素材中心", icon: Image },
{ key: "inquiries" as Section, label: "询盘", icon: Mail },
];
const sectionLabels: Record<Section, string> = {
products: "产品", "product-categories": "产品分类", NEWS: "新闻", "NEWS-categories": "新闻分类",
CASE: "案例", "CASE-categories": "案例分类", HELP: "帮助", "HELP-categories": "帮助分类",
pages: "页面", decoration: "店铺装修", "custom-code": "自定义代码", inquiries: "询盘", "inquiry-settings": "询盘设置",
pages: "页面", decoration: "店铺装修", "custom-code": "自定义代码", media: "素材中心", inquiries: "询盘", "inquiry-settings": "询盘设置",
};
const statusLabels: Record<string, string> = { DRAFT: "草稿", PUBLISHED: "已上架", OFFLINE: "已下架" };
@@ -314,7 +317,7 @@ function App() {
</div>
</aside>
<main>
{section === "decoration" ? <DecorationEditor onBack={() => navigateSection("pages")}/> : section === "custom-code" ? <CustomCodeManager/> : editingProduct !== null ? <ProductEditor productCode={editingProduct || undefined} onBack={closeProductEditor} /> : editingContent !== null ? <ContentEditor contentType={editingContent.contentType} contentCode={editingContent.contentCode || undefined} onBack={closeContentEditor} /> : editingPage !== null ? <PageEditor pageCode={editingPage || undefined} onBack={closePageEditor}/> : <>
{section === "decoration" ? <DecorationEditor onBack={() => navigateSection("pages")}/> : section === "custom-code" ? <CustomCodeManager/> : section === "media" ? <MediaCenter/> : editingProduct !== null ? <ProductEditor productCode={editingProduct || undefined} onBack={closeProductEditor} /> : editingContent !== null ? <ContentEditor contentType={editingContent.contentType} contentCode={editingContent.contentCode || undefined} onBack={closeContentEditor} /> : editingPage !== null ? <PageEditor pageCode={editingPage || undefined} onBack={closePageEditor}/> : <>
{section.endsWith("-categories") ? <CategoryManager contentType={section === "NEWS-categories" ? "NEWS" : section === "CASE-categories" ? "CASE" : section === "HELP-categories" ? "HELP" : undefined}/> : <>
<header>
<div>
+1 -1
View File
@@ -1,4 +1,4 @@
.decorator-page-select{margin-left:auto;min-width:150px;height:40px;padding:0 12px;border:1px solid #dce2e6;border-radius:5px;background:#fff;color:#17211f;font-size:14px}
.decorator-page-select{margin-left:auto;min-width:150px;height:40px;padding:0 12px;border:1px solid #dce2e6;border-radius:5px;background:#fff;color:#17211f;font-size:14px}.media-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:16px}.media-card{display:grid;gap:8px;background:#fff;border:1px solid #dde3e7;border-radius:6px;padding:12px;min-width:0}.media-card img,.media-card video{width:100%;height:150px;object-fit:cover;background:#eef1f4;border-radius:4px}.media-card strong,.media-card small{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.media-card small{color:#87918f}
:root {
font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;
color: #18212f;