feat: 重构为 Go Web 脚手架——在线图片识别 Web 服务 + vision-cli 独立工具

- Gin + config.yaml + SQLite 后端骨架,JWT 登录 + 管理员初始化
- web/ 原生单页:拖拽多图上传 → Agnes 免费识别 → 结果复制
- HTTP API:/api/v1/vision/analyze 免鉴权 + 令牌桶限流,支持程序直调
- cmd/vision-cli 独立 CLI 工具(复用 service 层,不依赖 Web 服务)
- build.bat / build.sh 构建脚本,移除 mcp-server
- 统一响应格式 {code, message, data},CORS/JWT/限流中间件

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-08-12 23:59:17 +08:00
parent 8bf77301bd
commit a3bbf33358
25 changed files with 1902 additions and 798 deletions

211
web/css/style.css Normal file
View File

@@ -0,0 +1,211 @@
/* ===== 基础 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
--primary: #4f6ef7;
--primary-dark: #3a55d8;
--bg: #f4f6fb;
--card: #ffffff;
--text: #1f2430;
--text-light: #6b7280;
--border: #e5e9f2;
--danger: #e5484d;
--radius: 12px;
}
body {
font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
background: var(--bg);
color: var(--text);
min-height: 100vh;
display: flex;
flex-direction: column;
}
/* ===== 顶栏 ===== */
.topbar {
background: var(--card);
border-bottom: 1px solid var(--border);
padding: 14px 28px;
display: flex;
align-items: center;
justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { font-size: 30px; }
.brand h1 { font-size: 20px; font-weight: 700; }
.brand p { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.account { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.account .user-chip {
background: #eef1fe;
color: var(--primary-dark);
padding: 6px 12px;
border-radius: 999px;
font-weight: 600;
}
/* ===== 布局 ===== */
.container {
flex: 1;
width: 100%;
max-width: 860px;
margin: 0 auto;
padding: 28px 20px;
display: flex;
flex-direction: column;
gap: 20px;
}
.card {
background: var(--card);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 22px;
box-shadow: 0 1px 3px rgba(16, 24, 40, 0.05);
}
/* ===== 上传区 ===== */
.dropzone {
border: 2px dashed #c7d2fe;
border-radius: var(--radius);
padding: 40px 20px;
text-align: center;
cursor: pointer;
transition: all .15s ease;
background: #fafbff;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: #eef1fe; }
.dropzone-icon { font-size: 40px; }
.dropzone-title { margin-top: 10px; font-weight: 600; font-size: 15px; }
.dropzone-hint { margin-top: 6px; font-size: 12px; color: var(--text-light); }
.preview-list {
display: flex;
flex-wrap: wrap;
gap: 12px;
margin-top: 16px;
}
.preview-item {
position: relative;
width: 96px;
height: 96px;
border-radius: 10px;
overflow: hidden;
border: 1px solid var(--border);
}
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-item .remove {
position: absolute;
top: 4px;
right: 4px;
width: 20px;
height: 20px;
border-radius: 50%;
background: rgba(0, 0, 0, .55);
color: #fff;
font-size: 12px;
line-height: 20px;
text-align: center;
cursor: pointer;
border: none;
}
.preview-item .remove:hover { background: var(--danger); }
/* ===== 提问与按钮 ===== */
.prompt-row { display: flex; gap: 12px; margin-top: 18px; }
.prompt-input {
flex: 1;
padding: 12px 14px;
border: 1px solid var(--border);
border-radius: 10px;
font-size: 14px;
outline: none;
transition: border-color .15s;
}
.prompt-input:focus { border-color: var(--primary); }
.btn {
border: none;
border-radius: 10px;
padding: 12px 22px;
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: all .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-light); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-block { width: 100%; margin-top: 6px; }
/* ===== 结果区 ===== */
.result-head { display: flex; align-items: center; justify-content: space-between; }
.result-head h2 { font-size: 16px; }
.result-body {
margin-top: 14px;
background: #f8f9fc;
border: 1px solid var(--border);
border-radius: 10px;
padding: 16px;
font-size: 14px;
line-height: 1.7;
white-space: pre-wrap;
word-break: break-word;
max-height: 480px;
overflow-y: auto;
}
.result-meta { margin-top: 10px; font-size: 12px; color: var(--text-light); }
/* ===== 加载态 ===== */
.loading { display: inline-flex; align-items: center; gap: 10px; }
.spinner {
width: 18px; height: 18px;
border: 2px solid var(--border);
border-top-color: var(--primary);
border-radius: 50%;
animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* ===== 模态框 ===== */
.modal-mask {
position: fixed;
inset: 0;
background: rgba(15, 20, 35, .45);
display: flex;
align-items: center;
justify-content: center;
z-index: 100;
}
.modal {
background: var(--card);
border-radius: 14px;
padding: 28px;
width: 380px;
box-shadow: 0 20px 60px rgba(0, 0, 0, .2);
}
.modal h2 { font-size: 18px; }
.modal-desc { font-size: 13px; color: var(--text-light); margin: 6px 0 16px; }
.modal-input {
width: 100%;
padding: 11px 13px;
margin-bottom: 10px;
border: 1px solid var(--border);
border-radius: 10px;
font-size: 14px;
outline: none;
}
.modal-input:focus { border-color: var(--primary); }
.modal-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 4px; }
/* ===== 页脚 ===== */
.footer {
text-align: center;
padding: 18px;
font-size: 12px;
color: var(--text-light);
}