fix(settings): inject channel_monitor & available_channels into SSR payload
Root cause: GetPublicSettingsForInjection used an inline struct that silently drifted from dto.PublicSettings and omitted channel_monitor_enabled / available_channels_enabled. On refresh window.__APP_CONFIG__ lacked these keys, so cachedPublicSettings.available_channels_enabled resolved to undefined and the opt-in sidebar entry (=== true) disappeared. Backend: extract PublicSettingsInjectionPayload as a named type with all feature-flag fields wired, and add a reflect-based drift test in the dto package so forgetting a future flag fails CI instead of the browser. Frontend: introduce utils/featureFlags.ts as the single registry for public-settings-driven toggles, with explicit opt-in / opt-out modes that encode the pre-load fallback. AppSidebar switches to makeSidebarFlag() so adding a new switch only touches the registry.
This commit is contained in:
@@ -186,6 +186,7 @@ import { useI18n } from 'vue-i18n'
|
||||
import { useAdminSettingsStore, useAppStore, useAuthStore, useOnboardingStore } from '@/stores'
|
||||
import VersionBadge from '@/components/common/VersionBadge.vue'
|
||||
import { sanitizeSvg } from '@/utils/sanitize'
|
||||
import { FeatureFlags, makeSidebarFlag } from '@/utils/featureFlags'
|
||||
|
||||
interface NavItem {
|
||||
path: string
|
||||
@@ -627,10 +628,13 @@ const ChevronDownIcon = {
|
||||
)
|
||||
}
|
||||
|
||||
// 各个开关集中声明:所有菜单项引用这里的 getter,未来加新开关只需在此加一个常量。
|
||||
// getter 返回 false = 隐藏;undefined/true = 显示(宽容策略,避免 public settings 未加载闪烁)。
|
||||
const flagChannelMonitor = () => appStore.cachedPublicSettings?.channel_monitor_enabled
|
||||
const flagPayment = () => appStore.cachedPublicSettings?.payment_enabled
|
||||
// Public-settings flags go through the registry in utils/featureFlags.ts,
|
||||
// which handles the opt-in vs opt-out fallback when settings haven't loaded
|
||||
// yet. Admin-only flags (not in public settings) stay inline below.
|
||||
const flagChannelMonitor = makeSidebarFlag(FeatureFlags.channelMonitor)
|
||||
const flagPayment = makeSidebarFlag(FeatureFlags.payment)
|
||||
const flagAvailableChannels = makeSidebarFlag(FeatureFlags.availableChannels)
|
||||
void flagAvailableChannels
|
||||
const flagOpsMonitoring = () => adminSettingsStore.opsMonitoringEnabled
|
||||
const flagAdminPayment = () => adminSettingsStore.paymentEnabled
|
||||
|
||||
|
||||
Reference in New Issue
Block a user