fix(web): DDNS 页改用 FRP 多服务端状态接口
This commit is contained in:
@@ -2,6 +2,12 @@
|
||||
|
||||
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
|
||||
|
||||
### 新增
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
})
|
||||
@@ -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)
|
||||
}
|
||||
@@ -518,6 +518,7 @@ import PageHeader from '../components/PageHeader.vue'
|
||||
import StatusBadge from '../components/StatusBadge.vue'
|
||||
import TaskProviderForm, { type ProviderForm } from '../components/TaskProviderForm.vue'
|
||||
import { formatDate, formatRelativeTime } from '../utils/format'
|
||||
import { shouldShowFrpHint } from '../utils/frp'
|
||||
import { statusLabel } from '../utils/status'
|
||||
|
||||
const DRAFT_KEY = '__draft__'
|
||||
@@ -929,8 +930,8 @@ async function init() {
|
||||
refreshPublicIP()
|
||||
refreshLiveDNS()
|
||||
try {
|
||||
const frp = await api.getFRP()
|
||||
frpEnabled.value = frp.enabled
|
||||
const status = await api.getFrpStatus()
|
||||
frpEnabled.value = shouldShowFrpHint(status)
|
||||
} catch {
|
||||
frpEnabled.value = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user