fix(web): DDNS 页改用 FRP 多服务端状态接口
This commit is contained in:
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user