mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
fix: add missing ui action controller exports
This commit is contained in:
@@ -85,3 +85,64 @@ export async function onFetchEmbeddingModelsController(runtime, mode = null) {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function onManualCompressController(runtime) {
|
||||
const graph = runtime.getCurrentGraph();
|
||||
if (!graph) return;
|
||||
if (!runtime.ensureGraphMutationReady("手动压缩")) return;
|
||||
|
||||
const beforeSnapshot = runtime.cloneGraphSnapshot(graph);
|
||||
const result = await runtime.compressAll(
|
||||
graph,
|
||||
runtime.getSchema(),
|
||||
runtime.getEmbeddingConfig(),
|
||||
false,
|
||||
undefined,
|
||||
undefined,
|
||||
runtime.getSettings(),
|
||||
);
|
||||
await runtime.recordGraphMutation({
|
||||
beforeSnapshot,
|
||||
artifactTags: ["compression"],
|
||||
});
|
||||
|
||||
runtime.toastr.info(`压缩完成: 新建 ${result.created}, 归档 ${result.archived}`);
|
||||
}
|
||||
|
||||
export async function onExportGraphController(runtime) {
|
||||
const graph = runtime.getCurrentGraph();
|
||||
if (!graph) return;
|
||||
|
||||
const json = runtime.exportGraph(graph);
|
||||
const blob = new Blob([json], { type: "application/json" });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = runtime.document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = `st-bme-graph-${Date.now()}.json`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
|
||||
runtime.toastr.success("图谱已导出");
|
||||
}
|
||||
|
||||
export async function onViewLastInjectionController(runtime) {
|
||||
const content = runtime.getLastInjectionContent();
|
||||
if (!content) {
|
||||
runtime.toastr.info("暂无注入内容");
|
||||
return;
|
||||
}
|
||||
|
||||
const popup = runtime.document.createElement("div");
|
||||
popup.style.cssText =
|
||||
"position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);background:#1a1a2e;color:#eee;padding:24px;border-radius:12px;max-width:80vw;max-height:80vh;overflow:auto;z-index:99999;white-space:pre-wrap;font-size:13px;box-shadow:0 8px 32px rgba(0,0,0,0.5);";
|
||||
popup.textContent = content;
|
||||
|
||||
const close = runtime.document.createElement("button");
|
||||
close.textContent = "关闭";
|
||||
close.style.cssText =
|
||||
"position:absolute;top:8px;right:12px;background:#e94560;color:white;border:none;padding:4px 12px;border-radius:4px;cursor:pointer;";
|
||||
close.onclick = () => popup.remove();
|
||||
popup.appendChild(close);
|
||||
|
||||
runtime.document.body.appendChild(popup);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user