From bacd79cb0ef0ab2d2e6bdcadd801b62da5505d90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B7=91=E5=A9=B7=E9=99=88?= Date: Wed, 22 Jul 2026 19:31:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20UTF-8=E8=A7=A3=E7=A0=81=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=B8=AD=E6=96=87=E4=B9=B1=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/api.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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); } // 列出目录