mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-05 08:55:28 +08:00
feat: Add comprehensive meta tags and a custom favicon to the web UI, and embed a new styled welcome page directly in home.py.
This commit is contained in:
11
README.MD
11
README.MD
@@ -29,13 +29,12 @@
|
||||
|
||||
### Vercel 部署(推荐)
|
||||
|
||||
[](https://vercel.com/import/project?template=https://github.com/CJackHwang/ds2api)
|
||||
[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FCJackHwang%2Fds2api&env=DS2API_ADMIN_KEY&envDescription=管理面板访问密码(必填)&envLink=https%3A%2F%2Fgithub.com%2FCJackHwang%2Fds2api%23环境变量&project-name=ds2api&repository-name=ds2api)
|
||||
|
||||
1. 点击上方按钮部署
|
||||
2. 设置环境变量 `DS2API_ADMIN_KEY`(管理密码,**必填**)
|
||||
3. 部署完成后访问 `/webui` 管理界面
|
||||
4. 添加 DeepSeek 账号和 API Key
|
||||
5. 点击「同步到 Vercel」完成配置
|
||||
1. 点击上方按钮,填写管理密码 `DS2API_ADMIN_KEY`
|
||||
2. 部署完成后访问 `/webui` 管理界面
|
||||
3. 添加 DeepSeek 账号和 API Key
|
||||
4. 点击「同步到 Vercel」保存配置
|
||||
|
||||
> **首次同步会自动验证账号、保存 Token 和 Vercel 凭证,后续操作无需再输入。**
|
||||
|
||||
|
||||
129
routes/home.py
129
routes/home.py
@@ -3,17 +3,138 @@
|
||||
import os
|
||||
from fastapi import APIRouter, Request
|
||||
from fastapi.responses import HTMLResponse, FileResponse
|
||||
from fastapi.templating import Jinja2Templates
|
||||
|
||||
from core.config import TEMPLATES_DIR, STATIC_ADMIN_DIR
|
||||
from core.config import STATIC_ADMIN_DIR
|
||||
|
||||
router = APIRouter()
|
||||
templates = Jinja2Templates(directory=TEMPLATES_DIR)
|
||||
|
||||
# 首页 HTML(内嵌避免依赖模板目录)
|
||||
WELCOME_HTML = """<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>DS2API - DeepSeek to OpenAI API</title>
|
||||
<meta name="description" content="DS2API - 将 DeepSeek 网页版转换为 OpenAI 兼容 API">
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0%25' y1='0%25' x2='100%25' y2='100%25'%3E%3Cstop offset='0%25' stop-color='%23f59e0b'/%3E%3Cstop offset='100%25' stop-color='%23ef4444'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect rx='20' width='100' height='100' fill='url(%23g)'/%3E%3Ctext x='50' y='68' font-family='Arial,sans-serif' font-size='48' font-weight='bold' fill='white' text-anchor='middle'%3EDS%3C/text%3E%3C/svg%3E">
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #fff;
|
||||
}
|
||||
.container {
|
||||
text-align: center;
|
||||
padding: 2rem;
|
||||
}
|
||||
.logo {
|
||||
font-size: 4rem;
|
||||
font-weight: bold;
|
||||
background: linear-gradient(135deg, #f59e0b, #ef4444);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.subtitle {
|
||||
color: #94a3b8;
|
||||
font-size: 1.2rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
.links {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.btn {
|
||||
display: inline-block;
|
||||
padding: 0.75rem 1.5rem;
|
||||
border-radius: 0.5rem;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
.btn-primary {
|
||||
background: linear-gradient(135deg, #f59e0b, #ef4444);
|
||||
color: #fff;
|
||||
}
|
||||
.btn-primary:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
|
||||
}
|
||||
.btn-secondary {
|
||||
border: 1px solid #475569;
|
||||
color: #94a3b8;
|
||||
}
|
||||
.btn-secondary:hover {
|
||||
border-color: #64748b;
|
||||
color: #fff;
|
||||
}
|
||||
.features {
|
||||
margin-top: 3rem;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 1.5rem;
|
||||
max-width: 800px;
|
||||
}
|
||||
.feature {
|
||||
background: rgba(255,255,255,0.05);
|
||||
padding: 1.5rem;
|
||||
border-radius: 0.75rem;
|
||||
border: 1px solid rgba(255,255,255,0.1);
|
||||
}
|
||||
.feature h3 {
|
||||
font-size: 1rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
.feature p {
|
||||
color: #94a3b8;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="logo">DS2API</div>
|
||||
<p class="subtitle">DeepSeek to OpenAI Compatible API</p>
|
||||
<div class="links">
|
||||
<a href="/webui" class="btn btn-primary">🎛️ 管理面板</a>
|
||||
<a href="/v1/models" class="btn btn-secondary">📡 API 端点</a>
|
||||
<a href="https://github.com/CJackHwang/ds2api" class="btn btn-secondary" target="_blank">📦 GitHub</a>
|
||||
</div>
|
||||
<div class="features">
|
||||
<div class="feature">
|
||||
<h3>🚀 OpenAI 兼容</h3>
|
||||
<p>完全兼容 OpenAI API 格式</p>
|
||||
</div>
|
||||
<div class="feature">
|
||||
<h3>🔄 多账号轮询</h3>
|
||||
<p>Round-Robin 负载均衡</p>
|
||||
</div>
|
||||
<div class="feature">
|
||||
<h3>🧠 深度思考</h3>
|
||||
<p>支持 R1 推理模式</p>
|
||||
</div>
|
||||
<div class="feature">
|
||||
<h3>🔍 联网搜索</h3>
|
||||
<p>DeepSeek 搜索增强</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
|
||||
@router.get("/")
|
||||
def index(request: Request):
|
||||
return templates.TemplateResponse("welcome.html", {"request": request})
|
||||
return HTMLResponse(content=WELCOME_HTML)
|
||||
|
||||
|
||||
@router.get("/webui")
|
||||
|
||||
@@ -4,10 +4,34 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<!-- SEO Meta Tags -->
|
||||
<title>DS2API - DeepSeek API 管理面板</title>
|
||||
<meta name="description" content="DS2API 管理面板 - 轻松管理 DeepSeek 账号、测试 API、同步 Vercel 配置" />
|
||||
<meta name="keywords" content="DeepSeek, API, OpenAI, 管理面板, DS2API" />
|
||||
<meta name="author" content="CJackHwang" />
|
||||
<meta name="robots" content="noindex, nofollow" />
|
||||
|
||||
<!-- Open Graph / Social -->
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:title" content="DS2API - DeepSeek API 管理面板" />
|
||||
<meta property="og:description" content="轻松管理 DeepSeek 账号、测试 API、同步 Vercel 配置" />
|
||||
<meta property="og:site_name" content="DS2API" />
|
||||
|
||||
<!-- PWA / Mobile -->
|
||||
<meta name="theme-color" content="#f59e0b" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
<meta name="apple-mobile-web-app-title" content="DS2API" />
|
||||
|
||||
<!-- Favicon - using data URI for orange-yellow gradient icon -->
|
||||
<link rel="icon" type="image/svg+xml"
|
||||
href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0%25' y1='0%25' x2='100%25' y2='100%25'%3E%3Cstop offset='0%25' stop-color='%23f59e0b'/%3E%3Cstop offset='100%25' stop-color='%23ef4444'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect rx='20' width='100' height='100' fill='url(%23g)'/%3E%3Ctext x='50' y='68' font-family='Arial,sans-serif' font-size='48' font-weight='bold' fill='white' text-anchor='middle'%3EDS%3C/text%3E%3C/svg%3E" />
|
||||
|
||||
<!-- Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap" rel="stylesheet">
|
||||
<title>DS2API 管理面板</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user