Files
qiqi fe1d3fcaa6 feat(image-vectorize): 顶栏「取消」改「关闭」并按主色调取色;补同步全屏到源码 v0.6.0
- ui.js: 顶栏最右按钮 data-act=cancel 文本「取消」→「关闭」,加 class vz-btn-close(行为不变)
- ui.css: 新增 .vz-btn-close 用编辑器主色调 #33566f(.vz-seg 选中态同款)填充 + #eaf6ff 文字,与左边三颗灰色产出按钮区分;hover/active 提亮
- ⚠ 重要修正:0.5.0 的全屏改动当时只改了产物 src/index.js,源码 plugin/ui.css 没同步(仍是 92vw 居中卡片)—— 若将来 build 会回退。本次把全屏(100vw×100vh、去圆角/阴影/边框)补进 plugin/ui.css 源码 + 重新 build 产物,源码与产物一致。
- version 0.5.0→0.6.0(package.json,build 注入 banner)
- build image-vectorize 通过,validate 10/10
2026-11-19 15:01:23 +08:00

527 lines
13 KiB
CSS

/* 位图转矢量:全屏模态。深色,与「标注 / 修图」同一套视觉语言。
CSP:由宿主 style-src 'unsafe-inline' 放行,运行时注入 <style>。 */
.vz-root {
position: fixed;
inset: 0;
z-index: 2147483000;
display: flex;
align-items: center;
justify-content: center;
background: rgba(10, 10, 14, 0.72);
font: 13px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
color: #e6e6ef;
}
.vz-modal {
display: flex;
flex-direction: column;
width: 100vw;
height: 100vh;
min-width: 0;
min-height: 0;
max-width: none;
background: #1b1b22;
border: 0;
border-radius: 0;
box-shadow: none;
overflow: hidden;
}
/* ---------- 顶栏 ---------- */
.vz-header {
display: flex;
align-items: center;
gap: 10px;
flex: 0 0 auto;
height: 52px;
padding: 0 14px;
background: #202029;
border-bottom: 1px solid #2e2e3a;
}
.vz-title {
font-size: 13px;
font-weight: 500;
color: #f0f0f7;
white-space: nowrap;
}
.vz-title em {
font-style: normal;
color: #8b8b9e;
font-weight: 400;
margin-left: 8px;
}
.vz-title em b {
color: #d6d6e4;
font-weight: 500;
}
.vz-spacer { flex: 1 1 auto; }
.vz-btn {
height: 32px;
padding: 0 14px;
border: 1px solid #3c3c4c;
border-radius: 7px;
background: #2a2a35;
color: #d8d8e4;
font-size: 12px;
cursor: pointer;
white-space: nowrap;
}
.vz-btn:hover { background: #34343f; border-color: #4a4a5c; }
.vz-btn:active { background: #2f2f3a; }
.vz-btn:disabled { opacity: 0.45; cursor: default; }
/* 顶栏「保存为节点 / 复制 SVG / 下载 SVG」三颗走上面这套灰色描边配色。
「关闭」单独用编辑器主色调(.vz-seg 选中态同款 #33566f)填充,与产出操作区分、防误点。
2026-11-19:原「取消」改名「关闭」并按主色调取色(行为不变,仍是 data-act="cancel" 退出编辑器)。 */
.vz-btn-close {
background: #33566f;
border-color: #33566f;
color: #eaf6ff;
}
.vz-btn-close:hover { background: #3d6480; border-color: #4a7394; }
.vz-btn-close:active { background: #2c4a60; }
/* ---------- 主体 ---------- */
.vz-body {
display: flex;
flex: 1 1 auto;
min-height: 0;
}
.vz-preview {
position: relative;
flex: 1 1 auto;
min-width: 0;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
overflow: hidden;
/* 预览区直接用白底,不铺透明棋盘:描摹结果默认就是「白纸上的单色图形」,
棋盘格既干扰判断形状,也让深色细笔画看起来发虚(实测用户第一反应是「糊」)。
矢量 SVG 本身仍不含背景矩形,导出/复制到 Figma 依旧是透明底。 */
background-color: #ffffff;
/* 缩放 / 平移的**唯一真源**:矢量图与原图两张 img 共用这套变量,
所以按住空格对比时,视图完全不动(各自存一份状态迟早会对不上)。
量纲:zoom 无单位;pan 是**屏幕像素**(先 scale 后 translate,平移量不被缩放放大)。 */
--vz-zoom: 1;
--vz-pan-x: 0px;
--vz-pan-y: 0px;
cursor: grab;
/* 触屏 / 触控板手势全部自己处理,别让浏览器抢去做页面滚动 */
touch-action: none;
}
.vz-preview.is-panning { cursor: grabbing; }
/* 白底之上用一圈极淡的描边 + 细阴影标出画面边界:
白底稿(如菜单/白底商品图)与预览区同色时,否则看不出图到哪里。
绝对定位 + 50%/50% 是为了让 transform 的中心锚点稳定落在预览区正中(缩放锚点计算依赖这一点);
max-* 用 calc(100% - 40px) 抵掉 .vz-preview 的 20px padding(百分比相对 padding box 算)。 */
.vz-stage {
position: absolute;
left: 50%;
top: 50%;
max-width: calc(100% - 40px);
max-height: calc(100% - 40px);
display: block;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.07);
transform:
translate(-50%, -50%)
translate(var(--vz-pan-x), var(--vz-pan-y))
scale(var(--vz-zoom));
transform-origin: 50% 50%;
/* 拖动时每帧改 transform,提前提层,避免整块重绘掉帧(最多两张图,内存代价可忽略) */
will-change: transform;
/* 拖动时别触发 img 的原生拖拽(会拽出一个半透明缩略图,手势直接断掉) */
user-select: none;
-webkit-user-drag: none;
}
.vz-stage[hidden] { display: none; }
/* 白底预览上的常驻小标签:浅色胶囊 + 细描边,深色版本在纯白画面里过于抢眼 */
.vz-badge {
position: absolute;
top: 14px;
left: 14px;
padding: 4px 9px;
border-radius: 6px;
background: rgba(255, 255, 255, 0.92);
border: 1px solid rgba(0, 0, 0, 0.1);
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
color: #55555f;
font-size: 11px;
letter-spacing: 0.2px;
}
.vz-hint {
position: absolute;
bottom: 14px;
left: 50%;
transform: translateX(-50%);
padding: 5px 11px;
border-radius: 999px;
background: rgba(255, 255, 255, 0.92);
border: 1px solid rgba(0, 0, 0, 0.1);
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
color: #55555f;
font-size: 11px;
pointer-events: none;
white-space: nowrap;
}
/* 缩放倍率:只有真的缩放过才出现(100% 时挂 hidden,不占视线)。
它同时是「现在没在 1:1」的唯一视觉信号 —— 用户放大看细节后容易忘记自己还缩着。 */
.vz-zoom {
position: absolute;
right: 14px;
bottom: 14px;
display: flex;
align-items: center;
gap: 6px;
padding: 4px 9px;
border-radius: 6px;
background: rgba(255, 255, 255, 0.94);
border: 1px solid rgba(0, 0, 0, 0.12);
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
color: #45454f;
font-size: 11px;
font-variant-numeric: tabular-nums;
cursor: pointer;
user-select: none;
}
.vz-zoom[hidden] { display: none; }
.vz-zoom b { font-weight: 600; }
.vz-zoom span { color: #9a9aa8; }
.vz-zoom:hover { border-color: rgba(0, 0, 0, 0.22); }
.vz-zoom:hover span { color: #45454f; }
/* 描摹中/出错的浮层 */
.vz-status {
position: absolute;
top: 14px;
right: 14px;
display: flex;
align-items: center;
gap: 8px;
padding: 5px 11px;
border-radius: 7px;
font-size: 11px;
background: rgba(18, 18, 24, 0.88);
border: 1px solid #33333f;
color: #b9b9cc;
}
.vz-status[hidden] { display: none; }
.vz-status.is-busy { color: #ffd08a; border-color: #5a4526; }
.vz-status.is-error { color: #ff9c9c; border-color: #5c2c2c; max-width: 60%; }
.vz-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: currentColor;
flex: 0 0 auto;
}
.vz-status.is-busy .vz-dot { animation: vz-pulse 1s ease-in-out infinite; }
@keyframes vz-pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
/* ---------- 参数面板 ---------- */
.vz-panel {
flex: 0 0 auto;
width: 312px;
padding: 12px 15px 14px;
background: #1e1e26;
border-left: 1px solid #2e2e3a;
overflow-y: auto;
}
.vz-panel::-webkit-scrollbar { width: 8px; }
.vz-panel::-webkit-scrollbar-thumb { background: #3a3a48; border-radius: 4px; }
/* 组间距比「看着舒服」再紧一点:高级参数默认展开(用户要求),
六组内容在 88vh 里要刚好放得下,否则最后一行「填充 / 背景」会贴着底边被裁 */
.vz-group + .vz-group { margin-top: 12px; padding-top: 10px; border-top: 1px solid #2b2b36; }
.vz-group-title {
font-size: 11px;
color: #7e7e94;
letter-spacing: 0.6px;
margin-bottom: 9px;
text-transform: none;
}
/* 预设 */
.vz-presets {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
}
.vz-preset {
display: flex;
flex-direction: column;
gap: 2px;
padding: 7px 9px;
border: 1px solid #37374a;
border-radius: 8px;
background: #262631;
color: #d5d5e2;
font-size: 12px;
text-align: left;
cursor: pointer;
}
.vz-preset small {
color: #7b7b91;
font-size: 10px;
line-height: 1.35;
}
.vz-preset:hover { background: #2e2e3b; border-color: #45455a; }
.vz-preset.active {
background: #1f3a30;
border-color: #2f7d5b;
color: #d8ffe9;
}
.vz-preset.active small { color: #79b79b; }
/* 分段控件 */
.vz-row { margin-bottom: 8px; }
/* 按模式隐藏的行(层数只在灰度、阈值只在手动)必须真的消失。
踩过的坑:flex/块级元素上加 `hidden` 属性,如果 CSS 里另有 display 声明就会失效,
于是「隐藏」只变成视觉上还在 —— 这里直接 !important 兜住所有形态。 */
.vz-row[hidden] { display: none !important; }
.vz-row:last-child { margin-bottom: 0; }
.vz-row-label {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 12px;
color: #b6b6c8;
margin-bottom: 6px;
}
.vz-row-label span { color: #6f6f85; font-size: 11px; }
.vz-seg {
display: flex;
gap: 0;
border: 1px solid #3a3a4a;
border-radius: 7px;
overflow: hidden;
}
.vz-seg button {
flex: 1 1 0;
height: 28px;
border: 0;
border-right: 1px solid #3a3a4a;
background: #24242e;
color: #a8a8bd;
font-size: 11.5px;
cursor: pointer;
white-space: nowrap;
}
.vz-seg button:last-child { border-right: 0; }
.vz-seg button:hover { background: #2c2c38; color: #d0d0e0; }
.vz-seg button.active { background: #33566f; color: #eaf6ff; }
/* 滑杆 */
.vz-range {
display: flex;
align-items: center;
gap: 9px;
}
.vz-range input[type="range"] {
flex: 1 1 auto;
min-width: 0;
height: 4px;
-webkit-appearance: none;
appearance: none;
background: #3a3a4a;
border-radius: 2px;
outline: none;
}
.vz-range input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 13px;
height: 13px;
border-radius: 50%;
background: #cfcfdd;
border: 0;
cursor: pointer;
}
.vz-range input[type="range"]:disabled { opacity: 0.4; }
.vz-range input[type="range"]:disabled::-webkit-slider-thumb { cursor: default; }
.vz-range-val {
flex: 0 0 auto;
min-width: 34px;
text-align: right;
font-size: 11.5px;
color: #d0d0e0;
font-variant-numeric: tabular-nums;
}
/* 高级参数折叠:首屏只露高频项,低频参数收起来但一档可达 */
.vz-adv-toggle {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
height: 30px;
padding: 0 10px;
border: 1px solid #37374a;
border-radius: 7px;
background: #24242e;
color: #a8a8bd;
font-size: 11.5px;
cursor: pointer;
}
.vz-adv-toggle:hover { background: #2c2c38; color: #d0d0e0; }
.vz-adv-toggle span { color: #6f6f85; }
/* 单色填充色(仅「纯单色」生效)。原生 color input 在深色面板里默认边框很亮,
去掉内边距与外框,只留一块颜色本身,和滑杆行视觉一致 */
.vz-color {
flex: 0 0 auto;
width: 42px;
height: 22px;
padding: 0;
border: 1px solid #45455a;
border-radius: 6px;
background: transparent;
cursor: pointer;
}
.vz-color::-webkit-color-swatch-wrapper { padding: 2px; }
.vz-color::-webkit-color-swatch { border: none; border-radius: 4px; }
.vz-color:disabled { cursor: default; }
/* 填充 / 背景并排(用户要求放一排)+ 「带底」小勾选。
色块从 42px 收到 34px,两个并排仍能塞进 312px 面板且不挤掉标签。 */
.vz-swatches {
display: flex;
align-items: center;
gap: 6px;
flex: 0 0 auto;
}
.vz-swatches .vz-color { width: 34px; }
.vz-mini {
display: inline-flex;
align-items: center;
gap: 4px;
height: 22px;
padding: 0 6px;
border: 1px solid #3c3c4c;
border-radius: 6px;
background: #24242e;
color: #a8a8bd;
font-size: 11px;
white-space: nowrap;
cursor: pointer;
}
.vz-mini:hover { border-color: #4a4a5c; color: #d0d0e0; }
.vz-mini input {
width: 11px;
height: 11px;
margin: 0;
accent-color: #2f9c69;
cursor: pointer;
}
/* 勾选开关(按孤岛拆分):原生 checkbox 在深色面板里太小、且难以点中。
用 label 包一层,点整块都能切换;focus-visible 保留键盘可达的焦点环。 */
.vz-row-switch {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.vz-row-text {
display: flex;
flex-direction: column;
gap: 3px;
min-width: 0;
font-size: 12px;
color: #b6b6c8;
}
.vz-row-text span {
color: #6f6f85;
font-size: 10.5px;
line-height: 1.4;
}
.vz-switch {
position: relative;
flex: 0 0 auto;
width: 34px;
height: 20px;
cursor: pointer;
}
.vz-switch input {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
margin: 0;
opacity: 0;
cursor: pointer;
}
.vz-switch i {
position: absolute;
inset: 0;
border-radius: 999px;
background: #3a3a4a;
transition: background 0.15s ease;
pointer-events: none;
}
.vz-switch i::after {
content: '';
position: absolute;
top: 2px;
left: 2px;
width: 16px;
height: 16px;
border-radius: 50%;
background: #b9b9c9;
transition: transform 0.15s ease, background 0.15s ease;
}
.vz-switch input:checked + i { background: #2f7d5b; }
.vz-switch input:checked + i::after { transform: translateX(14px); background: #ffffff; }
.vz-switch input:focus-visible + i { box-shadow: 0 0 0 2px rgba(90, 200, 160, 0.45); }
.vz-adv { margin-top: 10px; }
.vz-adv[hidden] { display: none; }
/* 统计 */
.vz-stats {
display: flex;
gap: 14px;
flex-wrap: wrap;
font-size: 11.5px;
color: #8f8fa4;
}
.vz-stats b { color: #d8d8e6; font-weight: 500; }
.vz-note {
margin-top: 9px;
font-size: 10.5px;
line-height: 1.55;
color: #6b6b80;
}
/* 窄屏:面板转到底部 */
@media (max-width: 900px) {
.vz-modal { width: 100vw; height: 100vh; min-width: 0; }
.vz-body { flex-direction: column; }
.vz-panel { width: auto; max-height: 46%; border-left: 0; border-top: 1px solid #2e2e3a; }
}