账户登录
This commit is contained in:
1 parent
d8e17fce1d
commit
7dea19f2db
12 files changed
+331
-14
No files matched your search
@@ -0,0 +1,19 @@
|
|||||||
|
package com.shoplix.site.controller;
|
||||||
|
|
||||||
|
import com.shoplix.site.facade.SiteNavigationFacade;
|
||||||
|
import com.shoplix.site.modules.navigation.req.NavigationDetailSiteReq;
|
||||||
|
import com.shoplix.site.modules.navigation.res.NavigationDetailSiteRes;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/** 前台站导航接口。 */
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/site/v1/navigations")
|
||||||
|
public class SiteNavigationController {
|
||||||
|
/** 导航 Facade。 */ private final SiteNavigationFacade facade;
|
||||||
|
/** 注入导航 Facade。 */ public SiteNavigationController(SiteNavigationFacade facade) { this.facade = facade; }
|
||||||
|
/** 查询指定位置的已发布导航。 */ @PostMapping("/detail") public NavigationDetailSiteRes detail(@Valid @RequestBody NavigationDetailSiteReq request) { return facade.detail(request); }
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.shoplix.site.facade;
|
||||||
|
|
||||||
|
import com.shoplix.site.modules.navigation.req.NavigationDetailSiteReq;
|
||||||
|
import com.shoplix.site.modules.navigation.res.NavigationDetailSiteRes;
|
||||||
|
import com.shoplix.site.service.SiteNavigationService;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/** 前台导航统一出口。 */
|
||||||
|
@Component
|
||||||
|
public class SiteNavigationFacade {
|
||||||
|
/** 导航业务服务。 */ private final SiteNavigationService service;
|
||||||
|
/** 注入导航业务。 */ public SiteNavigationFacade(SiteNavigationService service) { this.service = service; }
|
||||||
|
/** 查询指定位置的已发布导航。 */ public NavigationDetailSiteRes detail(NavigationDetailSiteReq request) { return service.detail(request.position().name()); }
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package com.shoplix.site.modules.navigation.req;
|
||||||
|
|
||||||
|
import com.shoplix.modules.navigation.enums.NavigationPositionEnum;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/** 前台查询已发布导航请求。 */
|
||||||
|
public record NavigationDetailSiteReq(
|
||||||
|
/** 导航展示位置。 */ @NotNull NavigationPositionEnum position) {
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
package com.shoplix.site.modules.navigation.res;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/** 前台已发布导航响应。 */
|
||||||
|
public record NavigationDetailSiteRes(
|
||||||
|
/** 导航业务编号,无配置时为空。 */ String navigationCode,
|
||||||
|
/** 导航名称。 */ String navigationName,
|
||||||
|
/** 导航展示位置。 */ String position,
|
||||||
|
/** 顶级菜单项。 */ List<NavigationItemSiteRes> items) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.shoplix.site.modules.navigation.res;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/** 前台导航菜单项响应。 */
|
||||||
|
public record NavigationItemSiteRes(
|
||||||
|
/** 菜单标题。 */ String title,
|
||||||
|
/** 菜单访问地址。 */ String url,
|
||||||
|
/** 页面打开方式。 */ String openType,
|
||||||
|
/** 子菜单列表。 */ List<NavigationItemSiteRes> children) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.shoplix.site.service;
|
||||||
|
|
||||||
|
import com.shoplix.common.context.SiteContextHolder;
|
||||||
|
import com.shoplix.modules.navigation.repository.entity.NavigationItemEntity;
|
||||||
|
import com.shoplix.modules.navigation.repository.service.NavigationItemRepositoryService;
|
||||||
|
import com.shoplix.modules.navigation.repository.service.NavigationRepositoryService;
|
||||||
|
import com.shoplix.site.modules.navigation.res.NavigationDetailSiteRes;
|
||||||
|
import com.shoplix.site.modules.navigation.res.NavigationItemSiteRes;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/** 前台已发布导航查询业务。 */
|
||||||
|
@Service
|
||||||
|
public class SiteNavigationService {
|
||||||
|
/** 导航仓储。 */ private final NavigationRepositoryService navigationRepository;
|
||||||
|
/** 菜单项仓储。 */ private final NavigationItemRepositoryService itemRepository;
|
||||||
|
|
||||||
|
/** 注入导航查询依赖。 */
|
||||||
|
public SiteNavigationService(NavigationRepositoryService navigationRepository,
|
||||||
|
NavigationItemRepositoryService itemRepository) {
|
||||||
|
this.navigationRepository = navigationRepository;
|
||||||
|
this.itemRepository = itemRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询当前站点指定位置的已发布导航。 */
|
||||||
|
public NavigationDetailSiteRes detail(String position) {
|
||||||
|
return navigationRepository.findPublished(SiteContextHolder.getRequired().siteCode(), position)
|
||||||
|
.map(navigation -> {
|
||||||
|
List<NavigationItemEntity> entities = itemRepository.list(navigation.getNavigationCode(), true);
|
||||||
|
List<NavigationItemSiteRes> items = buildChildren(entities, "");
|
||||||
|
return new NavigationDetailSiteRes(navigation.getNavigationCode(), navigation.getNavigationName(),
|
||||||
|
navigation.getPosition(), items);
|
||||||
|
})
|
||||||
|
.orElseGet(() -> new NavigationDetailSiteRes("", "", position, List.of()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 按父菜单编号递归组装菜单树。 */
|
||||||
|
private List<NavigationItemSiteRes> buildChildren(List<NavigationItemEntity> entities, String parentCode) {
|
||||||
|
return entities.stream()
|
||||||
|
.filter(item -> normalize(item.getParentItemCode()).equals(normalize(parentCode)))
|
||||||
|
.map(item -> new NavigationItemSiteRes(item.getTitle(), item.getCustomUrl(), item.getOpenType(),
|
||||||
|
buildChildren(entities, item.getItemCode())))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 将空父编号统一为空字符串。 */
|
||||||
|
private String normalize(String value) {
|
||||||
|
return value == null ? "" : value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
import { ArrowLeft, ChevronRight, Menu, Pencil, Plus, Save, Trash2 } from "lucide-react";
|
||||||
|
import { useEffect, useMemo, useState } from "react";
|
||||||
|
import { apiPost } from "./api";
|
||||||
|
|
||||||
|
const SITE_CODE = "SIT0000000000001";
|
||||||
|
|
||||||
|
type NavigationSummary = {
|
||||||
|
navigationCode: string;
|
||||||
|
navigationName: string;
|
||||||
|
position: "HEADER" | "FOOTER";
|
||||||
|
status: "DRAFT" | "PUBLISHED" | "OFFLINE";
|
||||||
|
items: NavigationItemResponse[];
|
||||||
|
};
|
||||||
|
|
||||||
|
type NavigationItemResponse = {
|
||||||
|
itemCode: string;
|
||||||
|
parentItemCode?: string;
|
||||||
|
itemType: string;
|
||||||
|
title: string;
|
||||||
|
targetCode?: string;
|
||||||
|
url: string;
|
||||||
|
openType: "CURRENT" | "NEW";
|
||||||
|
visible: boolean;
|
||||||
|
sortNo: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
type NavigationItemForm = {
|
||||||
|
clientKey: string;
|
||||||
|
parentClientKey: string;
|
||||||
|
itemType: string;
|
||||||
|
title: string;
|
||||||
|
targetCode: string;
|
||||||
|
url: string;
|
||||||
|
openType: "CURRENT" | "NEW";
|
||||||
|
visible: boolean;
|
||||||
|
sortNo: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
type TargetOption = {
|
||||||
|
group: string;
|
||||||
|
type: string;
|
||||||
|
code: string;
|
||||||
|
label: string;
|
||||||
|
url: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 生成仅用于当前编辑会话的菜单项临时键。 */
|
||||||
|
function createClientKey(): string {
|
||||||
|
return `menu-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新建一个空白菜单项。 */
|
||||||
|
function createItem(parentClientKey = "", sortNo = 0): NavigationItemForm {
|
||||||
|
return { clientKey: createClientKey(), parentClientKey, itemType: "HOME", title: "", targetCode: "", url: "/", openType: "CURRENT", visible: true, sortNo };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 菜单导航列表与独立编辑页。 */
|
||||||
|
export default function NavigationManager() {
|
||||||
|
const [list, setList] = useState<NavigationSummary[]>([]);
|
||||||
|
const [editing, setEditing] = useState(false);
|
||||||
|
const [navigationCode, setNavigationCode] = useState("");
|
||||||
|
const [navigationName, setNavigationName] = useState("");
|
||||||
|
const [position, setPosition] = useState<"HEADER" | "FOOTER">("HEADER");
|
||||||
|
const [status, setStatus] = useState<"DRAFT" | "PUBLISHED" | "OFFLINE">("DRAFT");
|
||||||
|
const [items, setItems] = useState<NavigationItemForm[]>([]);
|
||||||
|
const [targets, setTargets] = useState<TargetOption[]>([]);
|
||||||
|
const [message, setMessage] = useState("");
|
||||||
|
const [saving, setSaving] = useState(false);
|
||||||
|
|
||||||
|
/** 读取导航列表。 */
|
||||||
|
const loadList = async () => {
|
||||||
|
try {
|
||||||
|
const result = await apiPost<{ items: NavigationSummary[] }>("/navigations/list", { siteCode: SITE_CODE });
|
||||||
|
setList(result.items || []);
|
||||||
|
setMessage("");
|
||||||
|
} catch (error) {
|
||||||
|
setMessage(error instanceof Error ? error.message : "导航加载失败");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => { void loadList(); }, []);
|
||||||
|
|
||||||
|
/** 汇总导航可以跳转的固定页面和业务内容。 */
|
||||||
|
const loadTargets = async () => {
|
||||||
|
const options: TargetOption[] = [
|
||||||
|
{ group: "固定页面", type: "HOME", code: "", label: "首页", url: "/" },
|
||||||
|
{ group: "固定页面", type: "PRODUCT_LIST", code: "", label: "产品列表页", url: "/products" },
|
||||||
|
{ group: "固定页面", type: "NEWS_LIST", code: "", label: "新闻列表页", url: "/news" },
|
||||||
|
{ group: "固定页面", type: "CASE_LIST", code: "", label: "案例列表页", url: "/cases" },
|
||||||
|
{ group: "固定页面", type: "HELP_LIST", code: "", label: "帮助列表页", url: "/help" },
|
||||||
|
];
|
||||||
|
const settled = await Promise.allSettled([
|
||||||
|
apiPost<any>("/pages/list", { siteCode: SITE_CODE }),
|
||||||
|
apiPost<any>("/products/categories/list", { siteCode: SITE_CODE }),
|
||||||
|
apiPost<any>("/products/list", { siteCode: SITE_CODE }),
|
||||||
|
...(["NEWS", "CASE", "HELP"] as const).flatMap((contentType) => [
|
||||||
|
apiPost<any>("/contents/categories/list", { siteCode: SITE_CODE, contentType }),
|
||||||
|
apiPost<any>("/contents/list", { siteCode: SITE_CODE, contentType }),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
const value = (index: number) => settled[index].status === "fulfilled" ? (settled[index] as PromiseFulfilledResult<any>).value.items || [] : [];
|
||||||
|
value(0).forEach((page: any) => options.push({ group: page.pageType === "CUSTOM_PAGE" ? "自定义页面" : "系统页面", type: page.pageType === "CUSTOM_PAGE" ? "CUSTOM_PAGE" : "SYSTEM_PAGE", code: page.pageCode, label: page.pageName, url: `/${page.slug}` }));
|
||||||
|
value(1).forEach((category: any) => options.push({ group: "产品分类", type: "PRODUCT_CATEGORY", code: category.categoryCode, label: category.categoryName, url: `/products/category/${category.slug}` }));
|
||||||
|
value(2).forEach((product: any) => options.push({ group: "产品", type: "PRODUCT", code: product.productCode, label: product.productName, url: `/products/${product.slug}` }));
|
||||||
|
const contentMeta = [{ name: "新闻", prefix: "news", categoryType: "NEWS_CATEGORY", itemType: "NEWS" }, { name: "案例", prefix: "cases", categoryType: "CASE_CATEGORY", itemType: "CASE" }, { name: "帮助", prefix: "help", categoryType: "HELP_CATEGORY", itemType: "HELP" }];
|
||||||
|
contentMeta.forEach((meta, offset) => {
|
||||||
|
value(3 + offset * 2).forEach((category: any) => options.push({ group: `${meta.name}分类`, type: meta.categoryType, code: category.categoryCode, label: category.categoryName, url: `/${meta.prefix}/category/${category.slug}` }));
|
||||||
|
value(4 + offset * 2).forEach((content: any) => options.push({ group: meta.name, type: meta.itemType, code: content.contentCode, label: content.title, url: `/${meta.prefix}/${content.slug}` }));
|
||||||
|
});
|
||||||
|
setTargets(options);
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 打开新增导航页面。 */
|
||||||
|
const createNavigation = () => {
|
||||||
|
setNavigationCode(""); setNavigationName(""); setPosition("HEADER"); setStatus("DRAFT"); setItems([createItem()]); setEditing(true); setMessage("");
|
||||||
|
void loadTargets();
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 打开既有导航编辑页面。 */
|
||||||
|
const editNavigation = (navigation: NavigationSummary) => {
|
||||||
|
setNavigationCode(navigation.navigationCode); setNavigationName(navigation.navigationName); setPosition(navigation.position); setStatus(navigation.status);
|
||||||
|
setItems(navigation.items.map((item) => ({ clientKey: item.itemCode, parentClientKey: item.parentItemCode || "", itemType: item.itemType, title: item.title, targetCode: item.targetCode || "", url: item.url, openType: item.openType, visible: item.visible, sortNo: item.sortNo })));
|
||||||
|
setEditing(true); setMessage(""); void loadTargets();
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 更新指定菜单项。 */
|
||||||
|
const updateItem = (key: string, patch: Partial<NavigationItemForm>) => setItems((current) => current.map((item) => item.clientKey === key ? { ...item, ...patch } : item));
|
||||||
|
|
||||||
|
/** 选择内部页面或内容作为菜单目标。 */
|
||||||
|
const selectTarget = (key: string, encoded: string) => {
|
||||||
|
const option = targets.find((item) => `${item.type}|${item.code}|${item.url}` === encoded);
|
||||||
|
if (option) updateItem(key, { itemType: option.type, targetCode: option.code, url: option.url, title: items.find((item) => item.clientKey === key)?.title || option.label });
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 删除菜单项及其直接子项。 */
|
||||||
|
const deleteItem = (key: string) => setItems((current) => current.filter((item) => item.clientKey !== key && item.parentClientKey !== key));
|
||||||
|
|
||||||
|
/** 保存完整导航菜单树。 */
|
||||||
|
const save = async () => {
|
||||||
|
if (!navigationName.trim() || items.length === 0 || items.some((item) => !item.title.trim() || !item.url.trim())) { setMessage("请填写导航名称及全部菜单项的标题和目标"); return; }
|
||||||
|
try {
|
||||||
|
setSaving(true); setMessage("");
|
||||||
|
await apiPost("/navigations/save", { navigationCode: navigationCode || null, siteCode: SITE_CODE, navigationName, position, status, items: items.map((item, index) => ({ ...item, sortNo: index })) });
|
||||||
|
setEditing(false); await loadList();
|
||||||
|
} catch (error) { setMessage(error instanceof Error ? error.message : "导航保存失败"); } finally { setSaving(false); }
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 删除导航。 */
|
||||||
|
const remove = async (navigation: NavigationSummary) => {
|
||||||
|
if (!window.confirm(`确认删除导航“${navigation.navigationName}”吗?`)) return;
|
||||||
|
try { await apiPost("/navigations/delete", { siteCode: SITE_CODE, navigationCode: navigation.navigationCode }); await loadList(); } catch (error) { setMessage(error instanceof Error ? error.message : "导航删除失败"); }
|
||||||
|
};
|
||||||
|
|
||||||
|
const groupedTargets = useMemo(() => Array.from(new Set(targets.map((item) => item.group))), [targets]);
|
||||||
|
|
||||||
|
if (!editing) return <div className="navigation-manager"><header><div><h1>菜单导航</h1><p>配置前台站页头与页脚显示的菜单结构。</p></div><button className="primary" onClick={createNavigation}><Plus size={17}/>添加导航</button></header>{message && <div className="notice">{message}</div>}<section className="navigation-list"><div className="navigation-list-head"><span>导航</span><span>菜单项</span><span>位置 / 状态</span><span>操作</span></div>{list.length === 0 ? <div className="empty"><Menu size={34}/><strong>暂无导航配置</strong><p>点击“添加导航”创建前台菜单。</p></div> : list.map((navigation) => <div className="navigation-list-row" key={navigation.navigationCode}><strong>{navigation.navigationName}</strong><span>{navigation.items.filter((item) => !item.parentItemCode).map((item) => item.title).join("、") || "--"}</span><span>{navigation.position === "HEADER" ? "页头" : "页脚"} · {navigation.status === "PUBLISHED" ? "已发布" : navigation.status === "OFFLINE" ? "已下线" : "草稿"}</span><div><button title="编辑导航" onClick={() => editNavigation(navigation)}><Pencil size={17}/></button><button className="danger" title="删除导航" onClick={() => void remove(navigation)}><Trash2 size={17}/></button></div></div>)}</section></div>;
|
||||||
|
|
||||||
|
return <div className="navigation-editor"><header><div className="navigation-editor-title"><button className="icon-button" onClick={() => setEditing(false)}><ArrowLeft size={18}/></button><div><h1>{navigationCode ? "编辑导航" : "新增导航"}</h1><p>设置菜单层级、跳转目标和打开方式。</p></div></div><div className="header-actions"><button className="secondary" onClick={() => setEditing(false)}>取消</button><button className="primary" disabled={saving} onClick={() => void save()}><Save size={17}/>{saving ? "保存中" : "保存"}</button></div></header>{message && <div className="notice">{message}</div>}<section className="navigation-base"><label><span>导航标题 *</span><input maxLength={100} value={navigationName} onChange={(event) => setNavigationName(event.target.value)} placeholder="例如:主导航"/></label><label><span>展示位置</span><select value={position} onChange={(event) => setPosition(event.target.value as "HEADER" | "FOOTER")}><option value="HEADER">页头导航</option><option value="FOOTER">页脚导航</option></select></label><label><span>发布状态</span><select value={status} onChange={(event) => setStatus(event.target.value as typeof status)}><option value="DRAFT">草稿</option><option value="PUBLISHED">发布</option><option value="OFFLINE">下线</option></select></label></section><section className="navigation-items"><div className="navigation-items-heading"><div><h2>菜单项</h2><p>菜单项可以指向固定页面、分类、具体内容或自定义地址。</p></div><button className="secondary" onClick={() => setItems((current) => [...current, createItem("", current.length)])}><Plus size={16}/>添加菜单项</button></div><div className="navigation-item-head"><span>菜单标题</span><span>页面打开方式</span><span>跳转目标</span><span>显示</span><span>操作</span></div>{items.map((item) => <div className={`navigation-item-row ${item.parentClientKey ? "child" : ""}`} key={item.clientKey}>{item.parentClientKey && <ChevronRight className="child-marker" size={16}/>}<input value={item.title} onChange={(event) => updateItem(item.clientKey, { title: event.target.value })} placeholder="菜单标题"/><select value={item.openType} onChange={(event) => updateItem(item.clientKey, { openType: event.target.value as NavigationItemForm["openType"] })}><option value="CURRENT">当前页面打开</option><option value="NEW">新窗口打开</option></select><select value={`${item.itemType}|${item.targetCode}|${item.url}`} onChange={(event) => selectTarget(item.clientKey, event.target.value)}><option value={`${item.itemType}|${item.targetCode}|${item.url}`}>{targets.length ? "请选择页面或内容" : "正在加载目标..."}</option>{groupedTargets.map((group) => <optgroup label={group} key={group}>{targets.filter((target) => target.group === group).map((target) => <option key={`${target.type}-${target.code}-${target.url}`} value={`${target.type}|${target.code}|${target.url}`}>{target.label}</option>)}</optgroup>)}</select><label className="switch"><input type="checkbox" checked={item.visible} onChange={(event) => updateItem(item.clientKey, { visible: event.target.checked })}/><span/></label><div className="navigation-row-actions">{!item.parentClientKey && <button title="添加子菜单" onClick={() => setItems((current) => [...current, createItem(item.clientKey, current.length)])}><Plus size={17}/></button>}<button className="danger" title="删除菜单项" onClick={() => deleteItem(item.clientKey)}><Trash2 size={17}/></button></div></div>)}{items.length === 0 && <div className="empty"><strong>暂无菜单项</strong><p>添加至少一个菜单项后才能保存。</p></div>}</section></div>;
|
||||||
|
}
|
||||||
@@ -125,7 +125,6 @@ export default function SeoSettingsPage() {
|
|||||||
</nav>
|
</nav>
|
||||||
{notice && <div className="notice">{notice}</div>}
|
{notice && <div className="notice">{notice}</div>}
|
||||||
<section className="seo-settings-card">
|
<section className="seo-settings-card">
|
||||||
<div className="seo-card-head"><h2>搜索引擎优化</h2><p>系统提供默认内容,发布前请根据当前站点业务进行确认和修改。</p></div>
|
|
||||||
<div className="seo-settings-form">
|
<div className="seo-settings-form">
|
||||||
<label className="wide"><span>SEO 标题 *</span><input maxLength={70} value={form.title} onChange={(event) => setForm({ ...form, title: event.target.value })}/><small>{form.title.length} / 70</small></label>
|
<label className="wide"><span>SEO 标题 *</span><input maxLength={70} value={form.title} onChange={(event) => setForm({ ...form, title: event.target.value })}/><small>{form.title.length} / 70</small></label>
|
||||||
<label className="wide"><span>SEO 描述 *</span><textarea rows={4} maxLength={160} value={form.description} onChange={(event) => setForm({ ...form, description: event.target.value })}/><small>{form.description.length} / 160</small></label>
|
<label className="wide"><span>SEO 描述 *</span><textarea rows={4} maxLength={160} value={form.description} onChange={(event) => setForm({ ...form, description: event.target.value })}/><small>{form.description.length} / 160</small></label>
|
||||||
|
|||||||
+18
-5
@@ -6,9 +6,11 @@ import {
|
|||||||
ChevronDown,
|
ChevronDown,
|
||||||
FileText,
|
FileText,
|
||||||
FolderTree,
|
FolderTree,
|
||||||
|
Globe2,
|
||||||
HelpCircle,
|
HelpCircle,
|
||||||
Image,
|
Image,
|
||||||
Mail,
|
Mail,
|
||||||
|
Menu,
|
||||||
Newspaper,
|
Newspaper,
|
||||||
PanelsTopLeft,
|
PanelsTopLeft,
|
||||||
Paintbrush,
|
Paintbrush,
|
||||||
@@ -30,11 +32,12 @@ import MediaCenter from "./MediaCenter";
|
|||||||
import LoginPage, { type Account } from "./LoginPage";
|
import LoginPage, { type Account } from "./LoginPage";
|
||||||
import SettingsPage from "./SettingsPage";
|
import SettingsPage from "./SettingsPage";
|
||||||
import SeoSettingsPage from "./SeoSettingsPage";
|
import SeoSettingsPage from "./SeoSettingsPage";
|
||||||
|
import NavigationManager from "./NavigationManager";
|
||||||
import { apiPost } from "./api";
|
import { apiPost } from "./api";
|
||||||
|
|
||||||
const SITE_WEB = window.location.hostname === "admin.steliro.com" ? "https://site.steliro.com" : "http://localhost:5174";
|
const SITE_WEB = window.location.hostname === "admin.steliro.com" ? "https://site.steliro.com" : "http://localhost:5174";
|
||||||
const SITE = "SIT0000000000001";
|
const SITE = "SIT0000000000001";
|
||||||
type Section = "products" | "product-categories" | "NEWS" | "NEWS-categories" | "CASE" | "CASE-categories" | "HELP" | "HELP-categories" | "pages" | "seo-settings" | "decoration" | "custom-code" | "media" | "inquiries" | "inquiry-settings" | "settings";
|
type Section = "products" | "product-categories" | "NEWS" | "NEWS-categories" | "CASE" | "CASE-categories" | "HELP" | "HELP-categories" | "pages" | "navigation" | "seo-settings" | "decoration" | "custom-code" | "media" | "inquiries" | "inquiry-settings" | "settings";
|
||||||
type EditorialSection = "NEWS" | "CASE" | "HELP";
|
type EditorialSection = "NEWS" | "CASE" | "HELP";
|
||||||
type ContentEditorState = { contentType: EditorialSection; contentCode: string };
|
type ContentEditorState = { contentType: EditorialSection; contentCode: string };
|
||||||
type Item = {
|
type Item = {
|
||||||
@@ -76,17 +79,21 @@ async function post(path: string, body: unknown) {
|
|||||||
return apiPost(path, body);
|
return apiPost(path, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
const menus = [
|
const frontSiteMenus = [
|
||||||
{ key: "pages" as Section, label: "页面", icon: FileText },
|
{ key: "pages" as Section, label: "页面", icon: FileText },
|
||||||
|
{ key: "navigation" as Section, label: "菜单导航", icon: Menu },
|
||||||
{ key: "decoration" as Section, label: "店铺装修", icon: Paintbrush },
|
{ key: "decoration" as Section, label: "店铺装修", icon: Paintbrush },
|
||||||
{ key: "custom-code" as Section, label: "自定义代码", icon: Code2 },
|
{ key: "custom-code" as Section, label: "自定义代码", icon: Code2 },
|
||||||
|
{ key: "seo-settings" as Section, label: "页面 SEO", icon: Search },
|
||||||
|
];
|
||||||
|
const menus = [
|
||||||
{ key: "media" as Section, label: "素材中心", icon: Image },
|
{ key: "media" as Section, label: "素材中心", icon: Image },
|
||||||
{ key: "inquiries" as Section, label: "询盘", icon: Mail },
|
{ key: "inquiries" as Section, label: "询盘", icon: Mail },
|
||||||
];
|
];
|
||||||
const sectionLabels: Record<Section, string> = {
|
const sectionLabels: Record<Section, string> = {
|
||||||
products: "产品", "product-categories": "产品分类", NEWS: "新闻", "NEWS-categories": "新闻分类",
|
products: "产品", "product-categories": "产品分类", NEWS: "新闻", "NEWS-categories": "新闻分类",
|
||||||
CASE: "案例", "CASE-categories": "案例分类", HELP: "帮助", "HELP-categories": "帮助分类",
|
CASE: "案例", "CASE-categories": "案例分类", HELP: "帮助", "HELP-categories": "帮助分类",
|
||||||
pages: "页面", decoration: "店铺装修", "custom-code": "自定义代码", media: "素材中心", inquiries: "询盘", "inquiry-settings": "询盘设置",
|
pages: "页面", navigation: "菜单导航", decoration: "店铺装修", "custom-code": "自定义代码", media: "素材中心", inquiries: "询盘", "inquiry-settings": "询盘设置",
|
||||||
"seo-settings": "页面 SEO",
|
"seo-settings": "页面 SEO",
|
||||||
settings: "系统设置",
|
settings: "系统设置",
|
||||||
};
|
};
|
||||||
@@ -122,6 +129,7 @@ function App({ account, onAccount, onLogout }: { account: Account; onAccount: (v
|
|||||||
const [editingPage, setEditingPage] = useState<string | null>(resolvePageRoute);
|
const [editingPage, setEditingPage] = useState<string | null>(resolvePageRoute);
|
||||||
const [productMenuOpen, setProductMenuOpen] = useState(true);
|
const [productMenuOpen, setProductMenuOpen] = useState(true);
|
||||||
const [contentMenuOpen, setContentMenuOpen] = useState(true);
|
const [contentMenuOpen, setContentMenuOpen] = useState(true);
|
||||||
|
const [frontSiteMenuOpen, setFrontSiteMenuOpen] = useState(true);
|
||||||
const navigateSection = (next: Section) => {
|
const navigateSection = (next: Section) => {
|
||||||
setEditingProduct(null);
|
setEditingProduct(null);
|
||||||
setEditingContent(null);
|
setEditingContent(null);
|
||||||
@@ -145,6 +153,8 @@ function App({ account, onAccount, onLogout }: { account: Account; onAccount: (v
|
|||||||
? { items: [] }
|
? { items: [] }
|
||||||
: section === "settings"
|
: section === "settings"
|
||||||
? { items: [] }
|
? { items: [] }
|
||||||
|
: section === "navigation"
|
||||||
|
? { items: [] }
|
||||||
: section === "products"
|
: section === "products"
|
||||||
? await post("/products/list", { siteCode: SITE })
|
? await post("/products/list", { siteCode: SITE })
|
||||||
: section === "pages"
|
: section === "pages"
|
||||||
@@ -310,6 +320,10 @@ function App({ account, onAccount, onLogout }: { account: Account; onAccount: (v
|
|||||||
<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>
|
<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>}
|
{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>
|
</div>
|
||||||
|
<div className="nav-group">
|
||||||
|
<button className={frontSiteMenus.some((item) => item.key === section) ? "group-active" : ""} onClick={() => setFrontSiteMenuOpen(!frontSiteMenuOpen)}><Globe2 size={18}/>前台站<ChevronDown className={frontSiteMenuOpen ? "expanded" : ""} size={16}/></button>
|
||||||
|
{frontSiteMenuOpen && <div className="nav-children front-site-children">{frontSiteMenus.map((item) => <button key={item.key} className={section === item.key ? "active" : ""} onClick={() => navigateSection(item.key)}><item.icon size={15}/>{item.label}</button>)}</div>}
|
||||||
|
</div>
|
||||||
{menus.map((m) => (
|
{menus.map((m) => (
|
||||||
<button
|
<button
|
||||||
key={m.key}
|
key={m.key}
|
||||||
@@ -320,7 +334,6 @@ function App({ account, onAccount, onLogout }: { account: Account; onAccount: (v
|
|||||||
{m.label}
|
{m.label}
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
<button className={section === "seo-settings" ? "active" : ""} onClick={() => navigateSection("seo-settings")}><Search size={18}/>页面 SEO</button>
|
|
||||||
</nav>
|
</nav>
|
||||||
<div className="aside-bottom">
|
<div className="aside-bottom">
|
||||||
<button>
|
<button>
|
||||||
@@ -338,7 +351,7 @@ function App({ account, onAccount, onLogout }: { account: Account; onAccount: (v
|
|||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
<main>
|
<main>
|
||||||
{section === "settings" ? <SettingsPage account={account} onAccount={onAccount} onLogout={onLogout}/> : section === "seo-settings" ? <SeoSettingsPage/> : section === "decoration" ? <DecorationEditor onBack={() => navigateSection("pages")}/> : section === "custom-code" ? <CustomCodeManager/> : section === "media" ? <MediaCenter/> : editingProduct !== null ? <ProductEditor productCode={editingProduct || undefined} onBack={closeProductEditor} /> : editingContent !== null ? <ContentEditor contentType={editingContent.contentType} contentCode={editingContent.contentCode || undefined} onBack={closeContentEditor} /> : editingPage !== null ? <PageEditor pageCode={editingPage || undefined} onBack={closePageEditor}/> : <>
|
{section === "settings" ? <SettingsPage account={account} onAccount={onAccount} onLogout={onLogout}/> : section === "seo-settings" ? <SeoSettingsPage/> : section === "navigation" ? <NavigationManager/> : section === "decoration" ? <DecorationEditor onBack={() => navigateSection("pages")}/> : section === "custom-code" ? <CustomCodeManager/> : section === "media" ? <MediaCenter/> : editingProduct !== null ? <ProductEditor productCode={editingProduct || undefined} onBack={closeProductEditor} /> : editingContent !== null ? <ContentEditor contentType={editingContent.contentType} contentCode={editingContent.contentCode || undefined} onBack={closeContentEditor} /> : editingPage !== null ? <PageEditor pageCode={editingPage || undefined} onBack={closePageEditor}/> : <>
|
||||||
{section.endsWith("-categories") ? <CategoryManager contentType={section === "NEWS-categories" ? "NEWS" : section === "CASE-categories" ? "CASE" : section === "HELP-categories" ? "HELP" : undefined}/> : <>
|
{section.endsWith("-categories") ? <CategoryManager contentType={section === "NEWS-categories" ? "NEWS" : section === "CASE-categories" ? "CASE" : section === "HELP-categories" ? "HELP" : undefined}/> : <>
|
||||||
<header>
|
<header>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ select {
|
|||||||
.shell {
|
.shell {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 230px 1fr;
|
grid-template-columns: 230px 1fr;
|
||||||
min-height: 100vh;
|
height: 100vh;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
.shell > aside {
|
.shell > aside {
|
||||||
background: #17212b;
|
background: #17212b;
|
||||||
@@ -38,6 +39,8 @@ select {
|
|||||||
padding: 22px 14px;
|
padding: 22px 14px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
min-height: 0;
|
||||||
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
.brand {
|
.brand {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -102,6 +105,8 @@ nav {
|
|||||||
main {
|
main {
|
||||||
padding: 28px 34px;
|
padding: 28px 34px;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
min-height: 0;
|
||||||
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
header {
|
header {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -414,8 +419,11 @@ header p {
|
|||||||
.inquiry-editor-layout{grid-template-columns:1fr}.form-list-row{grid-template-columns:1fr}.forms-heading{align-items:flex-start;gap:12px}.form-field-table{overflow-x:auto}.form-field-head,.form-field-item{min-width:760px}.field-dialog .form-grid{grid-template-columns:1fr}.field-dialog .form-grid .wide{grid-column:auto}
|
.inquiry-editor-layout{grid-template-columns:1fr}.form-list-row{grid-template-columns:1fr}.forms-heading{align-items:flex-start;gap:12px}.form-field-table{overflow-x:auto}.form-field-head,.form-field-item{min-width:760px}.field-dialog .form-grid{grid-template-columns:1fr}.field-dialog .form-grid .wide{grid-column:auto}
|
||||||
}
|
}
|
||||||
.inquiry-table{overflow-x:auto}.inquiry-table .thead,.inquiry-table .row{min-width:1120px;grid-template-columns:1.25fr 1.7fr 1.35fr 1fr 1fr .8fr .65fr}.inquiry-table .row>span{min-width:0}.inquiry-table .row>span:nth-child(2){overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
.inquiry-table{overflow-x:auto}.inquiry-table .thead,.inquiry-table .row{min-width:1120px;grid-template-columns:1.25fr 1.7fr 1.35fr 1fr 1fr .8fr .65fr}.inquiry-table .row>span{min-width:0}.inquiry-table .row>span:nth-child(2){overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||||
.seo-settings-page{max-width:1500px;margin:0 auto}.seo-settings-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:24px;margin-bottom:20px}.seo-settings-heading h1{font-size:25px;font-weight:500;margin:0 0 6px}.seo-settings-heading p{margin:0;color:#72808d;font-size:13px}.seo-settings-heading .primary{display:inline-flex;align-items:center;gap:7px;white-space:nowrap}.seo-page-tabs{display:flex;gap:28px;overflow-x:auto;border-bottom:1px solid #dfe5e9;margin-bottom:20px;background:#fff;padding:0 20px}.seo-page-tabs button{flex:none;border:0;border-bottom:2px solid transparent;background:transparent;padding:15px 2px 13px;color:#68757f;font:inherit;cursor:pointer}.seo-page-tabs button.active{color:#176b5b;border-bottom-color:#176b5b;font-weight:500}.seo-settings-card{background:#fff;border:1px solid #dfe5e9;border-radius:6px;overflow:hidden}.seo-card-head{padding:20px 24px;border-bottom:1px solid #e6e9ed}.seo-card-head h2{font-size:17px;font-weight:500;margin:0 0 7px}.seo-card-head p{font-size:13px;color:#77838d;margin:0}.seo-settings-form{display:grid;grid-template-columns:1fr 1fr;gap:19px 22px;padding:24px}.seo-settings-form label{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:7px;align-items:center;min-width:0}.seo-settings-form label>span{grid-column:1/-1;font-size:13px;font-weight:500}.seo-settings-form input,.seo-settings-form textarea,.seo-settings-form select{grid-column:1/-1;box-sizing:border-box;width:100%;min-width:0;border:1px solid #d8dee3;border-radius:5px;padding:10px 12px;font:inherit;resize:vertical}.seo-settings-form label>small{grid-column:2;grid-row:1;color:#89949c;font-size:11px}.seo-settings-form .wide{grid-column:1/-1}.seo-settings-form .code-input{font-family:Consolas,"Courier New",monospace;font-size:13px}.seo-settings-page .notice{margin-bottom:18px}@media(max-width:900px){.seo-settings-heading{align-items:stretch;flex-direction:column}.seo-settings-heading .primary{justify-content:center}.seo-page-tabs{gap:20px}.seo-settings-form{grid-template-columns:1fr;padding:18px}.seo-settings-form .wide{grid-column:auto}}
|
.seo-settings-page{max-width:1500px;margin:0 auto}.seo-settings-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:24px;margin-bottom:20px}.seo-settings-heading h1{font-size:25px;font-weight:500;margin:0 0 6px}.seo-settings-heading p{margin:0;color:#72808d;font-size:13px}.seo-settings-heading .primary{display:inline-flex;align-items:center;gap:7px;white-space:nowrap}.seo-page-tabs{display:flex;gap:28px;overflow-x:auto;border-bottom:1px solid #dfe5e9;margin-bottom:20px;background:#fff;padding:0 20px}.seo-page-tabs button{flex:none;border:0;border-bottom:2px solid transparent;background:transparent;padding:15px 2px 13px;color:#68757f;font:inherit;cursor:pointer}.seo-page-tabs button.active{color:#176b5b;border-bottom-color:#176b5b;font-weight:500}.seo-settings-card{background:#fff;border:1px solid #dfe5e9;border-radius:6px;overflow:hidden}.seo-settings-form{display:grid;grid-template-columns:1fr 1fr;gap:19px 22px;padding:24px}.seo-settings-form label{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:7px;align-items:center;min-width:0}.seo-settings-form label>span{grid-column:1/-1;font-size:13px;font-weight:500}.seo-settings-form input,.seo-settings-form textarea,.seo-settings-form select{grid-column:1/-1;box-sizing:border-box;width:100%;min-width:0;border:1px solid #d8dee3;border-radius:5px;padding:10px 12px;font:inherit;resize:vertical}.seo-settings-form label>small{grid-column:2;grid-row:1;color:#89949c;font-size:11px}.seo-settings-form .wide{grid-column:1/-1}.seo-settings-form .code-input{font-family:Consolas,"Courier New",monospace;font-size:13px}.seo-settings-page .notice{margin-bottom:18px}@media(max-width:900px){.seo-settings-heading{align-items:stretch;flex-direction:column}.seo-settings-heading .primary{justify-content:center}.seo-page-tabs{gap:20px}.seo-settings-form{grid-template-columns:1fr;padding:18px}.seo-settings-form .wide{grid-column:auto}}
|
||||||
|
|
||||||
.auth-loading{min-height:100vh;display:flex;align-items:center;justify-content:center;gap:12px;color:#66737d;background:#f4f6f8}.auth-spinner{width:24px;height:24px;border:2px solid #d4ddda;border-top-color:#176b5b;border-radius:50%;animation:auth-spin .8s linear infinite}@keyframes auth-spin{to{transform:rotate(360deg)}}
|
.auth-loading{min-height:100vh;display:flex;align-items:center;justify-content:center;gap:12px;color:#66737d;background:#f4f6f8}.auth-spinner{width:24px;height:24px;border:2px solid #d4ddda;border-top-color:#176b5b;border-radius:50%;animation:auth-spin .8s linear infinite}@keyframes auth-spin{to{transform:rotate(360deg)}}
|
||||||
.login-page{min-height:100vh;display:grid;place-items:center;padding:24px;background:#eef2f3}.login-panel{width:min(430px,100%);background:#fff;border:1px solid #dfe5e9;border-radius:8px;padding:38px;box-shadow:0 18px 48px rgba(19,37,45,.1)}.login-brand{display:flex;align-items:center;gap:12px;margin-bottom:38px}.login-brand>span{width:48px;height:48px;border-radius:7px;background:#efbd43;display:grid;place-items:center;color:#13202b;font-size:24px;font-weight:700}.login-brand>div{display:grid}.login-brand strong{font-size:23px}.login-brand small{color:#77858e}.login-copy h1{font-size:26px;margin:0 0 9px}.login-copy p{margin:0 0 28px;color:#74818a;line-height:1.6}.login-panel form{display:grid;gap:18px}.login-panel label{display:grid;gap:8px}.login-panel label>span{font-size:13px;font-weight:600}.login-input{height:48px;border:1px solid #d6dde2;border-radius:5px;display:flex;align-items:center;padding:0 13px;gap:10px;color:#7b878f}.login-input:focus-within{border-color:#176b5b;box-shadow:0 0 0 3px rgba(23,107,91,.09)}.login-input input{border:0;outline:0;min-width:0;flex:1;font:inherit}.login-input button{border:0;background:transparent;padding:4px;color:#65727b;display:grid;place-items:center}.login-error{padding:10px 12px;border:1px solid #f0c9c9;background:#fff6f6;color:#a33b3b;border-radius:5px;font-size:13px}.login-submit{height:48px;border:0;border-radius:5px;background:#176b5b;color:#fff;font:inherit;font-weight:600;cursor:pointer}.login-submit:disabled{opacity:.55;cursor:not-allowed}
|
.login-page{min-height:100vh;display:grid;place-items:center;padding:24px;background:#eef2f3}.login-panel{width:min(430px,100%);background:#fff;border:1px solid #dfe5e9;border-radius:8px;padding:38px;box-shadow:0 18px 48px rgba(19,37,45,.1)}.login-brand{display:flex;align-items:center;gap:12px;margin-bottom:38px}.login-brand>span{width:48px;height:48px;border-radius:7px;background:#efbd43;display:grid;place-items:center;color:#13202b;font-size:24px;font-weight:700}.login-brand>div{display:grid}.login-brand strong{font-size:23px}.login-brand small{color:#77858e}.login-copy h1{font-size:26px;margin:0 0 9px}.login-copy p{margin:0 0 28px;color:#74818a;line-height:1.6}.login-panel form{display:grid;gap:18px}.login-panel label{display:grid;gap:8px}.login-panel label>span{font-size:13px;font-weight:600}.login-input{height:48px;border:1px solid #d6dde2;border-radius:5px;display:flex;align-items:center;padding:0 13px;gap:10px;color:#7b878f}.login-input:focus-within{border-color:#176b5b;box-shadow:0 0 0 3px rgba(23,107,91,.09)}.login-input input{border:0;outline:0;min-width:0;flex:1;font:inherit}.login-input button{border:0;background:transparent;padding:4px;color:#65727b;display:grid;place-items:center}.login-error{padding:10px 12px;border:1px solid #f0c9c9;background:#fff6f6;color:#a33b3b;border-radius:5px;font-size:13px}.login-submit{height:48px;border:0;border-radius:5px;background:#176b5b;color:#fff;font:inherit;font-weight:600;cursor:pointer}.login-submit:disabled{opacity:.55;cursor:not-allowed}
|
||||||
.account-settings{max-width:1500px;margin:0 auto}.account-settings>header{display:flex;align-items:flex-start;justify-content:space-between;margin-bottom:22px}.account-settings>header h1{margin:0 0 6px;font-size:28px}.account-settings>header p{margin:0;color:#71808a}.account-settings>header button{display:flex;align-items:center;gap:7px;border:1px solid #d8dee3;background:#fff;border-radius:5px;padding:10px 14px}.settings-message{margin-bottom:18px;padding:12px 15px;border:1px solid #bcdcd3;background:#eef8f5;color:#176b5b;border-radius:5px}.settings-message.error{border-color:#efcaca;background:#fff6f6;color:#9c3838}.settings-layout{display:grid;grid-template-columns:minmax(0,1.35fr) minmax(360px,.65fr);gap:20px;align-items:start}.settings-side{display:grid;gap:20px}.profile-card{background:#fff;border:1px solid #dfe5e9;border-radius:6px;padding:24px;display:grid;grid-template-columns:1fr 1fr;gap:18px}.settings-side .profile-card{grid-template-columns:1fr}.profile-card-title{grid-column:1/-1;display:flex;align-items:flex-start;gap:13px;padding-bottom:18px;border-bottom:1px solid #e8ecef}.profile-card-title>svg{color:#176b5b}.profile-card-title h2{font-size:18px;margin:0 0 5px}.profile-card-title p{font-size:13px;color:#77848d;margin:0;line-height:1.5}.profile-card label{display:grid;gap:7px}.profile-card label>span{font-size:13px;font-weight:600}.profile-card input,.profile-card textarea{border:1px solid #d8dee3;border-radius:5px;padding:11px 12px;font:inherit;resize:vertical}.profile-card .wide,.profile-actions{grid-column:1/-1}.profile-actions{display:flex;justify-content:flex-end;padding-top:4px}.profile-actions button{border:0;border-radius:5px;background:#176b5b;color:#fff;padding:10px 15px;display:flex;align-items:center;gap:7px;font:inherit;cursor:pointer}@media(max-width:1000px){.settings-layout{grid-template-columns:1fr}}@media(max-width:620px){.login-panel{padding:28px 22px}.profile-card{grid-template-columns:1fr}.profile-card .wide,.profile-actions{grid-column:auto}.account-settings>header{gap:14px}.account-settings>header p{display:none}}
|
.account-settings{max-width:1500px;margin:0 auto}.account-settings>header{display:flex;align-items:flex-start;justify-content:space-between;margin-bottom:22px}.account-settings>header h1{margin:0 0 6px;font-size:28px}.account-settings>header p{margin:0;color:#71808a}.account-settings>header button{display:flex;align-items:center;gap:7px;border:1px solid #d8dee3;background:#fff;border-radius:5px;padding:10px 14px}.settings-message{margin-bottom:18px;padding:12px 15px;border:1px solid #bcdcd3;background:#eef8f5;color:#176b5b;border-radius:5px}.settings-message.error{border-color:#efcaca;background:#fff6f6;color:#9c3838}.settings-layout{display:grid;grid-template-columns:minmax(0,1.35fr) minmax(360px,.65fr);gap:20px;align-items:start}.settings-side{display:grid;gap:20px}.profile-card{background:#fff;border:1px solid #dfe5e9;border-radius:6px;padding:24px;display:grid;grid-template-columns:1fr 1fr;gap:18px}.settings-side .profile-card{grid-template-columns:1fr}.profile-card-title{grid-column:1/-1;display:flex;align-items:flex-start;gap:13px;padding-bottom:18px;border-bottom:1px solid #e8ecef}.profile-card-title>svg{color:#176b5b}.profile-card-title h2{font-size:18px;margin:0 0 5px}.profile-card-title p{font-size:13px;color:#77848d;margin:0;line-height:1.5}.profile-card label{display:grid;gap:7px}.profile-card label>span{font-size:13px;font-weight:600}.profile-card input,.profile-card textarea{border:1px solid #d8dee3;border-radius:5px;padding:11px 12px;font:inherit;resize:vertical}.profile-card .wide,.profile-actions{grid-column:1/-1}.profile-actions{display:flex;justify-content:flex-end;padding-top:4px}.profile-actions button{border:0;border-radius:5px;background:#176b5b;color:#fff;padding:10px 15px;display:flex;align-items:center;gap:7px;font:inherit;cursor:pointer}@media(max-width:1000px){.settings-layout{grid-template-columns:1fr}}@media(max-width:620px){.login-panel{padding:28px 22px}.profile-card{grid-template-columns:1fr}.profile-card .wide,.profile-actions{grid-column:auto}.account-settings>header{gap:14px}.account-settings>header p{display:none}}
|
||||||
|
|
||||||
|
/* 菜单导航管理 */
|
||||||
|
.navigation-manager,.navigation-editor{max-width:1500px;margin:0 auto}.navigation-manager>header,.navigation-editor>header{align-items:flex-start}.navigation-list,.navigation-base,.navigation-items{background:#fff;border:1px solid #dfe5e9;border-radius:6px;overflow:hidden}.navigation-list-head,.navigation-list-row{display:grid;grid-template-columns:1.1fr 2.2fr .9fr 110px;align-items:center;gap:18px;padding:15px 20px}.navigation-list-head{background:#f7f9fb;color:#6d7983;font-size:12px;border-bottom:1px solid #e5e9ec}.navigation-list-row{min-height:70px;border-bottom:1px solid #edf0f2}.navigation-list-row:last-child{border-bottom:0}.navigation-list-row>span{color:#52616d;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.navigation-list-row>div{display:flex;gap:8px}.navigation-list-row button,.navigation-row-actions button{width:34px;height:34px;border:0;background:transparent;color:#176b5b;display:grid;place-items:center;border-radius:4px;cursor:pointer}.navigation-list-row button:hover,.navigation-row-actions button:hover{background:#eef5f3}.navigation-list-row button.danger,.navigation-row-actions button.danger{color:#b13d3d}.navigation-editor-title{display:flex;align-items:flex-start;gap:12px}.navigation-editor-title .icon-button{width:38px;height:38px;border:1px solid #d6dde2;background:#fff;border-radius:5px;display:grid;place-items:center;cursor:pointer}.navigation-base{padding:22px;display:grid;grid-template-columns:minmax(300px,2fr) minmax(180px,1fr) minmax(180px,1fr);gap:18px;margin-bottom:20px}.navigation-base label{display:grid;gap:7px}.navigation-base label>span{font-size:13px;font-weight:600}.navigation-base input,.navigation-base select,.navigation-item-row input,.navigation-item-row select{height:42px;width:100%;min-width:0;border:1px solid #d7dee3;border-radius:5px;background:#fff;padding:0 12px;font:inherit}.navigation-items-heading{padding:20px 22px;display:flex;justify-content:space-between;align-items:flex-start;border-bottom:1px solid #e6eaed}.navigation-items-heading h2{font-size:18px;margin:0 0 5px}.navigation-items-heading p{margin:0;color:#75818a;font-size:13px}.navigation-items-heading .secondary{height:40px}.navigation-item-head,.navigation-item-row{display:grid;grid-template-columns:minmax(160px,1fr) 190px minmax(260px,1.5fr) 72px 90px;align-items:center;gap:14px;padding:12px 20px}.navigation-item-head{background:#f7f9fb;color:#6d7983;font-size:12px;border-bottom:1px solid #e5e9ec}.navigation-item-row{position:relative;border-bottom:1px solid #edf0f2}.navigation-item-row.child{padding-left:50px;background:#fbfcfd}.navigation-item-row .child-marker{position:absolute;left:24px;color:#87939c}.navigation-row-actions{display:flex;justify-content:flex-end;gap:4px}.switch{display:inline-flex;align-items:center;cursor:pointer}.switch input{position:absolute;opacity:0;pointer-events:none}.switch span{width:40px;height:22px;border-radius:12px;background:#aeb8bf;position:relative;transition:.2s}.switch span:after{content:"";position:absolute;width:18px;height:18px;left:2px;top:2px;background:#fff;border-radius:50%;box-shadow:0 1px 3px #0003;transition:.2s}.switch input:checked+span{background:#176b5b}.switch input:checked+span:after{transform:translateX(18px)}.navigation-items>.empty{min-height:210px}@media(max-width:1050px){.navigation-list-head,.navigation-list-row{grid-template-columns:1fr 1.5fr 110px}.navigation-list-head span:nth-child(3),.navigation-list-row>span:nth-child(3){display:none}.navigation-base{grid-template-columns:1fr 1fr}.navigation-base label:first-child{grid-column:1/-1}.navigation-item-head{display:none}.navigation-item-row,.navigation-item-row.child{grid-template-columns:1fr 1fr;padding:16px}.navigation-item-row.child{padding-left:40px}.navigation-item-row select:nth-of-type(2){grid-column:1/-1}.navigation-row-actions{justify-content:flex-start}}@media(max-width:700px){.navigation-list-head{display:none}.navigation-list-row{grid-template-columns:1fr auto}.navigation-list-row>span{grid-column:1/-1}.navigation-base{grid-template-columns:1fr}.navigation-base label:first-child{grid-column:auto}.navigation-item-row,.navigation-item-row.child{grid-template-columns:1fr;padding:14px}.navigation-item-row select:nth-of-type(2){grid-column:auto}}
|
||||||
+28
-6
@@ -111,6 +111,26 @@ const nav = [
|
|||||||
["Help", "/help"],
|
["Help", "/help"],
|
||||||
["About", "/about-us"],
|
["About", "/about-us"],
|
||||||
];
|
];
|
||||||
|
type NavigationItem = { title: string; url: string; openType: "CURRENT" | "NEW"; children: NavigationItem[] };
|
||||||
|
|
||||||
|
/** 读取已发布导航,没有配置时返回既有默认菜单。 */
|
||||||
|
function useNavigation(position: "HEADER" | "FOOTER"): NavigationItem[] {
|
||||||
|
const fallback = nav.map(([title, url]) => ({ title, url, openType: "CURRENT" as const, children: [] }));
|
||||||
|
const [items, setItems] = useState<NavigationItem[]>(fallback);
|
||||||
|
useEffect(() => {
|
||||||
|
let active = true;
|
||||||
|
post("/navigations/detail", { position })
|
||||||
|
.then((data) => { if (active && data.items?.length) setItems(data.items); })
|
||||||
|
.catch(() => undefined);
|
||||||
|
return () => { active = false; };
|
||||||
|
}, [position]);
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 渲染支持二级菜单的前台导航链接。 */
|
||||||
|
function NavigationLinks({ items }: { items: NavigationItem[] }) {
|
||||||
|
return <>{items.map((item) => <div className="site-nav-item" key={`${item.title}-${item.url}`}><a href={item.url} target={item.openType === "NEW" ? "_blank" : undefined} rel={item.openType === "NEW" ? "noreferrer" : undefined}>{item.title}</a>{item.children?.length > 0 && <div className="site-subnav">{item.children.map((child) => <a href={child.url} key={`${child.title}-${child.url}`} target={child.openType === "NEW" ? "_blank" : undefined} rel={child.openType === "NEW" ? "noreferrer" : undefined}>{child.title}</a>)}</div>}</div>)}</>;
|
||||||
|
}
|
||||||
function route() {
|
function route() {
|
||||||
const p = location.pathname.split("/").filter(Boolean);
|
const p = location.pathname.split("/").filter(Boolean);
|
||||||
const previewPage = new URLSearchParams(location.search).get("previewPage") || undefined;
|
const previewPage = new URLSearchParams(location.search).get("previewPage") || undefined;
|
||||||
@@ -181,7 +201,7 @@ function DecoratedPage({ pageType, fallback }: { pageType: string; fallback: Rea
|
|||||||
function LiveSection({section}:{section:DecorationSection}) {
|
function LiveSection({section}:{section:DecorationSection}) {
|
||||||
const style={background:section.background,color:section.textColor};
|
const style={background:section.background,color:section.textColor};
|
||||||
if(section.type==="ANNOUNCEMENT")return <div className="live-announcement" style={style}>{section.title}</div>;
|
if(section.type==="ANNOUNCEMENT")return <div className="live-announcement" style={style}>{section.title}</div>;
|
||||||
if(section.type==="HEADER")return <header className="live-header" style={style}><a href="/" className="live-logo">SHOPLIX</a><nav>{nav.map(([name,url])=><a key={url} href={url}>{name}</a>)}</nav><a className="live-quote" href="/contact-us">Get a quote</a></header>;
|
if(section.type==="HEADER")return <LiveHeader style={style}/>;
|
||||||
if(section.type==="HERO")return <section className="live-hero" style={{...style,backgroundImage:section.imageUrl?`linear-gradient(90deg,rgba(0,0,0,.72),rgba(0,0,0,.12)),url(${section.imageUrl})`:undefined}}><div><p>ENGINEERED FOR INDUSTRY</p><h1>{section.title}</h1><span>{section.subtitle}</span>{section.buttonText&&<a href={section.buttonUrl||"#"}>{section.buttonText}<ArrowRight size={17}/></a>}</div></section>;
|
if(section.type==="HERO")return <section className="live-hero" style={{...style,backgroundImage:section.imageUrl?`linear-gradient(90deg,rgba(0,0,0,.72),rgba(0,0,0,.12)),url(${section.imageUrl})`:undefined}}><div><p>ENGINEERED FOR INDUSTRY</p><h1>{section.title}</h1><span>{section.subtitle}</span>{section.buttonText&&<a href={section.buttonUrl||"#"}>{section.buttonText}<ArrowRight size={17}/></a>}</div></section>;
|
||||||
if(section.type==="RICH_TEXT")return <section className="live-rich" style={style}><h2>{section.title}</h2><p>{section.subtitle}</p></section>;
|
if(section.type==="RICH_TEXT")return <section className="live-rich" style={style}><h2>{section.title}</h2><p>{section.subtitle}</p></section>;
|
||||||
if(section.type==="PRODUCTS"||section.type==="CONTENT")return <LiveCollection section={section}/>;
|
if(section.type==="PRODUCTS"||section.type==="CONTENT")return <LiveCollection section={section}/>;
|
||||||
@@ -189,6 +209,11 @@ function LiveSection({section}:{section:DecorationSection}) {
|
|||||||
if(section.type==="FOOTER")return <footer className="live-footer" style={style}><div><b>SHOPLIX</b><p>Industrial Solutions</p></div><div><b>Explore</b><a href="/products">Products</a><a href="/cases">Cases</a><a href="/news">News</a></div><div><b>Company</b><a href="/about-us">About Us</a><a href="/contact-us">Contact Us</a><a href="/privacy-policy">Privacy Policy</a></div><small>{section.subtitle||"Copyright © 2026. All rights reserved."}</small></footer>;
|
if(section.type==="FOOTER")return <footer className="live-footer" style={style}><div><b>SHOPLIX</b><p>Industrial Solutions</p></div><div><b>Explore</b><a href="/products">Products</a><a href="/cases">Cases</a><a href="/news">News</a></div><div><b>Company</b><a href="/about-us">About Us</a><a href="/contact-us">Contact Us</a><a href="/privacy-policy">Privacy Policy</a></div><small>{section.subtitle||"Copyright © 2026. All rights reserved."}</small></footer>;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
/** 装修页面使用的动态页头。 */
|
||||||
|
function LiveHeader({ style }: { style: React.CSSProperties }) {
|
||||||
|
const items = useNavigation("HEADER");
|
||||||
|
return <header className="live-header" style={style}><a href="/" className="live-logo">SHOPLIX</a><nav><NavigationLinks items={items}/></nav><a className="live-quote" href="/contact-us">Get a quote</a></header>;
|
||||||
|
}
|
||||||
function LiveCollection({section}:{section:DecorationSection}) {
|
function LiveCollection({section}:{section:DecorationSection}) {
|
||||||
const [items,setItems]=useState<Item[]>([]);
|
const [items,setItems]=useState<Item[]>([]);
|
||||||
useEffect(()=>{const path=section.type==="PRODUCTS"?"/products/list":"/contents/list";const body=section.type==="PRODUCTS"?{}:{contentType:section.sourceType||"CASE"};post(path,body).then(data=>setItems((data.items||[]).slice(0,section.limit||3))).catch(()=>setItems([]))},[section.type,section.sourceType,section.limit]);
|
useEffect(()=>{const path=section.type==="PRODUCTS"?"/products/list":"/contents/list";const body=section.type==="PRODUCTS"?{}:{contentType:section.sourceType||"CASE"};post(path,body).then(data=>setItems((data.items||[]).slice(0,section.limit||3))).catch(()=>setItems([]))},[section.type,section.sourceType,section.limit]);
|
||||||
@@ -196,6 +221,7 @@ function LiveCollection({section}:{section:DecorationSection}) {
|
|||||||
return <section className="live-collection" style={{background:section.background,color:section.textColor}}><p>FEATURED</p><h2>{section.title}</h2><div>{items.map(item=><a href={`/${base}/${item.slug}`} key={item.productCode||item.contentCode}><div>{item.coverMediaUrl&&<img src={`http://localhost:8082${item.coverMediaUrl}`} alt={item.productName||item.title}/>}</div><span>{section.type==="PRODUCTS"?"PRODUCT":section.sourceType}</span><h3>{item.productName||item.title}</h3><p>{item.summary}</p></a>)}</div></section>;
|
return <section className="live-collection" style={{background:section.background,color:section.textColor}}><p>FEATURED</p><h2>{section.title}</h2><div>{items.map(item=><a href={`/${base}/${item.slug}`} key={item.productCode||item.contentCode}><div>{item.coverMediaUrl&&<img src={`http://localhost:8082${item.coverMediaUrl}`} alt={item.productName||item.title}/>}</div><span>{section.type==="PRODUCTS"?"PRODUCT":section.sourceType}</span><h3>{item.productName||item.title}</h3><p>{item.summary}</p></a>)}</div></section>;
|
||||||
}
|
}
|
||||||
function Header() {
|
function Header() {
|
||||||
|
const items = useNavigation("HEADER");
|
||||||
return (
|
return (
|
||||||
<header>
|
<header>
|
||||||
<a className="logo" href="/">
|
<a className="logo" href="/">
|
||||||
@@ -203,11 +229,7 @@ function Header() {
|
|||||||
<span>Industrial Solutions</span>
|
<span>Industrial Solutions</span>
|
||||||
</a>
|
</a>
|
||||||
<nav>
|
<nav>
|
||||||
{nav.map(([n, h]) => (
|
<NavigationLinks items={items}/>
|
||||||
<a href={h} key={h}>
|
|
||||||
{n}
|
|
||||||
</a>
|
|
||||||
))}
|
|
||||||
</nav>
|
</nav>
|
||||||
<div className="actions">
|
<div className="actions">
|
||||||
<Search size={19} />
|
<Search size={19} />
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ nav {
|
|||||||
nav a:hover {
|
nav a:hover {
|
||||||
color: #16715e;
|
color: #16715e;
|
||||||
}
|
}
|
||||||
|
.site-nav-item{position:relative;display:flex;align-items:center}.site-subnav{display:none;position:absolute;top:100%;left:50%;transform:translateX(-50%);min-width:190px;padding:8px;background:#fff;color:#17242a;border:1px solid #e1e6e4;box-shadow:0 10px 28px #1d302a20}.site-nav-item:hover>.site-subnav,.site-nav-item:focus-within>.site-subnav{display:grid}.site-subnav a{white-space:nowrap;padding:9px 11px;font-weight:500}.site-subnav a:hover{background:#eef5f2}.live-header .site-subnav{top:calc(100% + 18px)}
|
||||||
.actions {
|
.actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
Reference in new issue
Block a user