Spaces:
Running
Running
File size: 10,974 Bytes
101c6cb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Studio 2 API - 管理面板</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
color: #333;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.header {
text-align: center;
margin-bottom: 40px;
color: white;
}
.header h1 {
font-size: 2.5rem;
margin-bottom: 10px;
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
.header p {
font-size: 1.2rem;
opacity: 0.9;
}
.main-content {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 30px;
margin-bottom: 40px;
}
.card {
background: white;
border-radius: 15px;
padding: 25px;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
transition: transform 0.3s ease;
}
.card:hover {
transform: translateY(-5px);
}
.card h2 {
color: #4a5568;
margin-bottom: 20px;
font-size: 1.5rem;
border-bottom: 2px solid #e2e8f0;
padding-bottom: 10px;
}
.screenshot-container {
text-align: center;
}
.screenshot {
max-width: 100%;
height: auto;
border-radius: 10px;
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
margin-bottom: 15px;
}
.config-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 0;
border-bottom: 1px solid #e2e8f0;
}
.config-item:last-child {
border-bottom: none;
}
.config-label {
font-weight: 600;
color: #4a5568;
}
.config-value {
color: #2d3748;
font-family: 'Courier New', monospace;
background: #f7fafc;
padding: 4px 8px;
border-radius: 4px;
font-size: 0.9rem;
}
.status-indicator {
display: inline-block;
width: 10px;
height: 10px;
border-radius: 50%;
margin-right: 8px;
}
.status-online {
background-color: #48bb78;
animation: pulse 2s infinite;
}
.status-offline {
background-color: #f56565;
}
@keyframes pulse {
0% { opacity: 1; }
50% { opacity: 0.5; }
100% { opacity: 1; }
}
.api-endpoints {
grid-column: 1 / -1;
}
.endpoint-list {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 15px;
}
.endpoint {
background: #f8f9fa;
padding: 15px;
border-radius: 8px;
border-left: 4px solid #667eea;
}
.endpoint-method {
font-weight: bold;
color: #667eea;
margin-right: 10px;
}
.endpoint-url {
font-family: 'Courier New', monospace;
color: #2d3748;
}
.endpoint-desc {
font-size: 0.9rem;
color: #718096;
margin-top: 5px;
}
.footer {
text-align: center;
color: white;
opacity: 0.8;
margin-top: 40px;
}
@media (max-width: 768px) {
.main-content {
grid-template-columns: 1fr;
}
.header h1 {
font-size: 2rem;
}
.container {
padding: 15px;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🤖 AI Studio 2 API</h1>
<p>Google AI Studio 到 OpenAI API 格式的转换服务</p>
</div>
<div class="main-content">
<div class="card screenshot-container">
<h2>📸 AI Studio 状态截图</h2>
<img src="/screenshots/aistudio-startup.png" alt="AI Studio 启动截图" class="screenshot" id="screenshot">
<p style="color: #718096; font-size: 0.9rem;">最后更新: <span id="lastUpdate">加载中...</span></p>
</div>
<div class="card">
<h2>⚙️ 基础配置</h2>
<div class="config-item">
<span class="config-label">服务状态</span>
<span class="config-value">
<span class="status-indicator status-online"></span>
运行中
</span>
</div>
<div class="config-item">
<span class="config-label">服务端口</span>
<span class="config-value" id="serverPort">加载中...</span>
</div>
<div class="config-item">
<span class="config-label">AI Studio URL</span>
<span class="config-value" id="aiStudioUrl">加载中...</span>
</div>
<div class="config-item">
<span class="config-label">默认模型</span>
<span class="config-value" id="defaultModel">加载中...</span>
</div>
<div class="config-item">
<span class="config-label">浏览器模式</span>
<span class="config-value" id="browserMode">加载中...</span>
</div>
<div class="config-item">
<span class="config-label">页面超时</span>
<span class="config-value" id="pageTimeout">加载中...</span>
</div>
</div>
<div class="card api-endpoints">
<h2>🔗 API 端点</h2>
<div class="endpoint-list">
<div class="endpoint">
<div>
<span class="endpoint-method">GET</span>
<span class="endpoint-url">/health</span>
</div>
<div class="endpoint-desc">健康检查端点</div>
</div>
<div class="endpoint">
<div>
<span class="endpoint-method">GET</span>
<span class="endpoint-url">/v1/models</span>
</div>
<div class="endpoint-desc">获取可用模型列表</div>
</div>
<div class="endpoint">
<div>
<span class="endpoint-method">GET</span>
<span class="endpoint-url">/v1/models/{model}</span>
</div>
<div class="endpoint-desc">获取特定模型信息</div>
</div>
<div class="endpoint">
<div>
<span class="endpoint-method">POST</span>
<span class="endpoint-url">/v1/chat/completions</span>
</div>
<div class="endpoint-desc">聊天完成 API (兼容 OpenAI 格式)</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>© 2024 AI Studio 2 API - 基于 H3 v2 构建</p>
</div>
</div>
<script>
// 获取配置信息
async function loadConfig() {
try {
// 从健康检查端点获取基本信息
const healthResponse = await fetch('/health');
const healthData = await healthResponse.json();
// 更新页面信息
document.getElementById('serverPort').textContent = window.location.port || '7860';
document.getElementById('aiStudioUrl').textContent = 'https://aistudio.google.com/prompts/new_chat';
document.getElementById('defaultModel').textContent = 'gemini-pro';
document.getElementById('browserMode').textContent = 'Headless';
document.getElementById('pageTimeout').textContent = '30000ms';
// 更新截图时间戳
updateScreenshotTimestamp();
} catch (err) {
console.error('加载配置失败:', err);
// 设置默认值
document.getElementById('serverPort').textContent = window.location.port || '7860';
document.getElementById('aiStudioUrl').textContent = 'https://aistudio.google.com/prompts/new_chat';
document.getElementById('defaultModel').textContent = 'gemini-pro';
document.getElementById('browserMode').textContent = 'Headless';
document.getElementById('pageTimeout').textContent = '30000ms';
}
}
// 更新截图时间戳
function updateScreenshotTimestamp() {
const now = new Date();
const timestamp = now.toLocaleString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
});
document.getElementById('lastUpdate').textContent = timestamp;
}
// 处理截图加载错误
document.getElementById('screenshot').onerror = function() {
this.src = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAwIiBoZWlnaHQ9IjMwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjBmMGYwIi8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxOCIgZmlsbD0iIzk5OTk5OSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iPuaIquWbvuS4jeWPr+eUqDwvdGV4dD48L3N2Zz4=';
this.alt = '截图不可用';
};
// 页面加载完成后执行
document.addEventListener('DOMContentLoaded', function() {
loadConfig();
// 每30秒刷新一次截图时间戳
setInterval(updateScreenshotTimestamp, 30000);
});
</script>
</body>
</html> |