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

2 lines
2.5 KiB
JavaScript

import{c as g}from"./index-eVF4AHSu.js";import{n as p}from"./pagination-BgSlm-mj.js";const a=g();function d(t){return{id:Number(t.id??0),nameZh:String(t.nameZh??t.name??""),nameEn:t.nameEn!==void 0?String(t.nameEn):void 0}}function l(t){return{id:Number(t.id??0),titleZh:String(t.titleZh??t.title??""),titleEn:t.titleEn!==void 0?String(t.titleEn):void 0,summaryZh:typeof t.summaryZh=="string"?t.summaryZh:typeof t.summary=="string"?t.summary:void 0,coverImage:typeof t.coverImage=="string"||t.coverImage===null?t.coverImage:typeof t.coverUrl=="string"?t.coverUrl:null,publishedAt:typeof t.publishedAt=="string"?t.publishedAt:void 0,isTop:typeof t.isTop=="boolean"?t.isTop:void 0,categoryZh:typeof t.categoryZh=="string"?t.categoryZh:void 0}}async function f(){try{const t=await a.get("/portal/news/category/list");return Array.isArray(t)?t.map(e=>d(e&&typeof e=="object"?e:{})):[]}catch(t){return console.warn("[portal/news/category/list] fallback:",t),[{id:101,nameZh:"品牌动态"},{id:102,nameZh:"行业洞察"}]}}function y(){return Array.from({length:12}).map((t,e)=>({id:1201+e,titleZh:`新闻占位 ${e+1}:品牌战略与智能制造升级路线图`,titleEn:`News scaffold ${e+1}`,summaryZh:e%3===0?"占位摘要:发布后由后端 `/portal/news/list` 回写发布时间、置顶与双语字段。":"占位:后续由 MinIO CDN 挂载封面大图与正文富文本。",coverImage:null,publishedAt:`202${4+Math.floor(e/6)}-0${e%9+1}-15`,isTop:e===0}))}async function Z(t){const e=t.size??10,n=t.page??1,o={page:String(n),size:String(e)};t.categoryId!==void 0&&(o.categoryId=String(t.categoryId)),t.isTop===!0&&(o.isTop="true");try{const r=await a.get("/portal/news/list",{params:o});return p(r,l,e)}catch(r){console.warn("[portal/news/list] fallback:",r);const i=y(),s=(n-1)*e,m=i.slice(s,s+e),c=i.length;return{records:m,total:c,current:n,pages:Math.max(1,Math.ceil(c/e))}}}async function v(t){try{const e=await a.get(`/portal/news/detail/${t}`),n=e&&typeof e=="object"?e:{},o=l(n),r=typeof n.contentHtmlZh=="string"?n.contentHtmlZh:typeof n.content=="string"?n.content:void 0;return{...o,contentHtmlZh:r}}catch(e){return console.warn("[portal/news/detail] fallback:",e),{id:Number.parseInt(t,10)||1200,titleZh:"新闻详情占位",titleEn:"News detail scaffold",summaryZh:"摘要占位;正文由 `/portal/news/detail/:id` 富文本回填。",coverImage:null,publishedAt:new Date().toISOString().slice(0,10),contentHtmlZh:"<p>正文占位:<strong>对齐设计稿「关于 · 新闻资讯」 Tab</strong>,上线后移除。</p>"}}}export{Z as a,v as b,f};