feat: 添加 codebuddy skills (image-tools, product-detail-designer, sku设计) 及商品实拍图样式优化

This commit is contained in:
张威33321
2026-04-03 18:33:36 +08:00
parent 6a486edde8
commit 9dc350ff58
19 changed files with 1226 additions and 1 deletions

View File

@@ -0,0 +1,71 @@
---
name: image-tools
description: 图片处理工具集用于检查图片信息、HTML转PNG、裁剪水印等操作。当用户需要处理产品图片、转换HTML为图片、或去除图片水印时使用此技能。
---
# Image Tools
## Overview
提供产品图片处理相关功能包括检查图片元信息、HTML页面截图、裁剪水印等操作。适用于产品文档和图片批量处理场景。
## Quick Start
使用前需安装依赖:
```bash
cd tools/image-tools/scripts
npm install
```
## Tasks
### 检查图片信息
查看图片的宽度、高度、格式等元信息:
```bash
cd tools/image-tools/scripts
node check-image-info.js
```
**用途**:批量检查产品图片尺寸,确保符合规格要求。
### HTML 转 PNG
将HTML文件转换为PNG图片截图
```bash
cd tools/image-tools/scripts
node convert-html-to-png.js
```
**用途**将产品配置清单HTML转换为PNG图片用于产品展示。
### 裁剪水印
裁剪图片底部水印区域默认裁剪底部300px
```bash
cd tools/image-tools/scripts
node remove-watermark.js
```
**用途**:批量处理产品图片,去除底部水印。
## Configuration
脚本默认处理路径为 `产品/飞牛 NAS/fyd-亚克力机箱 - 单/详情` 目录。如需修改:
- **check-image-info.js**: 修改 `imageDir` 变量
- **convert-html-to-png.js**: 修改 `detailDir` 变量及文件过滤条件
- **remove-watermark.js**: 修改 `imageDir``CROP_BOTTOM_HEIGHT` 常量
## Resources
### scripts/
- `check-image-info.js` - 图片信息检查脚本
- `convert-html-to-png.js` - HTML转PNG截图脚本
- `remove-watermark.js` - 水印裁剪脚本
- `package.json` - Node.js 依赖配置

View File

@@ -0,0 +1,27 @@
const sharp = require('sharp');
const path = require('path');
const fs = require('fs');
async function checkImageInfo() {
const imageDir = path.join(__dirname, '产品', '飞牛 NAS', 'fyd-亚克力机箱 - 单', '详情', 'image');
const imageFiles = fs.readdirSync(imageDir).filter(file => file.endsWith('.jpg'));
console.log('📸 图片信息检查\n');
for (const imageFile of imageFiles) {
const imagePath = path.join(imageDir, imageFile);
const metadata = await sharp(imagePath).metadata();
console.log(`${imageFile}:`);
console.log(` 宽度: ${metadata.width}px`);
console.log(` 高度: ${metadata.height}px`);
console.log(` 格式: ${metadata.format}`);
console.log('');
}
}
checkImageInfo().catch(error => {
console.error('💥 检查过程出错:', error);
process.exit(1);
});

View File

