update
This commit is contained in:
4
src/assets/css/bootstrap.css
vendored
4
src/assets/css/bootstrap.css
vendored
@ -287,10 +287,6 @@ textarea {
|
||||
font-size: inherit;
|
||||
line-height: inherit;
|
||||
}
|
||||
a {
|
||||
color: #1B242F;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:focus {
|
||||
outline: thin dotted;
|
||||
|
@ -15,12 +15,9 @@ const {data} = Astro.props;
|
||||
|
||||
<style>
|
||||
.breadcrumb {
|
||||
/* margin-left: 1rem; */
|
||||
/* margin-bottom: 1rem; */
|
||||
padding: 1rem;
|
||||
border-bottom: 1px solid #ebebeb;
|
||||
font-size: 1rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.breadcrumb a {
|
||||
|
@ -7,11 +7,10 @@ export interface Props {
|
||||
pageParam?: string; // 分页参数名,默认'page'
|
||||
}
|
||||
const { currentPage = 1, totalPages = 1, baseUrl = '', pageParam = 'page' } = Astro.props;
|
||||
|
||||
function getPageUrl(page: number) {
|
||||
// if (!baseUrl) return `?${pageParam}=${page}`;
|
||||
// 若baseUrl已带?,则拼接&,否则?
|
||||
return baseUrl + `${page}`;
|
||||
return baseUrl + `/page/${page}`;
|
||||
}
|
||||
|
||||
const showPages = [];
|
||||
@ -26,7 +25,6 @@ if (totalPages <= 7) {
|
||||
showPages.push(1, '...', currentPage - 1, currentPage, currentPage + 1, '...', totalPages);
|
||||
}
|
||||
}
|
||||
console.log(showPages)
|
||||
---
|
||||
<nav class="pagination">
|
||||
<ul>
|
||||
|
@ -3,7 +3,12 @@ import { getConfig } from '../../utils/config'
|
||||
import '../assets/css/bootstrap.css'
|
||||
import '../assets/css/theme-style.css'
|
||||
const config = getConfig(Astro)
|
||||
const {desc = '霍尔果斯飞驰广告传媒有限公司是一家充满活力和创新精神的互联网企业,专注于为客户提供卓越的数字化解决方案。我们秉承以客户为中心的理念,致力于通过创新技术和策略,助力企业实现数字化转型与品牌升级,共同开创更加美好的未来。', title = '霍尔果斯霍尔果斯飞驰广告传媒有限公司', keywords = '霍尔果斯霍尔果斯飞驰广告传媒有限公司'} = Astro.props
|
||||
const {
|
||||
desc = '霍尔果斯飞驰广告传媒有限公司是一家充满活力和创新精神的互联网企业,专注于为客户提供卓越的数字化解决方案。我们秉承以客户为中心的理念,致力于通过创新技术和策略,助力企业实现数字化转型与品牌升级,共同开创更加美好的未来。',
|
||||
title = '飞驰营销网',
|
||||
keywords = '霍尔果斯霍尔果斯飞驰广告传媒有限公司,霍尔果斯飞驰,飞驰营销网',
|
||||
bytedance = ''
|
||||
} = Astro.props
|
||||
---
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
@ -13,13 +18,14 @@ const {desc = '霍尔果斯飞驰广告传媒有限公司是一家充满活力
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
|
||||
<link rel="icon" href="/images/logo40_40.png" type="image/gif" />
|
||||
<title>{title}</title>
|
||||
<title>{`${title} | 飞驰营销网`}</title>
|
||||
<!-- site metas -->
|
||||
<meta name="keywords" content={keywords}>
|
||||
<meta name="description" content={desc}>
|
||||
<meta name="author" content="">
|
||||
<!-- fevicon -->
|
||||
{config.app_baidu_zhanzhang ? <Fragment set:html={config.app_baidu_zhanzhang} /> : ''}
|
||||
{bytedance ? <Fragment set:html={bytedance} /> : ''}
|
||||
<script is:inline src="/js/jquery.min.js"></script>
|
||||
<script is:inline type="text/javascript" src="/js/move-top.js"></script>
|
||||
<!-- <script is:inline type="text/javascript" src="/js/easing.js"></script> -->
|
||||
@ -94,20 +100,21 @@ const {desc = '霍尔果斯飞驰广告传媒有限公司是一家充满活力
|
||||
<p><span class="icon3"> </span><a href="javascript:void(0);" title="公司地址">新疆伊犁哈萨克自治州霍尔果斯市中哈国际边境合作中心B4地块东方劲秀展厅二层9012室</a></p><br />
|
||||
</div>
|
||||
<div class="clearfix"> </div>
|
||||
<div class="columns">
|
||||
<ul>
|
||||
<li><a title="关于我们" href='/about-us'>关于我们</a></li>
|
||||
<li><a title="资讯" href='/news'>资讯</a></li>
|
||||
<li><a title="我们的服务" href='/service'>我们的服务</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<div class="container">
|
||||
<div class="footer-right">
|
||||
<p> ©2025 新疆霍尔果斯飞驰广告传媒科技有限公司 版权所有 <a target="_blank" href="http://beian.miit.gov.cn/">新ICP备2025017329号-1</a></p>
|
||||
<div class="footer-container">
|
||||
<div class="copy-right">
|
||||
<p> ©2025 新疆霍尔果斯飞驰广告传媒科技有限公司 版权所有 <a target="_blank" href="http://beian.miit.gov.cn/">新ICP备2025017329号-1</a></p>
|
||||
</div>
|
||||
<div class="bottom-links">
|
||||
<span><a title="关于我们" href='/about'>关于我们</a></span>/
|
||||
<span><a title="资讯" href='/news'>资讯</a></span>/
|
||||
<span><a title="我们的服务" href='/service'>我们的服务</a></span>/
|
||||
<span><a title="网站地图" href='/sitemap.xml'>网站地图</a></span>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {-2
|
||||
$().UItoTop({ easingType: 'easeOutQuart' });
|
||||
@ -144,8 +151,7 @@ const {desc = '霍尔果斯飞驰广告传媒有限公司是一家充满活力
|
||||
var s = document.getElementsByTagName("script")[0];
|
||||
s.parentNode.insertBefore(hm, s);
|
||||
})();
|
||||
</script>
|
||||
|
||||
</script>
|
||||
</html>
|
||||
|
||||
<style>
|
||||
@ -160,19 +166,21 @@ const {desc = '霍尔果斯飞驰广告传媒有限公司是一家充满活力
|
||||
a {
|
||||
color:white;
|
||||
}
|
||||
|
||||
ul {
|
||||
display: flex;
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
ul>li>a {
|
||||
color:white;
|
||||
padding:0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.footer-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
color: white;
|
||||
|
||||
a {
|
||||
color: white;
|
||||
margin-left: 0.3rem;
|
||||
margin-right: 0.3rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<style is:global>
|
||||
|
||||
|
@ -2,8 +2,6 @@ import { getHost } from "../../utils/host";
|
||||
import { websiteConfig } from "../../utils/rpc";
|
||||
|
||||
export async function onRequest (context: any, next: any) {
|
||||
|
||||
console.log('middleware')
|
||||
// 拦截一个请求里的数据
|
||||
// 可选地修改 `locals` 中的属性
|
||||
const host = await getHost(context.request);
|
||||
|
68
src/pages/404.astro
Normal file
68
src/pages/404.astro
Normal file
@ -0,0 +1,68 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>404 - 飞驰营销</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="number">404</div>
|
||||
<div class="text">
|
||||
<span>糟糕!</span><br>页面走丢了</div>
|
||||
</body>
|
||||
</html>
|
||||
<style>
|
||||
body {
|
||||
display: -webkit-box;
|
||||
display: flex;
|
||||
-webkit-box-orient: horizontal;
|
||||
-webkit-box-direction: normal;
|
||||
flex-flow: row wrap;
|
||||
align-content: center;
|
||||
-webkit-box-pack: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
div {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.number {
|
||||
background: #fff;
|
||||
position: relative;
|
||||
font: 900 30vmin 'Consolas';
|
||||
letter-spacing: 5vmin;
|
||||
text-shadow: 2px -1px 0 #000, 4px -2px 0 #0a0a0a, 6px -3px 0 #0f0f0f, 8px -4px 0 #141414, 10px -5px 0 #1a1a1a, 12px -6px 0 #1f1f1f, 14px -7px 0 #242424, 16px -8px 0 #292929;
|
||||
}
|
||||
.number::before {
|
||||
background-color: #673ab7;
|
||||
background-image: radial-gradient(closest-side at 50% 50%, #ffc107 100%, rgba(0, 0, 0, 0)), radial-gradient(closest-side at 50% 50%, #e91e63 100%, rgba(0, 0, 0, 0));
|
||||
background-repeat: repeat-x;
|
||||
background-size: 40vmin 40vmin;
|
||||
background-position: -100vmin 20vmin, 100vmin -25vmin;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
mix-blend-mode: screen;
|
||||
-webkit-animation: moving 10s linear infinite both;
|
||||
animation: moving 10s linear infinite both;
|
||||
display: block;
|
||||
position: absolute;
|
||||
content: "";
|
||||
}
|
||||
@-webkit-keyframes moving {
|
||||
to {
|
||||
background-position: 100vmin 20vmin, -100vmin -25vmin;
|
||||
}
|
||||
}
|
||||
@keyframes moving {
|
||||
to {
|
||||
background-position: 100vmin 20vmin, -100vmin -25vmin;
|
||||
}
|
||||
}
|
||||
.text {
|
||||
font: 400 5vmin "Courgette";
|
||||
}
|
||||
.text span {
|
||||
font-size: 10vmin;
|
||||
}
|
||||
</style>
|
@ -1,4 +1,10 @@
|
||||
---
|
||||
export interface Props {
|
||||
page: number;
|
||||
columnDesc: string;
|
||||
breadcrumb: [];
|
||||
filter: []
|
||||
}
|
||||
import Layout from "../layouts/Layout.astro";
|
||||
import { getConfig } from "../../utils/config";
|
||||
import "../assets/css1/style.css";
|
||||
@ -13,15 +19,22 @@ const config = getConfig(Astro);
|
||||
const limit = 10;
|
||||
|
||||
// 页码
|
||||
const { page = 1, columnDesc = `霍尔果斯飞驰广告有限公司致力于分享从基础到进阶的SEO优化策略、广告投放方法、内容运营技巧和网站转化率提升方案。` ,breadcrumb = [{ title: "资讯", link: "/news" }] } = Astro.props;
|
||||
const { code, data, total = 0, hot } = await newsIndex(config.id, limit, page);
|
||||
|
||||
if (!data || code !== 0) {
|
||||
const {
|
||||
page = Astro.locals?.column_page || 1, // 页码
|
||||
columnDesc = Astro.locals?.column_data?.desc || `霍尔果斯飞驰广告有限公司致力于分享从基础到进阶的SEO优化策略、广告投放方法、内容运营技巧和网站转化率提升方案。` ,
|
||||
breadcrumb = Astro.locals?.column_data?.item || [{ title: "资讯", link: "/news" }], // 面包屑导航
|
||||
filter = Astro.locals?.column_data?.filter || [], // 面包屑导航
|
||||
} = Astro.props;
|
||||
const { code, data, total = 0, hot } = await newsIndex(config.id, limit, page, filter);
|
||||
if (data.length == 0 || code !== 0) {
|
||||
return Astro.redirect("/404");
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
<Layout>
|
||||
<Layout
|
||||
title={(breadcrumb.at(-1)?.title || '新闻') + `_即时播报`}
|
||||
>
|
||||
<main class="site-content">
|
||||
<!-- Blog Grid Section Start Here -->
|
||||
<div class="blog-page">
|
||||
@ -40,7 +53,7 @@ if (!data || code !== 0) {
|
||||
</div>
|
||||
<div class="news-list-row">
|
||||
{
|
||||
data?.map((e) => {
|
||||
data?.map((e, index) => {
|
||||
return (
|
||||
<div class="">
|
||||
<div class="post-inner news-card">
|
||||
@ -51,7 +64,7 @@ if (!data || code !== 0) {
|
||||
title={`${e.title}`}
|
||||
>
|
||||
<Image
|
||||
loading="lazy"
|
||||
loading={index > 2 ? 'lazy' : 'eager'}
|
||||
style={`aspect-ratio: 4 / 3;object-fit: cover;`}
|
||||
src={e.cover}
|
||||
alt={e.title}
|
||||
@ -85,7 +98,8 @@ if (!data || code !== 0) {
|
||||
{e.description}
|
||||
</p>
|
||||
<div>
|
||||
<a href={e.column_tag_url}><span class="label label-success">{e.column_tag}</span></a>
|
||||
{e.column_tag ? <a href={e.column_tag_url}><span class="label label-success">{e.column_tag}</span></a> : ''}
|
||||
{e.second_column_tag ? <a href={e.second_column_tag_url}><span class="label label-info">{e.second_column_tag}</span></a> : ''}
|
||||
{/* <a href={e.column_tag_url}><span class="label label-info">{e.column_tag}</span></a> */}
|
||||
</div>
|
||||
</div>
|
||||
@ -98,7 +112,7 @@ if (!data || code !== 0) {
|
||||
<PaginationComponent
|
||||
totalPages={Number(total)}
|
||||
currentPage={Number(page)}
|
||||
baseUrl={`/news/page/`}
|
||||
baseUrl={Astro.locals.column_base_uri || '/news'}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -116,6 +130,7 @@ if (!data || code !== 0) {
|
||||
title={item.title}
|
||||
>
|
||||
<Image
|
||||
loading="eager"
|
||||
src={item.cover}
|
||||
alt={item.title}
|
||||
height={100}
|
||||
@ -132,7 +147,7 @@ if (!data || code !== 0) {
|
||||
{item.title}
|
||||
</a>
|
||||
</h4>
|
||||
<span class="info">2025-02-27</span>
|
||||
<span class="info">{item.created_at}</span>
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
|
@ -1,26 +1,61 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
import { getConfig } from "../../../utils/config";
|
||||
import { newsDetail } from "../../../utils/rpc";
|
||||
import { newsDetail, columns as getColumns } from "../../../utils/rpc";
|
||||
import Breadcrumb from "../../components/Breadcrumb.astro";
|
||||
import { formatDate } from "../../../utils/date";
|
||||
const { slug } = Astro.params;
|
||||
const config = getConfig(Astro);
|
||||
const requestUrl = Astro.request.url;
|
||||
const breadcrumb = [{title: '资讯', link: '/news'},{title: '教程', link: '/news/tech'}, {title: '正文', link: ''}]
|
||||
if (!slug) {
|
||||
return Astro.redirect("/404");
|
||||
let requestUri = Astro.originPathname
|
||||
let page = 1;
|
||||
var breadcrumb = [{title: '资讯', link: '/news'},{title: '教程经验', link: '/news/tech'}, {title: '正文', link: ''}]
|
||||
|
||||
//---------------------------------栏目rewrite-------------------------------------
|
||||
// 定义正则表达式来匹配分页路径:/news/tech/page/{number}
|
||||
const regex = /^(\/news\/.+)\/page\/(\d+)$/;
|
||||
const match = requestUri.match(regex);
|
||||
// 如果发现分页了, uri 就移除掉分页参数, 并且做rewrite
|
||||
if (match && match[1]) {
|
||||
requestUri = match[1]
|
||||
page = Number(match[2])
|
||||
}
|
||||
|
||||
const { code, data } = await newsDetail(slug, config);
|
||||
if (!data || code !== 0) {
|
||||
return Astro.redirect("/404");
|
||||
// 如果请求的是栏目跳转到news, 如果请求的是页面 则渲染。后期可以考虑用nginx转发
|
||||
const col = await getColumns(config.id)
|
||||
const columns = col.data
|
||||
|
||||
const currentRequestPath = requestUri
|
||||
const val = columns?.find(data => data.path === currentRequestPath);
|
||||
if (val) {
|
||||
Astro.locals.column_data = val // 当前栏目数据
|
||||
Astro.locals.column_base_uri = requestUri // 当前去除掉页码信息的baseUri
|
||||
Astro.locals.column_page = page// 页码数据
|
||||
return Astro.rewrite(`/news`);
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
if (!slug) {
|
||||
return Astro.rewrite("/404");
|
||||
}
|
||||
|
||||
var { code, data } = await newsDetail(slug, config);
|
||||
if (!data || code !== 0) {
|
||||
return Astro.rewrite("/404");
|
||||
}
|
||||
|
||||
const bytedanceData = formatDate(data.created_at)
|
||||
|
||||
---
|
||||
<Layout
|
||||
desc={data.description}
|
||||
keywords={data.keywords}
|
||||
title={`${data.title} - ${config.app_name}`}
|
||||
bytedance={`
|
||||
<meta property="bytedance:published_time" content="${bytedanceData}" />
|
||||
<meta property="bytedance:lrDate_time" content="${bytedanceData}" />
|
||||
<meta property="bytedance:updated_time" content="${bytedanceData}" />
|
||||
`}
|
||||
>
|
||||
<div class="v4 header-placeholder nav-v2" id="header-placeholder"></div>
|
||||
<div class="html-text-component parbase">
|
||||
@ -32,7 +67,6 @@ if (!data || code !== 0) {
|
||||
<div class="product-tabs-wrap container">
|
||||
<div class="product-tabs__heading">
|
||||
<div class="product-tabs__title body-medium">
|
||||
<!-- <a title={TP2_COLUMN_NEWS} href={TP2_COLUMN_NEWS_URL} class="product-link product-link__active">{TP2_COLUMN_NEWS}</a> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -43,10 +77,11 @@ if (!data || code !== 0) {
|
||||
<Breadcrumb data={breadcrumb} />
|
||||
<header>
|
||||
<h1 class="title" title={data.title}>{data.title}</h1>
|
||||
<span>{data.created_at}</span>
|
||||
<a href={data.column_tag_url}
|
||||
><span class="label label-success">{data.column_tag}</span></a
|
||||
>
|
||||
<div class="meta">
|
||||
<span class="meta-pub">{data.created_at}</span>
|
||||
<a href={data.column_tag_url}><span>{data.column_tag}</span></a>
|
||||
<a href={data.second_column_url}><span>{data.second_column}</span></a>
|
||||
</div>
|
||||
</header>
|
||||
<article class="news-detail-content">
|
||||
<div class="top-icon"></div>
|
||||
@ -242,6 +277,10 @@ if (!data || code !== 0) {
|
||||
border-bottom: none !important;
|
||||
padding: unset !important;
|
||||
font-weight: unset;
|
||||
a {
|
||||
color: #999 !important;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
header > h1 {
|
||||
@ -249,6 +288,17 @@ if (!data || code !== 0) {
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
|
||||
.meta {
|
||||
span {
|
||||
font-size: 14px;
|
||||
color: #a4a4a4;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.related-news > h3:after {
|
||||
content: "";
|
||||
width: 70px;
|
||||
|
14
src/pages/news/columns/[...page].astro
Normal file
14
src/pages/news/columns/[...page].astro
Normal file
@ -0,0 +1,14 @@
|
||||
---
|
||||
import News from '../../news.astro'
|
||||
const {page = 1} = Astro.params;
|
||||
const columnData = Astro.locals.column_data
|
||||
if (!columnData) {
|
||||
return Astro.redirect('/404')
|
||||
}
|
||||
---
|
||||
<News
|
||||
page = {page}
|
||||
breadcrumb = {Astro.locals.column_data.item}
|
||||
columnDesc = {Astro.locals.column_data.desc}
|
||||
baseUri = {Astro.locals.column_base_uri || ''}
|
||||
>
|
@ -1,7 +0,0 @@
|
||||
---
|
||||
import News from '../../news.astro'
|
||||
const {page = 1} = Astro.params;
|
||||
const breadcrumb = [{title: '资讯', link: '/news'}, {title: '教程', link: '/news/tech'}]
|
||||
const columnDesc = '精选覆盖SEO优化、数字广告投放、网站转化率提升等多个方向的实用教程,帮助企业在2025年抓住数字营销红利。由霍尔果斯飞驰广告有限公司多年的实战经验总结,适用于各类企业与网站运营者。'
|
||||
---
|
||||
<News page = {page} breadcrumb = {breadcrumb} columnDesc = {columnDesc}>
|
43
src/types/astro.d.ts
vendored
Normal file
43
src/types/astro.d.ts
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// src/types/astro.d.ts
|
||||
// import 'astro';
|
||||
|
||||
import type { z } from 'zod';
|
||||
import type { ActionAccept, ActionClient, ActionReturnType } from '../../actions/runtime/virtual/server.js';
|
||||
import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from '../../core/constants.js';
|
||||
import type { AstroCookies } from '../../core/cookies/cookies.js';
|
||||
import type { CspDirective, CspHash } from '../../core/csp/config.js';
|
||||
import type { AstroSession } from '../../core/session.js';
|
||||
import type { AstroComponentFactory } from '../../runtime/server/index.js';
|
||||
import type { Params, RewritePayload } from './common.js';
|
||||
import type { ValidRedirectStatus } from './config.js';
|
||||
import type { AstroInstance, MarkdownInstance, MDXInstance } from './content.js';
|
||||
|
||||
|
||||
declare module 'astro' {
|
||||
|
||||
export interface AstroSharedContext<Props extends Record<string, any> = Record<string, any>, RouteParams extends Record<string, string | undefined> = Record<string, string | undefined>> {
|
||||
|
||||
/**
|
||||
* Object accessed via Astro middleware
|
||||
*/
|
||||
locals: {
|
||||
column_data?: {
|
||||
desc?: string;
|
||||
// 你可以继续补充
|
||||
};
|
||||
column_base_uri?: string;
|
||||
column_page?: number;
|
||||
custom?: number;
|
||||
// 你还可以加其它自定义属性
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// // src/types/astro.d.ts
|
||||
// declare module "astro" {
|
||||
// interface AstroLocals {
|
||||
// customProp: string;
|
||||
// anotherProp: number;
|
||||
// }
|
||||
// }
|
@ -1,7 +1,7 @@
|
||||
export const column = [
|
||||
{
|
||||
sign: 'seo_tech',
|
||||
title: 'SEO教程',
|
||||
title: 'SEO教程经验',
|
||||
desc: '霍尔果斯飞驰广告有限公司不仅帮助多个企业实现了品牌曝光和流量增长,也在SEO优化过程中积累了宝贵的经验和教训。我们相信,随着SEO策略的不断发展和优化,未来的网络营销将更加精细化、智能化。'
|
||||
}
|
||||
]
|
22
utils/date.ts
Normal file
22
utils/date.ts
Normal file
@ -0,0 +1,22 @@
|
||||
export function formatDate(dateStr:string) {
|
||||
const date = new Date(dateStr);
|
||||
|
||||
if (isNaN(date)) return 'Invalid Date';
|
||||
|
||||
// 本地时间组件
|
||||
const pad = n => String(n).padStart(2, '0');
|
||||
const year = date.getFullYear();
|
||||
const month = pad(date.getMonth() + 1);
|
||||
const day = pad(date.getDate());
|
||||
const hours = pad(date.getHours());
|
||||
const minutes = pad(date.getMinutes());
|
||||
const seconds = pad(date.getSeconds());
|
||||
|
||||
// 获取本地偏移量(分钟),转换为 +08:00 格式
|
||||
const timezoneOffset = -date.getTimezoneOffset(); // 反向处理
|
||||
const offsetHours = pad(Math.floor(Math.abs(timezoneOffset) / 60));
|
||||
const offsetMinutes = pad(Math.abs(timezoneOffset) % 60);
|
||||
const offsetSign = timezoneOffset >= 0 ? '+' : '-';
|
||||
|
||||
return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}${offsetSign}${offsetHours}:${offsetMinutes}`;
|
||||
}
|
40
utils/rpc.ts
40
utils/rpc.ts
@ -10,11 +10,6 @@ interface result<T> {
|
||||
data : T
|
||||
}
|
||||
|
||||
interface data<T> {
|
||||
page_title: string
|
||||
page_module: T
|
||||
}
|
||||
|
||||
function getRpcClient() {
|
||||
|
||||
return new JsonRpcClient(import.meta.env.RPC_REMOTE, import.meta.env.RPC_PORT)
|
||||
@ -32,13 +27,27 @@ export interface InewsIndex {
|
||||
updated_at: string
|
||||
column_tag: string
|
||||
column_tag_url: string
|
||||
second_column_tag: string
|
||||
second_column_tag_url: string
|
||||
}
|
||||
export async function newsIndex(websiteId:number = 0, limit:number = 10, page:number = 1):Promise<result<InewsIndex[]>>{
|
||||
export async function newsIndex(websiteId:number = 0, limit:number = 10, page:number = 1, filter = []):Promise<{
|
||||
code : number
|
||||
message : string
|
||||
data : InewsIndex[]
|
||||
total: number
|
||||
hot: {
|
||||
cover: string
|
||||
id: string
|
||||
title: string
|
||||
created_at: string
|
||||
}[]
|
||||
}>{
|
||||
const client = getRpcClient()
|
||||
const result = await client.call('news/index', {
|
||||
id:websiteId,
|
||||
limit: limit,
|
||||
page: page
|
||||
page: page,
|
||||
filter: filter
|
||||
})
|
||||
|
||||
return result
|
||||
@ -56,6 +65,8 @@ export interface InewsDetail {
|
||||
updated_at: string
|
||||
column_tag: string
|
||||
column_tag_url: string
|
||||
second_column: string
|
||||
second_column_url: string
|
||||
about: {
|
||||
id: number
|
||||
title: string
|
||||
@ -103,3 +114,18 @@ export async function websiteConfig(host:string):Promise<result<IWebsiteConfig>>
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
export interface Icolumns {
|
||||
id: number
|
||||
title: string
|
||||
link: string
|
||||
desc:string
|
||||
}
|
||||
export async function columns(id: number):Promise<result<Icolumns>>{
|
||||
const client = getRpcClient()
|
||||
const result = await client.call('column/index', {
|
||||
app_id:id,
|
||||
})
|
||||
return result
|
||||
}
|
Reference in New Issue
Block a user