feat(image-tools): 文字模板升级为成套文案(17套主副标题整组插入)

- TextTpl 增加 parts 多行文案:17套模板全部换成封面模板库真实标题组
  (B站史上/点击最高的10首MV、辣到没朋友!川菜/辣子鸡·水煮肉片、
  秀翻全场!/ALL KILL!、合法打工人/SLAVE の一天 DAILY 等 1~3 行)
- applyTpl:未选中层→整组插入(逐行独立居中、主大副小比例递减、
  总高适配画布);已选中层→仅换样式保留内容/位置/旋转
- 级联排版:连点插入新组自动排到已有文字底边之下,空间不足自动
  缩字号塞入,绝不叠压(修:原实现第三组回居中与第一组重叠)
- 插入后不选中→连续点击=连续插入多组;点中某行再点模板=换该行样式
- chip 小样显示真实文案(两行 clamp 截断),title 含全套内容
- 实测:17款小样真实文案;连点3套→3条独立历史+导出分带检测
  黑底组y210-300/红底中部/科普上部 无重叠;导出黄3975px青2592px
- 文案/CHANGELOG 同步(14款→17套成套文案)
This commit is contained in:
personal82555 committed 2026-10-21 23:34:19 +08:00
1 parent e65eb89fa9
commit c54799fd89
5 files changed
+106 -38

No files matched your search