@@ -0,0 +1,58 @@
const puppeteer = require('puppeteer');
const path = require('path');
const fs = require('fs');
async function convertHtmlToPng() {
console.log('🚀 启动 HTML 转 PNG 转换工具...\n');
const browser = await puppeteer.launch({
headless: 'new',
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
const page = await browser.newPage();
await page.setViewport({ width: 1000, height: 1000 });
const detailDir = path.join(__dirname, '产品', '飞牛 NAS', 'fyd-亚克力机箱 - 单', '详情');
const htmlFiles = fs.readdirSync(detailDir)
.filter(file => file.endsWith('.html') && file.includes('亚克力机箱 - 单'));
console.log(`📁 找到 ${htmlFiles.length} 个 HTML 文件需要转换\n`);
for (const htmlFile of htmlFiles) {
try {
const htmlPath = path.join(detailDir, htmlFile);
const pngFile = htmlFile.replace('.html', '.png');
const pngPath = path.join(detailDir, pngFile);
console.log(`📄 正在转换: ${htmlFile}`);
const fileUrl = `file:///${htmlPath.replace(/\\/g, '/')}`;
await page.goto(fileUrl, {
waitUntil: 'networkidle0',
timeout: 10000
});
await page.screenshot({
path: pngPath,
fullPage: false,
type: 'png'
});
console.log(`✅ 已生成: ${pngFile}\n`);
} catch (error) {
console.error(`❌ 转换失败 ${htmlFile}: ${error.message}\n`);
}
}
await browser.close();
console.log('✨ 所有转换任务已完成!');
}
convertHtmlToPng().catch(error => {
console.error('💥 转换过程出错:', error);
process.exit(1);
});

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,20 @@
{
"name": "membank",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git@gitee.com:xiongmaojames/membank.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"puppeteer": "^24.40.0",
"sharp": "^0.34.5"
}
}

View File

@@ -0,0 +1,51 @@
const sharp = require('sharp');
const path = require('path');
const fs = require('fs');
const CROP_BOTTOM_HEIGHT = 300;
async function removeWatermark() {
console.log('🖼️ 开始裁剪图片水印...\n');
const imageDir = path.join(__dirname, '产品', '飞牛 NAS', 'fyd-亚克力机箱 - 单', '详情', 'image');
const backupDir = path.join(imageDir, 'backup');
const imageFiles = fs.readdirSync(backupDir).filter(file => file.endsWith('.jpg'));
console.log(`📸 找到 ${imageFiles.length} 张图片需要处理\n`);
console.log(`✂️ 裁剪设置: 从底部裁剪 ${CROP_BOTTOM_HEIGHT}px\n`);
for (const imageFile of imageFiles) {
try {
const backupPath = path.join(backupDir, imageFile);
const imagePath = path.join(imageDir, imageFile);
console.log(`📄 正在处理: ${imageFile}`);
const metadata = await sharp(backupPath).metadata();
const newHeight = metadata.height - CROP_BOTTOM_HEIGHT;
await sharp(backupPath)
.extract({
left: 0,
top: 0,
width: metadata.width,
height: newHeight
})
.toFile(imagePath);
console.log(` ✅ 已裁剪: ${metadata.width}x${metadata.height} -> ${metadata.width}x${newHeight}\n`);
} catch (error) {
console.error(` ❌ 处理失败 ${imageFile}: ${error.message}\n`);
}
}
console.log('✨ 所有图片处理完成!');
}
removeWatermark().catch(error => {
console.error('💥 处理过程出错:', error);
process.exit(1);
});

View File

@@ -0,0 +1,78 @@
---
name: product-detail-designer
description: 设计电商产品的详情页。当用户需要为产品生成详情页HTML、批量渲染SKU页面、或处理产品图片时使用此技能。
---
# Product Detail Designer
## 概述
根据产品的 SKU 和配置规范,生成对应的产品详情页 HTML并转换为 PNG 图片。自动化处理从配置数据到最终展示页面的完整流程。
## 使用场景
- 有产品种类或 SKU 变化,需要重新生成详情页
- 有产品图片变化,需要更新详情页
- 需要批量为多个 SKU 生成对应的详情页
## 工作流程
### 步骤 1: 读取 SKU 配置
`产品/{产品线}/{产品名}/sku/` 目录下的 markdown 文件读取产品配置。
文件格式示例:
```
亚克力-单-AMD-A4-2G-16G.md
```
### 步骤 2: 渲染 HTML 模板
使用 `scripts/render.js` 脚本,将 SKU 数据填充到 HTML 模板中:
```bash
cd .codebuddy/skills/product-detail-designer/scripts
node render.js <sku文件路径> [输出目录]
```
模板位置:`assets/templates/{产品类型}/`
可用模板变量:
- `{{PRODUCT_NAME}}` - 产品名称
- `{{SKU_CODE}}` - SKU 编码
- `{{CPU}}` / `{{MEMORY}}` / `{{STORAGE}}` - 核心配置
- `{{TOTAL_COST}}` / `{{RETAIL_PRICE}}` - 价格信息
- `{{NOTE}}` - 备注信息
### 步骤 3: HTML 转 PNG 图片
使用 `image-tools` 技能的 `convert-html-to-png.js` 脚本:
```bash
cd ../image-tools/scripts
node convert-html-to-png.js
```
### 步骤 4: 裁剪图片水印
使用 `image-tools` 技能的 `remove-watermark.js` 脚本:
```bash
node remove-watermark.js
```
## 资源说明
### scripts/
- `render.js` - HTML 模板渲染脚本,读取 SKU markdown 并生成对应的 HTML 文件
### assets/templates/
- `亚克力单/` - 亚克力单机箱详情页模板7个 HTML 模板)
- `亚克力双/` - (预留)
- 其他产品模板可按需添加
### references/
- `产品配置规范.md` - 产品设计原则、SKU 命名规则、页面设计规范

View File

