fix(web): DDNS 页改用 FRP 多服务端状态接口
CI / verify (push) Canceled after 0s

This commit is contained in:
2026-09-27 18:14:47 +08:00
parent 8d932a50f3
commit 4c49f6a3b5
4 changed files with 35 additions and 2 deletions
+6
View File
@@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## [Unreleased]
### 修复
- **DDNS 页 FRP 提示恢复**:`DdnsView.vue` 原来调用已退役的 `/api/frp`,请求失败后会把 `frpEnabled` 固定为 `false`,导致“FRP 内网穿透已启用”提示不再出现。现改用 `/api/frpmulti/status`,仅在“已配置服务端且存在启用规则”时显示,并补充判定函数单元测试
## [v1.2.19] - 2026-09-27 ## [v1.2.19] - 2026-09-27
### 新增 ### 新增
+20
View File
@@ -0,0 +1,20 @@
import { describe, expect, it } from 'vitest'
import { shouldShowFrpHint } from './frp'
describe('shouldShowFrpHint', () => {
it('配置了服务端且存在启用规则时显示提示', () => {
expect(shouldShowFrpHint({ configured: true, enabled_proxies: 1 })).toBe(true)
})
it('未配置服务端时不显示提示', () => {
expect(shouldShowFrpHint({ configured: false, enabled_proxies: 1 })).toBe(false)
})
it('配置了服务端但没有启用规则时不显示提示', () => {
expect(shouldShowFrpHint({ configured: true, enabled_proxies: 0 })).toBe(false)
})
it('状态为空时不显示提示', () => {
expect(shouldShowFrpHint(undefined)).toBe(false)
})
})
+6
View File
@@ -0,0 +1,6 @@
import type { FrpStatus } from '../api/types'
// 只有配置了 FRP 服务端且存在启用规则时,DDNS 页才提示域名应指向 VPS。
export function shouldShowFrpHint(status: Pick<FrpStatus, 'configured' | 'enabled_proxies'> | null | undefined): boolean {
return Boolean(status?.configured && status.enabled_proxies > 0)
}
+3 -2
View File
@@ -518,6 +518,7 @@ import PageHeader from '../components/PageHeader.vue'
import StatusBadge from '../components/StatusBadge.vue' import StatusBadge from '../components/StatusBadge.vue'
import TaskProviderForm, { type ProviderForm } from '../components/TaskProviderForm.vue' import TaskProviderForm, { type ProviderForm } from '../components/TaskProviderForm.vue'
import { formatDate, formatRelativeTime } from '../utils/format' import { formatDate, formatRelativeTime } from '../utils/format'
import { shouldShowFrpHint } from '../utils/frp'
import { statusLabel } from '../utils/status' import { statusLabel } from '../utils/status'
const DRAFT_KEY = '__draft__' const DRAFT_KEY = '__draft__'
@@ -929,8 +930,8 @@ async function init() {
refreshPublicIP() refreshPublicIP()
refreshLiveDNS() refreshLiveDNS()
try { try {
const frp = await api.getFRP() const status = await api.getFrpStatus()
frpEnabled.value = frp.enabled frpEnabled.value = shouldShowFrpHint(status)
} catch { } catch {
frpEnabled.value = false frpEnabled.value = false
} }