Keep Douyin homeVariant BMI router intact while restoring admin join-group controls, TLS-safe config fetch, and ntfy channel labels. Co-authored-by: Cursor <cursoragent@cursor.com>
89 lines
1.8 KiB
TypeScript
89 lines
1.8 KiB
TypeScript
import type { CSSProperties, ReactNode } from 'react'
|
|
import { View, Text } from '@tarojs/components'
|
|
import { trackClick } from '../utils/track'
|
|
|
|
const isH5 = process.env.TARO_ENV === 'h5'
|
|
|
|
type BoxProps = {
|
|
className?: string
|
|
id?: string
|
|
children?: ReactNode
|
|
onClick?: () => void
|
|
html?: string
|
|
style?: CSSProperties
|
|
'aria-hidden'?: boolean
|
|
'aria-label'?: string
|
|
'data-theme'?: string
|
|
/** 设了则点击时自动 btn_click 埋点 */
|
|
trackLabel?: string
|
|
}
|
|
|
|
/** H5 uses native div (taro-view-core defaults to inline and breaks grid/absolute). */
|
|
export function H5Box({
|
|
className,
|
|
id,
|
|
children,
|
|
onClick,
|
|
html,
|
|
style,
|
|
'aria-hidden': ariaHidden,
|
|
'aria-label': ariaLabel,
|
|
'data-theme': dataTheme,
|
|
trackLabel,
|
|
}: BoxProps) {
|
|
const handleClick = onClick
|
|
? () => {
|
|
if (trackLabel) trackClick(trackLabel)
|
|
onClick()
|
|
}
|
|
: trackLabel
|
|
? () => trackClick(trackLabel)
|
|
: undefined
|
|
|
|
if (isH5) {
|
|
return (
|
|
<div
|
|
id={id}
|
|
className={className}
|
|
style={style}
|
|
onClick={handleClick}
|
|
aria-hidden={ariaHidden}
|
|
aria-label={ariaLabel}
|
|
data-theme={dataTheme}
|
|
dangerouslySetInnerHTML={html ? { __html: html } : undefined}
|
|
>
|
|
{html ? undefined : children}
|
|
</div>
|
|
)
|
|
}
|
|
return (
|
|
<View
|
|
id={id}
|
|
className={className}
|
|
style={style}
|
|
onClick={handleClick}
|
|
data-theme={dataTheme}
|
|
dangerouslySetInnerHTML={html ? { __html: html } : undefined}
|
|
>
|
|
{html ? undefined : children}
|
|
</View>
|
|
)
|
|
}
|
|
|
|
export function H5Txt({
|
|
className,
|
|
id,
|
|
children,
|
|
}: {
|
|
className?: string
|
|
id?: string
|
|
children?: ReactNode
|
|
}) {
|
|
if (isH5) return <span id={id} className={className}>{children}</span>
|
|
return (
|
|
<Text id={id} className={className}>
|
|
{children}
|
|
</Text>
|
|
)
|
|
}
|