@@ -0,0 +1,91 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=1000, height=1000">
<title>使用场景 - {{PRODUCT_NAME}}</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
width: 1000px;
height: 1000px;
font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
background: linear-gradient(135deg, #e0f2f1 0%, #b2dfdb 50%, #80cbc4 100%);
padding: 40px;
}
.container {
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.85);
border-radius: 20px;
padding: 50px;
box-shadow: 0 20px 60px rgba(0,0,0,0.1), inset 0 0 100px rgba(255,255,255,0.5);
backdrop-filter: blur(10px);
border: 2px solid rgba(255,255,255,0.6);
}
.title {
font-size: 56px;
font-weight: bold;
color: #00695c;
text-align: center;
margin-bottom: 40px;
}
.scenario-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 30px;
}
.scenario-item {
background: rgba(255, 255, 255, 0.9);
border-radius: 15px;
padding: 30px;
text-align: center;
box-shadow: 0 4px 15px rgba(0,0,0,0.08);
border: 1px solid rgba(38,166,154,0.3);
}
.scenario-icon {
font-size: 70px;
margin-bottom: 15px;
}
.scenario-title {
font-size: 28px;
color: #004d40;
font-weight: bold;
margin-bottom: 10px;
}
.scenario-desc {
font-size: 20px;
color: #00796b;
line-height: 1.5;
}
</style>
</head>
<body>
<div class="container">
<div class="title">使用场景</div>
<div class="scenario-grid">
<div class="scenario-item">
<div class="scenario-icon">🏠</div>
<div class="scenario-title">家庭数据中心</div>
<div class="scenario-desc">集中存储家庭照片、视频、文档,全家共享访问</div>
</div>
<div class="scenario-item">
<div class="scenario-icon">💼</div>
<div class="scenario-title">小型办公</div>
<div class="scenario-desc">团队文件共享,数据集中管理,提升工作效率</div>
</div>
<div class="scenario-item">
<div class="scenario-icon">🎬</div>
<div class="scenario-title">影音娱乐</div>
<div class="scenario-desc">搭建家庭影院,存储高清电影,随时观看</div>
</div>
<div class="scenario-item">
<div class="scenario-icon">📚</div>
<div class="scenario-title">学习资料库</div>
<div class="scenario-desc">存储学习资料、电子书籍,构建个人知识管理系统</div>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,107 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=1000, height=1000">
<title>功能描述 - {{PRODUCT_NAME}}</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
width: 1000px;
height: 1000px;
font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
background: linear-gradient(135deg, #e0f2f1 0%, #b2dfdb 50%, #80cbc4 100%);
padding: 40px;
}
.container {
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.85);
border-radius: 20px;
padding: 50px;
box-shadow: 0 20px 60px rgba(0,0,0,0.1), inset 0 0 100px rgba(255,255,255,0.5);
backdrop-filter: blur(10px);
border: 2px solid rgba(255,255,255,0.6);
}
.title {
font-size: 56px;
font-weight: bold;
color: #00695c;
text-align: center;
margin-bottom: 40px;
}
.function-list {
display: flex;
flex-direction: column;
gap: 25px;
}
.function-item {
background: rgba(255, 255, 255, 0.9);
border-radius: 15px;
padding: 25px 30px;
display: flex;
align-items: center;
gap: 25px;
box-shadow: 0 4px 15px rgba(0,0,0,0.08);
border: 1px solid rgba(38,166,154,0.3);
}
.function-icon {
font-size: 50px;
flex-shrink: 0;
}
.function-text h3 {
font-size: 28px;
color: #004d40;
margin-bottom: 8px;
}
.function-text p {
font-size: 20px;
color: #00796b;
line-height: 1.5;
}
</style>
</head>
<body>
<div class="container">
<div class="title">功能描述</div>
<div class="function-list">
<div class="function-item">
<div class="function-icon">💾</div>
<div class="function-text">
<h3>私有云存储</h3>
<p>搭建个人私有云,安全存储照片、视频、文档等重要资料</p>
</div>
</div>
<div class="function-item">
<div class="function-icon">🔄</div>
<div class="function-text">
<h3>数据备份</h3>
<p>自动备份手机、电脑数据,防止数据丢失,多重保护</p>
</div>
</div>
<div class="function-item">
<div class="function-icon">🌐</div>
<div class="function-text">
<h3>远程访问</h3>
<p>随时随地远程访问,在外也能查看家中文件资料</p>
</div>
</div>
<div class="function-item">
<div class="function-icon">👥</div>
<div class="function-text">
<h3>家庭共享</h3>
<p>家庭成员共享存储空间,照片视频轻松分享</p>
</div>
</div>
<div class="function-item">
<div class="function-icon">🤖</div>
<div class="function-text">
<h3>智能家居</h3>
<p>支持Home Assistant打造智能家居控制中心</p>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,101 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=1000, height=1000">
<title>包装展示 - {{PRODUCT_NAME}}</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
width: 1000px;
height: 1000px;
font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
background: linear-gradient(135deg, #e0f2f1 0%, #b2dfdb 50%, #80cbc4 100%);
padding: 40px;
}
.container {
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.85);
border-radius: 20px;
padding: 50px;
box-shadow: 0 20px 60px rgba(0,0,0,0.1), inset 0 0 100px rgba(255,255,255,0.5);
backdrop-filter: blur(10px);
border: 2px solid rgba(255,255,255,0.6);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.title {
font-size: 56px;
font-weight: bold;
color: #00695c;
margin-bottom: 40px;
}
.packaging-visual {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 30px;
width: 100%;
}
.package-item {
background: rgba(255, 255, 255, 0.9);
border-radius: 15px;
padding: 30px;
text-align: center;
box-shadow: 0 4px 15px rgba(0,0,0,0.08);
border: 1px solid rgba(38,166,154,0.3);
}
.package-icon {
font-size: 80px;
margin-bottom: 15px;
}
.package-name {
font-size: 24px;
color: #004d40;
font-weight: bold;
}
.footer-note {
margin-top: 40px;
font-size: 24px;
color: #00796b;
text-align: center;
}
</style>
</head>
<body>
<div class="container">
<div class="title">包装展示</div>
<div class="packaging-visual">
<div class="package-item">
<div class="package-icon">📦</div>
<div class="package-name">产品外箱</div>
</div>
<div class="package-item">
<div class="package-icon">💻</div>
<div class="package-name">主机</div>
</div>
<div class="package-item">
<div class="package-icon">🔌</div>
<div class="package-name">电源适配器</div>
</div>
<div class="package-item">
<div class="package-icon">🔗</div>
<div class="package-name">网线</div>
</div>
<div class="package-item">
<div class="package-icon">🔋</div>
<div class="package-name">电池</div>
</div>
<div class="package-item">
<div class="package-icon">📄</div>
<div class="package-name">说明书</div>
</div>
</div>
<div class="footer-note">整机包装,开箱即用</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,122 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=1000, height=1000">
<title>商品卖点 - {{PRODUCT_NAME}}</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
width: 1000px;
height: 1000px;
font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
background: linear-gradient(135deg, #e0f2f1 0%, #b2dfdb 50%, #80cbc4 100%);
padding: 40px;
}
.container {
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.85);
border-radius: 20px;
padding: 50px;
box-shadow: 0 20px 60px rgba(0,0,0,0.1), inset 0 0 100px rgba(255,255,255,0.5);
backdrop-filter: blur(10px);
border: 2px solid rgba(255,255,255,0.6);
}
.title {
font-size: 56px;
font-weight: bold;
color: #00695c;
text-align: center;
margin-bottom: 40px;
text-shadow: 0 2px 10px rgba(0,105,92,0.2);
}
.subtitle {
font-size: 28px;
color: #4db6ac;
text-align: center;
margin-bottom: 50px;
}
.points-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 30px;
}
.point-item {
background: rgba(255, 255, 255, 0.9);
border-radius: 15px;
padding: 30px;
display: flex;
align-items: center;
gap: 20px;
box-shadow: 0 4px 15px rgba(0,0,0,0.08);
border: 1px solid rgba(38,166,154,0.3);
}
.point-icon {
font-size: 60px;
flex-shrink: 0;
}
.point-content h3 {
font-size: 28px;
color: #004d40;
margin-bottom: 10px;
}
.point-content p {
font-size: 20px;
color: #00796b;
line-height: 1.5;
}
</style>
</head>
<body>
<div class="container">
<div class="title">商品卖点</div>
<div class="subtitle">{{PRODUCT_NAME}}</div>
<div class="points-grid">
<div class="point-item">
<div class="point-icon">💎</div>
<div class="point-content">
<h3>透明亚克力材质</h3>
<p>高透光亚克力,清晰展示内部结构,科技感十足</p>
</div>
</div>
<div class="point-item">
<div class="point-icon">🎨</div>
<div class="point-content">
<h3>时尚外观设计</h3>
<p>简约现代设计,透明机身,美观大方,适合各种环境</p>
</div>
</div>
<div class="point-item">
<div class="point-icon"></div>
<div class="point-content">
<h3>低功耗静音</h3>
<p>超低功耗设计无风扇静音运行7x24小时稳定</p>
</div>
</div>
<div class="point-item">
<div class="point-icon">🔧</div>
<div class="point-content">
<h3>易于维护</h3>
<p>透明设计便于观察,拆卸方便,升级维护简单</p>
</div>
</div>
<div class="point-item">
<div class="point-icon">🌡️</div>
<div class="point-content">
<h3>散热优良</h3>
<p>开放式设计,散热效果优异,保证系统稳定运行</p>
</div>
</div>
<div class="point-item">
<div class="point-icon">💰</div>
<div class="point-content">
<h3>超高性价比</h3>
<p>入门级NAS首选功能齐全价格亲民</p>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,96 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=1000, height=1000">
<title>配件清单 - {{PRODUCT_NAME}}</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
width: 1000px;
height: 1000px;
font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
background: linear-gradient(135deg, #e0f2f1 0%, #b2dfdb 50%, #80cbc4 100%);
padding: 40px;
}
.container {
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.85);
border-radius: 20px;
padding: 50px;
box-shadow: 0 20px 60px rgba(0,0,0,0.1), inset 0 0 100px rgba(255,255,255,0.5);
backdrop-filter: blur(10px);
border: 2px solid rgba(255,255,255,0.6);
}
.title {
font-size: 56px;
font-weight: bold;
color: #00695c;
text-align: center;
margin-bottom: 40px;
}
.accessories-list {
display: flex;
flex-direction: column;
gap: 20px;
}
.accessory-item {
background: rgba(255, 255, 255, 0.9);
border-radius: 12px;
padding: 20px 25px;
display: flex;
align-items: center;
gap: 20px;
box-shadow: 0 4px 15px rgba(0,0,0,0.08);
border: 1px solid rgba(38,166,154,0.3);
}
.accessory-icon {
font-size: 40px;
}
.accessory-name {
font-size: 26px;
color: #004d40;
font-weight: bold;
flex: 1;
}
.accessory-check {
font-size: 30px;
color: #26a69a;
}
</style>
</head>
<body>
<div class="container">
<div class="title">配件清单</div>
<div class="accessories-list">
<div class="accessory-item">
<div class="accessory-icon">📦</div>
<div class="accessory-name">主机 x1</div>
<div class="accessory-check"></div>
</div>
<div class="accessory-item">
<div class="accessory-icon">🔌</div>
<div class="accessory-name">电源适配器 x1</div>
<div class="accessory-check"></div>
</div>
<div class="accessory-item">
<div class="accessory-icon">🔗</div>
<div class="accessory-name">网线 x1</div>
<div class="accessory-check"></div>
</div>
<div class="accessory-item">
<div class="accessory-icon">🔋</div>
<div class="accessory-name">电池 x1</div>
<div class="accessory-check"></div>
</div>
<div class="accessory-item">
<div class="accessory-icon">📝</div>
<div class="accessory-name">说明书 x1</div>
<div class="accessory-check"></div>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,187 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=1000, height=1000">
<title>配置清单 (1/2) - {{PRODUCT_NAME}}</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
width: 1000px;
height: 1000px;
font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
background: linear-gradient(135deg, #e0f2f1 0%, #b2dfdb 50%, #80cbc4 100%);
padding: 40px;
}
.container {
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.85);
border-radius: 20px;
padding: 50px;
box-shadow: 0 20px 60px rgba(0,0,0,0.1), inset 0 0 100px rgba(255,255,255,0.5);
backdrop-filter: blur(10px);
border: 2px solid rgba(255,255,255,0.6);
}
.header {
text-align: center;
margin-bottom: 50px;
}
.title {
font-size: 56px;
font-weight: bold;
color: #00695c;
margin-bottom: 20px;
text-shadow: 0 2px 10px rgba(0,105,92,0.2);
}
.subtitle {
font-size: 28px;
color: #4db6ac;
margin-bottom: 10px;
}
.sku-badge {
display: inline-block;
background: #00695c;
color: white;
font-size: 22px;
padding: 8px 24px;
border-radius: 25px;
margin-top: 10px;
}
.config-section {
margin-bottom: 40px;
}
.section-title {
font-size: 32px;
font-weight: bold;
color: #00796b;
margin-bottom: 20px;
padding-left: 20px;
border-left: 5px solid #26a69a;
}
.config-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 20px;
}
.config-item {
background: rgba(255, 255, 255, 0.9);
padding: 20px 25px;
border-radius: 10px;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 4px 15px rgba(0,0,0,0.08);
border: 1px solid rgba(38,166,154,0.3);
}
.config-label {
font-size: 24px;
color: #004d40;
font-weight: bold;
}
.config-value {
font-size: 24px;
color: #26a69a;
font-weight: bold;
}
.config-item.highlight {
background: rgba(0,105,92,0.1);
border: 2px solid #26a69a;
}
.config-item.highlight .config-label,
.config-item.highlight .config-value {
color: #004d40;
}
.price-tag {
font-size: 36px;
color: #00695c;
font-weight: bold;
text-align: right;
margin-top: 30px;
}
.price-tag span {
font-size: 24px;
color: #00796b;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<div class="title">配置清单 (1/2)</div>
<div class="subtitle">{{PRODUCT_SUBTITLE}}</div>
<div class="sku-badge">{{SKU_CODE}}</div>
</div>
<div class="config-section">
<div class="section-title">机箱类型</div>
<div class="config-grid">
<div class="config-item">
<span class="config-label">亚克力-单</span>
<span class="config-value">单SATA口</span>
</div>
<div class="config-item">
<span class="config-label">亚克力-双</span>
<span class="config-value">双SATA口</span>
</div>
</div>
</div>
<div class="config-section">
<div class="section-title">处理器 (CPU)</div>
<div class="config-grid">
<div class="config-item">
<span class="config-label">Intel N2840</span>
<span class="config-value">双核 2.16GHz</span>
</div>
<div class="config-item">
<span class="config-label">Intel N2930</span>
<span class="config-value">四核 1.83GHz</span>
</div>
<div class="config-item">
<span class="config-label">AMD A4</span>
<span class="config-value">双核 2.0GHz</span>
</div>
<div class="config-item">
<span class="config-label">Intel 1037U</span>
<span class="config-value">双核 1.8GHz</span>
</div>
<div class="config-item">
<span class="config-label">Intel J1900</span>
<span class="config-value">四核 2.0GHz</span>
</div>
<div class="config-item">
<span class="config-label">Intel J3160</span>
<span class="config-value">四核 1.6GHz</span>
</div>
</div>
</div>
<div class="config-section">
<div class="section-title">已选配置</div>
<div class="config-grid">
<div class="config-item highlight">
<span class="config-label">CPU</span>
<span class="config-value">{{CPU}}</span>
</div>
<div class="config-item highlight">
<span class="config-label">内存</span>
<span class="config-value">{{MEMORY}}</span>
</div>
<div class="config-item highlight">
<span class="config-label">系统盘</span>
<span class="config-value">{{STORAGE}}</span>
</div>
<div class="config-item highlight">
<span class="config-label">机箱</span>
<span class="config-value">{{CASE}}</span>
</div>
</div>
</div>
<div class="price-tag">
成本合计:<span>¥</span>{{TOTAL_COST}}
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,154 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=1000, height=1000">
<title>配置清单 (2/2) - {{PRODUCT_NAME}}</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
width: 1000px;
height: 1000px;
font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
background: linear-gradient(135deg, #e0f2f1 0%, #b2dfdb 50%, #80cbc4 100%);
padding: 40px;
}
.container {
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.85);
border-radius: 20px;
padding: 50px;
box-shadow: 0 20px 60px rgba(0,0,0,0.1), inset 0 0 100px rgba(255,255,255,0.5);
backdrop-filter: blur(10px);
border: 2px solid rgba(255,255,255,0.6);
}
.header {
text-align: center;
margin-bottom: 50px;
}
.title {
font-size: 56px;
font-weight: bold;
color: #00695c;
margin-bottom: 20px;
}
.subtitle {
font-size: 28px;
color: #4db6ac;
}
.section-title {
font-size: 32px;
font-weight: bold;
color: #00796b;
margin-bottom: 20px;
padding-left: 20px;
border-left: 5px solid #26a69a;
}
.config-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 20px;
}
.config-item {
background: rgba(255, 255, 255, 0.9);
padding: 20px 25px;
border-radius: 10px;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 4px 15px rgba(0,0,0,0.08);
border: 1px solid rgba(38,166,154,0.3);
}
.config-label {
font-size: 24px;
color: #004d40;
font-weight: bold;
}
.config-value {
font-size: 24px;
color: #26a69a;
font-weight: bold;
}
.summary {
background: linear-gradient(135deg, #00695c, #004d40);
border-radius: 15px;
padding: 40px;
margin-top: 40px;
text-align: center;
color: white;
}
.summary-title {
font-size: 28px;
margin-bottom: 20px;
}
.summary-price {
font-size: 64px;
font-weight: bold;
}
.summary-note {
font-size: 20px;
margin-top: 10px;
opacity: 0.8;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<div class="title">配置清单 (2/2)</div>
<div class="subtitle">{{SKU_CODE}}</div>
</div>
<div class="config-section">
<div class="section-title">随机配件</div>
<div class="config-grid">
<div class="config-item">
<span class="config-label">电源</span>
<span class="config-value">{{POWER}}</span>
</div>
<div class="config-item">
<span class="config-label">硬盘线</span>
<span class="config-value">{{CABLE}}</span>
</div>
<div class="config-item">
<span class="config-label">电池</span>
<span class="config-value">{{BATTERY}}</span>
</div>
<div class="config-item">
<span class="config-label">网线</span>
<span class="config-value">{{ETHERNET_CABLE}}</span>
</div>
</div>
</div>
<div class="config-section">
<div class="section-title">费用明细</div>
<div class="config-grid">
<div class="config-item">
<span class="config-label">运费</span>
<span class="config-value">¥{{SHIPPING_FEE}}</span>
</div>
<div class="config-item">
<span class="config-label">包装费</span>
<span class="config-value">¥{{PACKAGING_FEE}}</span>
</div>
<div class="config-item">
<span class="config-label">装机费</span>
<span class="config-value">¥{{ASSEMBLY_FEE}}</span>
</div>
<div class="config-item">
<span class="config-label">总成本</span>
<span class="config-value">¥{{TOTAL_COST}}</span>
</div>
</div>
</div>
<div class="summary">
<div class="summary-title">建议零售价</div>
<div class="summary-price">¥{{RETAIL_PRICE}}</div>
<div class="summary-note">{{NOTE}}</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,59 @@
# 产品配置规范参考
## 亚克力机箱配置原则
- 亚克力机箱-单可安装所有单SATA口主板
- 亚克力机箱-双可安装所有双SATA口主板
- 内存规格2G-16G, 2G-32G, 4G-64G, 4G-128G
- 支持 CPUN2840, N2930, AMD-A4, 1037U, J1900, J3160, i3
## SKU 命名规则
格式:`亚克力-单-{CPU}-{内存}-{系统盘}`
示例:`亚克力-单-AMD-A4-2G-16G`
## SKU Markdown 文件格式
```markdown
# 产品信息
| 字段 | 配件名称 | 价格 |
:|------|---------|------:|
| **产品编号** | - | - |
| **产品名称** | 飞牛NAS 亚克力-单 AMD-A4 | - |
| **产品型号** | 亚克力-单-AMD-A4-2G-16G | - |
| **CPU** | AMD-A4 | ¥45 |
| **内存** | D3-2G | ¥13 |
| **系统盘** | mSATA-16G | ¥15 |
| **机箱** | 亚-单 | ¥42 |
| **电源** | 电源-60W | ¥12 |
| **硬盘线** | 硬盘线-单 | ¥4 |
| **电池** | 电池 | ¥1 |
| **网线** | 网线 | ¥1 |
| **运费** | 运费 | ¥10 |
| **包装费** | 包装费 | ¥5 |
| **装机费** | 装机费 | ¥10 |
| **总成本** | - | ¥158 |
| **建议零售价** | - | ¥205 |
| **备注** | 亚克力机箱单SATA口入门级配置 | - |
```
## 详情页组成部分
1. **配置清单-1.html** - 机箱类型、CPU 选项、已选配置
2. **配置清单-2.html** - 随机配件、费用明细、建议零售价
3. **商品卖点.html** - 产品核心卖点
4. **功能描述.html** - 功能列表
5. **使用场景.html** - 应用场景展示
6. **配件清单.html** - 随机配件列表
7. **包装展示.html** - 包装内容展示
## 页面设计规范
- 尺寸1000x1000px
- 背景:青绿色渐变 `#e0f2f1 → #b2dfdb → #80cbc4`
- 圆角卡片20px
- 主色调:#00695c (深青色)
- 强调色:#26a69a (青绿色)
- 字体Microsoft YaHei / PingFang SC

View File

@@ -0,0 +1,132 @@
const fs = require('fs');
const path = require('path');
// SKU 字段映射表
const FIELD_MAP = {
'{{PRODUCT_NAME}}': 'productName',
'{{PRODUCT_SUBTITLE}}': 'productSubtitle',
'{{SKU_CODE}}': 'skuCode',
'{{CPU}}': 'cpu',
'{{MEMORY}}': 'memory',
'{{STORAGE}}': 'storage',
'{{CASE}}': 'case',
'{{POWER}}': 'power',
'{{CABLE}}': 'cable',
'{{BATTERY}}': 'battery',
'{{ETHERNET_CABLE}}': 'ethernetCable',
'{{SHIPPING_FEE}}': 'shippingFee',
'{{PACKAGING_FEE}}': 'packagingFee',
'{{ASSEMBLY_FEE}}': 'assemblyFee',
'{{TOTAL_COST}}': 'totalCost',
'{{RETAIL_PRICE}}': 'retailPrice',
'{{NOTE}}': 'note'
};
// 从 SKU markdown 文件解析字段
function parseSkuFile(skuPath) {
const content = fs.readFileSync(skuPath, 'utf-8');
const data = {};
content.split('\n').forEach(line => {
const match = line.match(/:\s*\|\s*(.+?)\s*\|\s*(.+?)\s*\|/);
if (match) {
const [, fieldName, value] = match;
data[fieldName.trim()] = value.trim();
}
});
return data;
}
// 将 SKU 数据映射为模板变量
function mapSkuToVariables(skuData) {
const cpu = skuData['CPU'] || '';
const memory = skuData['内存'] || '';
const storage = skuData['系统盘'] || '';
const caseType = skuData['机箱'] || '';
return {
'{{PRODUCT_NAME}}': `飞牛NAS ${caseType}`,
'{{PRODUCT_SUBTITLE}}': '亚克力机箱 透明系列',
'{{SKU_CODE}}': skuData['产品型号'] || '',
'{{CPU}}': cpu,
'{{MEMORY}}': memory,
'{{STORAGE}}': storage,
'{{CASE}}': caseType,
'{{POWER}}': skuData['电源'] || '电源-60W',
'{{CABLE}}': skuData['硬盘线'] || '硬盘线-单',
'{{BATTERY}}': skuData['电池'] || '电池',
'{{ETHERNET_CABLE}}': skuData['网线'] || '网线',
'{{SHIPPING_FEE}}': skuData['运费']?.replace('¥', '') || '10',
'{{PACKAGING_FEE}}': skuData['包装费']?.replace('¥', '') || '5',
'{{ASSEMBLY_FEE}}': skuData['装机费']?.replace('¥', '') || '10',
'{{TOTAL_COST}}': skuData['总成本']?.replace('¥', '') || '0',
'{{RETAIL_PRICE}}': skuData['建议零售价']?.replace('¥', '') || '0',
'{{NOTE}}': skuData['备注'] || ''
};
}
// 渲染 HTML 模板
function renderTemplate(templatePath, variables) {
let html = fs.readFileSync(templatePath, 'utf-8');
Object.entries(variables).forEach(([placeholder, value]) => {
html = html.split(placeholder).join(value);
});
return html;
}
// 主函数:生成亚克力单详情页
function generateDetailPages(skuFilePath, outputDir) {
const skuData = parseSkuFile(skuFilePath);
const variables = mapSkuToVariables(skuData);
const skuCode = variables['{{SKU_CODE}}'];
const productType = '亚克力单';
const templateDir = path.join(__dirname, '..', 'assets', 'templates', productType);
// 创建输出目录
const productOutputDir = path.join(outputDir, skuCode);
if (!fs.existsSync(productOutputDir)) {
fs.mkdirSync(productOutputDir, { recursive: true });
}
// 模板列表
const templates = [
'配置清单-1.html',
'配置清单-2.html',
'商品卖点.html',
'功能描述.html',
'使用场景.html',
'配件清单.html',
'包装展示.html'
];
templates.forEach(template => {
const templatePath = path.join(templateDir, template);
if (!fs.existsSync(templatePath)) {
console.log(`跳过(模板不存在): ${template}`);
return;
}
const html = renderTemplate(templatePath, variables);
const outputPath = path.join(productOutputDir, template);
fs.writeFileSync(outputPath, html, 'utf-8');
console.log(`已生成: ${outputPath}`);
});
console.log(`\n完成!共生成 ${templates.length} 个 HTML 文件到: ${productOutputDir}`);
}
// 使用示例
const skuFile = process.argv[2];
const outputDir = process.argv[3] || path.join(__dirname, '..', '..', '..', '产品', '飞牛 NAS', 'fyd-亚克力机箱 - 单', '详情');
if (!skuFile) {
console.log('用法: node render.js <sku文件路径> [输出目录]');
console.log('示例: node render.js ../产品/飞牛NAS/fyd-亚克力机箱 - 单/sku/亚克力-单-AMD-A4-2G-16G.md');
process.exit(1);
}
generateDetailPages(skuFile, outputDir);

View File

@@ -0,0 +1,26 @@
---
name: sku设计
description: This skill should be used when the user asks to design or plan a SKU (Stock Keeping Unit) for a product. It provides structured guidance for creating SKU codes, organizing product variants, and documenting product configurations. Trigger scenarios include: "设计一个SKU"、"规划产品SKU"、"SKU配置"等。
---
# SKU 设计
## Overview
[TODO: 描述此技能的作用和使用场景]
## SKU 编码规则
[TODO: 定义 SKU 编码的命名规范和结构]
## 产品配置模板
[TODO: 定义不同产品类型的配置模板]
## 设计流程
[TODO: 描述 SKU 设计的标准流程]
## 参考资源
[TODO: 如有参考文档,在此引用]