summaryrefslogtreecommitdiff
path: root/src/components/about/About.tsx
blob: cb082181efad509129c18f61d9305440a96a54ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
import * as React from 'react';
import { GitHub } from '~/components/shared/FeatherIcons';

import ContentHeader from '~/components/ContentHeader';
import { useAboutVersionQuery } from '~/modules/about/hooks';
import { getCoreVersionMeta } from '~/modules/about/utils';
import { ClashAPIConfig } from '~/types';

import s from './About.module.scss';

type Props = { apiConfig: ClashAPIConfig };

function Version({ name, link, version }: { name: string; link: string; version: string }) {
  return (
    <div className={s.root}>
      <h2>{name}</h2>
      <p>
        <span>Version </span>
        <span className={s.mono}>{version}</span>
      </p>
      <p>
        <a className={s.link} href={link} target="_blank" rel="noopener noreferrer">
          <GitHub size={20} />
          <span>Source</span>
        </a>
      </p>
    </div>
  );
}

export function About({ apiConfig }: Props) {
  const { data: version } = useAboutVersionQuery(apiConfig);
  const coreVersionMeta = getCoreVersionMeta(version);

  return (
    <>
      <ContentHeader>About</ContentHeader>
      {coreVersionMeta && version?.version ? (
        <Version
          name={coreVersionMeta.name}
          version={version.version}
          link={coreVersionMeta.link}
        />
      ) : null}
      <Version name="Yacd" version={__VERSION__} link="https://github.com/metacubex/yacd" />
    </>
  );
}