Browse Source

chore: try

pull/41776/head
MadCcc 2 years ago
parent
commit
a6e0fe0906
  1. 8
      .dumi/hooks/useLocation.ts
  2. 3
      .dumi/theme/common/ThemeSwitch/index.tsx

8
.dumi/hooks/useLocation.ts

@ -1,5 +1,6 @@
import { useLocation as useDumiLocation } from 'dumi';
import * as React from 'react';
import { useEffect } from 'react';
import useLocale from './useLocale';
function clearPath(path: string) {
@ -7,10 +8,15 @@ function clearPath(path: string) {
}
export default function useLocation() {
const location = useDumiLocation();
const originLocation = useDumiLocation();
const [location, setLocation] = React.useState(originLocation);
const { search } = location;
const [, localeType] = useLocale();
useEffect(() => {
setLocation(originLocation);
}, [originLocation]);
const getLink = React.useCallback(
(path: string, hash?: string | { cn: string; en: string }) => {
let pathname = clearPath(path);

3
.dumi/theme/common/ThemeSwitch/index.tsx

@ -1,8 +1,9 @@
import React from 'react';
import { FloatButton } from 'antd';
import { FormattedMessage, Link, useLocation } from 'dumi';
import { FormattedMessage, Link } from 'dumi';
import { DarkTheme, CompactTheme } from 'antd-token-previewer/es/icons';
import { BgColorsOutlined } from '@ant-design/icons';
import useLocation from '../../../hooks/useLocation';
import useSiteToken from '../../../hooks/useSiteToken';
import { getLocalizedPathname, isZhCN } from '../../utils';
import ThemeIcon from './ThemeIcon';

Loading…
Cancel
Save