feat(mock): 补全新功能的 mock 数据(覆盖度/覆盖图/关联/工作空间)
- data:coverage、coverageGraph(11 节点树)、assetRefsFor、WS_TREE +
workspaceList/Read 示例文件树
- handler:/tasks/{id}/coverage · coverage-graph · asset-refs +
/workspace/list · read 路由(写/建/删走 {ok:true} 兜底)
- api:workspaceUpload/Download 加 MOCK 守卫(裸 fetch 绕过 http 助手,
demo 下改为 no-op/占位下载,不再网络报错)
Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
75ca97feb1
commit
4c407dc448
3 files changed
+127
-6
No files matched your search
+12
-6
@@ -144,6 +144,7 @@ export const api = {
|
||||
workspaceDelete: (path: string) =>
|
||||
del<{ ok: boolean }>(`/workspace/delete?path=${encodeURIComponent(path)}`),
|
||||
workspaceUpload: async (dir: string, files: File[]) => {
|
||||
if (MOCK) return { uploaded: files.length };
|
||||
const fd = new FormData();
|
||||
for (const f of files) fd.append("file", f);
|
||||
const token = getToken();
|
||||
@@ -156,12 +157,17 @@ export const api = {
|
||||
return r.json() as Promise<{ uploaded: number }>;
|
||||
},
|
||||
workspaceDownload: async (path: string) => {
|
||||
const token = getToken();
|
||||
const r = await fetch(`/api/workspace/download?path=${encodeURIComponent(path)}`, {
|
||||
headers: { ...(token ? { Authorization: `Bearer ${token}` } : {}) },
|
||||
});
|
||||
if (!r.ok) throw new Error(`下载失败: ${r.status}`);
|
||||
const blob = await r.blob();
|
||||
let blob: Blob;
|
||||
if (MOCK) {
|
||||
blob = new Blob([`(demo)${path} 的下载内容示例。`], { type: "text/plain" });
|
||||
} else {
|
||||
const token = getToken();
|
||||
const r = await fetch(`/api/workspace/download?path=${encodeURIComponent(path)}`, {
|
||||
headers: { ...(token ? { Authorization: `Bearer ${token}` } : {}) },
|
||||
});
|
||||
if (!r.ok) throw new Error(`下载失败: ${r.status}`);
|
||||
blob = await r.blob();
|
||||
}
|
||||
const objUrl = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = objUrl;
|
||||
|
||||
Reference in new issue
Block a user