From 9a726dbd9f3c3ef19b0693688e6135456be75298 Mon Sep 17 00:00:00 2001 From: gogongxt Date: Mon, 2 Nov 2026 16:01:16 +0800 Subject: [PATCH] update --- CLAUDE.md | 140 +-- assets/common.js | 265 +++++ assets/favicon.svg | 13 + assets/styles.css | 1945 +++++++++++++++++++++++++++++++ color_pick.html | 1500 ++++++++++++------------ electricity_calculator.html | 1008 +++++++++------- image_compressor.html | 2160 +++++++++++++++++----------------- image_to_pdf.html | 2039 +++++++++++++------------------- index.html | 2200 +++++++++++++++++++++++++---------- json_formatter.html | 933 ++++++--------- number.html | 591 +++++++--- other_function.html | 632 +++++----- url_encoder.html | 956 ++++++--------- 13 files changed, 8547 insertions(+), 5835 deletions(-) create mode 100644 assets/common.js create mode 100644 assets/favicon.svg create mode 100644 assets/styles.css diff --git a/CLAUDE.md b/CLAUDE.md index 8ab8a91..36a5408 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,93 +4,101 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co ## Project Overview -This is a Chinese-language web-based utility toolbox (功能工具箱) that provides multiple practical tools through a single interface. It's a pure frontend application built with vanilla HTML, CSS, and JavaScript that requires no backend server or external dependencies. +Chinese-language browser toolbox (功能工具箱) offering multiple practical utilities through one interface. Pure frontend: vanilla HTML, CSS, and JavaScript with no build step and no backend. All processing happens in the browser. ## Architecture ### Core Structure -- **Single-page application (SPA)** with modular tool architecture -- **Main entry point**: `index.html` - Central hub with collapsible sidebar navigation -- **Individual tools**: Separate HTML files loaded via iframe when selected -- **Pure client-side**: All processing happens in the browser, ensuring data privacy +- **Single-page shell** (`index.html`): collapsible sidebar, top bar, searchable tool cards, hash-based routing. +- **Tool pages**: standalone HTML files loaded in an iframe when selected, so each tool also works when opened directly. +- **Shared design system**: `assets/styles.css` (tokens + components) and `assets/common.js` (theme, toast, clipboard, helpers) are used by every page. +- **No dependencies** except jsPDF, loaded from CDN by `image_to_pdf.html`. -### Tool Modules +### Tools -- **Electricity Calculator** (`electricity_calculator.html`): Calculate appliance electricity costs -- **Programmer Calculator** (`number.html`): Base conversion utility (binary, octal, decimal, hex) -- **Color Picker** (`color_pick.html`): Professional color selection and format conversion -- **Other Functions** (`other_function.html`): Placeholder for future tools (under construction) +| File | Tool | +| --- | --- | +| `electricity_calculator.html` | 电费计算器 (single + peak/valley pricing) | +| `number.html` | 程序员计算器 (binary/octal/decimal/hex, arbitrary precision) | +| `color_pick.html` | 颜色选择器 (SV/H hue picker, HSV/RGB/HEX/HSL) | +| `json_formatter.html` | JSON 格式化 (pretty, minify, sort keys, highlight) | +| `url_encoder.html` | URL 编解码 (URI component/full/form/Base64) | +| `image_to_pdf.html` | 图片转 PDF (ordering, preview, page settings) | +| `image_compressor.html` | 图片压缩 (quality, format, resize, batch download) | +| `other_function.html` | 其他功能 (roadmap) | + +### Shared assets + +- `assets/styles.css`: design tokens for light/dark themes, resets, and reusable components (`.card`, `.btn`, `.field`, `.segmented`, `.editor-app`, `.image-grid`, `.dropzone`, `.toast`, etc.). Tool pages should reuse these instead of adding ad-hoc styles. +- `assets/common.js`: exposes `window.Toolbox` with `theme()`, `setTheme()`, `toggleTheme()`, `onThemeChange()`, `toast()`, `copy()`, `copyWithToast()`, `formatBytes()`, `escapeHtml()`, `debounce()`. It also wires `[data-theme-toggle]` buttons and declarative copy buttons (`data-copy-text` / `data-copy-target`). + +### Theme + +- Theme is stored in `localStorage` under `toolbox-theme`; without a stored value the system preference is used. +- `common.js` applies the theme before paint and listens to `storage` events, which keeps the parent page and iframe in sync live. +- Theme toggles use `` + `` inside a `[data-theme-toggle]` element. + +### Routing + +- Hashes map to tools: `#calculator`, `#number`, `#color`, `#json`, `#url`, `#image2pdf`, `#image-compressor`, `#other`. +- `index.html` uses `history.pushState` plus `popstate` / `hashchange` listeners. +- Keyboard shortcuts: `Ctrl/Cmd + K` focuses search, `Ctrl/Cmd + 1…8` opens tools, `Esc` closes mobile sidebar. ## Development -### No Build Process +### No build process -- **Static files**: Direct HTML/CSS/JS - no compilation needed -- **No dependencies**: Pure frontend with no npm packages or build tools -- **Simple deployment**: Can be served by any web server or opened directly in browser +Open `index.html` directly or serve the folder: -### Testing +```bash +python3 -m http.server 8000 +``` -- Open `index.html` directly in browser to test -- Test individual tools by opening their respective HTML files -- Check responsive design at different viewport sizes -- Verify keyboard shortcuts (Ctrl/Cmd + 1-5 for tool navigation) +### Testing checklist -### Adding New Tools +- Open `index.html`; verify sidebar collapse, mobile drawer, search, theme toggle, hash links. +- Open each tool directly; verify it works standalone and inside the iframe. +- Test light and dark themes; check contrast and iframe theme sync. +- Test mobile widths (≈375px) and desktop (≈1440px). +- Verify localStorage persists theme, sidebar state, and color history. +- Image tools: add multiple files, reorder/delete, change options, generate/compress, download. -1. Create new HTML file in root directory (following naming convention: `tool_name.html`) -2. Update `index.html` sidebar navigation to include new tool -3. Ensure new tool follows existing design patterns and styling -4. Test iframe loading and responsive behavior +### Adding a tool -### Code Style +1. Create `tool_name.html` using the shared assets: + ```html + + + ``` +2. Use the `.tool-page` / `.tool-header` / `.card` layout and existing components; add a theme toggle in `.header-actions`. +3. Add the tool to the `TOOLS` array in `index.html` (name, description, URL, hash, icon, tint). The sidebar and home cards are generated from that array. +4. Add an icon `` to the sprite at the top of `index.html` if needed; use `viewBox="0 0 24 24"` and stroke-style paths. +5. Test inside the iframe and standalone, in both themes and on mobile. -- **HTML5**: Semantic markup with Chinese UI text -- **CSS3**: Modern features (Flexbox, Grid, animations, gradients) -- **Vanilla JavaScript**: No external libraries, cross-browser compatible -- **Responsive design**: Mobile-first approach with media queries -- **Consistent styling**: Shared CSS patterns across all tools +### Code style -### Key Features to Maintain - -- **Privacy-focused**: All processing happens locally, no external data transmission -- **User experience**: Smooth animations, collapsible sidebar, tooltips -- **Accessibility**: Semantic HTML and keyboard navigation support -- **Professional UI**: Gradient backgrounds, modern styling, clean layouts +- Semantic HTML5, Chinese UI text, accessible labels (`aria-label`, `role`, visible focus). +- Vanilla ES5+/ES2020 browser JavaScript; no frameworks. +- Prefer shared CSS variables and components over inline styling. +- Keep all processing local; do not add backend calls or telemetry. ## File Structure ``` / -├── index.html # Main application hub with navigation -├── electricity_calculator.html # Electricity cost calculator -├── number.html # Programmer calculator (base conversion) -├── color_pick.html # Color picker and format converter -├── other_function.html # Future tools placeholder -└── CLAUDE.md # This file +├── index.html # App shell, sidebar, routing, tool registry +├── electricity_calculator.html +├── number.html +├── color_pick.html +├── json_formatter.html +├── url_encoder.html +├── image_to_pdf.html +├── image_compressor.html +├── other_function.html +├── assets/ +│ ├── styles.css # Shared design tokens and components +│ ├── common.js # Theme, toast, clipboard, helpers +│ └── favicon.svg # App icon +└── CLAUDE.md ``` - -## Common Tasks - -### Running the Application - -```bash -# Serve with any web server (optional) -python3 -m http.server 8000 -# or open directly in browser -open index.html -``` - -### Adding New Tools - -- Follow existing HTML structure and CSS patterns -- Include Chinese interface text consistent with current tools -- Ensure responsive design for mobile devices -- Test iframe integration with main navigation - -### Modifying Styles - -- Main styles are embedded in individual HTML files -- Consistent color scheme and design patterns across tools -- Use CSS variables for easy theme maintenance if needed \ No newline at end of file diff --git a/assets/common.js b/assets/common.js new file mode 100644 index 0000000..fd16b72 --- /dev/null +++ b/assets/common.js @@ -0,0 +1,265 @@ +/* ============================================================ + 功能工具箱 · 共享脚本 + 主题同步 / Toast / 剪贴板 / 格式化工具 + ============================================================ */ +(function () { + "use strict"; + + var THEME_KEY = "toolbox-theme"; + var root = document.documentElement; + + function readStoredTheme() { + try { + var value = localStorage.getItem(THEME_KEY); + return value === "light" || value === "dark" ? value : null; + } catch (error) { + return null; + } + } + + function systemTheme() { + return window.matchMedia && + window.matchMedia("(prefers-color-scheme: dark)").matches + ? "dark" + : "light"; + } + + function applyTheme(theme, persist) { + if (theme !== "light" && theme !== "dark") return; + root.dataset.theme = theme; + root.style.colorScheme = theme; + if (persist) { + try { + localStorage.setItem(THEME_KEY, theme); + } catch (error) { + /* 忽略隐私模式下的写入失败 */ + } + } + window.dispatchEvent( + new CustomEvent("toolbox:themechange", { detail: { theme: theme } }), + ); + } + + function currentTheme() { + return root.dataset.theme === "dark" ? "dark" : "light"; + } + + function toggleTheme() { + var next = currentTheme() === "dark" ? "light" : "dark"; + applyTheme(next, true); + return next; + } + + // 首次渲染前应用主题,避免闪烁 + applyTheme(readStoredTheme() || systemTheme(), false); + + // 跟随系统主题(用户未手动选择时) + if (window.matchMedia) { + var media = window.matchMedia("(prefers-color-scheme: dark)"); + var onSystemChange = function (event) { + if (!readStoredTheme()) { + applyTheme(event.matches ? "dark" : "light", false); + } + }; + if (media.addEventListener) { + media.addEventListener("change", onSystemChange); + } else if (media.addListener) { + media.addListener(onSystemChange); + } + } + + // 同一个页面内(父页面 / iframe)的主题同步 + window.addEventListener("storage", function (event) { + if (event.key === THEME_KEY && event.newValue) { + applyTheme(event.newValue, false); + } + }); + + /* ---------- Toast ---------- */ + + function toastContainer() { + var el = document.querySelector(".toast-wrap"); + if (!el) { + el = document.createElement("div"); + el.className = "toast-wrap"; + document.body.appendChild(el); + } + return el; + } + + function toast(message, type) { + if (!document.body) return; + type = type || "info"; + var el = document.createElement("div"); + el.className = "toast toast--" + type; + el.setAttribute("role", "status"); + el.setAttribute("aria-live", "polite"); + + var icon = document.createElement("span"); + icon.className = "toast-icon"; + icon.textContent = type === "success" ? "✓" : type === "error" ? "!" : "i"; + + var text = document.createElement("span"); + text.textContent = message; + + el.appendChild(icon); + el.appendChild(text); + toastContainer().appendChild(el); + + requestAnimationFrame(function () { + el.classList.add("show"); + }); + + setTimeout(function () { + el.classList.remove("show"); + setTimeout(function () { + el.remove(); + }, 220); + }, 2400); + } + + /* ---------- 剪贴板 ---------- */ + + function legacyCopy(text) { + return new Promise(function (resolve, reject) { + try { + var area = document.createElement("textarea"); + area.value = text; + area.style.position = "fixed"; + area.style.top = "-9999px"; + area.style.opacity = "0"; + document.body.appendChild(area); + area.focus(); + area.select(); + var ok = document.execCommand("copy"); + document.body.removeChild(area); + ok ? resolve() : reject(new Error("copy failed")); + } catch (error) { + reject(error); + } + }); + } + + function copyText(text) { + text = String(text == null ? "" : text); + if (navigator.clipboard && window.isSecureContext) { + return navigator.clipboard.writeText(text).catch(function () { + // iframe 或权限受限时回退到 execCommand + return legacyCopy(text); + }); + } + return legacyCopy(text); + } + + function copyWithToast(text, message) { + return copyText(text) + .then(function () { + toast(message || "已复制到剪贴板", "success"); + return true; + }) + .catch(function () { + toast("复制失败,请手动选择复制", "error"); + return false; + }); + } + + /* ---------- 格式化工具 ---------- */ + + function formatBytes(bytes, decimals) { + bytes = Number(bytes) || 0; + if (bytes <= 0) return "0 B"; + var k = 1024; + var sizes = ["B", "KB", "MB", "GB", "TB"]; + var i = Math.min( + Math.floor(Math.log(bytes) / Math.log(k)), + sizes.length - 1, + ); + var value = bytes / Math.pow(k, i); + return ( + parseFloat(value.toFixed(decimals == null ? 1 : decimals)) + + " " + + sizes[i] + ); + } + + function escapeHtml(value) { + return String(value).replace(/[&<>"']/g, function (char) { + return { + "&": "&", + "<": "<", + ">": ">", + '"': """, + "'": "'", + }[char]; + }); + } + + function debounce(fn, wait) { + var timer = null; + return function () { + var args = arguments; + var context = this; + clearTimeout(timer); + timer = setTimeout(function () { + fn.apply(context, args); + }, wait); + }; + } + + /* ---------- 初始化 ---------- */ + + function initThemeButtons() { + var buttons = document.querySelectorAll("[data-theme-toggle]"); + Array.prototype.forEach.call(buttons, function (button) { + if (button.dataset.themeBound === "1") return; + button.dataset.themeBound = "1"; + button.addEventListener("click", function () { + toggleTheme(); + }); + }); + } + + // 声明式复制按钮: + // data-copy-text="要复制的文本" + // data-copy-target="#elementId" (复制该元素 textContent) + function initCopyButtons() { + if (document.body.dataset.copyBound === "1") return; + document.body.dataset.copyBound = "1"; + document.addEventListener("click", function (event) { + var button = event.target.closest("[data-copy-text],[data-copy-target]"); + if (!button) return; + var text = button.dataset.copyText; + if (text == null && button.dataset.copyTarget) { + var target = document.querySelector(button.dataset.copyTarget); + text = target ? target.textContent : ""; + } + if (!text) return; + event.preventDefault(); + copyWithToast(text, button.dataset.copyMessage); + }); + } + + document.addEventListener("DOMContentLoaded", function () { + initThemeButtons(); + initCopyButtons(); + }); + + window.Toolbox = { + theme: currentTheme, + setTheme: function (theme) { + applyTheme(theme, true); + }, + toggleTheme: toggleTheme, + onThemeChange: function (callback) { + window.addEventListener("toolbox:themechange", function (event) { + callback(event.detail.theme); + }); + }, + toast: toast, + copy: copyText, + copyWithToast: copyWithToast, + formatBytes: formatBytes, + escapeHtml: escapeHtml, + debounce: debounce, + }; +})(); diff --git a/assets/favicon.svg b/assets/favicon.svg new file mode 100644 index 0000000..31bbf55 --- /dev/null +++ b/assets/favicon.svg @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/assets/styles.css b/assets/styles.css new file mode 100644 index 0000000..bfd78d0 --- /dev/null +++ b/assets/styles.css @@ -0,0 +1,1945 @@ +/* ============================================================ + 功能工具箱 · 共享设计系统 + ------------------------------------------------------------ + 设计变量 / 基础重置 / 组件 / 工具页布局 + ============================================================ */ + +:root { + color-scheme: light; + + --font-sans: + -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", + "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif; + --font-mono: + ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, + "Courier New", monospace; + + --bg: #f5f6fa; + --surface: #ffffff; + --surface-2: #f4f5f9; + --surface-3: #eceef5; + --border: #e4e6ef; + --border-strong: #d3d7e3; + + --text: #101322; + --text-secondary: #565c6e; + --text-muted: #8b90a0; + + --accent: #5b5bd6; + --accent-hover: #4a4ac4; + --accent-soft: #eef0ff; + --accent-contrast: #ffffff; + + --success: #0f9d76; + --success-soft: #e7f8f1; + --danger: #e5484d; + --danger-soft: #fdecec; + --warning: #c2760a; + --warning-soft: #fdf4e5; + + --ring: rgba(91, 91, 214, 0.2); + --shadow-sm: 0 1px 2px rgba(16, 19, 34, 0.05); + --shadow-md: 0 12px 32px -14px rgba(16, 19, 34, 0.22); + --shadow-lg: 0 24px 64px -24px rgba(16, 19, 34, 0.3); + + --radius-xs: 8px; + --radius-sm: 10px; + --radius: 14px; + --radius-lg: 18px; + + --rate: 0.18s; +} + +html[data-theme="dark"] { + color-scheme: dark; + + --bg: #0b0d14; + --surface: #11141e; + --surface-2: #161a26; + --surface-3: #1c2130; + --border: #242938; + --border-strong: #333a4d; + + --text: #e8eaf2; + --text-secondary: #a1a7b8; + --text-muted: #6f7689; + + --accent: #8b8cf7; + --accent-hover: #a5a6ff; + --accent-soft: rgba(124, 125, 245, 0.14); + --accent-contrast: #0b0d14; + + --success: #34d399; + --success-soft: rgba(52, 211, 153, 0.1); + --danger: #f87171; + --danger-soft: rgba(248, 113, 113, 0.1); + --warning: #fbbf24; + --warning-soft: rgba(251, 191, 36, 0.1); + + --ring: rgba(139, 140, 247, 0.25); + --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35); + --shadow-md: 0 12px 32px -14px rgba(0, 0, 0, 0.7); + --shadow-lg: 0 24px 64px -24px rgba(0, 0, 0, 0.8); +} + +/* ---------- 基础 ---------- */ + +*, +*::before, +*::after { + box-sizing: border-box; +} + +html, +body { + margin: 0; + padding: 0; +} + +body { + font-family: var(--font-sans); + font-size: 15px; + line-height: 1.6; + background: var(--bg); + color: var(--text); + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-rendering: optimizeLegibility; +} + +h1, +h2, +h3, +h4 { + margin: 0; + line-height: 1.25; + letter-spacing: -0.015em; +} + +p { + margin: 0; +} + +a { + color: var(--accent); + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +button, +input, +select, +textarea { + font: inherit; + color: inherit; +} + +button { + -webkit-tap-highlight-color: transparent; +} + +img, +svg { + display: block; + max-width: 100%; +} + +::selection { + background: var(--accent); + color: var(--accent-contrast); +} + +:focus-visible { + outline: 2px solid var(--accent); + outline-offset: 2px; +} + +::-webkit-scrollbar { + width: 10px; + height: 10px; +} + +::-webkit-scrollbar-track { + background: transparent; +} + +::-webkit-scrollbar-thumb { + background: var(--border-strong); + border: 2px solid transparent; + border-radius: 999px; + background-clip: content-box; +} + +::-webkit-scrollbar-thumb:hover { + background: var(--text-muted); + background-clip: content-box; +} + +/* ---------- 通用工具类 ---------- */ + +.mono { + font-family: var(--font-mono); +} + +.muted { + color: var(--text-muted); +} + +.secondary { + color: var(--text-secondary); +} + +.hidden, +[hidden] { + display: none !important; +} + +.row { + display: flex; + align-items: center; + gap: 8px; +} + +.spacer { + flex: 1; +} + +.sr-only { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + margin: -1px; + overflow: hidden; + clip: rect(0, 0, 0, 0); + white-space: nowrap; + border: 0; +} + +.kbd { + display: inline-flex; + align-items: center; + padding: 2px 6px; + border: 1px solid var(--border-strong); + border-bottom-width: 2px; + border-radius: 5px; + background: var(--surface); + color: var(--text-muted); + font-family: var(--font-mono); + font-size: 0.7rem; + line-height: 1.4; +} + +/* ---------- 工具页骨架 ---------- */ + +/* 工具页内统一使用线性图标 */ +.tool-page svg, +.editor-app svg { + fill: none; + stroke: currentColor; + stroke-width: 1.8; + stroke-linecap: round; + stroke-linejoin: round; +} + +.tool-page { + width: 100%; + max-width: 1180px; + margin: 0 auto; + padding: clamp(20px, 3.6vw, 40px); +} + +.tool-page--narrow { + max-width: 880px; +} + +.tool-header { + display: flex; + align-items: flex-start; + gap: 16px; + margin-bottom: 26px; +} + +.tool-header .tool-icon { + width: 48px; + height: 48px; + flex: none; + display: grid; + place-items: center; + border-radius: 14px; + background: var(--accent-soft); + color: var(--accent); +} + +.tool-header .tool-icon svg { + width: 24px; + height: 24px; +} + +.tool-header h1 { + font-size: clamp(1.45rem, 2.6vw, 1.9rem); + font-weight: 700; + letter-spacing: -0.025em; + margin-bottom: 4px; +} + +.tool-header p { + color: var(--text-secondary); + font-size: 0.92rem; +} + +.tool-header .header-actions { + margin-left: auto; + display: flex; + align-items: center; + gap: 8px; + flex: none; +} + +/* ---------- 卡片 ---------- */ + +.card { + background: var(--surface); + border: 1px solid var(--border); + border-radius: var(--radius); + box-shadow: var(--shadow-sm); + padding: clamp(18px, 2.6vw, 26px); +} + +.card + .card { + margin-top: 16px; +} + +.card--flush { + padding: 0; + overflow: hidden; +} + +.card-head { + display: flex; + align-items: center; + gap: 10px; + margin-bottom: 18px; +} + +.card-head h2 { + font-size: 1rem; + font-weight: 650; +} + +.card-head .spacer { + flex: 1; +} + +.card-head .hint { + font-size: 0.8rem; + color: var(--text-muted); +} + +/* ---------- 按钮 ---------- */ + +.btn { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 7px; + padding: 9px 16px; + border: 1px solid var(--border); + border-radius: var(--radius-sm); + background: var(--surface); + color: var(--text); + font-size: 0.875rem; + font-weight: 550; + line-height: 1.2; + cursor: pointer; + white-space: nowrap; + transition: + background var(--rate) ease, + border-color var(--rate) ease, + color var(--rate) ease, + transform var(--rate) ease, + box-shadow var(--rate) ease; +} + +.btn svg { + width: 17px; + height: 17px; + flex: none; +} + +.btn:hover { + background: var(--surface-2); + border-color: var(--border-strong); +} + +.btn:active { + transform: translateY(1px); +} + +.btn--primary { + background: var(--accent); + border-color: transparent; + color: var(--accent-contrast); + box-shadow: 0 6px 16px -8px var(--accent); +} + +.btn--primary:hover { + background: var(--accent-hover); + border-color: transparent; + color: var(--accent-contrast); +} + +.btn--soft { + background: var(--accent-soft); + border-color: transparent; + color: var(--accent); +} + +.btn--soft:hover { + background: var(--accent-soft); + border-color: transparent; + filter: brightness(0.96); +} + +html[data-theme="dark"] .btn--soft:hover { + filter: brightness(1.15); +} + +.btn--ghost { + background: transparent; + border-color: transparent; + color: var(--text-secondary); +} + +.btn--ghost:hover { + background: var(--surface-2); + border-color: transparent; + color: var(--text); +} + +.btn--danger { + background: var(--danger-soft); + border-color: transparent; + color: var(--danger); +} + +.btn--danger:hover { + background: var(--danger-soft); + border-color: transparent; + filter: brightness(0.96); +} + +.btn--sm { + padding: 6px 11px; + font-size: 0.8rem; + border-radius: var(--radius-xs); +} + +.btn--icon { + width: 38px; + height: 38px; + padding: 0; + border-radius: var(--radius-sm); +} + +.btn--icon.btn--sm { + width: 30px; + height: 30px; +} + +.btn:disabled { + opacity: 0.45; + cursor: not-allowed; + transform: none; +} + +/* 主题按钮图标切换 */ +[data-theme-toggle] .icon-sun { + display: none; +} + +html[data-theme="dark"] [data-theme-toggle] .icon-sun { + display: block; +} + +html[data-theme="dark"] [data-theme-toggle] .icon-moon { + display: none; +} + +/* ---------- 表单 ---------- */ + +.field { + display: flex; + flex-direction: column; + gap: 6px; + min-width: 0; +} + +.field > label, +.field-label { + font-size: 0.82rem; + font-weight: 600; + color: var(--text-secondary); +} + +.field .help { + font-size: 0.76rem; + color: var(--text-muted); +} + +input[type="text"], +input[type="number"], +input[type="search"], +input[type="url"], +input[type="email"], +select, +textarea { + width: 100%; + padding: 9px 12px; + border: 1px solid var(--border-strong); + border-radius: var(--radius-sm); + background: var(--surface); + color: var(--text); + font-size: 0.9rem; + transition: + border-color var(--rate) ease, + box-shadow var(--rate) ease, + background var(--rate) ease; +} + +input::placeholder, +textarea::placeholder { + color: var(--text-muted); +} + +input:focus, +select:focus, +textarea:focus { + outline: none; + border-color: var(--accent); + box-shadow: 0 0 0 3px var(--ring); +} + +select { + appearance: none; + padding-right: 34px; + background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), + linear-gradient(135deg, currentColor 50%, transparent 50%); + background-position: + calc(100% - 17px) calc(50% - 2px), + calc(100% - 12px) calc(50% - 2px); + background-size: 5px 5px, 5px 5px; + background-repeat: no-repeat; + cursor: pointer; +} + +input[type="range"] { + width: 100%; + height: 22px; + accent-color: var(--accent); + cursor: pointer; +} + +input[type="checkbox"] { + width: 16px; + height: 16px; + accent-color: var(--accent); + cursor: pointer; +} + +.input-row { + display: flex; + gap: 8px; + align-items: center; +} + +.input-row > input { + flex: 1; +} + +.form-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); + gap: 14px; +} + +.checkline { + display: inline-flex; + align-items: center; + gap: 8px; + font-size: 0.84rem; + color: var(--text-secondary); + cursor: pointer; + user-select: none; +} + +/* ---------- 分段控件 ---------- */ + +.segmented { + display: inline-flex; + gap: 2px; + padding: 4px; + border: 1px solid var(--border); + border-radius: 12px; + background: var(--surface-2); +} + +.segmented .seg { + position: relative; + display: inline-flex; + cursor: pointer; +} + +.segmented .seg input { + position: absolute; + opacity: 0; + pointer-events: none; +} + +.segmented .seg span { + display: inline-flex; + align-items: center; + gap: 6px; + padding: 6px 14px; + border-radius: 9px; + color: var(--text-secondary); + font-size: 0.83rem; + font-weight: 550; + white-space: nowrap; + transition: + background var(--rate) ease, + color var(--rate) ease, + box-shadow var(--rate) ease; +} + +.segmented .seg:hover span { + color: var(--text); +} + +.segmented .seg input:checked + span { + background: var(--surface); + color: var(--text); + box-shadow: var(--shadow-sm); +} + +.segmented .seg input:focus-visible + span { + outline: 2px solid var(--accent); + outline-offset: 1px; +} + +/* ---------- 徽标 / 状态 ---------- */ + +.badge { + display: inline-flex; + align-items: center; + gap: 5px; + padding: 3px 9px; + border-radius: 999px; + background: var(--surface-2); + color: var(--text-secondary); + font-size: 0.72rem; + font-weight: 600; + white-space: nowrap; +} + +.badge--accent { + background: var(--accent-soft); + color: var(--accent); +} + +.badge--success { + background: var(--success-soft); + color: var(--success); +} + +.badge--danger { + background: var(--danger-soft); + color: var(--danger); +} + +.badge--warning { + background: var(--warning-soft); + color: var(--warning); +} + +.status-dot { + width: 6px; + height: 6px; + border-radius: 50%; + background: currentColor; +} + +/* ---------- 统计卡片 ---------- */ + +.stat-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); + gap: 12px; +} + +.stat { + padding: 14px 16px; + border: 1px solid var(--border); + border-radius: 12px; + background: var(--surface-2); +} + +.stat-label { + font-size: 0.76rem; + color: var(--text-muted); + margin-bottom: 2px; +} + +.stat-value { + font-size: 1.4rem; + font-weight: 700; + letter-spacing: -0.025em; + font-variant-numeric: tabular-nums; +} + +.stat-value .unit { + font-size: 0.72rem; + font-weight: 500; + color: var(--text-muted); + margin-left: 2px; + letter-spacing: 0; +} + +.stat--accent { + background: var(--accent-soft); + border-color: transparent; +} + +.stat--accent .stat-value, +.stat--accent .stat-label { + color: var(--accent); +} + +/* ---------- 结果行 / 复制字段 ---------- */ + +.result-list { + display: flex; + flex-direction: column; + gap: 8px; +} + +.result-row { + display: flex; + align-items: center; + gap: 12px; + padding: 10px 12px; + border: 1px solid var(--border); + border-radius: 12px; + background: var(--surface-2); + min-width: 0; +} + +.result-row .row-label { + width: 46px; + flex: none; + font-size: 0.72rem; + font-weight: 700; + letter-spacing: 0.05em; + color: var(--text-muted); + text-transform: uppercase; +} + +.result-row code { + flex: 1; + min-width: 0; + overflow: auto; + white-space: nowrap; + font-family: var(--font-mono); + font-size: 0.86rem; + color: var(--text); +} + +.copy-btn { + flex: none; + display: inline-flex; + align-items: center; + gap: 5px; + padding: 5px 9px; + border: 1px solid var(--border); + border-radius: 8px; + background: var(--surface); + color: var(--text-secondary); + font-size: 0.75rem; + font-weight: 550; + cursor: pointer; + transition: all var(--rate) ease; +} + +.copy-btn:hover { + border-color: var(--accent); + color: var(--accent); +} + +.copy-btn svg { + width: 14px; + height: 14px; +} + +.copy-field { + display: flex; + align-items: center; + gap: 8px; + padding: 6px 6px 6px 12px; + border: 1px solid var(--border); + border-radius: 10px; + background: var(--surface-2); + min-width: 0; +} + +.copy-field code { + flex: 1; + min-width: 0; + overflow: auto; + white-space: nowrap; + font-family: var(--font-mono); + font-size: 0.82rem; +} + +/* ---------- 提示条 ---------- */ + +.alert { + display: flex; + align-items: flex-start; + gap: 9px; + padding: 10px 13px; + border-radius: 10px; + font-size: 0.83rem; + line-height: 1.5; + border: 1px solid transparent; +} + +.alert svg { + width: 16px; + height: 16px; + flex: none; + margin-top: 2px; +} + +.alert--error { + background: var(--danger-soft); + border-color: color-mix(in srgb, var(--danger) 24%, transparent); + color: var(--danger); +} + +.alert--warning { + background: var(--warning-soft); + border-color: color-mix(in srgb, var(--warning) 24%, transparent); + color: var(--warning); +} + +.alert--success { + background: var(--success-soft); + border-color: color-mix(in srgb, var(--success) 24%, transparent); + color: var(--success); +} + +.alert--info { + background: var(--accent-soft); + border-color: transparent; + color: var(--accent); +} + +/* ---------- 上传区 ---------- */ + +.dropzone { + position: relative; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 6px; + padding: 34px 20px; + border: 1.5px dashed var(--border-strong); + border-radius: var(--radius); + background: var(--surface-2); + text-align: center; + cursor: pointer; + transition: + border-color var(--rate) ease, + background var(--rate) ease, + transform var(--rate) ease; +} + +.dropzone:hover, +.dropzone.drag-over { + border-color: var(--accent); + background: var(--accent-soft); +} + +.dropzone.drag-over { + transform: scale(1.005); +} + +.dropzone-icon { + width: 48px; + height: 48px; + display: grid; + place-items: center; + border-radius: 14px; + background: var(--surface); + color: var(--accent); + box-shadow: var(--shadow-sm); + margin-bottom: 4px; +} + +.dropzone-icon svg { + width: 24px; + height: 24px; +} + +.dropzone strong { + font-size: 0.95rem; + font-weight: 600; +} + +.dropzone span { + font-size: 0.8rem; + color: var(--text-muted); +} + +.dropzone input[type="file"] { + display: none; +} + +/* 已有图片时收窄上传区,变成一条“继续添加”的操作条 */ +.dropzone--compact { + flex-direction: row; + flex-wrap: wrap; + gap: 10px; + padding: 14px 18px; +} + +.dropzone--compact .dropzone-icon { + width: 30px; + height: 30px; + margin: 0; + border-radius: 9px; +} + +.dropzone--compact .dropzone-icon svg { + width: 16px; + height: 16px; +} + +.dropzone--compact strong { + font-size: 0.85rem; +} + +.dropzone--compact span { + display: none; +} + +/* ---------- 图片网格 ---------- */ + +.image-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); + gap: 12px; +} + +.image-card { + position: relative; + border: 1px solid var(--border); + border-radius: 12px; + background: var(--surface); + overflow: hidden; + transition: + border-color var(--rate) ease, + box-shadow var(--rate) ease, + transform var(--rate) ease; +} + +.image-card:hover { + border-color: var(--border-strong); + box-shadow: var(--shadow-md); +} + +.image-card.dragging { + opacity: 0.45; + transform: scale(0.97); +} + +.image-card .thumb { + position: relative; + height: 118px; + background: var(--surface-2); + cursor: zoom-in; + overflow: hidden; +} + +.image-card .thumb img { + width: 100%; + height: 100%; + object-fit: cover; + transition: transform 0.3s ease; +} + +.image-card:hover .thumb img { + transform: scale(1.04); +} + +.image-card .thumb .thumb-hint { + position: absolute; + left: 6px; + bottom: 6px; + padding: 2px 7px; + border-radius: 6px; + background: rgba(5, 7, 15, 0.62); + color: #fff; + font-size: 0.65rem; + opacity: 0; + transition: opacity var(--rate) ease; + pointer-events: none; +} + +.image-card:hover .thumb-hint { + opacity: 1; +} + +.image-card .card-actions { + position: absolute; + top: 6px; + right: 6px; + display: flex; + gap: 4px; + opacity: 0; + transition: opacity var(--rate) ease; +} + +.image-card:hover .card-actions, +.image-card:focus-within .card-actions { + opacity: 1; +} + +.icon-bubble { + width: 24px; + height: 24px; + display: grid; + place-items: center; + border: none; + border-radius: 999px; + background: rgba(5, 7, 15, 0.62); + color: #fff; + font-size: 12px; + line-height: 1; + cursor: pointer; + backdrop-filter: blur(4px); + transition: background var(--rate) ease; +} + +.icon-bubble:hover { + background: var(--accent); +} + +.icon-bubble.danger:hover { + background: var(--danger); +} + +.icon-bubble svg { + width: 13px; + height: 13px; +} + +.image-card .meta { + padding: 9px 11px 10px; + font-size: 0.75rem; +} + +.image-card .name { + font-weight: 550; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + margin-bottom: 3px; +} + +.image-card .detail { + display: flex; + align-items: center; + justify-content: space-between; + gap: 6px; + color: var(--text-muted); + font-size: 0.72rem; +} + +.image-card .detail .sizes { + min-width: 0; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + font-variant-numeric: tabular-nums; +} + +.image-card .detail .sizes s { + color: var(--text-muted); + opacity: 0.75; +} + +.image-card .detail .sizes b { + color: var(--success); + font-weight: 650; +} + +.badge-ratio { + padding: 1px 6px; + border-radius: 999px; + background: var(--success-soft); + color: var(--success); + font-size: 0.65rem; + font-weight: 700; + white-space: nowrap; +} + +.index-badge { + position: absolute; + top: 6px; + left: 6px; + width: 20px; + height: 20px; + display: grid; + place-items: center; + border-radius: 999px; + background: rgba(5, 7, 15, 0.62); + color: #fff; + font-size: 0.65rem; + font-weight: 700; + backdrop-filter: blur(4px); +} + +/* ---------- 进度 ---------- */ + +.progress-wrap { + display: none; + margin-top: 16px; +} + +.progress-wrap.show { + display: block; +} + +.progress-track { + height: 6px; + border-radius: 999px; + background: var(--surface-3); + overflow: hidden; +} + +.progress-bar { + height: 100%; + width: 0; + border-radius: 999px; + background: linear-gradient(90deg, var(--accent), #a78bfa); + transition: width 0.25s ease; +} + +.progress-text { + margin-top: 7px; + text-align: center; + font-size: 0.78rem; + color: var(--text-muted); +} + +/* ---------- 空状态 ---------- */ + +.empty-state { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 3px; + padding: 44px 20px; + text-align: center; +} + +.empty-state .empty-icon { + width: 48px; + height: 48px; + display: grid; + place-items: center; + border-radius: 14px; + background: var(--surface-2); + color: var(--text-muted); + margin-bottom: 8px; +} + +.empty-state .empty-icon svg { + width: 23px; + height: 23px; +} + +.empty-state strong { + font-size: 0.92rem; + font-weight: 600; +} + +.empty-state span { + font-size: 0.8rem; + color: var(--text-muted); +} + +/* ---------- 编辑器工作区(JSON / URL) ---------- */ + +.editor-app { + width: 100%; + max-width: 1500px; + height: 100vh; + height: 100dvh; + margin: 0 auto; + padding: 18px clamp(14px, 2.6vw, 28px) 16px; + display: flex; + flex-direction: column; + gap: 12px; +} + +.editor-app .tool-header { + margin-bottom: 0; + align-items: center; +} + +.editor-toolbar { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 8px; + padding: 9px 11px; + border: 1px solid var(--border); + border-radius: 12px; + background: var(--surface); + box-shadow: var(--shadow-sm); +} + +.editor-toolbar .toolbar-group { + display: flex; + align-items: center; + gap: 8px; + flex-wrap: wrap; +} + +.editor-toolbar .toolbar-label { + font-size: 0.78rem; + color: var(--text-muted); + font-weight: 550; +} + +.editor-split { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 12px; + flex: 1; + min-height: 0; +} + +.editor-pane { + display: flex; + flex-direction: column; + min-height: 0; + min-width: 0; + border: 1px solid var(--border); + border-radius: 12px; + background: var(--surface); + overflow: hidden; + box-shadow: var(--shadow-sm); +} + +.editor-head { + display: flex; + align-items: center; + justify-content: space-between; + gap: 10px; + padding: 9px 13px; + border-bottom: 1px solid var(--border); + background: var(--surface-2); + font-size: 0.78rem; + font-weight: 600; + color: var(--text-secondary); + flex: none; +} + +.editor-head .count { + font-weight: 500; + color: var(--text-muted); + font-variant-numeric: tabular-nums; +} + +.editor-body { + position: relative; + flex: 1; + min-height: 0; +} + +.editor-textarea { + display: block; + width: 100%; + height: 100%; + padding: 14px 16px; + border: none; + border-radius: 0; + background: transparent; + color: var(--text); + font-family: var(--font-mono); + font-size: 13px; + line-height: 1.65; + resize: none; + tab-size: 2; +} + +.editor-textarea:focus { + outline: none; + box-shadow: none; + border: none; +} + +.code-output { + width: 100%; + height: 100%; + margin: 0; + padding: 14px 16px; + overflow: auto; + background: transparent; + font-family: var(--font-mono); + font-size: 13px; + line-height: 1.65; + white-space: pre; + tab-size: 2; +} + +.code-output .placeholder { + color: var(--text-muted); +} + +.tok-key { + color: #7c3aed; +} + +.tok-string { + color: #047857; +} + +.tok-number { + color: #0369a1; +} + +.tok-boolean { + color: #b45309; +} + +.tok-null { + color: #be123c; +} + +html[data-theme="dark"] .tok-key { + color: #c4b5fd; +} + +html[data-theme="dark"] .tok-string { + color: #6ee7b7; +} + +html[data-theme="dark"] .tok-number { + color: #7dd3fc; +} + +html[data-theme="dark"] .tok-boolean { + color: #fcd34d; +} + +html[data-theme="dark"] .tok-null { + color: #fda4af; +} + +.editor-status { + display: flex; + align-items: center; + gap: 10px; + padding: 6px 4px; + font-size: 0.76rem; + color: var(--text-muted); + flex: none; +} + +.editor-status .status-text { + color: var(--text-secondary); +} + +/* ---------- 双栏布局 ---------- */ + +.split { + display: grid; + grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); + gap: 16px; + align-items: start; +} + +.split > .card + .card { + margin-top: 0; +} + +.sticky { + position: sticky; + top: 16px; +} + +/* ---------- 颜色选择器 ---------- */ + +.color-layout { + display: grid; + grid-template-columns: minmax(260px, 1fr) minmax(280px, 1fr); + gap: 16px; + align-items: start; +} + +.sv-panel { + position: relative; + height: 260px; + border-radius: 12px; + overflow: hidden; + cursor: crosshair; + touch-action: none; + background: hsl(0, 100%, 50%); + border: 1px solid var(--border); +} + +.sv-panel::before, +.sv-panel::after { + content: ""; + position: absolute; + inset: 0; + pointer-events: none; +} + +.sv-panel::before { + background: linear-gradient(to right, #fff, rgba(255, 255, 255, 0)); +} + +.sv-panel::after { + background: linear-gradient(to top, #000, rgba(0, 0, 0, 0)); +} + +.sv-cursor { + position: absolute; + width: 16px; + height: 16px; + border: 2px solid #fff; + border-radius: 50%; + box-shadow: + 0 0 0 1px rgba(0, 0, 0, 0.45), + 0 2px 6px rgba(0, 0, 0, 0.35); + transform: translate(-50%, -50%); + pointer-events: none; + z-index: 2; +} + +.hue-strip { + position: relative; + height: 14px; + margin-top: 14px; + border-radius: 999px; + cursor: pointer; + touch-action: none; + background: linear-gradient( + to right, + #f00 0%, + #ff0 16.66%, + #0f0 33.33%, + #0ff 50%, + #00f 66.66%, + #f0f 83.33%, + #f00 100% + ); + border: 1px solid var(--border); +} + +.hue-cursor { + position: absolute; + top: 50%; + width: 20px; + height: 20px; + border-radius: 50%; + background: #fff; + box-shadow: + 0 0 0 1px rgba(0, 0, 0, 0.28), + 0 2px 6px rgba(0, 0, 0, 0.25); + transform: translate(-50%, -50%); + pointer-events: none; +} + +.color-preview-big { + height: 106px; + border-radius: 12px; + border: 1px solid var(--border); + background: #ffffff; + margin-bottom: 14px; + position: relative; + overflow: hidden; +} + +.color-preview-big .preview-hex { + position: absolute; + left: 10px; + bottom: 10px; + padding: 3px 8px; + border-radius: 7px; + font-family: var(--font-mono); + font-size: 0.75rem; + font-weight: 600; + color: #fff; + background: rgba(5, 7, 15, 0.42); + backdrop-filter: blur(4px); +} + +.slider-stack { + display: flex; + flex-direction: column; + gap: 10px; + margin-top: 4px; +} + +.slider-row { + display: flex; + align-items: center; + gap: 10px; +} + +.slider-row .slider-key { + width: 20px; + flex: none; + font-family: var(--font-mono); + font-size: 0.75rem; + font-weight: 700; + color: var(--text-muted); +} + +.slider-row input[type="range"] { + flex: 1; +} + +.slider-row .slider-num { + width: 40px; + flex: none; + text-align: right; + font-family: var(--font-mono); + font-size: 0.78rem; + color: var(--text-secondary); + font-variant-numeric: tabular-nums; +} + +.swatch-list { + display: flex; + flex-wrap: wrap; + gap: 8px; +} + +.swatch { + width: 32px; + height: 32px; + border-radius: 9px; + border: 1px solid rgba(0, 0, 0, 0.08); + cursor: pointer; + transition: + transform var(--rate) ease, + box-shadow var(--rate) ease; +} + +html[data-theme="dark"] .swatch { + border-color: rgba(255, 255, 255, 0.12); +} + +.swatch:hover { + transform: scale(1.1); + box-shadow: var(--shadow-sm); +} + +/* ---------- 选项统计 ---------- */ + +.option-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); + gap: 13px; +} + +.meta-line { + display: flex; + align-items: center; + justify-content: space-between; + gap: 8px; + font-size: 0.85rem; +} + +.meta-line .meta-label { + color: var(--text-secondary); +} + +.meta-line .meta-value { + font-weight: 650; + font-variant-numeric: tabular-nums; +} + +.divider { + height: 1px; + background: var(--border); + margin: 14px 0; +} + +/* ---------- PDF 预览 ---------- */ + +.preview-frame { + display: flex; + align-items: center; + justify-content: center; + min-height: 340px; + padding: 16px; + border: 1px solid var(--border); + border-radius: 12px; + background: var(--surface-2); + overflow: auto; +} + +.preview-frame canvas { + max-width: 100%; + max-height: 460px; + border-radius: 4px; + box-shadow: var(--shadow-md); + background: #fff; +} + +.preview-controls { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: 10px; + margin-top: 12px; +} + +.page-nav { + display: flex; + align-items: center; + gap: 6px; + font-size: 0.8rem; + color: var(--text-secondary); + font-variant-numeric: tabular-nums; +} + +.zoom-control { + display: flex; + align-items: center; + gap: 7px; + font-size: 0.8rem; + color: var(--text-secondary); +} + +.zoom-control input[type="range"] { + width: 96px; +} + +.preview-meta { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + gap: 8px; + margin-top: 12px; + padding-top: 12px; + border-top: 1px solid var(--border); + font-size: 0.75rem; + color: var(--text-muted); +} + +/* ---------- 模态框 / 图片预览 ---------- */ + +.overlay { + position: fixed; + inset: 0; + z-index: 1000; + display: none; + align-items: center; + justify-content: center; + padding: 22px; + background: rgba(5, 7, 15, 0.66); + backdrop-filter: blur(5px); +} + +.overlay.show { + display: flex; +} + +.modal { + width: min(920px, 100%); + max-height: 92vh; + display: flex; + flex-direction: column; + border: 1px solid var(--border); + border-radius: var(--radius-lg); + background: var(--surface); + box-shadow: var(--shadow-lg); + overflow: hidden; +} + +.modal-head { + display: flex; + align-items: center; + gap: 10px; + padding: 12px 16px; + border-bottom: 1px solid var(--border); + font-size: 0.85rem; + font-weight: 600; + flex: none; +} + +.modal-head .modal-title { + flex: 1; + min-width: 0; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.modal-body { + flex: 1; + min-height: 160px; + display: flex; + align-items: center; + justify-content: center; + padding: 18px; + background: var(--surface-2); + overflow: auto; +} + +.modal-body img { + max-width: 100%; + max-height: 68vh; + object-fit: contain; + border-radius: 4px; + transition: transform 0.15s ease; + transform-origin: center center; +} + +.modal-foot { + display: flex; + align-items: center; + justify-content: center; + gap: 8px; + padding: 10px 16px; + border-top: 1px solid var(--border); + flex-wrap: wrap; +} + +/* ---------- Toast ---------- */ + +.toast-wrap { + position: fixed; + left: 50%; + bottom: 26px; + z-index: 2000; + display: flex; + flex-direction: column; + align-items: center; + gap: 8px; + transform: translateX(-50%); + pointer-events: none; + padding: 0 16px; + width: max-content; + max-width: 100%; +} + +.toast { + display: flex; + align-items: center; + gap: 8px; + padding: 9px 15px; + border: 1px solid rgba(255, 255, 255, 0.1); + border-radius: 10px; + background: #151827; + color: #f4f5fb; + font-size: 0.82rem; + font-weight: 500; + box-shadow: 0 14px 34px -14px rgba(0, 0, 0, 0.6); + opacity: 0; + transform: translateY(8px); + transition: + opacity 0.2s ease, + transform 0.2s ease; + max-width: 92vw; +} + +.toast.show { + opacity: 1; + transform: none; +} + +.toast-icon { + width: 16px; + height: 16px; + flex: none; + display: grid; + place-items: center; + border-radius: 50%; + font-size: 10px; + font-weight: 800; + background: rgba(255, 255, 255, 0.14); +} + +.toast--success .toast-icon { + background: #10b981; + color: #04120c; +} + +.toast--error .toast-icon { + background: #f87171; + color: #260607; +} + +/* ---------- 其他页面元素 ---------- */ + +.hint { + color: var(--text-muted); + font-size: 0.78rem; +} + +.text-center { + text-align: center; +} + +.stack { + display: flex; + flex-direction: column; + gap: 12px; +} + +.stack-sm { + display: flex; + flex-direction: column; + gap: 8px; +} + +.wrap { + flex-wrap: wrap; +} + +/* ---------- 响应式 ---------- */ + +@media (max-width: 900px) { + .split, + .color-layout { + grid-template-columns: 1fr; + } + + .sticky { + position: static; + } +} + +@media (max-width: 760px) { + body { + font-size: 14.5px; + } + + .tool-page { + padding: 18px 16px 28px; + } + + .tool-header { + gap: 12px; + margin-bottom: 20px; + } + + .tool-header .tool-icon { + width: 42px; + height: 42px; + border-radius: 12px; + } + + .tool-header p { + display: none; + } + + .editor-app { + height: auto; + min-height: 100dvh; + padding: 14px 12px; + } + + .editor-app .tool-header p { + display: none; + } + + .editor-split { + display: flex; + flex-direction: column; + } + + .editor-pane { + min-height: 300px; + } + + .editor-toolbar { + position: sticky; + top: 0; + z-index: 5; + } + + .editor-status > span:last-child { + display: none; + } + + .image-grid { + grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); + gap: 10px; + } + + .stat-value { + font-size: 1.25rem; + } + + .sv-panel { + height: 220px; + } +} + +@media (max-width: 480px) { + .segmented { + width: 100%; + } + + .segmented .seg { + flex: 1; + } + + .segmented .seg span { + width: 100%; + justify-content: center; + padding: 6px 8px; + } + + .image-grid { + grid-template-columns: repeat(2, 1fr); + } + + .modal-body img { + max-height: 58vh; + } +} + +@media (hover: none) { + .image-card .card-actions { + opacity: 1; + } +} + +@media (prefers-reduced-motion: reduce) { + *, + *::before, + *::after { + animation-duration: 0.001ms !important; + animation-iteration-count: 1 !important; + transition-duration: 0.001ms !important; + scroll-behavior: auto !important; + } +} diff --git a/color_pick.html b/color_pick.html index 99c2699..745d131 100644 --- a/color_pick.html +++ b/color_pick.html @@ -3,873 +3,837 @@ - 颜色选择器 + 颜色选择器 · 功能工具箱 + + + -
-

