- 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>
128 lines
3.3 KiB
Svelte
128 lines
3.3 KiB
Svelte
<script lang="ts">
|
|
import { createQuery } from '@tanstack/svelte-query';
|
|
import { toStore } from 'svelte/store';
|
|
import { projects } from '$lib/api';
|
|
import { parseDbTs } from '$lib/dbtime';
|
|
import { t } from '$lib/i18n.svelte';
|
|
import Icon from '$lib/components/ui/Icon.svelte';
|
|
import ShellPop from './ShellPop.svelte';
|
|
|
|
/**
|
|
* 顶栏范围胶囊 — the project picker that replaced the old sidebar project
|
|
* entry: shows the project the page belongs to (or 全部项目) and lists
|
|
* recent projects, each opening its five-stage workbench.
|
|
*/
|
|
interface Props {
|
|
projectId: number | null;
|
|
onProjectsList: boolean;
|
|
}
|
|
|
|
let { projectId, onProjectsList }: Props = $props();
|
|
|
|
const RECENT_LIMIT = 8;
|
|
let open = $state(false);
|
|
|
|
const projectsQuery = createQuery(
|
|
toStore(() => ({
|
|
queryKey: ['projects'],
|
|
queryFn: projects.list,
|
|
enabled: open || projectId != null,
|
|
staleTime: 30_000,
|
|
})),
|
|
);
|
|
|
|
const all = $derived($projectsQuery.data ?? []);
|
|
const current = $derived(projectId == null ? null : (all.find((p) => p.id === projectId) ?? null));
|
|
const recent = $derived(
|
|
[...all]
|
|
.sort((a, b) => (parseDbTs(b.updated_at) || 0) - (parseDbTs(a.updated_at) || 0))
|
|
.slice(0, RECENT_LIMIT),
|
|
);
|
|
</script>
|
|
|
|
<div class="scope">
|
|
<button
|
|
type="button"
|
|
class="status-chip scope-btn"
|
|
aria-haspopup="dialog"
|
|
aria-expanded={open}
|
|
title={t('shell.scopeHint')}
|
|
onclick={() => (open = !open)}
|
|
>
|
|
<span class="scope-label">{current?.title ?? t('shell.scopeAll')}</span>
|
|
<Icon name="chevron-down" size={12} />
|
|
</button>
|
|
|
|
<ShellPop bind:open label={t('shell.scopeHint')} width="300px">
|
|
<a
|
|
class="a-menu-item"
|
|
href="/"
|
|
aria-current={onProjectsList ? 'page' : undefined}
|
|
onclick={() => (open = false)}
|
|
>
|
|
<Icon name="folder" size={15} />
|
|
<span class="a-menu-label">{t('shell.scopeAllList')}</span>
|
|
{#if all.length > 0}<span class="a-menu-meta mono">{all.length}</span>{/if}
|
|
</a>
|
|
<div class="a-menu-group">{t('shell.scopeRecent')}</div>
|
|
{#if $projectsQuery.isPending}
|
|
<p class="scope-note">{t('common.loading')}…</p>
|
|
{:else if $projectsQuery.isError}
|
|
<p class="scope-note err">{t('shell.scopeLoadFailed')}</p>
|
|
{:else if recent.length === 0}
|
|
<a class="a-menu-item" href="/" onclick={() => (open = false)}>
|
|
<Icon name="plus" size={15} />
|
|
<span class="a-menu-label">{t('shell.scopeEmpty')}</span>
|
|
</a>
|
|
{:else}
|
|
{#each recent as project (project.id)}
|
|
<a
|
|
class="a-menu-item"
|
|
href="/workbench/{project.id}"
|
|
aria-current={project.id === projectId ? 'true' : undefined}
|
|
onclick={() => (open = false)}
|
|
>
|
|
<Icon name="story" size={15} />
|
|
<span class="a-menu-label">{project.title}</span>
|
|
{#if project.stats}
|
|
<span class="a-menu-meta">
|
|
{t('shell.scopeStage', { n: project.stats.stage_confirmed })}
|
|
</span>
|
|
{/if}
|
|
</a>
|
|
{/each}
|
|
{/if}
|
|
</ShellPop>
|
|
</div>
|
|
|
|
<style>
|
|
.scope {
|
|
position: relative;
|
|
display: flex;
|
|
flex-shrink: 0;
|
|
}
|
|
.scope-btn {
|
|
max-width: 220px;
|
|
gap: var(--sp-1);
|
|
}
|
|
.scope-label {
|
|
min-width: 0;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
.scope-note {
|
|
margin: 0;
|
|
padding: var(--sp-3) var(--sp-4);
|
|
font-size: var(--fs-aux);
|
|
color: var(--text-3);
|
|
}
|
|
.scope-note.err {
|
|
color: var(--err);
|
|
}
|
|
@media (max-width: 760px) {
|
|
.scope-btn {
|
|
max-width: 132px;
|
|
}
|
|
}
|
|
</style>
|