fix: 工具广场统一18000端口 + 去除电量限制 + bot头像更新
nginx反代(tools-nginx.conf): - 10个工具统一通过18000端口路径分发 - 解决/static/冲突(Lama精确匹配,其余给LibreTranslate) - 解决/api/冲突(PDF用sub_filter改为/pdf-api/,/api/给imgcompress) - Overleaf兜底处理所有未匹配的绝对路径 - 前端工具卡片统一走18000端口+路径 后端: - 去除对话电量限制(validateUser中的num扣减逻辑) 前端: - bot头像更新为战知logo(蓝底白字) - LaTeX公式编辑器"复制为图片"改为"下载为图片"(解决跨域问题) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -67,7 +67,7 @@
|
||||
<div class="symbols" id="symbolBar"></div>
|
||||
<div class="actions">
|
||||
<button class="btn-primary" onclick="copyLatex()">复制公式</button>
|
||||
<button class="btn-secondary" onclick="copyImg()">复制为图片</button>
|
||||
<button class="btn-secondary" onclick="downloadImg()">下载为图片</button>
|
||||
<button class="btn-secondary" onclick="document.getElementById('input').value='';render()">清空</button>
|
||||
</div>
|
||||
<div class="templates">
|
||||
@@ -121,23 +121,26 @@ function copyLatex() {
|
||||
navigator.clipboard.writeText(document.getElementById('input').value);
|
||||
showToast('公式已复制!');
|
||||
}
|
||||
function copyImg() {
|
||||
function downloadImg() {
|
||||
const el = document.getElementById('preview');
|
||||
const svg = el.querySelector('svg') || el.querySelector('.katex');
|
||||
if (!svg) return;
|
||||
const canvas = document.createElement('canvas');
|
||||
const ctx = canvas.getContext('2d');
|
||||
const data = new XMLSerializer().serializeToString(el);
|
||||
const img = new Image();
|
||||
const blob = new Blob(['<svg xmlns="http://www.w3.org/2000/svg" width="'+el.scrollWidth+'" height="'+el.scrollHeight+'"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml" style="background:#fff;padding:20px">'+el.innerHTML+'</div></foreignObject></svg>'], {type:'image/svg+xml'});
|
||||
const url = URL.createObjectURL(blob);
|
||||
img.onload = () => {
|
||||
canvas.width = img.width * 2; canvas.height = img.height * 2;
|
||||
ctx.scale(2,2); ctx.drawImage(img, 0, 0);
|
||||
canvas.toBlob(b => { navigator.clipboard.write([new ClipboardItem({'image/png': b})]); showToast('图片已复制!'); });
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
img.src = url;
|
||||
if (!el.querySelector('.katex')) { showToast('请先输入公式'); return; }
|
||||
// 直接用 KaTeX 的 mathml/svg 渲染结果导出为 SVG 文件下载
|
||||
const w = el.scrollWidth + 40, h = el.scrollHeight + 40;
|
||||
const svgStr = `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h}">
|
||||
<rect width="100%" height="100%" fill="white"/>
|
||||
<foreignObject width="100%" height="100%">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="display:flex;align-items:center;justify-content:center;width:${w}px;height:${h}px;font-size:24px">
|
||||
${el.innerHTML}
|
||||
</div>
|
||||
</foreignObject>
|
||||
</svg>`;
|
||||
const blob = new Blob([svgStr], {type: 'image/svg+xml'});
|
||||
const a = document.createElement('a');
|
||||
a.href = URL.createObjectURL(blob);
|
||||
a.download = 'formula.svg';
|
||||
a.click();
|
||||
URL.revokeObjectURL(a.href);
|
||||
showToast('图片已下载!');
|
||||
}
|
||||
function showToast(msg) {
|
||||
const t = document.getElementById('toast');
|
||||
|
||||
Reference in New Issue
Block a user