优化✅
This commit is contained in:
parent
de9280d9e7
commit
60f5296dcb
@ -42,12 +42,14 @@ import "../styles/components/Aside.less";
|
|||||||
<h3>分类</h3>
|
<h3>分类</h3>
|
||||||
<div class="vh-aside-categories">
|
<div class="vh-aside-categories">
|
||||||
{
|
{
|
||||||
categories.map(i => (
|
categories
|
||||||
<a href={`/categories/${i.title}`}>
|
.sort((a: any, b: any) => b.count - a.count)
|
||||||
<span>{i.title}</span>
|
.map(i => (
|
||||||
<i>{i.count}</i>
|
<a href={`/categories/${i.title}`}>
|
||||||
</a>
|
<span>{i.title}</span>
|
||||||
))
|
<i>{i.count}</i>
|
||||||
|
</a>
|
||||||
|
))
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@ -110,6 +110,15 @@ section.article-list {
|
|||||||
/* 默认渐变色结束 */
|
/* 默认渐变色结束 */
|
||||||
--gradient-color-3: #66ff99;
|
--gradient-color-3: #66ff99;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.vh-categories-Share {
|
||||||
|
/* 默认渐变色起始 */
|
||||||
|
--gradient-color-1: rgb(240, 45, 133);
|
||||||
|
/* 默认渐变色中间 */
|
||||||
|
--gradient-color-2: #f95ba5;
|
||||||
|
/* 默认渐变色结束 */
|
||||||
|
--gradient-color-3: #f4bdd0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&>.title {
|
&>.title {
|
||||||
|
|||||||
@ -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 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 fmtDate = (time: string | Date) => {
|
||||||
const now = dayjs();
|
const now = dayjs();
|
||||||
@ -81,13 +81,8 @@ const LoadStyle = (href: string): Promise<HTMLLinkElement> => {
|
|||||||
// 请求封装
|
// 请求封装
|
||||||
const $GET = async (url: string, headers: Record<string, string> = {}): Promise<any> => {
|
const $GET = async (url: string, headers: Record<string, string> = {}): Promise<any> => {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(url, {
|
const res = await fetch(url, { method: "GET", headers: headers, });
|
||||||
method: "GET",
|
if (!res.ok) throw new Error(`HTTP error! Status: ${res.status}`);
|
||||||
headers: headers,
|
|
||||||
});
|
|
||||||
if (!res.ok) {
|
|
||||||
throw new Error(`HTTP error! Status: ${res.status}`);
|
|
||||||
}
|
|
||||||
return res.json();
|
return res.json();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("GET request failed:", error);
|
console.error("GET request failed:", error);
|
||||||
@ -97,14 +92,8 @@ const $GET = async (url: string, headers: Record<string, string> = {}): Promise<
|
|||||||
|
|
||||||
const $POST = async (url: string, data: Record<string, any>, headers: Record<string, string> = {}): Promise<any> => {
|
const $POST = async (url: string, data: Record<string, any>, headers: Record<string, string> = {}): Promise<any> => {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(url, {
|
const res = await fetch(url, { method: "POST", headers: { ...headers, }, body: JSON.stringify(data), });
|
||||||
method: "POST",
|
if (!res.ok) throw new Error(`HTTP error! Status: ${res.status}`);
|
||||||
headers: { ...headers, },
|
|
||||||
body: JSON.stringify(data),
|
|
||||||
});
|
|
||||||
if (!res.ok) {
|
|
||||||
throw new Error(`HTTP error! Status: ${res.status}`);
|
|
||||||
}
|
|
||||||
return res.json(); // 解析 JSON 数据
|
return res.json(); // 解析 JSON 数据
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("POST request failed:", error);
|
console.error("POST request failed:", error);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user