Welcome.tsx 3.3 KB
Newer Older
R
Rongfeng Fu 已提交
1
import { intl } from '@/utils/intl';
R
Rongfeng Fu 已提交
2 3 4 5 6 7
import { useEffect } from 'react';
import { useModel } from 'umi';
import { Button } from 'antd';
import videojs from 'video.js';
import 'video.js/dist/video-js.css';
import NP from 'number-precision';
R
Rongfeng Fu 已提交
8 9 10 11 12 13
import { getLocale } from 'umi';
import EnStyles from './indexEn.less';
import ZhStyles from './indexZh.less';

const locale = getLocale();
const styles = locale === 'zh-CN' ? ZhStyles : EnStyles;
R
Rongfeng Fu 已提交
14 15

export default function Welcome() {
R
Rongfeng Fu 已提交
16
  const { setCurrentStep, setErrorVisible, setErrorsList } = useModel('global');
R
Rongfeng Fu 已提交
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
  let Video: any;

  const aspectRatio = NP.divide(2498, 3940).toFixed(10);

  const screenWidth = window.innerWidth * 1.3;
  let videoWidth = 0;
  let videoHeight = 0;

  if (screenWidth < 1040) {
    videoWidth = 1040;
  } else {
    videoWidth = screenWidth;
  }

  videoHeight = Math.ceil(NP.times(videoWidth, aspectRatio));

  useEffect(() => {
    const welcomeVideo = document.querySelector('.welcome-video');
    if (welcomeVideo) {
      Video = videojs(welcomeVideo, {
        controls: false,
        autoplay: true,
        loop: true,
        preload: 'auto',
      });
    }
    return () => {
      Video.dispose();
    };
  }, []);

  return (
    <div className={styles.videoContainer}>
      <div className={styles.videoContent} style={{ width: videoWidth }}>
        <div className={styles.videoActions}>
R
Rongfeng Fu 已提交
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
          <h1 className={styles.h1}>
            {intl.formatMessage({
              id: 'OBD.pages.components.Welcome.WelcomeToDeploy',
              defaultMessage: '欢迎您部署',
            })}
          </h1>
          {locale === 'zh-CN' ? (
            <h2 className={styles.h2}>
              <span className={styles.letter}>OceanBase</span>
              {intl.formatMessage({
                id: 'OBD.pages.components.Welcome.DistributedDatabase',
                defaultMessage: '分布式数据库',
              })}
            </h2>
          ) : (
            <h2 className={styles.h2}>
              {intl.formatMessage({
                id: 'OBD.pages.components.Welcome.DistributedDatabase',
                defaultMessage: '分布式数据库',
              })}
            </h2>
          )}
R
Rongfeng Fu 已提交
74 75 76 77 78
          <div className={styles.startButtonContainer}>
            <Button
              className={styles.startButton}
              type="primary"
              data-aspm-click="c307505.d317276"
R
Rongfeng Fu 已提交
79 80 81 82
              data-aspm-desc={intl.formatMessage({
                id: 'OBD.pages.components.Welcome.WelcomeStartTheExperienceTour',
                defaultMessage: '欢迎-开启体验之旅',
              })}
R
Rongfeng Fu 已提交
83 84
              data-aspm-param={``}
              data-aspm-expo
R
Rongfeng Fu 已提交
85 86 87 88 89
              onClick={() => {
                setCurrentStep(1);
                setErrorVisible(false);
                setErrorsList([]);
              }}
R
Rongfeng Fu 已提交
90
            >
R
Rongfeng Fu 已提交
91 92 93 94
              {intl.formatMessage({
                id: 'OBD.pages.components.Welcome.StartAnExperienceTour',
                defaultMessage: '开启体验之旅',
              })}
R
Rongfeng Fu 已提交
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
            </Button>
          </div>
        </div>
        <video
          className={`${styles.video} welcome-video video-js`}
          width={videoWidth}
          height={videoHeight}
          muted
          poster="/assets/welcome/cover.jpg"
        >
          <source src="/assets/welcome/data.mp4" type="video/mp4"></source>
        </video>
      </div>
    </div>
  );
}