feat: 手写签名 — 浏览器本地手写(鼠标/触屏/笔), 笔触随机度模拟真实书写, 透明PNG裁剪导出, 签章到图片/PDF(宽度/透明度/旋转/页码范围), 受控授权

This commit is contained in:
personal82555 committed 2026-10-12 17:00:20 +08:00
1 parent b374cc31b2
commit b93a155c41
9 files changed
+901 -3

No files matched your search

+1 -1
View File
@@ -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', '/seal-maker']);
const WIDE_TOOLS = new Set(['/label-designer', '/json-prettify', '/pdf-tools', '/image-tools', '/doc-convert', '/video-tools', '/seal-maker', '/signature-pad']);
const isWide = computed(() => WIDE_TOOLS.has(route.path));
const i18nKey = computed<string>(() => route.path.trim().replace('/', ''));
+2 -1
View File
@@ -84,6 +84,7 @@ 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 signaturePad } from './signature-pad';
import { tool as docConvert } from './doc-convert';
import { tool as aiRetouch } from './ai-retouch';
import { tool as wifiQrCodeGenerator } from './wifi-qr-code-generator';
@@ -155,7 +156,7 @@ export const toolsByCategory: ToolCategory[] = [
},
{
name: 'Images and videos',
components: [qrCodeGenerator, wifiQrCodeGenerator, batchBarcodeGenerator, codeReader, imageOcr, pdfOcr, pdfTools, imageTools, videoTools, audioTools, sealMaker, docConvert, aiRetouch, labelDesigner, siteBookmarks, svgPlaceholderGenerator, cameraRecorder],
components: [qrCodeGenerator, wifiQrCodeGenerator, batchBarcodeGenerator, codeReader, imageOcr, pdfOcr, pdfTools, imageTools, videoTools, audioTools, sealMaker, signaturePad, docConvert, aiRetouch, labelDesigner, siteBookmarks, svgPlaceholderGenerator, cameraRecorder],
},
{
name: 'Development',
+1
View File
@@ -17,6 +17,7 @@ export const PROTECTED_TOOLS: Record<string, string> = {
'/video-tools': '视频工具',
'/audio-tools': '音频工具',
'/seal-maker': '印章生成',
'/signature-pad': '手写签名',
};
export const TRIAL_MS = 30 * 60 * 1000; // 每个功能免费 30 分钟
+12
View File
@@ -0,0 +1,12 @@
import { Signature } from '@vicons/tabler';
import { defineTool } from '../tool';
import { translate } from '@/plugins/i18n.plugin';
export const tool = defineTool({
name: translate('tools.signature-pad.title'),
path: '/signature-pad',
description: translate('tools.signature-pad.description'),
keywords: ['signature', 'sign', '签名', '手写', '电子签名', '签字', '合同'],
component: () => import('./signature-pad.vue'),
icon: Signature,
});
+877
View File
@@ -0,0 +1,877 @@
<script setup lang="ts">
import { computed, 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('signature-pad');
// ============ 手写参数 ============
const canvasW = ref(800);
const canvasH = ref(300);
const lineWidth = ref(2.5);
const lineJitter = ref(0.5); // 线宽随机浮动,模拟真实笔触
const fgColor = ref('#e71b1b');
const bgColor = ref(''); // 空 = 透明
interface Stroke {
color: string;
width: number;
points: { x: number; y: number }[];
}
const strokes = ref<Stroke[]>([]);
const hasSign = computed(() => strokes.value.length > 0);
const signCanvas = ref<HTMLCanvasElement>();
let currentStroke: Stroke | null = null;
function redraw() {
const c = signCanvas.value;
if (!c) {
return;
}
const ctx = c.getContext('2d')!;
ctx.clearRect(0, 0, c.width, c.height);
if (bgColor.value) {
ctx.fillStyle = bgColor.value;
ctx.fillRect(0, 0, c.width, c.height);
}
ctx.lineCap = 'round';
ctx.lineJoin = 'round';
for (const s of strokes.value) {
const pts = s.points;
if (pts.length < 2) {
if (pts.length === 1) {
ctx.fillStyle = s.color;
ctx.beginPath();
ctx.arc(pts[0].x, pts[0].y, s.width / 2, 0, Math.PI * 2);
ctx.fill();
}
continue;
}
ctx.strokeStyle = s.color;
for (let i = 1; i < pts.length; i++) {
const p0 = pts[i - 1];
const p1 = pts[i];
ctx.lineWidth = s.width + (Math.random() - 0.5) * lineJitter.value;
ctx.beginPath();
ctx.moveTo(p0.x, p0.y);
ctx.lineTo(p1.x, p1.y);
ctx.stroke();
}
}
}
function resizeCanvas() {
const c = signCanvas.value;
if (!c) {
return;
}
c.width = canvasW.value;
c.height = canvasH.value;
redraw();
}
function evPos(e: PointerEvent) {
const c = signCanvas.value!;
const rect = c.getBoundingClientRect();
return {
x: ((e.clientX - rect.left) * c.width) / rect.width,
y: ((e.clientY - rect.top) * c.height) / rect.height,
};
}
function onDown(e: PointerEvent) {
const c = signCanvas.value;
if (!c) {
return;
}
c.setPointerCapture(e.pointerId);
currentStroke = { color: fgColor.value, width: lineWidth.value, points: [evPos(e)] };
strokes.value.push(currentStroke);
redraw();
}
function onMove(e: PointerEvent) {
if (!currentStroke) {
return;
}
currentStroke.points.push(evPos(e));
redraw();
}
function onUp() {
currentStroke = null;
}
function clearSign() {
strokes.value = [];
redraw();
}
function resetAll() {
canvasW.value = 800;
canvasH.value = 300;
lineWidth.value = 2.5;
lineJitter.value = 0.5;
fgColor.value = '#e71b1b';
bgColor.value = '';
clearSign();
}
// ============ 导出 PNG(裁剪签名包围盒,透明底) ============
const signPngUrl = ref('');
const signPngBytes = ref<Uint8Array | null>(null);
function buildExport(): { url: string; bytes: Uint8Array } | null {
const c = signCanvas.value;
if (!c || !hasSign.value) {
return null;
}
// bbox
let minX = c.width;
let minY = c.height;
let maxX = 0;
let maxY = 0;
for (const s of strokes.value) {
for (const p of s.points) {
minX = Math.min(minX, p.x);
minY = Math.min(minY, p.y);
maxX = Math.max(maxX, p.x);
maxY = Math.max(maxY, p.y);
}
}
const pad = Math.max(12, lineWidth.value * 3);
minX = Math.max(0, minX - pad);
minY = Math.max(0, minY - pad);
maxX = Math.min(c.width, maxX + pad);
maxY = Math.min(c.height, maxY + pad);
const w = Math.max(1, Math.round(maxX - minX));
const h = Math.max(1, Math.round(maxY - minY));
const out = document.createElement('canvas');
out.width = w;
out.height = h;
const ctx = out.getContext('2d')!;
if (bgColor.value) {
ctx.fillStyle = bgColor.value;
ctx.fillRect(0, 0, w, h);
}
ctx.drawImage(c, minX, minY, w, h, 0, 0, w, h);
const url = out.toDataURL('image/png');
const b64 = url.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);
}
return { url, bytes };
}
function downloadSign() {
const ex = buildExport();
if (!ex) {
return;
}
signPngUrl.value = ex.url;
signPngBytes.value = ex.bytes;
const a = document.createElement('a');
a.href = ex.url;
a.download = '手写签名.png';
a.click();
genHist.add({ title: '生成手写签名', detail: `${ex.bytes.length}B PNG · ${fgColor.value}` });
}
// ============ 盖章到文件(签名视作印章) ============
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(50);
const stampOpacity = ref(100);
const stampRotation = ref(0);
const stampPos = ref<'br' | 'bl' | 'center'>('br');
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';
countPages(f);
}
else if (isImg) {
targetKind.value = 'image';
imagePreviewUrl.value = URL.createObjectURL(f);
}
else {
targetKind.value = null;
stampError.value = '仅支持图片或 PDF 文件';
}
}
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 ensureSignPng() {
if (!signPngBytes.value) {
const ex = buildExport();
if (!ex) {
throw new Error('请先手写签名');
}
signPngUrl.value = ex.url;
signPngBytes.value = ex.bytes;
}
}
async function stampImage() {
await ensureSignPng();
const f = targetFile.value!;
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 signImg = new Image();
signImg.src = signPngUrl.value;
await new Promise<void>((resolve) => {
signImg.onload = () => resolve();
});
const h = Math.round((w * signImg.height) / signImg.width);
const margin = Math.round(Math.min(canvas.width, canvas.height) * 0.06);
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;
}
ctx.save();
ctx.globalAlpha = stampOpacity.value / 100;
ctx.translate(cx, cy);
ctx.rotate((stampRotation.value * Math.PI) / 180);
ctx.drawImage(signImg, -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() {
await ensureSignPng();
const f = targetFile.value!;
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(signPngBytes.value);
const pages = doc.getPageCount() ? doc.getPages() : [];
const w = (stampWidthMm.value * 72) / 25.4;
const ratio = png.height / png.width;
const h = w * ratio;
const from = stampAllPages.value ? 1 : Math.max(1, startPage.value);
const to = stampAllPages.value ? pages.length : Math.min(pages.length, endPage.value);
const margin = (14 * 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();
const tcx = stampPos.value === 'br' ? width - margin - w / 2
: stampPos.value === 'bl' ? margin + w / 2
: width / 2;
const tcy = stampPos.value === 'center' ? height / 2 : margin + h / 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 (!hasSign.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();
}
</script>
<template>
<div class="sg-root">
<div class="sg-banner">
✍️ 请在画布上手写签名——签名在浏览器本地生成,不会上传到云端;下载为透明底 PNG,可直接盖章到合同文件。
</div>
<div class="sg-cols">
<!-- left: canvas -->
<div class="sg-left">
<div class="sg-canvas-wrap">
<canvas
ref="signCanvas"
class="sg-canvas"
width="800"
height="300"
@pointerdown="onDown"
@pointermove="onMove"
@pointerup="onUp"
@pointerleave="onUp"
/>
<div v-if="!hasSign" class="sg-canvas-hint">
请在此处手写签名(支持鼠标 / 触屏 / 手写笔)
</div>
</div>
<div class="sg-row">
<div class="sg-field">
<label class="sg-label">画布宽度</label>
<input v-model.number="canvasW" type="number" min="300" max="1600" class="sg-num" @change="resizeCanvas">
</div>
<div class="sg-field">
<label class="sg-label">画布高度</label>
<input v-model.number="canvasH" type="number" min="150" max="800" class="sg-num" @change="resizeCanvas">
</div>
<div class="sg-field sg-field-wide">
<label class="sg-label">线条宽度 {{ lineWidth }}px(浮动 ±{{ lineJitter }})</label>
<input v-model.number="lineWidth" type="range" min="1" max="12" step="0.5" class="sg-slider">
</div>
<div class="sg-field sg-field-wide">
<label class="sg-label">笔触随机度(越大越像真实手写)</label>
<input v-model.number="lineJitter" type="range" min="0" max="3" step="0.1" class="sg-slider">
</div>
</div>
<div class="sg-row">
<div class="sg-field">
<label class="sg-label">前景色(笔迹)</label>
<div class="sg-color-row">
<input v-model="fgColor" class="sg-input sg-input-color" @input="redraw">
<input v-model="fgColor" type="color" class="swatch">
</div>
</div>
<div class="sg-field">
<label class="sg-label">背景色(留空 = 透明)</label>
<div class="sg-color-row">
<input v-model="bgColor" class="sg-input sg-input-color" placeholder="透明" @input="redraw">
<input :value="bgColor || '#ffffff'" type="color" class="swatch" @input="bgColor = ($event.target as HTMLInputElement).value; redraw()">
<a v-if="bgColor" href="javascript:;" class="sg-clear-bg" @click="bgColor = ''; redraw()">透明</a>
</div>
</div>
</div>
<div class="sg-btns">
<button class="sg-btn" :disabled="!hasSign" @click="downloadSign">
⬇ 下载 PNG
</button>
<button class="sg-btn sg-btn-ghost" :disabled="!hasSign" @click="clearSign">
清空
</button>
<button class="sg-btn sg-btn-ghost" @click="resetAll">
重置全部
</button>
</div>
</div>
<!-- right: stamp to file -->
<div class="sg-right">
<div class="sg-panel">
<div class="sg-panel-title">📎 签名到文件 <span class="sg-panel-sub">图片 / PDF · 全程本地处理</span></div>
<div class="sg-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="sg-drop-hint">📁 拖拽或点击上传合同图片 / PDF</div>
</template>
<div v-else class="sg-file">
{{ targetKind === 'pdf' ? '📄' : '🖼️' }} {{ targetFile.name }}
<span class="sg-file-size">({{ (targetFile.size / 1024 / 1024).toFixed(1) }} MB{{ targetKind === 'pdf' && pageCount ? ` · ${pageCount} 页` : '' }})</span>
<a href="javascript:;" class="sg-clear-file" @click.stop="setTarget(null)">✕</a>
</div>
</div>
<div class="sg-row">
<div class="sg-field">
<label class="sg-label">签名宽度({{ targetKind === 'image' ? '% 图宽' : 'mm' }})</label>
<input v-model.number="stampWidthMm" type="range" :min="targetKind === 'image' ? 10 : 25" :max="targetKind === 'image' ? 60 : 90" step="1" class="sg-slider">
<span class="sg-val">{{ stampWidthMm }}{{ targetKind === 'image' ? '%' : 'mm' }}</span>
</div>
<div class="sg-field">
<label class="sg-label">透明度 {{ stampOpacity }}%</label>
<input v-model.number="stampOpacity" type="range" min="10" max="100" step="5" class="sg-slider">
</div>
</div>
<div class="sg-row">
<div class="sg-field">
<label class="sg-label">位置</label>
<select v-model="stampPos" class="sg-select">
<option value="br">右下角</option>
<option value="bl">左下角</option>
<option value="center">居中</option>
</select>
</div>
<div class="sg-field">
<label class="sg-label">旋转 {{ stampRotation }}°</label>
<input v-model.number="stampRotation" type="range" min="-20" max="20" step="1" class="sg-slider">
</div>
</div>
<div v-if="targetKind === 'pdf'" class="sg-field">
<label class="sg-label">签章范围</label>
<div class="sg-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="sg-range">
起始页 <input v-model.number="startPage" type="number" min="1" class="sg-num-sm"> 结束页 <input v-model.number="endPage" type="number" min="1" class="sg-num-sm">
</div>
</div>
<div class="sg-btns">
<button class="sg-btn" :disabled="stampBusy || !targetFile" @click="doStamp">
{{ stampBusy ? '⏳ 签署中…' : '🚀 签署并下载' }}
</button>
</div>
<div v-if="stampError" class="sg-error">
{{ stampError }}
</div>
<div v-if="stampResultUrl" class="sg-result">
<span class="sg-result-name">✓ {{ stampResultName }}({{ (stampResultSize / 1024).toFixed(0) }} KB · {{ stampSpent }}s)</span>
<button class="sg-btn sg-btn-sm" @click="downloadStamped">
⬇ 下载
</button>
</div>
</div>
<div class="sg-panel">
<div class="sg-panel-title">🖨️ 签名预览</div>
<div class="sg-sign-preview">
<img v-if="signPngUrl" :src="signPngUrl" alt="signature">
<span v-else class="sg-sign-empty">{{ hasSign ? '点击「下载 PNG」生成透明签名' : '手写后在此预览' }}</span>
</div>
</div>
<GenHistory tool="signature-pad" label="签名记录" class="mt-10px" />
</div>
</div>
</div>
</template>
<style lang="less" scoped>
.sg-root {
padding-bottom: 16px;
}
.sg-banner {
border-left: 4px solid #18a058;
background: rgba(128, 128, 128, 0.07);
border-radius: 8px;
padding: 9px 14px;
font-size: 12.5px;
opacity: 0.85;
margin-bottom: 12px;
}
.sg-cols {
display: flex;
gap: 14px;
align-items: flex-start;
}
.sg-left {
flex: 1;
min-width: 0;
}
.sg-right {
width: 400px;
flex-shrink: 0;
}
.sg-canvas-wrap {
position: relative;
border: 1.5px dashed rgba(128, 128, 128, 0.45);
border-radius: 10px;
overflow: hidden;
background: #fff;
margin-bottom: 12px;
.sg-canvas {
display: block;
width: 100%;
cursor: crosshair;
touch-action: none;
}
.sg-canvas-hint {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
font-size: 13.5px;
opacity: 0.4;
pointer-events: none;
}
}
.sg-row {
display: flex;
gap: 14px;
flex-wrap: wrap;
}
.sg-field {
margin-bottom: 10px;
min-width: 120px;
&.sg-field-wide {
flex: 1;
min-width: 180px;
}
.sg-label {
display: block;
font-size: 11.5px;
opacity: 0.65;
margin-bottom: 3px;
}
.sg-num,
.sg-num-sm {
border: 1px solid rgba(128, 128, 128, 0.35);
border-radius: 7px;
padding: 5px 9px;
font-size: 12.5px;
outline: none;
width: 90px;
&:focus {
border-color: #18a058;
}
}
.sg-num-sm {
width: 60px;
}
.sg-slider {
vertical-align: middle;
}
.sg-select {
width: 100%;
box-sizing: border-box;
border: 1px solid rgba(128, 128, 128, 0.35);
border-radius: 7px;
padding: 5px 9px;
font-size: 12.5px;
background: #fff;
outline: none;
}
.sg-val {
font-size: 11.5px;
opacity: 0.6;
margin-left: 6px;
}
}
.sg-color-row {
display: flex;
gap: 6px;
align-items: center;
.sg-input-color {
width: 110px;
border: 1px solid rgba(128, 128, 128, 0.35);
border-radius: 7px;
padding: 5px 9px;
font-size: 12.5px;
outline: none;
}
.swatch {
width: 32px;
height: 28px;
border: 1px solid rgba(128, 128, 128, 0.35);
border-radius: 7px;
padding: 1px;
background: #fff;
cursor: pointer;
flex-shrink: 0;
}
.sg-clear-bg {
font-size: 11.5px;
color: #18a058;
text-decoration: none;
}
}
.sg-radios {
display: flex;
gap: 14px;
font-size: 12.5px;
label {
cursor: pointer;
}
}
.sg-range {
margin-top: 6px;
font-size: 12.5px;
display: flex;
align-items: center;
gap: 6px;
}
.sg-btns {
display: flex;
gap: 8px;
margin: 4px 0 12px;
}
.sg-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;
}
&.sg-btn-ghost {
background: #fff;
color: inherit;
border: 1px solid rgba(128, 128, 128, 0.35);
font-weight: 400;
}
&.sg-btn-sm {
padding: 5px 12px;
font-size: 12px;
}
}
.sg-panel {
border: 1px solid rgba(128, 128, 128, 0.22);
border-radius: 12px;
padding: 12px 14px;
background: #fff;
margin-bottom: 12px;
.sg-panel-title {
font-size: 14px;
font-weight: 800;
margin-bottom: 10px;
.sg-panel-sub {
font-size: 11px;
font-weight: 400;
opacity: 0.5;
margin-left: 6px;
}
}
}
.sg-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;
}
.sg-drop-hint {
font-size: 13px;
font-weight: 600;
}
.sg-file {
font-size: 12.5px;
font-weight: 600;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
.sg-file-size {
font-weight: 400;
opacity: 0.55;
}
.sg-clear-file {
color: #d03050;
margin-left: 8px;
text-decoration: none;
}
}
}
.sg-error {
color: #d03050;
font-size: 12px;
}
.sg-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;
.sg-result-name {
font-size: 12px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.sg-sign-preview {
min-height: 110px;
display: flex;
align-items: center;
justify-content: center;
background:
repeating-conic-gradient(rgba(128, 128, 128, 0.06) 0% 25%, transparent 0% 50%) 0 0 / 18px 18px;
border-radius: 10px;
padding: 10px;
img {
max-width: 100%;
max-height: 140px;
}
.sg-sign-empty {
font-size: 12px;
opacity: 0.4;
}
}
</style>