import {useEffect, useState} from 'react'
import {useRouter} from '@tarojs/taro'
import {Divider} from '@nutui/nutui-react-taro'
import {CmsArticle} from "@/api/cms/cmsArticle/model"
// 显示html富文本
import {View, RichText} from '@tarojs/components'
// import Line from "@/components/Gap";
import {getCmsArticle} from "@/api/cms/cmsArticle";
import './detail.css';

function Detail() {
    const {params} = useRouter();
    // 文章详情
    const [item, setItem] = useState<CmsArticle>()

    const reload = () => {
        getCmsArticle(Number(params.id)).then(data => {
            if (data) {
                setItem(data)
            }
        })
    }

    useEffect(() => {
        reload();
    }, []);

    return (
        <div style={{
            background: 'linear-gradient(to bottom, #F63D3D, #C01717)',
            minHeight: '100vh'
        }}>
            <div className={'p-3 font-bold text-center text-lg text-[#F2FE03]'}>{item?.title}</div>
            <Divider/>
            {/*<img src={item?.image} alt={item?.title} />*/}
            <View className={'content text-[#F2FE03] text-sm'}>
                <RichText
                    nodes={item?.content || '暂无内容'}
                    space="nbsp"
                />
            </View>
        </div>
    )
}

export default Detail
