优化✅
This commit is contained in:
parent
de9280d9e7
commit
60f5296dcb
@ -42,12 +42,14 @@ import "../styles/components/Aside.less";
|
||||
<h3>分类</h3>
|
||||
<div class="vh-aside-categories">
|
||||
{
|
||||
categories.map(i => (
|
||||
<a href={`/categories/${i.title}`}>
|
||||
<span>{i.title}</span>
|
||||
<i>{i.count}</i>
|
||||
</a>
|
||||
))
|
||||
categories
|
||||
.sort((a: any, b: any) => b.count - a.count)
|
||||
.map(i => (
|
||||
<a href={`/categories/${i.title}`}>
|
||||
<span>{i.title}</span>
|
||||
<i>{i.count}</i>
|
||||
</a>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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<HTMLLinkElement> => {
|
||||
// 请求封装
|
||||
const $GET = async (url: string, headers: Record<string, string> = {}): Promise<any> => {
|
||||
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<string, string> = {}): Promise<
|
||||
|
||||
const $POST = async (url: string, data: Record<string, any>, headers: Record<string, string> = {}): Promise<any> => {
|
||||
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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user