Files
chuanggao-website/client/dist/assets/case-C97jSxNP.js
2026-05-12 16:53:18 +08:00

2 lines
3.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{c as m}from"./index-eVF4AHSu.js";import{n as p}from"./pagination-BgSlm-mj.js";import{m as u}from"./product-xndN8QNU.js";const d=m();function h(t){return{id:Number(t.id??0),nameZh:String(t.nameZh??t.name??""),nameEn:t.nameEn!==void 0?String(t.nameEn):void 0,code:t.code!==void 0?String(t.code):void 0}}function g(t){return{id:Number(t.id??0),titleZh:String(t.titleZh??t.title??""),titleEn:t.titleEn!==void 0?String(t.titleEn):void 0,subtitleZh:typeof t.subtitleZh=="string"?t.subtitleZh:typeof t.subtitle=="string"?t.subtitle:void 0,coverImage:typeof t.coverImage=="string"||t.coverImage===null?t.coverImage:typeof t.coverUrl=="string"?t.coverUrl:null,locationZh:typeof t.locationZh=="string"?t.locationZh:typeof t.location=="string"?t.location:void 0,categoryLabelZh:typeof t.categoryLabelZh=="string"?t.categoryLabelZh:void 0}}async function A(){try{const t=await d.get("/portal/case/category/list");return Array.isArray(t)?t.map(e=>h(e&&typeof e=="object"?e:{})):[]}catch(t){return console.warn("[portal/case/category/list] fallback:",t),[{id:10,nameZh:"全屋定制案例",code:"whole-house"},{id:20,nameZh:"客厅空间",code:"living"},{id:30,nameZh:"工程案例",code:"project"}]}}function y(t){return Array.from({length:18}).map((e,n)=>({id:800+n,titleZh:`实景案例占位 ${t??"全部"} · ${n+1}`,titleEn:`Reference project ${n+1}`,subtitleZh:"客厅 / 餐厅 / 工装 · 占位分类说明",coverImage:null,locationZh:"(占位地点)珠三角",categoryLabelZh:t?`分类 ${t}`:void 0}))}async function f(t){const e=t.size??9,n=t.page??1,a={page:String(n),size:String(e)};t.categoryId!==void 0&&(a.categoryId=String(t.categoryId)),t.isRecommend===!0&&(a.isRecommend="true");try{const r=await d.get("/portal/case/list",{params:a});return p(r,g,e)}catch(r){console.warn("[portal/case/list] fallback:",r);const l=y(t.categoryId),c=Math.max(0,(n-1)*e),i=l.slice(c,c+e),s=l.length,o=Math.max(1,Math.ceil(s/e));return{records:i,total:s,current:n,pages:o}}}async function C(t){const{records:e}=await f({categoryId:t,page:1,size:24});return e}function v(t){const e=g(t);let n;const a=t.gallery,r=t.images;Array.isArray(a)?n=a.map(o=>!o||typeof o!="object"?{src:null}:{src:o.src??null}):Array.isArray(r)&&(n=r.map(o=>typeof o=="string"?{src:o}:{src:null}));let l,c;const i=t.navigate&&typeof t.navigate=="object"?t.navigate:null;if(i!=null&&i.prev&&typeof i.prev=="object"){const o=i.prev;l={id:Number(o.id??0),titleZh:String(o.titleZh??o.title??"")}}if(i!=null&&i.next&&typeof i.next=="object"){const o=i.next;c={id:Number(o.id??0),titleZh:String(o.titleZh??o.title??"")}}const s=t.relatedProducts&&Array.isArray(t.relatedProducts)?t.relatedProducts.map(o=>u(o&&typeof o=="object"?o:{})):void 0;return{...e,gallery:n,areaSqm:typeof t.areaSqm=="string"?t.areaSqm:t.area!==void 0&&t.area!==null?String(t.area):void 0,finishedAt:typeof t.finishedAt=="string"?t.finishedAt:void 0,narrativeHtmlZh:typeof t.contentHtmlZh=="string"?t.contentHtmlZh:typeof t.narrativeHtmlZh=="string"?t.narrativeHtmlZh:void 0,relatedProducts:s,prev:l,next:c}}async function P(t){try{const e=await d.get(`/portal/case/detail/${t}`);return v(e&&typeof e=="object"?e:{})}catch(e){return console.warn("[portal/case/detail] fallback:",e),{id:Number.parseInt(t,10)||0,titleZh:"案例详情占位",titleEn:"Placeholder case study",subtitleZh:"支持轮播大图、叙事文本与关联 SKU接口就绪后回填。",coverImage:null,gallery:[{src:null},{src:null},{src:null}],areaSqm:"180㎡",locationZh:"深圳 · 占位",finishedAt:"2024-03",narrativeHtmlZh:"<p>案例叙事富文本占位,后续由 CMS 回填。</p>"}}}export{A as a,f as b,P as c,C as f,g as m};