diff --git a/src/components/Aside.astro b/src/components/Aside.astro index db7816f..1107ff7 100644 --- a/src/components/Aside.astro +++ b/src/components/Aside.astro @@ -42,12 +42,14 @@ import "../styles/components/Aside.less";

分类

{ - categories.map(i => ( - - {i.title} - {i.count} - - )) + categories + .sort((a: any, b: any) => b.count - a.count) + .map(i => ( + + {i.title} + {i.count} + + )) }
diff --git a/src/styles/components/ArticleCard.less b/src/styles/components/ArticleCard.less index 5ca24c3..02bbe9e 100644 --- a/src/styles/components/ArticleCard.less +++ b/src/styles/components/ArticleCard.less @@ -110,6 +110,15 @@ section.article-list { /* 默认渐变色结束 */ --gradient-color-3: #66ff99; } + + &.vh-categories-Share { + /* 默认渐变色起始 */ + --gradient-color-1: rgb(240, 45, 133); + /* 默认渐变色中间 */ + --gradient-color-2: #f95ba5; + /* 默认渐变色结束 */ + --gradient-color-3: #f4bdd0; + } } &>.title { diff --git a/src/utils/index.ts b/src/utils/index.ts index aa22639..736c427 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -9,7 +9,7 @@ dayjs.locale('zh-cn'); // 获取文章的描述 const getDescription = (post: any, num: number = 150) => (post.rendered ? post.rendered.html.replace(/<[^>]+>/g, "").replace(/\s+/g, "") : post.body.replace(/\n/g, "").replace(/#/g, "")).slice(0, num) || '暂无简介' //处理时间 -const fmtTime = (time: any, fmt: string = 'MMMM D, YYYY') => dayjs(time).tz('America/New_York').format(fmt) +const fmtTime = (time: any, fmt: string = 'MMMM D, YYYY') => dayjs(time).utc().format(fmt) // 处理日期 const fmtDate = (time: string | Date) => { const now = dayjs(); @@ -81,13 +81,8 @@ const LoadStyle = (href: string): Promise => { // 请求封装 const $GET = async (url: string, headers: Record = {}): Promise => { try { - const res = await fetch(url, { - method: "GET", - headers: headers, - }); - if (!res.ok) { - throw new Error(`HTTP error! Status: ${res.status}`); - } + const res = await fetch(url, { method: "GET", headers: headers, }); + if (!res.ok) throw new Error(`HTTP error! Status: ${res.status}`); return res.json(); } catch (error) { console.error("GET request failed:", error); @@ -97,14 +92,8 @@ const $GET = async (url: string, headers: Record = {}): Promise< const $POST = async (url: string, data: Record, headers: Record = {}): Promise => { try { - const res = await fetch(url, { - method: "POST", - headers: { ...headers, }, - body: JSON.stringify(data), - }); - if (!res.ok) { - throw new Error(`HTTP error! Status: ${res.status}`); - } + const res = await fetch(url, { method: "POST", headers: { ...headers, }, body: JSON.stringify(data), }); + if (!res.ok) throw new Error(`HTTP error! Status: ${res.status}`); return res.json(); // 解析 JSON 数据 } catch (error) { console.error("POST request failed:", error);