import { defineComponent, ref, computed, watch, resolveComponent, mergeProps, withCtx, unref, createVNode, createBlock, toDisplayString, openBlock, Fragment, renderList, isRef, createCommentVNode, useSSRContext } from 'vue'; import { ssrRenderAttrs, ssrRenderStyle, ssrInterpolate, ssrRenderComponent, ssrRenderList, ssrRenderClass, ssrRenderAttr } from 'vue/server-renderer'; import { message } from 'ant-design-vue'; import { a as _export_sfc, e as useRoute, d as useRouter } from './server.mjs'; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "ArticleListPage", __ssrInlineRender: true, props: { config: {} }, setup(__props) { const props = __props; const route = useRoute(); const router = useRouter(); const activeType = ref(route.query.type || ""); const currentPage = ref(1); const pageSize = ref(12); const total = ref(0); const loading = ref(false); const articles = ref([]); const currentCategoryLabel = computed(() => { if (!activeType.value) return "全部文章"; const found = props.config.categories.find((c) => c.type === activeType.value); return found?.label || "全部文章"; }); function getCategoryLabel(type) { const found = props.config.categories.find((c) => c.type === type); return found?.label || type; } function selectType(type) { activeType.value = type; currentPage.value = 1; router.replace({ query: type ? { type } : {} }); loadArticles(); } async function loadArticles() { loading.value = true; try { total.value = 35; articles.value = Array.from({ length: Math.min(pageSize.value, 35 - (currentPage.value - 1) * pageSize.value) }, (_, i) => ({ id: (currentPage.value - 1) * pageSize.value + i + 1, title: `${currentCategoryLabel.value}文章标题 ${(currentPage.value - 1) * pageSize.value + i + 1}:广西政策研究成果发布`, overview: "摘要内容:本文就广西经济社会发展中的若干重大问题进行深入研究,提出了切实可行的政策建议和对策措施,为相关决策提供参考依据...", image: `https://picsum.photos/200/130?random=${(currentPage.value - 1) * pageSize.value + i + 1}`, source: "广西决策咨询中心", publishTime: `2024-12-${String(20 - i).padStart(2, "0")}`, views: Math.floor(Math.random() * 2e3) + 100, type: activeType.value || props.config.categories[i % props.config.categories.length]?.type })); } catch (e) { message.error("加载失败"); } finally { loading.value = false; } } function handlePageChange(page) { currentPage.value = page; loadArticles(); (void 0).scrollTo({ top: 0, behavior: "smooth" }); } function handleView(article) { router.push(`/article/${article.id}`); } watch(() => route.query.type, (newType) => { activeType.value = newType || ""; currentPage.value = 1; loadArticles(); }); return (_ctx, _push, _parent, _attrs) => { const _component_a_row = resolveComponent("a-row"); const _component_a_col = resolveComponent("a-col"); const _component_a_skeleton = resolveComponent("a-skeleton"); const _component_a_empty = resolveComponent("a-empty"); const _component_a_pagination = resolveComponent("a-pagination"); _push(`

${ssrInterpolate(__props.config.title)}

`); _push(ssrRenderComponent(_component_a_row, { gutter: [32, 0] }, { default: withCtx((_, _push2, _parent2, _scopeId) => { if (_push2) { _push2(ssrRenderComponent(_component_a_col, { xs: 24, lg: 5, class: "mb-6 lg:mb-0" }, { default: withCtx((_2, _push3, _parent3, _scopeId2) => { if (_push3) { _push3(`
${ssrInterpolate(__props.config.title)}
`); ssrRenderList(__props.config.categories, (cat) => { _push3(`
${ssrInterpolate(cat.label)}
`); }); _push3(`
`); } else { return [ createVNode("div", { class: "category-sidebar" }, [ createVNode("div", { class: "category-sidebar-title" }, toDisplayString(__props.config.title), 1), (openBlock(true), createBlock(Fragment, null, renderList(__props.config.categories, (cat) => { return openBlock(), createBlock("div", { key: cat.type, class: ["category-item", { active: unref(activeType) === cat.type }], onClick: ($event) => selectType(cat.type) }, toDisplayString(cat.label), 11, ["onClick"]); }), 128)) ]) ]; } }), _: 1 }, _parent2, _scopeId)); _push2(ssrRenderComponent(_component_a_col, { xs: 24, lg: 19 }, { default: withCtx((_2, _push3, _parent3, _scopeId2) => { if (_push3) { _push3(`
${ssrInterpolate(unref(currentCategoryLabel))}共 ${ssrInterpolate(unref(total))} 篇文章
`); if (unref(loading)) { _push3(`
`); ssrRenderList(5, (i) => { _push3(ssrRenderComponent(_component_a_skeleton, { key: i, active: "", paragraph: { rows: 2 }, style: { "margin-bottom": "16px" } }, null, _parent3, _scopeId2)); }); _push3(`
`); } else { _push3(`
`); ssrRenderList(unref(articles), (article) => { _push3(`
`); if (article.image) { _push3(`
`); } else { _push3(``); } _push3(`

${ssrInterpolate(article.title)}

${ssrInterpolate(article.overview)}

`); }); _push3(`
`); if (unref(articles).length === 0) { _push3(`
`); _push3(ssrRenderComponent(_component_a_empty, { description: "暂无内容" }, null, _parent3, _scopeId2)); _push3(`
`); } else { _push3(``); } if (unref(total) > unref(pageSize)) { _push3(`
`); _push3(ssrRenderComponent(_component_a_pagination, { current: unref(currentPage), "onUpdate:current": ($event) => isRef(currentPage) ? currentPage.value = $event : null, total: unref(total), "page-size": unref(pageSize), "show-quick-jumper": "", onChange: handlePageChange }, null, _parent3, _scopeId2)); _push3(`
`); } else { _push3(``); } _push3(`
`); } } else { return [ createVNode("div", { class: "category-breadcrumb" }, [ createVNode("span", { class: "category-name" }, toDisplayString(unref(currentCategoryLabel)), 1), createVNode("span", { class: "article-count" }, "共 " + toDisplayString(unref(total)) + " 篇文章", 1) ]), unref(loading) ? (openBlock(), createBlock("div", { key: 0, class: "loading-state" }, [ (openBlock(), createBlock(Fragment, null, renderList(5, (i) => { return createVNode(_component_a_skeleton, { key: i, active: "", paragraph: { rows: 2 }, style: { "margin-bottom": "16px" } }); }), 64)) ])) : (openBlock(), createBlock("div", { key: 1 }, [ createVNode("div", { class: "article-list" }, [ (openBlock(true), createBlock(Fragment, null, renderList(unref(articles), (article) => { return openBlock(), createBlock("div", { key: article.id, class: "article-item", onClick: ($event) => handleView(article) }, [ article.image ? (openBlock(), createBlock("div", { key: 0, class: "article-thumb" }, [ createVNode("img", { src: article.image, alt: article.title }, null, 8, ["src", "alt"]) ])) : createCommentVNode("", true), createVNode("div", { class: "article-main" }, [ createVNode("h3", { class: "article-title" }, toDisplayString(article.title), 1), createVNode("p", { class: "article-overview" }, toDisplayString(article.overview), 1), createVNode("div", { class: "article-meta" }, [ article.type ? (openBlock(), createBlock("span", { key: 0, class: "meta-tag" }, toDisplayString(getCategoryLabel(article.type)), 1)) : createCommentVNode("", true), createVNode("span", { class: "meta-item" }, toDisplayString(article.source), 1), createVNode("span", { class: "meta-item" }, toDisplayString(article.publishTime), 1), article.views ? (openBlock(), createBlock("span", { key: 1, class: "meta-item" }, "👁 " + toDisplayString(article.views), 1)) : createCommentVNode("", true) ]) ]) ], 8, ["onClick"]); }), 128)) ]), unref(articles).length === 0 ? (openBlock(), createBlock("div", { key: 0, class: "empty-state" }, [ createVNode(_component_a_empty, { description: "暂无内容" }) ])) : createCommentVNode("", true), unref(total) > unref(pageSize) ? (openBlock(), createBlock("div", { key: 1, class: "pagination-wrap" }, [ createVNode(_component_a_pagination, { current: unref(currentPage), "onUpdate:current": ($event) => isRef(currentPage) ? currentPage.value = $event : null, total: unref(total), "page-size": unref(pageSize), "show-quick-jumper": "", onChange: handlePageChange }, null, 8, ["current", "onUpdate:current", "total", "page-size"]) ])) : createCommentVNode("", true) ])) ]; } }), _: 1 }, _parent2, _scopeId)); } else { return [ createVNode(_component_a_col, { xs: 24, lg: 5, class: "mb-6 lg:mb-0" }, { default: withCtx(() => [ createVNode("div", { class: "category-sidebar" }, [ createVNode("div", { class: "category-sidebar-title" }, toDisplayString(__props.config.title), 1), (openBlock(true), createBlock(Fragment, null, renderList(__props.config.categories, (cat) => { return openBlock(), createBlock("div", { key: cat.type, class: ["category-item", { active: unref(activeType) === cat.type }], onClick: ($event) => selectType(cat.type) }, toDisplayString(cat.label), 11, ["onClick"]); }), 128)) ]) ]), _: 1 }), createVNode(_component_a_col, { xs: 24, lg: 19 }, { default: withCtx(() => [ createVNode("div", { class: "category-breadcrumb" }, [ createVNode("span", { class: "category-name" }, toDisplayString(unref(currentCategoryLabel)), 1), createVNode("span", { class: "article-count" }, "共 " + toDisplayString(unref(total)) + " 篇文章", 1) ]), unref(loading) ? (openBlock(), createBlock("div", { key: 0, class: "loading-state" }, [ (openBlock(), createBlock(Fragment, null, renderList(5, (i) => { return createVNode(_component_a_skeleton, { key: i, active: "", paragraph: { rows: 2 }, style: { "margin-bottom": "16px" } }); }), 64)) ])) : (openBlock(), createBlock("div", { key: 1 }, [ createVNode("div", { class: "article-list" }, [ (openBlock(true), createBlock(Fragment, null, renderList(unref(articles), (article) => { return openBlock(), createBlock("div", { key: article.id, class: "article-item", onClick: ($event) => handleView(article) }, [ article.image ? (openBlock(), createBlock("div", { key: 0, class: "article-thumb" }, [ createVNode("img", { src: article.image, alt: article.title }, null, 8, ["src", "alt"]) ])) : createCommentVNode("", true), createVNode("div", { class: "article-main" }, [ createVNode("h3", { class: "article-title" }, toDisplayString(article.title), 1), createVNode("p", { class: "article-overview" }, toDisplayString(article.overview), 1), createVNode("div", { class: "article-meta" }, [ article.type ? (openBlock(), createBlock("span", { key: 0, class: "meta-tag" }, toDisplayString(getCategoryLabel(article.type)), 1)) : createCommentVNode("", true), createVNode("span", { class: "meta-item" }, toDisplayString(article.source), 1), createVNode("span", { class: "meta-item" }, toDisplayString(article.publishTime), 1), article.views ? (openBlock(), createBlock("span", { key: 1, class: "meta-item" }, "👁 " + toDisplayString(article.views), 1)) : createCommentVNode("", true) ]) ]) ], 8, ["onClick"]); }), 128)) ]), unref(articles).length === 0 ? (openBlock(), createBlock("div", { key: 0, class: "empty-state" }, [ createVNode(_component_a_empty, { description: "暂无内容" }) ])) : createCommentVNode("", true), unref(total) > unref(pageSize) ? (openBlock(), createBlock("div", { key: 1, class: "pagination-wrap" }, [ createVNode(_component_a_pagination, { current: unref(currentPage), "onUpdate:current": ($event) => isRef(currentPage) ? currentPage.value = $event : null, total: unref(total), "page-size": unref(pageSize), "show-quick-jumper": "", onChange: handlePageChange }, null, 8, ["current", "onUpdate:current", "total", "page-size"]) ])) : createCommentVNode("", true) ])) ]), _: 1 }) ]; } }), _: 1 }, _parent)); _push(`
`); }; } }); const _sfc_setup = _sfc_main.setup; _sfc_main.setup = (props, ctx) => { const ssrContext = useSSRContext(); (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/ArticleListPage.vue"); return _sfc_setup ? _sfc_setup(props, ctx) : void 0; }; const __nuxt_component_0 = /* @__PURE__ */ Object.assign(_export_sfc(_sfc_main, [["__scopeId", "data-v-adab0af3"]]), { __name: "ArticleListPage" }); export { __nuxt_component_0 as _ }; //# sourceMappingURL=ArticleListPage-Di4R26TI.mjs.map