|
|
|
@ -6,6 +6,7 @@ import styles from './article.module.scss' |
|
|
|
|
import down from '@/static/img/doubleDown.png' |
|
|
|
|
import {Profile} from "@/store"; |
|
|
|
|
import {parse} from "@/utils/marked/marked"; |
|
|
|
|
import {formatDate} from "@/utils/time"; |
|
|
|
|
|
|
|
|
|
const article: FC = () => { |
|
|
|
|
const {token} = Profile.useContainer() |
|
|
|
@ -13,10 +14,8 @@ const article:FC = () => { |
|
|
|
|
const [show, setShow] = useState(false) |
|
|
|
|
const [articleInfo, setArticleInfo] = useState<ArticleRecord>() |
|
|
|
|
const {children, headings} = useMemo(() => parse(articleInfo?.content || ''), [articleInfo]) |
|
|
|
|
|
|
|
|
|
const query = Taro.createSelectorQuery() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
getData() |
|
|
|
|
}, [id]) |
|
|
|
@ -30,6 +29,7 @@ const article:FC = () => { |
|
|
|
|
} catch (e) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function mao(id: string) { |
|
|
|
|
console.log(id) |
|
|
|
|
setShow(false) |
|
|
|
@ -39,22 +39,30 @@ const article:FC = () => { |
|
|
|
|
if (res.length) { |
|
|
|
|
Taro.pageScrollTo({ |
|
|
|
|
scrollTop: res[res.length - 1].top, |
|
|
|
|
duration: 300} |
|
|
|
|
duration: 300 |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function helloWorld() { |
|
|
|
|
return ( |
|
|
|
|
<> |
|
|
|
|
{/*<View style={{padding:'10px'}}>*/} |
|
|
|
|
{/* { children }*/} |
|
|
|
|
{/*</View>*/} |
|
|
|
|
<View className={styles.botmBox} style={{display:show?'none':'flex'}} onClick={()=>{setShow(true)}}> |
|
|
|
|
<View className={styles.botmBox} style={{display: show ? 'none' : 'flex'}} onClick={() => setShow(true)}> |
|
|
|
|
<View>文章导航</View> |
|
|
|
|
</View> |
|
|
|
|
<View style={{padding:'10px',height:!token ? Taro.getWindowInfo().windowHeight-60+'px' : 'auto',overflow:!token ? 'hidden':'auto'}}> |
|
|
|
|
<View style={{ |
|
|
|
|
padding: '10px', |
|
|
|
|
height: !token ? Taro.getWindowInfo().windowHeight - 60 + 'px' : 'auto', |
|
|
|
|
overflow: !token ? 'hidden' : 'auto' |
|
|
|
|
}}> |
|
|
|
|
<View className='text-center'> |
|
|
|
|
<View className='font-50 font-weight '>{articleInfo?.title}</View> |
|
|
|
|
<View className='mt-2'>{formatDate(new Date(articleInfo?.created_at || 0), "YY-mm-dd hh:mm:dd")}</View> |
|
|
|
|
</View> |
|
|
|
|
<View></View> |
|
|
|
|
{children} |
|
|
|
|
</View> |
|
|
|
|
{ |
|
|
|
@ -64,18 +72,23 @@ const article:FC = () => { |
|
|
|
|
<View className={styles['fixedBox-inner-icon']}> |
|
|
|
|
<Image src={down}></Image> |
|
|
|
|
</View> |
|
|
|
|
<View className={styles['fixedBox-inner-box']} onClick={ ()=> Taro.navigateTo({url: '/pages/login/login'})}> |
|
|
|
|
<View className={styles['fixedBox-inner-box']} |
|
|
|
|
onClick={() => Taro.navigateTo({url: '/pages/login/login'})}> |
|
|
|
|
<Text>登录查看更多内容</Text> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
<PageContainer onClickOverlay={()=>{ setShow(false)}} show={show} round={true} overlay={true} overlayStyle={'background:rgba(0,0,0,0.3)'} > |
|
|
|
|
<PageContainer onClickOverlay={() => { |
|
|
|
|
setShow(false) |
|
|
|
|
}} show={show} round={true} overlay={true} overlayStyle={'background:rgba(0,0,0,0.3)'}> |
|
|
|
|
<View className="px-3 py-5"> |
|
|
|
|
{headings.length > 0 && |
|
|
|
|
headings.map((d) => |
|
|
|
|
<View className="pb-3" style={{fontSize:'28rpx',fontWeight: '500',color: '#323635'}} onClick={()=>{mao(d.id)}}>{d.text}</View> |
|
|
|
|
<View className="pb-3" style={{fontSize: '28rpx', fontWeight: '500', color: '#323635'}} onClick={() => { |
|
|
|
|
mao(d.id) |
|
|
|
|
}}>{d.text}</View> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
</View> |
|
|
|
@ -84,6 +97,7 @@ const article:FC = () => { |
|
|
|
|
</> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return helloWorld() |
|
|
|
|
} |
|
|
|
|
export default article |
|
|
|
|