feat: 印章生成器 — canvas圆形公章(弧形文字/五角星/反转色), 盖章到图片与PDF(骑缝章/角章/透明度/旋转/页码范围), 全程浏览器本地处理, 受控授权
This commit is contained in:
1 parent
aaa2eaa834
commit
b374cc31b2
10 files changed
+1158
-13
No files matched your search
Vendored
+1
@@ -210,6 +210,7 @@ declare module '@vue/runtime-core' {
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
RsaKeyPairGenerator: typeof import('./src/tools/rsa-key-pair-generator/rsa-key-pair-generator.vue')['default']
|
||||
SafelinkDecoder: typeof import('./src/tools/safelink-decoder/safelink-decoder.vue')['default']
|
||||
SealMaker: typeof import('./src/tools/seal-maker/seal-maker.vue')['default']
|
||||
SiteBookmarks: typeof import('./src/tools/site-bookmarks/site-bookmarks.vue')['default']
|
||||
SlugifyString: typeof import('./src/tools/slugify-string/slugify-string.vue')['default']
|
||||
SpanCopyable: typeof import('./src/components/SpanCopyable.vue')['default']
|
||||
|
||||
@@ -44,7 +44,7 @@ AUTH_PASS = os.environ.get("AUTH_PASS", "")
|
||||
PROJECT_NAME = os.environ.get("PROJECT_NAME", "IT-Tools")
|
||||
TRIAL_FILE = os.environ.get("TRIAL_FILE", "/app/data/trials.json")
|
||||
TRIAL_MS = int(os.environ.get("TRIAL_MS_MIN", "30")) * 60 * 1000
|
||||
PROTECTED_TOOLS = {"translator", "image-ocr", "pdf-ocr", "ai-retouch", "label-designer", "doc-convert", "image-tools", "pdf-tools", "video-tools", "audio-tools"}
|
||||
PROTECTED_TOOLS = {"translator", "image-ocr", "pdf-ocr", "ai-retouch", "label-designer", "doc-convert", "image-tools", "pdf-tools", "video-tools", "audio-tools", "seal-maker"}
|
||||
MACHINE_RE = re.compile(r"^\d{10,16}$")
|
||||
|
||||
# verify() messages that unconditionally block activation
|
||||
@@ -1469,6 +1469,76 @@ class Handler(BaseHTTPRequestHandler):
|
||||
except Exception as e: # noqa: BLE001
|
||||
self._reply(500, json.dumps({"code": 500, "message": "合成失败: " + str(e)[:200]}, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
|
||||
def _handle_clone(self):
|
||||
import audio_ops
|
||||
import uuid as _uuid
|
||||
parsed = parse.urlparse(self.path)
|
||||
machine = self.headers.get("X-Machine-Id", "")
|
||||
status = check(machine, "audio-tools")
|
||||
if status != 200:
|
||||
self._reply(403, json.dumps({"code": 403, "message": "需要授权或免费试用已结束"}, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
return
|
||||
|
||||
if parsed.path == "/clone/prepare":
|
||||
# multipart: reference audio -> stored for the voice-clone pipeline
|
||||
try:
|
||||
ctype = self.headers.get("Content-Type", "")
|
||||
length = int(self.headers.get("Content-Length") or 0)
|
||||
if length > 35 * 1024 * 1024:
|
||||
self._reply(413, json.dumps({"code": 413, "message": "参考音频过大"}, ensure_ascii=False).encode(), "application/json")
|
||||
return
|
||||
raw = self.rfile.read(length) if length else b""
|
||||
env = {"REQUEST_METHOD": "POST", "CONTENT_TYPE": ctype, "CONTENT_LENGTH": str(length)}
|
||||
fs = cgi.FieldStorage(fp=io.BytesIO(raw), environ=env, keep_blank_values=True)
|
||||
fobj = fs["file"] if ("file" in fs.keys()) else None
|
||||
if fobj is None or not fobj.filename:
|
||||
self._reply(400, json.dumps({"code": 400, "message": "缺少参考音频文件"}, ensure_ascii=False).encode(), "application/json")
|
||||
return
|
||||
ref = audio_ops.clone_prepare(fobj.file.read(), os.path.basename(fobj.filename))
|
||||
log_usage(machine, "audio-tools-clone")
|
||||
body = {"code": 200, "message": "ok", "data": {"ref_file": ref}}
|
||||
self._reply(200, json.dumps(body, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
except ValueError as e:
|
||||
self._reply(400, json.dumps({"code": 400, "message": str(e)}, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
except Exception as e: # noqa: BLE001
|
||||
self._reply(500, json.dumps({"code": 500, "message": "上传失败: " + str(e)[:200]}, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
return
|
||||
|
||||
if parsed.path == "/clone/tts":
|
||||
try:
|
||||
length = int(self.headers.get("Content-Length") or 0)
|
||||
raw = self.rfile.read(length) if length else b"{}"
|
||||
pl = json.loads(raw.decode("utf-8") or "{}")
|
||||
out_path = "/tmp/clone-" + _uuid.uuid4().hex[:10] + ".wav"
|
||||
try:
|
||||
audio_ops.clone_tts(
|
||||
str(pl.get("ref_file") or ""),
|
||||
str(pl.get("prompt_text") or ""),
|
||||
str(pl.get("text") or ""),
|
||||
str(pl.get("text_lang") or "zh"),
|
||||
str(pl.get("prompt_lang") or "zh"),
|
||||
out_path,
|
||||
)
|
||||
with open(out_path, "rb") as f:
|
||||
out = f.read()
|
||||
finally:
|
||||
try:
|
||||
os.remove(out_path)
|
||||
except Exception:
|
||||
pass
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "audio/wav")
|
||||
self.send_header("Content-Length", str(len(out)))
|
||||
self.end_headers()
|
||||
self.wfile.write(out)
|
||||
except ValueError as e:
|
||||
self._reply(400, json.dumps({"code": 400, "message": str(e)}, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
except Exception as e: # noqa: BLE001
|
||||
self._reply(500, json.dumps({"code": 500, "message": "克隆合成失败: " + str(e)[:200]}, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
return
|
||||
|
||||
self._reply(404, b"not found")
|
||||
|
||||
def _handle_asr(self):
|
||||
import audio_ops
|
||||
import uuid as _uuid
|
||||
@@ -1533,6 +1603,9 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if parsed.path == "/asr":
|
||||
self._handle_asr()
|
||||
return
|
||||
if parsed.path.startswith("/clone"):
|
||||
self._handle_clone()
|
||||
return
|
||||
if parsed.path == "/video":
|
||||
self._handle_video()
|
||||
return
|
||||
|
||||
@@ -275,6 +275,9 @@ tools:
|
||||
title: Image OCR
|
||||
description: Extract text from images with OCR - click, drag & drop or paste a screenshot, get recognized lines with confidence scores, copy or download as TXT.
|
||||
|
||||
seal-maker:
|
||||
title: 'Seal maker'
|
||||
description: 'Generate official seals and stamp them onto images and PDFs (cross-page seal), all local in browser'
|
||||
audio-tools:
|
||||
title: 'Audio tools'
|
||||
description: 'Text to speech, speech to text, voice clone - AI audio toolkit'
|
||||
|
||||
@@ -272,6 +272,9 @@ tools:
|
||||
title: 图片OCR文字识别
|
||||
description: 上传、拖拽或粘贴截图识别图片中的文字,逐行输出识别结果和置信度,支持复制全部和下载TXT。
|
||||
|
||||
seal-maker:
|
||||
title: '印章生成器'
|
||||
description: '生成圆形公章/专用章(弧形文字+五角星),一键盖章到图片与 PDF(骑缝章/角章),全程浏览器本地处理'
|
||||
audio-tools:
|
||||
title: '音频工具'
|
||||
description: '文字转音频(14 种音色)、音频转文字(中英日粤自动检测)、声音克隆等 AI 语音工具'
|
||||
|
||||
@@ -40,7 +40,7 @@ useHead(head);
|
||||
const { t } = useI18n();
|
||||
|
||||
// 宽屏工具:不受 600px 限宽,占满可用宽度(画布/多栏类工具)
|
||||
const WIDE_TOOLS = new Set(['/label-designer', '/json-prettify', '/pdf-tools', '/image-tools', '/doc-convert', '/video-tools']);
|
||||
const WIDE_TOOLS = new Set(['/label-designer', '/json-prettify', '/pdf-tools', '/image-tools', '/doc-convert', '/video-tools', '/seal-maker']);
|
||||
const isWide = computed(() => WIDE_TOOLS.has(route.path));
|
||||
|
||||
const i18nKey = computed<string>(() => route.path.trim().replace('/', ''));
|
||||
|
||||
@@ -143,6 +143,111 @@ async function copyAsr() {
|
||||
catch { /* ignore */ }
|
||||
}
|
||||
|
||||
// ============ 声音克隆 (voice clone) ============
|
||||
const clRef = ref<File | null>(null);
|
||||
const clRefInput = ref<HTMLInputElement>();
|
||||
const clRefFile = ref(''); // ref_file id from server
|
||||
const clPrompt = ref('');
|
||||
const clText = ref('');
|
||||
const clLang = ref('zh');
|
||||
const clBusy = ref(false);
|
||||
const clUploading = ref(false);
|
||||
const clError = ref('');
|
||||
const clResultUrl = ref('');
|
||||
const clResultSize = ref(0);
|
||||
const clSpent = ref(0);
|
||||
|
||||
function pickClRef() {
|
||||
clRefInput.value?.click();
|
||||
}
|
||||
|
||||
function onClRef(e: Event) {
|
||||
const input = e.target as HTMLInputElement;
|
||||
clRef.value = input.files?.[0] ?? null;
|
||||
input.value = '';
|
||||
clRefFile.value = '';
|
||||
clError.value = '';
|
||||
}
|
||||
|
||||
function onClDrop(e: DragEvent) {
|
||||
clRef.value = e.dataTransfer?.files?.[0] ?? null;
|
||||
clRefFile.value = '';
|
||||
clError.value = '';
|
||||
}
|
||||
|
||||
async function uploadClRef() {
|
||||
if (!clRef.value) {
|
||||
clError.value = '请先选择参考音频';
|
||||
return;
|
||||
}
|
||||
clUploading.value = true;
|
||||
clError.value = '';
|
||||
try {
|
||||
const fd = new FormData();
|
||||
fd.append('file', clRef.value);
|
||||
const res = await fetch('/relay/clone/prepare', { method: 'POST', body: fd, headers: licenseHeaders() });
|
||||
const b = await res.json().catch(() => ({}));
|
||||
if (!res.ok) {
|
||||
throw new Error(b.message || `上传失败(${res.status})`);
|
||||
}
|
||||
clRefFile.value = b.data.ref_file;
|
||||
}
|
||||
catch (e: any) {
|
||||
clError.value = String(e?.message || e);
|
||||
}
|
||||
finally {
|
||||
clUploading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function runClone() {
|
||||
if (!clRefFile.value) {
|
||||
clError.value = '请先上传参考音频';
|
||||
return;
|
||||
}
|
||||
clBusy.value = true;
|
||||
clError.value = '';
|
||||
const t0 = Date.now();
|
||||
try {
|
||||
const res = await fetch('/relay/clone/tts', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', ...licenseHeaders() },
|
||||
body: JSON.stringify({
|
||||
ref_file: clRefFile.value,
|
||||
prompt_text: clPrompt.value,
|
||||
text: clText.value,
|
||||
text_lang: clLang.value,
|
||||
prompt_lang: clLang.value,
|
||||
}),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const b = await res.json().catch(() => ({}));
|
||||
throw new Error(b.message || `合成失败(${res.status})`);
|
||||
}
|
||||
const blob = await res.blob();
|
||||
if (clResultUrl.value) {
|
||||
URL.revokeObjectURL(clResultUrl.value);
|
||||
}
|
||||
clResultUrl.value = URL.createObjectURL(blob);
|
||||
clResultSize.value = blob.size;
|
||||
clSpent.value = Math.round((Date.now() - t0) / 1000);
|
||||
genHist.add({ title: `声音克隆: ${clText.value.slice(0, 24)}`, detail: `${(blob.size / 1024).toFixed(0)}KB(${clSpent.value}s)` });
|
||||
}
|
||||
catch (e: any) {
|
||||
clError.value = String(e?.message || e);
|
||||
}
|
||||
finally {
|
||||
clBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function downloadClone() {
|
||||
const a = document.createElement('a');
|
||||
a.href = clResultUrl.value;
|
||||
a.download = '克隆语音.wav';
|
||||
a.click();
|
||||
}
|
||||
|
||||
// ============ tabs ============
|
||||
type TabId = 'tts' | 'asr' | 'clone';
|
||||
const tab = ref<TabId>('tts');
|
||||
@@ -268,17 +373,60 @@ const tabDesc = computed(() => TABS.find(t => t.id === tab.value)?.desc ?? '');
|
||||
<div class="at-panel-title">
|
||||
🎭 声音克隆 <span class="at-panel-sub">{{ tabDesc }}</span>
|
||||
</div>
|
||||
<div class="at-soon">
|
||||
<div class="at-soon-icon">🔧</div>
|
||||
<div class="at-soon-title">声音克隆功能部署中,即将上线</div>
|
||||
<div class="at-soon-desc">
|
||||
基于 GPT-SoVITS 本地大模型:上传 5-10 秒参考音频即可克隆音色,让 AI 用你的声音朗读任意文本。
|
||||
模型部署完成后本页面自动开放,无需更新站点。
|
||||
|
||||
<!-- step 1: reference audio -->
|
||||
<div class="cl-step">
|
||||
<div class="cl-step-title">① 上传参考音频(5-10 秒清晰人声,本地 GPT-SoVITS 模型克隆音色)</div>
|
||||
<div class="at-drop" @click="pickClRef" @dragover.prevent @drop.prevent="onClDrop">
|
||||
<input ref="clRefInput" type="file" hidden accept="audio/*,.m4a,.mp3,.wav,.flac,.ogg,.mp4,.webm" @change="onClRef">
|
||||
<template v-if="!clRef">
|
||||
<div class="at-drop-hint">🎤 点击选择或拖拽参考音频</div>
|
||||
<div class="at-drop-sub">建议 5-10 秒、无背景音乐的清晰人声,最大 30MB</div>
|
||||
</template>
|
||||
<div v-else class="at-file">
|
||||
🎙️ {{ clRef.name }} <span class="at-file-size">({{ (clRef.size / 1024 / 1024).toFixed(1) }} MB)</span>
|
||||
<a href="javascript:;" class="at-clear" @click.stop="clRef = null; clRefFile = ''">✕</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="at-soon-tips">
|
||||
<div>✓ 支持中文零样本克隆(5 秒样本)</div>
|
||||
<div>✓ 克隆音色可保存复用</div>
|
||||
<div>✓ 本地模型推理,参考音频不外传</div>
|
||||
<button class="at-btn at-btn-sm" :disabled="clUploading || !clRef" @click="uploadClRef">
|
||||
{{ clUploading ? '⏳ 上传中…' : (clRefFile ? '✓ 参考音频已就绪' : '上传参考音频') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- step 2: texts -->
|
||||
<div class="cl-step">
|
||||
<div class="cl-step-title">② 填写参考音频里说的话(提升克隆相似度的关键)</div>
|
||||
<textarea v-model="clPrompt" class="at-textarea" rows="2" placeholder="逐字输入参考音频中的原话,例如:你好,我是张三,很高兴认识你。" />
|
||||
</div>
|
||||
|
||||
<div class="cl-step">
|
||||
<div class="cl-step-title">③ 输入要生成的目标文本,用克隆音色朗读</div>
|
||||
<textarea v-model="clText" class="at-textarea" rows="3" placeholder="输入想让克隆声音说的话,最多 2000 字…" />
|
||||
<div class="at-row">
|
||||
<div class="at-field">
|
||||
<label class="at-label">语言</label>
|
||||
<select v-model="clLang" class="at-select">
|
||||
<option value="zh">中文</option>
|
||||
<option value="en">英语</option>
|
||||
<option value="ja">日语</option>
|
||||
<option value="yue">粤语</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="at-actions">
|
||||
<button class="at-btn" :disabled="clBusy || !clRefFile || !clPrompt.trim() || !clText.trim()" @click="runClone">
|
||||
{{ clBusy ? '⏳ 克隆合成中(CPU 推理需 1-3 分钟)…' : '🎭 生成克隆语音' }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="clError" class="at-error">{{ clError }}</div>
|
||||
|
||||
<div v-if="clResultUrl" class="at-result">
|
||||
<audio :src="clResultUrl" controls class="at-audio" />
|
||||
<div class="at-result-bar">
|
||||
<span class="at-result-name">克隆语音({{ (clResultSize / 1024).toFixed(0) }} KB · 用时 {{ clSpent }}s)</span>
|
||||
<button class="at-btn at-btn-sm" @click="downloadClone">⬇ 下载 WAV</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -563,6 +711,17 @@ const tabDesc = computed(() => TABS.find(t => t.id === tab.value)?.desc ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
.cl-step {
|
||||
margin-bottom: 12px;
|
||||
|
||||
.cl-step-title {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
opacity: 0.75;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.at-soon {
|
||||
text-align: center;
|
||||
padding: 24px 10px;
|
||||
|
||||
+2
-1
@@ -83,6 +83,7 @@ import { tool as pdfTools } from './pdf-tools';
|
||||
import { tool as imageTools } from './image-tools';
|
||||
import { tool as videoTools } from './video-tools';
|
||||
import { tool as audioTools } from './audio-tools';
|
||||
import { tool as sealMaker } from './seal-maker';
|
||||
import { tool as docConvert } from './doc-convert';
|
||||
import { tool as aiRetouch } from './ai-retouch';
|
||||
import { tool as wifiQrCodeGenerator } from './wifi-qr-code-generator';
|
||||
@@ -154,7 +155,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
},
|
||||
{
|
||||
name: 'Images and videos',
|
||||
components: [qrCodeGenerator, wifiQrCodeGenerator, batchBarcodeGenerator, codeReader, imageOcr, pdfOcr, pdfTools, imageTools, videoTools, audioTools, docConvert, aiRetouch, labelDesigner, siteBookmarks, svgPlaceholderGenerator, cameraRecorder],
|
||||
components: [qrCodeGenerator, wifiQrCodeGenerator, batchBarcodeGenerator, codeReader, imageOcr, pdfOcr, pdfTools, imageTools, videoTools, audioTools, sealMaker, docConvert, aiRetouch, labelDesigner, siteBookmarks, svgPlaceholderGenerator, cameraRecorder],
|
||||
},
|
||||
{
|
||||
name: 'Development',
|
||||
|
||||
@@ -16,6 +16,7 @@ export const PROTECTED_TOOLS: Record<string, string> = {
|
||||
'/pdf-tools': 'PDF工具',
|
||||
'/video-tools': '视频工具',
|
||||
'/audio-tools': '音频工具',
|
||||
'/seal-maker': '印章生成',
|
||||
};
|
||||
|
||||
export const TRIAL_MS = 30 * 60 * 1000; // 每个功能免费 30 分钟
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Sticker } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
import { translate } from '@/plugins/i18n.plugin';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: translate('tools.seal-maker.title'),
|
||||
path: '/seal-maker',
|
||||
description: translate('tools.seal-maker.description'),
|
||||
keywords: ['seal', 'stamp', '印章', '公章', '盖章', '骑缝章', '签名', '专用章'],
|
||||
component: () => import('./seal-maker.vue'),
|
||||
icon: Sticker,
|
||||
});
|
||||
@@ -0,0 +1,892 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useHead } from '@vueuse/head';
|
||||
import GenHistory from '@/tools/gen-history/GenHistory.vue';
|
||||
import { useGenHistory } from '@/tools/gen-history/gen-history';
|
||||
|
||||
useHead({ title: '印章生成器 - IT-TOOLS-PRO' });
|
||||
|
||||
const genHist = useGenHistory('seal-maker');
|
||||
|
||||
// ============ 印章参数 ============
|
||||
const style = ref<'circle-star' | 'circle-text'>('circle-star');
|
||||
const mainText = ref('在线工具大全示例专用章');
|
||||
const subText = ref('合同专用章');
|
||||
const sealSize = ref(300);
|
||||
const color = ref('#E60012');
|
||||
const invert = ref(false);
|
||||
|
||||
const sealCanvas = ref<HTMLCanvasElement>();
|
||||
const sealReady = computed(() => sealDataUrl.value !== '');
|
||||
const sealDataUrl = ref('');
|
||||
const sealPngBytes = ref<Uint8Array | null>(null);
|
||||
|
||||
function hexToRgb(hex: string) {
|
||||
const m = /^#?([0-9a-f]{6})$/i.exec(hex.trim());
|
||||
if (!m) {
|
||||
return { r: 230, g: 0, b: 18 };
|
||||
}
|
||||
const n = Number.parseInt(m[1], 16);
|
||||
return { r: (n >> 16) & 255, g: (n >> 8) & 255, b: n & 255 };
|
||||
}
|
||||
|
||||
function drawStar(ctx: CanvasRenderingContext2D, cx: number, cy: number, r: number, fill: string) {
|
||||
ctx.save();
|
||||
ctx.fillStyle = fill;
|
||||
ctx.beginPath();
|
||||
for (let i = 0; i < 10; i++) {
|
||||
const ang = -Math.PI / 2 + (i * Math.PI) / 5;
|
||||
const rad = i % 2 === 0 ? r : r * 0.4;
|
||||
const x = cx + rad * Math.cos(ang);
|
||||
const y = cy + rad * Math.sin(ang);
|
||||
if (i === 0) {
|
||||
ctx.moveTo(x, y);
|
||||
}
|
||||
else {
|
||||
ctx.lineTo(x, y);
|
||||
}
|
||||
}
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
function drawArcText(ctx: CanvasRenderingContext2D, text: string, cx: number, cy: number, r: number, fontPx: number, fill: string) {
|
||||
const chars = [...text];
|
||||
const n = chars.length;
|
||||
if (!n) {
|
||||
return;
|
||||
}
|
||||
const perChar = fontPx * 1.02;
|
||||
let spread = (n * perChar) / r;
|
||||
spread = Math.min(spread, Math.PI * 1.05);
|
||||
const step = n > 1 ? spread / (n - 1) : 0;
|
||||
const begin = -Math.PI / 2 - spread / 2;
|
||||
ctx.save();
|
||||
ctx.fillStyle = fill;
|
||||
ctx.font = `bold ${fontPx}px "Microsoft YaHei", "PingFang SC", sans-serif`;
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
for (let i = 0; i < n; i++) {
|
||||
const a = begin + step * i;
|
||||
ctx.save();
|
||||
ctx.translate(cx + r * Math.cos(a), cy + r * Math.sin(a));
|
||||
ctx.rotate(a + Math.PI / 2);
|
||||
ctx.fillText(chars[i], 0, 0);
|
||||
ctx.restore();
|
||||
}
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
function renderSeal() {
|
||||
const c = sealCanvas.value;
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
const size = sealSize.value;
|
||||
c.width = size;
|
||||
c.height = size;
|
||||
const ctx = c.getContext('2d')!;
|
||||
ctx.clearRect(0, 0, size, size);
|
||||
const { r: R, g: G, b: B } = hexToRgb(color.value);
|
||||
const ink = `rgb(${R},${G},${B})`;
|
||||
const bg = ink;
|
||||
const paper = invert.value ? '#ffffff' : bg;
|
||||
const cx = size / 2;
|
||||
const cy = size / 2;
|
||||
const Rr = size / 2 - size * 0.02;
|
||||
const ringW = Math.max(3, size * 0.035);
|
||||
|
||||
if (invert.value) {
|
||||
ctx.fillStyle = bg;
|
||||
ctx.beginPath();
|
||||
ctx.arc(cx, cy, Rr, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
}
|
||||
else {
|
||||
ctx.strokeStyle = ink;
|
||||
ctx.lineWidth = ringW;
|
||||
ctx.beginPath();
|
||||
ctx.arc(cx, cy, Rr - ringW / 2, 0, Math.PI * 2);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
const fontPx = Math.max(12, Math.min(size * 0.135, (Math.PI * Rr * 0.82) / Math.max([...mainText.value].length, 1) * 1.6));
|
||||
drawArcText(ctx, mainText.value, cx, cy, Rr * 0.76, fontPx, paper);
|
||||
|
||||
if (style.value === 'circle-star') {
|
||||
drawStar(ctx, cx, cy + size * 0.01, Rr * 0.26, paper);
|
||||
}
|
||||
if (subText.value.trim()) {
|
||||
ctx.save();
|
||||
ctx.fillStyle = paper;
|
||||
const subFont = Math.max(10, size * (style.value === 'circle-star' ? 0.075 : 0.13));
|
||||
ctx.font = `bold ${subFont}px "Microsoft YaHei", "PingFang SC", sans-serif`;
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
ctx.fillText(subText.value, cx, cy + (style.value === 'circle-star' ? size * 0.3 : size * 0.02));
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
sealDataUrl.value = c.toDataURL('image/png');
|
||||
const b64 = sealDataUrl.value.split(',')[1];
|
||||
const bin = atob(b64);
|
||||
const bytes = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; i++) {
|
||||
bytes[i] = bin.charCodeAt(i);
|
||||
}
|
||||
sealPngBytes.value = bytes;
|
||||
}
|
||||
|
||||
function downloadSeal() {
|
||||
const a = document.createElement('a');
|
||||
a.href = sealDataUrl.value;
|
||||
a.download = `${mainText.value || '印章'}.png`;
|
||||
a.click();
|
||||
genHist.add({ title: `生成印章: ${mainText.value}`, detail: `${sealSize.value}px · ${color.value}${invert.value ? ' · 反转' : ''}` });
|
||||
}
|
||||
|
||||
function resetSeal() {
|
||||
style.value = 'circle-star';
|
||||
mainText.value = '在线工具大全示例专用章';
|
||||
subText.value = '合同专用章';
|
||||
sealSize.value = 300;
|
||||
color.value = '#E60012';
|
||||
invert.value = false;
|
||||
renderSeal();
|
||||
}
|
||||
|
||||
// ============ 盖章到文件 ============
|
||||
const targetFile = ref<File | null>(null);
|
||||
const targetKind = ref<'image' | 'pdf' | null>(null);
|
||||
const stampBusy = ref(false);
|
||||
const stampError = ref('');
|
||||
const stampResultUrl = ref('');
|
||||
const stampResultName = ref('');
|
||||
const stampResultSize = ref(0);
|
||||
const stampSpent = ref(0);
|
||||
|
||||
// 印章参数
|
||||
const stampWidthMm = ref(40);
|
||||
const stampOpacity = ref(85);
|
||||
const stampRotation = ref(0);
|
||||
const stampPos = ref<'edge' | 'br' | 'bl' | 'center'>('edge');
|
||||
const stampVertical = ref<'top' | 'center' | 'bottom'>('center');
|
||||
const stampAllPages = ref(true);
|
||||
const startPage = ref(1);
|
||||
const endPage = ref(1);
|
||||
const pageCount = ref(0);
|
||||
|
||||
const fileInput = ref<HTMLInputElement>();
|
||||
const imagePreviewUrl = ref('');
|
||||
|
||||
function pickTarget() {
|
||||
fileInput.value?.click();
|
||||
}
|
||||
|
||||
function onTargetInput(e: Event) {
|
||||
const input = e.target as HTMLInputElement;
|
||||
setTarget(input.files?.[0] ?? null);
|
||||
input.value = '';
|
||||
}
|
||||
|
||||
function onTargetDrop(e: DragEvent) {
|
||||
setTarget(e.dataTransfer?.files?.[0] ?? null);
|
||||
}
|
||||
|
||||
function setTarget(f: File | null) {
|
||||
targetFile.value = f;
|
||||
stampError.value = '';
|
||||
stampResultUrl.value = '';
|
||||
imagePreviewUrl.value = '';
|
||||
pageCount.value = 0;
|
||||
if (!f) {
|
||||
targetKind.value = null;
|
||||
return;
|
||||
}
|
||||
const isPdf = f.type === 'application/pdf' || f.name.toLowerCase().endsWith('.pdf');
|
||||
const isImg = f.type.startsWith('image/');
|
||||
if (isPdf) {
|
||||
targetKind.value = 'pdf';
|
||||
}
|
||||
else if (isImg) {
|
||||
targetKind.value = 'image';
|
||||
imagePreviewUrl.value = URL.createObjectURL(f);
|
||||
}
|
||||
else {
|
||||
targetKind.value = null;
|
||||
stampError.value = '仅支持图片(PNG/JPG等)或 PDF 文件';
|
||||
return;
|
||||
}
|
||||
if (isPdf) {
|
||||
countPages(f);
|
||||
}
|
||||
}
|
||||
|
||||
async function countPages(f: File) {
|
||||
try {
|
||||
const { PDFDocument } = await import('@cantoo/pdf-lib');
|
||||
const doc = await PDFDocument.load(await f.arrayBuffer(), { ignoreEncryption: true });
|
||||
pageCount.value = doc.getPageCount();
|
||||
endPage.value = pageCount.value;
|
||||
}
|
||||
catch {
|
||||
pageCount.value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
async function stampImage() {
|
||||
const f = targetFile.value;
|
||||
if (!f || !sealPngBytes.value) {
|
||||
return;
|
||||
}
|
||||
const t0 = Date.now();
|
||||
const img = new Image();
|
||||
const url = URL.createObjectURL(f);
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
img.onload = () => resolve();
|
||||
img.onerror = () => reject(new Error('图片加载失败'));
|
||||
img.src = url;
|
||||
});
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = img.naturalWidth;
|
||||
canvas.height = img.naturalHeight;
|
||||
const ctx = canvas.getContext('2d')!;
|
||||
ctx.drawImage(img, 0, 0);
|
||||
URL.revokeObjectURL(url);
|
||||
|
||||
const w = Math.round((canvas.width * stampWidthMm.value) / 100); // 图片模式下宽度按百分比
|
||||
const h = w;
|
||||
const margin = Math.round(Math.min(canvas.width, canvas.height) * 0.05);
|
||||
let cx = canvas.width - w / 2 - margin;
|
||||
let cy = canvas.height - h / 2 - margin;
|
||||
if (stampPos.value === 'bl') {
|
||||
cx = w / 2 + margin;
|
||||
}
|
||||
else if (stampPos.value === 'center') {
|
||||
cx = canvas.width / 2;
|
||||
cy = canvas.height / 2;
|
||||
}
|
||||
|
||||
const sealImg = new Image();
|
||||
sealImg.src = sealDataUrl.value;
|
||||
await new Promise<void>((resolve) => {
|
||||
sealImg.onload = () => resolve();
|
||||
});
|
||||
ctx.save();
|
||||
ctx.globalAlpha = stampOpacity.value / 100;
|
||||
ctx.translate(cx, cy);
|
||||
ctx.rotate((stampRotation.value * Math.PI) / 180);
|
||||
ctx.drawImage(sealImg, -w / 2, -h / 2, w, h);
|
||||
ctx.restore();
|
||||
|
||||
const blob: Blob | null = await new Promise(res => canvas.toBlob(res, 'image/png'));
|
||||
if (stampResultUrl.value) {
|
||||
URL.revokeObjectURL(stampResultUrl.value);
|
||||
}
|
||||
stampResultUrl.value = URL.createObjectURL(blob!);
|
||||
stampResultSize.value = blob!.size;
|
||||
stampResultName.value = f.name.replace(/\\.[^.]+$/, '') + '-盖章.png';
|
||||
stampSpent.value = Math.round((Date.now() - t0) / 1000);
|
||||
}
|
||||
|
||||
async function stampPdf() {
|
||||
const f = targetFile.value;
|
||||
if (!f || !sealPngBytes.value) {
|
||||
return;
|
||||
}
|
||||
const t0 = Date.now();
|
||||
const { PDFDocument, degrees } = await import('@cantoo/pdf-lib');
|
||||
const doc = await PDFDocument.load(await f.arrayBuffer(), { ignoreEncryption: true });
|
||||
const png = await doc.embedPng(sealPngBytes.value);
|
||||
const pages = doc.getPages();
|
||||
const w = (stampWidthMm.value * 72) / 25.4;
|
||||
const h = w;
|
||||
const from = stampAllPages.value ? 1 : Math.max(1, startPage.value);
|
||||
const to = stampAllPages.value ? pages.length : Math.min(pages.length, endPage.value);
|
||||
const margin = (12 * 72) / 25.4;
|
||||
const theta = (stampRotation.value * Math.PI) / 180;
|
||||
const cos = Math.cos(theta);
|
||||
const sin = Math.sin(theta);
|
||||
const offsetX = (w / 2) * cos - (h / 2) * sin - w / 2;
|
||||
const offsetY = (w / 2) * sin + (h / 2) * cos - h / 2;
|
||||
|
||||
for (let i = from - 1; i < to; i++) {
|
||||
const page = pages[i];
|
||||
const { width, height } = page.getSize();
|
||||
let tcx: number;
|
||||
let tcy: number;
|
||||
if (stampPos.value === 'edge') {
|
||||
tcx = width; // 骑缝:印章中心贴右边缘,半枚在页外
|
||||
tcy = stampVertical.value === 'top' ? height - margin - h / 2
|
||||
: stampVertical.value === 'bottom' ? margin + h / 2
|
||||
: height / 2;
|
||||
}
|
||||
else if (stampPos.value === 'br') {
|
||||
tcx = width - margin - w / 2;
|
||||
tcy = margin + h / 2;
|
||||
}
|
||||
else if (stampPos.value === 'bl') {
|
||||
tcx = margin + w / 2;
|
||||
tcy = margin + h / 2;
|
||||
}
|
||||
else {
|
||||
tcx = width / 2;
|
||||
tcy = height / 2;
|
||||
}
|
||||
page.drawImage(png, {
|
||||
x: tcx + offsetX,
|
||||
y: tcy + offsetY,
|
||||
width: w,
|
||||
height: h,
|
||||
rotate: degrees(stampRotation.value),
|
||||
opacity: stampOpacity.value / 100,
|
||||
});
|
||||
}
|
||||
|
||||
const bytes = await doc.save();
|
||||
const blob = new Blob([bytes as unknown as BlobPart], { type: 'application/pdf' });
|
||||
if (stampResultUrl.value) {
|
||||
URL.revokeObjectURL(stampResultUrl.value);
|
||||
}
|
||||
stampResultUrl.value = URL.createObjectURL(blob);
|
||||
stampResultSize.value = blob.size;
|
||||
stampResultName.value = f.name.replace(/\.pdf$/i, '') + '-盖章.pdf';
|
||||
stampSpent.value = Math.round((Date.now() - t0) / 1000);
|
||||
}
|
||||
|
||||
async function doStamp() {
|
||||
if (!sealReady.value) {
|
||||
stampError.value = '请先生成印章';
|
||||
return;
|
||||
}
|
||||
if (!targetFile.value) {
|
||||
stampError.value = '请先上传要盖章的文件';
|
||||
return;
|
||||
}
|
||||
stampBusy.value = true;
|
||||
stampError.value = '';
|
||||
try {
|
||||
if (targetKind.value === 'image') {
|
||||
await stampImage();
|
||||
}
|
||||
else {
|
||||
await stampPdf();
|
||||
}
|
||||
genHist.add({
|
||||
title: `盖章: ${targetFile.value.name}`,
|
||||
detail: `→ ${stampResultName.value}(${(stampResultSize.value / 1024).toFixed(0)}KB, ${stampSpent.value}s)`,
|
||||
});
|
||||
}
|
||||
catch (e: any) {
|
||||
stampError.value = String(e?.message || e);
|
||||
}
|
||||
finally {
|
||||
stampBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function downloadStamped() {
|
||||
const a = document.createElement('a');
|
||||
a.href = stampResultUrl.value;
|
||||
a.download = stampResultName.value;
|
||||
a.click();
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
renderSeal();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="sm-root">
|
||||
<div class="sm-cols">
|
||||
<!-- left: seal params -->
|
||||
<div class="sm-left">
|
||||
<div class="sm-panel">
|
||||
<div class="sm-panel-title">⚙️ 印章参数</div>
|
||||
<div class="sm-field">
|
||||
<label class="sm-label">印章样式</label>
|
||||
<select v-model="style" class="sm-select" @change="renderSeal">
|
||||
<option value="circle-star">圆形公章(五角星)</option>
|
||||
<option value="circle-text">圆形章(文字居中)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="sm-field">
|
||||
<label class="sm-label">主文字(环绕上方)</label>
|
||||
<input v-model="mainText" class="sm-input" maxlength="20" @input="renderSeal">
|
||||
</div>
|
||||
<div class="sm-field">
|
||||
<label class="sm-label">中心文字</label>
|
||||
<input v-model="subText" class="sm-input" maxlength="12" @input="renderSeal">
|
||||
</div>
|
||||
<div class="sm-row">
|
||||
<div class="sm-field">
|
||||
<label class="sm-label">大小 {{ sealSize }}px</label>
|
||||
<input v-model.number="sealSize" type="range" min="120" max="600" step="10" class="sm-slider" @input="renderSeal">
|
||||
</div>
|
||||
<div class="sm-field sm-field-color">
|
||||
<label class="sm-label">颜色</label>
|
||||
<div class="sm-color-row">
|
||||
<input v-model="color" class="sm-input sm-input-color" @input="renderSeal">
|
||||
<input v-model="color" type="color" class="swatch" @input="renderSeal">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sm-field">
|
||||
<label class="sm-label">颜色模式</label>
|
||||
<div class="sm-radios">
|
||||
<label><input v-model="invert" type="radio" :value="false" @change="renderSeal"> 正常(红字白底)</label>
|
||||
<label><input v-model="invert" type="radio" :value="true" @change="renderSeal"> 反转(白字红底)</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sm-btns">
|
||||
<button class="sm-btn" @click="downloadSeal">
|
||||
⬇ 下载 PNG
|
||||
</button>
|
||||
<button class="sm-btn sm-btn-ghost" @click="resetSeal">
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- stamp target -->
|
||||
<div class="sm-panel">
|
||||
<div class="sm-panel-title">📎 盖章到文件 <span class="sm-panel-sub">图片 / PDF · 全程本地处理</span></div>
|
||||
<div class="sm-drop" @click="pickTarget" @dragover.prevent @drop.prevent="onTargetDrop">
|
||||
<input ref="fileInput" type="file" hidden accept="image/*,.pdf" @change="onTargetInput">
|
||||
<template v-if="!targetFile">
|
||||
<div class="sm-drop-hint">📁 拖拽或点击上传图片 / PDF</div>
|
||||
</template>
|
||||
<div v-else class="sm-file">
|
||||
{{ targetKind === 'pdf' ? '📄' : '🖼️' }} {{ targetFile.name }}
|
||||
<span class="sm-file-size">({{ (targetFile.size / 1024 / 1024).toFixed(1) }} MB{{ targetKind === 'pdf' && pageCount ? ` · ${pageCount} 页` : '' }})</span>
|
||||
<a href="javascript:;" class="sm-clear" @click.stop="setTarget(null)">✕</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sm-row">
|
||||
<div class="sm-field">
|
||||
<label class="sm-label">{{ targetKind === 'image' ? '印章宽度' : '印章宽度' }}({{ targetKind === 'image' ? '%' : 'mm' }})</label>
|
||||
<input v-model.number="stampWidthMm" type="range" :min="targetKind === 'image' ? 5 : 15" :max="targetKind === 'image' ? 60 : 80" step="1" class="sm-slider">
|
||||
<span class="sm-val">{{ stampWidthMm }}{{ targetKind === 'image' ? '%' : 'mm' }}</span>
|
||||
</div>
|
||||
<div class="sm-field">
|
||||
<label class="sm-label">透明度 {{ stampOpacity }}%</label>
|
||||
<input v-model.number="stampOpacity" type="range" min="10" max="100" step="5" class="sm-slider">
|
||||
</div>
|
||||
</div>
|
||||
<div class="sm-row">
|
||||
<div class="sm-field">
|
||||
<label class="sm-label">位置</label>
|
||||
<select v-model="stampPos" class="sm-select">
|
||||
<option value="edge">{{ targetKind === 'image' ? '右下角' : '骑缝章(右边缘)' }}</option>
|
||||
<option value="br">右下角</option>
|
||||
<option value="bl">左下角</option>
|
||||
<option value="center">居中</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="sm-field">
|
||||
<label class="sm-label">旋转 {{ stampRotation }}°</label>
|
||||
<input v-model.number="stampRotation" type="range" min="-30" max="30" step="1" class="sm-slider">
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="targetKind === 'pdf' && stampPos === 'edge'" class="sm-field">
|
||||
<label class="sm-label">垂直位置</label>
|
||||
<select v-model="stampVertical" class="sm-select">
|
||||
<option value="top">顶部</option>
|
||||
<option value="center">居中</option>
|
||||
<option value="bottom">底部</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-if="targetKind === 'pdf'" class="sm-field">
|
||||
<label class="sm-label">签章范围</label>
|
||||
<div class="sm-radios">
|
||||
<label><input v-model="stampAllPages" type="radio" :value="true"> 全部页{{ pageCount ? `(${pageCount} 页)` : '' }}</label>
|
||||
<label><input v-model="stampAllPages" type="radio" :value="false"> 指定页</label>
|
||||
</div>
|
||||
<div v-if="!stampAllPages" class="sm-range">
|
||||
起始页 <input v-model.number="startPage" type="number" min="1" class="sm-num"> 结束页 <input v-model.number="endPage" type="number" min="1" class="sm-num">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sm-btns">
|
||||
<button class="sm-btn" :disabled="stampBusy || !targetFile" @click="doStamp">
|
||||
{{ stampBusy ? '⏳ 盖章中…' : '🚀 生成并下载' }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="stampError" class="sm-error">
|
||||
{{ stampError }}
|
||||
</div>
|
||||
<div v-if="stampResultUrl" class="sm-result">
|
||||
<span class="sm-result-name">✓ {{ stampResultName }}({{ (stampResultSize / 1024).toFixed(0) }} KB · {{ stampSpent }}s)</span>
|
||||
<button class="sm-btn sm-btn-sm" @click="downloadStamped">
|
||||
⬇ 下载
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- right: previews -->
|
||||
<div class="sm-right">
|
||||
<div class="sm-panel">
|
||||
<div class="sm-panel-title">🔴 印章预览</div>
|
||||
<div class="sm-seal-box">
|
||||
<canvas ref="sealCanvas" class="sm-seal-canvas" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="sm-panel">
|
||||
<div class="sm-panel-title">📄 文件预览</div>
|
||||
<div class="sm-preview-box">
|
||||
<img v-if="targetKind === 'image' && imagePreviewUrl" :src="imagePreviewUrl" class="sm-preview-img" alt="preview">
|
||||
<div v-else-if="targetKind === 'pdf'" class="sm-preview-page">
|
||||
<div class="sm-preview-paper">
|
||||
<div class="sm-preview-stamp" :class="`pos-${stampPos}`" :style="{ opacity: stampOpacity / 100, transform: `translate(-50%, -50%) rotate(${stampRotation}deg)` }">
|
||||
<img :src="sealDataUrl" alt="seal">
|
||||
</div>
|
||||
</div>
|
||||
<div class="sm-preview-label">PDF · {{ pageCount || '?' }} 页 · {{ stampPos === 'edge' ? '骑缝章' : '角章' }}示意</div>
|
||||
</div>
|
||||
<div v-else class="sm-preview-empty">
|
||||
上传图片或 PDF 后查看
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<GenHistory tool="seal-maker" label="印章记录" class="mt-10px" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.sm-root {
|
||||
padding-bottom: 16px;
|
||||
}
|
||||
|
||||
.sm-cols {
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.sm-left {
|
||||
width: 420px;
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.sm-right {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.sm-panel {
|
||||
border: 1px solid rgba(128, 128, 128, 0.22);
|
||||
border-radius: 12px;
|
||||
padding: 12px 14px;
|
||||
background: #fff;
|
||||
|
||||
.sm-panel-title {
|
||||
font-size: 14px;
|
||||
font-weight: 800;
|
||||
margin-bottom: 10px;
|
||||
|
||||
.sm-panel-sub {
|
||||
font-size: 11px;
|
||||
font-weight: 400;
|
||||
opacity: 0.5;
|
||||
margin-left: 6px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sm-field {
|
||||
margin-bottom: 10px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
.sm-label {
|
||||
display: block;
|
||||
font-size: 11.5px;
|
||||
opacity: 0.65;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
.sm-select,
|
||||
.sm-input {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid rgba(128, 128, 128, 0.35);
|
||||
border-radius: 7px;
|
||||
padding: 6px 10px;
|
||||
font-size: 13px;
|
||||
background: #fff;
|
||||
outline: none;
|
||||
|
||||
&:focus {
|
||||
border-color: #18a058;
|
||||
}
|
||||
}
|
||||
|
||||
.sm-slider {
|
||||
width: calc(100% - 56px);
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.sm-val {
|
||||
font-size: 11.5px;
|
||||
opacity: 0.6;
|
||||
margin-left: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.sm-row {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
|
||||
.sm-field-color {
|
||||
width: 150px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.sm-color-row {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
|
||||
.sm-input-color {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.swatch {
|
||||
width: 34px;
|
||||
height: 30px;
|
||||
border: 1px solid rgba(128, 128, 128, 0.35);
|
||||
border-radius: 7px;
|
||||
padding: 1px;
|
||||
background: #fff;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.sm-radios {
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
font-size: 12.5px;
|
||||
align-items: center;
|
||||
|
||||
label {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.sm-range {
|
||||
margin-top: 6px;
|
||||
font-size: 12.5px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
|
||||
.sm-num {
|
||||
width: 64px;
|
||||
border: 1px solid rgba(128, 128, 128, 0.35);
|
||||
border-radius: 6px;
|
||||
padding: 4px 8px;
|
||||
font-size: 12.5px;
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
|
||||
.sm-btns {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.sm-btn {
|
||||
background: #18a058;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
padding: 8px 18px;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.45;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
&.sm-btn-ghost {
|
||||
background: #fff;
|
||||
color: inherit;
|
||||
border: 1px solid rgba(128, 128, 128, 0.35);
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
&.sm-btn-sm {
|
||||
padding: 5px 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.sm-drop {
|
||||
border: 1.5px dashed rgba(128, 128, 128, 0.4);
|
||||
border-radius: 9px;
|
||||
text-align: center;
|
||||
padding: 12px;
|
||||
cursor: pointer;
|
||||
margin-bottom: 10px;
|
||||
transition: border-color 0.15s;
|
||||
|
||||
&:hover {
|
||||
border-color: #18a058;
|
||||
}
|
||||
|
||||
.sm-drop-hint {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.sm-file {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
|
||||
.sm-file-size {
|
||||
font-weight: 400;
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
.sm-clear {
|
||||
color: #d03050;
|
||||
margin-left: 8px;
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sm-error {
|
||||
color: #d03050;
|
||||
font-size: 12px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.sm-result {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-top: 10px;
|
||||
background: rgba(24, 160, 88, 0.07);
|
||||
border-radius: 8px;
|
||||
padding: 8px 12px;
|
||||
|
||||
.sm-result-name {
|
||||
font-size: 12px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.sm-seal-box {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 12px;
|
||||
background:
|
||||
repeating-conic-gradient(rgba(128, 128, 128, 0.06) 0% 25%, transparent 0% 50%) 0 0 / 22px 22px;
|
||||
border-radius: 10px;
|
||||
|
||||
.sm-seal-canvas {
|
||||
max-width: 300px;
|
||||
max-height: 300px;
|
||||
}
|
||||
}
|
||||
|
||||
.sm-preview-box {
|
||||
min-height: 220px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(128, 128, 128, 0.05);
|
||||
border-radius: 10px;
|
||||
padding: 12px;
|
||||
|
||||
.sm-preview-img {
|
||||
max-width: 100%;
|
||||
max-height: 320px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.sm-preview-empty {
|
||||
font-size: 12.5px;
|
||||
opacity: 0.45;
|
||||
}
|
||||
|
||||
.sm-preview-page {
|
||||
text-align: center;
|
||||
|
||||
.sm-preview-paper {
|
||||
position: relative;
|
||||
width: 200px;
|
||||
height: 283px;
|
||||
margin: 0 auto;
|
||||
background: #fff;
|
||||
border: 1px solid rgba(128, 128, 128, 0.35);
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
|
||||
overflow: hidden;
|
||||
|
||||
.sm-preview-stamp {
|
||||
position: absolute;
|
||||
width: 74px;
|
||||
|
||||
&.pos-edge {
|
||||
left: 100%;
|
||||
top: 50%;
|
||||
}
|
||||
|
||||
&.pos-br {
|
||||
left: 86%;
|
||||
top: 88%;
|
||||
}
|
||||
|
||||
&.pos-bl {
|
||||
left: 14%;
|
||||
top: 88%;
|
||||
}
|
||||
|
||||
&.pos-center {
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sm-preview-label {
|
||||
font-size: 11.5px;
|
||||
opacity: 0.5;
|
||||
margin-top: 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user