feat(image-tools): 图片编辑升级为 PS 风格图层编辑器

- 新增独立组件 PsEditor.vue:9 工具(移动/选框/画笔/橡皮/文字/油漆桶/吸管/裁剪/抓手)
- 图层面板:背景/画笔/文字/色块四类图层,显隐/不透明度/排序/删除/新建
- 历史记录面板:快照撤销重做(Ctrl+Z/Y,20 步,可点击跳转)
- 画布:滚轮缩放 3%-3200%、空格平移、棋盘格、画笔光圈、蚂蚁线选区
- 保留 OCR:识别→点框替换(自动取底色)/只擦除,结果为独立图层
- image-tools.vue 2284→1660 行;keywords/zh+en 文案/About/CHANGELOG 同步
This commit is contained in:
personal82555 committed 2026-10-21 19:20:05 +08:00
1 parent 41f7f0671c
commit 83d98a348e
8 files changed
+1744 -644

No files matched your search

File diff suppressed because it is too large. Load diff
+15 -640
View File
@@ -8,6 +8,7 @@ import { useStorage } from '@vueuse/core';
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';
prepareZXingModule({ overrideWasmUrl: wasmUrl });
const genHist = useGenHistory('image-tools');
@@ -22,7 +23,7 @@ const TABS: TabDef[] = [
{ key: 'rotate', label: '旋转', desc: '旋转或翻转图片' },
{ key: 'filter', label: '滤镜', desc: '为图片应用滤镜效果(灰度/复古/模糊等)' },
{ key: 'mosaic', label: '打码', desc: '在图片上拖拽框选区域,马赛克或涂黑打码' },
{ key: 'edit', label: '图片编辑', desc: '修改图中的文字(OCR 自动定位原文字,覆盖底色后替换)或点击图片任意位置添加新文字,可拖动调整' },
{ key: 'edit', label: '图片编辑', desc: 'PS 风格图层编辑器:画笔/橡皮/文字/选区/油漆桶/吸管/裁剪,支持缩放平移、图层面板与历史记录;OCR 一键替换图中文字' },
{ key: 'exif', label: 'EXIF 查看', desc: '查看拍摄设备、时间、参数等 EXIF 信息' },
{ key: 'qrgen', label: '二维码生成', desc: '把文字/链接生成为二维码图片', noFile: true },
{ key: 'qrread', label: '二维码识别', desc: '识别图片中的二维码/条码内容' },
@@ -133,7 +134,6 @@ function loadMainImage() {
qrResult.value = '';
decodeText.value = '';
mosaicBox.value = null;
resetEditState();
mainImg.value = null;
const f = files.value[0];
if (!f || tab.value.noFile) {
@@ -145,7 +145,6 @@ function loadMainImage() {
mainImg.value = img;
nextTick(() => {
drawMosaicCanvas();
drawEditCanvas();
});
};
img.src = url;
@@ -277,463 +276,24 @@ function mosaicPos(e: MouseEvent) {
return { x: e.clientX - r.left, y: e.clientY - r.top };
}
// ---------- 图片编辑(改文字 + 加文字) ----------
// 坐标约定:covers / layers / ocrHits 全部存原图像素坐标,渲染时乘 displayScale
interface EditCover { id: string; x: number; y: number; w: number; h: number; color: string }
interface EditLayer { id: string; text: string; x: number; y: number; size: number; color: string; bold: boolean }
interface OcrHit { id: string; text: string; score: number; box: number[][]; x: number; y: number; w: number; h: number; used: boolean }
// ---------- 图片编辑(PS 风格编辑器,组件内自带工具栏/图层/历史) ----------
const psEditor = ref<{ exportDoc: () => Promise<{ blob: Blob; detail: string; w: number; h: number }> } | null>(null);
const editCanvas = ref<HTMLCanvasElement>();
const editMode = useStorage<'ocr' | 'add'>('image-tools:edit-mode', 'ocr');
const editCovers = ref<EditCover[]>([]);
const editLayers = ref<EditLayer[]>([]);
const ocrHits = ref<OcrHit[]>([]);
const ocrBusy = ref(false);
const ocrDone = ref(false);
const selLayerId = ref<string | null>(null);
const selOcrId = ref<string | null>(null);
const replaceText = ref('');
const coverColor = ref('#ffffff');
const coverAuto = ref(true);
const addText = useStorage('image-tools:edit-add-text', '新文字');
const addSize = useStorage('image-tools:edit-add-size', 32);
const addColor = useStorage('image-tools:edit-add-color', '#d03050');
const addBold = useStorage('image-tools:edit-add-bold', false);
let editDragging = false;
let editDragLayer: EditLayer | null = null;
let editDragOff = { x: 0, y: 0 };
let editDrawing = false;
let editNewBox: { x1: number; y1: number; x2: number; y2: number } | null = null;
const selLayer = computed(() => editLayers.value.find(l => l.id === selLayerId.value) ?? null);
const unusedOcr = computed(() => ocrHits.value.filter(h => !h.used));
function editPos(e: MouseEvent) {
const c = editCanvas.value!;
const r = c.getBoundingClientRect();
return { x: e.clientX - r.left, y: e.clientY - r.top };
}
// 采样文字框外圈像素的中位色,作为覆盖底色(白底/灰底都自然)
function sampleBoxColor(box: { x: number; y: number; w: number; h: number }): string {
const img = mainImg.value;
if (!img) {
return coverColor.value;
}
try {
const c = document.createElement('canvas');
c.width = img.naturalWidth;
c.height = img.naturalHeight;
const ctx = c.getContext('2d', { willReadFrequently: true })!;
ctx.drawImage(img, 0, 0);
const pad = Math.max(3, Math.round(Math.min(box.w, box.h) * 0.35));
const sx = Math.max(0, Math.round(box.x - pad));
const sy = Math.max(0, Math.round(box.y - pad));
const sw = Math.min(c.width - sx, Math.round(box.w + pad * 2));
const sh = Math.min(c.height - sy, Math.round(box.h + pad * 2));
if (sw <= 0 || sh <= 0) {
return coverColor.value;
}
const d = ctx.getImageData(sx, sy, sw, sh).data;
const rs: number[] = [];
const gs: number[] = [];
const bs: number[] = [];
for (let py = 0; py < sh; py++) {
for (let px = 0; px < sw; px++) {
const ix = sx + px;
const iy = sy + py;
// 跳过框内(文字本身),只取外圈
if (ix >= box.x && ix < box.x + box.w && iy >= box.y && iy < box.y + box.h) {
continue;
}
const i = (py * sw + px) * 4;
rs.push(d[i]);
gs.push(d[i + 1]);
bs.push(d[i + 2]);
}
}
if (!rs.length) {
return coverColor.value;
}
const med = (a: number[]) => {
a.sort((p, q) => p - q);
return a[a.length >> 1];
};
return `rgb(${med(rs)}, ${med(gs)}, ${med(bs)})`;
}
catch {
return coverColor.value;
}
}
async function runEditOcr() {
const f = files.value[0];
if (!f) {
errorMsg.value = '请先选择图片';
return;
}
ocrBusy.value = true;
errorMsg.value = '';
try {
const form = new FormData();
form.append('image_file', f, f.name || 'image.png');
const res = await fetch('/api/ocr', { method: 'POST', body: form, headers: licenseHeaders('image-tools') });
if (!res.ok) {
throw new Error(res.status === 403 ? 'OCR 需要授权或试用' : `OCR 服务 HTTP ${res.status}`);
}
const data = await res.json().catch(() => ({}));
const hits: OcrHit[] = [];
for (const k of Object.keys(data)) {
const pts = data[k]?.dt_boxes;
if (!Array.isArray(pts) || pts.length < 4) {
continue;
}
const text = String(data[k]?.rec_txt ?? '').trim();
if (!text) {
continue;
}
const xs = pts.map((p: any) => Number(p[0]));
const ys = pts.map((p: any) => Number(p[1]));
const x = Math.min(...xs);
const y = Math.min(...ys);
hits.push({
id: `ocr-${k}`,
text,
score: Number(data[k]?.score ?? 0),
box: pts,
x,
y,
w: Math.max(...xs) - x,
h: Math.max(...ys) - y,
used: false,
});
}
ocrHits.value = hits;
ocrDone.value = true;
if (!hits.length) {
errorMsg.value = '未识别到文字,可截图更清晰后重试,或用「添加文字」模式';
}
else {
statusMsg.value = `识别到 ${hits.length} 处文字,点击虚线框或列表项即可替换`;
genHist.add({ title: `编辑 OCR:${f.name}`, detail: `${hits.length} 处文字` });
}
nextTick(drawEditCanvas);
}
catch (e: any) {
errorMsg.value = `识别失败:${e?.message ?? e}`;
ocrDone.value = false;
nextTick(drawEditCanvas);
}
finally {
ocrBusy.value = false;
}
}
// 选中一处 OCR 文字:盖底色 + 在原位创建可编辑文字图层(内容预填原文)
function applyOcrReplace(hit: OcrHit) {
if (hit.used) {
return;
}
const color = coverAuto.value ? sampleBoxColor({ x: hit.x, y: hit.y, w: hit.w, h: hit.h }) : coverColor.value;
const padX = Math.max(1, Math.round(hit.w * 0.02));
const padY = Math.max(1, Math.round(hit.h * 0.08));
editCovers.value.push({
id: `c${Date.now()}${Math.random().toString(36).slice(2, 6)}`,
x: Math.max(0, hit.x - padX),
y: Math.max(0, hit.y - padY),
w: hit.w + padX * 2,
h: hit.h + padY * 2,
color,
});
const layer: EditLayer = {
id: `l${Date.now()}${Math.random().toString(36).slice(2, 6)}`,
text: replaceText.value.trim() || hit.text,
x: hit.x,
y: hit.y + hit.h * 0.06,
size: Math.max(10, Math.round(hit.h * 0.82)),
color: '#000000',
bold: false,
};
editLayers.value.push(layer);
hit.used = true;
selLayerId.value = layer.id;
selOcrId.value = null;
replaceText.value = '';
coverColor.value = color.startsWith('rgb') ? '#ffffff' : color;
nextTick(drawEditCanvas);
}
// 仅擦除(盖底色,不加字)
function applyOcrErase(hit: OcrHit) {
if (hit.used) {
return;
}
const color = coverAuto.value ? sampleBoxColor({ x: hit.x, y: hit.y, w: hit.w, h: hit.h }) : coverColor.value;
const padX = Math.max(1, Math.round(hit.w * 0.02));
const padY = Math.max(1, Math.round(hit.h * 0.08));
editCovers.value.push({
id: `c${Date.now()}${Math.random().toString(36).slice(2, 6)}`,
x: Math.max(0, hit.x - padX),
y: Math.max(0, hit.y - padY),
w: hit.w + padX * 2,
h: hit.h + padY * 2,
color,
});
hit.used = true;
selOcrId.value = null;
nextTick(drawEditCanvas);
}
function removeCover(id: string) {
editCovers.value = editCovers.value.filter(c => c.id !== id);
drawEditCanvas();
}
function removeLayer(id: string) {
editLayers.value = editLayers.value.filter(l => l.id !== id);
if (selLayerId.value === id) {
selLayerId.value = null;
}
drawEditCanvas();
}
function resetEditState() {
editCovers.value = [];
editLayers.value = [];
ocrHits.value = [];
ocrDone.value = false;
selLayerId.value = null;
selOcrId.value = null;
replaceText.value = '';
editNewBox = null;
}
function drawEditCanvas() {
const c = editCanvas.value;
const img = mainImg.value;
if (!c || !img) {
return;
}
const maxW = 640;
const scale = Math.min(1, maxW / img.naturalWidth);
displayScale.value = scale;
c.width = Math.round(img.naturalWidth * scale);
c.height = Math.round(img.naturalHeight * scale);
const ctx = c.getContext('2d')!;
ctx.drawImage(img, 0, 0, c.width, c.height);
// 1) 底色覆盖(擦除原文字)
for (const cv of editCovers.value) {
ctx.fillStyle = cv.color;
ctx.fillRect(cv.x * scale, cv.y * scale, cv.w * scale, cv.h * scale);
}
// 2) 未处理的 OCR 虚线框
for (const h of ocrHits.value) {
if (h.used) {
continue;
}
const selected = h.id === selOcrId.value;
ctx.strokeStyle = selected ? '#2563eb' : '#d03050';
ctx.lineWidth = selected ? 2.5 : 1.5;
ctx.setLineDash([6, 4]);
ctx.strokeRect(h.x * scale, h.y * scale, h.w * scale, h.h * scale);
ctx.setLineDash([]);
// 框顶小标签
const label = h.text.length > 12 ? `${h.text.slice(0, 12)}…` : h.text;
ctx.font = `${Math.max(10, Math.round(11 / Math.max(scale, 0.4)))}px sans-serif`;
const tw = ctx.measureText(label).width + 8;
const ly = h.y * scale - 16;
ctx.fillStyle = selected ? '#2563eb' : 'rgba(208,48,80,0.92)';
ctx.fillRect(h.x * scale, ly < 0 ? h.y * scale : ly, tw, 15);
ctx.fillStyle = '#fff';
ctx.textBaseline = 'middle';
ctx.fillText(label, h.x * scale + 4, (ly < 0 ? h.y * scale : ly) + 8);
}
// 3) 文字图层
for (const l of editLayers.value) {
ctx.font = `${l.bold ? 'bold ' : ''}${l.size * scale}px "Microsoft YaHei","PingFang SC","Noto Sans CJK SC",sans-serif`;
ctx.fillStyle = l.color;
ctx.textBaseline = 'top';
ctx.fillText(l.text, l.x * scale, l.y * scale);
if (l.id === selLayerId.value) {
const w = ctx.measureText(l.text).width;
ctx.strokeStyle = '#18a058';
ctx.lineWidth = 1.5;
ctx.setLineDash([5, 3]);
ctx.strokeRect(l.x * scale - 4, l.y * scale - 3, w + 8, l.size * scale * 1.25 + 6);
ctx.setLineDash([]);
}
}
// 4) 拖拽框选预览(add 模式手动框选覆盖)
if (editNewBox) {
const b = editNewBox;
ctx.strokeStyle = '#d03050';
ctx.lineWidth = 2;
ctx.setLineDash([6, 4]);
ctx.strokeRect(Math.min(b.x1, b.x2), Math.min(b.y1, b.y2), Math.abs(b.x2 - b.x1), Math.abs(b.y2 - b.y1));
ctx.setLineDash([]);
}
}
function layerHitTest(ix: number, iy: number): EditLayer | null {
const c = editCanvas.value;
if (!c) {
return null;
}
const ctx = c.getContext('2d')!;
for (let i = editLayers.value.length - 1; i >= 0; i--) {
const l = editLayers.value[i];
ctx.font = `${l.bold ? 'bold ' : ''}${l.size}px "Microsoft YaHei","PingFang SC",sans-serif`;
const w = ctx.measureText(l.text).width;
const h = l.size * 1.25;
if (ix >= l.x - 6 && ix <= l.x + w + 6 && iy >= l.y - 6 && iy <= l.y + h + 6) {
return l;
}
}
return null;
}
function ocrHitTest(ix: number, iy: number): OcrHit | null {
for (const h of ocrHits.value) {
if (!h.used && ix >= h.x - 3 && ix <= h.x + h.w + 3 && iy >= h.y - 3 && iy <= h.y + h.h + 3) {
return h;
}
}
return null;
}
function onEditDown(e: MouseEvent) {
if (!editCanvas.value) {
return;
}
const p = editPos(e);
const s = displayScale.value;
const ix = p.x / s;
const iy = p.y / s;
// 1) 点到已有文字图层 → 选中并拖动
const lh = layerHitTest(ix, iy);
if (lh) {
selLayerId.value = lh.id;
editDragging = true;
editDragLayer = lh;
editDragOff = { x: ix - lh.x, y: iy - lh.y };
drawEditCanvas();
return;
}
// 2) OCR 模式:点到虚线框 → 替换
if (editMode.value === 'ocr') {
const oh = ocrHitTest(ix, iy);
if (oh) {
selOcrId.value = oh.id;
replaceText.value = '';
drawEditCanvas();
return;
}
return;
}
// 3) add 模式空白处:开始框选(松手后按框擦除)或直接加字
if (editMode.value === 'add') {
editDrawing = true;
editNewBox = { x1: p.x, y1: p.y, x2: p.x, y2: p.y };
}
}
function onEditMove(e: MouseEvent) {
if (!editCanvas.value) {
return;
}
const p = editPos(e);
const s = displayScale.value;
if (editDragging && editDragLayer) {
editDragLayer.x = Math.max(0, Math.min(editCanvas.value.width / s, p.x / s - editDragOff.x));
editDragLayer.y = Math.max(0, Math.min(editCanvas.value.height / s, p.y / s - editDragOff.y));
drawEditCanvas();
return;
}
if (editDrawing && editNewBox) {
editNewBox.x2 = p.x;
editNewBox.y2 = p.y;
drawEditCanvas();
}
}
function onEditUp() {
if (editDragging) {
editDragging = false;
editDragLayer = null;
return;
}
if (editDrawing && editNewBox) {
const b = editNewBox;
editDrawing = false;
editNewBox = null;
const s = displayScale.value;
const x = Math.round(Math.min(b.x1, b.x2) / s);
const y = Math.round(Math.min(b.y1, b.y2) / s);
const w = Math.round(Math.abs(b.x2 - b.x1) / s);
const h = Math.round(Math.abs(b.y2 - b.y1) / s);
if (w >= 6 && h >= 6) {
editCovers.value.push({
id: `c${Date.now()}${Math.random().toString(36).slice(2, 6)}`,
x,
y,
w,
h,
color: coverAuto.value ? sampleBoxColor({ x, y, w, h }) : coverColor.value,
});
}
drawEditCanvas();
}
}
function addTextLayer() {
const img = mainImg.value;
const text = addText.value.trim();
if (!img) {
return;
}
if (!text) {
errorMsg.value = '请输入要添加的文字';
return;
}
errorMsg.value = '';
const layer: EditLayer = {
id: `l${Date.now()}${Math.random().toString(36).slice(2, 6)}`,
text,
x: Math.round(img.naturalWidth * 0.08),
y: Math.round(img.naturalHeight * 0.08),
size: addSize.value,
color: addColor.value,
bold: addBold.value,
};
editLayers.value.push(layer);
selLayerId.value = layer.id;
nextTick(drawEditCanvas);
function onPsError(msg: string) {
errorMsg.value = msg;
}
async function doEdit() {
const img = mainImg.value!;
if (!editCovers.value.length && !editLayers.value.length) {
throw new Error('还没有任何修改:先「识别文字」点框替换,或在「添加文字」模式下框选/加字');
const ed = psEditor.value;
if (!ed) {
throw new Error('编辑器未就绪,请重新选择图片');
}
const c = loadCanvasFromImg(img);
const ctx = c.getContext('2d')!;
for (const cv of editCovers.value) {
ctx.fillStyle = cv.color;
ctx.fillRect(cv.x, cv.y, cv.w, cv.h);
}
for (const l of editLayers.value) {
ctx.font = `${l.bold ? 'bold ' : ''}${l.size}px "Microsoft YaHei","PingFang SC","Noto Sans CJK SC","Source Han Sans SC",sans-serif`;
ctx.fillStyle = l.color;
ctx.textBaseline = 'top';
ctx.fillText(l.text, l.x, l.y);
}
const keepPng = files.value[0].type === 'image/png';
const blob = await canvasToBlob(c, keepPng ? 'image/png' : 'image/jpeg', 94);
const { blob, detail, w, h } = await ed.exportDoc();
setOutput(blob, `${baseName(files.value[0])}-edited.${extOf(blob.type)}`, {
title: `编辑 ${files.value[0].name}`,
detail: `擦除 ${editCovers.value.length} 处 · 文字 ${editLayers.value.length} 个`,
detail,
});
resultDim.value = `${c.width}×${c.height}`;
resultDim.value = `${w}×${h}`;
}
@@ -1326,7 +886,6 @@ function fit() {
watch(tabKey, () => nextTick(() => {
drawMosaicCanvas();
drawEditCanvas();
}));
onMounted(() => {
@@ -1395,25 +954,7 @@ onUnmounted(() => {
</div>
</template>
<template v-else-if="files.length && tab.key === 'edit'">
<div class="it-mosaic-wrap">
<canvas
ref="editCanvas"
class="it-mosaic"
:class="editMode === 'ocr' ? 'edit-ocr-mode' : 'edit-add-mode'"
@mousedown="onEditDown"
@mousemove="onEditMove"
@mouseup="onEditUp"
@mouseleave="onEditUp"
/>
</div>
<div class="it-edit-hint">
<template v-if="editMode === 'ocr'">
点击虚线框选中文字 → 在下方输入新文字 → 替换(自动取底色覆盖原字)
</template>
<template v-else>
在图片上拖拽框选要涂掉的区域;点「添加文字」放新文字,拖动文字可调整位置
</template>
</div>
<PsEditor ref="psEditor" :file="files[0]" @error="onPsError" />
</template>
<template v-else-if="files.length">
<div class="it-files">
@@ -1494,84 +1035,7 @@ onUnmounted(() => {
<span class="it-hint">在左侧图片上按住拖拽框选打码区域</span>
</template>
<template v-else-if="tab.key === 'edit'">
<label>模式</label>
<button class="it-chip" :class="{ on: editMode === 'ocr' }" @click="editMode = 'ocr'">
🔍 改图中文字
</button>
<button class="it-chip" :class="{ on: editMode === 'add' }" @click="editMode = 'add'">
✏️ 涂改/加字
</button>
<button class="it-chip" :disabled="ocrBusy" @click="runEditOcr">
{{ ocrBusy ? '识别中…' : ocrDone ? '重新识别文字' : '识别图中文字' }}
</button>
<span v-if="unusedOcr.length" class="it-hint">待处理 {{ unusedOcr.length }} 处</span>
<template v-if="editMode === 'ocr' && selOcrId">
<label>新文字</label>
<input
v-model="replaceText"
class="it-input wide"
placeholder="留空 = 保持原文"
@keyup.enter="applyOcrReplace(ocrHits.find(h => h.id === selOcrId)!)"
>
<button class="it-chip on" @click="applyOcrReplace(ocrHits.find(h => h.id === selOcrId)!)">
✓ 替换
</button>
<button class="it-chip" @click="applyOcrErase(ocrHits.find(h => h.id === selOcrId)!)">
只擦除
</button>
</template>
<label v-if="editMode === 'ocr' && ocrDone && !unusedOcr.length" class="it-hint">全部文字已处理 ✓</label>
<template v-if="editMode === 'add'">
<label>文字</label>
<input v-model="addText" class="it-input wide" placeholder="要添加的文字" @keyup.enter="addTextLayer">
<button class="it-chip on" @click="addTextLayer">
+ 添加文字
</button>
<label>字号</label>
<input v-model.number="addSize" type="number" min="6" max="400" class="it-input n60">
<label>颜色</label>
<input v-model="addColor" type="color" class="it-colorswatch" title="文字颜色">
<label class="it-check"><input v-model="addBold" type="checkbox"> 加粗</label>
<label>底色</label>
<button class="it-chip" :class="{ on: coverAuto }" @click="coverAuto = true">
自动取图
</button>
<button class="it-chip" :class="{ on: !coverAuto }" @click="coverAuto = false">
手动
</button>
<input v-if="!coverAuto" v-model="coverColor" type="color" class="it-colorswatch" title="覆盖底色">
</template>
<!-- 已处理列表:可改字/删除 -->
<template v-if="editLayers.length || editCovers.length">
<label>图层</label>
<div class="it-edit-layers">
<div
v-for="l in editLayers"
:key="l.id"
class="it-edit-layer"
:class="{ on: l.id === selLayerId }"
@click="selLayerId = l.id; drawEditCanvas()"
>
<input v-model="l.text" class="it-edit-lt" @click.stop @input="drawEditCanvas">
<input v-model.number="l.size" type="number" min="6" max="400" class="it-edit-ls" title="字号" @click.stop @input="drawEditCanvas">
<input v-model="l.color" type="color" class="it-colorswatch" title="颜色" @click.stop @input="drawEditCanvas">
<a href="javascript:;" class="it-edit-del" title="删除文字" @click.stop="removeLayer(l.id)">✕</a>
</div>
<div
v-for="c in editCovers"
:key="c.id"
class="it-edit-layer cover"
title="擦除区域(点击删除)"
>
<span class="it-edit-ct">⬤ 擦除 {{ Math.round(c.w) }}×{{ Math.round(c.h) }}</span>
<input v-model="c.color" type="color" class="it-colorswatch" title="底色" @input="drawEditCanvas">
<a href="javascript:;" class="it-edit-del" @click.stop="removeCover(c.id)">✕</a>
</div>
</div>
</template>
<span class="it-hint">编辑器内含:工具栏(移动/选框/画笔/橡皮/文字/油漆桶/吸管/裁剪/抓手)、图层面板、历史记录;Ctrl+Z 撤销、滚轮缩放、空格拖动。编辑完成后点下方「执行」导出成品。</span>
</template>
<template v-else-if="tab.key === 'qrgen'">
<label>尺寸</label>
@@ -1935,23 +1399,7 @@ onUnmounted(() => {
}
}
// ---------- 图片编辑 ----------
.edit-ocr-mode {
cursor: pointer;
}
.edit-add-mode {
cursor: crosshair;
}
.it-edit-hint {
width: 100%;
font-size: 12px;
color: #2563eb;
opacity: 0.9;
line-height: 1.5;
padding-top: 4px;
}
// ---------- 图片编辑(组件内样式见 PsEditor.vue) ----------
.it-colorswatch {
width: 34px;
@@ -1963,79 +1411,6 @@ onUnmounted(() => {
cursor: pointer;
}
.it-edit-layers {
width: 100%;
display: flex;
flex-direction: column;
gap: 5px;
max-height: 168px;
overflow-y: auto;
border: 1px solid rgba(128, 128, 128, 0.22);
border-radius: 8px;
padding: 7px;
box-sizing: border-box;
.it-edit-layer {
display: flex;
align-items: center;
gap: 7px;
background: rgba(128, 128, 128, 0.05);
border: 1px solid transparent;
border-radius: 6px;
padding: 4px 7px;
&.on {
border-color: #18a058;
background: rgba(24, 160, 88, 0.08);
}
&.cover {
opacity: 0.85;
}
.it-edit-lt {
flex: 1;
min-width: 0;
border: 1px solid rgba(128, 128, 128, 0.3);
border-radius: 5px;
padding: 3px 7px;
font-size: 12.5px;
outline: none;
&:focus {
border-color: #18a058;
}
}
.it-edit-ls {
width: 54px;
border: 1px solid rgba(128, 128, 128, 0.3);
border-radius: 5px;
padding: 3px 5px;
font-size: 12px;
outline: none;
}
.it-edit-ct {
flex: 1;
font-size: 12px;
opacity: 0.65;
}
.it-edit-del {
color: #999;
text-decoration: none;
font-size: 13px;
padding: 0 3px;
flex-shrink: 0;
&:hover {
color: #d03050;
}
}
}
}
.it-qrbox {
flex: 1;
min-height: 120px;
+1 -1
View File
@@ -6,7 +6,7 @@ export const tool = defineTool({
name: translate('tools.image-tools.title'),
path: '/image-tools',
description: translate('tools.image-tools.description'),
keywords: ['image', 'compress', 'convert', 'resize', 'crop', 'rotate', 'filter', 'mosaic', 'exif', 'watermark', 'stitch', 'edit', 'text', 'replace', '图片', '压缩', '转换', '裁剪', '旋转', '滤镜', '打码', '水印', '拼接', '编辑', '改文字', '文字替换', '加文字'],
keywords: ['image', 'compress', 'convert', 'resize', 'crop', 'rotate', 'filter', 'mosaic', 'exif', 'watermark', 'stitch', 'edit', 'text', 'replace', 'photoshop', 'layer', 'brush', 'history', '图片', '压缩', '转换', '裁剪', '旋转', '滤镜', '打码', '水印', '拼接', '编辑', '改文字', '文字替换', '加文字', '画笔', '图层', '历史记录'],
component: () => import('./image-tools.vue'),
icon: Photo,
});