颜色选择器

+
+
+
+ +
+
+

颜色选择器

+

在色板上取色,或手动输入 RGB / HEX,一键复制多种颜色格式。

+
+
+ +
+
+ +
+ +
+
+ #6366f1 +
+ +
+
+
+
+
+
+ +
+
+ R + + 99 +
+
+ G + + 102 +
+
+ B + + 241 +
+
+ +

+ 上下拖动调整明度,左右拖动调整饱和度;右侧色相条用于选择色相。 +

+
+ + +
+
颜色格式
+ +
+
+ HEX + #6366f1 + +
+
+ RGB + rgb(99, 102, 241) + +
+
+ HSL + hsl(239, 84%, 67%) + +
+
+ HSV + hsv(239, 59%, 95%) + +
+
+ +
+
手动输入
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+
-
- -
-
- -
-
- - - 255 -
-
- - - 255 -
-
- - - 255 -
+ class="alert alert--error hidden" + id="colorError" + style="margin-top: 12px" + role="alert" + > + +
- -
-
-
-
-
-
-
-
- - -
-

颜色历史记录

-
-
-
- - -
-
-
- RGB: rgb(255, 255, 255) - -
-
- Hex: #ffffff - -
-
- HSL: hsl(0, 0%, 100%) - -
-
- HSV: hsv(0, 0%, 100%) -
+
+

