Collapse portal under src/, unify pnpm workspace/scripts, thin VIP topic re-exports, drop orphan vip scaffolds and one-shot scripts, ignore xhs/release, document root commands. Co-authored-by: Cursor <cursoragent@cursor.com>
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { useEffect, useState, type ReactNode } from 'react'
|
||
import { View, Text } from '@tarojs/components'
|
||
import {
|
||
getCachedRemoteConfig,
|
||
isModuleEnabled,
|
||
loadRemoteConfig,
|
||
} from '@/services/remoteConfig'
|
||
import type { NomadroRemoteConfig } from '@/data/remoteConfig.defaults'
|
||
|
||
type ModuleKey = keyof NomadroRemoteConfig['modules']
|
||
|
||
/** 小程序页级模块闸门:对齐门户 ModuleGate(首屏放行,无技术文案) */
|
||
export function MiniModuleGate({
|
||
moduleKey,
|
||
children,
|
||
}: {
|
||
moduleKey: ModuleKey
|
||
children: ReactNode
|
||
}) {
|
||
const [enabled, setEnabled] = useState(true)
|
||
|
||
useEffect(() => {
|
||
const cached = getCachedRemoteConfig()
|
||
setEnabled(isModuleEnabled(cached, moduleKey))
|
||
loadRemoteConfig().then((r) => {
|
||
setEnabled(isModuleEnabled(r.config, moduleKey))
|
||
})
|
||
}, [moduleKey])
|
||
|
||
if (!enabled) {
|
||
return (
|
||
<View className="sub">
|
||
<Text className="h">暂时无法打开</Text>
|
||
<Text className="p">该内容暂未开放,稍后再来看看吧。</Text>
|
||
</View>
|
||
)
|
||
}
|
||
|
||
return <>{children}</>
|
||
}
|