fix(HEL-730): preserve shared pins and sample icon geometry
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { storageGet, storageSet } from "$lib/storage";
|
||||
import { isWorkflowRunnable, workflowState } from "$lib/workflowState";
|
||||
import FamilyBadge from "$lib/components/manage/FamilyBadge.svelte";
|
||||
import ManagementPage from "$lib/components/manage/ManagementPage.svelte";
|
||||
@@ -6,7 +8,6 @@
|
||||
import { createMutation, useQueryClient } from "@tanstack/svelte-query";
|
||||
import Button from "$lib/components/ui/Button.svelte";
|
||||
import ConfirmDialog from "$lib/components/ui/ConfirmDialog.svelte";
|
||||
import EmptyState from "$lib/components/ui/EmptyState.svelte";
|
||||
import Icon from "$lib/components/ui/Icon.svelte";
|
||||
import Switch from "$lib/components/ui/Switch.svelte";
|
||||
import WorkflowImportDrawer from "$lib/components/WorkflowImportDrawer.svelte";
|
||||
@@ -62,6 +63,32 @@
|
||||
});
|
||||
|
||||
const client = useQueryClient();
|
||||
let pins = $state<number[]>([]);
|
||||
onMount(() => {
|
||||
try {
|
||||
const saved = JSON.parse(
|
||||
storageGet("calliope.reference.workflowPins") ?? "[]",
|
||||
);
|
||||
pins = Array.isArray(saved)
|
||||
? saved.filter((id): id is number => typeof id === "number")
|
||||
: [];
|
||||
} catch {
|
||||
pins = [];
|
||||
}
|
||||
});
|
||||
function pin(id: number) {
|
||||
pins = pins.includes(id)
|
||||
? pins.filter((value) => value !== id)
|
||||
: [...pins, id];
|
||||
storageSet("calliope.reference.workflowPins", JSON.stringify(pins));
|
||||
}
|
||||
function inputNodeLabel(wf: Workflow, id: string, label: string): string {
|
||||
const [nodeId, field] = id.split("@");
|
||||
const node = wf.workflow_json[nodeId];
|
||||
const name = typeof node?.class_type === "string" ? node.class_type : label;
|
||||
return nodeId + " · " + name + (field ? "." + field : "");
|
||||
}
|
||||
|
||||
function invalidateWorkflows() {
|
||||
return Promise.all([
|
||||
client.invalidateQueries({ queryKey: ["workflows"] }),
|
||||
@@ -224,13 +251,11 @@
|
||||
}
|
||||
|
||||
let batchPending = $state(false);
|
||||
let batchEnableDir = $state<boolean | null>(null);
|
||||
let metaDialogOpen = $state(false);
|
||||
let metaTargets = $state<WorkflowMeta[]>([]);
|
||||
|
||||
async function batchSetEnabled(enabled: boolean) {
|
||||
batchPending = true;
|
||||
batchEnableDir = enabled;
|
||||
let done = 0;
|
||||
let failed = 0;
|
||||
try {
|
||||
@@ -252,7 +277,6 @@
|
||||
}
|
||||
} finally {
|
||||
batchPending = false;
|
||||
batchEnableDir = null;
|
||||
}
|
||||
invalidateWorkflows();
|
||||
if (failed === 0) toast.success(t("wl.batchDone", { n: done }));
|
||||
@@ -557,12 +581,6 @@
|
||||
searchInput?.focus();
|
||||
}
|
||||
|
||||
function mediaIcon(kind: string): "image" | "film" | "music" {
|
||||
if (kind === "video") return "film";
|
||||
if (kind === "audio") return "music";
|
||||
return "image";
|
||||
}
|
||||
|
||||
function mediaTitle(kind: string): string {
|
||||
if (kind === "video") return t("wl.mediaVideo");
|
||||
if (kind === "audio") return t("wl.mediaAudio");
|
||||
@@ -593,7 +611,6 @@
|
||||
toast.error(apiErrorMessage(err));
|
||||
}
|
||||
}
|
||||
const pendingCount = $derived(rows.filter((r) => !r.usage).length);
|
||||
const favCount = $derived(rows.filter((r) => r.favorite).length);
|
||||
</script>
|
||||
|
||||
@@ -604,7 +621,7 @@
|
||||
.length} 个</span
|
||||
>{/snippet}
|
||||
{#snippet actions()}<Button size="sm" onclick={() => (singleOpen = true)}
|
||||
><Icon name="upload" size={14} />导入工作流</Button
|
||||
><Icon name="upload-manage" size={14} />导入工作流</Button
|
||||
>{/snippet}
|
||||
<div class="mg-layout">
|
||||
<aside class="mg-side" aria-label="工作流筛选">
|
||||
@@ -707,7 +724,7 @@
|
||||
<div class="mg-main">
|
||||
<div class="mg-tools">
|
||||
<label class="mg-search workflow-search"
|
||||
><Icon name="search" size={14} /><input
|
||||
><Icon name="search-manage" size={14} /><input
|
||||
bind:this={searchInput}
|
||||
bind:value={search}
|
||||
placeholder="搜索名称、文件名、模型…"
|
||||
@@ -809,12 +826,11 @@
|
||||
><td><span class="mg-tag {state.tone}">{state.label}</span></td>
|
||||
<td
|
||||
><button
|
||||
class="mg-click"
|
||||
aria-label={"收藏 " + row.name}
|
||||
aria-pressed={row.favorite}
|
||||
onclick={() =>
|
||||
$favMutation.mutate({ id: row.id, fav: !row.favorite })}
|
||||
><Icon name="star" size={13} /></button
|
||||
class="mg-pin"
|
||||
aria-label={"在创作台置顶 " + row.name}
|
||||
aria-pressed={pins.includes(row.id)}
|
||||
onclick={() => pin(row.id)}
|
||||
><Icon name="pin" size={14} /></button
|
||||
></td
|
||||
>
|
||||
</tr>
|
||||
@@ -896,6 +912,13 @@
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onclick={() => openMetaDialog([row])}>+ 标签</Button
|
||||
><Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
loading={$favMutation.isPending}
|
||||
onclick={() =>
|
||||
$favMutation.mutate({ id: row.id, fav: !row.favorite })}
|
||||
>{row.favorite ? "★ 已收藏" : "☆ 收藏"}</Button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
@@ -906,13 +929,10 @@
|
||||
</p>{:else if full}{#each full.input_schema as input}<div
|
||||
class="mg-map"
|
||||
>
|
||||
<span class="a">{input.nodeId} · {input.label}</span><Icon
|
||||
name="chevron-right"
|
||||
size={12}
|
||||
/><span class="b"
|
||||
>{input.role ?? input.kind}{input.required
|
||||
? "(必填)"
|
||||
: ""}</span
|
||||
<span class="a"
|
||||
>{inputNodeLabel(full, input.nodeId, input.label)}</span
|
||||
><Icon name="arrow-right" size={14} /><span class="b"
|
||||
>{input.label}{input.required ? "(必填)" : ""}</span
|
||||
>
|
||||
</div>{/each}{:else}<Button
|
||||
size="sm"
|
||||
|
||||
Reference in New Issue
Block a user