+6
View File
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. See [standa
## Version 2026.10.16-it-tools-pro
### ✨ 文字模板升级为成套文案(17套,主副标题整组插入)
- 每套模板不再是单个占位词,而是**完整标题组**(取自封面模板库真实文案):主标题+副标题 1~3 行成组——如「B站史上/点击最高的10首MV」「辣到没朋友!川菜/辣子鸡 · 水煮肉片」「秀翻全场!/ALL KILL!」「合法打工人/SLAVE の一天 DAILY」等 17 套
- 点击一次插入整组:逐行独立居中、主大副小按比例递减、总高自动适配画布;**连续点击插入多组时自动级联排到已有文字下方**,空间不足自动缩字号塞入,绝不互相叠压
- 模板小样直接显示真实文案(两行截断预览),hover 标题含全套内容
- 交互定稿:点击=插入新组;**点中某行文字后再点模板=仅换该行样式**(保留内容/位置/旋转)
### ✨ 文字旋转 + 14 款花字模板(点击即套用)
- **画布直旋**:选中文字后拖顶部蓝色圆点手柄实时旋转(拖动即所见),松手进历史(「旋转文字 N°」);按住 Shift 吸附 15°;旋转以文字框中心为锚点,命中检测同步旋转(斜着也能点中)
- **旋转滑条**:属性面板「旋转」-180°~180° 精调 + 数字输入 + 一键回正
+1 -1
View File
@@ -310,7 +310,7 @@ tools:
image-tools:
title: Image tools
description: "In-browser image toolbox: compress, convert, resize, crop, rotate, filters, mosaic/redaction, Photoshop-style editor (layers, brush, text, selection, OCR text replacement, 14 artistic text templates with canvas rotation, content-aware erase with live preview), EXIF viewer, QR generate/scan, watermark and stitching. Images never leave your device."
description: "In-browser image toolbox: compress, convert, resize, crop, rotate, filters, mosaic/redaction, Photoshop-style editor (layers, brush, text, selection, OCR text replacement, 17 full-copy artistic text templates with canvas rotation, content-aware erase with live preview), EXIF viewer, QR generate/scan, watermark and stitching. Images never leave your device."
pdf-tools:
title: PDF tools
+1 -1
View File
@@ -307,7 +307,7 @@ tools:
image-tools:
title: 图片工具
description: 浏览器本地处理的图片工具箱:图片压缩、格式转换、调整尺寸、裁剪、旋转、滤镜、打码、PS 风格图片编辑(图层/画笔/文字/选区/OCR 改字/14款花字模板+画布旋转/智能消除笔实时预览无痕去文字水印)、EXIF 查看、二维码生成/识别、加水印、多图拼接,图片全程不上传。
description: 浏览器本地处理的图片工具箱:图片压缩、格式转换、调整尺寸、裁剪、旋转、滤镜、打码、PS 风格图片编辑(图层/画笔/文字/选区/OCR 改字/17套成套文案花字模板+画布旋转/智能消除笔实时预览无痕去文字水印)、EXIF 查看、二维码生成/识别、加水印、多图拼接,图片全程不上传。
pdf-tools:
title: PDF工具
+97 -35
View File
@@ -25,27 +25,31 @@ interface TextLayer {
badge?: string | null; // 色块底(红底白字类)
}
// ---------- 文字花字模板(点击即套用,之后可继续调内容/字号/位置/旋转) ----------
// ---------- 文字花字模板(成套文案:点击一次插入整组标题+副标题,源自封面模板库文案) ----------
interface TextTpl {
id: string; name: string; color: string;
parts: string[]; // 主标题 → 副标题 → 小字,逐行成组插入
grad?: [string, string]; bold?: boolean;
stroke?: string; strokeW?: number; shadow?: string; badge?: string;
}
const TEXT_TPLS: TextTpl[] = [
{ id: 'wp', name: '白字黑描边', color: '#ffffff', stroke: '#1a1a1a', strokeW: 0.10, bold: true },
{ id: 'yp', name: '黄字紫描边', color: '#ffe14d', stroke: '#7b2cbf', strokeW: 0.10, bold: true },
{ id: 'wpu', name: '白字紫描边', color: '#ffffff', stroke: '#8e44ad', strokeW: 0.09, bold: true },
{ id: 'yc', name: '黄字青描边', color: '#ffeb3b', stroke: '#00e5ff', strokeW: 0.11, bold: true },
{ id: 'rb', name: '红底白字', color: '#ffffff', badge: '#e53935', bold: true },
{ id: 'bb', name: '蓝底白字', color: '#ffffff', badge: '#1e88e5', bold: true },
{ id: 'kb', name: '黑底黄字', color: '#ffd600', badge: '#212121', bold: true },
{ id: 'gd', name: '鎏金渐变', color: '#ffcc00', grad: ['#fff3b0', '#ff9500'], stroke: '#7a4a00', strokeW: 0.07, bold: true },
{ id: 'fg', name: '烈焰渐变', color: '#ff4d4f', grad: ['#ff5252', '#ff8f00'], stroke: '#7a1f00', strokeW: 0.08, bold: true },
{ id: 'ws', name: '白字投影', color: '#ffffff', shadow: 'rgba(0,0,0,0.75)', bold: true },
{ id: 'cb', name: '青字黑描边', color: '#18ffff', stroke: '#00364d', strokeW: 0.10, bold: true },
{ id: 'pb', name: '粉底白字', color: '#ffffff', badge: '#ec407a', bold: true },
{ id: 'ol', name: '空心描边', color: 'rgba(255,255,255,0.06)', stroke: '#2962ff', strokeW: 0.10, bold: true },
{ id: 'gb', name: '荧光绿描边', color: '#76ff03', stroke: '#1b3d00', strokeW: 0.09, bold: true },
{ id: 'wp', name: '白字黑描边·搞怪', color: '#ffffff', stroke: '#1a1a1a', strokeW: 0.10, bold: true, parts: ['最强拉轰!', '《躲汉子》'] },
{ id: 'yp', name: '黄字紫描边·热榜', color: '#ffe14d', stroke: '#7b2cbf', strokeW: 0.10, bold: true, parts: ['B站史上', '点击最高的10首MV'] },
{ id: 'wpu', name: '白字紫描边·科普', color: '#ffffff', stroke: '#8e44ad', strokeW: 0.09, bold: true, parts: ['熬夜', '如何科学修仙'] },
{ id: 'yc', name: '黄字青描边·美食', color: '#ffeb3b', stroke: '#00e5ff', strokeW: 0.11, bold: true, parts: ['辣到没朋友!川菜', '辣子鸡 · 水煮肉片'] },
{ id: 'rb', name: '红底白字·冠军', color: '#ffffff', badge: '#e53935', bold: true, parts: ['收视冠军?'] },
{ id: 'bb', name: '蓝底白字·力作', color: '#ffffff', badge: '#1e88e5', bold: true, parts: ['翻身力作?'] },
{ id: 'kb', name: '黑底黄字·高光', color: '#ffd600', badge: '#212121', bold: true, parts: ['秀翻全场!', 'ALL KILL!'] },
{ id: 'gd', name: '鎏金渐变·打卡', color: '#ffcc00', grad: ['#fff3b0', '#ff9500'], stroke: '#7a4a00', strokeW: 0.07, bold: true, parts: ['香浓拿铁', '网红打卡'] },
{ id: 'fg', name: '烈焰渐变·社会', color: '#ff4d4f', grad: ['#ff5252', '#ff8f00'], stroke: '#7a1f00', strokeW: 0.08, bold: true, parts: ['男子医院体验', '竟查出有孕在身'] },
{ id: 'ws', name: '白字投影·Vlog', color: '#ffffff', shadow: 'rgba(0,0,0,0.75)', bold: true, parts: ['Vlog', '我的旅行日记'] },
{ id: 'cb', name: '青字黑描边·热梗', color: '#18ffff', stroke: '#00364d', strokeW: 0.10, bold: true, parts: ['年轻人', '耗子尾汁'] },
{ id: 'pb', name: '粉底白字·生活', color: '#ffffff', badge: '#ec407a', bold: true, parts: ['我的', '上海日租生活'] },
{ id: 'ol', name: '空心描边·搞笑', color: 'rgba(255,255,255,0.06)', stroke: '#2962ff', strokeW: 0.10, bold: true, parts: ['你根本', '不会上厕所'] },
{ id: 'gb', name: '荧光绿描边·攻略', color: '#76ff03', stroke: '#1b3d00', strokeW: 0.09, bold: true, parts: ['角色养成攻略', '躺平吧 赶紧的'] },
{ id: 'wp2', name: '白字蓝边·职场', color: '#ffffff', stroke: '#0d47a1', strokeW: 0.10, bold: true, parts: ['合法打工人', 'SLAVE の一天 DAILY'] },
{ id: 'gd2', name: '金渐变·B站', color: '#ffe082', grad: ['#fffde7', '#ffb300'], stroke: '#5d4037', strokeW: 0.07, bold: true, parts: ['B站', '崛起的十二年'] },
{ id: 'rb2', name: '红底白字·毕业', color: '#ffffff', badge: '#c62828', bold: true, parts: ['毕业后找工作', '如此简单!'] },
];
interface FillLayer {
id: string; type: 'fill'; name: string; visible: boolean; opacity: number;
@@ -113,7 +117,10 @@ const statusHint = computed(() => {
if (tool.value === 'text') {
return activeLayer.value?.type === 'text'
? '拖动文字可移动;拖顶部蓝点旋转(Shift 吸附15°);右侧模板一键换花字'
: '点击画布放置文字,或右侧直接点模板插入;拖顶部蓝点可旋转';
: '右侧模板点击即插入整组文案(可连点多组);点中某行文字后再点模板=只换样式';
}
if (tool.value === 'move' && !activeLayer.value) {
return '点右侧✨文字模板插入整组标题文案;点中文字可拖动/旋转/改内容';
}
if (tool.value === 'fill') {
return '点击图片相近颜色区域填充(容差 ' + tolerance.value + ')';
@@ -704,31 +711,75 @@ function applyTpl(t: TextTpl): void {
const al = activeLayer.value;
if (al && al.type === 'text') {
Object.assign(al, style);
commitProps(); // 实时生效并进历史
commitProps(); // 实时生效并进历史(保留用户已输入内容)
return;
}
const content = newText.value.trim() || '新文字';
const tl: TextLayer = {
id: uid(), type: 'text', name: `文字「${content.slice(0, 8)}」`,
visible: true, opacity: 100, text: content,
x: 0, y: 0, size: fontSize.value, rot: 0, ...style,
};
layers.value.push(tl);
activeLayerId.value = tl.id;
const m = textMetrics(tl);
tl.x = Math.round((docW.value - m.w) / 2);
tl.y = Math.round(Math.max(8, docH.value * 0.1));
if (tool.value !== 'text' && tool.value !== 'move') {
tool.value = 'move'; // 插入后直接可拖动/旋转
// 未选中文字层 → 按模板成套插入整组文案(主标题大、副标题依次递减,整体居中)
const ratios = [1, 0.62, 0.5, 0.42];
const base = fontSize.value;
let sizes = t.parts.map((_, i) => Math.max(10, Math.round(base * (ratios[Math.min(i, ratios.length - 1)]))));
const gap = Math.round(base * 0.18);
const totalOf = (ss: number[]) => ss.reduce((s, sz) => s + Math.round(sz * 1.3), 0) + gap * (t.parts.length - 1);
const avail = docH.value * 0.76;
let totalH = totalOf(sizes);
if (totalH > avail) {
const k = avail / totalH;
sizes = sizes.map(sz => Math.max(9, Math.round(sz * k)));
totalH = totalOf(sizes);
}
commit(`套用模板「${t.name}」`);
// 级联:新组放在已有文字层底边之下;空间不足则自动缩字号塞入(绝不叠到已有组上)
let maxY = 0;
for (const l of layers.value) {
if (l.type === 'text') {
maxY = Math.max(maxY, l.y + textMetrics(l).h);
}
}
const cascade = maxY > 0 ? maxY + gap : -1;
let y: number;
if (cascade > 0) {
const space = docH.value * 0.96 - cascade;
if (space < 26) {
y = Math.max(8, Math.round((docH.value - totalH) / 2.4)); // 极端无空间才回居中
}
else {
if (totalH > space) {
const k = space / totalH;
sizes = sizes.map(sz => Math.max(9, Math.round(sz * k)));
totalH = totalOf(sizes);
}
y = Math.round(Math.min(cascade, docH.value * 0.96 - totalH));
}
}
else {
y = Math.max(8, Math.round((docH.value - totalH) / 2.4));
}
let firstId = '';
t.parts.forEach((text, i) => {
const tl: TextLayer = {
id: uid(), type: 'text', name: `文字「${text.slice(0, 8)}」`,
visible: true, opacity: 100, text,
x: 0, y, size: sizes[i], rot: 0, ...style,
};
layers.value.push(tl);
const m = textMetrics(tl);
tl.x = Math.round((docW.value - m.w) / 2); // 每行独立居中
if (!firstId) {
firstId = tl.id;
}
y += Math.round(sizes[i] * 1.3) + gap;
});
activeLayerId.value = ''; // 不选中:可连续点模板插入多组;点中文字行后再点模板=换该行样式
if (tool.value !== 'text' && tool.value !== 'move') {
tool.value = 'move';
}
commit(`套用模板「${t.name}」(${t.parts.length}行)`);
composite();
scheduleRender();
}
// 模板 chip 的 CSS 预览样式
function tplStyle(t: TextTpl): Record<string, string> {
const s: Record<string, string> = { fontWeight: '700', fontSize: '15px', lineHeight: '1.15' };
const s: Record<string, string> = { fontWeight: '700' };
if (t.badge) {
s.background = t.badge;
s.color = t.color;
@@ -1933,10 +1984,10 @@ onBeforeUnmount(() => {
v-for="t in TEXT_TPLS"
:key="t.id"
class="psx-tpl"
:title="`${t.name} — ${activeLayer?.type === 'text' ? '应用到当前文字' : '插入并应用'}`"
:title="`${t.name}:${t.parts.join(' / ')} — ${activeLayer?.type === 'text' ? '应用样式到当前文字' : '插入整组文案'}`"
@click="applyTpl(t)"
>
<span :style="tplStyle(t)">文字</span>
<span class="psx-tpl-txt" :style="tplStyle(t)">{{ t.parts[0] }}</span>
</button>
</div>
</div>
@@ -2197,8 +2248,19 @@ onBeforeUnmount(() => {
gap: 6px;
}
&-tpl-txt {
font-size: 11.5px;
line-height: 1.12;
text-align: center;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
word-break: break-all;
}
&-tpl {
height: 40px;
height: 46px;
border: 1px solid rgba(128, 128, 128, 0.3);
border-radius: 7px;
background: rgba(128, 128, 128, 0.07);
+1 -1
View File
@@ -23,7 +23,7 @@ const TABS: TabDef[] = [
{ key: 'rotate', label: '旋转', desc: '旋转或翻转图片' },
{ key: 'filter', label: '滤镜', desc: '为图片应用滤镜效果(灰度/复古/模糊等)' },
{ key: 'mosaic', label: '打码', desc: '在图片上拖拽框选区域,马赛克或涂黑打码' },
{ key: 'edit', label: '图片编辑', desc: 'PS 风格图层编辑器:画笔/智能消除笔/文字/选区/油漆桶/吸管/裁剪,文字支持画布拖拽旋转+14款花字模板点击套用,消除实时预览,OCR 一键替换/消除图中文字' },
{ key: 'edit', label: '图片编辑', desc: 'PS 风格图层编辑器:画笔/智能消除笔/文字/选区/油漆桶/吸管/裁剪,文字支持画布拖拽旋转+17套成套标题文案模板点击即插(主副标题整组),消除实时预览,OCR 一键替换/消除图中文字' },
{ key: 'exif', label: 'EXIF 查看', desc: '查看拍摄设备、时间、参数等 EXIF 信息' },
{ key: 'qrgen', label: '二维码生成', desc: '把文字/链接生成为二维码图片', noFile: true },
{ key: 'qrread', label: '二维码识别', desc: '识别图片中的二维码/条码内容' },