修复若干问题

This commit is contained in:
zqlit committed 2026-05-21 13:35:18 +08:00
1 parent 013dce4f9f
commit d9b7026d21
12 files changed
+581 -40

No files matched your search

+12
View File
@@ -163,3 +163,15 @@ export async function createComment(data: {
export async function deleteComment(id: number): Promise<void> {
await artalkMutate<void>(`/api/v2/comments/${id}`, "DELETE", { site_name: ARTALK_SITE });
}
export async function updatePage(
id: number,
data: { key: string; title: string; admin_only?: boolean }
): Promise<ArtalkPage> {
return artalkMutate<ArtalkPage>(`/api/v2/pages/${id}`, "PUT", {
key: data.key,
title: data.title,
admin_only: data.admin_only ?? false,
site_name: ARTALK_SITE,
});
}
+1 -1
View File
@@ -10,7 +10,7 @@ export const ARTALK_SITE = "优世界";
export const ITEMS_PER_PAGE = 20;
export const RECYCLE_DAYS = 30;
export const HUGO_PREVIEW = "http://localhost:1313";
export const RSS_API_BASE = process.env.RSS_API_BASE || "https://rssapi.usj.cc";
export const RSS_API_BASE = process.env.RSS_API_BASE || "https://api.usj.cc";
export const RSS_API_TOKEN = process.env.RSS_API_TOKEN || "";
export const WECHAT_APP_ID = process.env.WECHAT_APP_ID || "";
export const WECHAT_APP_SECRET = process.env.WECHAT_APP_SECRET || "";
+15 -3
View File
@@ -64,6 +64,17 @@ export async function addFeed(url: string, feedTitle: string): Promise<void> {
});
}
export async function updateFeed(oldUrl: string, newUrl: string, feedTitle: string): Promise<void> {
const qs = withToken();
const body: Record<string, string> = { url: newUrl, feedTitle };
if (oldUrl && oldUrl !== newUrl) body.oldUrl = oldUrl;
await rssFetch(`/api/feeds?${qs}`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
}
export async function deleteFeed(url: string): Promise<void> {
const qs = withToken(new URLSearchParams({ url, token: RSS_API_TOKEN }));
await rssFetch(`/api/feeds?${qs}`, { method: "DELETE" });
@@ -94,13 +105,14 @@ export async function addLink(link: { name: string; url: string; description?: s
});
}
export async function updateLink(url: string, data: { name?: string; description?: string; hidden?: boolean }): Promise<void> {
// RSS API uses POST as upsert
export async function updateLink(oldUrl: string, data: { name?: string; url?: string; description?: string; hidden?: boolean }): Promise<void> {
const qs = withToken();
const body: Record<string, unknown> = { ...data };
if (data.url && data.url !== oldUrl) body.oldUrl = oldUrl;
await rssFetch(`/api/links?${qs}`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ url, ...data }),
body: JSON.stringify(body),
});
}