🎉 init: 小龙的工作空间

This commit is contained in:
大海
2026-06-06 10:40:48 +08:00
commit a188ee1426
3201 changed files with 231817 additions and 0 deletions
@@ -0,0 +1,47 @@
// Auto-generated API client for SocialApp
const API_BASE = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001/api";
interface RequestOptions extends RequestInit {
params?: Record<string, string | number>;
}
async function request<T>(endpoint: string, options: RequestOptions = {}): Promise<T> {
const { params, ...init } = options;
let url = `${API_BASE}${endpoint}`;
if (params) {
const searchParams = new URLSearchParams();
Object.entries(params).forEach(([k, v]) => searchParams.set(k, String(v)));
url += `?${searchParams.toString()}`;
}
const res = await fetch(url, {
...init,
headers: {
"Content-Type": "application/json",
...init.headers,
},
});
if (!res.ok) {
const err = await res.json().catch(() => ({ message: res.statusText }));
throw new Error(err.message || `API Error: ${res.status}`);
}
return res.json();
}
export const api = {
get: <T>(url: string, params?: Record<string, string | number>) =>
request<T>(url, { method: "GET", params }),
post: <T>(url: string, data?: unknown) =>
request<T>(url, { method: "POST", body: JSON.stringify(data) }),
put: <T>(url: string, data?: unknown) =>
request<T>(url, { method: "PUT", body: JSON.stringify(data) }),
delete: <T>(url: string) =>
request<T>(url, { method: "DELETE" }),
};
@@ -0,0 +1,10 @@
// Auto-generated articles service
import { api } from "./api";
export function get() {
return api.get("/api/articles");
}
export function post(data: Record<string, unknown>) {
return api.post("/api/articles", data);
}
@@ -0,0 +1,10 @@
// Auto-generated auth service
import { api } from "./api";
export function postlogin(data: Record<string, unknown>) {
return api.post("/api/auth", data);
}
export function getme() {
return api.get("/api/auth");
}
@@ -0,0 +1,10 @@
// Auto-generated comments service
import { api } from "./api";
export function get() {
return api.get("/api/comments");
}
export function post(data: Record<string, unknown>) {
return api.post("/api/comments", data);
}
@@ -0,0 +1,6 @@
// Auto-generated feed service
import { api } from "./api";
export function get() {
return api.get("/api/feed");
}
@@ -0,0 +1,10 @@
// Auto-generated media service
import { api } from "./api";
export function get() {
return api.get("/api/media");
}
export function post(data: Record<string, unknown>) {
return api.post("/api/media", data);
}
@@ -0,0 +1,10 @@
// Auto-generated posts service
import { api } from "./api";
export function post(data: Record<string, unknown>) {
return api.post("/api/posts", data);
}
export function post_id_like(data: Record<string, unknown>) {
return api.post("/api/posts", data);
}
@@ -0,0 +1,10 @@
// Auto-generated tags service
import { api } from "./api";
export function get() {
return api.get("/api/tags");
}
export function post(data: Record<string, unknown>) {
return api.post("/api/tags", data);
}
@@ -0,0 +1,6 @@
// Auto-generated users service
import { api } from "./api";
export function get_id(id: string) {
return api.get(`/api/users/${id}`);
}
@@ -0,0 +1,10 @@
// Auto-generated 分类标签 service
import { api } from "./api";
export function get() {
return api.get("/api/分类标签");
}
export function post(data: Record<string, unknown>) {
return api.post("/api/分类标签", data);
}
@@ -0,0 +1,10 @@
// Auto-generated 媒体库 service
import { api } from "./api";
export function get() {
return api.get("/api/媒体库");
}
export function post(data: Record<string, unknown>) {
return api.post("/api/媒体库", data);
}
@@ -0,0 +1,10 @@
// Auto-generated 文章发布 service
import { api } from "./api";
export function get() {
return api.get("/api/文章发布");
}
export function post(data: Record<string, unknown>) {
return api.post("/api/文章发布", data);
}
@@ -0,0 +1,10 @@
// Auto-generated 评论管理 service
import { api } from "./api";
export function get() {
return api.get("/api/评论管理");
}
export function post(data: Record<string, unknown>) {
return api.post("/api/评论管理", data);
}