复制或应用颜色后会自动记录。

- - -
- - - - - - - - - - - - - - - - -
-
-
+
diff --git a/electricity_calculator.html b/electricity_calculator.html index c2b839c..b208f41 100644 --- a/electricity_calculator.html +++ b/electricity_calculator.html @@ -1,506 +1,690 @@ - + - 电费计算器 - + 电费计算器 · 功能工具箱 + + + -
-

电费计算器

- -
- - -
- - -
-
- - +
+
+
+
- -
- - +
+

电费计算器

+

根据设备功率、使用时长与电价,快速估算用电成本。

- -
- - -
-
- - -
+ +
+
+
+ + +
+ 输入后自动计算 +
+ + +
+
+
+ +
+ + 瓦 (W) +
+
+
+ +
+ + 小时 +
+
+
+ +
+ + 元 / 度 +
-
- -
-
+ + +
- - -
-
+
+

计算结果

-
- 每日电费: - 0.00 + + 实时估算 +
+ + + + +
+
+
+
每日电费
+
+ 0.00元 +
+
+
+ 每日用电 0.00 度
+ 每度电约 0.60 元 +
-
- 每周电费: - 0.00 -
-
- 每月电费: - 0.00 -
-
- 每年电费: - 0.00 + +
+
+
每周电费
+
+ 0.00元 +
+
+
+
每月电费 · 30 天
+
+ 0.00元 +
+
+
+
每年电费 · 365 天
+
+ 0.00元 +
+
-
diff --git a/image_compressor.html b/image_compressor.html index 16fb26b..90dcef3 100644 --- a/image_compressor.html +++ b/image_compressor.html @@ -3,1198 +3,1270 @@ - 图片压缩工具 + 图片压缩 · 功能工具箱 + + + + -
-

