Files
aigc-home/calliope-web/src/lib/components/ToastHost.svelte
T
总工andmultica-agent 949cd2ecad HEL-654: D 批——记录流状态语义、金框结果切换、撤销删除与任务页重皮
- 点选金框滑动 + 检视区 150ms 交叉淡变;↑↓/J/K 即时切换、空格播放、
  Delete 删除、] 检视区、浮层让位;新记录入场/完成金光/失败抖动,减动效只余短淡变
- 单条删除 5 秒撤销(Toast 金色动作钮),窗口过后才提交 DELETE,离页 flush;
  任务页同队列同步;工作流删除保留旧记录并标识「工作流已删除」
- 红/琥珀界线:失败红 + 中文结论展开;done 但文件取不到 → 琥珀「文件缺失」
  + 用相同参数重做/移除记录
- 参数页提交自动切结果页;工作流选择器 ↑↓ 真高亮 + Enter 使用(ShellPop arrowRoving 开关)
- 记录流 80 条分页(220 条专项:50 次轮询 490ms);任务页 §3.5 芯片+搜索+
  行内进度条+ghost 重试;i18n 七语种 +17 键

Co-authored-by: multica-agent <github@multica.ai>
2026-09-30 13:02:51 +08:00

184 lines
3.9 KiB
Svelte

<script lang="ts">
import { onMount } from 'svelte';
import {
dismissToast,
pauseToast,
resumeToast,
subscribeToasts,
type Toast,
} from '$lib/toast';
import Icon from '$lib/components/ui/Icon.svelte';
import type { IconName } from '$lib/components/ui/icons';
import { t } from '$lib/i18n.svelte';
let items = $state<Toast[]>([]);
onMount(() => subscribeToasts((next) => (items = next)));
const kindIcon: Record<Toast['kind'], IconName> = {
success: 'check',
error: 'alert',
info: 'info',
};
</script>
{#if items.length}
<div class="toast-host" aria-live="polite" aria-relevant="additions">
{#each items as toast (toast.id)}
<div
class="toast {toast.kind}"
role="status"
onmouseenter={() => pauseToast(toast.id)}
onmouseleave={() => resumeToast(toast.id)}
onfocusin={() => pauseToast(toast.id)}
onfocusout={() => resumeToast(toast.id)}
>
<span class="badge" aria-hidden="true">
<span class="dot"></span>
<Icon name={kindIcon[toast.kind]} size={15} />
</span>
<span class="msg">{toast.message}</span>
{#if toast.action}
<button type="button" class="action" onclick={() => (toast.action?.run(), dismissToast(toast.id))}>
{toast.action.label}
</button>
{/if}
<button
type="button"
class="dismiss"
aria-label={t('toast.dismiss')}
onclick={() => dismissToast(toast.id)}
>
<Icon name="close" size={14} />
</button>
</div>
{/each}
</div>
{/if}
<style>
/* §四.5 Toast:右下角堆叠,220ms 上移入场;成功绿点 / 失败红点。 */
.toast-host {
position: fixed;
right: 24px;
bottom: 24px;
z-index: 1000;
display: flex;
flex-direction: column;
gap: 8px;
max-width: min(400px, calc(100vw - 32px));
pointer-events: none;
}
.toast {
pointer-events: auto;
display: flex;
align-items: flex-start;
gap: 10px;
padding: 12px 14px;
border-radius: var(--r-lg);
background: var(--float-bg);
box-shadow: var(--shadow-float);
animation: toast-in var(--d-enter) var(--ease-out);
}
.badge {
display: inline-flex;
align-items: center;
gap: 6px;
margin-top: 1px;
flex-shrink: 0;
}
.dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: currentColor;
}
.toast.success .badge {
color: var(--ok);
}
.toast.error .badge {
color: var(--err);
}
.toast.info .badge {
color: var(--text-2);
}
.msg {
flex: 1;
font-size: var(--fs-body);
line-height: 1.4;
color: var(--text-primary);
font-weight: 500;
}
/* §四.5: Toast 动作(如撤销)为金色文字 */
.action {
flex-shrink: 0;
align-self: center;
padding: var(--sp-1) var(--sp-2);
border: 0;
border-radius: var(--r-sm);
background: transparent;
color: var(--accent);
font: inherit;
font-size: var(--fs-aux);
font-weight: 600;
cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
.action:hover {
background: var(--accent-soft);
}
}
.action:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.dismiss {
display: inline-flex;
align-items: center;
justify-content: center;
border: none;
background: transparent;
color: var(--text-muted);
cursor: pointer;
padding: 0 2px;
min-width: 28px;
min-height: 28px;
border-radius: var(--r-sm);
}
@media (hover: hover) and (pointer: fine) {
.dismiss:hover {
color: var(--text-primary);
}
}
.dismiss:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
@keyframes toast-in {
from {
opacity: 0;
transform: translateY(8px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@media (prefers-reduced-motion: reduce) {
.toast {
animation: none;
}
}
:global(:root[data-reduce='1']) .toast {
animation: none;
}
@media (max-width: 760px) {
.toast-host {
bottom: calc(var(--tabbar-h) + var(--sp-5) + env(safe-area-inset-bottom));
right: 16px;
left: 16px;
max-width: none;
}
}
</style>