fix:锁定文件只读

This commit is contained in:
xiaozhu
2026-08-13 10:26:01 +08:00
parent 7b10f08484
commit a2f515cf87
5 changed files with 389 additions and 52 deletions
+35 -5
View File
@@ -424,11 +424,41 @@ export async function getScriptContent(
content: string | object;
format: string;
}> {
return apiRequest(
`/api/v1/scripts/${scriptId}/content`,
{},
workspaceId,
).then((envelope) => (envelope as Record<string, any>).data);
const response = await fetch(
`/api/v1/scripts/${scriptId}/content?workspace_id=${encodeURIComponent(workspaceId)}`,
{
credentials: "same-origin",
headers: {
"X-Request-ID": createUuid().replaceAll("-", ""),
},
},
);
if (response.status === 401 && typeof window !== "undefined") {
const here = window.location.pathname;
if (here !== "/login") {
window.location.assign("/login");
}
throw new ApiRequestError("未登录或登录已过期", 401);
}
const payload = await response.json();
if (!response.ok) {
const error = payload as ApiErrorEnvelope;
const detailMessage = typeof error.detail === "string"
? error.detail
: error.detail?.message;
throw new ApiRequestError(
detailMessage ?? `请求失败(HTTP ${response.status}`,
response.status,
);
}
const data = (payload as { data: { script_id: string; script_type: ScriptType; content: string | object; format: string } }).data;
if (!data || !data.script_type) {
throw new ApiRequestError("响应数据格式错误", response.status);
}
return data;
}
export async function deleteScript(