Files
nj/docs/opendesign/screens/tablet/editor.html
iven b320641d9c
Some checks failed
Main Merge / backend (push) Has been cancelled
Main Merge / frontend (push) Has been cancelled
fix(app): 全链路验证修复 — 编译错误/CORS/迁移/启动脚本
前端修复:
- calendar_page: 移除不存在的 JournalEntry.content getter
- responsive_scaffold: 移除不存在的 notchThickness 参数
- splash_page: SingleTickerProvider → TickerProvider (多 AnimationController)
- profile_page: UserRoleType.name → .code (修复运行时崩溃)
- 导入缺失的 user.dart

后端修复:
- class_service: generate_class_code 取 UUID 后6位(随机部分)避免碰撞
- diary_role_seed: 移除不存在的 id 列,使用复合主键 ON CONFLICT

基础设施:
- config/default.toml: CORS 改为通配符(开发模式)
- scripts/dev.sh: 统一启动脚本(自动清理端口)
- docs/opendesign/: Open Design 设计规格 HTML 原型稿

验证结果: flutter analyze 0 error, cargo test 77/77 通过, 17个页面全部渲染正常
2026-06-02 01:03:58 +08:00

893 lines
31 KiB
HTML

<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=1024, height=768, initial-scale=1">
<title>暖记 — 平板端编辑器</title>
<link rel="stylesheet" href="../css/tokens.css">
<link rel="stylesheet" href="../css/components.css">
<link rel="stylesheet" href="../css/editor-common.css">
<link rel="stylesheet" href="shared.css">
<style>
body {
width: 1024px;
height: 768px;
overflow: hidden;
background: var(--bg);
font-family: var(--font-body);
}
/* Editor layout: sidebar + canvas + side panel */
.editor-layout {
display: flex;
height: 768px;
}
.sidebar { position: relative; flex-shrink: 0; }
.editor-main {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
}
/* Top bar */
.editor-topbar {
height: 56px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 var(--space-6);
background: var(--surface);
border-bottom: 1px solid var(--border-soft);
flex-shrink: 0;
}
.topbar-left, .topbar-right {
display: flex;
align-items: center;
gap: var(--space-3);
}
.topbar-btn {
width: 38px;
height: 38px;
border-radius: var(--radius-pill);
border: none;
background: none;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
color: var(--fg);
transition: background var(--motion-fast);
}
.topbar-btn:hover { background: var(--surface-warm); }
.topbar-btn svg { width: 20px; height: 20px; }
.topbar-center {
font-family: var(--font-display);
font-size: var(--text-base);
font-weight: 600;
color: var(--fg-2);
}
.save-btn {
padding: 10px 24px;
background: var(--accent);
color: var(--accent-on);
border: none;
border-radius: var(--radius-pill);
font-family: var(--font-display);
font-size: var(--text-sm);
font-weight: 600;
cursor: pointer;
transition: all var(--motion-fast);
}
.save-btn:hover { background: var(--accent-hover); }
/* Undo/Redo */
.topbar-undo-redo {
display: flex;
align-items: center;
gap: 2px;
}
.undo-btn, .redo-btn {
width: 34px;
height: 34px;
border-radius: var(--radius-pill);
border: none;
background: none;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
color: var(--muted);
transition: all var(--motion-fast);
}
.undo-btn:hover:not(:disabled), .redo-btn:hover:not(:disabled) { background: var(--surface-warm); color: var(--fg); }
.undo-btn:disabled, .redo-btn:disabled { opacity: 0.35; cursor: default; }
.undo-btn svg, .redo-btn svg { width: 18px; height: 18px; }
/* Auto-save */
.autosave-status {
display: flex;
align-items: center;
gap: 5px;
font-size: 11px;
color: var(--success);
font-weight: 500;
}
.autosave-dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--success);
}
/* Canvas + Panel split */
.editor-body {
flex: 1;
display: flex;
overflow: hidden;
}
/* Canvas area */
.canvas-wrapper {
flex: 1;
padding: var(--space-6);
overflow-y: auto;
scrollbar-width: thin;
scrollbar-color: var(--border) transparent;
}
.canvas-wrapper::-webkit-scrollbar { width: 4px; }
.canvas-wrapper::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.canvas-paper {
max-width: 640px;
margin: 0 auto;
background: var(--surface);
border-radius: var(--radius-md);
box-shadow: var(--elev-medium);
border: 1px solid var(--border-soft);
padding: var(--space-8);
min-height: 600px;
position: relative;
}
.canvas-grid {
position: absolute;
inset: 0;
background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
background-size: 28px 28px;
opacity: 0.4;
pointer-events: none;
border-radius: var(--radius-md);
}
.washi-tape {
position: absolute;
top: 16px;
right: 40px;
width: 110px;
height: 22px;
background: repeating-linear-gradient(45deg, var(--tertiary), var(--tertiary) 4px, var(--surface-warm) 4px, var(--surface-warm) 8px);
transform: rotate(-8deg);
border-radius: 2px;
opacity: 0.8;
}
.placed-sticker {
position: absolute;
font-size: 36px;
cursor: move;
filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}
.journal-content { position: relative; z-index: 1; }
.journal-title {
font-family: var(--font-display);
font-size: var(--text-2xl);
font-weight: 700;
color: var(--fg);
margin-bottom: var(--space-4);
border: none;
outline: none;
width: 100%;
background: transparent;
}
.format-bar {
display: flex;
align-items: center;
gap: var(--space-2);
padding: var(--space-2) 0;
margin-bottom: var(--space-4);
border-bottom: 1px solid var(--border-soft);
}
.format-btn {
width: 34px;
height: 34px;
border-radius: 6px;
border: none;
background: none;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
color: var(--muted);
font-size: var(--text-sm);
font-weight: 600;
transition: all var(--motion-fast);
}
.format-btn:hover { background: var(--surface-warm); color: var(--fg); }
.format-btn.active { background: var(--accent); color: var(--accent-on); }
.format-divider { width: 1px; height: 22px; background: var(--border); }
.color-dot {
width: 26px;
height: 26px;
border-radius: 50%;
border: 2px solid transparent;
cursor: pointer;
transition: all var(--motion-fast);
}
.color-dot:hover { transform: scale(1.15); }
.color-dot.active { border-color: var(--fg); }
.journal-body {
font-size: var(--text-base);
line-height: 1.9;
color: var(--fg-2);
border: none;
outline: none;
width: 100%;
background: transparent;
resize: none;
min-height: 240px;
}
.placed-photo {
width: 100%;
height: 160px;
border-radius: var(--radius-sm);
background: linear-gradient(135deg, var(--secondary-soft), var(--secondary-soft));
margin: var(--space-5) 0;
display: flex;
align-items: center;
justify-content: center;
}
/* Right panel */
.tool-panel-side {
width: 320px;
background: var(--surface);
border-left: 1px solid var(--border-soft);
overflow-y: auto;
scrollbar-width: thin;
flex-shrink: 0;
}
.tool-panel-side::-webkit-scrollbar { width: 4px; }
.tool-panel-side::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.panel-header {
padding: var(--space-5);
border-bottom: 1px solid var(--border-soft);
display: flex;
align-items: center;
gap: var(--space-3);
}
.panel-tab {
padding: 8px 16px;
border-radius: var(--radius-pill);
font-size: var(--text-sm);
font-weight: 500;
background: var(--surface-warm);
color: var(--fg-2);
border: none;
cursor: pointer;
white-space: nowrap;
transition: all var(--motion-fast);
}
.panel-tab.active { background: var(--accent); color: var(--accent-on); }
.panel-content {
padding: var(--space-5);
}
.sticker-grid {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: var(--space-3);
}
.sticker-item {
aspect-ratio: 1;
border-radius: var(--radius-sm);
background: var(--surface-warm);
display: flex;
align-items: center;
justify-content: center;
font-size: 28px;
cursor: pointer;
transition: all var(--motion-fast) var(--ease-bounce);
border: 1px solid transparent;
}
.sticker-item:hover { transform: scale(1.1); border-color: var(--accent); }
.date-strip {
display: flex;
align-items: center;
justify-content: space-between;
padding: var(--space-3) var(--space-6);
background: var(--surface);
border-bottom: 1px solid var(--border-soft);
flex-shrink: 0;
}
.date-info {
display: flex;
align-items: center;
gap: var(--space-2);
font-size: var(--text-sm);
color: var(--muted);
}
.date-info strong { color: var(--fg); font-weight: 600; }
.mood-quick { display: flex; gap: 6px; }
.mood-mini {
width: 30px;
height: 30px;
border-radius: 50%;
border: 1.5px solid var(--border);
display: flex;
align-items: center;
justify-content: center;
font-size: 15px;
background: var(--surface);
cursor: pointer;
transition: all var(--motion-fast);
}
.mood-mini.selected { border-color: var(--accent); background: var(--surface-warm); }
/* Brush tool panel */
.brush-section-title {
font-size: var(--text-xs);
font-weight: 600;
color: var(--muted);
text-transform: uppercase;
letter-spacing: 0.5px;
margin-bottom: var(--space-3);
}
.brush-tools-list {
display: flex;
flex-direction: column;
gap: var(--space-2);
margin-bottom: var(--space-5);
}
.brush-tool-item {
display: flex;
align-items: center;
gap: var(--space-3);
padding: var(--space-2) var(--space-3);
border-radius: var(--radius-sm);
border: 2px solid transparent;
background: none;
cursor: pointer;
color: var(--muted);
transition: all var(--motion-fast);
width: 100%;
}
.brush-tool-item:hover { background: var(--surface-warm); color: var(--fg); }
.brush-tool-item.active { border-color: var(--accent); color: var(--accent); background: var(--surface-warm); }
.brush-tool-item svg { width: 22px; height: 22px; flex-shrink: 0; }
.brush-tool-item span { font-size: var(--text-sm); font-weight: 500; }
.brush-size-preview {
display: flex;
align-items: center;
justify-content: center;
height: 32px;
background: var(--surface-warm);
border-radius: var(--radius-sm);
margin-bottom: var(--space-2);
}
.brush-size-line {
width: 80%;
border-radius: 4px;
background: var(--fg);
transition: height var(--motion-fast);
}
.brush-size-row {
display: flex;
align-items: center;
gap: var(--space-3);
margin-bottom: var(--space-5);
}
.brush-size-value {
font-size: var(--text-sm);
font-weight: 600;
color: var(--fg);
min-width: 36px;
text-align: right;
}
.brush-slider {
flex: 1;
-webkit-appearance: none;
appearance: none;
height: 4px;
border-radius: 2px;
background: var(--border);
outline: none;
}
.brush-slider::-webkit-slider-thumb {
-webkit-appearance: none;
width: 18px;
height: 18px;
border-radius: 50%;
background: var(--accent);
cursor: pointer;
box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.brush-colors-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: var(--space-3);
margin-bottom: var(--space-5);
}
.brush-color-dot {
width: 100%;
aspect-ratio: 1;
border-radius: 50%;
border: 3px solid transparent;
cursor: pointer;
transition: all var(--motion-fast);
}
.brush-color-dot:hover { transform: scale(1.1); }
.brush-color-dot.active { border-color: var(--fg); box-shadow: 0 0 0 2px var(--surface); }
.brush-opacity-row {
display: flex;
align-items: center;
gap: var(--space-3);
transition: opacity var(--motion-fast);
}
.brush-opacity-row.disabled { opacity: 0.35; pointer-events: none; }
.brush-opacity-label {
font-size: var(--text-xs);
color: var(--muted);
font-weight: 500;
min-width: 40px;
}
.brush-opacity-value {
font-size: var(--text-sm);
font-weight: 600;
color: var(--fg);
min-width: 36px;
text-align: right;
}
/* Tags panel */
.tags-section {
margin-bottom: var(--space-5);
}
.tags-section-title {
font-size: var(--text-xs);
font-weight: 600;
color: var(--muted);
text-transform: uppercase;
letter-spacing: 0.5px;
margin-bottom: var(--space-3);
}
.tag-selected-area {
display: flex;
flex-wrap: wrap;
gap: var(--space-2);
min-height: 36px;
}
.tag-pill {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 4px 12px;
border-radius: 9999px;
background: var(--surface-warm);
color: var(--accent);
font-size: 13px;
font-weight: 500;
}
.tag-pill .remove {
width: 16px;
height: 16px;
border-radius: 50%;
background: var(--accent);
color: var(--surface);
display: flex;
align-items: center;
justify-content: center;
font-size: 10px;
cursor: pointer;
border: none;
line-height: 1;
transition: background var(--motion-fast);
}
.tag-pill .remove:hover { background: var(--accent-hover); }
.tag-input-row {
display: flex;
}
.tag-input {
flex: 1;
height: 44px;
border: 1.5px solid var(--border);
border-radius: var(--radius-pill);
padding: 0 var(--space-4);
font-size: var(--text-sm);
color: var(--fg);
background: var(--bg);
outline: none;
transition: border-color var(--motion-fast);
font-family: var(--font-body);
}
.tag-input::placeholder { color: var(--meta); }
.tag-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--shadow-input-focus); }
.tag-suggest-grid {
display: flex;
flex-wrap: wrap;
gap: var(--space-2);
}
.tag-suggest-item {
display: inline-flex;
align-items: center;
padding: 6px 14px;
border-radius: 9999px;
background: var(--surface-warm);
color: var(--fg-2);
font-size: var(--text-sm);
font-weight: 500;
border: 1px solid transparent;
cursor: pointer;
white-space: nowrap;
min-height: 44px;
transition: all var(--motion-fast);
}
.tag-suggest-item:hover { border-color: var(--accent); color: var(--accent); }
</style>
</head>
<body>
<div class="editor-layout">
<!-- Sidebar -->
<nav class="sidebar" role="navigation" aria-label="主导航">
<div class="sidebar-brand">
<div class="sidebar-logo">📖</div>
<div>
<div class="sidebar-brand-text">暖记</div>
<div class="sidebar-brand-sub">Warm Notes</div>
</div>
</div>
<div class="sidebar-nav">
<button class="sidebar-nav-item">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M3 9l9-7 9 7v11a2 2 0 01-2 2H5a2 2 0 01-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg>
首页
</button>
<button class="sidebar-nav-item">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><rect x="3" y="4" width="18" height="18" rx="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>
日历
</button>
<button class="sidebar-nav-item">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M20.84 4.61a5.5 5.5 0 00-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 00-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 000-7.78z"/></svg>
心情追踪
</button>
</div>
<div class="sidebar-footer">
<div class="sidebar-avatar">🐱</div>
<div>
<div class="sidebar-user-name">小暖</div>
<div class="sidebar-user-streak">连续记录 12 天</div>
</div>
</div>
</nav>
<div class="editor-main">
<!-- Top bar -->
<div class="editor-topbar">
<div class="topbar-left">
<button class="topbar-btn" aria-label="返回">
<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M15 18l-6-6 6-6"/></svg>
</button>
</div>
<div class="topbar-center">5月31日 · 周日</div>
<div class="topbar-right">
<div class="topbar-undo-redo">
<button class="undo-btn" disabled aria-label="撤销">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 10h10a5 5 0 015 5v2"/><polyline points="3 10 7 6"/><polyline points="3 10 7 14"/></svg>
</button>
<button class="redo-btn" disabled aria-label="重做">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 10H11a5 5 0 00-5 5v2"/><polyline points="21 10 17 6"/><polyline points="21 10 17 14"/></svg>
</button>
</div>
<div class="autosave-status" aria-live="polite">
<span class="autosave-dot"></span>
<span>已保存</span>
</div>
<button class="topbar-btn" aria-label="上传">
<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M4 12v6h14v-6"/><polyline points="14 6 10 2 6 6"/><line x1="10" y1="2" x2="10" y2="13"/></svg>
</button>
<button class="save-btn">保存</button>
</div>
</div>
<!-- Date strip -->
<div class="date-strip">
<div class="date-info">
<strong>14:32</strong>
<span>· 晴 26°</span>
</div>
<div class="mood-quick">
<div class="mood-mini">😊</div>
<div class="mood-mini selected">🥰</div>
<div class="mood-mini">😌</div>
</div>
</div>
<!-- Canvas + Side Panel -->
<div class="editor-body">
<div class="canvas-wrapper">
<div class="canvas-paper">
<div class="canvas-grid"></div>
<div class="washi-tape"></div>
<div class="placed-sticker" style="top:10px;left:10px">🌸</div>
<div class="placed-sticker" style="top:180px;right:16px"></div>
<div class="journal-content">
<input class="journal-title" type="text" value="图书馆的午后时光" placeholder="给日记起个标题...">
<div class="format-bar">
<button class="format-btn active" style="font-weight:800">B</button>
<button class="format-btn" style="font-style:italic">I</button>
<button class="format-btn" style="text-decoration:underline">U</button>
<div class="format-divider"></div>
<div class="color-dot active" style="background:#2D2420"></div>
<div class="color-dot" style="background:var(--accent)"></div>
<div class="color-dot" style="background:var(--secondary)"></div>
<div class="color-dot" style="background:#5B7DB1"></div>
<div class="format-divider"></div>
<button class="format-btn">
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><rect x="1" y="3" width="14" height="2" rx="1"/><rect x="1" y="7" width="10" height="2" rx="1"/><rect x="1" y="11" width="6" height="2" rx="1"/></svg>
</button>
</div>
<textarea class="journal-body" rows="10">今天下午去图书馆自习,找了一个靠窗的位置。阳光从窗外洒进来,落在摊开的高数课本上,暖暖的。
不知不觉就学了三个小时,中间喝了一杯抹茶拿铁☕。虽然期末压力大,但看到窗外的樱花还在开,觉得一切都会好的。
晚上回宿舍路上,买了喜欢的草莓蛋糕犒劳自己 🍰</textarea>
<div class="placed-photo">
<div style="text-align:center;color:var(--secondary)">
<svg width="36" height="36" viewBox="0 0 32 32" fill="none" stroke="currentColor" stroke-width="1.5" style="margin-bottom:4px"><rect x="4" y="6" width="24" height="20" rx="3"/><circle cx="12" cy="14" r="3"/><path d="M4 22l6-6 4 4 6-8 8 10"/></svg>
<div style="font-size:13px">图书馆窗边的阳光 ☀</div>
</div>
</div>
</div>
</div>
</div>
<!-- Right side panel -->
<div class="tool-panel-side">
<div class="panel-header">
<button class="panel-tab active" onclick="switchPanel('stickers', this)">贴纸</button>
<button class="panel-tab" onclick="switchPanel('brush', this)">画笔工具</button>
<button class="panel-tab" onclick="switchPanel('templates', this)">模板</button>
<button class="panel-tab" onclick="switchPanel('tags', this)">标签</button>
<button class="panel-tab" onclick="switchPanel('background', this)">背景</button>
</div>
<!-- Sticker panel -->
<div class="panel-content" id="panelStickers">
<div style="display:flex;gap:var(--space-2);margin-bottom:var(--space-4);flex-wrap:wrap">
<button class="panel-tab" style="font-size:12px;padding:5px 12px">热门</button>
<button class="panel-tab active" style="font-size:12px;padding:5px 12px">可爱</button>
<button class="panel-tab" style="font-size:12px;padding:5px 12px">植物</button>
<button class="panel-tab" style="font-size:12px;padding:5px 12px">天气</button>
<button class="panel-tab" style="font-size:12px;padding:5px 12px">校园</button>
</div>
<div class="sticker-grid">
<div class="sticker-item">🌸</div>
<div class="sticker-item"></div>
<div class="sticker-item">🌿</div>
<div class="sticker-item">☀️</div>
<div class="sticker-item">🌙</div>
<div class="sticker-item">🍰</div>
<div class="sticker-item">📚</div>
<div class="sticker-item">🎵</div>
<div class="sticker-item">💡</div>
<div class="sticker-item">🎀</div>
<div class="sticker-item">🍂</div>
<div class="sticker-item"></div>
<div class="sticker-item">🌈</div>
<div class="sticker-item">✏️</div>
<div class="sticker-item">🦋</div>
<div class="sticker-item">🐱</div>
<div class="sticker-item">🌸</div>
<div class="sticker-item">🎈</div>
<div class="sticker-item">🌻</div>
<div class="sticker-item">🎨</div>
</div>
</div>
<!-- Brush tool panel -->
<div class="panel-content" id="panelBrush" style="display:none">
<div class="brush-section-title">工具</div>
<div class="brush-tools-list">
<button class="brush-tool-item active" data-tool="pen" onclick="selectBrushTool(this, 'pen')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3l4 4L7 21H3v-4L17 3z"/></svg>
<span>钢笔</span>
</button>
<button class="brush-tool-item" data-tool="pencil" onclick="selectBrushTool(this, 'pencil')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 20l1.5-5.5L18 2l4 4L9.5 18.5 4 20z"/><path d="M15 5l4 4"/></svg>
<span>铅笔</span>
</button>
<button class="brush-tool-item" data-tool="marker" onclick="selectBrushTool(this, 'marker')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="6" y="3" width="14" height="8" rx="2" transform="rotate(45 13 7)"/><path d="M4 20l3-7"/></svg>
<span>马克笔</span>
</button>
<button class="brush-tool-item" data-tool="eraser" onclick="selectBrushTool(this, 'eraser')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 20H9L3.5 14.5a2 2 0 010-2.83l9.17-9.17a2 2 0 012.83 0L20 7"/><path d="M6 12l6 6"/></svg>
<span>橡皮擦</span>
</button>
</div>
<div class="brush-section-title">粗细</div>
<div class="brush-size-preview">
<div class="brush-size-line" id="brushSizeLine" style="height:2px"></div>
</div>
<div class="brush-size-row">
<input type="range" class="brush-slider" id="brushSizeSlider" min="1" max="20" value="2">
<span class="brush-size-value" id="brushSizeValue">2px</span>
</div>
<div class="brush-section-title">颜色</div>
<div class="brush-colors-grid">
<div class="brush-color-dot active" style="background:#2D2420" data-color="#2D2420" onclick="selectBrushColor(this)"></div>
<div class="brush-color-dot" style="background:var(--accent)" data-color="#E07A5F" onclick="selectBrushColor(this)"></div>
<div class="brush-color-dot" style="background:var(--secondary)" data-color="#81B29A" onclick="selectBrushColor(this)"></div>
<div class="brush-color-dot" style="background:var(--tertiary)" data-color="#F2CC8F" onclick="selectBrushColor(this)"></div>
<div class="brush-color-dot" style="background:var(--rose)" data-color="#D4A5A5" onclick="selectBrushColor(this)"></div>
<div class="brush-color-dot" style="background:#5B8FB9" data-color="#5B8FB9" onclick="selectBrushColor(this)"></div>
<div class="brush-color-dot" style="background:#9B72AA" data-color="#9B72AA" onclick="selectBrushColor(this)"></div>
<div class="brush-color-dot" style="background:#C93D3D" data-color="#C93D3D" onclick="selectBrushColor(this)"></div>
</div>
<div class="brush-section-title">透明度</div>
<div class="brush-opacity-row disabled" id="brushOpacityRow">
<span class="brush-opacity-label">透明度</span>
<input type="range" class="brush-slider" id="brushOpacitySlider" min="0" max="100" value="50">
<span class="brush-opacity-value" id="brushOpacityValue">50%</span>
</div>
</div>
<!-- Templates panel -->
<div class="panel-content" id="panelTemplates" style="display:none">
<p style="color:var(--muted);font-size:var(--text-sm)">模板内容</p>
</div>
<!-- Tags panel -->
<div class="panel-content" id="panelTags" style="display:none">
<div class="tags-section">
<div class="tags-section-title">已选标签</div>
<div class="tag-selected-area" id="tagSelectedArea">
<span class="tag-pill">#图书馆<span class="remove" aria-label="删除标签 图书馆" role="button" onclick="this.parentElement.remove()">&times;</span></span>
<span class="tag-pill">#学习<span class="remove" aria-label="删除标签 学习" role="button" onclick="this.parentElement.remove()">&times;</span></span>
</div>
</div>
<div class="tags-section">
<div class="tags-section-title">添加标签</div>
<div class="tag-input-row">
<input class="tag-input" type="text" id="tagInput" placeholder="输入标签后回车添加..." autocomplete="off" aria-label="输入新标签" onkeydown="handleTagInput(event)">
</div>
</div>
<div class="tags-section">
<div class="tags-section-title">推荐标签</div>
<div class="tag-suggest-grid">
<button class="tag-suggest-item" aria-label="添加标签 日常" onclick="addSuggestedTag(this)">#日常</button>
<button class="tag-suggest-item" aria-label="添加标签 学习" onclick="addSuggestedTag(this)">#学习</button>
<button class="tag-suggest-item" aria-label="添加标签 读书" onclick="addSuggestedTag(this)">#读书</button>
<button class="tag-suggest-item" aria-label="添加标签 运动" onclick="addSuggestedTag(this)">#运动</button>
<button class="tag-suggest-item" aria-label="添加标签 旅行" onclick="addSuggestedTag(this)">#旅行</button>
<button class="tag-suggest-item" aria-label="添加标签 美食" onclick="addSuggestedTag(this)">#美食</button>
<button class="tag-suggest-item" aria-label="添加标签 心情" onclick="addSuggestedTag(this)">#心情</button>
<button class="tag-suggest-item" aria-label="添加标签 灵感" onclick="addSuggestedTag(this)">#灵感</button>
</div>
</div>
</div>
<!-- Background panel -->
<div class="panel-content" id="panelBackground" style="display:none">
<p style="color:var(--muted);font-size:var(--text-sm)">背景内容</p>
</div>
</div>
</div>
</div>
</div>
<script>
function switchPanel(name, tabEl) {
var tabs = tabEl.parentElement.querySelectorAll('.panel-tab');
for (var i = 0; i < tabs.length; i++) tabs[i].classList.remove('active');
tabEl.classList.add('active');
var panels = ['panelStickers', 'panelBrush', 'panelTemplates', 'panelTags', 'panelBackground'];
var names = ['stickers', 'brush', 'templates', 'tags', 'background'];
for (var i = 0; i < panels.length; i++) {
var el = document.getElementById(panels[i]);
if (el) el.style.display = names[i] === name ? '' : 'none';
}
}
function selectBrushTool(btn, tool) {
var items = document.querySelectorAll('.brush-tool-item');
for (var i = 0; i < items.length; i++) items[i].classList.remove('active');
btn.classList.add('active');
var defaults = { pen: 2, pencil: 3, marker: 8, eraser: 10 };
var slider = document.getElementById('brushSizeSlider');
slider.value = defaults[tool] || 2;
updateSizePreview(slider.value);
var opacityRow = document.getElementById('brushOpacityRow');
if (tool === 'marker') {
opacityRow.classList.remove('disabled');
} else {
opacityRow.classList.add('disabled');
}
}
function selectBrushColor(dot) {
var dots = document.querySelectorAll('.brush-color-dot');
for (var i = 0; i < dots.length; i++) dots[i].classList.remove('active');
dot.classList.add('active');
}
function updateSizePreview(val) {
document.getElementById('brushSizeValue').textContent = val + 'px';
var line = document.getElementById('brushSizeLine');
if (line) line.style.height = Math.max(1, val) + 'px';
}
document.getElementById('brushSizeSlider').addEventListener('input', function() {
updateSizePreview(this.value);
});
document.getElementById('brushOpacitySlider').addEventListener('input', function() {
document.getElementById('brushOpacityValue').textContent = this.value + '%';
});
/* Tags functionality */
function handleTagInput(e) {
if (e.key === 'Enter') {
var input = e.target;
var text = input.value.trim();
if (text) {
if (!text.startsWith('#')) text = '#' + text;
var area = document.getElementById('tagSelectedArea');
var pill = document.createElement('span');
pill.className = 'tag-pill';
pill.innerHTML = text + '<span class="remove" aria-label="删除标签 ' + text.slice(1) + '" role="button" onclick="this.parentElement.remove()">&times;</span>';
area.appendChild(pill);
input.value = '';
}
}
}
function addSuggestedTag(btn) {
var text = btn.textContent.trim();
var area = document.getElementById('tagSelectedArea');
var pill = document.createElement('span');
pill.className = 'tag-pill';
pill.innerHTML = text + '<span class="remove" aria-label="删除标签 ' + text.slice(1) + '" role="button" onclick="this.parentElement.remove()">&times;</span>';
area.appendChild(pill);
btn.style.display = 'none';
}
</script>
<script src="../../js/theme-switcher.js"></script>
</body>
</html>