实现投稿ui

This commit is contained in:
2026-01-23 11:16:07 +08:00
parent 2bb3db5966
commit 5932adcd9a
8 changed files with 839 additions and 16 deletions

View File

@@ -48,3 +48,36 @@ export const getAbout = async (): Promise<string> => {
throw error;
}
};
export interface StaticsData {
posts: number;
comments: number;
images: number;
}
export const testApiStatus = async (): Promise<boolean> => {
try {
const response = await fetch('/api/test');
return response.ok;
} catch (error) {
return false;
}
};
export const getStatics = async (): Promise<StaticsData> => {
try {
const response = await fetch('/api/statics');
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const json = await response.json();
if (json.code === 1000) {
return json.data;
} else {
throw new Error('Invalid response code');
}
} catch (error) {
console.error('Failed to fetch statics:', error);
throw error;
}
};