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');
|
||||
|
||||
133
scripts/tools-nginx.conf
Normal file
133
scripts/tools-nginx.conf
Normal file
@@ -0,0 +1,133 @@
|
||||
server {
|
||||
listen 18000;
|
||||
client_max_body_size 500M;
|
||||
|
||||
# 1. Stirling PDF
|
||||
location /pdf/ {
|
||||
proxy_pass http://127.0.0.1:18080/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header Accept-Encoding "";
|
||||
proxy_buffering off;
|
||||
sub_filter_once off;
|
||||
sub_filter '"/api/' '"/pdf-api/';
|
||||
}
|
||||
location /pdf-api/ {
|
||||
proxy_pass http://127.0.0.1:18080/api/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_buffering off;
|
||||
client_max_body_size 500M;
|
||||
}
|
||||
|
||||
# 2. Excalidraw
|
||||
location /draw/ {
|
||||
proxy_pass http://127.0.0.1:18081/;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
location /assets/ { proxy_pass http://127.0.0.1:18081/assets/; }
|
||||
location /v1/ai/ {
|
||||
proxy_pass http://127.0.0.1:18082/v1/ai/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_read_timeout 60s;
|
||||
proxy_buffering off;
|
||||
}
|
||||
|
||||
# 3. TrWebOCR
|
||||
location /ocr/ {
|
||||
proxy_pass http://127.0.0.1:18083/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_buffering off;
|
||||
}
|
||||
|
||||
# 4. LibreTranslate
|
||||
location /translate/ {
|
||||
proxy_pass http://127.0.0.1:18084/;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
# 5. PPTist
|
||||
location /ppt/ {
|
||||
proxy_pass http://127.0.0.1:18085/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_buffering off;
|
||||
}
|
||||
location /pptapi/ {
|
||||
proxy_pass http://127.0.0.1:18086/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
proxy_buffering off;
|
||||
proxy_cache off;
|
||||
}
|
||||
|
||||
# 6. imgcompress
|
||||
location /imgcompress/ {
|
||||
proxy_pass http://127.0.0.1:18087/;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
# 7. Lama Cleaner
|
||||
location /lama/ {
|
||||
proxy_pass http://127.0.0.1:18088/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_buffering off;
|
||||
}
|
||||
location /lama/inpaint {
|
||||
proxy_pass http://127.0.0.1:18088/inpaint;
|
||||
proxy_set_header Host $host;
|
||||
proxy_buffering off;
|
||||
proxy_read_timeout 300s;
|
||||
client_max_body_size 500M;
|
||||
}
|
||||
# Lama Cleaner 的2个精确static文件
|
||||
location /static/js/main.1bd455bc.js { proxy_pass http://127.0.0.1:18088/static/js/main.1bd455bc.js; }
|
||||
location /static/css/main.c28d98ca.css { proxy_pass http://127.0.0.1:18088/static/css/main.c28d98ca.css; }
|
||||
|
||||
# /static/ 其余的给 LibreTranslate
|
||||
location /static/ { proxy_pass http://127.0.0.1:18084/static/; }
|
||||
|
||||
# LibreTranslate 绝对路径 API
|
||||
location /languages { proxy_pass http://127.0.0.1:18084/languages; }
|
||||
location /frontend/settings { proxy_pass http://127.0.0.1:18084/frontend/settings; }
|
||||
location /detect { proxy_pass http://127.0.0.1:18084/detect; }
|
||||
|
||||
# imgcompress 绝对路径
|
||||
location /_next/ { proxy_pass http://127.0.0.1:18087/_next/; }
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:18087/api/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_buffering off;
|
||||
client_max_body_size 500M;
|
||||
}
|
||||
|
||||
# 8. webp2jpg
|
||||
location /webp2jpg/ {
|
||||
proxy_pass http://127.0.0.1:18089/;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
location /cdn/ { proxy_pass http://127.0.0.1:18089/cdn/; }
|
||||
|
||||
# 9. Overleaf
|
||||
location /overleaf/ {
|
||||
proxy_pass http://127.0.0.1:18090/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_buffering off;
|
||||
}
|
||||
|
||||
# 10. LaTeX 公式编辑器
|
||||
location /latex/ {
|
||||
proxy_pass http://127.0.0.1:18091/;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
# 默认回落到 Overleaf
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:18090;
|
||||
proxy_set_header Host $host;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_buffering off;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user