Files
aigc-home/calliope-web/src/lib/components/agent/WorkflowMentionMenu.svelte
T
总工andmultica-agent d882fd62d8 feat(ui): F批——其余页面融合收口与整站规范统一 (HEL-656)
- 移除 Calliope 旧壳死代码:/project/[id] 旧四段编辑器页面与 9 个遗留组件
  (NavRail/StoryStage/AssetsStage/ScriptStage/QueueStage/ActivityPanel/
  JobRow/AssetThumb/ProjectCard),/projects 死页面(308→/ 已有)
- 素材库 /library 迁入 AppShell 新壳:a-chip 筛选、ui/Modal、ConfirmDialog
  实心红两级删除、窄屏单列;移除 A 时期 308→/ 重定向;导航轨/更多菜单新增入口
- 智能体子系统去杂色:agentPalette 默认紫→中性、回退色板收敛为 avatar 五色族;
  AgentChat 气泡按 §3.2/3.6(用户 bg-3/Agent bg-2+line)、进行中指示改青、
  紫色空态图标清除;AgentComposer 天蓝/金芯片收敛
- 首页/工作台/五面板/StageStepper/PromptBlock/JobChip 类名收敛到全局 a-btn/
  a-input/a-tag/field;Stepper 补金色当前下划+已确认✓;镜头序号按规范用
  accent-lo+mono;分页/工作台选择页金色越界改中性或青
- 金色纪律修正:次级文字操作(重试/测试/链接)与必填星标、任务「测试」标签
  去金色;「默认」金标签按 §3.9 保留
- 断点收敛:1023/1279/900/780/700/640 → 1180/760(1440 增强保留)
- canvas/build-scene 可用级 ≤760 纵向堆叠适配 + 硬编码色/旧 fallback 清理;
  AppHeader 去 Calliope 品牌与死链
- favicon 收口:static/favicon.png 金色品牌图标,移除 204 stub 与构建豁免
- i18n 七语种 +3 key(shell.navLibrary/library.loadError/library.subtitle)全对齐
- 新增 e2e/fpages.mjs:F 页面三档走查/重定向/五段导入编辑/规范色断言 38 项

Co-authored-by: multica-agent <github@multica.ai>
2026-09-30 16:29:47 +08:00

196 lines
4.5 KiB
Svelte

<script lang="ts">
import { t } from '$lib/i18n.svelte';
interface MenuItem {
id?: number;
name: string;
kind?: string;
description?: string | null;
}
interface Props {
open: boolean;
items: MenuItem[];
activeIndex: number;
/** Caret / `@` viewport box — menu opens above this (composer is bottom-docked). */
anchor: { top: number; bottom: number; left: number };
/** When set, the list is replaced with this explanation (one-workflow guardrail). */
lockReason?: string | null;
/** Skill mode: rows show `/name` + a description subtitle, no kind chip. */
skillMode?: boolean;
onSelect: (item: any) => void;
onHover: (index: number) => void;
}
let {
open,
items,
activeIndex,
anchor,
lockReason = null,
skillMode = false,
onSelect,
onHover,
}: Props = $props();
let menuEl = $state<HTMLDivElement | null>(null);
let pos = $state({ top: 0, left: 0, maxHeight: 280 });
let placed = $state(false);
const GAP = 6;
const PAD = 8;
const MENU_MAX = 280;
function placeMenu() {
if (!menuEl) return;
const h = Math.min(menuEl.scrollHeight || 40, MENU_MAX);
const spaceAbove = anchor.top - GAP - PAD;
const spaceBelow = window.innerHeight - anchor.bottom - GAP - PAD;
// Bottom-docked composer: prefer above the `@` unless there is no room.
const openUp = spaceAbove >= Math.min(h, 80) || spaceAbove >= spaceBelow;
const maxHeight = Math.max(80, Math.min(MENU_MAX, openUp ? spaceAbove : spaceBelow));
const used = Math.min(h, maxHeight);
let top = openUp ? anchor.top - used - GAP : anchor.bottom + GAP;
let left = anchor.left;
left = Math.max(PAD, Math.min(left, window.innerWidth - 280 - PAD));
top = Math.max(PAD, Math.min(top, window.innerHeight - used - PAD));
pos = { top, left, maxHeight };
placed = true;
}
$effect(() => {
if (!open || !menuEl) return;
document.body.appendChild(menuEl);
return () => {
menuEl?.remove();
};
});
$effect(() => {
if (!open) {
placed = false;
return;
}
if (!menuEl) return;
void items.length;
void lockReason;
void anchor.top;
void anchor.left;
void anchor.bottom;
requestAnimationFrame(placeMenu);
});
</script>
{#if open}
<div
bind:this={menuEl}
class="mention-menu"
style="top: {pos.top}px; left: {pos.left}px; max-height: {pos.maxHeight}px; visibility: {placed
? 'visible'
: 'hidden'}"
role="listbox"
aria-label={skillMode ? t('mentionMenu.skills') : t('mentionMenu.workflows')}
>
{#if lockReason}
<div class="empty">{lockReason}</div>
{:else if items.length === 0}
<div class="empty">{skillMode ? t('mentionMenu.noSkill') : t('mentionMenu.noWorkflow')}</div>
{:else}
{#each items as item, i (item.id ?? item.name)}
<button
type="button"
class="item"
class:active={i === activeIndex}
role="option"
aria-selected={i === activeIndex}
onmousedown={(e) => {
e.preventDefault();
onSelect(item);
}}
onmouseenter={() => onHover(i)}
>
<span class="text">
<span class="name">{skillMode ? `/${item.name}` : item.name}</span>
{#if skillMode && item.description}
<span class="desc">{item.description}</span>
{/if}
</span>
{#if !skillMode}
<span class="kind">{item.kind}</span>
{/if}
</button>
{/each}
{/if}
</div>
{/if}
<style>
.mention-menu {
position: fixed;
z-index: 10000;
min-width: 240px;
max-width: 360px;
max-height: 280px;
overflow-y: auto;
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: var(--radius-md);
box-shadow: var(--shadow-float);
padding: 4px;
}
.empty {
padding: 10px 12px;
font-size: 13px;
color: var(--text-muted);
}
.item {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
width: 100%;
padding: 8px 12px;
border: none;
border-radius: var(--radius-sm);
background: transparent;
color: var(--text-primary);
font-size: 13px;
font-family: inherit;
cursor: pointer;
text-align: left;
}
.item:hover,
.item.active {
background: var(--bg-elevated);
}
.item.active .name {
color: var(--accent);
}
.text {
display: flex;
flex-direction: column;
gap: 2px;
min-width: 0;
}
.name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-weight: 500;
}
.desc {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 11px;
color: var(--text-muted);
}
.kind {
flex-shrink: 0;
font-size: 11px;
color: var(--text-muted);
text-transform: uppercase;
letter-spacing: 0.04em;
}
</style>