diff --git a/CHANGELOG.md b/CHANGELOG.md index e52a09b..287b3c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 +### ✨ 上传前模板墙:未选图就能看到全部模板 +- 图片编辑 tab **未上传图片时,上传区直接平铺 17 套文字模板预览墙**(真实文案小样+花字样式),不再是空白上传框 +- 点任意模板 → 直接弹出选图 → 选完图片**该模板整组文案自动套入画布**(无需再回编辑器找模板) +- 底部一行"点这里选择图片"随时可直接上传(不套模板);模板墙几何验收首屏 17/17 全露出、无需滚动 +- 模板定义抽为共享模块 text-tpls.ts(画布内侧栏模板区与上传前模板墙共用一套数据) + ### ✨ 文字模板升级为成套文案(17套,主副标题整组插入) - 每套模板不再是单个占位词,而是**完整标题组**(取自封面模板库真实文案):主标题+副标题 1~3 行成组——如「B站史上/点击最高的10首MV」「辣到没朋友!川菜/辣子鸡 · 水煮肉片」「秀翻全场!/ALL KILL!」「合法打工人/SLAVE の一天 DAILY」等 17 套 - 点击一次插入整组:逐行独立居中、主大副小按比例递减、总高自动适配画布;**连续点击插入多组时自动级联排到已有文字下方**,空间不足自动缩字号塞入,绝不互相叠压 diff --git a/src/tools/image-tools/PsEditor.vue b/src/tools/image-tools/PsEditor.vue index dd7b310..065c08b 100644 --- a/src/tools/image-tools/PsEditor.vue +++ b/src/tools/image-tools/PsEditor.vue @@ -3,9 +3,11 @@ // 图层类型:image(底图) / paint(画笔涂改层) / text(文字层) / fill(色块擦除层) import { useStorage } from '@vueuse/core'; import { licenseHeaders } from '@/tools/license/license'; +import { TEXT_TPLS, tplStyle, type TextTpl } from './text-tpls'; -const props = defineProps<{ file: File }>(); -const emit = defineEmits<{ (e: 'error', msg: string): void }>(); +const props = defineProps<{ file: File; autoTpl?: TextTpl | null }>(); +const emit = defineEmits<{ (e: 'error', msg: string): void; (e: 'applied'): void }>(); +let autoTplConsumed = false; // 上传前模板墙套用一次性标记 // ---------- 文档状态 ---------- const docW = ref(0); @@ -25,32 +27,7 @@ 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, 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; x: number; y: number; w: number; h: number; color: string; @@ -777,35 +754,7 @@ function applyTpl(t: TextTpl): void { scheduleRender(); } -// 模板 chip 的 CSS 预览样式 -function tplStyle(t: TextTpl): Record { - const s: Record = { fontWeight: '700' }; - if (t.badge) { - s.background = t.badge; - s.color = t.color; - s.padding = '4px 7px'; - s.borderRadius = '5px'; - } - else if (t.grad) { - s.backgroundImage = `linear-gradient(90deg, ${t.grad[0]}, ${t.grad[1]})`; - s.backgroundClip = 'text'; - s.WebkitBackgroundClip = 'text'; - s.color = 'transparent'; - if (t.stroke) { - s.WebkitTextStroke = `1px ${t.stroke}`; - } - } - else { - s.color = t.color; - if (t.stroke) { - s.WebkitTextStroke = `${Math.max(1, Math.round((t.strokeW ?? 0.08) * 16))}px ${t.stroke}`; - } - } - if (t.shadow) { - s.textShadow = `2px 2px 3px ${t.shadow}`; - } - return s; -} + function removeLayer(id: string): void { const i = layers.value.findIndex(l => l.id === id); @@ -1853,6 +1802,12 @@ async function init(): Promise { hist.value = []; hIdx.value = -1; commit('打开图片'); + // 上传前模板墙选中的模板:图片就绪后立即套入画布(实时可见) + if (props.autoTpl && !autoTplConsumed) { + autoTplConsumed = true; // 只套一次 + applyTpl(props.autoTpl); + emit('applied'); + } } watch(() => props.file, () => { diff --git a/src/tools/image-tools/image-tools.vue b/src/tools/image-tools/image-tools.vue index 3fc08d7..91fdfbb 100644 --- a/src/tools/image-tools/image-tools.vue +++ b/src/tools/image-tools/image-tools.vue @@ -9,6 +9,7 @@ import GenHistory from '@/tools/gen-history/GenHistory.vue'; import { useGenHistory } from '@/tools/gen-history/gen-history'; import { getMachineId, licenseHeaders } from '@/tools/license/license'; import PsEditor from './PsEditor.vue'; +import { TEXT_TPLS, tplStyle, type TextTpl } from './text-tpls'; prepareZXingModule({ overrideWasmUrl: wasmUrl }); const genHist = useGenHistory('image-tools'); @@ -278,6 +279,13 @@ function mosaicPos(e: MouseEvent) { // ---------- 图片编辑(PS 风格编辑器,组件内自带工具栏/图层/历史) ---------- const psEditor = ref<{ exportDoc: () => Promise<{ blob: Blob; detail: string; w: number; h: number }> } | null>(null); +// 上传前模板墙:先点模板记住,选图后由 PsEditor 自动套入 +const pendingTpl = ref(null); + +function chooseTpl(t: TextTpl) { + pendingTpl.value = t; + pickFiles(); // 选完图自动套用该模板 +} function onPsError(msg: string) { errorMsg.value = msg; @@ -935,7 +943,7 @@ onUnmounted(() => {
{
+