mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-14 21:35:19 +00:00
refac: click to focus on mesage node
This commit is contained in:
parent
c89bb01db9
commit
732f730213
1 changed files with 13 additions and 2 deletions
|
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
export let history;
|
export let history;
|
||||||
|
|
||||||
|
let selectedMessageId = null;
|
||||||
|
|
||||||
const nodes = writable([]);
|
const nodes = writable([]);
|
||||||
const edges = writable([]);
|
const edges = writable([]);
|
||||||
|
|
||||||
|
|
@ -34,10 +36,17 @@
|
||||||
drawFlow();
|
drawFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
$: if (history?.currentId) {
|
$: if (history && history.currentId) {
|
||||||
fitView({ nodes: [{ id: history.currentId }] });
|
focusNode();
|
||||||
|
selectedMessageId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const focusNode = async () => {
|
||||||
|
if (selectedMessageId === null) {
|
||||||
|
await fitView({ nodes: [{ id: history.currentId }] });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const drawFlow = async () => {
|
const drawFlow = async () => {
|
||||||
const nodeList = [];
|
const nodeList = [];
|
||||||
const edgeList = [];
|
const edgeList = [];
|
||||||
|
|
@ -168,6 +177,8 @@
|
||||||
on:nodeclick={(e) => {
|
on:nodeclick={(e) => {
|
||||||
console.log(e.detail.node.data);
|
console.log(e.detail.node.data);
|
||||||
dispatch('nodeclick', e.detail);
|
dispatch('nodeclick', e.detail);
|
||||||
|
selectedMessageId = e.detail.node.data.message.id;
|
||||||
|
fitView({ nodes: [{ id: selectedMessageId }] });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue