feat: 新增api接口

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-04-24 15:36:44 +08:00
parent 278f1aab85
commit 5ab74ad9dd
13 changed files with 537 additions and 59 deletions
+21
View File
@@ -0,0 +1,21 @@
// server/api/auth/logout.get.ts
import type { UserLogoutResult } from "#shared/types";
/**
* GET /api/auth/logout
*
* 登出流程:
* 1. 服务端直接转发 GET 请求到上游 NewAPI
* 2. 上游成功后统一返回 { code: 0, data: null, msg: "登出成功" }
*/
export default defineEventHandler(async () => {
try {
await newApiFetch<UserLogoutResult>("/api/user/logout", {
method: "GET"
});
return createSuccessResponse(null, "登出成功");
} catch (error) {
return createUpstreamErrorResponse(error, "登出失败");
}
});