feat(api): 新增素材检索 API 服务(图标/海报检索 + SVG 直链 + Key 鉴权 + 中文语义检索)

This commit is contained in:
sgp
2026-11-04 16:42:02 +08:00
parent 9e222877ea
commit dce05d6516
15 changed files with 1848 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
# 画个标自动部署脚本(由 Gitea webhook 触发或手动执行)
set -e
cd /opt/drawlogo
git fetch origin main && git reset --hard origin/main
echo "$(date '+%Y-%m-%d %H:%M:%S') DEPLOY ok $(git log -1 --format='%h %s')" >> /opt/drawlogo/.deploy.log
echo "部署完成: $(git log -1 --format='%h %s')"
+13
View File
@@ -0,0 +1,13 @@
[Unit]
Description=画个标 Gitea Webhook 自动部署
After=network.target
[Service]
Type=simple
User=ubuntu
ExecStart=/usr/bin/python3 /opt/drawlogo/deploy/drawlogo-webhook.py
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env python3
"""画个标 Gitea webhook 监听(push main 时自动部署)"""
import http.server, subprocess, json, os, datetime
DEPLOY_SCRIPT = '/opt/drawlogo/deploy/deploy.sh'
class Handler(http.server.BaseHTTPRequestHandler):
def do_POST(self):
length = int(self.headers.get('Content-Length', 0))
body = self.rfile.read(length)
try:
data = json.loads(body) if body else {}
ref = data.get('ref', '')
if ref == 'refs/heads/main':
subprocess.Popen(
['/bin/bash', DEPLOY_SCRIPT],
stdout=open('/opt/drawlogo/.deploy.log', 'a'),
stderr=subprocess.STDOUT
)
except Exception:
pass
self.send_response(200)
self.end_headers()
self.wfile.write(b'ok')
def log_message(self, format, *args):
pass
if __name__ == '__main__':
http.server.HTTPServer(('0.0.0.0', 7890), Handler).serve_forever()
+54
View File
@@ -0,0 +1,54 @@
# 画个标 - drawlogo.zhuig.com(纯静态站,无后端)
server {
listen 80;
listen [::]:80;
server_name drawlogo.zhuig.com;
# certbot ACME 验证
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name drawlogo.zhuig.com;
ssl_certificate /etc/letsencrypt/live/drawlogo.zhuig.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/drawlogo.zhuig.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
# 安全响应头
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; connect-src 'self' https://api.deepseek.com; img-src 'self' data: blob:;" always;
root /opt/drawlogo;
index index.html;
# 静态资源长期缓存(带 ?v= 版本号的 JS/CSS)
location ~* \.(js|css|woff2|ttf|svg|png|jpg|jpeg|gif|ico)$ {
expires 30d;
add_header Cache-Control "public, immutable";
}
# HTML 不缓存(保证入口页及时更新)
location ~* \.html$ {
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
# 默认首页
location / {
try_files $uri $uri/ $uri/index.html =404;
}
access_log /var/log/nginx/drawlogo_zhuig_access.log;
error_log /var/log/nginx/drawlogo_zhuig_error.log;
}
+34
View File
@@ -0,0 +1,34 @@
[Unit]
Description=画个标 Gitea Webhook 自动部署
After=network.target
[Service]
Type=simple
User=ubuntu
ExecStart=/usr/bin/python3 -c "
import http.server, subprocess, json
class H(http.server.BaseHTTPRequestHandler):
def do_POST(self):
length = int(self.headers.get('Content-Length', 0))
body = self.rfile.read(length)
try:
data = json.loads(body) if body else {}
ref = data.get('ref', '')
if ref == 'refs/heads/main':
subprocess.Popen(['/bin/bash', '/opt/drawlogo/deploy/deploy.sh'],
stdout=open('/opt/drawlogo/.deploy.log', 'a'),
stderr=subprocess.STDOUT)
except Exception as e:
pass
self.send_response(200)
self.end_headers()
self.wfile.write(b'ok')
def log_message(self, format, *args):
pass
http.server.HTTPServer(('127.0.0.1', 7890), H).serve_forever()
"
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target