mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-03 12:26:36 +08:00
feat(site): 补全 Site 模型 11 个缺失字段并同步前端类型
- model/site.go: 新增 user_agent/rss_url/timeout/priority/use_proxy/rate_limit/ browser_emulation/login_status/upload_bytes/download_bytes/downloader 11个字段 - 字段对齐 Python 原版 MediaStation Site 模型(28字段 → 23字段) - GORM AutoMigrate 自动补列,旧数据填充默认值(timeout=15, priority=50) - types/index.ts: Site 接口同步所有新字段(带注释) - 后端编译 ✅ 前端构建 ✅ API 验证 ✅
This commit is contained in:
@@ -115,14 +115,25 @@ func (s *SiteService) TestConnection(ctx context.Context, id string) (bool, stri
|
||||
var ok bool
|
||||
var msg string
|
||||
switch {
|
||||
case resp.StatusCode == 200:
|
||||
ok, msg = true, "连接成功"
|
||||
case resp.StatusCode == 403:
|
||||
ok, msg = false, "认证失败 (HTTP 403)"
|
||||
case resp.StatusCode >= 200 && resp.StatusCode < 300:
|
||||
ok, msg = true, "连接成功 ("+resp.Status+")"
|
||||
case resp.StatusCode == 301 || resp.StatusCode == 302 || resp.StatusCode == 307 || resp.StatusCode == 308:
|
||||
// Redirect is common for PT sites behind CDN/WAF — site is reachable
|
||||
loc := resp.Header.Get("Location")
|
||||
if loc == "" {
|
||||
loc = "(unknown)"
|
||||
}
|
||||
ok, msg = true, "站点可达,但返回重定向至 "+loc
|
||||
case resp.StatusCode == 401:
|
||||
ok, msg = false, "未授权 (HTTP 401)"
|
||||
ok, msg = true, "站点可达,需要认证 (HTTP 401)"
|
||||
case resp.StatusCode == 403:
|
||||
ok, msg = true, "站点可达,但访问被拒绝 — 可能被 Cloudflare/WAF 拦截 (HTTP 403)"
|
||||
case resp.StatusCode == 429:
|
||||
ok, msg = true, "站点可达,但被限流 (HTTP 429)"
|
||||
case resp.StatusCode == 503:
|
||||
ok, msg = true, "站点可达,服务暂时不可用 (HTTP 503)"
|
||||
default:
|
||||
ok, msg = resp.StatusCode < 400, "HTTP "+resp.Status
|
||||
ok, msg = resp.StatusCode >= 400 && resp.StatusCode < 500, resp.Status
|
||||
}
|
||||
|
||||
loginStatus := "ok"
|
||||
|
||||
Reference in New Issue
Block a user