功能迭代
This commit is contained in:
1 parent
0b41b03011
commit
148d1297b2
15 files changed
+4705
-99
No files matched your search
@@ -317,7 +317,7 @@ function CustomCodeRuntime() {
|
||||
useEffect(() => { let nodes: HTMLElement[] = []; post("/custom-codes/list", { siteCode: "SIT0000000000001" }).then(data => { (data.items || []).forEach((item: { content: string; position: string }) => { const container = item.position === "HEAD" ? document.head : document.body; const wrapper = document.createElement("div"); wrapper.innerHTML = item.content; Array.from(wrapper.children).forEach(child => { let node: HTMLElement = child as HTMLElement; if (child.tagName === "SCRIPT") { const script = document.createElement("script"); Array.from(child.attributes).forEach(attribute => script.setAttribute(attribute.name, attribute.value)); script.text = child.textContent || ""; node = script; } container.insertBefore(node, item.position === "BODY_START" ? container.firstChild : null); nodes.push(node); }); }); }).catch(() => undefined); return () => nodes.forEach(node => node.remove()); }, []);
|
||||
return null;
|
||||
}
|
||||
type DecorationSection = { id:string; type:string; title:string; subtitle:string; imageUrl:string; imageUrls?:string[]; heroHeight?:"30"|"50"|"80"|"100"; buttonText:string; buttonUrl:string; sourceType:string; limit:number; visible:boolean; background:string; textColor:string; showProductInformation?:boolean; productInformationTitle?:string; productInformationLimit?:number };
|
||||
type DecorationSection = { id:string; type:string; title:string; subtitle:string; imageUrl:string; imageUrls?:string[]; videoUrl?:string; heroHeight?:"30"|"50"|"80"|"100"; buttonText:string; buttonUrl:string; sourceType:string; limit:number; visible:boolean; background:string; textColor:string; showProductInformation?:boolean; productInformationTitle?:string; productInformationLimit?:number };
|
||||
type ProductDetailConfiguration = {
|
||||
/** 是否在商品摘要区域展示产品信息。 */
|
||||
showProductInformation?: boolean;
|
||||
@@ -337,13 +337,14 @@ function DecoratedPage({ pageType, fallback }: { pageType: string; fallback: Rea
|
||||
function LiveSection({section}:{section:DecorationSection}) {
|
||||
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==="HEADER")return <LiveHeader style={style}/>;
|
||||
if(section.type==="HEADER")return <LiveHeader section={section} style={style}/>;
|
||||
if(section.type==="HERO")return <LiveHero section={section} style={style}/>;
|
||||
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.imageUrl&&<img src={assetUrl(section.imageUrl)} alt={section.title}/>}</section>;
|
||||
if(section.type==="VIDEO")return <section className="live-video" style={style}><div><p>OUR FACTORY</p><h2>{section.title}</h2><span>{section.subtitle}</span></div>{section.videoUrl&&<video controls playsInline preload="metadata" src={assetUrl(section.videoUrl)}/>}</section>;
|
||||
if(section.type==="PRODUCT_DETAIL")return <RuntimeProductDetail configuration={section}/>;
|
||||
if(section.type==="PRODUCTS"||section.type==="CONTENT")return <LiveCollection section={section}/>;
|
||||
if(section.type==="INQUIRY")return <section className="live-inquiry" style={style}><div><p>START A PROJECT</p><h2>{section.title}</h2><span>{section.subtitle}</span></div><InquiryForm scene="GENERAL"/></section>;
|
||||
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>{section.title||"Trimmer Head Sourcing"}</b><p>{section.subtitle||"Garden Tool Parts & Accessories"}</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>Copyright © 2026. All rights reserved.</small></footer>;
|
||||
return null;
|
||||
}
|
||||
/** 首页首屏轮播组件,支持自动播放、左右切换和指示点。 */
|
||||
@@ -365,13 +366,13 @@ function RuntimeProductDetail({ configuration }: { configuration: ProductDetailC
|
||||
return <ProductDetailView data={product} configuration={configuration}/>;
|
||||
}
|
||||
/** 装修页面使用的动态页头。 */
|
||||
function LiveHeader({ style }: { style: React.CSSProperties }) {
|
||||
function LiveHeader({ section, style }: { section: DecorationSection; style: React.CSSProperties }) {
|
||||
const items = useNavigation("HEADER");
|
||||
const productCategories = useProductCategoryTree();
|
||||
const navigationItems = items.map((item) => productCategories.length > 0 && item.url.split("?")[0] === "/products"
|
||||
? { ...item, children: productCategoryNavigation(productCategories) }
|
||||
: item);
|
||||
return <header className="live-header" style={style}><a href="/" className="live-logo">SHOPLIX</a><nav><NavigationLinks items={navigationItems}/></nav><a className="live-quote" href="/contact-us">Get a quote</a></header>;
|
||||
return <header className="live-header" style={style}><a href="/" className="live-logo">{section.title||"Trimmer Head Sourcing"}</a><nav><NavigationLinks items={navigationItems}/></nav><a className="live-quote" href="/contact-us">Get a quote</a></header>;
|
||||
}
|
||||
function LiveCollection({section}:{section:DecorationSection}) {
|
||||
const [items,setItems]=useState<Item[]>([]);
|
||||
|
||||
Reference in new issue
Block a user