图片压缩工具(纯前端,后台不保存数据)

+
+
+
+ +
+
+

图片压缩

+

批量压缩图片体积,可调节质量、输出格式与最大尺寸。

+
+
+ +
+
-
- -
- -
-
🖼️
-
点击或拖拽图片到这里
-
支持 JPG、PNG、WEBP 格式
- - -
+
+ +
+
+
+

图片

+ 0 张 + + + +
- -
-
-
- -
-
- 压缩质量 - 80% -
- -
- 低质量 - 高质量 -
-
+
+
+
+ 点击或拖拽图片到这里 + 支持 JPG、PNG、WEBP 等常见格式,可一次选择多张 + + +
-
- + +
+
+ + +
- - + +
+ 等待添加图片 + + 添加图片后可开始压缩 + +
+ + - - -
- -
-
-
+
+
+
+
+
处理中…
-
处理中...
-
-
- -
- -
-
📷
-
还没有选择图片
-
点击左侧区域选择要压缩的图片
-
- - - -
+

+ PNG 为无损格式,质量参数对 PNG 不生效;转换为 JPEG + 时透明区域会填充为白色。若重新编码后体积反而变大,会自动保留原图。修改设置后需要重新压缩。 +

+ +
- -
-
-
-
图片预览
- + + + + +