- 216px 文字侧栏改为 60px 图标轨:金色渐变 Logo、当前页金色指示条滑动、350ms 延迟悬停提示,底部连接/模型/设置/语言 - 顶栏:标题+副标题、项目范围胶囊(全部项目列表/最近项目)、Ctrl/⌘K 搜索、减少动态开关、任务托盘胶囊、本次连接胶囊(名称+延迟) - ≤760px:隐藏图标轨,底部 项目/创作/生成/更多 四个标签,更多为底部抽屉(其余页面、搜索、减少动态、语言);删除「手机端暂不适配」拦截 - 新增 ShellPop(Esc/↑↓/Tab 循环/外部点击关闭、焦点归还)与 CommandPalette(复用 Modal) - 减少动态:跟随系统设置,另可手动开启并持久化(data-reduce) - .a-darkroom 背景接入 --page-glow;新增壳层尺寸 token 与 .a-kbd/.a-menu-* 公共类 - 生图/生视频顶栏去掉与全局胶囊重复的连接状态(参数栏仍显示所选连接与队列) - 路由 URL 不变(/projects 仍重定向到项目总览 /) Co-authored-by: multica-agent <github@multica.ai> Co-authored-by: Cursor <cursoragent@cursor.com>
165 lines
4.6 KiB
Svelte
165 lines
4.6 KiB
Svelte
<script lang="ts">
|
|
import { createQuery } from '@tanstack/svelte-query';
|
|
import { toStore } from 'svelte/store';
|
|
import { workflows, type Job } from '$lib/api';
|
|
import { parseDbTs } from '$lib/dbtime';
|
|
import { t } from '$lib/i18n.svelte';
|
|
import { jobSourceLabel } from '$lib/jobLabels';
|
|
import { jobStatusInfo, type JobStatusTone } from '$lib/jobStatus';
|
|
import ShellPop from './ShellPop.svelte';
|
|
|
|
/**
|
|
* 顶栏队列胶囊 + 任务托盘 (§二). The dot is cyan only while something is
|
|
* actually generating — queued work stays gray, as on the task page.
|
|
*/
|
|
let { jobs }: { jobs: Job[] } = $props();
|
|
|
|
const TRAY_LIMIT = 6;
|
|
const TAG_CLASS: Record<JobStatusTone, string> = { ok: 'ok', run: 'run', queue: '', fail: 'err' };
|
|
|
|
let open = $state(false);
|
|
let capsule = $state<HTMLButtonElement | null>(null);
|
|
|
|
const workflowsQuery = createQuery(
|
|
toStore(() => ({
|
|
queryKey: ['workflows'],
|
|
queryFn: workflows.list,
|
|
enabled: open,
|
|
staleTime: 60_000,
|
|
})),
|
|
);
|
|
|
|
const active = $derived(jobs.filter((j) => j.status === 'pending' || j.status === 'running'));
|
|
const running = $derived(active.filter((j) => jobStatusInfo(j).tone === 'run').length);
|
|
const queued = $derived(active.length - running);
|
|
const recent = $derived([...jobs].sort((a, b) => b.id - a.id).slice(0, TRAY_LIMIT));
|
|
|
|
const label = $derived.by(() => {
|
|
const parts: string[] = [];
|
|
if (running > 0) parts.push(t('shell.queueRunning', { n: running }));
|
|
if (queued > 0) parts.push(t('shell.queueQueued', { n: queued }));
|
|
return parts.length ? parts.join(' · ') : t('shell.queueIdle');
|
|
});
|
|
|
|
// 任务数变化时胶囊轻弹一次(320ms,只播一次).
|
|
let lastCount: number | null = null;
|
|
$effect(() => {
|
|
const count = active.length;
|
|
if (lastCount !== null && count !== lastCount && capsule) {
|
|
capsule.classList.remove('bump');
|
|
void capsule.offsetWidth;
|
|
capsule.classList.add('bump');
|
|
}
|
|
lastCount = count;
|
|
});
|
|
|
|
function workflowName(job: Job): string {
|
|
return (
|
|
($workflowsQuery.data ?? []).find((w) => w.id === job.workflow_id)?.name ??
|
|
t('studio.jobName', { id: job.id })
|
|
);
|
|
}
|
|
|
|
function timeOf(job: Job): string {
|
|
const ts = parseDbTs(job.created_at);
|
|
if (!Number.isFinite(ts)) return '—';
|
|
const d = new Date(ts);
|
|
const p = (n: number) => String(n).padStart(2, '0');
|
|
return `${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`;
|
|
}
|
|
</script>
|
|
|
|
<div class="tray">
|
|
<button
|
|
bind:this={capsule}
|
|
type="button"
|
|
class="status-chip queue-btn"
|
|
aria-haspopup="dialog"
|
|
aria-expanded={open}
|
|
aria-label={label}
|
|
title={label}
|
|
onclick={() => (open = !open)}
|
|
onanimationend={() => capsule?.classList.remove('bump')}
|
|
>
|
|
<span class="status-chip-dot {running > 0 ? 'run' : 'idle'}" aria-hidden="true"></span>
|
|
<span class="queue-label">{label}</span>
|
|
<span class="queue-count mono">{active.length}</span>
|
|
</button>
|
|
|
|
<ShellPop bind:open label={t('shell.trayTitle')} align="end" width="340px">
|
|
<div class="a-menu-group">{t('shell.trayRecent')}</div>
|
|
{#if recent.length === 0}
|
|
<p class="tray-note">{t('shell.trayEmpty')}</p>
|
|
{:else}
|
|
{#each recent as job (job.id)}
|
|
{@const info = jobStatusInfo(job)}
|
|
<a class="a-menu-item tray-row" href="/tasks" title={info.detail} onclick={() => (open = false)}>
|
|
<span class="tray-copy">
|
|
<span class="a-menu-label">{workflowName(job)}</span>
|
|
<span class="tray-meta">{jobSourceLabel(job)} · <span class="mono">{timeOf(job)}</span></span>
|
|
</span>
|
|
<span class="a-tag {TAG_CLASS[info.tone]}">{info.label}</span>
|
|
</a>
|
|
{/each}
|
|
{/if}
|
|
<a class="a-menu-item tray-all" href="/tasks" onclick={() => (open = false)}>
|
|
<span class="a-menu-label">{t('shell.trayAll')}</span>
|
|
</a>
|
|
</ShellPop>
|
|
</div>
|
|
|
|
<style>
|
|
.tray {
|
|
position: relative;
|
|
flex-shrink: 0;
|
|
}
|
|
.queue-btn:global(.bump) {
|
|
animation: queue-bump 320ms var(--ease-out);
|
|
}
|
|
@keyframes queue-bump {
|
|
40% {
|
|
transform: scale(1.06);
|
|
}
|
|
}
|
|
.queue-count {
|
|
display: none;
|
|
}
|
|
@media (max-width: 1179px) {
|
|
.queue-label {
|
|
display: none;
|
|
}
|
|
.queue-count {
|
|
display: inline;
|
|
}
|
|
}
|
|
.tray-row {
|
|
align-items: center;
|
|
}
|
|
.tray-copy {
|
|
display: flex;
|
|
flex-direction: column;
|
|
flex: 1;
|
|
min-width: 0;
|
|
line-height: 1.4;
|
|
}
|
|
.tray-meta {
|
|
font-size: var(--fs-mini);
|
|
color: var(--text-3);
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
.tray-note {
|
|
margin: 0;
|
|
padding: var(--sp-3) var(--sp-4) var(--sp-5);
|
|
font-size: var(--fs-aux);
|
|
color: var(--text-3);
|
|
}
|
|
.tray-all {
|
|
margin-top: var(--sp-1);
|
|
border-top: 1px solid var(--line);
|
|
border-radius: 0 0 var(--r-md) var(--r-md);
|
|
justify-content: center;
|
|
}
|
|
</style>
|