You've already forked DataMate
refactor(annotation): 移除对 Label Studio Server 的依赖并切换到内嵌编辑器模式
- 移除 LabelStudioClient 和 SyncService 的导入及使用 - 删除与 Label Studio 项目的创建、删除和同步相关代码 - 修改创建数据集映射功能,改为创建 DataMate 标注项目 - 更新删除映射接口,仅进行软删除不再删除 Label Studio 项目 - 修改同步接口为兼容性保留,实际操作为空操作 - 移除 Label Studio 连接诊断功能 - 更新文档说明以反映内嵌编辑器模式的变化
This commit is contained in:
@@ -45,6 +45,19 @@
|
||||
window.parent.postMessage({ type, payload }, ORIGIN);
|
||||
}
|
||||
|
||||
window.addEventListener("error", (event) => {
|
||||
try {
|
||||
postToParent("LS_ERROR", { message: event?.message || "iframe 内发生脚本错误" });
|
||||
} catch (_) {}
|
||||
});
|
||||
|
||||
window.addEventListener("unhandledrejection", (event) => {
|
||||
try {
|
||||
const reason = event?.reason;
|
||||
postToParent("LS_ERROR", { message: reason?.message || String(reason || "iframe 内发生未处理异常") });
|
||||
} catch (_) {}
|
||||
});
|
||||
|
||||
function destroyLabelStudio() {
|
||||
try {
|
||||
if (lsInstance && typeof lsInstance.destroy === "function") {
|
||||
@@ -166,12 +179,17 @@
|
||||
: { id: selected?.id || "draft", result: (selected && selected.result) || [] };
|
||||
|
||||
// 最小化对齐 Label Studio Server 的字段(DataMate 侧会原样存储)
|
||||
if (!annotationPayload.task) annotationPayload.task = currentTask?.id || null;
|
||||
const taskId = typeof currentTask?.id === "number" ? currentTask.id : Number(currentTask?.id) || null;
|
||||
const fileId = currentTask?.data?.file_id || currentTask?.data?.fileId || null;
|
||||
|
||||
annotationPayload.id = typeof annotationPayload.id === "number" ? annotationPayload.id : taskId || 1;
|
||||
annotationPayload.task = taskId;
|
||||
if (!annotationPayload.created_at) annotationPayload.created_at = new Date().toISOString();
|
||||
annotationPayload.updated_at = new Date().toISOString();
|
||||
|
||||
return {
|
||||
taskId: currentTask?.id || null,
|
||||
taskId,
|
||||
fileId,
|
||||
annotation: annotationPayload,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user