Skip to content

Commit

Permalink
feat: 优化站点逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
honkinglin committed Jan 13, 2022
1 parent cc7abc0 commit c18cde6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions site/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const LazyDemo = lazy(() => import('./components/Demo'));
const { docs: routerList } = JSON.parse(JSON.stringify(siteConfig).replace(/component:.+/g, ''));

const registryUrl = 'https://mirrors.tencent.com/npm/tdesign-react';
const currentVersion = packageJson.version.replace(/\./g, '_');

function Components(props) {
const tdHeaderRef = useRef();
Expand All @@ -21,7 +22,7 @@ function Components(props) {
const tdDocSearch = useRef();

const [versionOptions, setVersionOptions] = useState([]);
const [version] = useState(packageJson.version.replace(/\./g, '_'));
const [version] = useState(currentVersion);

const docRoutes = getRoute(siteConfig.docs, []);
const [renderRouter] = useState(renderRoutes(docRoutes));
Expand All @@ -35,7 +36,7 @@ function Components(props) {
}

function changeVersion(version) {
if (version === packageJson.version) return;
if (version === currentVersion) return;
const histryUrl = `//${version}-tdesign-react.surge.sh`;
window.open(histryUrl, '_blank');
}
Expand All @@ -48,6 +49,7 @@ function Components(props) {
versions.forEach(v => {
const nums = v.split('.');
if (nums[0] === '0' && nums[1] < 21) return false;
if (v.includes('alpha') || v.includes('beta')) return false;

options.unshift({ label: v, value: v.replace(/\./g, '_') });
});
Expand Down

0 comments on commit c18cde6

Please sign in to comment.