diff --git a/src/lib/api.ts b/src/lib/api.ts index 06fef81..f244a30 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -1,7 +1,8 @@ // HoloLake Era · V0.1 · Gitea API 数据服务 // 连接 guanghutansuohe.com 的 yeye 仓库作为事实源 -const BASE = "https://guanghutansuohe.com/code/api/v1/repos/bingshuo/yeye/contents"; +// 通过 Vite 代理访问 Gitea API(避免 CORS) +const BASE = "/gitea-api/repos/bingshuo/yeye/contents"; async function fetchJson(url: string): Promise { const res = await fetch(url); @@ -12,8 +13,8 @@ async function fetchJson(url: string): Promise { // 读取文件内容(API返回base64编码) async function readFile(path: string): Promise { const data = await fetchJson(`${BASE}/${path}?ref=main`); - const decoded = atob(data.content); - return decoded; + const bytes = Uint8Array.from(atob(data.content), (c: string) => c.charCodeAt(0)); + return new TextDecoder("utf-8").decode(bytes); } // 列出目录