Files
cover-studio/src/components/ContextMenu.vue
T
Jz0ojiang 8934f374bb feat: Figma 式外壳与编辑器内核
布局改成 顶部工具栏 / 左图层 / 中画布 / 右属性 / 底部悬浮胶囊。

新内核:
- 图层模型:fabric 对象是唯一真源,LayerInfo 是只读投影;
  id/名字/锁定挂在 customProperties 上,随 toJSON 持久化
- 视口:zoom/pan 走 viewportTransform,只影响显示;
  导出改为按视口裁剪(artboardExportOptions),旧的「multiplier 恒为 1」
  在画布铺满工作区之后不再成立
- 历史:快照式撤销重做,30 步上限,带重入保护
- 命令表:快捷键 / 右键菜单 / 工具栏三个入口共用一份注册表
  键位取自 Penpot 快捷键表
- 画板用 backgroundImage 画(跟随视口且不进 getObjects)

两个 fabric 陷阱已在注释里记下:
- Rect 默认原点是中心,left:0/top:0 不写 originX/originY 会画错位置
- canvas.clipPath 不吃 viewportTransform,不能用来裁画板
2026-09-05 02:18:20 +08:00

33 lines
1.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
/**
* 【T9 待实现 — 右键上下文菜单】
*
* 开合与位置在 `@/editor/useContextMenu`(坐标相对画布区左上角)。
* 菜单内容读 `CANVAS_CONTEXT_MENU`(`@/editor/commands`),每项指向一条命令:
* 标题用 `command.label`,右侧灰字用 `keyHintOf(id)`(`@/editor/useShortcuts`),
* `command.enabled()` 为 false 时置灰不可点,点击走 `runCommand(id)`。
*
* **不要在这里自己写删除/层序的逻辑**——那些都在命令表里,
* 快捷键和工具栏走的是同一条,抄一份必然走偏。
*
* 要处理:点菜单外或按 Esc 关闭;贴近视口边缘时翻转,不要被裁掉。
*/
</script>
<template>
<div v-if="false" class="context-menu">T9 待实现</div>
</template>
<style scoped>
.context-menu {
position: absolute;
min-width: 180px;
padding: 4px;
border: 1px solid var(--line);
border-radius: 8px;
background: var(--bg3);
box-shadow: 0 8px 28px rgb(0 0 0 / 0.5);
z-index: 10;
}
</style>