diff --git a/.eslintrc.cjs b/.eslintrc.cjs index c25475d..e1b3daa 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -24,5 +24,6 @@ module.exports = { ], rules: { 'prettier/prettier': 'error', + '@typescript-eslint/no-explicit-any': 0, }, }; diff --git a/src/App.tsx b/src/App.tsx index 1be0a39..2f496a9 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -7,20 +7,20 @@ import React, { } from 'react'; import './App.css'; -import { GithubIcon } from './GithubIcon'; -import { randomString, waitTimeout } from './utils'; +import { GithubIcon } from './components/GithubIcon'; +import { parseThemePath, randomString, waitTimeout } from './utils'; import { defaultTheme } from './themes/default'; import { Icon, Theme } from './themes/interface'; import { fishermanTheme } from './themes/fisherman'; import { jinlunTheme } from './themes/jinlun'; import { ikunTheme } from './themes/ikun'; import { pddTheme } from './themes/pdd'; -import { BeiAn } from './BeiAn'; -import { Info } from './Info'; +import { BeiAn } from './components/BeiAn'; +import { Info } from './components/Info'; import { owTheme } from './themes/ow'; // 主题 -const themes = [ +const themes: Theme[] = [ defaultTheme, fishermanTheme, jinlunTheme, @@ -165,8 +165,14 @@ const Symbol: FC = ({ x, y, icon, isCover, status, onClick }) => { ); }; +// 从url初始化主题 +const themeFromPath: string = parseThemePath(location.href); + const App: FC = () => { - const [curTheme, setCurTheme] = useState>(defaultTheme); + const [curTheme, setCurTheme] = useState>( + themes.find((theme) => theme.name === themeFromPath) ?? defaultTheme + ); + const [scene, setScene] = useState(makeScene(1, curTheme.icons)); const [level, setLevel] = useState(1); const [queue, setQueue] = useState([]); @@ -204,6 +210,12 @@ const App: FC = () => { }, 300); } restart(); + // 更改路径 + history.pushState( + {}, + curTheme.title, + `/?theme=${encodeURIComponent(curTheme.name)}` + ); }, [curTheme]); // 队列区排序 @@ -416,7 +428,11 @@ const App: FC = () => {

主题: + {/*TODO themes维护方式调整*/}