generated from liutk/owl-admin-base
120 lines
7.1 KiB
JavaScript
120 lines
7.1 KiB
JavaScript
import { _ as __nuxt_component_0 } from './HeaderImage-92nFA80c.mjs';
|
|
import { defineComponent, computed, withAsyncContext, mergeProps, unref, useSSRContext } from 'vue';
|
|
import { ssrRenderAttrs, ssrRenderComponent, ssrRenderList, ssrRenderAttr, ssrInterpolate, ssrRenderClass } from 'vue/server-renderer';
|
|
import { u as useRequest } from './useRequest-pSRZvR3u.mjs';
|
|
import { b as useRouter, u as useRoute, n as navigateTo } from './server.mjs';
|
|
import { u as useAsyncData } from './asyncData-D5wEK86T.mjs';
|
|
import '../nitro/nitro.mjs';
|
|
import 'node:http';
|
|
import 'node:https';
|
|
import 'node:events';
|
|
import 'node:buffer';
|
|
import 'node:fs';
|
|
import 'node:path';
|
|
import 'node:crypto';
|
|
import 'node:url';
|
|
import '../routes/renderer.mjs';
|
|
import 'vue-bundle-renderer/runtime';
|
|
import 'unhead/server';
|
|
import 'devalue';
|
|
import 'unhead/plugins';
|
|
import 'unhead/utils';
|
|
import 'vue-router';
|
|
import 'axios';
|
|
import 'perfect-debounce';
|
|
|
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
__name: "index",
|
|
__ssrInlineRender: true,
|
|
async setup(__props) {
|
|
let __temp, __restore;
|
|
useRouter();
|
|
const route = useRoute();
|
|
const request = useRequest();
|
|
const page = computed({
|
|
get: () => Number(route.query.page) || 1,
|
|
set: (v) => navigateTo({ query: { ...route.query, page: v === 1 ? void 0 : v } })
|
|
});
|
|
const { data: newsRes } = ([__temp, __restore] = withAsyncContext(async () => useAsyncData(
|
|
() => `news-page-${page.value}`,
|
|
async () => await request.get("/api/news", {
|
|
params: { page: page.value }
|
|
}),
|
|
{ watch: [page] }
|
|
)), __temp = await __temp, __restore(), __temp);
|
|
const news = computed(() => {
|
|
const res = newsRes.value;
|
|
return res?.code === 200 && Array.isArray(res.data) ? res.data : [];
|
|
});
|
|
const meta = computed(() => {
|
|
const res = newsRes.value;
|
|
return res?.meta ?? {
|
|
current_page: 1,
|
|
last_page: 1,
|
|
per_page: 20,
|
|
total: 0
|
|
};
|
|
});
|
|
const pageNumbers = computed(() => {
|
|
const cur = meta.value.current_page;
|
|
const last = meta.value.last_page;
|
|
if (last <= 7) return Array.from({ length: last }, (_, i) => i + 1);
|
|
const list = [];
|
|
if (cur <= 3) {
|
|
list.push(1, 2, 3, 4, -1, last);
|
|
} else if (cur >= last - 2) {
|
|
list.push(1, -1, last - 3, last - 2, last - 1, last);
|
|
} else {
|
|
list.push(1, -1, cur - 1, cur, cur + 1, -1, last);
|
|
}
|
|
return list;
|
|
});
|
|
function formatDate(str) {
|
|
if (!str) return "";
|
|
const d = str.split(" ")[0];
|
|
return d || str;
|
|
}
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
const _component_HeaderImage = __nuxt_component_0;
|
|
_push(`<div${ssrRenderAttrs(mergeProps({ class: "w-full" }, _attrs))}>`);
|
|
_push(ssrRenderComponent(_component_HeaderImage, {
|
|
title: "企业资讯",
|
|
img: "/images/企业资讯/企业资讯.png"
|
|
}, null, _parent));
|
|
_push(`<div class="w-full pb-[24px] sm:pb-[32px] md:pb-[40px] lg:pb-[48px] xl:pb-[56px]"><div class="layout !px-0 sm:mt-[28px] sm:mb-[29px] mt-[36px] mb-[60px]"><div class="flex flex-col w-full"><!--[-->`);
|
|
ssrRenderList(unref(news), (newInfo) => {
|
|
_push(`<div class="w-full cursor-pointer group bg-[#FFFFFF] hover:bg-[#F5F5F5] transition-colors duration-300"><div class="flex flex-row px-[16px] sm:px-[20px] md:px-[24px] lg:px-[40px] xl:px-[52px] py-[16px] sm:py-[20px] md:py-[22px] lg:py-[26px] xl:py-[30px]"><div class="w-[126px] h-[104px] sm:w-[160px] sm:h-[120px] md:w-[220px] md:h-[150px] lg:w-[340px] lg:h-[214px] xl:w-[370px] xl:h-[228px] flex-shrink-0"><img class="object-cover w-full h-full"${ssrRenderAttr("src", newInfo.cover)}${ssrRenderAttr("alt", newInfo.title)}></div><div class="flex flex-col flex-1 items-start justify-between sm:justify-start gap-y-[0px] sm:gap-y-[15px] ml-[10px] sm:ml-[10px] md:ml-[20px] lg:ml-[30px] xl:ml-[60px]"><span class="line-clamp-2 break-words text-[15px] sm:text-[18px] md:text-[20px] lg:text-[22px] xl:text-[24px] text-[#333333] group-hover:text-[#2E75B5] font-bold leading-snug">${ssrInterpolate(newInfo.title)}</span><span class="text-[10px] sm:text-[14px] md:text-[16px] lg:text-[18px] xl:text-[18px] text-[#666666]">${ssrInterpolate(formatDate(newInfo.published_at))}</span><p class="line-clamp-2 text-[12px] sm:text-[14px] md:text-[16px] lg:text-[18px] xl:text-[18px] text-[#666666]">${ssrInterpolate(newInfo.description)}</p></div><div class="items-center hidden sm:ml-[15px] md:flex"><div class="w-[56px] h-[56px] group-hover:bg-[url('/images/企业资讯/选中.png')] bg-[url('/images/企业资讯/未选中.png')] bg-no-repeat bg-center bg-cover"></div></div></div></div>`);
|
|
});
|
|
_push(`<!--]-->`);
|
|
if (unref(meta).last_page > 1) {
|
|
_push(`<nav class="hidden sm:flex mt-[16px] items-center justify-center space-x-[6px] md:space-x-[8px]" aria-label="分页"><a href="#" class="${ssrRenderClass([{ "opacity-50 pointer-events-none": unref(meta).current_page <= 1 }, "flex items-center justify-center w-[32px] h-[32px] md:w-[36px] md:h-[36px] border border-gray-300 text-gray-500 hover:bg-gray-100 transition-colors text-[10px] md:text-[12px] disabled:opacity-50 disabled:pointer-events-none"])}"><span class="sr-only">上一页</span><svg class="w-3 h-3 md:w-4 md:h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path></svg></a><!--[-->`);
|
|
ssrRenderList(unref(pageNumbers), (p) => {
|
|
_push(`<!--[-->`);
|
|
if (p === -1) {
|
|
_push(`<span class="flex items-center justify-center w-[32px] h-[32px] md:w-[36px] md:h-[36px] text-gray-500 text-[10px] md:text-[12px]"> … </span>`);
|
|
} else {
|
|
_push(`<a href="#" class="${ssrRenderClass([
|
|
p === unref(meta).current_page ? "border-blue-600 bg-blue-600 text-white font-medium" : "border-gray-300 text-gray-600 hover:bg-gray-100",
|
|
"flex items-center justify-center w-[32px] h-[32px] md:w-[36px] md:h-[36px] border transition-colors text-[10px] md:text-[12px]"
|
|
])}">${ssrInterpolate(p)}</a>`);
|
|
}
|
|
_push(`<!--]-->`);
|
|
});
|
|
_push(`<!--]--><a href="#" class="${ssrRenderClass([{ "opacity-50 pointer-events-none": unref(meta).current_page >= unref(meta).last_page }, "flex items-center justify-center w-[32px] h-[32px] md:w-[36px] md:h-[36px] border border-gray-300 text-gray-500 hover:bg-gray-100 transition-colors text-[10px] md:text-[12px]"])}"><span class="sr-only">下一页</span><svg class="w-3 h-3 md:w-4 md:h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path></svg></a></nav>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</div></div></div></div>`);
|
|
};
|
|
}
|
|
});
|
|
const _sfc_setup = _sfc_main.setup;
|
|
_sfc_main.setup = (props, ctx) => {
|
|
const ssrContext = useSSRContext();
|
|
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/news/index.vue");
|
|
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
|
|
};
|
|
|
|
export { _sfc_main as default };
|
|
//# sourceMappingURL=index-BIJrlrSw.mjs.map
|