feat: V1.1 批次入库——色号表SEO页/Showcase/图纸库/帮助中心/JSON-LD/CI门禁/竞品分析
This commit is contained in:
1 parent
40e2342a02
commit
f53f0a2b25
104 files changed
+21760
-157
No files matched your search
@@ -21,6 +21,14 @@ COPY tsconfig.json vite.config.ts index.html ./
|
||||
COPY src ./src
|
||||
COPY public ./public
|
||||
|
||||
# 生产 API 基址(T-110):默认同源 /api,浏览器请求走 Nginx `/api/` 反向代理到
|
||||
# 后端容器(server:8788),同源请求无需 CORS。可用 build arg 覆盖:
|
||||
# docker compose build --build-arg VITE_API_BASE=http://api.example.com
|
||||
# 注意:仅影响本镜像构建;本地 `npm run dev`(Vite 5173)无此变量,仍回退到
|
||||
# src/lib/api.ts 中的开发默认值 http://localhost:8788。
|
||||
ARG VITE_API_BASE=/api
|
||||
ENV VITE_API_BASE=$VITE_API_BASE
|
||||
|
||||
# 构建 React 应用 → dist/(与 package.json 的 build 脚本一致:vite build)
|
||||
RUN npm run build
|
||||
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
// Generate perler-lab/src/lib/faq-data.ts from docs/FAQ-DATA.md (T-106/T-107 contract).
|
||||
// Usage: node scripts/generate-faq-data.mjs (run from perler-lab/)
|
||||
import { readFileSync, writeFileSync } from 'node:fs';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const ROOT = dirname(dirname(fileURLToPath(import.meta.url))); // perler-lab/
|
||||
const mdPath = resolve(ROOT, '../docs/FAQ-DATA.md');
|
||||
const outPath = resolve(ROOT, 'src/lib/faq-data.ts');
|
||||
const md = readFileSync(mdPath, 'utf8');
|
||||
|
||||
// zh/en labels per category id (derived from FAQ-DATA.md section headers + appendix table)
|
||||
const CATEGORY_LABELS = {
|
||||
'bead-selection': { zh: '选豆', en: 'Bead Selection' },
|
||||
'color-matching': { zh: '配色与图纸生成', en: 'Color Matching & Generation' },
|
||||
printing: { zh: '打印', en: 'Printing' },
|
||||
ironing: { zh: '熨烫', en: 'Ironing' },
|
||||
framing: { zh: '裱框', en: 'Framing' },
|
||||
redemption: { zh: '兑换码与权益', en: 'Redemption & Credits' },
|
||||
'ai-zone': { zh: 'AI 专区', en: 'AI Zone' },
|
||||
product: { zh: '平台与使用', en: 'Platform & Usage' },
|
||||
};
|
||||
|
||||
const FIELD_RE = /^\s*-\s+\*\*(\w+)\*\*:\s*(.*)$/;
|
||||
|
||||
/** Parse FAQ items: blocks starting with "### FAQ-XX" containing "- **field**: value" lines. */
|
||||
function parseItems(text) {
|
||||
const items = [];
|
||||
const lines = text.split('\n');
|
||||
let cur = null;
|
||||
|
||||
const flush = () => {
|
||||
if (cur && cur.category && cur.questionZh && cur.answerZh) {
|
||||
items.push(cur);
|
||||
}
|
||||
cur = null;
|
||||
};
|
||||
|
||||
for (const line of lines) {
|
||||
const heading = line.match(/^###\s+(FAQ-\d+)/);
|
||||
if (heading) {
|
||||
flush();
|
||||
cur = { id: heading[1] };
|
||||
continue;
|
||||
}
|
||||
if (!cur) continue;
|
||||
if (line.trim() === '---') {
|
||||
flush();
|
||||
continue;
|
||||
}
|
||||
const m = line.match(FIELD_RE);
|
||||
if (m) {
|
||||
const [, key, value] = m;
|
||||
if (key === 'category') {
|
||||
cur.category = value.split('/')[0].trim(); // "bead-selection / 选豆"
|
||||
} else if (key === 'question_zh') cur.questionZh = value.trim();
|
||||
else if (key === 'question_en') cur.questionEn = value.trim();
|
||||
else if (key === 'answer_zh') cur.answerZh = value.trim();
|
||||
else if (key === 'answer_en') cur.answerEn = value.trim();
|
||||
}
|
||||
}
|
||||
flush();
|
||||
return items;
|
||||
}
|
||||
|
||||
const items = parseItems(md);
|
||||
|
||||
// group by category preserving md order; build typed TS output
|
||||
const byCat = new Map();
|
||||
for (const it of items) {
|
||||
if (!byCat.has(it.category)) byCat.set(it.category, []);
|
||||
byCat.get(it.category).push(it);
|
||||
}
|
||||
|
||||
const esc = (s) => s.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\${/g, '\\${');
|
||||
|
||||
const catBlocks = [];
|
||||
for (const [catId, list] of byCat) {
|
||||
const labels = CATEGORY_LABELS[catId];
|
||||
if (!labels) throw new Error('Unknown category: ' + catId);
|
||||
const itemLines = list.map(
|
||||
(it) => ` {
|
||||
id: '${it.id}',
|
||||
questionZh: \`${esc(it.questionZh)}\`,
|
||||
questionEn: \`${esc(it.questionEn ?? '')}\`,
|
||||
answerZh: \`${esc(it.answerZh)}\`,
|
||||
answerEn: \`${esc(it.answerEn ?? '')}\`,
|
||||
},`,
|
||||
);
|
||||
catBlocks.push(` {
|
||||
id: '${catId}',
|
||||
labelZh: '${labels.zh}',
|
||||
labelEn: '${labels.en}',
|
||||
items: [
|
||||
${itemLines.join('\n')}
|
||||
],
|
||||
},`);
|
||||
}
|
||||
|
||||
const total = items.length;
|
||||
const header = `/**
|
||||
* PERLER LAB — 帮助中心 FAQ 数据(T-106)
|
||||
*
|
||||
* 数据源: docs/FAQ-DATA.md(T-107,共 ${total} 条,8 个分类)。
|
||||
* 由脚本生成(question/answer 双语言 zh+en),供 HelpPage 渲染。
|
||||
* 变更流程: 修改 FAQ-DATA.md → 重新运行 node scripts/generate-faq-data.mjs。
|
||||
*/
|
||||
|
||||
export interface FaqItem {
|
||||
/** FAQ 编号,如 FAQ-01。 */
|
||||
id: string;
|
||||
questionZh: string;
|
||||
questionEn: string;
|
||||
answerZh: string;
|
||||
answerEn: string;
|
||||
}
|
||||
|
||||
export interface FaqCategory {
|
||||
/** 分类标签(过滤/展示用),如 'bead-selection'。 */
|
||||
id: string;
|
||||
labelZh: string;
|
||||
labelEn: string;
|
||||
items: readonly FaqItem[];
|
||||
}
|
||||
|
||||
export const FAQ_CATEGORIES: readonly FaqCategory[] = [
|
||||
${catBlocks.join('\n')}
|
||||
];
|
||||
|
||||
export const FAQ_TOTAL: number = ${total};
|
||||
`;
|
||||
|
||||
writeFileSync(outPath, header, 'utf8');
|
||||
console.log(`OK: ${items.length} items across ${byCat.size} categories -> ${outPath}`);
|
||||
+22
-2
@@ -1,5 +1,9 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import ChibiPage from './ChibiPage';
|
||||
import ColorChartPage from './ColorChartPage';
|
||||
import ShowcasePage from './pages/ShowcasePage';
|
||||
import LibraryPage from './pages/LibraryPage';
|
||||
import HelpPage from './pages/HelpPage';
|
||||
import Nav from './components/Nav';
|
||||
import Hero from './components/Hero';
|
||||
import PassSection, { type Plan } from './components/PassSection';
|
||||
@@ -314,8 +318,12 @@ function HomePage() {
|
||||
|
||||
/**
|
||||
* Root component:
|
||||
* - `/chibi` → AI 拼豆专区
|
||||
* - 其他路径 → 首页(图片转拼豆)
|
||||
* - `/chibi` → AI 拼豆专区
|
||||
* - `/color-chart`、`/color-chart/:brand` → 品牌色号表页(T-091/T-092/T-093)
|
||||
* - `/showcase` → 作品展示页(T-097/T-098)
|
||||
* - `/library` → 图纸库页(T-108)
|
||||
* - `/help` → 帮助中心 FAQ 页(T-106)
|
||||
* - 其他路径 → 首页(图片转拼豆)
|
||||
*/
|
||||
export default function App() {
|
||||
const [path, setPath] = useState<string>(() => window.location.pathname);
|
||||
@@ -329,5 +337,17 @@ export default function App() {
|
||||
if (path === '/chibi' || path.startsWith('/chibi/')) {
|
||||
return <ChibiPage />;
|
||||
}
|
||||
if (path === '/color-chart' || path.startsWith('/color-chart/')) {
|
||||
return <ColorChartPage />;
|
||||
}
|
||||
if (path === '/showcase' || path.startsWith('/showcase/')) {
|
||||
return <ShowcasePage />;
|
||||
}
|
||||
if (path === '/library' || path.startsWith('/library/')) {
|
||||
return <LibraryPage />;
|
||||
}
|
||||
if (path === '/help' || path.startsWith('/help/')) {
|
||||
return <HelpPage />;
|
||||
}
|
||||
return <HomePage />;
|
||||
}
|
||||
@@ -1321,3 +1321,88 @@
|
||||
font-size: var(--text-xs);
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
/* ═══════════════════════ 发布到展示 (T-102) ═══════════════════════ */
|
||||
|
||||
.chibi-publish {
|
||||
margin-top: var(--space-4);
|
||||
padding: var(--space-4);
|
||||
border: 1px dashed var(--border-dashed);
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--bg-card);
|
||||
}
|
||||
|
||||
.chibi-publish-head {
|
||||
margin-bottom: var(--space-3);
|
||||
}
|
||||
|
||||
.chibi-publish-title {
|
||||
font-size: var(--text-md);
|
||||
font-weight: 700;
|
||||
margin: 0 0 var(--space-1);
|
||||
}
|
||||
|
||||
.chibi-publish-desc {
|
||||
font-size: var(--text-xs);
|
||||
color: var(--text-tertiary);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.chibi-publish-row {
|
||||
display: flex;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.chibi-publish-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: var(--touch-min);
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: var(--radius-md);
|
||||
padding: 0 var(--space-3);
|
||||
font-size: var(--text-md);
|
||||
font-family: var(--font-sans);
|
||||
background: var(--bg-hover);
|
||||
outline: none;
|
||||
transition: border-color .15s ease;
|
||||
}
|
||||
|
||||
.chibi-publish-input:focus {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.chibi-publish-btn {
|
||||
min-height: var(--touch-min);
|
||||
font-size: var(--text-md);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.chibi-publish-done {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.chibi-publish-done .chibi-btn {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.chibi-publish-success {
|
||||
font-size: var(--text-sm);
|
||||
font-weight: 500;
|
||||
color: var(--success);
|
||||
font-family: var(--font-mono);
|
||||
word-break: break-all;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.chibi-publish-row {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.chibi-publish-btn {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import "./ChibiPage.css";
|
||||
import { generateChibi, redeemCode } from "./lib/api";
|
||||
import { generateChibi, publishShowcaseWork, redeemCode } from "./lib/api";
|
||||
import { CHIBI_CATEGORY_TO_TAG } from "./lib/showcase";
|
||||
import { useT, type MessageKey } from "./i18n";
|
||||
import LangSwitcher from "./components/LangSwitcher";
|
||||
|
||||
@@ -385,6 +386,12 @@ export function ChibiPage() {
|
||||
const [generateError, setGenerateError] = useState<string | null>(null);
|
||||
const tagHintTimerRef = useRef<number | null>(null);
|
||||
|
||||
// 发布到展示状态(T-102)
|
||||
const [publishTitle, setPublishTitle] = useState<string>("");
|
||||
const [publishing, setPublishing] = useState(false);
|
||||
const [publishError, setPublishError] = useState<string | null>(null);
|
||||
const [publishedId, setPublishedId] = useState<string | null>(null);
|
||||
|
||||
const hasCode = redeemedCode !== null;
|
||||
|
||||
const category = CATEGORIES.find((c) => c.id === categoryId) ?? CATEGORIES[0];
|
||||
@@ -491,6 +498,29 @@ export function ChibiPage() {
|
||||
}
|
||||
};
|
||||
|
||||
// T-102:发布到作品展示(POST /api/showcase/works,接口约定见 lib/api.ts)
|
||||
const publish = async (): Promise<void> => {
|
||||
if (!generatedImage || publishing) return;
|
||||
setPublishing(true);
|
||||
setPublishError(null);
|
||||
try {
|
||||
const fallbackTitle = t(category?.nameKey ?? "chibi.cat.pet.name") + " · " +
|
||||
t(selectedSubtype?.nameKey ?? "chibi.cat.pet.cat");
|
||||
const tag = CHIBI_CATEGORY_TO_TAG[categoryId];
|
||||
const res = await publishShowcaseWork({
|
||||
title: publishTitle.trim() || fallbackTitle,
|
||||
imageData: generatedImage,
|
||||
tags: tag ? [tag] : [],
|
||||
source: "chibi",
|
||||
});
|
||||
setPublishedId(res.id);
|
||||
} catch (err) {
|
||||
setPublishError(err instanceof Error ? err.message : t("chibi.publish.fail"));
|
||||
} finally {
|
||||
setPublishing(false);
|
||||
}
|
||||
};
|
||||
|
||||
const ctaLabel = generating
|
||||
? t("chibi.cta.generating")
|
||||
: hasCode
|
||||
@@ -823,6 +853,49 @@ export function ChibiPage() {
|
||||
{downloadGrant ? t("chibi.result.withGrant") : t("chibi.result.plain")}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* ── T-102:发布到展示 ── */}
|
||||
<div className="chibi-publish">
|
||||
{publishedId === null ? (
|
||||
<>
|
||||
<div className="chibi-publish-head">
|
||||
<h3 className="chibi-publish-title">{t("chibi.publish.title")}</h3>
|
||||
<p className="chibi-publish-desc">{t("chibi.publish.desc")}</p>
|
||||
</div>
|
||||
<div className="chibi-publish-row">
|
||||
<input
|
||||
className="chibi-publish-input"
|
||||
placeholder={t("chibi.publish.placeholder")}
|
||||
maxLength={40}
|
||||
value={publishTitle}
|
||||
onChange={(e) => {
|
||||
setPublishTitle(e.target.value);
|
||||
setPublishError(null);
|
||||
}}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
className="chibi-btn chibi-btn-primary chibi-publish-btn"
|
||||
disabled={publishing}
|
||||
onClick={publish}
|
||||
>
|
||||
{publishing && <span className="chibi-spinner" />}
|
||||
{publishing ? t("chibi.publish.publishing") : t("chibi.publish.button")}
|
||||
</button>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className="chibi-publish-done">
|
||||
<p className="chibi-publish-success">
|
||||
{t("chibi.publish.published", { id: publishedId })}
|
||||
</p>
|
||||
<a className="chibi-btn chibi-btn-primary" href="/showcase">
|
||||
{t("chibi.publish.view")}
|
||||
</a>
|
||||
</div>
|
||||
)}
|
||||
{publishError && <p className="chibi-upload-error">{publishError}</p>}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
|
||||
@@ -0,0 +1,485 @@
|
||||
/* =============================================================================
|
||||
* PERLER LAB — 品牌色号表页 (/color-chart)
|
||||
* DESIGN.md §1 tokens (scoped under .chart-page)
|
||||
* ========================================================================= */
|
||||
|
||||
.chart-page {
|
||||
/* ── 色彩系统 (DESIGN.md §1.1) ─────────────────────────────── */
|
||||
--bg-page: #f4f3ef;
|
||||
--bg-card: #ffffff;
|
||||
--bg-subtle: #f0ede4;
|
||||
--bg-hover: #faf9f4;
|
||||
--text-primary: #171713;
|
||||
--text-secondary: #66645d;
|
||||
--text-tertiary: #8a877d;
|
||||
--text-disabled: #b0aca0;
|
||||
--text-on-dark: #ffffff;
|
||||
--accent: #edb045;
|
||||
--accent-hover: #dda02e;
|
||||
--accent-soft: #fdf3df;
|
||||
--success: #3daf80;
|
||||
--danger: #e04f4f;
|
||||
--info: #3677d2;
|
||||
--border: #e6e3d9;
|
||||
--border-strong: #d2cec4;
|
||||
--border-dashed: #e0dccd;
|
||||
|
||||
/* ── 字体系统 (DESIGN.md §1.2) ─────────────────────────────── */
|
||||
--font-sans: "Geist", system-ui, -apple-system, "Segoe UI", "PingFang SC",
|
||||
"Microsoft YaHei", sans-serif;
|
||||
--font-mono: "Geist Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
|
||||
--text-xs: 11px;
|
||||
--text-sm: 12px;
|
||||
--text-md: 13px;
|
||||
--text-lg: 17px;
|
||||
--text-xl: 20px;
|
||||
--text-hero: 32px;
|
||||
|
||||
/* ── 间距 / 圆角 / 阴影 (DESIGN.md §1.3) ───────────────────── */
|
||||
--space-1: 4px;
|
||||
--space-2: 8px;
|
||||
--space-3: 12px;
|
||||
--space-4: 16px;
|
||||
--space-5: 24px;
|
||||
--space-6: 32px;
|
||||
--radius-sm: 8px;
|
||||
--radius-md: 10px;
|
||||
--radius-lg: 12px;
|
||||
--radius-full: 999px;
|
||||
--shadow-card: 0 1px 2px rgba(0, 0, 0, .04);
|
||||
--shadow-float: 0 2px 12px rgba(23, 23, 19, .08);
|
||||
|
||||
/* ── 触控目标 (DESIGN.md §1.4) ─────────────────────────────── */
|
||||
--touch-min: 40px;
|
||||
--touch-min-sm: 34px;
|
||||
|
||||
background: var(--bg-page);
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-sans);
|
||||
font-size: var(--text-md);
|
||||
line-height: 1.6;
|
||||
min-height: 100vh;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
.chart-page *,
|
||||
.chart-page *::before,
|
||||
.chart-page *::after {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.chart-page button {
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
background: none;
|
||||
}
|
||||
|
||||
.chart-page a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* ═══════════════════════ NAV ═══════════════════════ */
|
||||
|
||||
.chart-nav {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 100;
|
||||
height: 56px;
|
||||
background: var(--bg-card);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.chart-nav-inner {
|
||||
max-width: 1280px;
|
||||
height: 100%;
|
||||
margin: 0 auto;
|
||||
padding: 0 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-5);
|
||||
}
|
||||
|
||||
.chart-nav-back {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
height: var(--touch-min-sm);
|
||||
padding: 0 var(--space-2);
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--text-md);
|
||||
font-weight: 500;
|
||||
border-radius: var(--radius-sm);
|
||||
transition: color .15s ease;
|
||||
}
|
||||
|
||||
.chart-nav-back:hover {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.chart-brand {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
font-size: var(--text-lg);
|
||||
font-weight: 700;
|
||||
letter-spacing: .02em;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.chart-brand-mark {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--text-primary);
|
||||
color: var(--bg-card);
|
||||
font-size: var(--text-md);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.chart-nav-spacer {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.chart-nav-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
height: 24px;
|
||||
padding: 0 var(--space-2);
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: var(--radius-full);
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--text-xs);
|
||||
letter-spacing: .08em;
|
||||
}
|
||||
|
||||
/* ═══════════════════════ HERO ═══════════════════════ */
|
||||
|
||||
.chart-hero {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: var(--space-6) var(--space-5) var(--space-5);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.chart-h1 {
|
||||
font-size: var(--text-hero);
|
||||
font-weight: 700;
|
||||
letter-spacing: .01em;
|
||||
line-height: 1.25;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.chart-sub {
|
||||
margin-top: var(--space-3);
|
||||
font-size: var(--text-lg);
|
||||
color: var(--text-secondary);
|
||||
max-width: 640px;
|
||||
margin-inline: auto;
|
||||
}
|
||||
|
||||
/* ═══════════════════════ MAIN ═══════════════════════ */
|
||||
|
||||
.chart-main {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: var(--space-2) var(--space-5) var(--space-6);
|
||||
}
|
||||
|
||||
/* ── 品牌切换 Tab ── */
|
||||
|
||||
.chart-tabs {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-2);
|
||||
justify-content: center;
|
||||
margin-bottom: var(--space-5);
|
||||
}
|
||||
|
||||
.chart-tab {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 2px;
|
||||
min-width: 128px;
|
||||
padding: var(--space-3) var(--space-4);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--bg-card);
|
||||
color: var(--text-secondary);
|
||||
transition: border-color .15s ease, color .15s ease, background .15s ease;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.chart-tab:hover {
|
||||
border-color: var(--border-strong);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.chart-tab.is-selected {
|
||||
border-color: var(--accent);
|
||||
background: var(--accent-soft);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.chart-tab-name {
|
||||
font-size: var(--text-lg);
|
||||
font-weight: 600;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.chart-tab-meta {
|
||||
font-size: var(--text-sm);
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.chart-tab-count {
|
||||
margin-top: var(--space-1);
|
||||
font-size: var(--text-xs);
|
||||
font-weight: 500;
|
||||
color: var(--accent-hover);
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
/* ── 色号表卡片 ── */
|
||||
|
||||
.chart-table-card {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-card);
|
||||
padding: var(--space-4);
|
||||
}
|
||||
|
||||
.chart-table {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.chart-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
padding: var(--space-2);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--bg-hover);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.chart-swatch {
|
||||
flex: 0 0 34px;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border-radius: var(--radius-sm);
|
||||
border: 1px solid rgba(23, 23, 19, 0.12);
|
||||
box-shadow: var(--shadow-card);
|
||||
}
|
||||
|
||||
.chart-code {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-md);
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.chart-hex {
|
||||
flex: 0 0 auto;
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-xs);
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.chart-name {
|
||||
flex: 0 0 auto;
|
||||
font-size: var(--text-xs);
|
||||
color: var(--text-tertiary);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 110px;
|
||||
}
|
||||
|
||||
.chart-empty {
|
||||
padding: var(--space-6);
|
||||
text-align: center;
|
||||
color: var(--text-disabled);
|
||||
}
|
||||
|
||||
/* ── 品牌互链(SEO 内链,6 品牌 + 回首页) ── */
|
||||
|
||||
.chart-crosslinks {
|
||||
margin-top: var(--space-5);
|
||||
padding: var(--space-4);
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-card);
|
||||
}
|
||||
|
||||
.chart-crosslinks-title {
|
||||
font-size: var(--text-md);
|
||||
font-weight: 600;
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: var(--space-3);
|
||||
}
|
||||
|
||||
.chart-crosslinks-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.chart-crosslink {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: var(--space-2);
|
||||
min-height: var(--touch-min-sm);
|
||||
padding: var(--space-1) var(--space-3);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-full);
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--text-sm);
|
||||
transition: border-color .15s ease, color .15s ease, background .15s ease;
|
||||
}
|
||||
|
||||
.chart-crosslink:hover {
|
||||
border-color: var(--accent);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.chart-crosslink.is-current {
|
||||
border-color: var(--accent);
|
||||
background: var(--accent-soft);
|
||||
color: var(--text-primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.chart-crosslink-name {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.chart-crosslink-count {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-xs);
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.chart-crosslinks-home {
|
||||
display: inline-block;
|
||||
margin-top: var(--space-3);
|
||||
font-size: var(--text-sm);
|
||||
font-weight: 500;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.chart-crosslinks-home:hover {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
/* ═══════════════════════ FOOTER ═══════════════════════ */
|
||||
|
||||
.chart-footer {
|
||||
border-top: 1px solid var(--border);
|
||||
background: var(--bg-card);
|
||||
}
|
||||
|
||||
.chart-footer-inner {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: var(--space-5) var(--space-4);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: var(--space-4);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.chart-footer-text {
|
||||
font-size: var(--text-sm);
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.chart-footer-link {
|
||||
font-size: var(--text-sm);
|
||||
font-weight: 500;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.chart-footer-link:hover {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
/* ═══════════════════════ RESPONSIVE ═══════════════════════ */
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.chart-nav-inner {
|
||||
padding: 0 var(--space-3);
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.chart-nav-badge {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.chart-hero {
|
||||
padding: var(--space-5) var(--space-4) var(--space-4);
|
||||
}
|
||||
|
||||
.chart-h1 {
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.chart-sub {
|
||||
font-size: var(--text-md);
|
||||
}
|
||||
|
||||
.chart-main {
|
||||
padding: var(--space-2) var(--space-3) var(--space-5);
|
||||
}
|
||||
|
||||
.chart-tabs {
|
||||
justify-content: stretch;
|
||||
}
|
||||
|
||||
.chart-tab {
|
||||
flex: 1 1 44%;
|
||||
min-width: 0;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
padding: var(--space-2) var(--space-3);
|
||||
}
|
||||
|
||||
.chart-table {
|
||||
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.chart-row {
|
||||
padding: var(--space-1);
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.chart-swatch {
|
||||
flex-basis: 28px;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
.chart-name {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
/**
|
||||
* PERLER LAB — 品牌色号表页面 (/color-chart/:brand)
|
||||
*
|
||||
* T-091/T-092/T-093:六品牌(MARD / Artkal-C / Perler / Hama / Pyssla / Nabbi)
|
||||
* 色号速查页。数据来自 src/lib/color-chart-data.ts(复用既有 MARD_PALETTE +
|
||||
* competitor-analysis/palettes JSON 资产)。
|
||||
*
|
||||
* 无路由环境亦可直接挂载:brandId 通过 props 传入;缺省时从
|
||||
* window.location.pathname 推导(/color-chart/mard 等)。
|
||||
*/
|
||||
import { useEffect, useState } from 'react';
|
||||
import './ColorChartPage.css';
|
||||
import { useT } from './i18n';
|
||||
import LangSwitcher from './components/LangSwitcher';
|
||||
import { COLOR_CHART_BRANDS, getColorChartBrand } from './lib/color-chart-data';
|
||||
|
||||
/** 从路径提取品牌段:/color-chart/mard → "mard"。 */
|
||||
function brandIdFromPath(path: string): string | null {
|
||||
const match = path.match(/^\/color-chart\/([^/]+)/);
|
||||
return match?.[1] ?? null;
|
||||
}
|
||||
|
||||
interface ColorChartPageProps {
|
||||
/** 可选:显式指定品牌 ID(如 "mard");缺省则读 URL。 */
|
||||
brandId?: string;
|
||||
}
|
||||
|
||||
export function ColorChartPage({ brandId: brandIdProp }: ColorChartPageProps) {
|
||||
const { t } = useT();
|
||||
const [selectedId, setSelectedId] = useState<string>(() => {
|
||||
if (brandIdProp) return brandIdProp.toLowerCase();
|
||||
if (typeof window === 'undefined') return COLOR_CHART_BRANDS[0]!.id;
|
||||
return brandIdFromPath(window.location.pathname) ?? COLOR_CHART_BRANDS[0]!.id;
|
||||
});
|
||||
|
||||
// URL 变化(前进/后退)时同步品牌;显式 prop 优先。
|
||||
useEffect(() => {
|
||||
if (brandIdProp) return;
|
||||
const onPop = () => {
|
||||
const id = brandIdFromPath(window.location.pathname);
|
||||
if (id) setSelectedId(id);
|
||||
};
|
||||
window.addEventListener('popstate', onPop);
|
||||
return () => window.removeEventListener('popstate', onPop);
|
||||
}, [brandIdProp]);
|
||||
|
||||
const brand = getColorChartBrand(selectedId);
|
||||
const colors = brand.colors;
|
||||
|
||||
// 品牌切换:URL 同步(供 SEO 页互链与分享),同时保留 popstate 兼容。
|
||||
const selectBrand = (id: string): void => {
|
||||
if (id === selectedId) return;
|
||||
setSelectedId(id);
|
||||
if (!brandIdProp) {
|
||||
const url = `/color-chart/${id}`;
|
||||
window.history.pushState(null, '', url);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="chart-page">
|
||||
{/* ── NAV (色号表版) ── */}
|
||||
<nav className="chart-nav">
|
||||
<div className="chart-nav-inner">
|
||||
<a className="chart-nav-back" href="/">
|
||||
{t('chart.nav.back')}
|
||||
</a>
|
||||
<a className="chart-brand" href="/">
|
||||
<span className="chart-brand-mark">P</span>
|
||||
<span>
|
||||
PERLER <b>LAB</b>
|
||||
</span>
|
||||
</a>
|
||||
<span className="chart-nav-spacer" />
|
||||
<span className="chart-nav-badge">{t('chart.hero.badge')}</span>
|
||||
<LangSwitcher base="chart-nav-lang" />
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{/* ── HERO ── */}
|
||||
<header className="chart-hero">
|
||||
<h1 className="chart-h1">{t('chart.hero.title')}</h1>
|
||||
<p className="chart-sub">{t('chart.hero.sub')}</p>
|
||||
</header>
|
||||
|
||||
{/* ── 品牌切换 ── */}
|
||||
<main className="chart-main">
|
||||
<div className="chart-tabs" role="tablist" aria-label={t('chart.tabs.aria')}>
|
||||
{COLOR_CHART_BRANDS.map((b) => {
|
||||
const selected = b.id === brand.id;
|
||||
return (
|
||||
<button
|
||||
key={b.id}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={selected}
|
||||
className={`chart-tab${selected ? ' is-selected' : ''}`}
|
||||
onClick={() => selectBrand(b.id)}
|
||||
>
|
||||
<span className="chart-tab-name">{t(b.nameKey)}</span>
|
||||
<span className="chart-tab-meta">{t(b.seriesKey)}</span>
|
||||
<span className="chart-tab-count">
|
||||
{`${b.colors.length} ${t('chart.countUnit')}`}
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* ── 色号表 ── */}
|
||||
<section className="chart-table-card" aria-label={t('chart.table.aria', {
|
||||
brand: t(brand.nameKey),
|
||||
count: colors.length,
|
||||
})}>
|
||||
{colors.length === 0 ? (
|
||||
<p className="chart-empty">{t('chart.empty')}</p>
|
||||
) : (
|
||||
<div className="chart-table">
|
||||
{colors.map((c) => (
|
||||
<div className="chart-row" key={`${c.code}-${c.hex}`}>
|
||||
<span className="chart-swatch" style={{ background: c.hex }} aria-hidden="true" />
|
||||
<span className="chart-code">{c.code}</span>
|
||||
<span className="chart-hex">{c.hex}</span>
|
||||
{c.name !== undefined && <span className="chart-name">{c.name}</span>}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
{/* ── 品牌互链(SEO 内链:6 品牌互链 + 回首页,锚文本复用品牌名) ── */}
|
||||
<section className="chart-crosslinks" aria-label={t('chart.crosslinks.title')}>
|
||||
<h2 className="chart-crosslinks-title">{t('chart.crosslinks.title')}</h2>
|
||||
<nav className="chart-crosslinks-list">
|
||||
{COLOR_CHART_BRANDS.map((b) => (
|
||||
<a
|
||||
key={b.id}
|
||||
className={`chart-crosslink${b.id === brand.id ? ' is-current' : ''}`}
|
||||
href={`/color-chart/${b.id}`}
|
||||
aria-current={b.id === brand.id ? 'page' : undefined}
|
||||
>
|
||||
<span className="chart-crosslink-name">{t(b.nameKey)}</span>
|
||||
<span className="chart-crosslink-count">
|
||||
{`${b.colors.length} ${t('chart.countUnit')}`}
|
||||
</span>
|
||||
</a>
|
||||
))}
|
||||
</nav>
|
||||
<a className="chart-crosslinks-home" href="/">
|
||||
{t('chart.crosslinks.home')}
|
||||
</a>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
{/* ── FOOTER ── */}
|
||||
<footer className="chart-footer">
|
||||
<div className="chart-footer-inner">
|
||||
<span className="chart-footer-text">{t('chart.footer')}</span>
|
||||
<a className="chart-footer-link" href="/">
|
||||
{t('chart.nav.back')}
|
||||
</a>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ColorChartPage;
|
||||
@@ -26,6 +26,9 @@ export default function Nav({ onAgencyClick }: NavProps) {
|
||||
{t('nav.chibi')}
|
||||
<span className="nav-pro-badge">PRO</span>
|
||||
</a>
|
||||
<a className="nav-link" href="/color-chart">
|
||||
{t('nav.colorChart')}
|
||||
</a>
|
||||
</nav>
|
||||
|
||||
<div className="nav-right">
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
import LangSwitcher from './LangSwitcher';
|
||||
import { useT } from '../i18n';
|
||||
|
||||
export type SubNavActive = 'home' | 'chibi' | 'showcase' | 'library' | 'help';
|
||||
|
||||
interface SubNavProps {
|
||||
active: SubNavActive;
|
||||
}
|
||||
|
||||
interface LinkItem {
|
||||
key: SubNavActive;
|
||||
href: string;
|
||||
labelKey: 'nav.home' | 'nav.toPattern' | 'nav.chibi' | 'nav.showcase' | 'nav.library' | 'nav.help';
|
||||
pro?: boolean;
|
||||
}
|
||||
|
||||
const LINKS: readonly LinkItem[] = [
|
||||
{ key: 'home', href: '/', labelKey: 'nav.home' },
|
||||
{ key: 'chibi', href: '/chibi', labelKey: 'nav.chibi', pro: true },
|
||||
{ key: 'showcase', href: '/showcase', labelKey: 'nav.showcase' },
|
||||
{ key: 'library', href: '/library', labelKey: 'nav.library' },
|
||||
{ key: 'help', href: '/help', labelKey: 'nav.help' },
|
||||
];
|
||||
|
||||
/**
|
||||
* SubNav — Showcase / Library 共用的子页导航(与 ChibiPage 的 chibi-nav 同构)。
|
||||
* 全站链接通过原生 <a> 跳转(App.tsx 按 pathname 分发路由)。
|
||||
*/
|
||||
export default function SubNav({ active }: SubNavProps) {
|
||||
const { t } = useT();
|
||||
|
||||
return (
|
||||
<nav className="pl-nav">
|
||||
<div className="pl-nav-inner">
|
||||
<a className="pl-brand" href="/">
|
||||
<span className="pl-brand-mark">P</span>
|
||||
<span>
|
||||
PERLER <b>LAB</b>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<div className="pl-nav-links">
|
||||
{LINKS.map((link) => (
|
||||
<a
|
||||
key={link.key}
|
||||
className={`pl-nav-link${link.key === active ? ' is-active' : ''}`}
|
||||
href={link.href}
|
||||
aria-current={link.key === active ? 'page' : undefined}
|
||||
>
|
||||
{t(link.labelKey)}
|
||||
{link.pro && <span className="pl-nav-pro">PRO</span>}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="pl-nav-right">
|
||||
<LangSwitcher base="pl-nav-lang" />
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
import type { ShowcaseWork, ShowcaseTag } from '../lib/showcase';
|
||||
import { SHOWCASE_TAGS } from '../lib/showcase';
|
||||
import { useT, type MessageKey } from '../i18n';
|
||||
|
||||
/**
|
||||
* WorkCard — 作品卡片(T-098)
|
||||
*
|
||||
* 展示区:缩略图 + 标题 + 标签 + 作者 + 互动数;`source === 'chibi'` 时带「AI 生成」标记。
|
||||
* 标签按钮可点击筛选(由父组件通过 `onTagClick` 承接)。
|
||||
*/
|
||||
|
||||
export const SHOWCASE_TAG_KEYS: Record<ShowcaseTag, MessageKey> = {
|
||||
landscape: 'showcase.tag.landscape',
|
||||
people: 'showcase.tag.people',
|
||||
pet: 'showcase.tag.pet',
|
||||
item: 'showcase.tag.item',
|
||||
food: 'showcase.tag.food',
|
||||
};
|
||||
|
||||
function formatCount(n: number): string {
|
||||
if (n >= 10000) return `${(n / 10000).toFixed(1)}w`;
|
||||
if (n >= 1000) return `${(n / 1000).toFixed(1)}k`;
|
||||
return String(n);
|
||||
}
|
||||
|
||||
interface WorkCardProps {
|
||||
work: ShowcaseWork;
|
||||
activeTag: ShowcaseTag | null;
|
||||
onTagClick: (tag: ShowcaseTag) => void;
|
||||
}
|
||||
|
||||
export default function WorkCard({ work, activeTag, onTagClick }: WorkCardProps) {
|
||||
const { t } = useT();
|
||||
|
||||
return (
|
||||
<article className="sw-card">
|
||||
<div className="sw-card-media">
|
||||
<img className="sw-card-img" src={work.thumb} alt={work.title} loading="lazy" />
|
||||
{work.source === 'chibi' && (
|
||||
<span className="sw-card-badge">{t('showcase.aiBadge')}</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="sw-card-body">
|
||||
<h3 className="sw-card-title">{work.title}</h3>
|
||||
<p className="sw-card-author">@{work.author}</p>
|
||||
|
||||
<div className="sw-card-tags">
|
||||
{SHOWCASE_TAGS.filter((tag) => work.tags.includes(tag)).map((tag) => (
|
||||
<button
|
||||
key={tag}
|
||||
type="button"
|
||||
className={`sw-card-tag${tag === activeTag ? ' is-active' : ''}`}
|
||||
aria-pressed={tag === activeTag}
|
||||
onClick={() => onTagClick(tag)}
|
||||
>
|
||||
{t(SHOWCASE_TAG_KEYS[tag])}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="sw-card-meta">
|
||||
<span className="sw-card-meta-item" aria-label={t('showcase.likesAria', { count: work.likes })}>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
||||
<path d="M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z" />
|
||||
</svg>
|
||||
{formatCount(work.likes)}
|
||||
</span>
|
||||
<span className="sw-card-meta-item" aria-label={t('showcase.viewsAria', { count: work.views })}>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
||||
<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0Z" />
|
||||
<circle cx="12" cy="12" r="3" />
|
||||
</svg>
|
||||
{formatCount(work.views)}
|
||||
</span>
|
||||
{work.grid && <span className="sw-card-grid">{work.grid}</span>}
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
@@ -15,6 +15,11 @@ export const en: Messages = {
|
||||
'nav.agency': 'Partnership',
|
||||
'nav.status': 'Free preview · pay per AI generation',
|
||||
'nav.lang': 'Language',
|
||||
'nav.home': 'Home',
|
||||
'nav.showcase': 'Showcase',
|
||||
'nav.library': 'Pattern Library',
|
||||
'nav.colorChart': 'Color Charts',
|
||||
'nav.help': 'Help',
|
||||
|
||||
/* ── Hero ── */
|
||||
'hero.title.prefix': 'Turn any image into',
|
||||
@@ -335,4 +340,86 @@ export const en: Messages = {
|
||||
'chibi.tag.decor': 'Reduce tiny decorations',
|
||||
'chibi.tag.saturation': 'Boost color contrast',
|
||||
'chibi.tag.topdown': 'Top-down composition',
|
||||
|
||||
/* ── ColorChartPage (brand color charts · T-091/T-092) ── */
|
||||
'chart.nav.back': '← Back to Home',
|
||||
'chart.hero.title': 'Bead Color Charts',
|
||||
'chart.hero.sub': 'Quick reference for 6 brands: MARD / Artkal-C / Perler / Hama / Pyssla / Nabbi',
|
||||
'chart.hero.badge': 'Color charts',
|
||||
'chart.tabs.aria': 'Select brand',
|
||||
'chart.count': '{count} colors',
|
||||
'chart.countUnit': 'colors',
|
||||
'chart.col.code': 'Code',
|
||||
'chart.col.hex': 'HEX',
|
||||
'chart.col.name': 'Name',
|
||||
'chart.table.aria': '{brand} color chart, {count} colors',
|
||||
'chart.empty': 'No color data yet',
|
||||
'chart.footer': 'Codes & HEX from community-measured data · for reference only',
|
||||
'chart.brand.mard': 'MARD',
|
||||
'chart.brand.artkalC': 'Artkal C',
|
||||
'chart.brand.perler': 'Perler',
|
||||
'chart.brand.hama': 'Hama',
|
||||
'chart.brand.pyssla': 'IKEA Pyssla',
|
||||
'chart.brand.nabbi': 'Nabbi',
|
||||
'chart.series.mard': 'MARD beads',
|
||||
'chart.series.artkalC': '2.6mm mini',
|
||||
'chart.series.perler': 'Midi 5mm',
|
||||
'chart.series.hama': 'Midi 5mm',
|
||||
'chart.series.pyssla': '5mm (incl. 8 Pastell colors)',
|
||||
'chart.series.nabbi': 'Midi 5mm',
|
||||
'chart.crosslinks.title': 'Other brand color charts',
|
||||
'chart.crosslinks.home': '← Back to Home',
|
||||
|
||||
/* ── Showcase (T-097/T-098) ── */
|
||||
'showcase.eyebrow': 'COMMUNITY SHOWCASE',
|
||||
'showcase.title.prefix': 'Explore',
|
||||
'showcase.title.accent': 'community bead art.',
|
||||
'showcase.sub':
|
||||
'Discover popular bead pieces from the community for inspiration — works created in the AI Studio can be published here too.',
|
||||
'showcase.filter.aria': 'Filter works by tag',
|
||||
'showcase.filter.all': 'All',
|
||||
'showcase.count': '{count} works',
|
||||
'showcase.empty.title': 'No works yet',
|
||||
'showcase.empty.desc': 'Try another tag, or create your very first piece.',
|
||||
'showcase.publish': 'Submit your work →',
|
||||
'showcase.aiBadge': 'AI',
|
||||
'showcase.likesAria': '{count} likes',
|
||||
'showcase.viewsAria': '{count} views',
|
||||
'showcase.tag.landscape': 'Landscape',
|
||||
'showcase.tag.people': 'People',
|
||||
'showcase.tag.pet': 'Pets',
|
||||
'showcase.tag.item': 'Objects',
|
||||
'showcase.tag.food': 'Food',
|
||||
|
||||
/* ── Library (T-108) ── */
|
||||
'library.aria': 'Pattern list',
|
||||
'library.eyebrow': 'PATTERN LIBRARY',
|
||||
'library.title': 'Pattern Library',
|
||||
'library.title.accent': ' · Featured',
|
||||
'library.sub': 'Featured patterns you can preview and download — AI Studio pieces appear here after publishing.',
|
||||
'library.grid': '{size}',
|
||||
'library.brand': '{brand} palette',
|
||||
'library.preview': 'Preview',
|
||||
'library.download': 'Download pattern',
|
||||
'library.empty': 'Library under construction',
|
||||
'library.empty.desc': 'Saved patterns and published AI works will appear here soon.',
|
||||
|
||||
/* ── Help Center FAQ (T-106) ── */
|
||||
'help.eyebrow': 'HELP CENTER',
|
||||
'help.title': 'Help Center',
|
||||
'help.title.accent': ' · FAQ',
|
||||
'help.sub': 'Quick answers on bead selection, color matching, printing, ironing, framing, redemption, and the AI Studio.',
|
||||
'help.aria': 'Frequently asked questions',
|
||||
'help.back': '← Back to Home',
|
||||
|
||||
/* ── ChibiPage publish to showcase (T-102) ── */
|
||||
'chibi.publish.title': 'Publish to Showcase',
|
||||
'chibi.publish.desc': 'Share this piece with the community showcase for everyone to see.',
|
||||
'chibi.publish.placeholder': 'Name your piece (optional)',
|
||||
'chibi.publish.button': 'Publish to Showcase',
|
||||
'chibi.publish.publishing': 'Publishing…',
|
||||
'chibi.publish.success': 'Published to the showcase',
|
||||
'chibi.publish.view': 'View the showcase →',
|
||||
'chibi.publish.fail': 'Publish failed, please try again later',
|
||||
'chibi.publish.published': 'Published · {id}',
|
||||
};
|
||||
@@ -14,6 +14,11 @@ export const zhCN = {
|
||||
'nav.agency': '代理合作',
|
||||
'nav.status': '普通预览免费 · AI生成按次付费',
|
||||
'nav.lang': '语言',
|
||||
'nav.home': '首页',
|
||||
'nav.showcase': '作品展示',
|
||||
'nav.library': '图纸库',
|
||||
'nav.colorChart': '色号表',
|
||||
'nav.help': '帮助',
|
||||
|
||||
/* ── Hero ── */
|
||||
'hero.title.prefix': '把喜欢的图片,',
|
||||
@@ -323,6 +328,88 @@ export const zhCN = {
|
||||
'chibi.tag.decor': '减少细碎装饰',
|
||||
'chibi.tag.saturation': '增强色彩对比',
|
||||
'chibi.tag.topdown': '俯拍构图',
|
||||
|
||||
/* ── ColorChartPage(品牌色号表 · T-091/T-092) ── */
|
||||
'chart.nav.back': '← 返回主页',
|
||||
'chart.hero.title': '品牌色号表',
|
||||
'chart.hero.sub': '六品牌拼豆色号速查:MARD / Artkal-C / Perler / Hama / Pyssla / Nabbi',
|
||||
'chart.hero.badge': '色号速查',
|
||||
'chart.tabs.aria': '选择品牌',
|
||||
'chart.count': '{count} 色',
|
||||
'chart.countUnit': '色',
|
||||
'chart.col.code': '色号',
|
||||
'chart.col.hex': 'HEX',
|
||||
'chart.col.name': '名称',
|
||||
'chart.table.aria': '{brand} 色号表,共 {count} 色',
|
||||
'chart.empty': '暂无色号数据',
|
||||
'chart.footer': '色号与 HEX 来自社区实测数据 · 仅供参考,以实物为准',
|
||||
'chart.brand.mard': 'MARD',
|
||||
'chart.brand.artkalC': 'Artkal C',
|
||||
'chart.brand.perler': 'Perler',
|
||||
'chart.brand.hama': 'Hama',
|
||||
'chart.brand.pyssla': 'IKEA Pyssla',
|
||||
'chart.brand.nabbi': 'Nabbi',
|
||||
'chart.series.mard': 'MARD 拼豆',
|
||||
'chart.series.artkalC': '2.6mm mini',
|
||||
'chart.series.perler': 'Midi 5mm',
|
||||
'chart.series.hama': 'Midi 5mm',
|
||||
'chart.series.pyssla': '5mm(含 8 色 Pastell)',
|
||||
'chart.series.nabbi': 'Midi 5mm',
|
||||
'chart.crosslinks.title': '其他品牌色号表',
|
||||
'chart.crosslinks.home': '← 返回首页',
|
||||
|
||||
/* ── Showcase 作品展示(T-097/T-098) ── */
|
||||
'showcase.eyebrow': 'COMMUNITY SHOWCASE',
|
||||
'showcase.title.prefix': '看看大家的',
|
||||
'showcase.title.accent': '拼豆作品。',
|
||||
'showcase.sub':
|
||||
'探索社区里受欢迎的拼豆作品,找到灵感;在 AI 专区生成的作品也可以发布到这里分享给大家。',
|
||||
'showcase.filter.aria': '按标签筛选作品',
|
||||
'showcase.filter.all': '全部',
|
||||
'showcase.count': '共 {count} 个作品',
|
||||
'showcase.empty.title': '暂无作品',
|
||||
'showcase.empty.desc': '换一个标签看看,或去生成你自己的第一份作品。',
|
||||
'showcase.publish': '投稿你的作品 →',
|
||||
'showcase.aiBadge': 'AI 生成',
|
||||
'showcase.likesAria': '{count} 次点赞',
|
||||
'showcase.viewsAria': '{count} 次浏览',
|
||||
'showcase.tag.landscape': '风景',
|
||||
'showcase.tag.people': '人物',
|
||||
'showcase.tag.pet': '宠物',
|
||||
'showcase.tag.item': '物品',
|
||||
'showcase.tag.food': '食物',
|
||||
|
||||
/* ── Library 图纸库(T-108) ── */
|
||||
'library.aria': '图纸列表',
|
||||
'library.eyebrow': 'PATTERN LIBRARY',
|
||||
'library.title': '图纸库',
|
||||
'library.title.accent': '· 精选',
|
||||
'library.sub': '精选图纸合集,可预览与下载;在 AI 专区生成的作品发布后也会出现在这里。',
|
||||
'library.grid': '{size}',
|
||||
'library.brand': '{brand} 色号',
|
||||
'library.preview': '预览',
|
||||
'library.download': '下载图纸',
|
||||
'library.empty': '图纸库建设中',
|
||||
'library.empty.desc': '收藏的图纸和已发布的 AI 作品之后会出现在这里。',
|
||||
|
||||
/* ── Help 帮助中心 FAQ(T-106) ── */
|
||||
'help.eyebrow': 'HELP CENTER',
|
||||
'help.title': '帮助中心',
|
||||
'help.title.accent': '· FAQ',
|
||||
'help.sub': '常见问题速查:选豆、配色、打印、熨烫、裱框,以及兑换码与 AI 专区使用说明。',
|
||||
'help.aria': '常见问题',
|
||||
'help.back': '← 返回主页',
|
||||
|
||||
/* ── ChibiPage 发布到展示(T-102) ── */
|
||||
'chibi.publish.title': '发布到作品展示',
|
||||
'chibi.publish.desc': '把这张作品分享到社区作品展示,让更多人看到。',
|
||||
'chibi.publish.placeholder': '给作品起个名字(选填)',
|
||||
'chibi.publish.button': '发布到展示',
|
||||
'chibi.publish.publishing': '发布中…',
|
||||
'chibi.publish.success': '已发布到作品展示',
|
||||
'chibi.publish.view': '去作品展示看看 →',
|
||||
'chibi.publish.fail': '发布失败,请稍后重试',
|
||||
'chibi.publish.published': '已发布 · {id}',
|
||||
} as const;
|
||||
|
||||
export type Messages = { [K in keyof typeof zhCN]: string };
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* bfs-cleanup.ts 测试 — BFS 连通域标记 + 小面积噪点簇清理(清除 / 合并到主区域)。
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
import { bfsCleanNoise, labelConnectedRegions } from '../bfs-cleanup.js';
|
||||
import type { Rgb3 } from '../lab.js';
|
||||
|
||||
const red: Rgb3 = [190, 25, 25];
|
||||
const blue: Rgb3 = [25, 25, 190];
|
||||
const white: Rgb3 = [255, 255, 255];
|
||||
const black: Rgb3 = [0, 0, 0];
|
||||
|
||||
function makeGrid(size: number, fill: Rgb3): Rgb3[] {
|
||||
return Array.from({ length: size * size }, () => fill);
|
||||
}
|
||||
|
||||
describe('labelConnectedRegions', () => {
|
||||
it('把两个分离的相同色块标记为不同区域', () => {
|
||||
// 5×5:左上 2×2 红色块(下标 1,2,6,7)、右下 2×2 蓝色块(下标 16,17,21,22),
|
||||
// 其余白色。红/蓝块与白色互不连通。
|
||||
const grid = makeGrid(5, white);
|
||||
for (const idx of [1, 2, 6, 7]) grid[idx] = red;
|
||||
for (const idx of [16, 17, 21, 22]) grid[idx] = blue;
|
||||
|
||||
const ids = labelConnectedRegions(grid, 5);
|
||||
|
||||
// 红色块内部同一区域
|
||||
expect(ids[1]).toBe(ids[2]);
|
||||
expect(ids[1]).toBe(ids[6]);
|
||||
expect(ids[1]).toBe(ids[7]);
|
||||
// 蓝色块内部同一区域
|
||||
expect(ids[16]).toBe(ids[17]);
|
||||
expect(ids[16]).toBe(ids[21]);
|
||||
expect(ids[16]).toBe(ids[22]);
|
||||
// 红块、蓝块、白色是三个不同区域
|
||||
expect(ids[1]).not.toBe(ids[16]);
|
||||
expect(ids[1]).not.toBe(ids[12]);
|
||||
expect(ids[16]).not.toBe(ids[12]);
|
||||
});
|
||||
|
||||
it('颜色差异超过阈值时相邻格不并入同一区域', () => {
|
||||
// 2×2:红格紧邻蓝格(LAB 距离远超默认阈值 24)
|
||||
const grid: Rgb3[] = [red, blue, white, white];
|
||||
const ids = labelConnectedRegions(grid, 2);
|
||||
expect(ids[0]).not.toBe(ids[1]);
|
||||
});
|
||||
|
||||
it('空网格返回空数组', () => {
|
||||
expect(labelConnectedRegions([], 0)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('bfsCleanNoise (mode=clear)', () => {
|
||||
it('清除面积小于 minRegionSize 的孤立噪点簇', () => {
|
||||
// 5×5:孤立 1 格红色(下标 0)、2×2 红色块(下标 6,7,11,12),其余白色
|
||||
const grid = makeGrid(5, white);
|
||||
grid[0] = red;
|
||||
for (const idx of [6, 7, 11, 12]) grid[idx] = red;
|
||||
|
||||
const changed = bfsCleanNoise(grid, 5, 4, { mode: 'clear' });
|
||||
|
||||
// 孤立 1 格 → 清为白色
|
||||
expect(grid[0]).toEqual(white);
|
||||
expect(changed).toEqual([0]);
|
||||
// 2×2 大区域(面积 4)保留
|
||||
for (const idx of [6, 7, 11, 12]) expect(grid[idx]).toEqual(red);
|
||||
});
|
||||
|
||||
it('面积 ≥ minRegionSize 的区域不被清理', () => {
|
||||
// 5×5:2×2 红色块(下标 6,7,11,12),面积恰为 minRegionSize=4
|
||||
const grid = makeGrid(5, white);
|
||||
for (const idx of [6, 7, 11, 12]) grid[idx] = red;
|
||||
|
||||
const changed = bfsCleanNoise(grid, 5, 4, { mode: 'clear' });
|
||||
expect(changed).toEqual([]);
|
||||
for (const idx of [6, 7, 11, 12]) expect(grid[idx]).toEqual(red);
|
||||
});
|
||||
|
||||
it('clear 模式支持自定义背景色', () => {
|
||||
// 5×5:孤立 1 格红色(下标 0),其余白色
|
||||
const grid = makeGrid(5, white);
|
||||
grid[0] = red;
|
||||
|
||||
bfsCleanNoise(grid, 5, 4, { mode: 'clear', clearColor: black });
|
||||
expect(grid[0]).toEqual(black);
|
||||
});
|
||||
|
||||
it('空网格返回空数组', () => {
|
||||
expect(bfsCleanNoise([], 0, 4)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('bfsCleanNoise (mode=merge)', () => {
|
||||
it('把噪点簇并入接触最多的邻近主区域', () => {
|
||||
// 5×5:蓝色主区域 = 下标 1,2,5,6(L 形连通,面积 4),孤立 1 格红色(下标 0),
|
||||
// 其余白色。红色噪点的两个邻居(1、5)都属于蓝色主区域 → 并入蓝色。
|
||||
const grid = makeGrid(5, white);
|
||||
for (const idx of [1, 2, 5, 6]) grid[idx] = blue;
|
||||
grid[0] = red;
|
||||
|
||||
const changed = bfsCleanNoise(grid, 5, 4, { mode: 'merge' });
|
||||
|
||||
expect(grid[0]).toEqual(blue);
|
||||
expect(changed).toEqual([0]);
|
||||
// 蓝色主区域与白色背景不受影响
|
||||
for (const idx of [1, 2, 5, 6]) expect(grid[idx]).toEqual(blue);
|
||||
expect(grid[12]).toEqual(white);
|
||||
});
|
||||
|
||||
it('噪点簇没有任何邻近主区域时回退为背景色', () => {
|
||||
// 3×3 全红:单区域面积 9 < minRegionSize=10 → 整张图都是噪点,无主区域可并入
|
||||
const grid = makeGrid(3, red);
|
||||
const changed = bfsCleanNoise(grid, 3, 10, { mode: 'merge' });
|
||||
|
||||
expect(changed).toEqual([0, 1, 2, 3, 4, 5, 6, 7, 8]);
|
||||
for (let i = 0; i < 9; i++) expect(grid[i]).toEqual(white);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,158 @@
|
||||
/**
|
||||
* 品牌色号表数据层(color-chart-data.ts)测试。
|
||||
*
|
||||
* 覆盖:六品牌聚合完整性(MARD 复用既有 221 色管线、其余 5 品牌来自
|
||||
* competitor-analysis/palettes JSON 资产)、统一条目格式、路由段 ID 解析。
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
import {
|
||||
COLOR_CHART_BRANDS,
|
||||
getColorChartBrand,
|
||||
type ColorChartColor,
|
||||
} from '../color-chart-data.js';
|
||||
import { MARD_PALETTE } from '../mard-palette.js';
|
||||
|
||||
/** 各品牌实测色数(与 competitor-analysis/palettes README 核对)。 */
|
||||
const EXPECTED_COUNTS: Readonly<Record<string, number>> = {
|
||||
mard: 221,
|
||||
'artkal-c': 174,
|
||||
perler: 103,
|
||||
hama: 92,
|
||||
pyssla: 18,
|
||||
nabbi: 30,
|
||||
};
|
||||
|
||||
describe('COLOR_CHART_BRANDS 六品牌聚合', () => {
|
||||
it('按固定顺序定义 6 个品牌(MARD → Artkal-C → Perler → Hama → Pyssla → Nabbi)', () => {
|
||||
expect(COLOR_CHART_BRANDS.map((b) => b.id)).toEqual([
|
||||
'mard',
|
||||
'artkal-c',
|
||||
'perler',
|
||||
'hama',
|
||||
'pyssla',
|
||||
'nabbi',
|
||||
]);
|
||||
expect(new Set(COLOR_CHART_BRANDS.map((b) => b.id)).size).toBe(6);
|
||||
});
|
||||
|
||||
it('每个品牌色数与既有 JSON 资产实测一致', () => {
|
||||
for (const brand of COLOR_CHART_BRANDS) {
|
||||
const expected = EXPECTED_COUNTS[brand.id] ?? -1;
|
||||
console.log(`[color-chart] ${brand.id}: ${brand.colors.length} 色(预期 ${expected})`);
|
||||
expect(brand.colors.length).toBe(expected);
|
||||
}
|
||||
});
|
||||
|
||||
it('MARD 复用既有 MARD_PALETTE 管线数据(221 色逐一对应)', () => {
|
||||
const mard = COLOR_CHART_BRANDS[0]!;
|
||||
expect(mard.id).toBe('mard');
|
||||
expect(mard.colors).toHaveLength(MARD_PALETTE.length);
|
||||
for (let i = 0; i < MARD_PALETTE.length; i++) {
|
||||
expect(mard.colors[i]!.code).toBe(MARD_PALETTE[i]!.code);
|
||||
expect(mard.colors[i]!.hex).toBe(MARD_PALETTE[i]!.hex);
|
||||
}
|
||||
});
|
||||
|
||||
it('每个品牌色号唯一、hex 合法、rgb 为三元组', () => {
|
||||
for (const brand of COLOR_CHART_BRANDS) {
|
||||
const codes = brand.colors.map((c) => c.code);
|
||||
const hexes = brand.colors.map((c) => c.hex);
|
||||
expect(new Set(codes).size).toBe(codes.length);
|
||||
expect(new Set(hexes).size).toBe(hexes.length);
|
||||
for (const c of brand.colors) {
|
||||
expect(c.hex).toMatch(/^#[0-9A-F]{6}$/);
|
||||
expect(c.rgb).toHaveLength(3);
|
||||
for (const v of c.rgb) {
|
||||
expect(v).toBeGreaterThanOrEqual(0);
|
||||
expect(v).toBeLessThanOrEqual(255);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('非 MARD 品牌条目带英文名(数据源提供)', () => {
|
||||
for (const brand of COLOR_CHART_BRANDS.slice(1)) {
|
||||
for (const c of brand.colors) {
|
||||
expect(c.name).toBeTruthy();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('每个品牌带展示名与规格 i18n 键', () => {
|
||||
for (const brand of COLOR_CHART_BRANDS) {
|
||||
expect(brand.nameKey).toMatch(/^chart\.brand\./);
|
||||
expect(brand.seriesKey).toMatch(/^chart\.series\./);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('getColorChartBrand 路由段解析', () => {
|
||||
it('按 ID 精确命中(大小写不敏感)', () => {
|
||||
for (const brand of COLOR_CHART_BRANDS) {
|
||||
expect(getColorChartBrand(brand.id).id).toBe(brand.id);
|
||||
expect(getColorChartBrand(brand.id.toUpperCase()).id).toBe(brand.id);
|
||||
}
|
||||
});
|
||||
|
||||
it('未知 ID 回退到 MARD(首品牌)', () => {
|
||||
expect(getColorChartBrand('no-such-brand').id).toBe('mard');
|
||||
expect(getColorChartBrand(null).id).toBe('mard');
|
||||
expect(getColorChartBrand(undefined).id).toBe('mard');
|
||||
});
|
||||
});
|
||||
|
||||
/** 编译期防御:统一条目结构可被组件安全消费。 */
|
||||
const _typeGuard: ColorChartColor = COLOR_CHART_BRANDS[0]!.colors[0]!;
|
||||
void _typeGuard;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ColorChartPage 渲染冒烟(与 i18n.test 相同 SSR 模式)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
import { createElement } from 'react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { I18nProvider } from '../../i18n/index.js';
|
||||
import { ColorChartPage } from '../../ColorChartPage.js';
|
||||
|
||||
describe('ColorChartPage SSR 渲染', () => {
|
||||
it('默认品牌(MARD)完整渲染色号表,首条色号可见', () => {
|
||||
const html = renderToStaticMarkup(
|
||||
createElement(
|
||||
I18nProvider,
|
||||
null,
|
||||
createElement(ColorChartPage, { brandId: 'mard' }),
|
||||
),
|
||||
);
|
||||
expect(html).toContain('chart-');
|
||||
expect(html).toContain(COLOR_CHART_BRANDS[0]!.colors[0]!.code);
|
||||
expect(html).toContain(COLOR_CHART_BRANDS[0]!.colors[0]!.hex);
|
||||
// 221 条 MARD 色号全部渲染
|
||||
expect(html.split('chart-row').length - 1).toBe(221);
|
||||
});
|
||||
|
||||
it('指定品牌(artkal-c)渲染 174 色且带英文名', () => {
|
||||
const html = renderToStaticMarkup(
|
||||
createElement(
|
||||
I18nProvider,
|
||||
null,
|
||||
createElement(ColorChartPage, { brandId: 'artkal-c' }),
|
||||
),
|
||||
);
|
||||
expect(html.split('chart-row').length - 1).toBe(174);
|
||||
const first = COLOR_CHART_BRANDS.find((b) => b.id === 'artkal-c')!.colors[0]!;
|
||||
expect(html).toContain(first.name);
|
||||
});
|
||||
|
||||
it('未知品牌回退 MARD 不崩溃', () => {
|
||||
const html = renderToStaticMarkup(
|
||||
createElement(
|
||||
I18nProvider,
|
||||
null,
|
||||
createElement(ColorChartPage, { brandId: 'no-such-brand' }),
|
||||
),
|
||||
);
|
||||
expect(html.split('chart-row').length - 1).toBe(221);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* color-sort.ts 测试 — 色相环排序 + 明度次级排序 + 无彩色处理。
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
import { sortColorsByHue, sortPaletteByHue } from '../color-sort.js';
|
||||
import type { Rgb3 } from '../lab.js';
|
||||
|
||||
const red: Rgb3 = [255, 0, 0];
|
||||
const yellow: Rgb3 = [255, 255, 0];
|
||||
const green: Rgb3 = [0, 255, 0];
|
||||
const cyan: Rgb3 = [0, 255, 255];
|
||||
const blue: Rgb3 = [0, 0, 255];
|
||||
const magenta: Rgb3 = [255, 0, 255];
|
||||
const darkRed: Rgb3 = [100, 0, 0];
|
||||
const black: Rgb3 = [0, 0, 0];
|
||||
const white: Rgb3 = [255, 255, 255];
|
||||
/** 与纯红同色相(h=0)、同明度,但饱和度更低的去饱和红。 */
|
||||
const desaturatedRed: Rgb3 = [191, 64, 64];
|
||||
|
||||
describe('sortColorsByHue', () => {
|
||||
it('六原色按色相环序排列(红→黄→绿→青→蓝→品红)', () => {
|
||||
const sorted = sortColorsByHue([green, magenta, red, blue, yellow, cyan]);
|
||||
expect(sorted).toEqual([red, yellow, green, cyan, blue, magenta]);
|
||||
});
|
||||
|
||||
it('同一色相按明度升序(默认次级排序 lightness)', () => {
|
||||
expect(sortColorsByHue([red, darkRed])).toEqual([darkRed, red]);
|
||||
expect(sortColorsByHue([darkRed, red])).toEqual([darkRed, red]);
|
||||
});
|
||||
|
||||
it('排序稳定:排序键完全相同的元素保持输入顺序', () => {
|
||||
// red 与 desaturatedRed 同色相、同明度(默认 tieBreak=lightness 下键相同)
|
||||
expect(sortColorsByHue([red, desaturatedRed])).toEqual([red, desaturatedRed]);
|
||||
expect(sortColorsByHue([desaturatedRed, red])).toEqual([desaturatedRed, red]);
|
||||
});
|
||||
|
||||
it('次级排序切到 saturation 时同色相按饱和度升序', () => {
|
||||
expect(sortColorsByHue([red, desaturatedRed], { tieBreak: 'saturation' })).toEqual([
|
||||
desaturatedRed,
|
||||
red,
|
||||
]);
|
||||
});
|
||||
|
||||
it('无彩色默认排在彩色之后、按明度升序', () => {
|
||||
// 彩色:red(h=0)、blue(h=240);无彩色:black(l=0)、white(l=1)
|
||||
expect(sortColorsByHue([blue, black, red, white])).toEqual([red, blue, black, white]);
|
||||
});
|
||||
|
||||
it('无彩色可排到最前(neutrals=start)', () => {
|
||||
expect(sortColorsByHue([blue, black, red], { neutrals: 'start' })).toEqual([black, red, blue]);
|
||||
});
|
||||
|
||||
it('空数组返回空数组', () => {
|
||||
expect(sortColorsByHue([])).toEqual([]);
|
||||
});
|
||||
|
||||
it('单色返回原样', () => {
|
||||
expect(sortColorsByHue([green])).toEqual([green]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('sortPaletteByHue', () => {
|
||||
it('按条目的 rgb 排序并保留条目对象', () => {
|
||||
const entries = [
|
||||
{ code: 'B', rgb: blue, count: 3 },
|
||||
{ code: 'A', rgb: red, count: 1 },
|
||||
{ code: 'N', rgb: black, count: 2 },
|
||||
];
|
||||
|
||||
const sorted = sortPaletteByHue(entries);
|
||||
|
||||
expect(sorted.map((e) => e.code)).toEqual(['A', 'B', 'N']);
|
||||
// 条目对象本身不变(引用相等)
|
||||
expect(sorted[0]).toBe(entries[1]);
|
||||
expect(sorted[1]).toBe(entries[0]);
|
||||
expect(sorted[2]).toBe(entries[2]);
|
||||
});
|
||||
|
||||
it('空数组返回空数组', () => {
|
||||
expect(sortPaletteByHue([])).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -166,3 +166,29 @@ export function generateChibi(params: GenerateChibiParams): Promise<GenerateChib
|
||||
body: JSON.stringify(params),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* T-102:POST /api/showcase/works — 把 AI 专区生成的作品发布到作品展示。
|
||||
*
|
||||
* 接口约定(与 T-099 后端并行开发):
|
||||
* req { title, imageData, tags, source: 'chibi' }
|
||||
* res { id }
|
||||
* 后端尚未就绪时抛出「无法连接服务器」,UI 以失败态呈现即可。
|
||||
*/
|
||||
export interface PublishWorkParams {
|
||||
title: string;
|
||||
imageData: string;
|
||||
tags: string[];
|
||||
source: 'chibi';
|
||||
}
|
||||
|
||||
export interface PublishWorkResponse {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export function publishShowcaseWork(params: PublishWorkParams): Promise<PublishWorkResponse> {
|
||||
return request<PublishWorkResponse>('/api/showcase/works', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(params),
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
/**
|
||||
* BFS 连通域标记 + 杂色清理(Noise Cleanup)。
|
||||
*
|
||||
* 与 cleanup.ts 的职责区分(cleanup.ts 已有 mergeSimilarRegions + removeNoise,
|
||||
* 本模块不复用、不修改它们):
|
||||
* - cleanup.ts:把相似色连通区域统一为多数派颜色(区域合并)、标记小区域为噪声,
|
||||
* 供上层决定是否剔除(T-072 已验收)。
|
||||
* - 本模块:**小面积连通域(噪点簇)的清除与合并** —— 用 BFS 标记连通域后,
|
||||
* 把面积小于 minRegionSize 的噪点簇整簇清除为背景色(mode='clear'),
|
||||
* 或整簇并入接触最多的邻近主区域(mode='merge')。
|
||||
*
|
||||
* 连通域判定规则与 cleanup.ts 一致:相邻两格 LAB 距离 < mergeThreshold 且
|
||||
* 与区域种子色 LAB 距离 < maxMergeDistance 视为同一区域(4 连通)。
|
||||
*/
|
||||
|
||||
import { labDistance, srgbToLab, type Lab3, type Rgb3 } from './lab.js';
|
||||
|
||||
/** 杂色清理参数(均可选,缺省用默认值)。 */
|
||||
export interface BfsCleanOptions {
|
||||
/** 相邻两格 LAB 距离阈值(默认 24),小于该值视为同一区域。 */
|
||||
mergeThreshold?: number;
|
||||
/** 候选格与区域种子色的最大 LAB 距离(默认 24),限制区域颜色漂移。 */
|
||||
maxMergeDistance?: number;
|
||||
/** 噪点处理方式:'merge' 并入邻近主区域(默认)| 'clear' 清为背景色。 */
|
||||
mode?: 'merge' | 'clear';
|
||||
/** mode='clear' 时替换成的背景色(默认白色 [255,255,255])。 */
|
||||
clearColor?: Rgb3;
|
||||
}
|
||||
|
||||
const DEFAULT_MERGE_THRESHOLD = 24;
|
||||
const DEFAULT_MAX_MERGE_DISTANCE = 24;
|
||||
const DEFAULT_MODE: NonNullable<BfsCleanOptions['mode']> = 'merge';
|
||||
const DEFAULT_CLEAR_COLOR: Rgb3 = [255, 255, 255];
|
||||
|
||||
/**
|
||||
* 4 连通 BFS 连通域标记:返回每个格子的区域 id(行主序)。
|
||||
* 从每个未访问格出发做洪水填充:相邻格同时满足
|
||||
* ① 与当前格 LAB 距离 < mergeThreshold
|
||||
* ② 与区域种子色 LAB 距离 < maxMergeDistance
|
||||
* 即并入同一区域。
|
||||
*
|
||||
* @param grid - 颜色网格(只读,行主序)。
|
||||
* @param size - 网格边长(size × size)。
|
||||
* @param options - 连通域判定参数(均可选)。
|
||||
* @returns 长度与 grid 相同的区域 id 数组;空网格返回 []。
|
||||
*/
|
||||
export function labelConnectedRegions(
|
||||
grid: readonly Rgb3[],
|
||||
size: number,
|
||||
options: Partial<Pick<BfsCleanOptions, 'mergeThreshold' | 'maxMergeDistance'>> = {},
|
||||
): number[] {
|
||||
const n = grid.length;
|
||||
if (n === 0 || size <= 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const mergeThreshold = options.mergeThreshold ?? DEFAULT_MERGE_THRESHOLD;
|
||||
const maxMergeDistance = options.maxMergeDistance ?? DEFAULT_MAX_MERGE_DISTANCE;
|
||||
|
||||
const labCache: Lab3[] = grid.map(srgbToLab);
|
||||
const regionId = new Array<number>(n).fill(-1);
|
||||
let nextId = 0;
|
||||
|
||||
for (let start = 0; start < n; start++) {
|
||||
if (regionId[start] !== -1) continue;
|
||||
|
||||
const seedLab = labCache[start]!;
|
||||
const queue: number[] = [start];
|
||||
regionId[start] = nextId;
|
||||
|
||||
while (queue.length > 0) {
|
||||
const idx = queue.shift()!;
|
||||
for (const nb of neighborsOf(idx, size, n)) {
|
||||
if (regionId[nb] !== -1) continue;
|
||||
const nbLab = labCache[nb]!;
|
||||
if (
|
||||
labDistance(nbLab, labCache[idx]!) < mergeThreshold &&
|
||||
labDistance(nbLab, seedLab) < maxMergeDistance
|
||||
) {
|
||||
regionId[nb] = nextId;
|
||||
queue.push(nb);
|
||||
}
|
||||
}
|
||||
}
|
||||
nextId++;
|
||||
}
|
||||
|
||||
return regionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* BFS 杂色清理:清除或合并面积小于 minRegionSize 的噪点簇。
|
||||
*
|
||||
* 先对 grid 做连通域标记,面积(格子数)小于 minRegionSize 的区域视为噪点簇:
|
||||
* - mode='clear':整簇改写为 clearColor(默认白色)。
|
||||
* - mode='merge':整簇并入「接触格数最多的邻近主区域」(接触数相同取面积更大、
|
||||
* 再取区域 id 更小者),改写为该主区域的多数派颜色;若某簇没有任何邻近主区域
|
||||
* (整张图都是噪点),回退为 clearColor。
|
||||
*
|
||||
* @param grid - 待清理的颜色网格(会被就地修改)。
|
||||
* @param size - 网格边长(size × size)。
|
||||
* @param minRegionSize - 最小区域面积:区域格子数 < 该值视为噪点簇。
|
||||
* @param options - 清理参数(均可选)。
|
||||
* @returns 颜色被改写(与清理前不同)的格子下标数组。
|
||||
*/
|
||||
export function bfsCleanNoise(
|
||||
grid: Rgb3[],
|
||||
size: number,
|
||||
minRegionSize: number,
|
||||
options: Partial<BfsCleanOptions> = {},
|
||||
): number[] {
|
||||
const n = grid.length;
|
||||
if (n === 0 || size <= 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const mode = options.mode ?? DEFAULT_MODE;
|
||||
const clearColor = options.clearColor ?? DEFAULT_CLEAR_COLOR;
|
||||
|
||||
const regionId = labelConnectedRegions(grid, size, options);
|
||||
|
||||
// ---- 统计每个区域的面积 ----
|
||||
const regionSize = new Map<number, number>();
|
||||
for (const rid of regionId) {
|
||||
regionSize.set(rid, (regionSize.get(rid) ?? 0) + 1);
|
||||
}
|
||||
|
||||
const isNoise = (rid: number): boolean => (regionSize.get(rid) ?? 0) < minRegionSize;
|
||||
|
||||
const changed: number[] = [];
|
||||
|
||||
// ---- 'clear':整簇噪点改写为背景色 ----
|
||||
if (mode === 'clear') {
|
||||
for (let i = 0; i < n; i++) {
|
||||
if (isNoise(regionId[i]!)) {
|
||||
if (!sameColor(grid[i]!, clearColor)) {
|
||||
grid[i] = clearColor;
|
||||
changed.push(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
// ---- 'merge':把每个噪点簇并入接触最多的邻近主区域 ----
|
||||
// 1) 统计每个噪点区域与各非噪声相邻区域(主区域)的接触格数
|
||||
const contact = new Map<number, Map<number, number>>();
|
||||
for (let i = 0; i < n; i++) {
|
||||
const rid = regionId[i]!;
|
||||
if (!isNoise(rid)) continue;
|
||||
for (const nb of neighborsOf(i, size, n)) {
|
||||
const nbRid = regionId[nb]!;
|
||||
if (isNoise(nbRid)) continue;
|
||||
const byRegion = contact.get(rid) ?? new Map<number, number>();
|
||||
byRegion.set(nbRid, (byRegion.get(nbRid) ?? 0) + 1);
|
||||
contact.set(rid, byRegion);
|
||||
}
|
||||
}
|
||||
|
||||
// 2) 每簇选定一个主区域:接触格数最多 → 面积更大 → 区域 id 更小
|
||||
const targetRegion = new Map<number, number>();
|
||||
for (const [rid, byRegion] of contact) {
|
||||
let bestRid = -1;
|
||||
let bestContact = -1;
|
||||
for (const [nbRid, count] of byRegion) {
|
||||
if (count > bestContact) {
|
||||
bestContact = count;
|
||||
bestRid = nbRid;
|
||||
continue;
|
||||
}
|
||||
if (count < bestContact) continue;
|
||||
// 接触数相同:优先面积更大的主区域,其次区域 id 更小(保证确定性)
|
||||
const nbSize = regionSize.get(nbRid) ?? 0;
|
||||
const bestSize = regionSize.get(bestRid) ?? 0;
|
||||
if (nbSize > bestSize || (nbSize === bestSize && nbRid < bestRid)) {
|
||||
bestRid = nbRid;
|
||||
}
|
||||
}
|
||||
targetRegion.set(rid, bestRid);
|
||||
}
|
||||
|
||||
// 3) 主区域的多数派颜色(平局取扫描顺序先出现的颜色)作为合并目标
|
||||
const mergeColor = new Map<number, Rgb3>();
|
||||
for (const [rid, targetRid] of targetRegion) {
|
||||
const votes = new Map<string, { color: Rgb3; count: number }>();
|
||||
for (let i = 0; i < n; i++) {
|
||||
if (regionId[i] === targetRid) {
|
||||
const color = grid[i]!;
|
||||
const key = rgbKey(color);
|
||||
const vote = votes.get(key) ?? { color, count: 0 };
|
||||
vote.count++;
|
||||
votes.set(key, vote);
|
||||
}
|
||||
}
|
||||
let bestColor: Rgb3 = [0, 0, 0];
|
||||
let bestCount = -1;
|
||||
for (const { color, count } of votes.values()) {
|
||||
if (count > bestCount) {
|
||||
bestCount = count;
|
||||
bestColor = color;
|
||||
}
|
||||
}
|
||||
mergeColor.set(rid, bestColor);
|
||||
}
|
||||
|
||||
// 4) 应用:整簇改写;无邻近主区域的孤立噪点簇回退为背景色
|
||||
for (let i = 0; i < n; i++) {
|
||||
const rid = regionId[i]!;
|
||||
if (!isNoise(rid)) continue;
|
||||
const target = mergeColor.get(rid) ?? clearColor;
|
||||
if (!sameColor(grid[i]!, target)) {
|
||||
grid[i] = target;
|
||||
changed.push(i);
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
/** 4 连通邻居下标(越界安全,限制在 [0, n) 内)。 */
|
||||
function neighborsOf(i: number, size: number, n: number): number[] {
|
||||
const x = i % size;
|
||||
const y = Math.floor(i / size);
|
||||
const nbs: number[] = [];
|
||||
if (x > 0) nbs.push(i - 1);
|
||||
if (x < size - 1) nbs.push(i + 1);
|
||||
if (y > 0) nbs.push(i - size);
|
||||
if (y < size - 1) nbs.push(i + size);
|
||||
return nbs.filter((nb) => nb >= 0 && nb < n);
|
||||
}
|
||||
|
||||
function rgbKey(c: Rgb3): string {
|
||||
return `${c[0]}-${c[1]}-${c[2]}`;
|
||||
}
|
||||
|
||||
function sameColor(a: Rgb3, b: Rgb3): boolean {
|
||||
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* 品牌色号表数据层(色号表 SEO 页)。
|
||||
*
|
||||
* 六品牌聚合:
|
||||
* - MARD:直接复用前端既有 MARD_PALETTE(mard-palette-data.ts,221 色,已验证)。
|
||||
* - Artkal-C / Perler / Hama / Pyssla / Nabbi:来自 competitor-analysis/palettes 的
|
||||
* 既有 JSON 资产(`{code, hex, rgb, name}`,实测数据,随包拷贝于
|
||||
* src/lib/palette-data/)。此处做统一适配。
|
||||
*
|
||||
* 统一条目格式:code / hex / rgb / name(name 可选,MARD 无英文名)。
|
||||
*/
|
||||
|
||||
import type { MessageKey } from '../i18n';
|
||||
import { MARD_PALETTE } from './mard-palette.js';
|
||||
|
||||
import artkalCJson from './palette-data/artkal-c.json';
|
||||
import perlerJson from './palette-data/perler.json';
|
||||
import hamaJson from './palette-data/hama.json';
|
||||
import pysslaJson from './palette-data/ikea-pyssla.json';
|
||||
import nabbiJson from './palette-data/nabbi.json';
|
||||
|
||||
/** 色号表页统一颜色条目(适配自各品牌数据源)。 */
|
||||
export interface ColorChartColor {
|
||||
code: string;
|
||||
hex: string;
|
||||
rgb: readonly [number, number, number];
|
||||
/** 颜色英文名(MARD 数据源无英文名,省略)。 */
|
||||
name?: string;
|
||||
}
|
||||
|
||||
/** 色号表页品牌元信息。id 即路由段(如 /color-chart/mard)。 */
|
||||
export interface ColorChartBrand {
|
||||
/** 路由段 ID(小写、URL 安全)。 */
|
||||
id: string;
|
||||
/** 品牌展示名 i18n 键。 */
|
||||
nameKey: MessageKey;
|
||||
/** 豆珠规格(如 5mm / 2.6mm mini)。 */
|
||||
seriesKey: MessageKey;
|
||||
colors: readonly ColorChartColor[];
|
||||
}
|
||||
|
||||
type RawJsonColor = {
|
||||
code: string;
|
||||
hex: string;
|
||||
rgb: number[];
|
||||
name?: string;
|
||||
};
|
||||
|
||||
/** JSON 资产 → 统一条目:rgb 数组规整为三元组。 */
|
||||
function fromJson(raw: readonly RawJsonColor[]): readonly ColorChartColor[] {
|
||||
return raw.map((c) => ({
|
||||
code: c.code,
|
||||
hex: c.hex,
|
||||
rgb: [c.rgb[0] ?? 0, c.rgb[1] ?? 0, c.rgb[2] ?? 0] as const,
|
||||
...(c.name ? { name: c.name } : {}),
|
||||
}));
|
||||
}
|
||||
|
||||
/** MARD_PALETTE → 统一条目(沿用现有已验证 LAB 管线数据,不重复造数)。 */
|
||||
const mardColors: readonly ColorChartColor[] = MARD_PALETTE.map((m) => ({
|
||||
code: m.code,
|
||||
hex: m.hex,
|
||||
rgb: m.rgb,
|
||||
}));
|
||||
|
||||
/** 六品牌色号表(固定顺序:MARD → Artkal-C → Perler → Hama → Pyssla → Nabbi)。 */
|
||||
export const COLOR_CHART_BRANDS: readonly ColorChartBrand[] = [
|
||||
{
|
||||
id: 'mard',
|
||||
nameKey: 'chart.brand.mard',
|
||||
seriesKey: 'chart.series.mard',
|
||||
colors: mardColors,
|
||||
},
|
||||
{
|
||||
id: 'artkal-c',
|
||||
nameKey: 'chart.brand.artkalC',
|
||||
seriesKey: 'chart.series.artkalC',
|
||||
colors: fromJson(artkalCJson),
|
||||
},
|
||||
{
|
||||
id: 'perler',
|
||||
nameKey: 'chart.brand.perler',
|
||||
seriesKey: 'chart.series.perler',
|
||||
colors: fromJson(perlerJson),
|
||||
},
|
||||
{
|
||||
id: 'hama',
|
||||
nameKey: 'chart.brand.hama',
|
||||
seriesKey: 'chart.series.hama',
|
||||
colors: fromJson(hamaJson),
|
||||
},
|
||||
{
|
||||
id: 'pyssla',
|
||||
nameKey: 'chart.brand.pyssla',
|
||||
seriesKey: 'chart.series.pyssla',
|
||||
colors: fromJson(pysslaJson),
|
||||
},
|
||||
{
|
||||
id: 'nabbi',
|
||||
nameKey: 'chart.brand.nabbi',
|
||||
seriesKey: 'chart.series.nabbi',
|
||||
colors: fromJson(nabbiJson),
|
||||
},
|
||||
];
|
||||
|
||||
/** 按路由段 ID 查品牌(未知 ID 回退到 MARD,保持页面始终有内容)。 */
|
||||
export function getColorChartBrand(brandId: string | null | undefined): ColorChartBrand {
|
||||
const id = brandId?.toLowerCase();
|
||||
return COLOR_CHART_BRANDS.find((b) => b.id === id) ?? COLOR_CHART_BRANDS[0]!;
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* 颜色排序 — 将一组颜色按色相(色相环 0..360°,红→黄→绿→青→蓝→品红)
|
||||
* 为主、明度为辅排序输出。
|
||||
*
|
||||
* 对齐竞品 pixel-beads 的颜色处理能力(见 competitor-analysis/pixelbeads-analysis.md),
|
||||
* 供最终色板「按色相/明度排序」使用。无彩色(饱和度极低)默认统一排在彩色之后、
|
||||
* 按明度升序排列。
|
||||
*/
|
||||
|
||||
import type { Rgb3 } from './lab.js';
|
||||
|
||||
/** 同一色相内的次级排序维度。 */
|
||||
export type ColorSortTieBreak = 'lightness' | 'saturation' | 'value' | 'none';
|
||||
|
||||
/** 无彩色(灰度色)的摆放位置。 */
|
||||
export type NeutralPlacement = 'start' | 'end';
|
||||
|
||||
/** 颜色排序参数(均可选,缺省用默认值)。 */
|
||||
export interface ColorSortOptions {
|
||||
/** 同一色相内的次级排序维度(默认 'lightness',升序)。 */
|
||||
tieBreak?: ColorSortTieBreak;
|
||||
/** 无彩色的摆放位置(默认 'end',置于彩色之后、按明度升序)。 */
|
||||
neutrals?: NeutralPlacement;
|
||||
/** 判定为无彩色的饱和度阈值(0..1,默认 0.02)。 */
|
||||
neutralSaturationThreshold?: number;
|
||||
}
|
||||
|
||||
const DEFAULT_TIE_BREAK: ColorSortTieBreak = 'lightness';
|
||||
const DEFAULT_NEUTRAL_PLACEMENT: NeutralPlacement = 'end';
|
||||
const DEFAULT_NEUTRAL_SATURATION_THRESHOLD = 0.02;
|
||||
|
||||
/** 归一化后的 HSV(h 为色相 0..360,s/v 为 0..1),l 为 HSL 明度。 */
|
||||
interface HsvL {
|
||||
h: number;
|
||||
s: number;
|
||||
v: number;
|
||||
l: number;
|
||||
}
|
||||
|
||||
function rgbToHsvL(rgb: Rgb3): HsvL {
|
||||
const r = rgb[0] / 255;
|
||||
const g = rgb[1] / 255;
|
||||
const b = rgb[2] / 255;
|
||||
const max = Math.max(r, g, b);
|
||||
const min = Math.min(r, g, b);
|
||||
const delta = max - min;
|
||||
|
||||
let h = 0;
|
||||
if (delta > 0) {
|
||||
if (max === r) {
|
||||
h = 60 * (((g - b) / delta) % 6);
|
||||
} else if (max === g) {
|
||||
h = 60 * ((b - r) / delta + 2);
|
||||
} else {
|
||||
h = 60 * ((r - g) / delta + 4);
|
||||
}
|
||||
}
|
||||
if (h < 0) h += 360;
|
||||
if (h >= 360) h -= 360;
|
||||
|
||||
return { h, s: max === 0 ? 0 : delta / max, v: max, l: (max + min) / 2 };
|
||||
}
|
||||
|
||||
interface SortKey {
|
||||
/** 色相环位置;无彩色按 neutrals 选项映射到 -1(排最前)或 361(排最后)。 */
|
||||
hue: number;
|
||||
/** 次级排序用的数值(lightness / saturation / value;tieBreak='none' 时恒为 0)。 */
|
||||
tie: number;
|
||||
/** 输入顺序下标,保证同键元素排序稳定。 */
|
||||
index: number;
|
||||
}
|
||||
|
||||
function buildSortKey(rgb: Rgb3, index: number, options: Required<ColorSortOptions>): SortKey {
|
||||
const { h, s, v, l } = rgbToHsvL(rgb);
|
||||
const isNeutral = s < options.neutralSaturationThreshold;
|
||||
const hue = isNeutral ? (options.neutrals === 'start' ? -1 : 361) : h;
|
||||
|
||||
let tie = 0;
|
||||
switch (options.tieBreak) {
|
||||
case 'lightness':
|
||||
tie = l;
|
||||
break;
|
||||
case 'saturation':
|
||||
tie = s;
|
||||
break;
|
||||
case 'value':
|
||||
tie = v;
|
||||
break;
|
||||
case 'none':
|
||||
break;
|
||||
}
|
||||
|
||||
return { hue, tie, index };
|
||||
}
|
||||
|
||||
function compareSortKeys(a: SortKey, b: SortKey, tieBreak: ColorSortTieBreak): number {
|
||||
if (a.hue !== b.hue) return a.hue - b.hue;
|
||||
if (tieBreak !== 'none' && a.tie !== b.tie) return a.tie - b.tie;
|
||||
return a.index - b.index;
|
||||
}
|
||||
|
||||
function resolveOptions(options: ColorSortOptions): Required<ColorSortOptions> {
|
||||
return {
|
||||
tieBreak: options.tieBreak ?? DEFAULT_TIE_BREAK,
|
||||
neutrals: options.neutrals ?? DEFAULT_NEUTRAL_PLACEMENT,
|
||||
neutralSaturationThreshold: options.neutralSaturationThreshold ?? DEFAULT_NEUTRAL_SATURATION_THRESHOLD,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 颜色排序(色相为主、明度为辅,稳定排序)。
|
||||
*
|
||||
* @param colors - 待排序颜色(Rgb3 元组),不修改输入。
|
||||
* @param options - 排序参数(均可选)。
|
||||
* @returns 排序后的新数组;排序键完全相同的元素保持输入相对顺序。
|
||||
*/
|
||||
export function sortColorsByHue<T extends Rgb3>(colors: readonly T[], options: ColorSortOptions = {}): T[] {
|
||||
const opts = resolveOptions(options);
|
||||
return [...colors]
|
||||
.map((rgb, index) => ({ rgb, key: buildSortKey(rgb, index, opts) }))
|
||||
.sort((a, b) => compareSortKeys(a.key, b.key, opts.tieBreak))
|
||||
.map(({ rgb }) => rgb);
|
||||
}
|
||||
|
||||
/**
|
||||
* 色板条目排序:按条目的 `rgb` 字段做同样的色相排序。
|
||||
*
|
||||
* @param entries - 带 `rgb` 字段的色板条目(如 ProcessedPaletteEntry)。
|
||||
* @param options - 排序参数(均可选)。
|
||||
* @returns 排序后的新数组;条目对象本身不变,排序键相同的元素保持输入相对顺序。
|
||||
*/
|
||||
export function sortPaletteByHue<T extends { rgb: Rgb3 }>(
|
||||
entries: readonly T[],
|
||||
options: ColorSortOptions = {},
|
||||
): T[] {
|
||||
const opts = resolveOptions(options);
|
||||
return [...entries]
|
||||
.map((entry, index) => ({ entry, key: buildSortKey(entry.rgb, index, opts) }))
|
||||
.sort((a, b) => compareSortKeys(a.key, b.key, opts.tieBreak))
|
||||
.map(({ entry }) => entry);
|
||||
}
|
||||
@@ -0,0 +1,330 @@
|
||||
/**
|
||||
* PERLER LAB — 帮助中心 FAQ 数据(T-106)
|
||||
*
|
||||
* 数据源: docs/FAQ-DATA.md(T-107,共 35 条,8 个分类)。
|
||||
* 由脚本生成(question/answer 双语言 zh+en),供 HelpPage 渲染。
|
||||
* 变更流程: 修改 FAQ-DATA.md → 重新运行 node scripts/generate-faq-data.mjs。
|
||||
*/
|
||||
|
||||
export interface FaqItem {
|
||||
/** FAQ 编号,如 FAQ-01。 */
|
||||
id: string;
|
||||
questionZh: string;
|
||||
questionEn: string;
|
||||
answerZh: string;
|
||||
answerEn: string;
|
||||
}
|
||||
|
||||
export interface FaqCategory {
|
||||
/** 分类标签(过滤/展示用),如 'bead-selection'。 */
|
||||
id: string;
|
||||
labelZh: string;
|
||||
labelEn: string;
|
||||
items: readonly FaqItem[];
|
||||
}
|
||||
|
||||
export const FAQ_CATEGORIES: readonly FaqCategory[] = [
|
||||
{
|
||||
id: 'bead-selection',
|
||||
labelZh: '选豆',
|
||||
labelEn: 'Bead Selection',
|
||||
items: [
|
||||
{
|
||||
id: 'FAQ-01',
|
||||
questionZh: `不同品牌的拼豆可以混用吗?`,
|
||||
questionEn: `Can I mix beads from different brands?`,
|
||||
answerZh: `不建议混用。不同品牌在颜色编号、材质手感以及熨烫时的热缩率上可能存在差异,混用容易导致颜色不一致或熨烫后变形。为了保证成品效果,建议同一作品尽量使用同一品牌的拼豆。`,
|
||||
answerEn: `Not recommended. Different brands may differ in color codes, material feel, and heat-shrink rate during ironing, which can cause color mismatch or warping. Use one brand per project for the best result.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-02',
|
||||
questionZh: `5mm 和 2.6mm 拼豆可以放在同一块拼板上吗?`,
|
||||
questionEn: `Can 5mm and 2.6mm beads share the same pegboard?`,
|
||||
answerZh: `不可以。5mm 和 2.6mm 拼豆属于完全不同规格,对应的拼板孔径不同,无法通用。如果混用尺寸,会导致拼豆无法固定,图案也无法正常熨烫。`,
|
||||
answerEn: `No. 5mm and 2.6mm beads have different peg-hole sizes and are incompatible. Mixing sizes means beads won't stay in place and the design cannot be ironed properly.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-03',
|
||||
questionZh: `新手应该从 5mm 还是 2.6mm 拼豆开始?`,
|
||||
questionEn: `Should beginners start with 5mm or 2.6mm beads?`,
|
||||
answerZh: `建议从 5mm 开始。5mm 拼豆颗粒更大、操作难度更低,更适合新手建立信心。2.6mm 拼豆对精细操作和耐心要求较高,更适合 16 岁以上、有一定经验的用户。`,
|
||||
answerEn: `Start with 5mm. Bigger beads are easier to handle and build confidence. 2.6mm requires finer motor control and patience, better for ages 16+ or experienced makers.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-04',
|
||||
questionZh: `72 色和 168 色拼豆差别大吗?需要一开始就买 168 色吗?`,
|
||||
questionEn: `Is there a big difference between 72-color and 168-color sets? Should I buy 168 colors right away?`,
|
||||
answerZh: `差别主要体现在细节表现上。72 色可以满足大多数基础图案和练习需求,而 168 色在渐变、肤色和复杂图案上表现更自然。新手可以先从 72 色开始,熟练后再升级到 168 色。`,
|
||||
answerEn: `The difference is in detail. 72 colors cover most basic patterns and practice; 168 colors handle gradients, skin tones, and complex designs more naturally. Beginners can start with 72 and upgrade later.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-05',
|
||||
questionZh: `选豆时如何确定作品需要买哪些颜色?`,
|
||||
questionEn: `How do I know which bead colors a project needs?`,
|
||||
answerZh: `用拼豆图纸生成器生成图纸后,导出材料统计表即可看到每一色需要的豆数与总量。将颜色按「大面积主色」和「少量点缀色」区分:主色优先囤货,点缀色按单次用量购买即可,避免浪费。`,
|
||||
answerEn: `After generating a pattern, export the material list to see the bead count per color. Separate "bulk main colors" from "small accent colors": stock up on main colors, buy accents per project to avoid waste.`,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'color-matching',
|
||||
labelZh: '配色与图纸生成',
|
||||
labelEn: 'Color Matching & Generation',
|
||||
items: [
|
||||
{
|
||||
id: 'FAQ-06',
|
||||
questionZh: `为什么不建议上传过大的图片?`,
|
||||
questionEn: `Why shouldn't I upload very large images?`,
|
||||
answerZh: `过大的图片并不会让拼豆作品效果更好,反而会增加难度。图片尺寸过大(例如上千像素)时:会产生过多拼豆颗粒、图纸结构过于复杂,制作难度明显提升、自动配色更容易出现杂色、实际完成所需的时间和成本显著增加。拼豆创作强调的是清晰的像素感,而不是高分辨率图片。`,
|
||||
answerEn: `A larger image doesn't mean a better bead project — it just adds difficulty. Very large images (e.g. thousands of pixels) produce too many beads, overly complex charts, noisier auto-matching, and much higher time/cost. Bead art is about clean pixel clarity, not resolution.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-07',
|
||||
questionZh: `上传图片的推荐尺寸是多少?`,
|
||||
questionEn: `What image size do you recommend uploading?`,
|
||||
answerZh: `建议图片的宽或高控制在 100–300 像素(px)之间。在这个范围内,图案清晰度、拼豆数量和制作难度更容易取得平衡,生成的图纸也更适合实际制作。`,
|
||||
answerEn: `Keep the width or height between 100–300 px. This range balances clarity, bead count, and build difficulty, and produces charts that are practical to make.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-08',
|
||||
questionZh: `图片比例有要求吗?`,
|
||||
questionEn: `Is there an aspect-ratio requirement for images?`,
|
||||
answerZh: `图片比例不限,但建议接近最终成品比例。在上传前适当裁剪主体,避免过多无关背景,有助于生成更理想的拼豆图纸。`,
|
||||
answerEn: `No strict requirement, but keep it close to the final layout ratio. Crop the subject and trim excess background before uploading for a better result.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-09',
|
||||
questionZh: `5mm 拼豆适合使用多大的图片?`,
|
||||
questionEn: `What image size suits 5mm beads?`,
|
||||
answerZh: `5mm 拼豆建议使用 100–200px 左右的图片。这个尺寸范围下,图案清晰、颗粒数量适中,非常适合儿童、新手或轻松制作的作品。`,
|
||||
answerEn: `Around 100–200 px. Within this range patterns stay clear with a moderate bead count — ideal for kids, beginners, or quick relaxing projects.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-10',
|
||||
questionZh: `2.6mm 拼豆适合使用多大的图片?`,
|
||||
questionEn: `What image size suits 2.6mm beads?`,
|
||||
answerZh: `2.6mm 拼豆可以使用 200–300px 的图片。由于颗粒更小,2.6mm 拼豆可以表现更多细节,适合人物、复杂图案或进阶创作。`,
|
||||
answerEn: `200–300 px. Smaller beads capture more detail, making this range ideal for portraits, complex designs, and advanced projects.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-11',
|
||||
questionZh: `自动配色出现杂色或颜色不理想怎么办?`,
|
||||
questionEn: `Auto color-matching produced noise or off colors. What can I do?`,
|
||||
answerZh: `使用左侧工具栏的三个常用修补工具:画笔(为指定像素重新上色,支持左键拖动连续绘制)、橡皮擦(清除不需要的颜色,支持批量擦除)、取色器(吸取画板中已有颜色,保持整体配色统一)。配色原则:优先保证大面积颜色的统一性、减少零散孤立的颜色点、必要时适当简化细节,更利于实际拼豆制作。`,
|
||||
answerEn: `Use the three toolbar tools: Brush (repaint specific pixels, drag to paint continuously), Eraser (bulk-erase unwanted colors), and Eyedropper (pick existing board colors to keep the palette consistent). Keep large areas uniform, reduce isolated single-color dots, and simplify details when needed.`,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'printing',
|
||||
labelZh: '打印',
|
||||
labelEn: 'Printing',
|
||||
items: [
|
||||
{
|
||||
id: 'FAQ-12',
|
||||
questionZh: `为什么要打印拼豆蓝图?`,
|
||||
questionEn: `Why should I print a bead blueprint?`,
|
||||
answerZh: `蓝图可以作为参考,保证颜色、像素和图案准确,尤其适用于复杂作品。`,
|
||||
answerEn: `A printed blueprint keeps colors, pixels, and the design accurate — especially important for complex projects.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-13',
|
||||
questionZh: `打印蓝图前需要注意什么?`,
|
||||
questionEn: `What should I check before printing a blueprint?`,
|
||||
answerZh: `检查图纸比例与最终成品是否一致;使用 300 DPI 高清打印,保证像素清晰;根据纸张尺寸选择合适的打印方式。`,
|
||||
answerEn: `Verify the chart scale matches the finished size; print at 300 DPI for crisp pixels; pick a print layout that fits your paper size.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-14',
|
||||
questionZh: `打印比例不对怎么办?`,
|
||||
questionEn: `The printed scale is wrong. What should I do?`,
|
||||
answerZh: `检查打印设置,确保选择「实际大小」或按比例缩放;可先打印小样确认比例。`,
|
||||
answerEn: `Check print settings and choose "actual size" or scale-to-fit; print a small test swatch first to confirm the scale.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-15',
|
||||
questionZh: `颜色与拼豆不完全对应怎么办?`,
|
||||
questionEn: `The chart color doesn't exactly match my beads. What now?`,
|
||||
answerZh: `使用蓝图参考颜色,结合画板工具(画笔、橡皮擦、取色器)修补;尽量优先使用已有拼豆颜色,避免新增无法购买的颜色。`,
|
||||
answerEn: `Use the blueprint as a reference and adjust with the board tools (brush, eraser, eyedropper). Prefer beads you already own; avoid adding colors you can't buy.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-16',
|
||||
questionZh: `打印蓝图有哪些常见失误?`,
|
||||
questionEn: `What are common blueprint printing mistakes?`,
|
||||
answerZh: `图案比例错误 → 调整打印设置;纸张过小 → 分块打印;铺豆顺序混乱 → 先大面积、后细节;蓝图损坏 → 保留电子备份。`,
|
||||
answerEn: `Wrong scale → fix print settings; paper too small → print in tiles; messy beading order → lay large areas first, then details; damaged blueprint → keep a digital backup.`,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'ironing',
|
||||
labelZh: '熨烫',
|
||||
labelEn: 'Ironing',
|
||||
items: [
|
||||
{
|
||||
id: 'FAQ-17',
|
||||
questionZh: `为什么熨烫这么难?`,
|
||||
questionEn: `Why is ironing so tricky?`,
|
||||
answerZh: `拼豆材料是低密度聚乙烯(LDPE),熔点 105–115°C。温度过低粘合不牢,过高会完全熔化;颜色深浅吸热速度不同,导致局部熔化不均。熨烫需要控制温度、时间、压力和移动速度四个变量。`,
|
||||
answerEn: `Beads are LDPE with a melting point of 105–115°C. Too low won't fuse, too high melts them flat; dark colors absorb heat faster, causing uneven melting. You must control temperature, time, pressure, and movement speed.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-18',
|
||||
questionZh: `家用熨斗可以熨烫拼豆吗?`,
|
||||
questionEn: `Can I use a regular household iron?`,
|
||||
answerZh: `可以,但有局限:蒸汽孔会导致受热不均、留下印记。建议关闭蒸汽、温度中档、持续画圈移动,不要停留在同一位置超过 3 秒。进阶选择:Cricut EasyPress 或小型压烫机,平整加热、温控精准,尤其适合细节或大作品。`,
|
||||
answerEn: `Yes, with caveats — steam holes heat unevenly and leave marks. Turn steam off, use medium heat, and keep a circular motion without pausing more than 3 seconds in one spot. For better results, use a Cricut EasyPress or mini heat press for even, precise heat.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-19',
|
||||
questionZh: `熨烫介质层(助烫纸/熨烫膜)应该选哪种?`,
|
||||
questionEn: `Which ironing paper should I use — parchment or ironing film?`,
|
||||
answerZh: `助烫纸(Parchment Paper):哑光效果,便宜易用,适合日常练习。熨烫膜(Ironing Film):透明、高光泽,适合重要作品,可观察熨烫进度。特别注意:不要用蜡纸,会融化污染作品和熨斗。`,
|
||||
answerEn: `Parchment paper: matte finish, cheap and easy, good for practice. Ironing film: transparent with a glossy finish, lets you watch the melt, great for special projects. Never use wax paper — it melts and ruins both the piece and the iron.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-20',
|
||||
questionZh: `作品容易翘曲或断裂怎么办?`,
|
||||
questionEn: `My piece keeps warping or breaking. What should I do?`,
|
||||
answerZh: `冷却时在平面上压重物 10–20 分钟;避免单面过度熨烫;熨烫不足(豆豆仅表面粘连)时,可覆盖助烫纸局部补熨。`,
|
||||
answerEn: `Press the piece flat under a weight for 10–20 minutes while cooling; avoid over-ironing one side only; if beads are only surface-fused, re-iron that area under fresh parchment.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-21',
|
||||
questionZh: `胶带法(Tape Method)有什么用?`,
|
||||
questionEn: `What is the Tape Method for?`,
|
||||
answerZh: `胶带法可避免钉板受热变形,允许使用更高温度、更长时间熨烫。步骤:贴胶带 → 翻面 → 打孔排气 → 熨烫 → 冷却压平 → 撕胶带。注意:打孔防止空气膨胀造成爆孔。`,
|
||||
answerEn: `The Tape Method protects the pegboard from heat and allows higher temperature / longer ironing. Steps: tape the beads → flip → punch holes for venting → iron → cool and press flat → remove tape. Punching holes prevents blowouts from trapped air.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-22',
|
||||
questionZh: `熨烫有哪些常见问题?如何解决?`,
|
||||
questionEn: `What are common ironing problems and fixes?`,
|
||||
answerZh: `① 爆孔(Blowouts):胶带未打孔或温度过高 → 打孔、降低温度、延长熨烫时间。② 胶带残留:温度过高或熨烫过久 → 用酒精或清洁剂擦拭。③ 作品翘曲:冷却未压平、单面受热过度 → 重新加热局部、重物压平。④ 熔化不均:熨斗移动不均、纸张皱褶、桌面不平 → 加强圆周运动、局部补熨。⑤ 作品断裂:熨烫不足 → 覆盖助烫纸重新熨烫。⑥ 表面哑/亮混合:介质层不平整、过早撕除 → 新助烫纸局部再熨,完全冷却后撕。`,
|
||||
answerEn: `① Blowouts: tape not vented or heat too high → vent, lower heat, iron longer. ② Tape residue: too hot / too long → wipe with alcohol or cleaner. ③ Warping: cooled without pressure / one side over-heated → reheat locally and press flat. ④ Uneven melt: uneven motion, wrinkled paper, uneven surface → circle more, touch up locally. ⑤ Breakage: not fused enough → re-iron under fresh parchment. ⑥ Matte/glossy mix: uneven medium or removed too early → re-iron with new parchment, remove only after fully cooled.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-23',
|
||||
questionZh: `熨烫风格有哪几种?怎么选?`,
|
||||
questionEn: `What ironing styles are there and how do I choose?`,
|
||||
answerZh: `① 部分熨烫(Partial Melt):保留圆形孔洞,立体感强,新手易操作。② 完全平融(Flat Melt / Pixel Melt):豆豆闭合、表面平滑,视觉震撼,难度高。③ 混合风格(Back Melt):背面平融、正面保留立体,兼顾坚固与质感。`,
|
||||
answerEn: `① Partial Melt — keeps round holes, 3D feel, beginner-friendly. ② Flat/Pixel Melt — beads fully closed into a smooth surface, striking look, harder. ③ Back Melt — flat back for strength, dimensional front for texture.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-24',
|
||||
questionZh: `新手熨烫有什么黄金法则?`,
|
||||
questionEn: `What's the golden rule for beginner ironing?`,
|
||||
answerZh: `低温慢熨(Low and Slow)比高温快熨更安全;大作品分区熨烫、边缘优先;使用透明熨烫膜观察熨烫进度;冷却时保持压平。`,
|
||||
answerEn: `Low and slow beats hot and fast. Iron large pieces in sections, edges first; use transparent film to watch the melt; keep it pressed flat while cooling.`,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'framing',
|
||||
labelZh: '裱框',
|
||||
labelEn: 'Framing',
|
||||
items: [
|
||||
{
|
||||
id: 'FAQ-25',
|
||||
questionZh: `一定要买定制画框来装裱吗?`,
|
||||
questionEn: `Do I need a custom frame for my bead art?`,
|
||||
answerZh: `不需要。市面上的「5cm 深度展示框」非常通用,性价比极高。选购时注意画框需有足够深度(立体中空框,如宜家 HOVSTA),避免挤压拼豆;背景纸建议深色以突显颜色,或同色系增加质感。`,
|
||||
answerEn: `No. A common 5cm-deep shadow-box frame is affordable and works great. Make sure it has enough depth (a hollow/deep frame like IKEA HOVSTA) so beads aren't squeezed; use a dark backing for contrast or a matching color for a richer look.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-26',
|
||||
questionZh: `拼豆作品可以直接贴墙上吗?`,
|
||||
questionEn: `Can I hang bead art directly on the wall?`,
|
||||
answerZh: `可以,建议使用蓝丁胶或无痕泡沫胶,在作品背面多点固定,避免损坏豆子表面;长期暴露可能积灰,可加亚克力罩保护。想营造像素悬浮感,可在作品与背板间加小块泡沫胶。`,
|
||||
answerEn: `Yes — use Blu-Tack or foam mounting dots at multiple points on the back to avoid damaging bead surfaces. Long-term display may collect dust, so consider an acrylic cover. Add small foam pads behind the piece for a floating-pixel effect.`,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'redemption',
|
||||
labelZh: '兑换码与权益',
|
||||
labelEn: 'Redemption & Credits',
|
||||
items: [
|
||||
{
|
||||
id: 'FAQ-27',
|
||||
questionZh: `兑换码怎么使用?`,
|
||||
questionEn: `How do I redeem a code?`,
|
||||
answerZh: `在首页/生成页点击「兑换」,输入兑换码即可将对应权益次数绑定到当前设备;兑换成功后会显示剩余次数,无需再次输入。注意:兑换码需未过期、未耗尽,且单设备绑定。`,
|
||||
answerEn: `Click "Redeem" on the home/generator page and enter your code — the credits are bound to your current device. You'll see your remaining count immediately, no re-entry needed. Codes must be valid, unused, and are device-bound.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-28',
|
||||
questionZh: `兑换码可以多个设备共用吗?`,
|
||||
questionEn: `Can I use my code on multiple devices?`,
|
||||
answerZh: `兑换码为单设备绑定。兑换后权益次数记录在当前浏览器(localStorage)中,请在主要创作设备上兑换;如需更换设备,建议联系客服协助迁移。`,
|
||||
answerEn: `Codes are bound to one device. Credits are stored locally in your browser, so redeem on the device you'll mainly use. Contact support if you need to move credits to another device.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-29',
|
||||
questionZh: `购买套餐后如何拿到兑换码?`,
|
||||
questionEn: `How do I receive my code after purchasing a plan?`,
|
||||
answerZh: `支付成功后系统会自动完成兑换(自动 redeem),无需手动输入兑换码;同时订单结果页会展示兑换码与剩余次数,可截图留存。如支付未回调成功,请联系客服手动处理。`,
|
||||
answerEn: `After payment succeeds the code is redeemed automatically — no manual entry needed. The order page shows your code and remaining credits for reference. If the callback fails, contact support for manual processing.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-30',
|
||||
questionZh: `权益次数是怎么扣减的?`,
|
||||
questionEn: `How are credits consumed?`,
|
||||
answerZh: `每次下载高清图纸(含 AI 生成)扣除 1 次权益;免费预览、参数调整不扣次数。扣减前会明确提示,避免误扣。剩余次数会常驻显示在顶部导航。`,
|
||||
answerEn: `Each HD pattern download (including AI generation) consumes 1 credit. Free previews and parameter tweaks never consume credits. You'll be prompted before any deduction, and remaining credits always show in the top nav.`,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'ai-zone',
|
||||
labelZh: 'AI 专区',
|
||||
labelEn: 'AI Zone',
|
||||
items: [
|
||||
{
|
||||
id: 'FAQ-31',
|
||||
questionZh: `AI 拼豆专区是什么?怎么用?`,
|
||||
questionEn: `What is the AI bead zone and how do I use it?`,
|
||||
answerZh: `AI 专区(/chibi)提供 5 大风格(风景/人物/宠物/物品/像素二创)共 15 种细分风格:选择大类与细分 → 调整格数(48/64/80/96)与色数(16/24/32/40)→ 点击生成,AI 会为你直接产出一张拼豆图纸。生成即扣 1 次权益。`,
|
||||
answerEn: `The AI zone (/chibi) offers 5 categories (landscape / portrait / pet / object / pixel remix) with 15 sub-styles. Pick a category and sub-style, set grid size (48/64/80/96) and color count (16/24/32/40), then hit generate — AI produces a ready-to-iron bead chart. Each generation consumes 1 credit.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-32',
|
||||
questionZh: `AI 生成前需要准备什么?生成的图纸能用吗?`,
|
||||
questionEn: `What do I need before generating with AI? Is the output usable?`,
|
||||
answerZh: `需要已兑换的权益(≥1 次)。AI 会返回带色号标注的图纸,可照图买豆、直接打印/下载,也支持微调格数与色数重新生成。建议描述场景关键词(如「童话森林,晨雾中的小屋」)以获得更贴合需求的效果。`,
|
||||
answerEn: `You need at least 1 credit. AI returns a bead chart with color codes that you can print or download directly; you can also tweak grid size / color count and regenerate. Descriptive keywords (e.g. "fairy forest cottage in morning mist") get closer to what you want.`,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'product',
|
||||
labelZh: '平台与使用',
|
||||
labelEn: 'Platform & Usage',
|
||||
items: [
|
||||
{
|
||||
id: 'FAQ-33',
|
||||
questionZh: `平台收费吗?需要注册吗?`,
|
||||
questionEn: `Is the platform free? Do I need to register?`,
|
||||
answerZh: `完全免费使用、无需注册。图片处理在浏览器本地完成,你的图片不会上传服务器。只有「高清图纸下载」和「AI 生成」消耗兑换码权益。`,
|
||||
answerEn: `Completely free, no registration required. Images are processed locally in your browser and never leave your device. Only HD downloads and AI generation consume credits.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-34',
|
||||
questionZh: `代理合作怎么开展?`,
|
||||
questionEn: `How does agent/affiliate cooperation work?`,
|
||||
answerZh: `平台提供面向微商/手工博主的代理套餐(¥139/200 次、¥299/500 次、¥499/1000 次,单价低至 ¥0.5/次),支持批量采购并分发给学员/客户赚取差价;代理可查看名下兑换码、剩余库存与核销记录。联系客服提交代理合作申请即可开通。`,
|
||||
answerEn: `We offer affiliate plans for resellers and craft bloggers (¥139/200 uses, ¥299/500 uses, ¥499/1000 uses, down to ¥0.5/use) for bulk purchase and resale at a margin. Agents can view their codes, stock, and redemption history. Contact support to apply.`,
|
||||
},
|
||||
{
|
||||
id: 'FAQ-35',
|
||||
questionZh: `图纸可以导成什么格式?如何高质量打印?`,
|
||||
questionEn: `What export formats are available? How do I print at high quality?`,
|
||||
answerZh: `图纸支持高清 PNG/PDF 导出(兑换权益后);PDF 建议 300 DPI、标准 A4 或更大纸张打印,必要时分块打印。打印后把蓝图放在拼板下方(透明板)或旁边参考,先铺大面积色块、再铺细节区域,每完成一个区域确认颜色与图纸一致。`,
|
||||
answerEn: `Export HD PNG/PDF after redemption. For PDF, print at 300 DPI on A4 or larger, tiling if needed. Place the blueprint under a transparent pegboard or beside it; lay large color areas first, then details, checking each section as you go.`,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export const FAQ_TOTAL: number = 35;
|
||||
@@ -16,6 +16,12 @@ export { removeBackground } from './background.js';
|
||||
export { mergeSimilarRegions, removeNoise } from './cleanup.js';
|
||||
export type { CleanupOptions } from './cleanup.js';
|
||||
|
||||
export { bfsCleanNoise, labelConnectedRegions } from './bfs-cleanup.js';
|
||||
export type { BfsCleanOptions } from './bfs-cleanup.js';
|
||||
|
||||
export { sortColorsByHue, sortPaletteByHue } from './color-sort.js';
|
||||
export type { ColorSortOptions, ColorSortTieBreak, NeutralPlacement } from './color-sort.js';
|
||||
|
||||
export { excludeAndRemap, restoreExcluded } from './exclusion.js';
|
||||
|
||||
export { MARD_PALETTE, findNearestColor, nearestColorFromRgb } from './mard-palette.js';
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,922 @@
|
||||
[
|
||||
{
|
||||
"code": "H01",
|
||||
"hex": "#E5ECF1",
|
||||
"rgb": [
|
||||
229,
|
||||
236,
|
||||
241
|
||||
],
|
||||
"name": "White"
|
||||
},
|
||||
{
|
||||
"code": "H02",
|
||||
"hex": "#E4E4C5",
|
||||
"rgb": [
|
||||
228,
|
||||
228,
|
||||
197
|
||||
],
|
||||
"name": "Cream"
|
||||
},
|
||||
{
|
||||
"code": "H03",
|
||||
"hex": "#E9C704",
|
||||
"rgb": [
|
||||
233,
|
||||
199,
|
||||
4
|
||||
],
|
||||
"name": "Yellow"
|
||||
},
|
||||
{
|
||||
"code": "H04",
|
||||
"hex": "#D14803",
|
||||
"rgb": [
|
||||
209,
|
||||
72,
|
||||
3
|
||||
],
|
||||
"name": "Orange"
|
||||
},
|
||||
{
|
||||
"code": "H05",
|
||||
"hex": "#B4060E",
|
||||
"rgb": [
|
||||
180,
|
||||
6,
|
||||
14
|
||||
],
|
||||
"name": "Red"
|
||||
},
|
||||
{
|
||||
"code": "H06",
|
||||
"hex": "#EA8AA5",
|
||||
"rgb": [
|
||||
234,
|
||||
138,
|
||||
165
|
||||
],
|
||||
"name": "Pink"
|
||||
},
|
||||
{
|
||||
"code": "H07",
|
||||
"hex": "#712297",
|
||||
"rgb": [
|
||||
113,
|
||||
34,
|
||||
151
|
||||
],
|
||||
"name": "Purple"
|
||||
},
|
||||
{
|
||||
"code": "H08",
|
||||
"hex": "#0239A3",
|
||||
"rgb": [
|
||||
2,
|
||||
57,
|
||||
163
|
||||
],
|
||||
"name": "Blue"
|
||||
},
|
||||
{
|
||||
"code": "H09",
|
||||
"hex": "#025BC3",
|
||||
"rgb": [
|
||||
2,
|
||||
91,
|
||||
195
|
||||
],
|
||||
"name": "Light Blue"
|
||||
},
|
||||
{
|
||||
"code": "H10",
|
||||
"hex": "#027643",
|
||||
"rgb": [
|
||||
2,
|
||||
118,
|
||||
67
|
||||
],
|
||||
"name": "Green"
|
||||
},
|
||||
{
|
||||
"code": "H11",
|
||||
"hex": "#19CDA7",
|
||||
"rgb": [
|
||||
25,
|
||||
205,
|
||||
167
|
||||
],
|
||||
"name": "Light Green"
|
||||
},
|
||||
{
|
||||
"code": "H12",
|
||||
"hex": "#3E271A",
|
||||
"rgb": [
|
||||
62,
|
||||
39,
|
||||
26
|
||||
],
|
||||
"name": "Brown"
|
||||
},
|
||||
{
|
||||
"code": "H13",
|
||||
"hex": "#C02435",
|
||||
"rgb": [
|
||||
192,
|
||||
36,
|
||||
53
|
||||
],
|
||||
"name": "Transparent Red"
|
||||
},
|
||||
{
|
||||
"code": "H14",
|
||||
"hex": "#E4AA32",
|
||||
"rgb": [
|
||||
228,
|
||||
170,
|
||||
50
|
||||
],
|
||||
"name": "Transparent Yellow"
|
||||
},
|
||||
{
|
||||
"code": "H16",
|
||||
"hex": "#37B876",
|
||||
"rgb": [
|
||||
55,
|
||||
184,
|
||||
118
|
||||
],
|
||||
"name": "Transparent Green"
|
||||
},
|
||||
{
|
||||
"code": "H17",
|
||||
"hex": "#838F98",
|
||||
"rgb": [
|
||||
131,
|
||||
143,
|
||||
152
|
||||
],
|
||||
"name": "Grey"
|
||||
},
|
||||
{
|
||||
"code": "H18",
|
||||
"hex": "#141315",
|
||||
"rgb": [
|
||||
20,
|
||||
19,
|
||||
21
|
||||
],
|
||||
"name": "Black"
|
||||
},
|
||||
{
|
||||
"code": "H19",
|
||||
"hex": "#D8D2CE",
|
||||
"rgb": [
|
||||
216,
|
||||
210,
|
||||
206
|
||||
],
|
||||
"name": "Clear"
|
||||
},
|
||||
{
|
||||
"code": "H20",
|
||||
"hex": "#8D2A0F",
|
||||
"rgb": [
|
||||
141,
|
||||
42,
|
||||
15
|
||||
],
|
||||
"name": "Reddish Brown"
|
||||
},
|
||||
{
|
||||
"code": "H21",
|
||||
"hex": "#BE6C21",
|
||||
"rgb": [
|
||||
190,
|
||||
108,
|
||||
33
|
||||
],
|
||||
"name": "Light Brown"
|
||||
},
|
||||
{
|
||||
"code": "H22",
|
||||
"hex": "#91020A",
|
||||
"rgb": [
|
||||
145,
|
||||
2,
|
||||
10
|
||||
],
|
||||
"name": "Dark Red"
|
||||
},
|
||||
{
|
||||
"code": "H24",
|
||||
"hex": "#683E9A",
|
||||
"rgb": [
|
||||
104,
|
||||
62,
|
||||
154
|
||||
],
|
||||
"name": "Translucent Purple"
|
||||
},
|
||||
{
|
||||
"code": "H25",
|
||||
"hex": "#87593D",
|
||||
"rgb": [
|
||||
135,
|
||||
89,
|
||||
61
|
||||
],
|
||||
"name": "Translucent Brown"
|
||||
},
|
||||
{
|
||||
"code": "H26",
|
||||
"hex": "#E8A498",
|
||||
"rgb": [
|
||||
232,
|
||||
164,
|
||||
152
|
||||
],
|
||||
"name": "Matt Rose"
|
||||
},
|
||||
{
|
||||
"code": "H27",
|
||||
"hex": "#DCB18E",
|
||||
"rgb": [
|
||||
220,
|
||||
177,
|
||||
142
|
||||
],
|
||||
"name": "Beige"
|
||||
},
|
||||
{
|
||||
"code": "H28",
|
||||
"hex": "#1E2C1C",
|
||||
"rgb": [
|
||||
30,
|
||||
44,
|
||||
28
|
||||
],
|
||||
"name": "Dark Green"
|
||||
},
|
||||
{
|
||||
"code": "H29",
|
||||
"hex": "#BF0142",
|
||||
"rgb": [
|
||||
191,
|
||||
1,
|
||||
66
|
||||
],
|
||||
"name": "Claret"
|
||||
},
|
||||
{
|
||||
"code": "H30",
|
||||
"hex": "#4E0C1B",
|
||||
"rgb": [
|
||||
78,
|
||||
12,
|
||||
27
|
||||
],
|
||||
"name": "Burgundy"
|
||||
},
|
||||
{
|
||||
"code": "H31",
|
||||
"hex": "#489AB9",
|
||||
"rgb": [
|
||||
72,
|
||||
154,
|
||||
185
|
||||
],
|
||||
"name": "Turquoise"
|
||||
},
|
||||
{
|
||||
"code": "H32",
|
||||
"hex": "#FF208D",
|
||||
"rgb": [
|
||||
255,
|
||||
32,
|
||||
141
|
||||
],
|
||||
"name": "Neon Fuchsia"
|
||||
},
|
||||
{
|
||||
"code": "H33",
|
||||
"hex": "#FF3956",
|
||||
"rgb": [
|
||||
255,
|
||||
57,
|
||||
86
|
||||
],
|
||||
"name": "Cerise"
|
||||
},
|
||||
{
|
||||
"code": "H34",
|
||||
"hex": "#E5EF13",
|
||||
"rgb": [
|
||||
229,
|
||||
239,
|
||||
19
|
||||
],
|
||||
"name": "Neon Yellow"
|
||||
},
|
||||
{
|
||||
"code": "H35",
|
||||
"hex": "#FF2833",
|
||||
"rgb": [
|
||||
255,
|
||||
40,
|
||||
51
|
||||
],
|
||||
"name": "Neon Red"
|
||||
},
|
||||
{
|
||||
"code": "H36",
|
||||
"hex": "#2353B0",
|
||||
"rgb": [
|
||||
35,
|
||||
83,
|
||||
176
|
||||
],
|
||||
"name": "Neon Blue"
|
||||
},
|
||||
{
|
||||
"code": "H37",
|
||||
"hex": "#06B73C",
|
||||
"rgb": [
|
||||
6,
|
||||
183,
|
||||
60
|
||||
],
|
||||
"name": "Neon Green"
|
||||
},
|
||||
{
|
||||
"code": "H38",
|
||||
"hex": "#FD8600",
|
||||
"rgb": [
|
||||
253,
|
||||
134,
|
||||
0
|
||||
],
|
||||
"name": "Neon Orange"
|
||||
},
|
||||
{
|
||||
"code": "H39",
|
||||
"hex": "#F1F21C",
|
||||
"rgb": [
|
||||
241,
|
||||
242,
|
||||
28
|
||||
],
|
||||
"name": "Fluorescent Yellow"
|
||||
},
|
||||
{
|
||||
"code": "H40",
|
||||
"hex": "#FE630B",
|
||||
"rgb": [
|
||||
254,
|
||||
99,
|
||||
11
|
||||
],
|
||||
"name": "Fluorescent Orange"
|
||||
},
|
||||
{
|
||||
"code": "H41",
|
||||
"hex": "#2659B2",
|
||||
"rgb": [
|
||||
38,
|
||||
89,
|
||||
178
|
||||
],
|
||||
"name": "Fluorescent Blue"
|
||||
},
|
||||
{
|
||||
"code": "H42",
|
||||
"hex": "#0CBD51",
|
||||
"rgb": [
|
||||
12,
|
||||
189,
|
||||
81
|
||||
],
|
||||
"name": "Fluorescent Green"
|
||||
},
|
||||
{
|
||||
"code": "H43",
|
||||
"hex": "#E7E45A",
|
||||
"rgb": [
|
||||
231,
|
||||
228,
|
||||
90
|
||||
],
|
||||
"name": "Pastel Yellow"
|
||||
},
|
||||
{
|
||||
"code": "H44",
|
||||
"hex": "#F96160",
|
||||
"rgb": [
|
||||
249,
|
||||
97,
|
||||
96
|
||||
],
|
||||
"name": "Pastel Red"
|
||||
},
|
||||
{
|
||||
"code": "H45",
|
||||
"hex": "#8E69CD",
|
||||
"rgb": [
|
||||
142,
|
||||
105,
|
||||
205
|
||||
],
|
||||
"name": "Pastel Purple"
|
||||
},
|
||||
{
|
||||
"code": "H46",
|
||||
"hex": "#51AEE4",
|
||||
"rgb": [
|
||||
81,
|
||||
174,
|
||||
228
|
||||
],
|
||||
"name": "Pastel Blue"
|
||||
},
|
||||
{
|
||||
"code": "H47",
|
||||
"hex": "#80DF96",
|
||||
"rgb": [
|
||||
128,
|
||||
223,
|
||||
150
|
||||
],
|
||||
"name": "Pastel Green"
|
||||
},
|
||||
{
|
||||
"code": "H48",
|
||||
"hex": "#D67AD1",
|
||||
"rgb": [
|
||||
214,
|
||||
122,
|
||||
209
|
||||
],
|
||||
"name": "Pastel Pink"
|
||||
},
|
||||
{
|
||||
"code": "H49",
|
||||
"hex": "#0FACD1",
|
||||
"rgb": [
|
||||
15,
|
||||
172,
|
||||
209
|
||||
],
|
||||
"name": "Azure"
|
||||
},
|
||||
{
|
||||
"code": "H60",
|
||||
"hex": "#F0981E",
|
||||
"rgb": [
|
||||
240,
|
||||
152,
|
||||
30
|
||||
],
|
||||
"name": "Teddybear Brown"
|
||||
},
|
||||
{
|
||||
"code": "H70",
|
||||
"hex": "#A5B3C0",
|
||||
"rgb": [
|
||||
165,
|
||||
179,
|
||||
192
|
||||
],
|
||||
"name": "Light Grey"
|
||||
},
|
||||
{
|
||||
"code": "H71",
|
||||
"hex": "#445059",
|
||||
"rgb": [
|
||||
68,
|
||||
80,
|
||||
89
|
||||
],
|
||||
"name": "Dark Grey"
|
||||
},
|
||||
{
|
||||
"code": "H75",
|
||||
"hex": "#B78C6D",
|
||||
"rgb": [
|
||||
183,
|
||||
140,
|
||||
109
|
||||
],
|
||||
"name": "Tan"
|
||||
},
|
||||
{
|
||||
"code": "H76",
|
||||
"hex": "#8A5937",
|
||||
"rgb": [
|
||||
138,
|
||||
89,
|
||||
55
|
||||
],
|
||||
"name": "Nougat"
|
||||
},
|
||||
{
|
||||
"code": "H77",
|
||||
"hex": "#CED1C8",
|
||||
"rgb": [
|
||||
206,
|
||||
209,
|
||||
200
|
||||
],
|
||||
"name": "Cloudy White"
|
||||
},
|
||||
{
|
||||
"code": "H78",
|
||||
"hex": "#F7C1AA",
|
||||
"rgb": [
|
||||
247,
|
||||
193,
|
||||
170
|
||||
],
|
||||
"name": "Light Peach"
|
||||
},
|
||||
{
|
||||
"code": "H79",
|
||||
"hex": "#F87633",
|
||||
"rgb": [
|
||||
248,
|
||||
118,
|
||||
51
|
||||
],
|
||||
"name": "Apricot"
|
||||
},
|
||||
{
|
||||
"code": "H82",
|
||||
"hex": "#91175A",
|
||||
"rgb": [
|
||||
145,
|
||||
23,
|
||||
90
|
||||
],
|
||||
"name": "Plum"
|
||||
},
|
||||
{
|
||||
"code": "H83",
|
||||
"hex": "#037A9F",
|
||||
"rgb": [
|
||||
3,
|
||||
122,
|
||||
159
|
||||
],
|
||||
"name": "Petrol Blue"
|
||||
},
|
||||
{
|
||||
"code": "H84",
|
||||
"hex": "#687836",
|
||||
"rgb": [
|
||||
104,
|
||||
120,
|
||||
54
|
||||
],
|
||||
"name": "Olive Green"
|
||||
},
|
||||
{
|
||||
"code": "H95",
|
||||
"hex": "#DD9BA3",
|
||||
"rgb": [
|
||||
221,
|
||||
155,
|
||||
163
|
||||
],
|
||||
"name": "Pastel Rose"
|
||||
},
|
||||
{
|
||||
"code": "H96",
|
||||
"hex": "#B491AD",
|
||||
"rgb": [
|
||||
180,
|
||||
145,
|
||||
173
|
||||
],
|
||||
"name": "Pastel Lilac"
|
||||
},
|
||||
{
|
||||
"code": "H97",
|
||||
"hex": "#8AAFC2",
|
||||
"rgb": [
|
||||
138,
|
||||
175,
|
||||
194
|
||||
],
|
||||
"name": "Pastel Ice Blue"
|
||||
},
|
||||
{
|
||||
"code": "H98",
|
||||
"hex": "#94CCA4",
|
||||
"rgb": [
|
||||
148,
|
||||
204,
|
||||
164
|
||||
],
|
||||
"name": "Pastel Mint"
|
||||
},
|
||||
{
|
||||
"code": "H15",
|
||||
"hex": "#487ED5",
|
||||
"rgb": [
|
||||
72,
|
||||
126,
|
||||
213
|
||||
],
|
||||
"name": "Transparent Blue"
|
||||
},
|
||||
{
|
||||
"code": "H55",
|
||||
"hex": "#FAF8ED",
|
||||
"rgb": [
|
||||
250,
|
||||
248,
|
||||
237
|
||||
],
|
||||
"name": "Green (Glow in the Dark)"
|
||||
},
|
||||
{
|
||||
"code": "H56",
|
||||
"hex": "#EDBF9F",
|
||||
"rgb": [
|
||||
237,
|
||||
191,
|
||||
159
|
||||
],
|
||||
"name": "Red (Glow in the Dark)"
|
||||
},
|
||||
{
|
||||
"code": "H57",
|
||||
"hex": "#C4D0E3",
|
||||
"rgb": [
|
||||
196,
|
||||
208,
|
||||
227
|
||||
],
|
||||
"name": "Blue (Glow in the Dark)"
|
||||
},
|
||||
{
|
||||
"code": "H61",
|
||||
"hex": "#D99350",
|
||||
"rgb": [
|
||||
217,
|
||||
147,
|
||||
80
|
||||
],
|
||||
"name": "Gold"
|
||||
},
|
||||
{
|
||||
"code": "H62",
|
||||
"hex": "#48474A",
|
||||
"rgb": [
|
||||
72,
|
||||
71,
|
||||
74
|
||||
],
|
||||
"name": "Silver"
|
||||
},
|
||||
{
|
||||
"code": "H63",
|
||||
"hex": "#42312F",
|
||||
"rgb": [
|
||||
66,
|
||||
49,
|
||||
47
|
||||
],
|
||||
"name": "Bronze"
|
||||
},
|
||||
{
|
||||
"code": "H64",
|
||||
"hex": "#EFEBE4",
|
||||
"rgb": [
|
||||
239,
|
||||
235,
|
||||
228
|
||||
],
|
||||
"name": "Pearl"
|
||||
},
|
||||
{
|
||||
"code": "H72",
|
||||
"hex": "#F097B0",
|
||||
"rgb": [
|
||||
240,
|
||||
151,
|
||||
176
|
||||
],
|
||||
"name": "Translucent Pink"
|
||||
},
|
||||
{
|
||||
"code": "H73",
|
||||
"hex": "#59AEF5",
|
||||
"rgb": [
|
||||
89,
|
||||
174,
|
||||
245
|
||||
],
|
||||
"name": "Translucent Aqua"
|
||||
},
|
||||
{
|
||||
"code": "H74",
|
||||
"hex": "#5B55BD",
|
||||
"rgb": [
|
||||
91,
|
||||
85,
|
||||
189
|
||||
],
|
||||
"name": "Translucent Lilac"
|
||||
},
|
||||
{
|
||||
"code": "H101",
|
||||
"hex": "#A9C39B",
|
||||
"rgb": [
|
||||
169,
|
||||
195,
|
||||
155
|
||||
],
|
||||
"name": "Eucalyptus"
|
||||
},
|
||||
{
|
||||
"code": "H102",
|
||||
"hex": "#356B2D",
|
||||
"rgb": [
|
||||
53,
|
||||
107,
|
||||
45
|
||||
],
|
||||
"name": "Forest Green"
|
||||
},
|
||||
{
|
||||
"code": "H103",
|
||||
"hex": "#FFE660",
|
||||
"rgb": [
|
||||
255,
|
||||
230,
|
||||
96
|
||||
],
|
||||
"name": "Light Yellow"
|
||||
},
|
||||
{
|
||||
"code": "H104",
|
||||
"hex": "#BCD122",
|
||||
"rgb": [
|
||||
188,
|
||||
209,
|
||||
34
|
||||
],
|
||||
"name": "Lime"
|
||||
},
|
||||
{
|
||||
"code": "H105",
|
||||
"hex": "#FFAC78",
|
||||
"rgb": [
|
||||
255,
|
||||
172,
|
||||
120
|
||||
],
|
||||
"name": "Light Apricot"
|
||||
},
|
||||
{
|
||||
"code": "H106",
|
||||
"hex": "#CCC5ED",
|
||||
"rgb": [
|
||||
204,
|
||||
197,
|
||||
237
|
||||
],
|
||||
"name": "Light Lavender"
|
||||
},
|
||||
{
|
||||
"code": "H107",
|
||||
"hex": "#6A87C1",
|
||||
"rgb": [
|
||||
106,
|
||||
135,
|
||||
193
|
||||
],
|
||||
"name": "Lavender"
|
||||
},
|
||||
{
|
||||
"code": "H108",
|
||||
"hex": "#2A2536",
|
||||
"rgb": [
|
||||
42,
|
||||
37,
|
||||
54
|
||||
],
|
||||
"name": "Aubergine"
|
||||
},
|
||||
{
|
||||
"code": "H109",
|
||||
"hex": "#8A847F",
|
||||
"rgb": [
|
||||
138,
|
||||
132,
|
||||
127
|
||||
],
|
||||
"name": "Cloudy Grey"
|
||||
},
|
||||
{
|
||||
"code": "H110",
|
||||
"hex": "#838956",
|
||||
"rgb": [
|
||||
131,
|
||||
137,
|
||||
86
|
||||
],
|
||||
"name": "Matcha"
|
||||
},
|
||||
{
|
||||
"code": "H111",
|
||||
"hex": "#835854",
|
||||
"rgb": [
|
||||
131,
|
||||
88,
|
||||
84
|
||||
],
|
||||
"name": "Dark Blush"
|
||||
},
|
||||
{
|
||||
"code": "H112",
|
||||
"hex": "#AD8A82",
|
||||
"rgb": [
|
||||
173,
|
||||
138,
|
||||
130
|
||||
],
|
||||
"name": "Blush"
|
||||
},
|
||||
{
|
||||
"code": "H113",
|
||||
"hex": "#5F887B",
|
||||
"rgb": [
|
||||
95,
|
||||
136,
|
||||
123
|
||||
],
|
||||
"name": "Aqua"
|
||||
},
|
||||
{
|
||||
"code": "H114",
|
||||
"hex": "#9A2C31",
|
||||
"rgb": [
|
||||
154,
|
||||
44,
|
||||
49
|
||||
],
|
||||
"name": "Cherry Red"
|
||||
},
|
||||
{
|
||||
"code": "H115",
|
||||
"hex": "#6E975F",
|
||||
"rgb": [
|
||||
110,
|
||||
151,
|
||||
95
|
||||
],
|
||||
"name": "Bright Green"
|
||||
},
|
||||
{
|
||||
"code": "H116",
|
||||
"hex": "#222838",
|
||||
"rgb": [
|
||||
34,
|
||||
40,
|
||||
56
|
||||
],
|
||||
"name": "Midnight Blue"
|
||||
},
|
||||
{
|
||||
"code": "H117",
|
||||
"hex": "#777169",
|
||||
"rgb": [
|
||||
119,
|
||||
113,
|
||||
105
|
||||
],
|
||||
"name": "Taupe Grey"
|
||||
},
|
||||
{
|
||||
"code": "H118",
|
||||
"hex": "#612932",
|
||||
"rgb": [
|
||||
97,
|
||||
41,
|
||||
50
|
||||
],
|
||||
"name": "Maroon Red"
|
||||
},
|
||||
{
|
||||
"code": "H119",
|
||||
"hex": "#4167B4",
|
||||
"rgb": [
|
||||
65,
|
||||
103,
|
||||
180
|
||||
],
|
||||
"name": "Sky Blue"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,182 @@
|
||||
[
|
||||
{
|
||||
"code": "Black",
|
||||
"hex": "#000000",
|
||||
"rgb": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"name": "Black"
|
||||
},
|
||||
{
|
||||
"code": "Blue",
|
||||
"hex": "#0657D8",
|
||||
"rgb": [
|
||||
6,
|
||||
87,
|
||||
216
|
||||
],
|
||||
"name": "Blue"
|
||||
},
|
||||
{
|
||||
"code": "Green",
|
||||
"hex": "#1FAA03",
|
||||
"rgb": [
|
||||
31,
|
||||
170,
|
||||
3
|
||||
],
|
||||
"name": "Green"
|
||||
},
|
||||
{
|
||||
"code": "Brown",
|
||||
"hex": "#3A0909",
|
||||
"rgb": [
|
||||
58,
|
||||
9,
|
||||
9
|
||||
],
|
||||
"name": "Brown"
|
||||
},
|
||||
{
|
||||
"code": "Blue (Pastell)",
|
||||
"hex": "#93D3E2",
|
||||
"rgb": [
|
||||
147,
|
||||
211,
|
||||
226
|
||||
],
|
||||
"name": "Blue (Pastell)"
|
||||
},
|
||||
{
|
||||
"code": "Grey (Pastell)",
|
||||
"hex": "#9E9C9D",
|
||||
"rgb": [
|
||||
158,
|
||||
156,
|
||||
157
|
||||
],
|
||||
"name": "Grey (Pastell)"
|
||||
},
|
||||
{
|
||||
"code": "Green (Pastell)",
|
||||
"hex": "#ACBF33",
|
||||
"rgb": [
|
||||
172,
|
||||
191,
|
||||
51
|
||||
],
|
||||
"name": "Green (Pastell)"
|
||||
},
|
||||
{
|
||||
"code": "Purple",
|
||||
"hex": "#BE88EA",
|
||||
"rgb": [
|
||||
190,
|
||||
136,
|
||||
234
|
||||
],
|
||||
"name": "Purple"
|
||||
},
|
||||
{
|
||||
"code": "Purple (Pastell)",
|
||||
"hex": "#C5B7DA",
|
||||
"rgb": [
|
||||
197,
|
||||
183,
|
||||
218
|
||||
],
|
||||
"name": "Purple (Pastell)"
|
||||
},
|
||||
{
|
||||
"code": "Red",
|
||||
"hex": "#D80606",
|
||||
"rgb": [
|
||||
216,
|
||||
6,
|
||||
6
|
||||
],
|
||||
"name": "Red"
|
||||
},
|
||||
{
|
||||
"code": "Sand (Pastell)",
|
||||
"hex": "#E0BEA8",
|
||||
"rgb": [
|
||||
224,
|
||||
190,
|
||||
168
|
||||
],
|
||||
"name": "Sand (Pastell)"
|
||||
},
|
||||
{
|
||||
"code": "Orange (Pastell)",
|
||||
"hex": "#EDA250",
|
||||
"rgb": [
|
||||
237,
|
||||
162,
|
||||
80
|
||||
],
|
||||
"name": "Orange (Pastell)"
|
||||
},
|
||||
{
|
||||
"code": "Orange",
|
||||
"hex": "#F2741A",
|
||||
"rgb": [
|
||||
242,
|
||||
116,
|
||||
26
|
||||
],
|
||||
"name": "Orange"
|
||||
},
|
||||
{
|
||||
"code": "Pink (Pastell)",
|
||||
"hex": "#F2BFD2",
|
||||
"rgb": [
|
||||
242,
|
||||
191,
|
||||
210
|
||||
],
|
||||
"name": "Pink (Pastell)"
|
||||
},
|
||||
{
|
||||
"code": "Yellow (Pastell)",
|
||||
"hex": "#F7EE45",
|
||||
"rgb": [
|
||||
247,
|
||||
238,
|
||||
69
|
||||
],
|
||||
"name": "Yellow (Pastell)"
|
||||
},
|
||||
{
|
||||
"code": "Pink",
|
||||
"hex": "#FF66B7",
|
||||
"rgb": [
|
||||
255,
|
||||
102,
|
||||
183
|
||||
],
|
||||
"name": "Pink"
|
||||
},
|
||||
{
|
||||
"code": "Yellow",
|
||||
"hex": "#FFE016",
|
||||
"rgb": [
|
||||
255,
|
||||
224,
|
||||
22
|
||||
],
|
||||
"name": "Yellow"
|
||||
},
|
||||
{
|
||||
"code": "White",
|
||||
"hex": "#FFFFFF",
|
||||
"rgb": [
|
||||
255,
|
||||
255,
|
||||
255
|
||||
],
|
||||
"name": "White"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,302 @@
|
||||
[
|
||||
{
|
||||
"code": "N16",
|
||||
"hex": "#297A3B",
|
||||
"rgb": [
|
||||
41,
|
||||
122,
|
||||
59
|
||||
],
|
||||
"name": "Green"
|
||||
},
|
||||
{
|
||||
"code": "N09",
|
||||
"hex": "#2F4A39",
|
||||
"rgb": [
|
||||
47,
|
||||
74,
|
||||
57
|
||||
],
|
||||
"name": "Hunter Green"
|
||||
},
|
||||
{
|
||||
"code": "N01",
|
||||
"hex": "#3A3D41",
|
||||
"rgb": [
|
||||
58,
|
||||
61,
|
||||
65
|
||||
],
|
||||
"name": "Black"
|
||||
},
|
||||
{
|
||||
"code": "N17",
|
||||
"hex": "#3B75CB",
|
||||
"rgb": [
|
||||
59,
|
||||
117,
|
||||
203
|
||||
],
|
||||
"name": "Bright Blue"
|
||||
},
|
||||
{
|
||||
"code": "N22",
|
||||
"hex": "#48AF4F",
|
||||
"rgb": [
|
||||
72,
|
||||
175,
|
||||
79
|
||||
],
|
||||
"name": "Lime"
|
||||
},
|
||||
{
|
||||
"code": "N02",
|
||||
"hex": "#50443B",
|
||||
"rgb": [
|
||||
80,
|
||||
68,
|
||||
59
|
||||
],
|
||||
"name": "Dark Brown"
|
||||
},
|
||||
{
|
||||
"code": "N03",
|
||||
"hex": "#5A3E36",
|
||||
"rgb": [
|
||||
90,
|
||||
62,
|
||||
54
|
||||
],
|
||||
"name": "Brown Medium"
|
||||
},
|
||||
{
|
||||
"code": "N11",
|
||||
"hex": "#644591",
|
||||
"rgb": [
|
||||
100,
|
||||
69,
|
||||
145
|
||||
],
|
||||
"name": "Purple"
|
||||
},
|
||||
{
|
||||
"code": "N23",
|
||||
"hex": "#71A3E6",
|
||||
"rgb": [
|
||||
113,
|
||||
163,
|
||||
230
|
||||
],
|
||||
"name": "Medium Blue"
|
||||
},
|
||||
{
|
||||
"code": "N04",
|
||||
"hex": "#813547",
|
||||
"rgb": [
|
||||
129,
|
||||
53,
|
||||
71
|
||||
],
|
||||
"name": "Maroon"
|
||||
},
|
||||
{
|
||||
"code": "N27",
|
||||
"hex": "#875F52",
|
||||
"rgb": [
|
||||
135,
|
||||
95,
|
||||
82
|
||||
],
|
||||
"name": "Chocolate"
|
||||
},
|
||||
{
|
||||
"code": "N08",
|
||||
"hex": "#8D8B7F",
|
||||
"rgb": [
|
||||
141,
|
||||
139,
|
||||
127
|
||||
],
|
||||
"name": "Ash"
|
||||
},
|
||||
{
|
||||
"code": "N05",
|
||||
"hex": "#A76224",
|
||||
"rgb": [
|
||||
167,
|
||||
98,
|
||||
36
|
||||
],
|
||||
"name": "Caramel"
|
||||
},
|
||||
{
|
||||
"code": "N28",
|
||||
"hex": "#A7C6F1",
|
||||
"rgb": [
|
||||
167,
|
||||
198,
|
||||
241
|
||||
],
|
||||
"name": "Sky"
|
||||
},
|
||||
{
|
||||
"code": "N06",
|
||||
"hex": "#AD967E",
|
||||
"rgb": [
|
||||
173,
|
||||
150,
|
||||
126
|
||||
],
|
||||
"name": "Tan"
|
||||
},
|
||||
{
|
||||
"code": "N20",
|
||||
"hex": "#B58B69",
|
||||
"rgb": [
|
||||
181,
|
||||
139,
|
||||
105
|
||||
],
|
||||
"name": "Light Brown"
|
||||
},
|
||||
{
|
||||
"code": "N24",
|
||||
"hex": "#B6A0DB",
|
||||
"rgb": [
|
||||
182,
|
||||
160,
|
||||
219
|
||||
],
|
||||
"name": "Lavender"
|
||||
},
|
||||
{
|
||||
"code": "N30",
|
||||
"hex": "#C7BF5E",
|
||||
"rgb": [
|
||||
199,
|
||||
191,
|
||||
94
|
||||
],
|
||||
"name": "Kiwi"
|
||||
},
|
||||
{
|
||||
"code": "N10",
|
||||
"hex": "#D3CBCB",
|
||||
"rgb": [
|
||||
211,
|
||||
203,
|
||||
203
|
||||
],
|
||||
"name": "Light Grey"
|
||||
},
|
||||
{
|
||||
"code": "N19",
|
||||
"hex": "#DF2638",
|
||||
"rgb": [
|
||||
223,
|
||||
38,
|
||||
56
|
||||
],
|
||||
"name": "Red"
|
||||
},
|
||||
{
|
||||
"code": "N18",
|
||||
"hex": "#E1B4AB",
|
||||
"rgb": [
|
||||
225,
|
||||
180,
|
||||
171
|
||||
],
|
||||
"name": "Light Rose"
|
||||
},
|
||||
{
|
||||
"code": "N12",
|
||||
"hex": "#E2D0BF",
|
||||
"rgb": [
|
||||
226,
|
||||
208,
|
||||
191
|
||||
],
|
||||
"name": "Ivory"
|
||||
},
|
||||
{
|
||||
"code": "N25",
|
||||
"hex": "#EE6A97",
|
||||
"rgb": [
|
||||
238,
|
||||
106,
|
||||
151
|
||||
],
|
||||
"name": "Pink"
|
||||
},
|
||||
{
|
||||
"code": "N29",
|
||||
"hex": "#EE9527",
|
||||
"rgb": [
|
||||
238,
|
||||
149,
|
||||
39
|
||||
],
|
||||
"name": "Gold"
|
||||
},
|
||||
{
|
||||
"code": "N07",
|
||||
"hex": "#EEB182",
|
||||
"rgb": [
|
||||
238,
|
||||
177,
|
||||
130
|
||||
],
|
||||
"name": "Sand"
|
||||
},
|
||||
{
|
||||
"code": "N13",
|
||||
"hex": "#F3601B",
|
||||
"rgb": [
|
||||
243,
|
||||
96,
|
||||
27
|
||||
],
|
||||
"name": "Orange"
|
||||
},
|
||||
{
|
||||
"code": "N15",
|
||||
"hex": "#F4F4F3",
|
||||
"rgb": [
|
||||
244,
|
||||
244,
|
||||
243
|
||||
],
|
||||
"name": "White"
|
||||
},
|
||||
{
|
||||
"code": "N21",
|
||||
"hex": "#F5EC8D",
|
||||
"rgb": [
|
||||
245,
|
||||
236,
|
||||
141
|
||||
],
|
||||
"name": "Light Yellow"
|
||||
},
|
||||
{
|
||||
"code": "N14",
|
||||
"hex": "#F9CA00",
|
||||
"rgb": [
|
||||
249,
|
||||
202,
|
||||
0
|
||||
],
|
||||
"name": "Yellow"
|
||||
},
|
||||
{
|
||||
"code": "N26",
|
||||
"hex": "#FCA879",
|
||||
"rgb": [
|
||||
252,
|
||||
168,
|
||||
121
|
||||
],
|
||||
"name": "Peach"
|
||||
}
|
||||
]
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,190 @@
|
||||
/**
|
||||
* PERLER LAB — Showcase / Library 共享数据模型
|
||||
*
|
||||
* - `ShowcaseWork`:作品展示页(T-097/T-098)与图纸库页(T-108)共用的作品条目。
|
||||
* - `SHOWCASE_TAGS`:筛选标签词汇表(与 chibi 五大类一一对应)。
|
||||
* - `makePixelThumb`:确定性像素豆图缩略图(内联 SVG data URI,无外部依赖)。
|
||||
* - `SEED_WORKS`:首版种子数据(T-099 后端就绪后替换为接口拉取)。
|
||||
*
|
||||
* 标签为内部值(landscape/people/…),展示文案由 i18n `showcase.tag.*` 驱动。
|
||||
*/
|
||||
|
||||
export type ShowcaseTag = 'landscape' | 'people' | 'pet' | 'item' | 'food';
|
||||
|
||||
/** 作品来源:chibi = AI 专区发布(卡片展示「AI 生成」标记);official = 官方精选。 */
|
||||
export type ShowcaseSource = 'chibi' | 'official';
|
||||
|
||||
export interface ShowcaseWork {
|
||||
id: string;
|
||||
title: string;
|
||||
/** 缩略图 URL(data URI 或远端地址) */
|
||||
thumb: string;
|
||||
tags: ShowcaseTag[];
|
||||
author: string;
|
||||
likes: number;
|
||||
views: number;
|
||||
source: ShowcaseSource;
|
||||
/** 图纸规格,如 '64×64';缺省表示未知 */
|
||||
grid?: string;
|
||||
}
|
||||
|
||||
/** 筛选标签词汇表:'全部' 由页面单独处理。 */
|
||||
export const SHOWCASE_TAGS: readonly ShowcaseTag[] = [
|
||||
'landscape',
|
||||
'people',
|
||||
'pet',
|
||||
'item',
|
||||
'food',
|
||||
] as const;
|
||||
|
||||
/** ChibiPage 大类 id → Showcase 标签(二者一致,可直接透传)。 */
|
||||
export const CHIBI_CATEGORY_TO_TAG: Record<string, ShowcaseTag> = {
|
||||
landscape: 'landscape',
|
||||
people: 'people',
|
||||
pet: 'pet',
|
||||
item: 'item',
|
||||
food: 'food',
|
||||
};
|
||||
|
||||
/* ── 确定性随机(mulberry32),保证缩略图跨刷新稳定 ── */
|
||||
|
||||
function mulberry32(seed: number): () => number {
|
||||
let a = seed >>> 0;
|
||||
return () => {
|
||||
a |= 0;
|
||||
a = (a + 0x6d2b79f5) | 0;
|
||||
let t = Math.imul(a ^ (a >>> 15), 1 | a);
|
||||
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
||||
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成一张 12×12 拼豆风格的缩略图(SVG data URI)。
|
||||
* `seed` 决定图案;`palette` 决定用色(与作品品类呼应)。
|
||||
*/
|
||||
export function makePixelThumb(seed: number, palette: readonly string[]): string {
|
||||
const rand = mulberry32(seed);
|
||||
const size = 12;
|
||||
const cell = 400 / size;
|
||||
const beads: string[] = [];
|
||||
for (let y = 0; y < size; y += 1) {
|
||||
for (let x = 0; x < size; x += 1) {
|
||||
const idx = Math.min(palette.length - 1, Math.floor(rand() * palette.length));
|
||||
const color = palette[idx] ?? '#e0dccd';
|
||||
const inset = cell * 0.14;
|
||||
beads.push(
|
||||
`<rect x="${(x * cell + inset).toFixed(1)}" y="${(y * cell + inset).toFixed(1)}" ` +
|
||||
`width="${(cell - inset * 2).toFixed(1)}" height="${(cell - inset * 2).toFixed(1)}" ` +
|
||||
`rx="${(cell * 0.16).toFixed(1)}" fill="${color}"/>`,
|
||||
);
|
||||
}
|
||||
}
|
||||
const svg =
|
||||
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400">` +
|
||||
`<rect width="400" height="400" rx="28" fill="#f0ede4"/>` +
|
||||
`<rect x="10" y="10" width="380" height="380" rx="20" fill="#ffffff"/>` +
|
||||
`${beads.join('')}</svg>`;
|
||||
return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
|
||||
}
|
||||
|
||||
/* ── 各类品配色(取自设计令牌家族,拼豆可读) ── */
|
||||
|
||||
const PALETTE_LANDSCAPE = ['#edb045', '#d99a2b', '#3daf80', '#3677d2', '#f4f3ef', '#66645d'];
|
||||
const PALETTE_PEOPLE = ['#edb045', '#8a4526', '#f0ede4', '#171713', '#e08a3c', '#66645d'];
|
||||
const PALETTE_PET = ['#d99a2b', '#8a877d', '#f4f3ef', '#171713', '#e0a03c', '#b0aca0'];
|
||||
const PALETTE_ITEM = ['#3daf80', '#3677d2', '#edb045', '#e04f4f', '#f4f3ef', '#66645d'];
|
||||
const PALETTE_FOOD = ['#e04f4f', '#edb045', '#d99a2b', '#3daf80', '#fdf3df', '#8a4526'];
|
||||
|
||||
/* ── 首版种子数据(T-099 后端就绪后由接口替换) ── */
|
||||
|
||||
export const SEED_WORKS: readonly ShowcaseWork[] = [
|
||||
{
|
||||
id: 'sw_001',
|
||||
title: '落日余晖',
|
||||
thumb: makePixelThumb(11, PALETTE_LANDSCAPE),
|
||||
tags: ['landscape'],
|
||||
author: '山月',
|
||||
likes: 128,
|
||||
views: 6346,
|
||||
source: 'official',
|
||||
grid: '64×64',
|
||||
},
|
||||
{
|
||||
id: 'sw_002',
|
||||
title: '午后窗台的猫',
|
||||
thumb: makePixelThumb(22, PALETTE_PET),
|
||||
tags: ['pet'],
|
||||
author: '橘猫',
|
||||
likes: 96,
|
||||
views: 6148,
|
||||
source: 'official',
|
||||
grid: '48×48',
|
||||
},
|
||||
{
|
||||
id: 'sw_003',
|
||||
title: '岩雀徽章',
|
||||
thumb: makePixelThumb(33, PALETTE_ITEM),
|
||||
tags: ['item'],
|
||||
author: 'Tornorroyv',
|
||||
likes: 74,
|
||||
views: 5585,
|
||||
source: 'official',
|
||||
grid: '64×64',
|
||||
},
|
||||
{
|
||||
id: 'sw_004',
|
||||
title: '初夏同款少年',
|
||||
thumb: makePixelThumb(44, PALETTE_PEOPLE),
|
||||
tags: ['people'],
|
||||
author: 'Baico',
|
||||
likes: 61,
|
||||
views: 5078,
|
||||
source: 'official',
|
||||
grid: '80×80',
|
||||
},
|
||||
{
|
||||
id: 'sw_005',
|
||||
title: '草莓奶油蛋糕',
|
||||
thumb: makePixelThumb(55, PALETTE_FOOD),
|
||||
tags: ['food'],
|
||||
author: '小圆子y',
|
||||
likes: 58,
|
||||
views: 4319,
|
||||
source: 'official',
|
||||
grid: '48×48',
|
||||
},
|
||||
{
|
||||
id: 'sw_006',
|
||||
title: '云海远山',
|
||||
thumb: makePixelThumb(66, PALETTE_LANDSCAPE),
|
||||
tags: ['landscape'],
|
||||
author: '息舟',
|
||||
likes: 49,
|
||||
views: 4228,
|
||||
source: 'official',
|
||||
grid: '64×64',
|
||||
},
|
||||
{
|
||||
id: 'sw_007',
|
||||
title: '城市夜景灯火',
|
||||
thumb: makePixelThumb(77, PALETTE_LANDSCAPE),
|
||||
tags: ['landscape'],
|
||||
author: 'Bubble',
|
||||
likes: 36,
|
||||
views: 1416,
|
||||
source: 'official',
|
||||
grid: '96×96',
|
||||
},
|
||||
{
|
||||
id: 'sw_008',
|
||||
title: '柴犬全身像',
|
||||
thumb: makePixelThumb(88, PALETTE_PET),
|
||||
tags: ['pet'],
|
||||
author: '豆子',
|
||||
likes: 27,
|
||||
views: 1240,
|
||||
source: 'official',
|
||||
grid: '80×80',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,93 @@
|
||||
import { useState } from 'react';
|
||||
import './pages.css';
|
||||
import SubNav from '../components/SubNav';
|
||||
import { FAQ_CATEGORIES } from '../lib/faq-data';
|
||||
import { useT } from '../i18n';
|
||||
|
||||
/** 分类折叠状态:key = 分类 id,value = 是否展开。 */
|
||||
type OpenState = Record<string, boolean>;
|
||||
|
||||
/**
|
||||
* HelpPage — 帮助中心 FAQ 页 (/help) [T-106]
|
||||
*
|
||||
* 数据源: src/lib/faq-data.ts(由 docs/FAQ-DATA.md 生成,35 条 / 8 分类)。
|
||||
* 交互: 分类级折叠(手风琴)+ 条目级 <details> 展开;文案按当前语言
|
||||
* (zh-CN/en)取用数据中的 question/answer 双语言字段。
|
||||
*/
|
||||
export default function HelpPage() {
|
||||
const { t, locale } = useT();
|
||||
const isZh = locale === 'zh-CN';
|
||||
|
||||
// 默认全部分类展开,便于首屏即见全部内容;点击标题折叠。
|
||||
const [open, setOpen] = useState<OpenState>(() =>
|
||||
Object.fromEntries(FAQ_CATEGORIES.map((cat) => [cat.id, true])),
|
||||
);
|
||||
|
||||
const toggle = (id: string): void => {
|
||||
setOpen((prev) => ({ ...prev, [id]: !prev[id] }));
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="pl-page">
|
||||
<SubNav active="help" />
|
||||
|
||||
<main className="pl-main">
|
||||
<header className="pl-hero">
|
||||
<span className="pl-eyebrow">{t('help.eyebrow')}</span>
|
||||
<h1 className="pl-h1">
|
||||
{t('help.title')}
|
||||
<em>{t('help.title.accent')}</em>
|
||||
</h1>
|
||||
<p className="pl-sub">{t('help.sub')}</p>
|
||||
</header>
|
||||
|
||||
<section className="help-faq" aria-label={t('help.aria')}>
|
||||
{FAQ_CATEGORIES.map((cat) => {
|
||||
const isOpen = open[cat.id] ?? false;
|
||||
const label = isZh ? cat.labelZh : cat.labelEn;
|
||||
return (
|
||||
<article key={cat.id} className="help-cat">
|
||||
<h2 className="help-cat-head">
|
||||
<button
|
||||
type="button"
|
||||
className="help-cat-toggle"
|
||||
aria-expanded={isOpen}
|
||||
aria-controls={`help-panel-${cat.id}`}
|
||||
onClick={() => toggle(cat.id)}
|
||||
>
|
||||
<span className="help-cat-label">{label}</span>
|
||||
<span className="help-cat-count">{cat.items.length}</span>
|
||||
<span className="help-cat-caret" aria-hidden="true" />
|
||||
</button>
|
||||
</h2>
|
||||
|
||||
{isOpen && (
|
||||
<div id={`help-panel-${cat.id}`} className="help-cat-panel">
|
||||
{cat.items.map((item) => (
|
||||
<details key={item.id} className="help-item">
|
||||
<summary className="help-item-q">
|
||||
<span className="help-item-id">{item.id}</span>
|
||||
{isZh ? item.questionZh : item.questionEn}
|
||||
</summary>
|
||||
<p className="help-item-a">{isZh ? item.answerZh : item.answerEn}</p>
|
||||
</details>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</article>
|
||||
);
|
||||
})}
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer className="pl-footer">
|
||||
<div className="pl-footer-inner">
|
||||
<span className="pl-footer-text">{t('footer.slogan')}</span>
|
||||
<a className="pl-footer-link" href="/">
|
||||
{t('help.back')}
|
||||
</a>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import './pages.css';
|
||||
import SubNav from '../components/SubNav';
|
||||
import { SHOWCASE_TAG_KEYS } from '../components/WorkCard';
|
||||
import { SEED_WORKS, SHOWCASE_TAGS, type ShowcaseWork } from '../lib/showcase';
|
||||
import { useT } from '../i18n';
|
||||
|
||||
/**
|
||||
* LibraryPage — 图纸库页 (/library) [T-108]
|
||||
*
|
||||
* 展示图纸列表:复用 showcase 作品作为首版数据源(每行含缩略图 / 标题 / 标签 /
|
||||
* 图纸规格 / 操作)。后续可接入「已保存 / 已分享图纸」聚合。
|
||||
*/
|
||||
export default function LibraryPage() {
|
||||
const { t } = useT();
|
||||
const works: readonly ShowcaseWork[] = SEED_WORKS;
|
||||
|
||||
return (
|
||||
<div className="pl-page">
|
||||
<SubNav active="library" />
|
||||
|
||||
<main className="pl-main">
|
||||
<header className="pl-hero">
|
||||
<span className="pl-eyebrow">{t('library.eyebrow')}</span>
|
||||
<h1 className="pl-h1">
|
||||
{t('library.title')}
|
||||
<em>{t('library.title.accent')}</em>
|
||||
</h1>
|
||||
<p className="pl-sub">{t('library.sub')}</p>
|
||||
</header>
|
||||
|
||||
<section aria-label={t('library.aria')}>
|
||||
{works.length === 0 ? (
|
||||
<div className="sw-empty">
|
||||
<b>{t('library.empty')}</b>
|
||||
{t('library.empty.desc')}
|
||||
</div>
|
||||
) : (
|
||||
<div className="lib-list">
|
||||
{works.map((work) => {
|
||||
const tags = SHOWCASE_TAGS.filter((tag) => work.tags.includes(tag));
|
||||
return (
|
||||
<article key={work.id} className="lib-row">
|
||||
<img className="lib-thumb" src={work.thumb} alt={work.title} loading="lazy" />
|
||||
<div className="lib-info">
|
||||
<h3 className="lib-title">
|
||||
{work.title}
|
||||
{work.source === 'chibi' && (
|
||||
<span className="lib-badge">{t('showcase.aiBadge')}</span>
|
||||
)}
|
||||
</h3>
|
||||
<div className="lib-meta">
|
||||
<span>@{work.author}</span>
|
||||
{work.grid && <span>{t('library.grid', { size: work.grid })}</span>}
|
||||
<span>{t('library.brand', { brand: 'MARD' })}</span>
|
||||
</div>
|
||||
{tags.length > 0 && (
|
||||
<div className="lib-tags">
|
||||
{tags.map((tag) => (
|
||||
<span key={tag} className="lib-tag">
|
||||
{t(SHOWCASE_TAG_KEYS[tag])}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="lib-actions">
|
||||
<button type="button" className="lib-btn lib-btn--outline">
|
||||
{t('library.preview')}
|
||||
</button>
|
||||
<button type="button" className="lib-btn lib-btn--primary">
|
||||
{t('library.download')}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer className="pl-footer">
|
||||
<div className="pl-footer-inner">
|
||||
<span className="pl-footer-text">{t('footer.slogan')}</span>
|
||||
<span className="pl-footer-text">{t('footer.note')}</span>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
import { useMemo, useState } from 'react';
|
||||
import './pages.css';
|
||||
import SubNav from '../components/SubNav';
|
||||
import WorkCard, { SHOWCASE_TAG_KEYS } from '../components/WorkCard';
|
||||
import { SEED_WORKS, SHOWCASE_TAGS, type ShowcaseTag, type ShowcaseWork } from '../lib/showcase';
|
||||
import { useT } from '../i18n';
|
||||
|
||||
type Filter = ShowcaseTag | 'all';
|
||||
|
||||
/**
|
||||
* ShowcasePage — 作品展示页 (/showcase) [T-097]
|
||||
*
|
||||
* 标题区 + 标签筛选区 + 作品卡片网格。筛选在前端完成(T-098 的 WorkCard 复用;
|
||||
* T-099 后端就绪后可将 `works` 数据源替换为接口拉取)。
|
||||
*/
|
||||
export default function ShowcasePage() {
|
||||
const { t } = useT();
|
||||
const [filter, setFilter] = useState<Filter>('all');
|
||||
|
||||
const works: readonly ShowcaseWork[] = SEED_WORKS;
|
||||
|
||||
const visibleWorks = useMemo(
|
||||
() => (filter === 'all' ? works : works.filter((w) => w.tags.includes(filter))),
|
||||
[works, filter],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="pl-page">
|
||||
<SubNav active="showcase" />
|
||||
|
||||
<main className="pl-main">
|
||||
<header className="pl-hero">
|
||||
<span className="pl-eyebrow">{t('showcase.eyebrow')}</span>
|
||||
<h1 className="pl-h1">
|
||||
{t('showcase.title.prefix')}
|
||||
<em>{t('showcase.title.accent')}</em>
|
||||
</h1>
|
||||
<p className="pl-sub">{t('showcase.sub')}</p>
|
||||
</header>
|
||||
|
||||
<section aria-label={t('showcase.filter.aria')}>
|
||||
<div className="sw-toolbar">
|
||||
<div className="sw-filters">
|
||||
<button
|
||||
type="button"
|
||||
className={`sw-filter${filter === 'all' ? ' is-active' : ''}`}
|
||||
aria-pressed={filter === 'all'}
|
||||
onClick={() => setFilter('all')}
|
||||
>
|
||||
{t('showcase.filter.all')}
|
||||
</button>
|
||||
{SHOWCASE_TAGS.map((tag) => (
|
||||
<button
|
||||
key={tag}
|
||||
type="button"
|
||||
className={`sw-filter${filter === tag ? ' is-active' : ''}`}
|
||||
aria-pressed={filter === tag}
|
||||
onClick={() => setFilter(tag)}
|
||||
>
|
||||
{t(SHOWCASE_TAG_KEYS[tag])}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<span className="sw-count" aria-live="polite">
|
||||
{t('showcase.count', { count: visibleWorks.length })}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{visibleWorks.length === 0 ? (
|
||||
<div className="sw-empty">
|
||||
<b>{t('showcase.empty.title')}</b>
|
||||
{t('showcase.empty.desc')}
|
||||
<br />
|
||||
<a className="sw-cta" href="/chibi">
|
||||
{t('showcase.publish')}
|
||||
</a>
|
||||
</div>
|
||||
) : (
|
||||
<div className="sw-grid">
|
||||
{visibleWorks.map((work) => (
|
||||
<WorkCard
|
||||
key={work.id}
|
||||
work={work}
|
||||
activeTag={filter === 'all' ? null : filter}
|
||||
onTagClick={(tag) => setFilter(tag)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer className="pl-footer">
|
||||
<div className="pl-footer-inner">
|
||||
<span className="pl-footer-text">{t('footer.slogan')}</span>
|
||||
<a className="pl-footer-link" href="/chibi">
|
||||
{t('showcase.publish')}
|
||||
</a>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,837 @@
|
||||
/* =============================================================================
|
||||
* PERLER LAB — Showcase 作品展示 (/showcase) + 图纸库 (/library)
|
||||
* 令牌与 DESIGN.md §1 / ChibiPage.css 保持一致,作用域限定在 .pl-page 下
|
||||
* ========================================================================= */
|
||||
|
||||
.pl-page {
|
||||
/* ── 色彩系统 ── */
|
||||
--bg-page: #f4f3ef;
|
||||
--bg-card: #ffffff;
|
||||
--bg-subtle: #f0ede4;
|
||||
--bg-hover: #faf9f4;
|
||||
--text-primary: #171713;
|
||||
--text-secondary: #66645d;
|
||||
--text-tertiary: #8a877d;
|
||||
--text-disabled: #b0aca0;
|
||||
--text-on-dark: #ffffff;
|
||||
--accent: #edb045;
|
||||
--accent-hover: #dda02e;
|
||||
--accent-soft: #fdf3df;
|
||||
--success: #3daf80;
|
||||
--danger: #e04f4f;
|
||||
--info: #3677d2;
|
||||
--border: #e6e3d9;
|
||||
--border-strong: #d2cec4;
|
||||
--border-dashed: #e0dccd;
|
||||
|
||||
/* ── 字体系统 ── */
|
||||
--font-sans: "Geist", system-ui, -apple-system, "Segoe UI", "PingFang SC",
|
||||
"Microsoft YaHei", sans-serif;
|
||||
--text-xs: 11px;
|
||||
--text-sm: 12px;
|
||||
--text-md: 13px;
|
||||
--text-lg: 17px;
|
||||
--text-xl: 20px;
|
||||
--text-hero: 32px;
|
||||
|
||||
/* ── 间距 / 圆角 / 阴影 ── */
|
||||
--space-1: 4px;
|
||||
--space-2: 8px;
|
||||
--space-3: 12px;
|
||||
--space-4: 16px;
|
||||
--space-5: 24px;
|
||||
--space-6: 32px;
|
||||
--radius-sm: 8px;
|
||||
--radius-md: 10px;
|
||||
--radius-lg: 12px;
|
||||
--radius-full: 999px;
|
||||
--shadow-card: 0 1px 2px rgba(0, 0, 0, .04);
|
||||
--shadow-float: 0 2px 12px rgba(23, 23, 19, .08);
|
||||
|
||||
/* ── 触控目标 ── */
|
||||
--touch-min: 40px;
|
||||
--touch-min-sm: 34px;
|
||||
|
||||
background: var(--bg-page);
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-sans);
|
||||
font-size: var(--text-md);
|
||||
line-height: 1.6;
|
||||
min-height: 100vh;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
.pl-page *,
|
||||
.pl-page *::before,
|
||||
.pl-page *::after {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.pl-page button {
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
background: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.pl-page a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* ═══════════════════════ 子页导航 (与 chibi-nav 同构) ═══════════════════════ */
|
||||
|
||||
.pl-nav {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 100;
|
||||
height: 56px;
|
||||
background: var(--bg-card);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.pl-nav-inner {
|
||||
max-width: 1280px;
|
||||
height: 100%;
|
||||
margin: 0 auto;
|
||||
padding: 0 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-5);
|
||||
}
|
||||
|
||||
.pl-brand {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
color: var(--text-primary);
|
||||
font-size: var(--text-lg);
|
||||
font-weight: 500;
|
||||
letter-spacing: .02em;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.pl-brand-mark {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 6px;
|
||||
background: var(--accent);
|
||||
color: var(--text-on-dark);
|
||||
font-weight: 700;
|
||||
font-size: var(--text-lg);
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.pl-brand b {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.pl-nav-links {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-4);
|
||||
margin-left: var(--space-2);
|
||||
overflow-x: auto;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
.pl-nav-links::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pl-nav-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
height: var(--touch-min-sm);
|
||||
padding: 0 var(--space-1);
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--text-md);
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
border-bottom: 2px solid transparent;
|
||||
transition: color .15s ease;
|
||||
}
|
||||
|
||||
.pl-nav-link:hover {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.pl-nav-link.is-active {
|
||||
color: var(--text-primary);
|
||||
border-bottom-color: var(--accent);
|
||||
}
|
||||
|
||||
.pl-nav-pro {
|
||||
font-size: 9px;
|
||||
font-weight: 700;
|
||||
color: var(--text-on-dark);
|
||||
background: var(--accent);
|
||||
border-radius: var(--radius-full);
|
||||
padding: 1px 6px;
|
||||
letter-spacing: .5px;
|
||||
}
|
||||
|
||||
.pl-nav-right {
|
||||
margin-left: auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-4);
|
||||
}
|
||||
|
||||
.pl-nav-lang {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-full);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.pl-nav-lang-btn {
|
||||
font-size: var(--text-xs);
|
||||
line-height: 1;
|
||||
padding: 5px 10px;
|
||||
min-height: 0;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.pl-nav-lang-btn:hover {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.pl-nav-lang-btn--active {
|
||||
color: var(--text-on-dark);
|
||||
background: var(--accent);
|
||||
}
|
||||
|
||||
/* ═══════════════════════ 页面主体 ═══════════════════════ */
|
||||
|
||||
.pl-main {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: 0 24px 48px;
|
||||
}
|
||||
|
||||
/* ═══════════════════════ 标题区 ═══════════════════════ */
|
||||
|
||||
.pl-hero {
|
||||
padding: 40px 0 24px;
|
||||
}
|
||||
|
||||
.pl-eyebrow {
|
||||
display: block;
|
||||
font-size: var(--text-xs);
|
||||
font-weight: 700;
|
||||
letter-spacing: .18em;
|
||||
text-transform: uppercase;
|
||||
color: var(--accent-hover);
|
||||
margin: 0 0 var(--space-3);
|
||||
}
|
||||
|
||||
.pl-h1 {
|
||||
font-size: var(--text-hero);
|
||||
font-weight: 700;
|
||||
line-height: 1.25;
|
||||
margin: 0 0 var(--space-3);
|
||||
}
|
||||
|
||||
.pl-h1 em {
|
||||
font-style: italic;
|
||||
color: var(--accent-hover);
|
||||
}
|
||||
|
||||
.pl-sub {
|
||||
font-size: 14px;
|
||||
color: var(--text-secondary);
|
||||
max-width: 560px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* ═══════════════════════ Showcase:筛选区 ═══════════════════════ */
|
||||
|
||||
.sw-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-4);
|
||||
flex-wrap: wrap;
|
||||
padding: var(--space-3) 0 var(--space-4);
|
||||
border-bottom: 1px solid var(--border);
|
||||
margin-bottom: var(--space-5);
|
||||
}
|
||||
|
||||
.sw-filters {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.sw-filter {
|
||||
min-height: var(--touch-min-sm);
|
||||
padding: 0 var(--space-4);
|
||||
border-radius: var(--radius-full);
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-strong);
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--text-sm);
|
||||
font-weight: 500;
|
||||
transition: border-color .15s ease, color .15s ease, background .15s ease;
|
||||
}
|
||||
|
||||
.sw-filter:hover {
|
||||
border-color: var(--accent);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.sw-filter.is-active {
|
||||
background: var(--accent);
|
||||
border-color: var(--accent);
|
||||
color: var(--text-on-dark);
|
||||
}
|
||||
|
||||
.sw-count {
|
||||
margin-left: auto;
|
||||
font-size: var(--text-xs);
|
||||
color: var(--text-tertiary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* ═══════════════════════ Showcase:作品卡片网格 ═══════════════════════ */
|
||||
|
||||
.sw-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: var(--space-4);
|
||||
}
|
||||
|
||||
.sw-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-card);
|
||||
overflow: hidden;
|
||||
transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
|
||||
}
|
||||
|
||||
.sw-card:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: var(--shadow-float);
|
||||
border-color: var(--border-strong);
|
||||
}
|
||||
|
||||
.sw-card-media {
|
||||
position: relative;
|
||||
aspect-ratio: 1;
|
||||
background: var(--bg-subtle);
|
||||
}
|
||||
|
||||
.sw-card-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
image-rendering: auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.sw-card-badge {
|
||||
position: absolute;
|
||||
top: var(--space-2);
|
||||
right: var(--space-2);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: var(--text-xs);
|
||||
font-weight: 700;
|
||||
color: var(--text-on-dark);
|
||||
background: rgba(23, 23, 19, 0.72);
|
||||
border-radius: var(--radius-full);
|
||||
padding: 2px 10px;
|
||||
backdrop-filter: blur(2px);
|
||||
}
|
||||
|
||||
.sw-card-badge::before {
|
||||
content: "";
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: var(--accent);
|
||||
}
|
||||
|
||||
.sw-card-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
padding: var(--space-3) var(--space-4) var(--space-4);
|
||||
}
|
||||
|
||||
.sw-card-title {
|
||||
font-size: var(--text-md);
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.sw-card-author {
|
||||
font-size: var(--text-sm);
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.sw-card-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-1);
|
||||
margin-top: var(--space-1);
|
||||
}
|
||||
|
||||
.sw-card-tag {
|
||||
min-height: 22px;
|
||||
padding: 0 var(--space-2);
|
||||
border-radius: var(--radius-full);
|
||||
background: var(--bg-subtle);
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--text-xs);
|
||||
transition: background .15s ease, color .15s ease;
|
||||
}
|
||||
|
||||
.sw-card-tag:hover {
|
||||
background: var(--accent-soft);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.sw-card-tag.is-active {
|
||||
background: var(--accent);
|
||||
color: var(--text-on-dark);
|
||||
}
|
||||
|
||||
.sw-card-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
margin-top: var(--space-2);
|
||||
padding-top: var(--space-2);
|
||||
border-top: 1px solid var(--border);
|
||||
font-size: var(--text-sm);
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.sw-card-meta-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.sw-card-meta-item svg {
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
}
|
||||
|
||||
.sw-card-grid {
|
||||
margin-left: auto;
|
||||
font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
|
||||
font-size: var(--text-xs);
|
||||
color: var(--text-secondary);
|
||||
background: var(--bg-subtle);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 1px 8px;
|
||||
}
|
||||
|
||||
/* Showcase:空态 / 投稿入口 */
|
||||
|
||||
.sw-empty {
|
||||
grid-column: 1 / -1;
|
||||
text-align: center;
|
||||
padding: var(--space-6) var(--space-4);
|
||||
color: var(--text-tertiary);
|
||||
font-size: var(--text-sm);
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.sw-empty b {
|
||||
display: block;
|
||||
font-size: var(--text-lg);
|
||||
color: var(--text-primary);
|
||||
margin-bottom: var(--space-1);
|
||||
}
|
||||
|
||||
.sw-cta {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
min-height: var(--touch-min);
|
||||
margin-top: var(--space-3);
|
||||
padding: 0 var(--space-5);
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--accent);
|
||||
color: var(--text-on-dark);
|
||||
font-size: var(--text-md);
|
||||
font-weight: 700;
|
||||
transition: background .15s ease;
|
||||
}
|
||||
|
||||
.sw-cta:hover {
|
||||
background: var(--accent-hover);
|
||||
}
|
||||
|
||||
/* ═══════════════════════ Library:图纸列表 ═══════════════════════ */
|
||||
|
||||
.lib-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.lib-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-4);
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-card);
|
||||
padding: var(--space-3);
|
||||
transition: border-color .15s ease, box-shadow .15s ease;
|
||||
}
|
||||
|
||||
.lib-row:hover {
|
||||
border-color: var(--border-strong);
|
||||
box-shadow: var(--shadow-float);
|
||||
}
|
||||
|
||||
.lib-thumb {
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
border-radius: var(--radius-md);
|
||||
object-fit: cover;
|
||||
background: var(--bg-subtle);
|
||||
border: 1px solid var(--border);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.lib-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.lib-title {
|
||||
font-size: var(--text-md);
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.lib-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
font-size: var(--text-sm);
|
||||
color: var(--text-tertiary);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.lib-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: var(--text-xs);
|
||||
font-weight: 700;
|
||||
color: var(--text-on-dark);
|
||||
background: rgba(23, 23, 19, 0.72);
|
||||
border-radius: var(--radius-full);
|
||||
padding: 1px 8px;
|
||||
}
|
||||
|
||||
.lib-tags {
|
||||
display: flex;
|
||||
gap: var(--space-1);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.lib-tag {
|
||||
font-size: var(--text-xs);
|
||||
color: var(--text-secondary);
|
||||
background: var(--bg-subtle);
|
||||
border-radius: var(--radius-full);
|
||||
padding: 1px 10px;
|
||||
}
|
||||
|
||||
.lib-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.lib-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--space-1);
|
||||
min-height: var(--touch-min-sm);
|
||||
padding: 0 var(--space-4);
|
||||
border-radius: var(--radius-md);
|
||||
font-size: var(--text-sm);
|
||||
font-weight: 500;
|
||||
transition: background .15s ease, border-color .15s ease;
|
||||
}
|
||||
|
||||
.lib-btn--primary {
|
||||
background: var(--accent);
|
||||
color: var(--text-on-dark);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.lib-btn--primary:hover {
|
||||
background: var(--accent-hover);
|
||||
}
|
||||
|
||||
.lib-btn--outline {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-strong);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.lib-btn--outline:hover {
|
||||
border-color: var(--accent);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
/* ═══════════════════════ Help:FAQ 帮助中心 ═══════════════════════ */
|
||||
|
||||
.help-faq {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.help-cat {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-card);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.help-cat-head {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.help-cat-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
width: 100%;
|
||||
min-height: var(--touch-min);
|
||||
padding: var(--space-3) var(--space-4);
|
||||
text-align: left;
|
||||
color: var(--text-primary);
|
||||
transition: background .15s ease;
|
||||
}
|
||||
|
||||
.help-cat-toggle:hover {
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
|
||||
.help-cat-label {
|
||||
flex: 1;
|
||||
font-size: var(--text-lg);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.help-cat-count {
|
||||
font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
|
||||
font-size: var(--text-xs);
|
||||
color: var(--text-tertiary);
|
||||
background: var(--bg-subtle);
|
||||
border-radius: var(--radius-full);
|
||||
padding: 2px 10px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.help-cat-caret {
|
||||
flex-shrink: 0;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-right: 2px solid var(--text-tertiary);
|
||||
border-bottom: 2px solid var(--text-tertiary);
|
||||
transform: rotate(45deg);
|
||||
transition: transform .15s ease;
|
||||
}
|
||||
|
||||
.help-cat-toggle[aria-expanded='false'] .help-cat-caret {
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
.help-cat-panel {
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.help-item {
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.help-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.help-item-q {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: var(--space-2);
|
||||
padding: var(--space-3) var(--space-4);
|
||||
cursor: pointer;
|
||||
list-style: none;
|
||||
font-size: var(--text-md);
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
transition: background .15s ease;
|
||||
}
|
||||
|
||||
.help-item-q:hover {
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
|
||||
.help-item-q::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.help-item-q::before {
|
||||
content: '▸';
|
||||
flex-shrink: 0;
|
||||
color: var(--text-tertiary);
|
||||
transition: transform .15s ease;
|
||||
}
|
||||
|
||||
.help-item[open] .help-item-q::before {
|
||||
content: '▾';
|
||||
}
|
||||
|
||||
.help-item-id {
|
||||
flex-shrink: 0;
|
||||
font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
|
||||
font-size: var(--text-xs);
|
||||
font-weight: 500;
|
||||
color: var(--accent-hover);
|
||||
}
|
||||
|
||||
.help-item-a {
|
||||
padding: 0 var(--space-4) var(--space-3) calc(var(--space-4) + 24px);
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--text-sm);
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
/* ═══════════════════════ Footer ═══════════════════════ */
|
||||
|
||||
.pl-footer {
|
||||
border-top: 1px solid var(--border);
|
||||
background: var(--bg-card);
|
||||
}
|
||||
|
||||
.pl-footer-inner {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: var(--space-5) 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-4);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.pl-footer-text {
|
||||
font-size: var(--text-xs);
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.pl-footer-link {
|
||||
font-size: var(--text-sm);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.pl-footer-link:hover {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
/* ═══════════════════════ 响应式 ═══════════════════════ */
|
||||
|
||||
@media (max-width: 1023px) {
|
||||
.sw-grid {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.pl-nav-inner {
|
||||
padding: 0 16px;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.pl-nav-links {
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.pl-nav-link {
|
||||
font-size: var(--text-sm);
|
||||
padding: 0 var(--space-2);
|
||||
}
|
||||
|
||||
.pl-main {
|
||||
padding: 0 16px 48px;
|
||||
}
|
||||
|
||||
.pl-hero {
|
||||
padding: 32px 0 20px;
|
||||
}
|
||||
|
||||
.pl-h1 {
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.sw-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.sw-count {
|
||||
width: 100%;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.lib-row {
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.lib-actions {
|
||||
width: 100%;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.pl-footer-inner {
|
||||
padding: var(--space-4) 16px;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 420px) {
|
||||
.sw-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true,
|
||||
"isolatedModules": true,
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true,
|
||||
"declaration": true,
|
||||
"outDir": "dist",
|
||||
|
||||
Reference in new issue
Block a user