import { WebView } from '@tarojs/components';
import { getPageQuery } from '@/utils/route';
import React, { useState } from 'react';
import { useLoad } from '@tarojs/taro';


import Toast from '@/utils/toast';

import './index.less';

export default function MaterialWebview() {
  const [src, setSrc] = useState('')

  useLoad(() => {
    const { source } = getPageQuery<{ source: string }>()
    setSrc(`https://neighbourhood.cn/material-preview.html?source=${source}`)
  })

  if (src) {

    return <WebView src={src} onError={() => Toast.error('加载失败请重试')} />;
  }

  return '加载中...'

}
