feat: initialize shoplix platform

This commit is contained in:
张锐 committed 2026-11-21 14:09:59 +08:00
commit de2074a43b
277 files changed
+10407

No files matched your search

+65
View File
@@ -0,0 +1,65 @@
import React, { useEffect, useMemo, useState } from "react";
import { ChevronDown, ChevronRight, Edit3, Plus, X } from "lucide-react";
const API = "http://localhost:8081/api/admin/v1";
const SITE = "SIT0000000000001";
type ContentType = "NEWS" | "CASE" | "HELP";
type Category = { categoryCode: string; parentCategoryCode: string; categoryName: string; slug: string; description?: string; sortNo: number; status: string };
type TreeCategory = Category & { depth: number; children: TreeCategory[] };
type Props = { contentType?: ContentType };
async function post(path: string, body: unknown) {
const response = await fetch(API + path, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
if (!response.ok) throw new Error((await response.json()).message || "请求失败");
return response.json();
}
/** 产品与内容共用的树形分类管理页面。 */
export default function CategoryManager({ contentType }: Props) {
const isProduct = !contentType;
const maxDepth = isProduct ? 3 : 2;
const label = isProduct ? "产品" : ({ NEWS: "新闻", CASE: "案例", HELP: "帮助" } as const)[contentType];
const basePath = isProduct ? "/products/categories" : "/contents/categories";
const [items, setItems] = useState<Category[]>([]);
const [expanded, setExpanded] = useState<Set<string>>(new Set());
const [editing, setEditing] = useState<Category | null | undefined>(undefined);
const [parentCode, setParentCode] = useState("");
const [error, setError] = useState("");
const [saving, setSaving] = useState(false);
const [form, setForm] = useState({ categoryName: "", slug: "", description: "", sortNo: 30, status: "DRAFT" });
const load = async () => {
try {
setError("");
const data = await post(`${basePath}/list`, isProduct ? { siteCode: SITE } : { siteCode: SITE, contentType });
setItems(data.items || []);
setExpanded(new Set((data.items || []).map((item: Category) => item.categoryCode)));
} catch (loadError) { setError(loadError instanceof Error ? loadError.message : "分类加载失败"); }
};
useEffect(() => { void load(); }, [contentType]);
const tree = useMemo(() => {
const children = new Map<string, Category[]>();
items.forEach((item) => { const parent = item.parentCategoryCode || ""; children.set(parent, [...(children.get(parent) || []), item]); });
const build = (parent: string, depth: number): TreeCategory[] => (children.get(parent) || []).sort((a, b) => a.sortNo - b.sortNo).map((item) => ({ ...item, depth, children: build(item.categoryCode, depth + 1) }));
return build("", 1);
}, [items]);
const visibleRows = useMemo(() => {
const rows: TreeCategory[] = [];
const append = (nodes: TreeCategory[]) => nodes.forEach((node) => { rows.push(node); if (expanded.has(node.categoryCode)) append(node.children); });
append(tree); return rows;
}, [tree, expanded]);
const openCreate = (parent = "") => { setParentCode(parent); setEditing(null); setForm({ categoryName: "", slug: "", description: "", sortNo: 30, status: "DRAFT" }); };
const openEdit = (item: Category) => { setParentCode(item.parentCategoryCode || ""); setEditing(item); setForm({ categoryName: item.categoryName, slug: item.slug, description: item.description || "", sortNo: item.sortNo, status: item.status }); };
const save = async () => {
try {
setSaving(true); setError("");
await post(`${basePath}/save`, { categoryCode: editing?.categoryCode, siteCode: SITE, ...(isProduct ? {} : { contentType }), parentCategoryCode: parentCode, categoryName: form.categoryName, slug: form.slug, description: form.description, coverMediaCode: null, sortNo: form.sortNo, status: form.status });
setEditing(undefined); await load();
} catch (saveError) { setError(saveError instanceof Error ? saveError.message : "分类保存失败"); } finally { setSaving(false); }
};
return <div className="category-manager"><div className="category-heading"><div><h1>{label}分类</h1><p>最多支持 {maxDepth} 级分类,使用英文名称维护前台目录。</p></div><button className="primary" onClick={() => openCreate()}><Plus size={17}/>添加分类</button></div>{error && <div className="notice">{error}</div>}<section className="category-table"><div className="category-table-head"><span>分类</span><span>英文路径</span><span>状态</span><span>操作</span></div>{visibleRows.length === 0 ? <div className="empty"><strong>暂无{label}分类</strong><p>点击右上角添加第一个顶级分类。</p></div> : visibleRows.map((item) => <div className="category-row" key={item.categoryCode}><div className="category-name" style={{ paddingLeft: `${(item.depth - 1) * 28}px` }}>{item.children.length > 0 ? <button className="tree-toggle" title={expanded.has(item.categoryCode) ? "收起" : "展开"} onClick={() => setExpanded((current) => { const next = new Set(current); next.has(item.categoryCode) ? next.delete(item.categoryCode) : next.add(item.categoryCode); return next; })}>{expanded.has(item.categoryCode) ? <ChevronDown size={17}/> : <ChevronRight size={17}/>}</button> : <span className="tree-space"/>}<strong>{item.categoryName}</strong><small>{item.categoryCode}</small></div><code>/{item.slug}</code><span className={`status ${item.status.toLowerCase()}`}>{item.status}</span><div className="category-actions">{item.depth < maxDepth && <button title="新增子分类" onClick={() => openCreate(item.categoryCode)}><Plus size={17}/></button>}<button title="编辑分类" onClick={() => openEdit(item)}><Edit3 size={17}/></button></div></div>)}</section>
{editing !== undefined && <div className="mask"><section className="category-dialog"><div className="dialog-head"><div><h2>{editing ? `编辑${label}分类` : `新增${label}分类`}</h2><p>{parentCode ? "当前分类将创建在所选父分类下" : "创建顶级分类"}</p></div><button className="icon" aria-label="关闭" onClick={() => setEditing(undefined)}><X size={19}/></button></div><div className="form-grid"><label><span>分类名称</span><input value={form.categoryName} onChange={(event) => setForm({ ...form, categoryName: event.target.value })}/></label><label><span>英文路径</span><input value={form.slug} onChange={(event) => setForm({ ...form, slug: event.target.value.toLowerCase().replace(/[^a-z0-9-]/g, "-") })}/></label><label className="wide"><span>分类描述</span><textarea rows={4} value={form.description} onChange={(event) => setForm({ ...form, description: event.target.value })}/></label><label><span>排序</span><input type="number" value={form.sortNo} onChange={(event) => setForm({ ...form, sortNo: Number(event.target.value) })}/></label><label><span>状态</span><select value={form.status} onChange={(event) => setForm({ ...form, status: event.target.value })}><option value="DRAFT">草稿</option><option value="PUBLISHED">上架</option><option value="OFFLINE">下线</option></select></label></div><div className="dialog-foot"><button onClick={() => setEditing(undefined)}>取消</button><button className="primary" disabled={saving || !form.categoryName || !form.slug} onClick={save}>{saving ? "保存中" : "保存"}</button></div></section></div>}
</div>;
}
+78
View File
@@ -0,0 +1,78 @@
import React, { useEffect, useState } from "react";
import { EditorContent, useEditor } from "@tiptap/react";
import StarterKit from "@tiptap/starter-kit";
import Link from "@tiptap/extension-link";
import Image from "@tiptap/extension-image";
import { ArrowLeft, Bold, Heading2, Heading3, Image as ImageIcon, Italic, Link as LinkIcon, List, Plus, Redo2, Save, Trash2, Undo2 } from "lucide-react";
const API = "http://localhost:8081/api/admin/v1";
const SITE = "SIT0000000000001";
type ContentType = "NEWS" | "CASE" | "HELP";
type Heading = { level: number; text: string; sortNo: number };
type Props = { contentType: ContentType; contentCode?: string; onBack: () => void };
const META: Record<ContentType, { label: string; route: string; seoType: string }> = {
NEWS: { label: "新闻", route: "news", seoType: "NEWS_DETAIL" },
CASE: { label: "案例", route: "cases", seoType: "CASE_DETAIL" },
HELP: { label: "帮助", route: "help", seoType: "HELP_DETAIL" },
};
async function post(path: string, body: unknown) {
const response = await fetch(API + path, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
if (!response.ok) throw new Error((await response.json()).message || "请求失败");
return response.json();
}
/** 新闻、案例和帮助共用的独立内容编辑页。 */
export default function ContentEditor({ contentType, contentCode, onBack }: Props) {
const meta = META[contentType];
const [form, setForm] = useState({ title: "", slug: "", summary: "", primaryCategoryCode: "", coverMediaCode: "", coverMediaUrl: "", authorName: "", sourceName: "", featured: false, sortNo: 30, status: "DRAFT" });
const [seo, setSeo] = useState({ title: "", description: "", keywords: "", h1: "", canonicalUrl: "", robots: "index,follow", ogTitle: "", ogDescription: "", ogImageUrl: "", status: "DRAFT" });
const [headings, setHeadings] = useState<Heading[]>([]);
const [saving, setSaving] = useState(false);
const [notice, setNotice] = useState("");
const editor = useEditor({ extensions: [StarterKit, Link.configure({ openOnClick: false }), Image], content: "<p></p>" });
useEffect(() => {
if (!contentCode) return;
post("/contents/detail", { siteCode: SITE, contentCode, contentType }).then((data) => {
setForm({ ...data, coverMediaUrl: data.coverMediaUrl || "" });
editor?.commands.setContent(data.contentBody || "<p></p>");
}).catch((error) => setNotice(error.message));
post("/seo/detail", { siteCode: SITE, pageType: meta.seoType, targetCode: contentCode }).then((data) => {
setSeo({ title: data.title, description: data.description, keywords: data.keywords || "", h1: data.h1, canonicalUrl: data.canonicalUrl || "", robots: data.robots, ogTitle: data.ogTitle || "", ogDescription: data.ogDescription || "", ogImageUrl: data.ogImageUrl || "", status: data.status });
setHeadings(data.headings || []);
}).catch(() => undefined);
}, [contentCode, contentType, editor, meta.seoType]);
const upload = async (file?: File) => {
if (!file) return;
try {
const body = new FormData(); body.append("siteCode", SITE); body.append("altText", form.title); body.append("file", file);
const response = await fetch(API + "/media/upload-image", { method: "POST", body });
if (!response.ok) throw new Error((await response.json()).message || "上传失败");
const data = await response.json();
setForm({ ...form, coverMediaCode: data.mediaCode, coverMediaUrl: data.url });
} catch (error) { setNotice(error instanceof Error ? error.message : "上传失败"); }
};
const save = async () => {
if (!editor) return;
try {
setSaving(true); setNotice("");
const result = await post("/contents/save", { contentCode, siteCode: SITE, contentType, primaryCategoryCode: form.primaryCategoryCode, title: form.title, slug: form.slug, summary: form.summary, contentBody: editor.getHTML(), coverMediaCode: form.coverMediaCode, authorName: form.authorName, sourceName: form.sourceName, featured: form.featured, sortNo: form.sortNo, status: form.status });
await post("/seo/save", { siteCode: SITE, pageType: meta.seoType, targetCode: result.contentCode, title: seo.title || form.title, description: seo.description || form.summary, keywords: seo.keywords, h1: seo.h1 || form.title, canonicalUrl: seo.canonicalUrl || `/${meta.route}/${form.slug}`, robots: seo.robots, ogTitle: seo.ogTitle, ogDescription: seo.ogDescription, ogImageUrl: seo.ogImageUrl || form.coverMediaUrl, structuredData: null, status: form.status, headings });
setNotice(`${meta.label}与 SEO 已保存`);
if (!contentCode) setTimeout(onBack, 500);
} catch (error) { setNotice(error instanceof Error ? error.message : "保存失败"); } finally { setSaving(false); }
};
const addLink = () => { const href = window.prompt("请输入链接地址"); if (href) editor?.chain().focus().setLink({ href }).run(); };
const addImage = () => { const src = window.prompt("请输入图片地址"); if (src) editor?.chain().focus().setImage({ src }).run(); };
return <div className="product-editor"><div className="editor-top"><div className="breadcrumb-title"><button className="back" onClick={onBack}><ArrowLeft size={17}/>{meta.label}管理</button><span>/</span><h1>{contentCode ? `编辑${meta.label}` : `新增${meta.label}`}</h1>{notice&&<em>{notice}</em>}</div><div className="editor-actions"><button onClick={onBack}>取消</button><button className="primary" disabled={saving || !form.title || !form.slug} onClick={save}><Save size={16}/>{saving ? "保存中" : "保存"}</button></div></div><div className="editor-layout"><div className="editor-main">
<section className="edit-section"><h2>基础信息</h2><div className="edit-grid"><Field label={`${meta.label}标题 *`}><input value={form.title} onChange={(event) => setForm({ ...form, title: event.target.value })}/></Field><Field label="英文路径 *"><input value={form.slug} onChange={(event) => setForm({ ...form, slug: event.target.value.toLowerCase().replace(/[^a-z0-9-]/g, "-") })}/></Field><Field label="作者"><input value={form.authorName || ""} onChange={(event) => setForm({ ...form, authorName: event.target.value })}/></Field><Field label="来源"><input value={form.sourceName || ""} onChange={(event) => setForm({ ...form, sourceName: event.target.value })}/></Field><Field label="排序"><input type="number" value={form.sortNo} onChange={(event) => setForm({ ...form, sortNo: Number(event.target.value) })}/></Field><Field wide label={`${meta.label}简介 *`}><textarea rows={4} value={form.summary || ""} onChange={(event) => setForm({ ...form, summary: event.target.value })}/></Field></div></section>
<section className="edit-section"><h2>{meta.label}封面</h2><div className="cover-upload">{form.coverMediaUrl ? <img src={`http://localhost:8081${form.coverMediaUrl}`} alt={`${meta.label}封面预览`}/> : <ImageIcon size={42}/>}<label><span>选择图片</span><input type="file" accept="image/jpeg,image/png,image/webp,image/gif" onChange={(event) => upload(event.target.files?.[0])}/></label><p>支持 JPG、PNG、WebP、GIF,单图不超过 10MB</p></div></section>
<section className="edit-section"><h2>{meta.label}详情 *</h2><div className="rich-editor"><div className="rich-toolbar"><Tool title="撤销" onClick={() => editor?.chain().focus().undo().run()}><Undo2/></Tool><Tool title="重做" onClick={() => editor?.chain().focus().redo().run()}><Redo2/></Tool><Tool title="粗体" active={editor?.isActive("bold")} onClick={() => editor?.chain().focus().toggleBold().run()}><Bold/></Tool><Tool title="斜体" active={editor?.isActive("italic")} onClick={() => editor?.chain().focus().toggleItalic().run()}><Italic/></Tool><Tool title="二级标题" active={editor?.isActive("heading", { level: 2 })} onClick={() => editor?.chain().focus().toggleHeading({ level: 2 }).run()}><Heading2/></Tool><Tool title="三级标题" active={editor?.isActive("heading", { level: 3 })} onClick={() => editor?.chain().focus().toggleHeading({ level: 3 }).run()}><Heading3/></Tool><Tool title="项目列表" onClick={() => editor?.chain().focus().toggleBulletList().run()}><List/></Tool><Tool title="链接" onClick={addLink}><LinkIcon/></Tool><Tool title="插入图片" onClick={addImage}><ImageIcon/></Tool></div><EditorContent editor={editor}/></div></section>
</div><aside className="editor-side"><section className="edit-section"><h2>发布</h2><Field label="状态"><select value={form.status} onChange={(event) => setForm({ ...form, status: event.target.value })}><option value="DRAFT">草稿</option><option value="PUBLISHED">上架</option><option value="OFFLINE">下线</option></select></Field><label className="check"><input type="checkbox" checked={form.featured} onChange={(event) => setForm({ ...form, featured: event.target.checked })}/>推荐内容</label></section><section className="edit-section"><h2>搜索引擎优化</h2><Field label="SEO 标题"><input maxLength={70} value={seo.title} onChange={(event) => setSeo({ ...seo, title: event.target.value })}/></Field><Field label="SEO 描述"><textarea maxLength={160} rows={4} value={seo.description} onChange={(event) => setSeo({ ...seo, description: event.target.value })}/></Field><Field label="SEO 关键词"><input value={seo.keywords} onChange={(event) => setSeo({ ...seo, keywords: event.target.value })}/></Field><Field label="H1"><input maxLength={120} value={seo.h1} onChange={(event) => setSeo({ ...seo, h1: event.target.value })}/></Field><Field label="Canonical"><input value={seo.canonicalUrl} placeholder={`/${meta.route}/${form.slug}`} onChange={(event) => setSeo({ ...seo, canonicalUrl: event.target.value })}/></Field><div className="section-head"><h3>H2 / H3 标签</h3><button onClick={() => setHeadings([...headings, { level: 2, text: "", sortNo: headings.length }])}><Plus size={15}/></button></div>{headings.map((heading, index) => <div className="heading-row" key={index}><select value={heading.level} onChange={(event) => setHeadings(headings.map((item, position) => position === index ? { ...item, level: Number(event.target.value) } : item))}><option value={2}>H2</option><option value={3}>H3</option></select><input value={heading.text} onChange={(event) => setHeadings(headings.map((item, position) => position === index ? { ...item, text: event.target.value } : item))}/><button onClick={() => setHeadings(headings.filter((_, position) => position !== index))}><Trash2 size={15}/></button></div>)}</section></aside></div></div>;
}
function Field({ label, wide, children }: { label: string; wide?: boolean; children: React.ReactNode }) { return <label className={wide ? "wide" : ""}><span>{label}</span>{children}</label>; }
function Tool({ title, active, onClick, children }: { title: string; active?: boolean; onClick: () => void; children: React.ReactElement }) { return <button type="button" title={title} className={active ? "active" : ""} onClick={onClick}>{React.cloneElement(children, { size: 18 } as never)}</button>; }
+15
View File
@@ -0,0 +1,15 @@
import { useEffect, useState } from "react";
import { Code2, Pencil, Plus, Trash2 } from "lucide-react";
const API = "http://localhost:8081/api/admin/v1";
const SITE = "SIT0000000000001";
type CodeItem = { code:string; siteCode:string; title:string; content:string; locale:string; device:string; position:string; enabled:boolean; sortNo:number };
async function post(path:string, body:unknown) { const r=await fetch(API+path,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(body)}); if(!r.ok) throw new Error("请求失败"); return r.json(); }
/** 自定义代码管理页面。 */
export default function CustomCodeManager() {
const [items,setItems]=useState<CodeItem[]>([]); const [editing,setEditing]=useState<CodeItem|null>(null); const [notice,setNotice]=useState("");
const load=()=>post("/custom-codes/list",{siteCode:SITE}).then(d=>setItems(d.items||[])).catch(e=>setNotice(e.message)); useEffect(()=>{void load()},[]);
const save=async()=>{if(!editing)return;try{await post("/custom-codes/save",{...editing,enabled:editing.enabled});setEditing(null);setNotice("已保存");void load()}catch(e){setNotice(e instanceof Error?e.message:"保存失败")}};
const remove=async(code:string)=>{if(!confirm("确定删除这段代码吗?"))return;await post(`/custom-codes/delete?siteCode=${SITE}&code=${code}`,{});void load()};
return <div className="content-page"><header><div><h1>自定义代码</h1><p>用于 Google Search Console、GTM、GA 和客服插件等代码注入</p></div><button className="primary" onClick={()=>setEditing({code:"",siteCode:SITE,title:"",content:"",locale:"ALL",device:"ALL",position:"HEAD",enabled:true,sortNo:30})}><Plus size={17}/>新建代码</button></header>{notice&&<div className="notice">{notice}</div>}<section className="table"><div className="thead"><span>标题</span><span>语言站</span><span>终端</span><span>位置</span><span>状态</span><span>操作</span></div>{items.map(item=><div className="row" key={item.code}><span><strong>{item.title}</strong><small>{item.code}</small></span><span>{item.locale}</span><span>{item.device}</span><span>{item.position}</span><span className={`status ${item.enabled?"published":"draft"}`}>{item.enabled?"已启用":"已停用"}</span><div className="row-actions"><button className="link" onClick={()=>setEditing(item)}><Pencil size={14}/>编辑</button><button className="link danger" onClick={()=>void remove(item.code)}><Trash2 size={14}/>删除</button></div></div>)}</section>{editing&&<div className="mask"><section className="dialog"><div className="dialog-head"><div><h2>{editing.code?"编辑代码":"新建代码"}</h2><p>GSC 验证通常选择 HEAD;脚本请根据供应商要求选择注入位置。</p></div><button className="icon" onClick={()=>setEditing(null)}>×</button></div><div className="form-grid"><label><span>标题</span><input value={editing.title} onChange={e=>setEditing({...editing,title:e.target.value})}/></label><label><span>代码内容</span><textarea rows={10} value={editing.content} onChange={e=>setEditing({...editing,content:e.target.value})}/></label><label><span>语言站点</span><input value={editing.locale} onChange={e=>setEditing({...editing,locale:e.target.value})}/></label><label><span>终端</span><select value={editing.device} onChange={e=>setEditing({...editing,device:e.target.value})}><option value="ALL">全部终端</option><option value="DESKTOP">桌面端</option><option value="MOBILE">移动端</option></select></label><label><span>注入位置</span><select value={editing.position} onChange={e=>setEditing({...editing,position:e.target.value})}><option value="HEAD">顶部 &lt;head&gt;</option><option value="BODY_START">正文顶部</option><option value="BODY_END">正文底部</option></select></label><label><span>排序</span><input type="number" value={editing.sortNo} onChange={e=>setEditing({...editing,sortNo:Number(e.target.value)})}/></label><label className="check"><input type="checkbox" checked={editing.enabled} onChange={e=>setEditing({...editing,enabled:e.target.checked})}/>启用</label></div><div className="dialog-actions"><button onClick={()=>setEditing(null)}>取消</button><button className="primary" onClick={()=>void save()}><Code2 size={16}/>保存</button></div></section></div>}</div>;
}
+51
View File
@@ -0,0 +1,51 @@
import { useEffect, useMemo, useState } from "react";
import { ChevronDown, ChevronUp, Copy, Eye, EyeOff, GripVertical, Monitor, Plus, Redo2, Save, Smartphone, Tablet, Trash2, Undo2, X, ExternalLink } from "lucide-react";
const API = "http://localhost:8081/api/admin/v1";
const SITE = "SIT0000000000001";
type Viewport = "desktop" | "tablet" | "mobile";
type SectionType = "ANNOUNCEMENT" | "HEADER" | "HERO" | "RICH_TEXT" | "PRODUCTS" | "CONTENT" | "INQUIRY" | "FOOTER";
type Section = { id: string; type: SectionType; title: string; subtitle: string; imageUrl: string; buttonText: string; buttonUrl: string; sourceType: string; limit: number; visible: boolean; background: string; textColor: string };
type Schema = { global: { primaryColor: string; backgroundColor: string; textColor: string; fontFamily: string; contentWidth: number }; sections: Section[] };
const labels: Record<SectionType, string> = { ANNOUNCEMENT: "公告栏", HEADER: "导航栏", HERO: "轮播横幅", RICH_TEXT: "富文本", PRODUCTS: "产品展示", CONTENT: "内容展示", INQUIRY: "询盘表单", FOOTER: "页脚" };
const initialSchema: Schema = { global: { primaryColor: "#176b5d", backgroundColor: "#ffffff", textColor: "#17211f", fontFamily: "Inter", contentWidth: 1200 }, sections: [] };
const pageOptions = [{ value: "HOME", label: "首页", path: "/" }, { value: "PRODUCT_CATEGORY", label: "产品分类页", path: "/products" }, { value: "PRODUCT_DETAIL", label: "产品详情页", path: "/products" }, { value: "NEWS_CATEGORY", label: "新闻分类页", path: "/news" }, { value: "NEWS_DETAIL", label: "新闻详情页", path: "/news" }, { value: "CASE_CATEGORY", label: "案例分类页", path: "/cases" }, { value: "CASE_DETAIL", label: "案例详情页", path: "/cases" }, { value: "HELP_CATEGORY", label: "帮助分类页", path: "/help" }, { value: "HELP_DETAIL", label: "帮助详情页", path: "/help" }, { value: "ABOUT_US", label: "关于我们", path: "/about-us" }, { value: "CUSTOM_PAGE", label: "自定义页面", path: "/custom-page" }];
async function post(path: string, body: unknown) { const response = await fetch(API + path, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) }); if (!response.ok) throw new Error((await response.json()).message || "请求失败"); return response.json(); }
function createSection(type: SectionType): Section { return { id: `${type.toLowerCase()}-${Date.now()}`, type, title: type === "HERO" ? "Reliable equipment for demanding operations." : labels[type], subtitle: type === "HERO" ? "Industrial products and project-proven solutions for global B2B customers." : "", imageUrl: "", buttonText: type === "HERO" ? "Explore Products" : "", buttonUrl: type === "HERO" ? "/products" : "", sourceType: type === "CONTENT" ? "CASE" : "", limit: 3, visible: true, background: type === "HEADER" || type === "FOOTER" ? "#101a25" : "#ffffff", textColor: type === "HEADER" || type === "FOOTER" ? "#ffffff" : "#17211f" }; }
export default function DecorationEditor({ onBack }: { onBack: () => void }) {
const [pageType, setPageType] = useState("HOME");
const [schema, setSchema] = useState<Schema>(initialSchema); const [history, setHistory] = useState<Schema[]>([]); const [future, setFuture] = useState<Schema[]>([]);
const [selected, setSelected] = useState<string | null>(null); const [globalMode, setGlobalMode] = useState(false); const [viewport, setViewport] = useState<Viewport>("desktop"); const [notice, setNotice] = useState(""); const [status, setStatus] = useState("DRAFT"); const [version, setVersion] = useState(0);
useEffect(() => { setSelected(null); setGlobalMode(false); setHistory([]); setFuture([]); post("/decorations/detail", { siteCode: SITE, pageType }).then(data => { setSchema(JSON.parse(data.schema)); setStatus(data.status); setVersion(data.publishedVersion); }).catch(error => setNotice(error.message)); }, [pageType]);
const commit = (next: Schema) => { setHistory(items => [...items.slice(-19), schema]); setFuture([]); setSchema(next); };
const updateSection = (id: string, patch: Partial<Section>) => commit({ ...schema, sections: schema.sections.map(item => item.id === id ? { ...item, ...patch } : item) });
const active = schema.sections.find(item => item.id === selected);
const add = (type: SectionType) => { const item = createSection(type); commit({ ...schema, sections: [...schema.sections, item] }); setSelected(item.id); setGlobalMode(false); };
const move = (index: number, offset: number) => { const target = index + offset; if (target < 0 || target >= schema.sections.length) return; const sections = [...schema.sections]; [sections[index], sections[target]] = [sections[target], sections[index]]; commit({ ...schema, sections }); };
const undo = () => { const previous = history.at(-1); if (!previous) return; setFuture(items => [schema, ...items]); setSchema(previous); setHistory(items => items.slice(0, -1)); };
const redo = () => { const next = future[0]; if (!next) return; setHistory(items => [...items, schema]); setSchema(next); setFuture(items => items.slice(1)); };
const save = async () => { await post("/decorations/save", { siteCode: SITE, pageType, schema: JSON.stringify(schema) }); setNotice("装修草稿已保存"); };
const publish = async () => { await save(); await post("/decorations/publish", { siteCode: SITE, pageType }); setStatus("PUBLISHED"); setVersion(value => value + 1); setNotice("已发布到英文前台站"); };
const preview = () => { const target = pageOptions.find(item => item.value === pageType) || pageOptions[0]; window.open(`http://localhost:5174${target.path}?previewPage=${pageType}`, "_blank", "noopener,noreferrer"); };
const previewWidth = useMemo(() => viewport === "desktop" ? "100%" : viewport === "tablet" ? "820px" : "390px", [viewport]);
return <div className="decorator">
<div className="decorator-top"><button className="icon" onClick={onBack} title="返回"><X size={19}/></button><strong>{pageOptions.find(item => item.value === pageType)?.label || "页面装修"}</strong><span className={`status ${status.toLowerCase()}`}>{status === "PUBLISHED" ? `已发布 V${version}` : "草稿"}</span><select className="decorator-page-select" value={pageType} onChange={event => setPageType(event.target.value)}>{pageOptions.map(item => <option key={item.value} value={item.value}>{item.label}</option>)}</select><button className="icon" onClick={undo} disabled={!history.length} title="撤销"><Undo2 size={18}/></button><button className="icon" onClick={redo} disabled={!future.length} title="重做"><Redo2 size={18}/></button><div className="viewport-switch"><button className={viewport === "desktop" ? "active" : ""} onClick={() => setViewport("desktop")} title="桌面"><Monitor size={18}/></button><button className={viewport === "tablet" ? "active" : ""} onClick={() => setViewport("tablet")} title="平板"><Tablet size={18}/></button><button className={viewport === "mobile" ? "active" : ""} onClick={() => setViewport("mobile")} title="手机"><Smartphone size={18}/></button></div><button className="secondary" onClick={preview}><ExternalLink size={16}/>预览</button><button className="secondary" onClick={save}><Save size={16}/>保存草稿</button><button className="primary" onClick={publish}>发布</button></div>
{notice && <div className="decorator-notice">{notice}</div>}
<div className="decorator-body"><aside className="decorator-tree"><div className="decorator-tabs"><button className={!globalMode ? "active" : ""} onClick={() => setGlobalMode(false)}>装修组件</button><button className={globalMode ? "active" : ""} onClick={() => { setGlobalMode(true); setSelected(null); }}>全局设置</button></div>{!globalMode && <><div className="section-tree">{schema.sections.map((item, index) => <button key={item.id} className={selected === item.id ? "selected" : ""} onClick={() => setSelected(item.id)}><GripVertical size={15}/><span>{labels[item.type]}<small>{item.title}</small></span><i onClick={event => { event.stopPropagation(); updateSection(item.id, { visible: !item.visible }); }}>{item.visible ? <Eye size={15}/> : <EyeOff size={15}/>}</i><i onClick={event => { event.stopPropagation(); move(index, -1); }}><ChevronUp size={14}/></i><i onClick={event => { event.stopPropagation(); move(index, 1); }}><ChevronDown size={14}/></i></button>)}</div><div className="component-palette"><h3>添加组件</h3>{(Object.keys(labels) as SectionType[]).map(type => <button key={type} onClick={() => add(type)}><Plus size={15}/>{labels[type]}</button>)}</div></>}</aside>
<div className="decorator-stage"><div className="preview-frame" style={{ width: previewWidth, background: schema.global.backgroundColor, color: schema.global.textColor, fontFamily: schema.global.fontFamily }}>{schema.sections.filter(item => item.visible).length ? schema.sections.filter(item => item.visible).map(item => <PreviewSection key={item.id} item={item} primary={schema.global.primaryColor} selected={selected === item.id} onSelect={() => { setSelected(item.id); setGlobalMode(false); }}/>) : <div className="preview-empty"><Panels/><h2>开始装修首页</h2><p>从左侧添加轮播横幅、产品、案例或询盘表单等组件。</p></div>}</div></div>
<aside className="decorator-settings">{globalMode ? <GlobalSettings schema={schema} onChange={global => commit({ ...schema, global })}/> : active ? <SectionSettings item={active} onChange={patch => updateSection(active.id, patch)} onDuplicate={() => { const copy = { ...active, id: `${active.type.toLowerCase()}-${Date.now()}` }; commit({ ...schema, sections: [...schema.sections, copy] }); setSelected(copy.id); }} onDelete={() => { commit({ ...schema, sections: schema.sections.filter(item => item.id !== active.id) }); setSelected(null); }}/> : <div className="settings-empty"><h3>组件设置</h3><p>在左侧组件树或中间预览中选择一个组件进行编辑。</p></div>}</aside></div>
</div>;
}
function Panels() { return <div className="empty-panels"><span/><span/><span/></div>; }
function PreviewSection({ item, primary, selected, onSelect }: { item: Section; primary: string; selected: boolean; onSelect: () => void }) { const style = { background: item.background, color: item.textColor, outline: selected ? `2px solid ${primary}` : undefined };
if (item.type === "ANNOUNCEMENT") return <section className="pv-announcement" style={style} onClick={onSelect}>{item.title || "Free consultation for your next industrial project"}</section>;
if (item.type === "HEADER") return <section className="pv-header" style={style} onClick={onSelect}><b>SHOPLIX</b><nav>Products Solutions News About Us Contact</nav><button style={{background:primary}}>Get a quote</button></section>;
if (item.type === "HERO") return <section className="pv-hero" style={{...style, backgroundImage: item.imageUrl ? `linear-gradient(90deg,rgba(0,0,0,.65),rgba(0,0,0,.1)),url(${item.imageUrl})` : undefined}} onClick={onSelect}><div><span>ENGINEERED FOR INDUSTRY</span><h1>{item.title}</h1><p>{item.subtitle}</p>{item.buttonText && <button style={{background:primary}}>{item.buttonText}</button>}</div></section>;
if (item.type === "RICH_TEXT") return <section className="pv-rich" style={style} onClick={onSelect}><h2>{item.title}</h2><p>{item.subtitle || "Add your English introduction, advantages or service description here."}</p></section>;
if (item.type === "PRODUCTS" || item.type === "CONTENT") return <section className="pv-collection" style={style} onClick={onSelect}><p>FEATURED</p><h2>{item.title}</h2><div>{Array.from({length: Math.min(item.limit, 4)}, (_, i) => <article key={i}><span>{item.type === "PRODUCTS" ? "PRODUCT" : item.sourceType || "CONTENT"}</span><b>{item.type === "PRODUCTS" ? `Industrial product ${i + 1}` : `Project story ${i + 1}`}</b></article>)}</div></section>;
if (item.type === "INQUIRY") return <section className="pv-inquiry" style={style} onClick={onSelect}><div><h2>{item.title}</h2><p>{item.subtitle}</p></div><form><input placeholder="Your name"/><input placeholder="Business email"/><textarea placeholder="Project requirements"/><button type="button" style={{background:primary}}>Submit Inquiry</button></form></section>;
return <section className="pv-footer" style={style} onClick={onSelect}><b>SHOPLIX</b><div>Products<br/>Solutions<br/>Case Studies</div><div>About Us<br/>Contact Us<br/>Privacy Policy</div><small>{item.subtitle || "Copyright © 2026. All rights reserved."}</small></section>;
}
function Field({ label, children }: { label: string; children: React.ReactNode }) { return <label className="decor-field"><span>{label}</span>{children}</label>; }
function GlobalSettings({ schema, onChange }: { schema: Schema; onChange: (global: Schema["global"]) => void }) { const g = schema.global; return <div><h3>全局设置</h3><p>统一控制整站装修的基础视觉。</p><Field label="品牌主色"><input type="color" value={g.primaryColor} onChange={e => onChange({...g, primaryColor:e.target.value})}/></Field><Field label="页面背景"><input type="color" value={g.backgroundColor} onChange={e => onChange({...g, backgroundColor:e.target.value})}/></Field><Field label="正文颜色"><input type="color" value={g.textColor} onChange={e => onChange({...g, textColor:e.target.value})}/></Field><Field label="英文字体"><select value={g.fontFamily} onChange={e => onChange({...g, fontFamily:e.target.value})}><option>Inter</option><option>Arial</option><option>Georgia</option></select></Field><Field label="内容最大宽度"><input type="number" min="960" max="1600" value={g.contentWidth} onChange={e => onChange({...g, contentWidth:Number(e.target.value)})}/></Field></div>; }
function SectionSettings({ item, onChange, onDuplicate, onDelete }: { item: Section; onChange: (patch: Partial<Section>) => void; onDuplicate: () => void; onDelete: () => void }) { return <div><h3>{labels[item.type]}设置</h3><Field label="英文标题"><input value={item.title} onChange={e => onChange({title:e.target.value})}/></Field><Field label="英文副标题/内容"><textarea rows={4} value={item.subtitle} onChange={e => onChange({subtitle:e.target.value})}/></Field>{item.type === "HERO" && <><Field label="背景图片 URL"><input value={item.imageUrl} onChange={e => onChange({imageUrl:e.target.value})}/></Field><Field label="按钮文案"><input value={item.buttonText} onChange={e => onChange({buttonText:e.target.value})}/></Field><Field label="按钮链接"><input value={item.buttonUrl} onChange={e => onChange({buttonUrl:e.target.value})}/></Field></>}{item.type === "CONTENT" && <Field label="内容来源"><select value={item.sourceType} onChange={e => onChange({sourceType:e.target.value})}><option value="CASE">案例</option><option value="NEWS">新闻</option><option value="HELP">帮助</option></select></Field>}{["PRODUCTS","CONTENT"].includes(item.type) && <Field label="展示数量"><input type="number" min="1" max="12" value={item.limit} onChange={e => onChange({limit:Number(e.target.value)})}/></Field>}<Field label="区块背景"><input type="color" value={item.background} onChange={e => onChange({background:e.target.value})}/></Field><Field label="文字颜色"><input type="color" value={item.textColor} onChange={e => onChange({textColor:e.target.value})}/></Field><div className="section-actions"><button onClick={onDuplicate}><Copy size={15}/>复制组件</button><button className="danger" onClick={onDelete}><Trash2 size={15}/>删除组件</button></div></div>; }
+37
View File
@@ -0,0 +1,37 @@
import React, { useEffect, useState } from "react";
import { ArrowLeft, Edit3, Plus, Save, Trash2 } from "lucide-react";
const API = "http://localhost:8081/api/admin/v1";
const SITE = "SIT0000000000001";
type Field = { fieldCode?: string; fieldKey: string; label: string; fieldType: string; placeholder: string; helpText: string; required: boolean; systemField: boolean; optionsJson: string; widthType: string; sortNo: number };
type Form = { formCode?: string; formName: string; scene: string; submitButtonText: string; successMessage: string; privacyPageCode: string; status: string; sortNo: number; fields: Field[] };
const emptyField = (): Field => ({ fieldKey: "", label: "", fieldType: "TEXT", placeholder: "", helpText: "", required: false, systemField: false, optionsJson: "", widthType: "FULL", sortNo: 0 });
const emptyForm = (): Form => ({ formName: "", scene: "PRODUCT", submitButtonText: "Submit Inquiry", successMessage: "Thank you. We will contact you soon.", privacyPageCode: "", status: "DRAFT", sortNo: 30, fields: [emptyField()] });
const sceneLabels: Record<string, string> = { PRODUCT: "产品详情页按钮", GENERAL: "网站右下角悬浮按钮", CONTACT: "联系页面", CONTENT: "新闻、案例和帮助详情页", PAGE: "固定或自定义页面" };
async function post(path: string, body: unknown) {
const response = await fetch(API + path, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
if (!response.ok) throw new Error((await response.json()).message || "请求失败");
return response.json();
}
/** 询盘基础设置和动态表单管理。 */
export default function InquirySettingsPanel() {
const [tab, setTab] = useState<"settings" | "forms">("settings");
const [settings, setSettings] = useState({ inquiryEnabled: true, captchaEnabled: false, privacyConsentRequired: true, duplicateWindowMinutes: 30, ipHourLimit: 10, emailDayLimit: 20, successAction: "MESSAGE", successPageCode: "", successRedirectUrl: "", notificationEnabled: true, autoReplyEnabled: false, autoReplySubject: "", autoReplyContent: "", dataRetentionDays: 730 });
const [forms, setForms] = useState<Form[]>([]);
const [editing, setEditing] = useState<Form | null>(null);
const [notice, setNotice] = useState("");
const [saving, setSaving] = useState(false);
const loadForms = () => post("/inquiries/forms/list", { siteCode: SITE }).then((data) => setForms(data.items || [])).catch((error) => setNotice(error.message));
useEffect(() => { post("/inquiries/settings/detail", { siteCode: SITE }).then(setSettings).catch((error) => setNotice(error.message)); void loadForms(); }, []);
const saveSettings = async () => { try { setSaving(true); await post("/inquiries/settings/save", { siteCode: SITE, ...settings }); setNotice("询盘基础设置已保存"); } catch (error) { setNotice(error instanceof Error ? error.message : "保存失败"); } finally { setSaving(false); } };
const saveForm = async () => { if (!editing) return; try { setSaving(true); await post("/inquiries/forms/save", { ...editing, siteCode: SITE, fields: editing.fields.map((field, index) => ({ ...field, sortNo: index })) }); setNotice("询盘表单已保存"); setEditing(null); await loadForms(); } catch (error) { setNotice(error instanceof Error ? error.message : "保存失败"); } finally { setSaving(false); } };
const updateField = (index: number, value: Partial<Field>) => editing && setEditing({ ...editing, fields: editing.fields.map((field, position) => position === index ? { ...field, ...value } : field) });
if (editing) return <div className="inquiry-form-editor"><div className="editor-top"><div className="breadcrumb-title"><button className="back" onClick={() => setEditing(null)}><ArrowLeft size={17}/>询盘表单</button><span>/</span><h1>{editing.formCode ? "编辑表单" : "新增表单"}</h1></div><div className="editor-actions"><button onClick={() => setEditing(null)}>取消</button><button className="primary" disabled={saving || !editing.formName || editing.fields.some((field) => !field.fieldKey || !field.label)} onClick={saveForm}><Save size={16}/>{saving ? "保存中" : "保存"}</button></div></div><div className="inquiry-editor-layout"><div className="editor-main"><section className="edit-section"><h2>表单信息</h2><div className="edit-grid"><Field label="表单名称 *"><input value={editing.formName} onChange={(event) => setEditing({ ...editing, formName: event.target.value })}/></Field><Field label="展示到线上网站"><select value={editing.scene} onChange={(event) => setEditing({ ...editing, scene: event.target.value })}>{Object.entries(sceneLabels).map(([value, label]) => <option value={value} key={value}>{label}</option>)}</select></Field><Field wide label="提交成功英文提示"><textarea rows={3} value={editing.successMessage} onChange={(event) => setEditing({ ...editing, successMessage: event.target.value })}/></Field></div></section><section className="edit-section"><div className="section-head"><h2>表单字段</h2><button onClick={() => setEditing({ ...editing, fields: [...editing.fields, { ...emptyField(), sortNo: editing.fields.length }] })}><Plus size={16}/>添加字段</button></div><div className="form-field-list">{editing.fields.map((field, index) => <div className="form-field-row" key={field.fieldCode || index}><input aria-label="字段标签" placeholder="English label" value={field.label} onChange={(event) => updateField(index, { label: event.target.value })}/><input aria-label="字段键" placeholder="field_key" value={field.fieldKey} onChange={(event) => updateField(index, { fieldKey: event.target.value.toLowerCase().replace(/[^a-z0-9_]/g, "_") })}/><select aria-label="字段类型" value={field.fieldType} onChange={(event) => updateField(index, { fieldType: event.target.value })}><option value="TEXT">单行文本</option><option value="TEXTAREA">多行文本</option><option value="EMAIL">邮箱</option><option value="PHONE">电话</option><option value="NUMBER">数字</option><option value="SINGLE_SELECT">下拉单选</option><option value="MULTI_SELECT">下拉多选</option><option value="RADIO">单选框</option><option value="CHECKBOX">复选框</option><option value="FILE">文件</option><option value="COUNTRY">国家</option></select><label><input type="checkbox" checked={field.required} onChange={(event) => updateField(index, { required: event.target.checked })}/>必填</label><select aria-label="字段宽度" value={field.widthType} onChange={(event) => updateField(index, { widthType: event.target.value })}><option value="FULL">整行</option><option value="HALF">半行</option></select><button title="删除字段" onClick={() => setEditing({ ...editing, fields: editing.fields.filter((_, position) => position !== index) })}><Trash2 size={17}/></button></div>)}</div></section><section className="edit-section"><Field label="提交按钮英文文案 *"><input maxLength={100} value={editing.submitButtonText} onChange={(event) => setEditing({ ...editing, submitButtonText: event.target.value })}/></Field></section></div><aside className="editor-side"><section className="edit-section"><h2>发布设置</h2><Field label="状态"><select value={editing.status} onChange={(event) => setEditing({ ...editing, status: event.target.value })}><option value="DRAFT">草稿</option><option value="PUBLISHED">已发布</option><option value="OFFLINE">已下线</option></select></Field><Field label="排序"><input type="number" value={editing.sortNo} onChange={(event) => setEditing({ ...editing, sortNo: Number(event.target.value) })}/></Field></section></aside></div></div>;
return <div className="inquiry-settings"><div className="settings-tabs"><button className={tab === "settings" ? "active" : ""} onClick={() => setTab("settings")}>基础设置</button><button className={tab === "forms" ? "active" : ""} onClick={() => setTab("forms")}>询盘表单</button></div>{notice && <div className="notice">{notice}</div>}{tab === "settings" ? <section className="settings-panel"><h2>提交、风控与邮件</h2><div className="form-grid"><Field label="启用询盘"><input type="checkbox" checked={settings.inquiryEnabled} onChange={(event) => setSettings({ ...settings, inquiryEnabled: event.target.checked })}/></Field><Field label="隐私授权必填"><input type="checkbox" checked={settings.privacyConsentRequired} onChange={(event) => setSettings({ ...settings, privacyConsentRequired: event.target.checked })}/></Field><Field label="IP 每小时上限"><input type="number" value={settings.ipHourLimit} onChange={(event) => setSettings({ ...settings, ipHourLimit: Number(event.target.value) })}/></Field><Field label="邮箱每日上限"><input type="number" value={settings.emailDayLimit} onChange={(event) => setSettings({ ...settings, emailDayLimit: Number(event.target.value) })}/></Field><Field label="重复识别窗口(分钟)"><input type="number" value={settings.duplicateWindowMinutes} onChange={(event) => setSettings({ ...settings, duplicateWindowMinutes: Number(event.target.value) })}/></Field><Field label="数据保留天数"><input type="number" value={settings.dataRetentionDays} onChange={(event) => setSettings({ ...settings, dataRetentionDays: Number(event.target.value) })}/></Field><Field label="启用客户自动回复"><input type="checkbox" checked={settings.autoReplyEnabled} onChange={(event) => setSettings({ ...settings, autoReplyEnabled: event.target.checked })}/></Field><Field wide label="自动回复英文主题"><input value={settings.autoReplySubject || ""} onChange={(event) => setSettings({ ...settings, autoReplySubject: event.target.value })}/></Field><Field wide label="自动回复英文内容"><textarea rows={5} value={settings.autoReplyContent || ""} onChange={(event) => setSettings({ ...settings, autoReplyContent: event.target.value })}/></Field></div><div className="settings-actions"><button className="primary" disabled={saving} onClick={saveSettings}>保存设置</button></div></section> : <><div className="forms-heading"><div><h2>询盘表单</h2><p>配置不同展示位置使用的英文询盘表单。</p></div><button className="primary" onClick={() => setEditing(emptyForm())}><Plus size={17}/>新增表单</button></div><section className="forms-list">{forms.length === 0 ? <div className="empty"><strong>暂无询盘表单</strong><p>创建表单后发布到产品详情、联系页或全站悬浮入口。</p></div> : forms.map((form) => <div className="form-list-row" key={form.formCode}><div><strong>{form.formName}</strong><small>{sceneLabels[form.scene] || form.scene}</small></div><span className={`status ${form.status.toLowerCase()}`}>{form.status === "PUBLISHED" ? "已发布" : form.status === "OFFLINE" ? "已下线" : "草稿"}</span><span>{form.fields.length} 个字段</span><button className="link" onClick={() => setEditing({ ...form, fields: form.fields || [] })}><Edit3 size={15}/>编辑</button></div>)}</section></>}</div>;
}
function Field({ label, wide, children }: { label: string; wide?: boolean; children: React.ReactNode }) { return <label className={wide ? "wide" : ""}><span>{label}</span>{children}</label>; }
+28
View File
@@ -0,0 +1,28 @@
import React, { useEffect, useState } from "react";
import { EditorContent, useEditor } from "@tiptap/react";
import StarterKit from "@tiptap/starter-kit";
import Link from "@tiptap/extension-link";
import Image from "@tiptap/extension-image";
import { ArrowLeft, Bold, Heading2, Heading3, Image as ImageIcon, Italic, Link as LinkIcon, List, Plus, Redo2, Save, Trash2, Undo2 } from "lucide-react";
const API = "http://localhost:8081/api/admin/v1";
const SITE = "SIT0000000000001";
type Heading = { level: number; text: string; sortNo: number };
type Props = { pageCode?: string; onBack: () => void };
async function post(path: string, body: unknown) { const response = await fetch(API + path, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) }); if (!response.ok) throw new Error((await response.json()).message || "请求失败"); return response.json(); }
/** 固定页面和自定义页面内容、SEO 编辑器。 */
export default function PageEditor({ pageCode, onBack }: Props) {
const [form, setForm] = useState({ pageType: "SYSTEM_PAGE", systemPageType: "ABOUT_US", pageName: "", slug: "", summary: "", coverMediaCode: "", coverMediaUrl: "", sortNo: 30, status: "DRAFT" });
const [seo, setSeo] = useState({ title: "", description: "", keywords: "", h1: "", canonicalUrl: "", robots: "index,follow", ogTitle: "", ogDescription: "", ogImageUrl: "", status: "DRAFT" });
const [headings, setHeadings] = useState<Heading[]>([]);
const [saving, setSaving] = useState(false); const [notice, setNotice] = useState("");
const editor = useEditor({ extensions: [StarterKit, Link.configure({ openOnClick: false }), Image], content: "<p></p>" });
useEffect(() => { if (!pageCode) return; post("/pages/detail", { siteCode: SITE, pageCode }).then((data) => { setForm({ ...data, coverMediaUrl: data.coverMediaUrl || "" }); editor?.commands.setContent(data.pageContent || "<p></p>"); post("/seo/detail", { siteCode: SITE, pageType: data.pageType === "SYSTEM_PAGE" ? "SYSTEM_PAGE" : "CUSTOM_PAGE", targetCode: pageCode }).then((seoData) => { setSeo({ title: seoData.title, description: seoData.description, keywords: seoData.keywords || "", h1: seoData.h1, canonicalUrl: seoData.canonicalUrl || "", robots: seoData.robots, ogTitle: seoData.ogTitle || "", ogDescription: seoData.ogDescription || "", ogImageUrl: seoData.ogImageUrl || "", status: seoData.status }); setHeadings(seoData.headings || []); }).catch(() => undefined); }).catch((error) => setNotice(error.message)); }, [pageCode, editor]);
const save = async () => { if (!editor) return; try { setSaving(true); setNotice(""); const result = await post("/pages/save", { pageCode, siteCode: SITE, pageType: form.pageType, systemPageType: form.pageType === "SYSTEM_PAGE" ? form.systemPageType : null, pageName: form.pageName, slug: form.slug, pageContent: editor.getHTML(), summary: form.summary, coverMediaCode: form.coverMediaCode, sortNo: form.sortNo, status: form.status }); await post("/seo/save", { siteCode: SITE, pageType: form.pageType === "SYSTEM_PAGE" ? "SYSTEM_PAGE" : "CUSTOM_PAGE", targetCode: result.pageCode, title: seo.title || form.pageName, description: seo.description || form.summary, keywords: seo.keywords, h1: seo.h1 || form.pageName, canonicalUrl: seo.canonicalUrl || `/${form.slug}`, robots: seo.robots, ogTitle: seo.ogTitle, ogDescription: seo.ogDescription, ogImageUrl: seo.ogImageUrl, structuredData: null, status: form.status, headings }); setNotice("页面与 SEO 已保存"); if (!pageCode) setTimeout(onBack, 500); } catch (error) { setNotice(error instanceof Error ? error.message : "保存失败"); } finally { setSaving(false); } };
const addLink = () => { const href = window.prompt("请输入链接地址"); if (href) editor?.chain().focus().setLink({ href }).run(); };
const addImage = () => { const src = window.prompt("请输入图片地址"); if (src) editor?.chain().focus().setImage({ src }).run(); };
return <div className="product-editor"><div className="editor-top"><div className="breadcrumb-title"><button className="back" onClick={onBack}><ArrowLeft size={17}/>页面管理</button><span>/</span><h1>{pageCode ? "编辑页面" : "新增页面"}</h1>{notice && <em>{notice}</em>}</div><div className="editor-actions"><button onClick={onBack}>取消</button><button className="primary" disabled={saving || !form.pageName || !form.slug} onClick={save}><Save size={16}/>{saving ? "保存中" : "保存"}</button></div></div><div className="editor-layout"><div className="editor-main"><section className="edit-section"><h2>页面信息</h2><div className="edit-grid"><Field label="页面名称 *"><input value={form.pageName} onChange={(event) => setForm({ ...form, pageName: event.target.value })}/></Field><Field label="英文路径 *"><input value={form.slug} onChange={(event) => setForm({ ...form, slug: event.target.value.toLowerCase().replace(/[^a-z0-9-]/g, "-") })}/></Field><Field label="页面类型"><select value={form.pageType} onChange={(event) => setForm({ ...form, pageType: event.target.value })}><option value="SYSTEM_PAGE">固定页面</option><option value="CUSTOM_PAGE">自定义页面</option></select></Field>{form.pageType === "SYSTEM_PAGE" && <Field label="固定页面类型"><select value={form.systemPageType || "ABOUT_US"} onChange={(event) => setForm({ ...form, systemPageType: event.target.value })}><option value="ABOUT_US">关于我们</option><option value="CONTACT_US">联系我们</option><option value="TERMS_OF_SERVICE">服务协议</option><option value="PRIVACY_POLICY">隐私协议</option><option value="COOKIE_POLICY">Cookie 协议</option><option value="INQUIRY_SUCCESS">询盘成功页</option></select></Field>}<Field label="排序"><input type="number" value={form.sortNo} onChange={(event) => setForm({ ...form, sortNo: Number(event.target.value) })}/></Field><Field wide label="页面摘要"><textarea rows={4} value={form.summary || ""} onChange={(event) => setForm({ ...form, summary: event.target.value })}/></Field></div></section><section className="edit-section"><h2>页面正文 *</h2><div className="rich-editor"><div className="rich-toolbar"><Tool title="撤销" onClick={() => editor?.chain().focus().undo().run()}><Undo2/></Tool><Tool title="重做" onClick={() => editor?.chain().focus().redo().run()}><Redo2/></Tool><Tool title="粗体" onClick={() => editor?.chain().focus().toggleBold().run()}><Bold/></Tool><Tool title="斜体" onClick={() => editor?.chain().focus().toggleItalic().run()}><Italic/></Tool><Tool title="二级标题" onClick={() => editor?.chain().focus().toggleHeading({ level: 2 }).run()}><Heading2/></Tool><Tool title="三级标题" onClick={() => editor?.chain().focus().toggleHeading({ level: 3 }).run()}><Heading3/></Tool><Tool title="项目列表" onClick={() => editor?.chain().focus().toggleBulletList().run()}><List/></Tool><Tool title="链接" onClick={addLink}><LinkIcon/></Tool><Tool title="插入图片" onClick={addImage}><ImageIcon/></Tool></div><EditorContent editor={editor}/></div></section></div><aside className="editor-side"><section className="edit-section"><h2>发布</h2><Field label="状态"><select value={form.status} onChange={(event) => setForm({ ...form, status: event.target.value })}><option value="DRAFT">草稿</option><option value="PUBLISHED">已上架</option><option value="OFFLINE">已下架</option></select></Field></section><section className="edit-section"><h2>页面 SEO 设置</h2><Field label="SEO 标题"><input maxLength={70} value={seo.title} onChange={(event) => setSeo({ ...seo, title: event.target.value })}/></Field><Field label="SEO 描述"><textarea rows={4} maxLength={160} value={seo.description} onChange={(event) => setSeo({ ...seo, description: event.target.value })}/></Field><Field label="SEO 关键词"><input value={seo.keywords} onChange={(event) => setSeo({ ...seo, keywords: event.target.value })}/></Field><Field label="H1"><input value={seo.h1} onChange={(event) => setSeo({ ...seo, h1: event.target.value })}/></Field><Field label="Canonical"><input value={seo.canonicalUrl} placeholder={`/${form.slug}`} onChange={(event) => setSeo({ ...seo, canonicalUrl: event.target.value })}/></Field><div className="section-head"><h3>H2 / H3 标签</h3><button onClick={() => setHeadings([...headings, { level: 2, text: "", sortNo: headings.length }])}><Plus size={15}/></button></div>{headings.map((heading, index) => <div className="heading-row" key={index}><select value={heading.level} onChange={(event) => setHeadings(headings.map((item, position) => position === index ? { ...item, level: Number(event.target.value) } : item))}><option value={2}>H2</option><option value={3}>H3</option></select><input value={heading.text} onChange={(event) => setHeadings(headings.map((item, position) => position === index ? { ...item, text: event.target.value } : item))}/><button onClick={() => setHeadings(headings.filter((_, position) => position !== index))}><TrLine truncated
}
function Field({ label, wide, children }: { label: string; wide?: boolean; children: React.ReactNode }) { return <label className={wide ? "wide" : ""}><span>{label}</span>{children}</label>; }
function Tool({ title, onClick, children }: { title: string; onClick: () => void; children: React.ReactElement }) { return <button type="button" title={title} onClick={onClick}>{React.cloneElement(children, { size: 18 } as never)}</button>; }
+35
View File
@@ -0,0 +1,35 @@
import React,{useEffect,useState} from 'react';
import {EditorContent,useEditor} from '@tiptap/react';
import StarterKit from '@tiptap/starter-kit';
import Link from '@tiptap/extension-link';
import Image from '@tiptap/extension-image';
import {ArrowLeft,Bold,Heading2,Heading3,Image as ImageIcon,Italic,Link as LinkIcon,List,Plus,Save,Trash2,Undo2,Redo2} from 'lucide-react';
const API='http://localhost:8081/api/admin/v1';
const SITE='SIT0000000000001';
async function post(path:string,body:unknown){const r=await fetch(API+path,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(body)});if(!r.ok)throw new Error((await r.json()).message||'请求失败');return r.json()}
type Attribute={attributeCode?:string;attributeName:string;value:string;unit:string;sortNo:number};
type Specification={groupName:string;name:string;value:string;unit:string;sortNo:number};
type Heading={level:number;text:string;sortNo:number};
type Props={productCode?:string;onBack:()=>void};
export default function ProductEditor({productCode,onBack}:Props){
const [form,setForm]=useState({productName:'',slug:'',model:'',summary:'',primaryCategoryCode:'',coverMediaCode:'',coverMediaUrl:'',featured:false,inquiryEnabled:true,sortNo:30,status:'DRAFT'});
const [attributes,setAttributes]=useState<Attribute[]>([]);const [specifications,setSpecifications]=useState<Specification[]>([]);const [categories,setCategories]=useState<any[]>([]);
const [seo,setSeo]=useState({title:'',description:'',keywords:'',h1:'',canonicalUrl:'',robots:'index,follow',ogTitle:'',ogDescription:'',ogImageUrl:'',status:'DRAFT'});const [headings,setHeadings]=useState<Heading[]>([]);
const [saving,setSaving]=useState(false);const [notice,setNotice]=useState('');
const editor=useEditor({extensions:[StarterKit,Link.configure({openOnClick:false}),Image],content:'<p></p>'});
useEffect(()=>{post('/products/categories/list',{siteCode:SITE}).then(x=>setCategories(x.items||[]));if(!productCode)return;post('/products/detail',{siteCode:SITE,productCode}).then(d=>{setForm({...d,coverMediaUrl:d.coverMediaUrl||''});setAttributes(d.attributes||[]);setSpecifications(d.specifications||[]);editor?.commands.setContent(d.productContent||'<p></p>')});post('/seo/detail',{siteCode:SITE,pageType:'PRODUCT_DETAIL',targetCode:productCode}).then(d=>{setSeo({title:d.title,description:d.description,keywords:d.keywords||'',h1:d.h1,canonicalUrl:d.canonicalUrl||'',robots:d.robots,ogTitle:d.ogTitle||'',ogDescription:d.ogDescription||'',ogImageUrl:d.ogImageUrl||'',status:d.status});setHeadings(d.headings||[])}).catch(()=>{})},[productCode,editor]);
const upload=async(file?:File)=>{if(!file)return;try{const body=new FormData();body.append('siteCode',SITE);body.append('altText',form.productName);body.append('file',file);const r=await fetch(API+'/media/upload-image',{method:'POST',body});if(!r.ok)throw new Error((await r.json()).message||'上传失败');const d=await r.json();setForm({...form,coverMediaCode:d.mediaCode,coverMediaUrl:d.url})}catch(e){setNotice(e instanceof Error?e.message:'上传失败')}};
const save=async()=>{if(!editor)return;try{setSaving(true);setNotice('');const result=await post('/products/save',{productCode,siteCode:SITE,primaryCategoryCode:form.primaryCategoryCode,productName:form.productName,slug:form.slug,model:form.model,summary:form.summary,productContent:editor.getHTML(),coverMediaCode:form.coverMediaCode,featured:form.featured,inquiryEnabled:form.inquiryEnabled,sortNo:form.sortNo,status:form.status,specifications,attributes});await post('/seo/save',{siteCode:SITE,pageType:'PRODUCT_DETAIL',targetCode:result.productCode,title:seo.title||form.productName,description:seo.description||form.summary,keywords:seo.keywords,h1:seo.h1||form.productName,canonicalUrl:seo.canonicalUrl||`/products/${form.slug}`,robots:seo.robots,ogTitle:seo.ogTitle,ogDescription:seo.ogDescription,ogImageUrl:seo.ogImageUrl,structuredData:null,status:form.status,headings});setNotice('产品与 SEO 已保存');if(!productCode)setTimeout(onBack,500)}catch(e){setNotice(e instanceof Error?e.message:'保存失败')}finally{setSaving(false)}};
const addLink=()=>{const href=window.prompt('请输入链接地址');if(href)editor?.chain().focus().setLink({href}).run()};const addImage=()=>{const src=window.prompt('请输入图片地址');if(src)editor?.chain().focus().setImage({src}).run()};
return <div className="product-editor"><div className="editor-top"><div className="breadcrumb-title"><button className="back" onClick={onBack}><ArrowLeft size={17}/>产品管理</button><span>/</span><h1>{productCode?'编辑产品':'新增产品'}</h1>{notice&&<em>{notice}</em>}</div><div className="editor-actions"><button onClick={onBack}>取消</button><button className="primary" disabled={saving||!form.productName||!form.slug} onClick={save}><Save size={16}/>{saving?'保存中':'保存'}</button></div></div><div className="editor-layout"><div className="editor-main">
<section className="edit-section"><h2>基础信息</h2><div className="edit-grid"><Field label="产品标题 *"><input value={form.productName} onChange={e=>setForm({...form,productName:e.target.value})}/></Field><Field label="英文路径 *"><input value={form.slug} onChange={e=>setForm({...form,slug:e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,'-')})}/></Field><Field label="产品分类"><select value={form.primaryCategoryCode} onChange={e=>setForm({...form,primaryCategoryCode:e.target.value})}><option value="">请选择</option>{categories.map(x=><option key={x.categoryCode} value={x.categoryCode}>{x.categoryName}</option>)}</select></Field><Field label="产品型号"><input value={form.model||''} onChange={e=>setForm({...form,model:e.target.value})}/></Field><Field label="排序"><input type="number" value={form.sortNo} onChange={e=>setForm({...form,sortNo:Number(e.target.value)})}/></Field><Field wide label="产品简介 *"><textarea rows={4} value={form.summary||''} onChange={e=>setForm({...form,summary:e.target.value})}/></Field></div></section>
<section className="edit-section"><h2>产品主图</h2><div className="cover-upload">{form.coverMediaUrl?<img src={`http://localhost:8081${form.coverMediaUrl}`} alt="产品主图预览"/>:<ImageIcon size={42}/>}<label><span>选择图片</span><input type="file" accept="image/jpeg,image/png,image/webp,image/gif" onChange={e=>upload(e.target.files?.[0])}/></label><p>支持 JPG、PNG、WebP、GIF,单图不超过 10MB</p></div></section>
<section className="edit-section"><div className="section-head"><h2>产品属性</h2><button onClick={()=>setAttributes([...attributes,{attributeName:'',value:'',unit:'',sortNo:attributes.length}])}><Plus size={16}/>添加属性</button></div>{attributes.map((a,i)=><div className="repeat-row" key={i}><input placeholder="Attribute name" value={a.attributeName} onChange={e=>setAttributes(attributes.map((x,j)=>j===i?{...x,attributeName:e.target.value}:x))}/><input placeholder="Value" value={a.value} onChange={e=>setAttributes(attributes.map((x,j)=>j===i?{...x,value:e.target.value}:x))}/><input placeholder="Unit" value={a.unit||''} onChange={e=>setAttributes(attributes.map((x,j)=>j===i?{...x,unit:e.target.value}:x))}/><button title="删除属性" onClick={()=>setAttributes(attributes.filter((_,j)=>j!==i))}><Trash2 size={17}/></button></div>)}</section>
<section className="edit-section"><div className="section-head"><h2>弱规格参数</h2><button onClick={()=>setSpecifications([...specifications,{groupName:'',name:'',value:'',unit:'',sortNo:specifications.length}])}><Plus size={16}/>添加规格</button></div>{specifications.map((s,i)=><div className="repeat-row specs-row" key={i}><input placeholder="Group" value={s.groupName||''} onChange={e=>setSpecifications(specifications.map((x,j)=>j===i?{...x,groupName:e.target.value}:x))}/><input placeholder="Name" value={s.name} onChange={e=>setSpecifications(specifications.map((x,j)=>j===i?{...x,name:e.target.value}:x))}/><input placeholder="Value" value={s.value} onChange={e=>setSpecifications(specifications.map((x,j)=>j===i?{...x,value:e.target.value}:x))}/><input placeholder="Unit" value={s.unit||''} onChange={e=>setSpecifications(specifications.map((x,j)=>j===i?{...x,unit:e.target.value}:x))}/><button title="删除规格" onClick={()=>setSpecifications(specifications.filter((_,j)=>j!==i))}><Trash2 size={17}/></button></div>)}</section>
<section className="edit-section"><h2>产品详情 *</h2><div className="rich-editor"><div className="rich-toolbar"><Tool title="撤销" onClick={()=>editor?.chain().focus().undo().run()}><Undo2/></Tool><Tool title="重做" onClick={()=>editor?.chain().focus().redo().run()}><Redo2/></Tool><Tool title="粗体" active={editor?.isActive('bold')} onClick={()=>editor?.chain().focus().toggleBold().run()}><Bold/></Tool><Tool title="斜体" active={editor?.isActive('italic')} onClick={()=>editor?.chain().focus().toggleItalic().run()}><Italic/></Tool><Tool title="二级标题" active={editor?.isActive('heading',{level:2})} onClick={()=>editor?.chain().focus().toggleHeading({level:2}).run()}><Heading2/></Tool><Tool title="三级标题" active={editor?.isActive('heading',{level:3})} onClick={()=>editor?.chain().focus().toggleHeading({level:3}).run()}><Heading3/></Tool><Tool title="项目列表" onClick={()=>editor?.chain().focus().toggleBulletList().run()}><List/></Tool><Tool title="链接" onClick={addLink}><LinkIcon/></Tool><Tool title="插入图片" onClick={addImage}><ImageIcon/></Tool></div><EditorContent editor={editor}/></div></section>
</div><aside className="editor-side"><section className="edit-section"><h2>发布</h2><Field label="状态"><select value={form.status} onChange={e=>setForm({...form,status:e.target.value})}><option value="DRAFT">草稿</option><option value="PUBLISHED">上架</option><option value="OFFLINE">下线</option></select></Field><label className="check"><input type="checkbox" checked={form.inquiryEnabled} onChange={e=>setForm({...form,inquiryEnabled:e.target.checked})}/>启用产品询盘</label><label className="check"><input type="checkbox" checked={form.featured} onChange={e=>setForm({...form,featured:e.target.checked})}/>推荐产品</label></section><section className="edit-section"><h2>搜索引擎优化</h2><Field label="SEO 标题"><input maxLength={70} value={seo.title} onChange={e=>setSeo({...seo,title:e.target.value})}/></Field><Field label="SEO 描述"><textarea maxLength={160} rows={4} value={seo.description} onChange={e=>setSeo({...seo,description:e.target.value})}/></Field><Field label="SEO 关键词"><input value={seo.keywords} onChange={e=>setSeo({...seo,keywords:e.target.value})}/></Field><Field label="H1"><input maxLength={120} value={seo.h1} onChange={e=>setSeo({...seo,h1:e.target.value})}/></Field><Field label="Canonical"><input value={seo.canonicalUrl} placeholder={`/products/${form.slug}`} onChange={e=>setSeo({...seo,canonicalUrl:e.target.value})}/></Field><div className="section-head"><h3>H2 / H3 标签</h3><button onClick={()=>setHeadings([...headings,{level:2,text:'',sortNo:headings.length}])}><Plus size={15}/></button></div>{headings.map((h,i)=><div className="heading-row" key={i}><select value={h.level} onChange={e=>setHeadings(headings.map((x,j)=>j===i?{...x,level:Number(e.target.value)}:x))}><option value={2}>H2</option><option value={3}>H3</option></select><input value={h.text} onChange={e=>setHeadings(headings.map((x,j)=>j===i?{...x,text:e.target.value}:x))}/><button onClick={()=>setHeadings(headings.filter((_,j)=>j!==i))}><Trash2 size={15}/></button></div>)}</section></aside></div></div>
}
function Field({label,wide,children}:{label:string;wide?:boolean;children:React.ReactNode}){return <label className={wide?'wide':''}><span>{label}</span>{children}</label>}
function Tool({title,active,onClick,children}:{title:string;active?:boolean;onClick:()=>void;children:React.ReactElement}){return <button type="button" title={title} className={active?'active':''} onClick={onClick}>{React.cloneElement(children,{size:18} as any)}</button>}
+499
View File
@@ -0,0 +1,499 @@
import React, { useEffect, useState } from "react";
import { createRoot } from "react-dom/client";
import {
Boxes,
Code2,
ChevronDown,
FileText,
FolderTree,
HelpCircle,
Mail,
Newspaper,
PanelsTopLeft,
Paintbrush,
Plus,
Search,
Settings,
Users,
X,
} from "lucide-react";
import "./styles.css";
import ProductEditor from "./ProductEditor";
import ContentEditor from "./ContentEditor";
import CategoryManager from "./CategoryManager";
import InquirySettingsPanel from "./InquirySettingsPanel";
import PageEditor from "./PageEditor";
import DecorationEditor from "./DecorationEditor";
import CustomCodeManager from "./CustomCodeManager";
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 EditorialSection = "NEWS" | "CASE" | "HELP";
type ContentEditorState = { contentType: EditorialSection; contentCode: string };
type Item = {
productCode?: string;
contentCode?: string;
pageCode?: string;
productName?: string;
title?: string;
pageName?: string;
slug: string;
status: string;
model?: string;
publishTime?: string;
inquiryCode?: string;
customerName?: string;
customerEmail?: string;
companyName?: string;
statusLabel?: string;
createTime?: string;
};
async function post(path: string, body: unknown) {
const response = await fetch(API + path, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
if (!response.ok)
throw new Error((await response.json()).message || "请求失败");
return response.json();
}
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: "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": "询盘设置",
};
const statusLabels: Record<string, string> = { DRAFT: "草稿", PUBLISHED: "已上架", OFFLINE: "已下架" };
function App() {
const contentRoutes: Record<EditorialSection, string> = { NEWS: "news", CASE: "cases", HELP: "help" };
const resolveContentRoute = (): ContentEditorState | null => {
const match = window.location.pathname.match(/^\/(news|cases|help)\/(new|([^/]+)\/edit)$/);
if (!match) return null;
const contentType = ({ news: "NEWS", cases: "CASE", help: "HELP" } as const)[match[1] as "news" | "cases" | "help"];
return { contentType, contentCode: match[2] === "new" ? "" : decodeURIComponent(match[3]) };
};
const initialContentEditor = resolveContentRoute();
const [section, setSection] = useState<Section>(initialContentEditor?.contentType || (window.location.pathname.startsWith("/pages/") ? "pages" : "products"));
const [items, setItems] = useState<Item[]>([]);
const [error, setError] = useState("");
const [query, setQuery] = useState("");
const [open, setOpen] = useState(false);
const [saving, setSaving] = useState(false);
const resolveProductRoute = () => {
if (window.location.pathname === "/products/new") return "";
const match = window.location.pathname.match(/^\/products\/([^/]+)\/edit$/);
return match ? decodeURIComponent(match[1]) : null;
};
const resolvePageRoute = () => {
if (window.location.pathname === "/pages/new") return "";
const match = window.location.pathname.match(/^\/pages\/([^/]+)\/edit$/);
return match ? decodeURIComponent(match[1]) : null;
};
const [editingProduct, setEditingProduct] = useState<string | null>(resolveProductRoute);
const [editingContent, setEditingContent] = useState<ContentEditorState | null>(initialContentEditor);
const [editingPage, setEditingPage] = useState<string | null>(resolvePageRoute);
const [productMenuOpen, setProductMenuOpen] = useState(true);
const [contentMenuOpen, setContentMenuOpen] = useState(true);
const navigateSection = (next: Section) => {
setEditingProduct(null);
setEditingContent(null);
setEditingPage(null);
setSection(next);
window.history.pushState({}, "", "/");
};
const [form, setForm] = useState({
name: "",
slug: "",
summary: "",
body: "",
model: "",
status: "DRAFT",
});
const load = async () => {
try {
setError("");
const data =
section.endsWith("-categories")
? { items: [] }
: section === "products"
? await post("/products/list", { siteCode: SITE })
: section === "pages"
? await post("/pages/list", { siteCode: SITE })
: section === "decoration"
? { items: [] }
: section === "inquiries"
? await post("/inquiries/list", { siteCode: SITE })
: section === "inquiry-settings"
? { items: [] }
: await post("/contents/list", {
siteCode: SITE,
contentType: section,
});
setItems(data.items || []);
} catch (e) {
setError(e instanceof Error ? e.message : "加载失败");
setItems([]);
}
};
useEffect(() => {
void load();
}, [section]);
useEffect(() => {
const handlePopState = () => {
setEditingProduct(resolveProductRoute());
setEditingPage(resolvePageRoute());
const content = resolveContentRoute();
setEditingContent(content);
if (content) setSection(content.contentType);
};
window.addEventListener("popstate", handlePopState);
return () => window.removeEventListener("popstate", handlePopState);
}, []);
const openProductEditor = (productCode?: string) => {
const path = productCode
? `/products/${encodeURIComponent(productCode)}/edit`
: "/products/new";
window.history.pushState({}, "", path);
setEditingProduct(productCode || "");
};
const closeProductEditor = () => {
window.history.pushState({}, "", "/");
setEditingProduct(null);
void load();
};
const openContentEditor = (contentType: EditorialSection, contentCode?: string) => {
const route = contentRoutes[contentType];
const path = contentCode ? `/${route}/${encodeURIComponent(contentCode)}/edit` : `/${route}/new`;
window.history.pushState({}, "", path);
setEditingContent({ contentType, contentCode: contentCode || "" });
};
const closeContentEditor = () => {
window.history.pushState({}, "", "/");
setEditingContent(null);
};
const openPageEditor = (pageCode?: string) => {
window.history.pushState({}, "", pageCode ? `/pages/${encodeURIComponent(pageCode)}/edit` : "/pages/new");
setEditingPage(pageCode || "");
};
const closePageEditor = () => {
window.history.pushState({}, "", "/");
setEditingPage(null);
};
const title = sectionLabels[section];
const filtered = items.filter((x) =>
JSON.stringify(x).toLowerCase().includes(query.toLowerCase()),
);
const changeItemStatus = async (item: Item) => {
const status = item.status === "PUBLISHED" ? "OFFLINE" : "PUBLISHED";
try {
setError("");
if (section === "products" && item.productCode)
await post("/products/status", { siteCode: SITE, productCode: item.productCode, status });
else if (["NEWS", "CASE", "HELP"].includes(section) && item.contentCode)
await post("/contents/status", { siteCode: SITE, contentCode: item.contentCode, contentType: section, status });
await load();
} catch (operationError) { setError(operationError instanceof Error ? operationError.message : "状态更新失败"); }
};
const deleteItem = async (item: Item) => {
if (!window.confirm("删除后该内容将不再展示,确认删除吗?")) return;
try {
setError("");
if (section === "products" && item.productCode)
await post("/products/delete", { siteCode: SITE, productCode: item.productCode });
else if (["NEWS", "CASE", "HELP"].includes(section) && item.contentCode)
await post("/contents/delete", { siteCode: SITE, contentCode: item.contentCode, contentType: section });
await load();
} catch (operationError) { setError(operationError instanceof Error ? operationError.message : "删除失败"); }
};
const save = async () => {
try {
setSaving(true);
setError("");
if (section === "products")
await post("/products/save", {
siteCode: SITE,
productName: form.name,
slug: form.slug,
model: form.model,
summary: form.summary,
productContent: form.body,
featured: false,
inquiryEnabled: true,
sortNo: 0,
status: form.status,
specifications: [],
});
else if (section === "pages")
await post("/pages/save", {
siteCode: SITE,
pageName: form.name,
slug: form.slug,
summary: form.summary,
pageContent: form.body,
systemPage: false,
sortNo: 0,
status: form.status,
});
else
await post("/contents/save", {
siteCode: SITE,
contentType: section,
title: form.name,
slug: form.slug,
summary: form.summary,
contentBody: form.body,
featured: false,
sortNo: 0,
status: form.status,
});
setOpen(false);
setForm({
name: "",
slug: "",
summary: "",
body: "",
model: "",
status: "DRAFT",
});
await load();
} catch (e) {
setError(e instanceof Error ? e.message : "保存失败");
} finally {
setSaving(false);
}
};
return (
<div className="shell">
<aside>
<div className="brand">
<span>S</span>
<div>
Shoplix<small>运营中心</small>
</div>
</div>
<nav>
<div className="nav-group">
<button className={["products", "product-categories"].includes(section) ? "group-active" : ""} onClick={() => setProductMenuOpen(!productMenuOpen)}><Boxes size={18}/>产品<ChevronDown className={productMenuOpen ? "expanded" : ""} size={16}/></button>
{productMenuOpen && <div className="nav-children"><button className={section === "products" ? "active" : ""} onClick={() => navigateSection("products")}>产品管理</button><button className={section === "product-categories" ? "active" : ""} onClick={() => navigateSection("product-categories")}>分类管理</button></div>}
</div>
<div className="nav-group">
<button className={["NEWS", "NEWS-categories", "CASE", "CASE-categories", "HELP", "HELP-categories"].includes(section) ? "group-active" : ""} onClick={() => setContentMenuOpen(!contentMenuOpen)}><FolderTree size={18}/>内容<ChevronDown className={contentMenuOpen ? "expanded" : ""} size={16}/></button>
{contentMenuOpen && <div className="nav-children content-children"><button className={["NEWS", "NEWS-categories"].includes(section) ? "active" : ""} onClick={() => navigateSection("NEWS")}><Newspaper size={15}/>新闻</button><button className={["CASE", "CASE-categories"].includes(section) ? "active" : ""} onClick={() => navigateSection("CASE")}><PanelsTopLeft size={15}/>案例</button><button className={["HELP", "HELP-categories"].includes(section) ? "active" : ""} onClick={() => navigateSection("HELP")}><HelpCircle size={15}/>帮助</button></div>}
</div>
{menus.map((m) => (
<button
key={m.key}
className={section === m.key ? "active" : ""}
onClick={() => navigateSection(m.key)}
>
<m.icon size={18} />
{m.label}
</button>
))}
</nav>
<div className="aside-bottom">
<button>
<Users size={18} />
CRM 客户
</button>
<button className={section === "inquiry-settings" ? "active" : ""} onClick={() => navigateSection("inquiry-settings")}>
<Settings size={18} />
询盘设置
</button>
</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.endsWith("-categories") ? <CategoryManager contentType={section === "NEWS-categories" ? "NEWS" : section === "CASE-categories" ? "CASE" : section === "HELP-categories" ? "HELP" : undefined}/> : <>
<header>
<div>
<h1>{title}管理</h1>
<p>Local Development Site · 英文站内容</p>
</div>
{!["inquiries", "inquiry-settings"].includes(section) && <div className="header-actions">
{["NEWS", "CASE", "HELP"].includes(section) && <button className="secondary" onClick={() => setSection(`${section}-categories` as Section)}><FolderTree size={17}/>管理分类</button>}
<button className="primary" onClick={() => section === "products" ? openProductEditor() : ["NEWS", "CASE", "HELP"].includes(section) ? openContentEditor(section as EditorialSection) : section === "pages" ? openPageEditor() : setOpen(true)}><Plus size={17}/>新建{title}</button>
</div>}
</header>
{section === "inquiry-settings" ? <InquirySettingsPanel/> : <><section className="toolbar">
<div className="search">
<Search size={17} />
<input
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder={`搜索${title}名称或路径`}
/>
</div>
</section>
{error && (
<div className="notice">
{error}。请先启动 Admin 后端,并初始化本地站点数据。
</div>
)}
<section className="table">
<div className="thead">
<span>{section === "inquiries" ? "客户" : "名称"}</span>
<span>{section === "inquiries" ? "公司 / 来源" : "英文路径"}</span>
<span>状态</span>
<span>{section === "inquiries" ? "提交时间" : "发布时间"}</span>
<span>操作</span>
</div>
{filtered.length === 0 && !error ? (
<div className="empty">
<strong>暂无{title}数据</strong>
<p>点击右上角新建按钮录入第一条内容。</p>
</div>
) : (
filtered.map((item, index) => (
<div
className="row"
key={
item.productCode || item.contentCode || item.pageCode || item.inquiryCode || index
}
>
<span>
<strong>
{item.productName || item.title || item.pageName || item.customerName}
</strong>
<small>
{item.model ||
item.productCode ||
item.contentCode ||
item.pageCode || item.customerEmail}
</small>
</span>
<code>{section === "inquiries" ? (item.companyName || "Direct inquiry") : `/${item.slug}`}</code>
<span className={`status ${item.status.toLowerCase()}`}>
{item.statusLabel || statusLabels[item.status] || item.status}
</span>
<span>
{(item.publishTime || item.createTime)?.replace("T", " ").slice(0, 16) || "--"}
</span>
<div className="row-actions">{["products", "NEWS", "CASE", "HELP"].includes(section) && item.slug && <a className="link" href={`${SITE_WEB}/${section === "products" ? "products" : section === "CASE" ? "cases" : section === "NEWS" ? "news" : "help"}/${encodeURIComponent(item.slug)}`} target="_blank" rel="noreferrer">查看前台</a>}<button className="link" onClick={() => section === "products" && item.productCode ? openProductEditor(item.productCode) : ["NEWS", "CASE", "HELP"].includes(section) && item.contentCode ? openContentEditor(section as EditorialSection, item.contentCode) : section === "pages" && item.pageCode ? openPageEditor(item.pageCode) : undefined}>{section === "inquiries" ? "查看" : "编辑"}</button>{["products", "NEWS", "CASE", "HELP"].includes(section) && <><button className="link" onClick={() => void changeItemStatus(item)}>{item.status === "PUBLISHED" ? "下架" : "上架"}</button><button className="link danger" onClick={() => void deleteItem(item)}>删除</button></>}</div>
</div>
))
)}
</section></>}
</>}
</>}
</main>
{open && (
<div className="mask">
<section className="dialog">
<div className="dialog-head">
<div>
<h2>新建{title}</h2>
<p>前台内容统一使用英文录入</p>
</div>
<button
className="icon"
onClick={() => setOpen(false)}
aria-label="关闭"
>
<X size={19} />
</button>
</div>
<div className="form-grid">
<label>
<span>
{section === "products"
? "产品名称"
: section === "pages"
? "页面名称"
: "标题"}
</span>
<input
value={form.name}
onChange={(e) => setForm({ ...form, name: e.target.value })}
placeholder="English name"
/>
</label>
<label>
<span>英文路径</span>
<input
value={form.slug}
onChange={(e) =>
setForm({
...form,
slug: e.target.value
.toLowerCase()
.replace(/[^a-z0-9-]/g, "-"),
})
}
placeholder="industrial-pumps"
/>
</label>
{section === "products" && (
<label>
<span>产品型号</span>
<input
value={form.model}
onChange={(e) =>
setForm({ ...form, model: e.target.value })
}
placeholder="Model / Series"
/>
</label>
)}
<label>
<span>发布状态</span>
<select
value={form.status}
onChange={(e) => setForm({ ...form, status: e.target.value })}
>
<option value="DRAFT">草稿</option>
<option value="PUBLISHED">立即发布</option>
<option value="OFFLINE">下线</option>
</select>
</label>
<label className="wide">
<span>英文摘要</span>
<textarea
rows={3}
value={form.summary}
onChange={(e) =>
setForm({ ...form, summary: e.target.value })
}
/>
</label>
<label className="wide">
<span>英文正文</span>
<textarea
rows={9}
value={form.body}
onChange={(e) => setForm({ ...form, body: e.target.value })}
/>
</label>
</div>
<div className="dialog-actions">
<button onClick={() => setOpen(false)}>取消</button>
<button
className="primary"
disabled={saving || !form.name || !form.slug || !form.body}
onClick={save}
>
{saving ? "保存中..." : "保存"}
</button>
</div>
</section>
</div>
)}
</div>
);
}
createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
);
+415
View File
@@ -0,0 +1,415 @@
.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}
:root {
font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;
color: #18212f;
background: #f4f6f8;
font-synthesis: none;
font-weight: 400;
line-height: 1.5;
}
/* 店铺装修器 */
.decorator{height:100vh;display:flex;flex-direction:column;background:#eef1f4;margin:-30px;overflow:hidden}.decorator-top{height:72px;flex:none;background:#fff;border-bottom:1px solid #dfe4e8;display:flex;align-items:center;gap:12px;padding:0 20px}.decorator-top>strong{font-size:18px}.decorator-top .status{font-size:12px}.decorator-page{margin-left:auto;display:flex;align-items:center;gap:5px;padding:9px 14px;border:1px solid #dce2e6;border-radius:5px}.decorator-top .primary,.decorator-top .secondary{height:40px}.viewport-switch{display:flex;background:#f1f3f5;border-radius:5px;padding:3px}.viewport-switch button{width:36px;height:32px;border:0;background:transparent;display:grid;place-items:center;border-radius:4px}.viewport-switch button.active{background:#fff;box-shadow:0 1px 5px #aeb7bd66}.decorator-notice{position:fixed;top:80px;left:50%;z-index:20;transform:translateX(-50%);background:#183f37;color:#fff;padding:9px 18px;border-radius:4px}.decorator-body{min-height:0;display:grid;grid-template-columns:280px minmax(600px,1fr) 300px;flex:1}.decorator-tree,.decorator-settings{background:#fff;overflow:auto;border-right:1px solid #dfe4e8}.decorator-settings{border-right:0;border-left:1px solid #dfe4e8;padding:22px}.decorator-tabs{display:grid;grid-template-columns:1fr 1fr;border-bottom:1px solid #e5e8eb}.decorator-tabs button{height:52px;border:0;background:#fff}.decorator-tabs button.active{color:#176b5d;border-bottom:2px solid #176b5d}.section-tree{padding:12px}.section-tree>button{width:100%;display:flex;align-items:center;gap:7px;border:1px solid transparent;background:#fff;text-align:left;padding:10px 7px;border-radius:4px;margin-bottom:4px}.section-tree>button.selected{background:#edf7f4;border-color:#87bdb3}.section-tree span{flex:1;min-width:0;font-weight:600}.section-tree small{display:block;color:#87918f;font-weight:400;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;margin-top:3px}.section-tree i{display:grid;place-items:center;font-style:normal;color:#63706d}.component-palette{border-top:1px solid #e5e8eb;padding:16px}.component-palette h3{font-size:14px;margin:0 0 10px}.component-palette button{width:calc(50% - 4px);margin:2px;border:1px solid #dce2df;background:#fff;padding:9px 6px;border-radius:4px;display:inline-flex;align-items:center;justify-content:center;gap:5px;font-size:13px}.decorator-stage{overflow:auto;padding:18px;background:#dfe4e8}.preview-frame{min-height:100%;margin:auto;box-shadow:0 2px 14px #65706b30;transition:width .2s;overflow:hidden}.preview-frame section{position:relative;cursor:pointer}.preview-empty{min-height:540px;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;color:#75807d}.empty-panels{display:flex;gap:8px}.empty-panels span{width:36px;height:56px;background:#d6ddda}.pv-announcement{text-align:center;padding:8px 15px;font-size:13px}.pv-header{display:flex;align-items:center;gap:28px;padding:20px 5%;min-height:75px}.pv-header b{font-size:20px}.pv-header nav{flex:1;text-align:center}.pv-header button,.pv-hero button,.pv-inquiry button{color:#fff;border:0;padding:11px 18px;border-radius:3px}.pv-hero{min-height:440px;background:#273a42;background-size:cover;background-position:center;display:flex;align-items:center;padding:7%;color:#fff}.pv-hero>div{max-width:620px}.pv-hero h1{font-size:46px;line-height:1.08;margin:14px 0}.pv-hero p{font-size:18px;line-height:1.6}.pv-rich,.pv-collection,.pv-inquiry{padding:60px 7%}.pv-rich{text-align:center}.pv-rich h2,.pv-collection h2,.pv-inquiry h2{font-size:30px;margin:8px 0 20px}.pv-collection>div{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}.pv-collection article{min-height:160px;padding:20px;background:#eef1ef;display:flex;flex-direction:column;justify-content:space-between}.pv-collection article span{font-size:11px;color:#65706d}.pv-inquiry{display:grid;grid-template-columns:1fr 1fr;gap:40px;background:#eef4f2!important}.pv-inquiry form{display:grid;gap:10px}.pv-inquiry input,.pv-inquiry textarea{padding:12px;border:1px solid #d4dcd9;background:#fff}.pv-footer{padding:45px 5%;display:grid;grid-template-columns:2fr 1fr 1fr;gap:30px}.pv-footer small{grid-column:1/-1;border-top:1px solid #ffffff33;padding-top:20px}.decorator-settings h3{margin:0 0 6px}.decorator-settings>div>p,.settings-empty p{color:#77817f;font-size:13px;line-height:1.5}.decor-field{display:block;margin-top:18px}.decor-field>span{display:block;font-size:13px;font-weight:600;margin-bottom:7px}.decor-field input:not([type=color]),.decor-field textarea,.decor-field select{width:100%;box-sizing:border-box;border:1px solid #d8dfdc;border-radius:4px;padding:10px}.decor-field input[type=color]{width:100%;height:42px;border:1px solid #d8dfdc;background:#fff}.section-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:24px}.section-actions button{border:1px solid #d8dfdc;background:#fff;padding:9px;display:flex;align-items:center;justify-content:center;gap:5px}.section-actions buttoLine truncated
* {
box-sizing: border-box;
}
body {
margin: 0;
font-size: 14px;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
}
button,
input,
textarea,
select {
font-family: inherit;
letter-spacing: 0;
}
.shell {
display: grid;
grid-template-columns: 230px 1fr;
min-height: 100vh;
}
.shell > aside {
background: #17212b;
color: #cbd4dc;
padding: 22px 14px;
display: flex;
flex-direction: column;
}
.brand {
display: flex;
align-items: center;
gap: 11px;
padding: 0 10px 25px;
color: white;
font-weight: 600;
font-size: 18px;
}
.brand > span {
display: grid;
place-items: center;
width: 34px;
height: 34px;
background: #e9b949;
color: #17212b;
border-radius: 6px;
}
.brand small {
display: block;
font-size: 11px;
color: #8594a2;
font-weight: 400;
margin-top: 2px;
}
nav {
display: grid;
gap: 4px;
}
.nav-group > button { width: 100%; }
.nav-group > button svg:last-child { margin-left: auto; transition: transform .2s; }
.nav-group > button svg:last-child.expanded { transform: rotate(180deg); }
.nav-group > button.group-active { color: #fff; }
.nav-children { display: grid; gap: 2px; margin: 1px 0 7px 28px; border-left: 1px solid #344451; padding-left: 8px; }
.nav-children button { padding: 8px 10px; font-size: 13px; border-radius: 4px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.header-actions .secondary { border: 1px solid #d5dce2; background: #fff; color: #34424d; border-radius: 6px; padding: 10px 15px; display: flex; align-items: center; gap: 7px; font-weight: 600; cursor: pointer; }
.shell > aside button {
border: 0;
background: transparent;
color: inherit;
text-align: left;
padding: 11px 12px;
border-radius: 6px;
display: flex;
align-items: center;
gap: 10px;
font: inherit;
cursor: pointer;
}
.shell > aside button:hover,
.shell > aside button.active {
background: #263442;
color: white;
}
.aside-bottom {
margin-top: auto;
border-top: 1px solid #2d3944;
padding-top: 12px;
}
main {
padding: 28px 34px;
min-width: 0;
}
header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 24px;
}
h1 {
font-size: 24px;
margin: 0 0 6px;
letter-spacing: 0;
font-weight: 500;
}
header p {
margin: 0;
color: #72808d;
font-size: 13px;
}
.primary {
background: #176b5b;
color: white;
border: 0;
border-radius: 6px;
padding: 10px 16px;
display: flex;
align-items: center;
gap: 7px;
font-weight: 500;
}
.toolbar {
display: flex;
justify-content: space-between;
margin-bottom: 14px;
}
.search {
width: min(440px, 60vw);
height: 40px;
display: flex;
align-items: center;
gap: 9px;
background: white;
border: 1px solid #d9e0e5;
border-radius: 6px;
padding: 0 12px;
}
.search input {
border: 0;
outline: 0;
width: 100%;
font: inherit;
}
.toolbar > button {
border: 1px solid #d5dce2;
background: white;
border-radius: 6px;
padding: 0 16px;
}
.notice {
background: #fff6dc;
border: 1px solid #ead38e;
padding: 13px 16px;
border-radius: 6px;
margin-bottom: 14px;
color: #6d5619;
}
.table {
background: white;
border: 1px solid #dfe5e9;
border-radius: 6px;
overflow: hidden;
}
.thead,
.row {
display: grid;
grid-template-columns: 2fr 1.4fr 0.8fr 1fr 1.15fr;
align-items: center;
gap: 16px;
padding: 14px 18px;
}
.thead {
background: #f8fafb;
color: #6d7983;
font-size: 12px;
font-weight: 600;
border-bottom: 1px solid #e4e9ed;
}
.row {
min-height: 69px;
border-bottom: 1px solid #edf0f2;
font-size: 13px;
}
.row:last-child {
border: 0;
}
.row > span:first-child {
display: grid;
gap: 4px;
}
.row small {
color: #8b969f;
}
.row code {
font-family: inherit;
color: #4f6170;
}
.row-actions{display:flex;align-items:center;gap:12px;flex-wrap:wrap}.row-actions .link{border:0;background:transparent;color:#176b5b;padding:4px 0;cursor:pointer;font-weight:600}.row-actions .danger{color:#b33d3d}
.status {
width: max-content;
border-radius: 12px;
padding: 4px 9px;
font-size: 11px;
background: #eef1f3;
}
.status.published {
background: #e4f4ed;
color: #176b5b;
}
.status.draft {
background: #fff1d1;
color: #8a5b00;
}
/* 运营后台采用轻量中文管理系统字阶,装修画布内的站点预览保持独立视觉。 */
.shell > aside button,
.nav-children button,
.aside-bottom button {
font-weight: 400;
}
.shell > main h2,
.shell > main h3,
.dialog h2,
.edit-section h2,
.forms-heading h2,
.category-heading h1 {
font-weight: 500;
}
.thead,
.category-table-head,
.edit-grid label > span,
.editor-side label > span,
.inquiry-form-editor .edit-section > label > span,
.decor-field > span {
font-weight: 400;
}
.row strong,
.form-list-row strong,
.category-name strong,
.section-tree span {
font-weight: 500;
}
.row-actions .link,
.link,
.header-actions .secondary,
.settings-tabs button.active {
font-weight: 500;
}
.link {
border: 0;
background: transparent;
color: #176b5b;
font-weight: 600;
}
.empty {
text-align: center;
padding: 70px 20px;
color: #8a969f;
}
.empty strong {
display: block;
color: #34414d;
margin-bottom: 8px;
}
.empty p {
font-size: 13px;
}
.mask {
position: fixed;
inset: 0;
background: rgba(15, 23, 42, 0.42);
display: grid;
place-items: center;
padding: 24px;
z-index: 20;
}
.dialog {
width: min(760px, 100%);
max-height: 92vh;
overflow: auto;
background: #fff;
border-radius: 8px;
box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}
.dialog-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 22px 24px;
border-bottom: 1px solid #e6e9ed;
}
.dialog-head h2 {
margin: 0 0 5px;
font-size: 20px;
}
.dialog-head p {
margin: 0;
color: #7b8490;
font-size: 13px;
}
.icon {
width: 36px;
height: 36px;
padding: 0;
display: grid;
place-items: center;
}
.form-grid {
padding: 22px 24px;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 18px;
}
.form-grid label {
display: grid;
gap: 7px;
}
.form-grid label span {
font-size: 13px;
font-weight: 600;
}
.form-grid input,
.form-grid select,
.form-grid textarea {
border: 1px solid #d9dee5;
border-radius: 5px;
padding: 10px 12px;
font: inherit;
resize: vertical;
}
.form-grid .wide {
grid-column: 1/-1;
}
.dialog-actions {
display: flex;
justify-content: flex-end;
gap: 10px;
padding: 16px 24px;
border-top: 1px solid #e6e9ed;
}
.dialog-actions button {
min-width: 88px;
padding: 10px 16px;
border: 1px solid #d9dee5;
border-radius: 5px;
background: #fff;
}
.dialog-actions .primary {
background: #176b5b;
color: #fff;
}
.primary:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.settings-panel { background: #fff; border: 1px solid #dfe5e9; border-radius: 6px; overflow: hidden; }
.settings-panel h2 { margin: 0; padding: 20px 24px; font-size: 17px; border-bottom: 1px solid #e6e9ed; }
.settings-panel .form-grid { max-width: 900px; }
.settings-panel input[type="checkbox"] { width: 20px; height: 20px; }
.settings-actions { display: flex; align-items: center; gap: 18px; padding: 18px 24px; border-top: 1px solid #e6e9ed; color: #176b5b; font-size: 13px; }
.product-editor{padding:0 0 60px}.editor-top{display:flex;justify-content:space-between;align-items:center;max-width:1500px;margin:0 auto 22px}.editor-actions{display:flex;gap:10px}.breadcrumb-title{display:flex;align-items:center;gap:9px;min-width:0}.breadcrumb-title h1{font-size:18px;margin:0}.breadcrumb-title>span{color:#9aa4ac}.breadcrumb-title em{font-style:normal;color:#176b5b;font-size:12px;margin-left:8px}.editor-top button,.section-head button,.repeat-row button,.heading-row button,.rich-toolbar button{border:1px solid #d8dee3;background:#fff;border-radius:5px;padding:9px 13px;display:inline-flex;align-items:center;gap:7px;cursor:pointer}.editor-top .back{border:0;background:transparent;padding-left:0;color:#596873}.editor-top .primary{background:#176b5b;color:#fff}.editor-layout{max-width:1500px;margin:auto;display:grid;grid-template-columns:minmax(0,1fr) 360px;gap:22px;align-items:start}.editor-main,.editor-side{display:grid;gap:20px}.editor-side{position:sticky;top:20px}.edit-section{background:#fff;border:1px solid #dde3e7;border-radius:6px;padding:22px}.edit-section h2{font-size:17px;margin:0 0 20px}.edit-section h3{font-size:14px;margin:0}.edit-grid{display:grid;grid-template-columns:1fr 1fr;gap:18px}.edit-grid label,.editor-side label{display:grid;gap:7px}.edit-grid label>span,.editor-side label>span{font-size:13px;font-weight:600}.edit-grid input,.edit-grid select,.edit-grid textarea,.editor-side input,.editor-side select,.editor-side textarea,.repeat-row input,.heading-row input,.heading-row select{border:1px solid #d8dee3;border-radius:5px;padding:10px 12px;font:inherit;width:100%}.edit-grid .wide{grid-column:1/-1}.section-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px}.section-head h2{margin:0}.section-head button{padding:7px 10px;color:#176b5b}.repeat-row{display:grid;grid-template-columns:1.2fr 1.6fr .7fr 42px;gap:10px;margin-top:10px}.repeat-row.specs-row{grid-template-columns:1fr 1fr 1.3fr .6fr 42px}.repeat-row button,.heading-row button{padding:8px;color:#9b3434;justify-content:center}.cover-upload{min-height:210px;border:1px dashed #bdc8c4;display:grid;place-items:center;align-content:center;gap:12px;color:#81908b;position:relative;overflow:hidden}.cover-upload img{max-width:100%;max-height:280px;object-fit:contain}.cover-upload label span{display:inline-block;background:#176b5b;color:#fff;padding:9px 14px;border-radius:5px;cursor:pointer}.cover-upload input{display:none}.cover-upload p{font-size:12px;margin:0}.rich-editor{border:1px solid #d8dee3;border-radius:5px;overflow:hidden}.rich-toolbar{display:flex;flex-wrap:wrap;gap:4px;padding:8px;background:#f7f9fa;border-bottom:1px solid #d8dee3}.rich-toolbar button{border:0;padding:7px}.rich-toolbar button.active{background:#dcece7;color:#176b5b}.rich-editor .ProseMirror{min-height:360px;padding:20px;outline:0}.rich-editor .ProseMirror h2{font-size:28px}.rich-editor .ProseMirror h3{font-size:21px}.rich-editor .ProseMirror img{max-width:100%}.editor-side .edit-section{display:grid;gap:15px}.editor-side .edit-section>h2{margin-bottom:2px}.check{display:flex!important;grid-template-columns:auto 1fr!important;align-items:center;font-size:13px}.check input{width:17px}.heading-row{display:grid;grid-template-columns:65px 1fr 38px;gap:7px}.heading-row button{padding:6px}
.category-manager{max-width:1500px;margin:auto}.category-heading{display:flex;align-items:center;justify-content:space-between;margin-bottom:22px}.category-heading h1{margin:0 0 5px}.category-heading p{margin:0;color:#72808d;font-size:13px}.category-table{background:#fff;border:1px solid #dfe5e9;border-radius:6px;overflow:hidden}.category-table-head,.category-row{display:grid;grid-template-columns:minmax(300px,2fr) 1.2fr .7fr .6fr;align-items:center;gap:18px;padding:13px 20px}.category-table-head{background:#f8fafb;color:#6d7983;font-size:12px;font-weight:600;border-bottom:1px solid #e4e9ed}.category-row{min-height:64px;border-bottom:1px solid #edf0f2}.category-row:last-child{border-bottom:0}.category-name{display:grid;grid-template-columns:24px 1fr;align-items:center;min-width:0}.category-name small{grid-column:2;color:#8b969f;font-size:10px;margin-top:3px}.tree-toggle{width:24px!important;height:24px;padding:0!important;display:grid!important;place-items:center}.tree-space{width:24px}.category-actions{display:flex;gap:5px}.category-actions button{width:34px;height:34px;display:grid;place-items:center;border:1px solid #d8dee3;background:#fff;border-radius:5px;color:#176b5b;cursor:pointer}.category-dialog{width:min(720px,calc(100vw - 32px));background:#fff;border-radius:7px;box-shadow:0 24px 70px rgba(0,0,0,.24);overflow:hidden}.dialog-foot{display:flex;justify-content:flex-end;gap:10px;padding:16px 24px;border-top:1px solid #e6e9ed}.dialog-foot button{border:1px solid #d9dee5;background:#fff;border-radius:5px;padding:10px 18px}.dialog-foot .primary{background:#176b5b;color:#fff}
.settings-tabs{display:flex;gap:20px;border-bottom:1px solid #dfe5e9;margin-bottom:18px}.settings-tabs button{border:0;background:transparent;padding:10px 2px;color:#6d7983;font:inherit;cursor:pointer}.settings-tabs button.active{color:#176b5b;border-bottom:2px solid #176b5b;font-weight:700}.forms-heading{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px}.forms-heading h2{margin:0 0 4px}.forms-heading p{margin:0;color:#72808d;font-size:13px}.forms-list{background:#fff;border:1px solid #dfe5e9;border-radius:6px;overflow:hidden}.form-list-row{display:grid;grid-template-columns:2fr .7fr .7fr .5fr;align-items:center;gap:16px;padding:16px 20px;border-bottom:1px solid #edf0f2}.form-list-row:last-child{border-bottom:0}.form-list-row>div{display:grid;gap:4px}.form-list-row small{color:#7b8791}.form-list-row .link{border:0;background:transparent;color:#176b5b;display:flex;align-items:center;gap:5px;cursor:pointer}.inquiry-form-editor{padding-bottom:50px}.inquiry-editor-layout{display:grid;grid-template-columns:minmax(0,1fr) 330px;gap:22px;align-items:start}.form-field-list{display:grid;gap:10px}.form-field-row{display:grid;grid-template-columns:1.2fr 1fr 1fr auto .65fr 38px;gap:8px;align-items:center}.form-field-row input,.form-field-row select{border:1px solid #d8dee3;border-radius:5px;padding:9px 10px;font:inherit;min-width:0}.form-field-row label{display:flex;align-items:center;gap:5px;font-size:12px}.form-field-row button{height:38px;border:1px solid #e2caca;background:#fff;color:#a43d3d;border-radius:5px;display:grid;place-items:center;cursor:pointer}.inquiry-form-editor .edit-section>label{display:grid;gap:7px}.inquiry-form-editor .edit-section>label>span{font-size:13px;font-weight:600}.inquiry-form-editor .edit-section>label>input{border:1px solid #d8dee3;border-radius:5px;padding:10px 12px;font:inherit}
@media (max-width: 760px) {
.shell {
grid-template-columns: 68px 1fr;
}
.brand div,
.shell > aside button:not(.active) {
font-size: 0;
}
.brand {
padding-left: 3px;
}
.shell > aside button {
justify-content: center;
}
.aside-bottom {
display: none;
}
main {
padding: 20px 14px;
}
.thead,
.row {
grid-template-columns: 1.7fr 1fr 0.8fr;
}
.thead span:nth-child(4),
.thead span:nth-child(5),
.row > span:nth-child(4),
.row-actions {
display: none;
}
.form-grid {
grid-template-columns: 1fr;
}
.form-grid .wide {
grid-column: auto;
}
.product-editor{padding:0 0 30px}.editor-layout{grid-template-columns:1fr}.editor-side{position:static}.edit-grid{grid-template-columns:1fr}.edit-grid .wide{grid-column:auto}.repeat-row,.repeat-row.specs-row{grid-template-columns:1fr}.editor-top{align-items:flex-start}.editor-actions{flex-direction:column}.breadcrumb-title{align-items:flex-start;flex-wrap:wrap}
.nav-children{margin-left:0;padding-left:0;border-left:0}.nav-children button{font-size:0}.category-heading{align-items:flex-start;gap:14px}.category-table{overflow-x:auto}.category-table-head,.category-row{min-width:700px}.category-heading p{display:none}
.inquiry-editor-layout{grid-template-columns:1fr}.form-field-row{grid-template-columns:1fr}.form-list-row{grid-template-columns:1fr}.forms-heading{align-items:flex-start;gap:12px}
}
+1
View File
@@ -0,0 +1 @@
/// <reference types="vite/client" />