1. Y-Log 上报 optDetail 前缀 B1-CM助手 → CM助手-全量(全量替换 44 个前端文件 + 文档) 2. 知识库入库 nodeName 改为只取 md5(标题).md(去掉时间戳),同一篇 md 每次入库一致,避免重复记录 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import { apiFetch } from "@/core/api";
|
|
import { OptType, writeYLog } from "@/core/log/y-log";
|
|
|
|
import { urlOfArtifact } from "./utils";
|
|
|
|
async function errorMessageFromResponse(res: Response): Promise<string> {
|
|
try {
|
|
const data: unknown = await res.json();
|
|
if (data && typeof data === "object" && "detail" in data) {
|
|
const detail = (data as { detail: unknown }).detail;
|
|
if (typeof detail === "string") return detail;
|
|
}
|
|
} catch {
|
|
// ignore non-json errors
|
|
}
|
|
return res.statusText || "Request failed";
|
|
}
|
|
|
|
export async function updateArtifactContent({
|
|
filepath,
|
|
threadId,
|
|
content,
|
|
isMock,
|
|
}: {
|
|
filepath: string;
|
|
threadId: string;
|
|
content: string;
|
|
isMock?: boolean;
|
|
}) {
|
|
const url = urlOfArtifact({ filepath, threadId, isMock });
|
|
const res = await apiFetch(url, {
|
|
method: "PATCH",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({ content }),
|
|
});
|
|
if (!res.ok) {
|
|
throw new Error(await errorMessageFromResponse(res));
|
|
}
|
|
writeYLog({
|
|
optType: OptType.edit,
|
|
optDetail: "CM助手-全量-产物-编辑产物内容",
|
|
url,
|
|
reqParam: { filepath, threadId },
|
|
});
|
|
return res.text();
|
|
}
|