- 设置页重写进 AppShell:生成与队列 / 智能体运行 / 存储路径三段,其余设置入口链到模型设置、ComfyUI 连接、智能体;旧 ?tab= 链接跳转到对应新页 - 项目卡状态标签改为按五段真实进度显示(已完成 / 某阶段生成中·待确认 / 进行中 / 待开始) - 首页生成任务行对齐 a1(来源标签、项目名、进度条、本地时间) - 连接页:右栏默认新增表单 + 任务使用目标面板,进入页面自动实测各连接;模型页默认新增表单、自动 1-token 实测,去掉双加号 - 生图/生视频:生成参数面板标题、通栏生成按钮、成片预览、按类型的历史标题与 16:9 视频历史、顶栏连接状态胶囊,连接状态改用服务器实测 - 智能体页:五个 Agent / Skill 库 / 已装 Skill 面板标题,内置 Skill 中文名,去掉对话空态 Calliope 字样 - 侧栏底部 ComfyUI 状态修正为真实实测(原查询不响应导致一直测试中) - 统一样式来源:.a-btn/.a-panel/.a-select/.status-chip 等只在 app.css 定义一次,删除各页重复定义;新增 Switch、Button block、ProgressBar tone - 旧 Calliope 路由(/projects、/project/:id、/canvas、/library、/build-scene、/playground)重定向到 A 页面;页面标题改为影工坊 - 轮询间隔单位改为秒(7 种语言) Co-authored-by: multica-agent <github@multica.ai>
597 lines
13 KiB
Svelte
597 lines
13 KiB
Svelte
<script lang="ts">
|
|
import { createQuery } from '@tanstack/svelte-query';
|
|
import { toStore } from 'svelte/store';
|
|
import LanguageSwitcher from '$lib/components/LanguageSwitcher.svelte';
|
|
import Icon from '$lib/components/ui/Icon.svelte';
|
|
import type { IconName } from '$lib/components/ui/icons';
|
|
import { settings, jobsApi, comfy } from '$lib/api';
|
|
import { t } from '$lib/i18n.svelte';
|
|
|
|
/**
|
|
* A「片场暗房」application shell — spec-v2 §3 (HEL-608).
|
|
*
|
|
* 216px left navigation with the confirmed item order, the 影工坊 brand,
|
|
* a ComfyUI address row pinned to the nav bottom, and a per-page top bar
|
|
* (title 20/600 + gray blurb + page actions). Unbuilt pages stay in the
|
|
* nav with an honest 「开发中」 pill instead of pretending to work.
|
|
*/
|
|
|
|
type NavId =
|
|
| 'projects'
|
|
| 'workbench'
|
|
| 'image'
|
|
| 'video'
|
|
| 'tasks'
|
|
| 'agents'
|
|
| 'connections'
|
|
| 'models'
|
|
| 'settings';
|
|
|
|
interface NavItem {
|
|
id: NavId;
|
|
labelKey: string;
|
|
icon: IconName;
|
|
href?: string;
|
|
wip?: boolean;
|
|
}
|
|
|
|
// Order is fixed by spec-v2 §3: 项目 / 创作工作台 / 生图 / 生视频 /
|
|
// 生成任务 / 智能体 / ComfyUI 连接 / 模型设置 / 设置.
|
|
const NAV: NavItem[] = [
|
|
{ id: 'projects', labelKey: 'shell.navProjects', icon: 'home', href: '/' },
|
|
{ id: 'workbench', labelKey: 'shell.navWorkbench', icon: 'story', href: '/workbench' },
|
|
{ id: 'image', labelKey: 'shell.navImage', icon: 'image', href: '/image' },
|
|
{ id: 'video', labelKey: 'shell.navVideo', icon: 'film', href: '/video' },
|
|
{ id: 'tasks', labelKey: 'shell.navTasks', icon: 'queue', href: '/tasks' },
|
|
{ id: 'agents', labelKey: 'shell.navAgents', icon: 'sparkle', href: '/agents' },
|
|
{ id: 'connections', labelKey: 'shell.navConnections', icon: 'link', href: '/connections' },
|
|
{ id: 'models', labelKey: 'shell.navModels', icon: 'assets', href: '/models' },
|
|
{ id: 'settings', labelKey: 'shell.navSettings', icon: 'settings', href: '/settings' },
|
|
];
|
|
|
|
interface Props {
|
|
active: NavId;
|
|
title: string;
|
|
subtitle?: string;
|
|
/** Page-level actions rendered right of the top bar (chips / buttons). */
|
|
actions?: import('svelte').Snippet;
|
|
children?: import('svelte').Snippet;
|
|
}
|
|
|
|
let { active, title, subtitle, actions, children }: Props = $props();
|
|
|
|
// Real ComfyUI connections from settings — shown honestly without a
|
|
// fake "connected" claim; tested state lives on /connections (a6).
|
|
const settingsQuery = createQuery({
|
|
queryKey: ['settings'],
|
|
queryFn: settings.get,
|
|
staleTime: 60_000,
|
|
});
|
|
|
|
// 生成任务 badge: how many jobs are queued or running right now
|
|
// (spec §3 — 进行数徽章). Polled lightly; SSE-driven pages keep
|
|
// their own faster cadence.
|
|
const activeJobsQuery = createQuery({
|
|
queryKey: ['jobs', 'active-count'],
|
|
queryFn: () => jobsApi.list(),
|
|
refetchInterval: 8_000,
|
|
staleTime: 5_000,
|
|
});
|
|
const activeJobs = $derived(
|
|
($activeJobsQuery.data ?? []).filter((j) => j.status === 'pending' || j.status === 'running')
|
|
.length,
|
|
);
|
|
|
|
// The ACTIVE ComfyUI connection (HEL-611). Its status dot comes from a
|
|
// real server-side probe (GET /system_stats from the workbench server,
|
|
// §3) — green only when that probe passes.
|
|
const activeEndpoint = $derived.by(() => {
|
|
const s = $settingsQuery.data;
|
|
if (!s) return null;
|
|
return s.comfyui_endpoints?.find((ep) => ep.id === s.comfyui_active_id) ?? null;
|
|
});
|
|
|
|
const comfyUrl = $derived.by(() => {
|
|
const raw = (activeEndpoint?.base_url ?? $settingsQuery.data?.comfyui_base_url ?? '').trim();
|
|
if (!raw) return '';
|
|
try {
|
|
const u = new URL(raw.includes('://') ? raw : `http://${raw}`);
|
|
return u.host;
|
|
} catch {
|
|
return raw;
|
|
}
|
|
});
|
|
|
|
const activeId = $derived(activeEndpoint?.id ?? null);
|
|
const probeQuery = createQuery(
|
|
toStore(() => ({
|
|
queryKey: ['comfy-probe', activeId],
|
|
queryFn: () => comfy.testEndpoint({ endpoint_id: activeId ?? undefined, timeout_sec: 5 }),
|
|
enabled: activeId != null,
|
|
staleTime: 60_000,
|
|
refetchInterval: 60_000,
|
|
retry: false,
|
|
})),
|
|
);
|
|
const probeState = $derived.by<'unset' | 'testing' | 'ok' | 'fail'>(() => {
|
|
if (!activeEndpoint) return 'unset';
|
|
if ($probeQuery.isPending) return 'testing';
|
|
if ($probeQuery.isError) return 'fail';
|
|
return $probeQuery.data?.ok ? 'ok' : 'fail';
|
|
});
|
|
const endpointName = $derived(activeEndpoint?.name?.trim() || 'ComfyUI');
|
|
</script>
|
|
|
|
<svelte:head>
|
|
<title>{title} · {t('shell.brand')}</title>
|
|
</svelte:head>
|
|
|
|
<div class="a-shell a-darkroom">
|
|
<!-- Mobile guard: this is a desktop-first tool (spec §4.5). -->
|
|
<div class="desktop-only-notice" data-testid="mobile-notice">
|
|
<Icon name="film" size={22} />
|
|
<p>{t('shell.mobileNotice')}</p>
|
|
</div>
|
|
|
|
<div class="shell-frame">
|
|
<aside class="side">
|
|
<a class="brand" href="/" title={t('shell.brandHome')}>
|
|
<span class="brand-mark" aria-hidden="true">{t('shell.brandMark')}</span>
|
|
<span class="brand-copy">
|
|
<span class="brand-name">{t('shell.brand')}</span>
|
|
<span class="brand-sub">AIGC STUDIO</span>
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="nav" aria-label={t('shell.navAria')}>
|
|
{#each NAV as item (item.id)}
|
|
{#if item.href}
|
|
<a
|
|
class="nav-item"
|
|
class:active={active === item.id}
|
|
href={item.href}
|
|
aria-current={active === item.id ? 'page' : undefined}
|
|
>
|
|
<span class="nav-icon"><Icon name={item.icon} size={17} /></span>
|
|
<span class="nav-label">{t(item.labelKey)}</span>
|
|
{#if item.id === 'tasks' && activeJobs > 0}
|
|
<span class="nav-badge">{activeJobs}</span>
|
|
{/if}
|
|
</a>
|
|
{:else}
|
|
<span class="nav-item disabled" title={t('shell.wipHint')} aria-disabled="true">
|
|
<span class="nav-icon"><Icon name={item.icon} size={17} /></span>
|
|
<span class="nav-label">{t(item.labelKey)}</span>
|
|
<span class="wip-pill">{t('shell.wip')}</span>
|
|
</span>
|
|
{/if}
|
|
{/each}
|
|
</nav>
|
|
|
|
<div class="side-foot">
|
|
<a
|
|
class="comfy-row"
|
|
href="/connections"
|
|
title={probeState === 'fail'
|
|
? ($probeQuery.data?.message ?? t('shell.comfyManage'))
|
|
: t('shell.comfyManage')}
|
|
>
|
|
<span class="dot {probeState}" aria-hidden="true"></span>
|
|
<span class="comfy-text">
|
|
{#if probeState === 'unset'}
|
|
{t('shell.comfyUnset')}
|
|
{:else}
|
|
<span class="comfy-state" class:fail={probeState === 'fail'}>
|
|
{t(`shell.comfy_${probeState}`, { name: endpointName })}
|
|
</span>
|
|
{#if comfyUrl}<span class="mono comfy-host">{comfyUrl}</span>{/if}
|
|
{/if}
|
|
</span>
|
|
</a>
|
|
<div class="lang-row">
|
|
<LanguageSwitcher />
|
|
</div>
|
|
</div>
|
|
</aside>
|
|
|
|
<div class="main">
|
|
<header class="topbar">
|
|
<div class="topbar-copy">
|
|
<h1>{title}</h1>
|
|
{#if subtitle}<p class="sub">{subtitle}</p>{/if}
|
|
</div>
|
|
{#if actions}
|
|
<div class="topbar-actions">
|
|
{@render actions()}
|
|
</div>
|
|
{/if}
|
|
</header>
|
|
<div class="body">
|
|
{@render children?.()}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
.a-shell {
|
|
position: fixed;
|
|
inset: 0;
|
|
}
|
|
|
|
.desktop-only-notice {
|
|
display: none;
|
|
}
|
|
|
|
.shell-frame {
|
|
height: 100%;
|
|
display: flex;
|
|
min-width: 0;
|
|
}
|
|
|
|
/* ---------------- side navigation (§3, 216px) ---------------- */
|
|
.side {
|
|
width: 216px;
|
|
flex-shrink: 0;
|
|
background: var(--surface);
|
|
border-right: 1px solid var(--border);
|
|
display: flex;
|
|
flex-direction: column;
|
|
padding: 16px 12px 12px;
|
|
gap: 14px;
|
|
box-sizing: border-box;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.brand {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 9px;
|
|
padding: 2px 8px;
|
|
text-decoration: none;
|
|
color: var(--text);
|
|
}
|
|
|
|
.brand-mark {
|
|
width: 30px;
|
|
height: 30px;
|
|
border-radius: 8px;
|
|
background: var(--avatar-1);
|
|
color: var(--accent-contrast);
|
|
font-size: 15px;
|
|
font-weight: 700;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.brand-copy {
|
|
display: flex;
|
|
flex-direction: column;
|
|
min-width: 0;
|
|
line-height: 1.25;
|
|
}
|
|
|
|
.brand-name {
|
|
font-size: 15px;
|
|
font-weight: 700;
|
|
letter-spacing: 0.02em;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.brand-sub {
|
|
font-family: var(--font-a-mono);
|
|
font-size: 9.5px;
|
|
letter-spacing: 0.14em;
|
|
color: var(--text-3);
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.nav {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 2px;
|
|
}
|
|
|
|
.nav-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
min-height: 38px;
|
|
padding: 0 10px;
|
|
border-radius: 8px;
|
|
color: var(--text-2);
|
|
font-size: 13px;
|
|
text-decoration: none;
|
|
transition:
|
|
background-color 150ms cubic-bezier(0.16, 1, 0.3, 1),
|
|
color 150ms;
|
|
}
|
|
|
|
.nav-item .nav-icon {
|
|
display: inline-flex;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
a.nav-item:hover {
|
|
background: var(--surface-3);
|
|
color: var(--text);
|
|
}
|
|
|
|
.nav-item.active {
|
|
background: var(--surface-3);
|
|
color: var(--text);
|
|
font-weight: 600;
|
|
}
|
|
|
|
.nav-item.disabled {
|
|
cursor: default;
|
|
user-select: none;
|
|
color: var(--text-3);
|
|
}
|
|
|
|
.wip-pill {
|
|
margin-left: auto;
|
|
padding: 1px 8px;
|
|
border-radius: 999px;
|
|
background: var(--surface-3);
|
|
color: var(--text-3);
|
|
font-size: 10px;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
/* 进行数徽章 (spec §3): accent-dim capsule with amber count */
|
|
.nav-badge {
|
|
margin-left: auto;
|
|
min-width: 20px;
|
|
padding: 1px 7px;
|
|
border-radius: 999px;
|
|
background: var(--accent-dim);
|
|
color: var(--accent);
|
|
font-size: 10.5px;
|
|
font-weight: 600;
|
|
font-variant-numeric: tabular-nums;
|
|
text-align: center;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.side-foot {
|
|
margin-top: auto;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
padding-top: 12px;
|
|
border-top: 1px solid var(--border);
|
|
}
|
|
|
|
.comfy-row {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
padding: 7px 10px;
|
|
border-radius: 7px;
|
|
text-decoration: none;
|
|
color: var(--text-2);
|
|
font-size: 11.5px;
|
|
transition:
|
|
background-color 150ms cubic-bezier(0.16, 1, 0.3, 1),
|
|
color 150ms;
|
|
}
|
|
|
|
.comfy-row:hover {
|
|
background: var(--surface-3);
|
|
color: var(--text);
|
|
}
|
|
|
|
/* §5 连接状态点: green = probe passed, amber breathing = testing,
|
|
red = failed, gray = no connection configured. */
|
|
.dot {
|
|
width: 7px;
|
|
height: 7px;
|
|
border-radius: 50%;
|
|
background: var(--text-3);
|
|
flex-shrink: 0;
|
|
align-self: flex-start;
|
|
margin-top: 5px;
|
|
}
|
|
.dot.ok {
|
|
background: var(--success);
|
|
}
|
|
.dot.fail {
|
|
background: var(--error);
|
|
}
|
|
.dot.testing {
|
|
background: var(--accent);
|
|
animation: shell-breathe 2s cubic-bezier(0.16, 1, 0.3, 1) infinite;
|
|
}
|
|
@keyframes shell-breathe {
|
|
50% {
|
|
opacity: 0.35;
|
|
}
|
|
}
|
|
|
|
.comfy-text {
|
|
display: flex;
|
|
flex-direction: column;
|
|
min-width: 0;
|
|
line-height: 1.5;
|
|
}
|
|
.comfy-state,
|
|
.comfy-host {
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
.comfy-state.fail {
|
|
color: var(--error);
|
|
}
|
|
.comfy-host {
|
|
font-size: 10.5px;
|
|
color: var(--text-3);
|
|
}
|
|
|
|
.lang-row :global(.lang-switcher) {
|
|
background: var(--surface-2);
|
|
color: var(--text-2);
|
|
border-color: var(--border-strong);
|
|
width: 100%;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
/* ---------------- main column ---------------- */
|
|
.main {
|
|
flex: 1;
|
|
min-width: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
background: var(--bg);
|
|
}
|
|
|
|
.topbar {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 16px;
|
|
padding: 14px 28px;
|
|
border-bottom: 1px solid var(--border);
|
|
background: var(--bg);
|
|
flex-shrink: 0;
|
|
min-height: 64px;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.topbar-copy h1 {
|
|
margin: 0;
|
|
font-size: 20px;
|
|
font-weight: 600;
|
|
color: var(--text);
|
|
line-height: 1.3;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.sub {
|
|
margin: 3px 0 0;
|
|
font-size: 12.5px;
|
|
color: var(--text-3);
|
|
line-height: 1.5;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.topbar-actions {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.body {
|
|
flex: 1;
|
|
min-height: 0;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
/* ---------------- responsive (§4.5) ---------------- */
|
|
@media (max-width: 1023px) {
|
|
.side {
|
|
width: 64px;
|
|
padding: 14px 8px 10px;
|
|
align-items: center;
|
|
}
|
|
.brand {
|
|
padding: 0;
|
|
justify-content: center;
|
|
}
|
|
.brand-copy {
|
|
display: none;
|
|
}
|
|
.nav {
|
|
width: 100%;
|
|
}
|
|
.nav-item {
|
|
justify-content: center;
|
|
padding: 0;
|
|
}
|
|
.nav-label {
|
|
display: none;
|
|
}
|
|
.wip-pill {
|
|
display: none;
|
|
}
|
|
/* icon-only rail: the tasks badge collapses to a small amber dot */
|
|
.nav-item {
|
|
position: relative;
|
|
}
|
|
.nav-badge {
|
|
position: absolute;
|
|
top: 3px;
|
|
right: 5px;
|
|
min-width: 6px;
|
|
width: 6px;
|
|
height: 6px;
|
|
padding: 0;
|
|
border-radius: 50%;
|
|
background: var(--accent);
|
|
font-size: 0;
|
|
line-height: 0;
|
|
}
|
|
/* icon-only rail: a small dot marks unbuilt entries */
|
|
.nav-item.disabled .nav-icon {
|
|
position: relative;
|
|
}
|
|
.nav-item.disabled .nav-icon::after {
|
|
content: '';
|
|
position: absolute;
|
|
top: -2px;
|
|
right: -4px;
|
|
width: 5px;
|
|
height: 5px;
|
|
border-radius: 50%;
|
|
background: var(--text-3);
|
|
}
|
|
.comfy-text,
|
|
.lang-row {
|
|
display: none;
|
|
}
|
|
.comfy-row {
|
|
justify-content: center;
|
|
padding: 6px;
|
|
}
|
|
.topbar {
|
|
padding: 12px 18px;
|
|
}
|
|
.sub {
|
|
white-space: normal;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 767px) {
|
|
.shell-frame {
|
|
display: none;
|
|
}
|
|
.desktop-only-notice {
|
|
display: flex;
|
|
height: 100%;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 12px;
|
|
padding: 32px;
|
|
text-align: center;
|
|
color: var(--text-2);
|
|
}
|
|
.desktop-only-notice p {
|
|
margin: 0;
|
|
font-size: 14px;
|
|
line-height: 1.7;
|
|
}
|
|
.desktop-only-notice :global(.icon) {
|
|
color: var(--accent);
|
|
}
|
|
}
|
|
</style>
|