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
+25
View File
@@ -0,0 +1,25 @@
/** 上游 NewAPI 服务的根地址 */
const BASE_URL = "https://api.qflink.xyz";
/**
* 向上游 NewAPI 发起请求
*
* @param path 相对路径,如 "/api/user/register",会自动拼接到 BASE_URL 后面
* @param options 透传给 $fetch 的所有选项(method、body、headers 等)
* @returns Promise<T>T 是上游返回的数据类型
*
* @example
* const result = await newApiFetch<string>("/api/user/register", {
* method: "POST",
* body: { username: "xxx" }
* })
*/
export const newApiFetch = <T>(
path: string,
options?: Parameters<typeof $fetch>[1]
): Promise<T> => {
return $fetch<T>(path, {
baseURL: BASE_URL,
...options
}) as Promise<T>;
};