mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-30 16:23:31 +00:00
feat(channel-monitor-v2): 补齐管理端配置、隐藏吞吐开关与测试
管理端 V2 配置面板与系统设置中的模式/隐藏 RPM·TPM 开关,纳入关键 vitest 与 Makefile 前端关键路径,覆盖门控与展示行为。
This commit is contained in:
@@ -68,9 +68,9 @@
|
||||
* `makeSidebarFlag(flag)` returns a `() => boolean | undefined` compatible with
|
||||
* `AppSidebar.NavItem.featureFlag`, where `false` hides the menu entry.
|
||||
*/
|
||||
|
||||
import { useAppStore } from '@/stores/app'
|
||||
import type { PublicSettings } from '@/types'
|
||||
import { DEFAULT_INTERVAL_SECONDS } from '@/constants/channelMonitor'
|
||||
|
||||
export type FeatureFlagMode = 'opt-in' | 'opt-out'
|
||||
|
||||
@@ -152,3 +152,37 @@ export function isFeatureFlagEnabled(flag: FeatureFlagDefinition): boolean {
|
||||
export function makeSidebarFlag(flag: FeatureFlagDefinition): () => boolean {
|
||||
return () => isFeatureFlagEnabled(flag)
|
||||
}
|
||||
|
||||
/** True when channel monitor feature flag is enabled. */
|
||||
export function isChannelMonitorRouteEnabled(): boolean {
|
||||
return isFeatureFlagEnabled(FeatureFlags.channelMonitor)
|
||||
}
|
||||
|
||||
export type ChannelMonitorMode = 'v1' | 'v2'
|
||||
|
||||
/** Exclusive channel-monitor implementation. Invalid/missing → v2. */
|
||||
export function getChannelMonitorMode(): ChannelMonitorMode {
|
||||
const appStore = useAppStore()
|
||||
const mode = appStore.cachedPublicSettings?.channel_monitor_mode
|
||||
return mode === 'v1' ? 'v1' : 'v2'
|
||||
}
|
||||
|
||||
export function isChannelMonitorV1Mode(): boolean {
|
||||
return isChannelMonitorRouteEnabled() && getChannelMonitorMode() === 'v1'
|
||||
}
|
||||
|
||||
export function isChannelMonitorV2Mode(): boolean {
|
||||
return isChannelMonitorRouteEnabled() && getChannelMonitorMode() === 'v2'
|
||||
}
|
||||
|
||||
export function getChannelMonitorRefreshIntervalSeconds(): number {
|
||||
const appStore = useAppStore()
|
||||
const configured = appStore.cachedPublicSettings?.channel_monitor_default_interval_seconds
|
||||
return configured && configured > 0 ? configured : DEFAULT_INTERVAL_SECONDS
|
||||
}
|
||||
|
||||
/** Hide RPM/TPM on user-facing monitor (scale privacy). Admin always shows full metrics. */
|
||||
export function isChannelMonitorThroughputHidden(): boolean {
|
||||
const appStore = useAppStore()
|
||||
return Boolean(appStore.cachedPublicSettings?.channel_monitor_hide_throughput)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user