Skip to content

Commit

Permalink
pref 配置别名减少查找模块时间消耗
Browse files Browse the repository at this point in the history
  • Loading branch information
xuhaoxian committed Oct 8, 2024
1 parent 774ce6d commit 499ca47
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 41 deletions.
6 changes: 3 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import "./App.css";
import { Route, Routes } from "react-router-dom";
import Layout from "./components/Layout";
import { menuList } from "./utils/menuData";
import NotFound from "./components/NotFound";
import Layout from "@/components/Layout";
import { menuList } from "@/utils/menuData";
import NotFound from "@/components/NotFound";
import { useEffect } from "react";

function App() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import ListItemText from "@mui/material/ListItemText";
import Toolbar from "@mui/material/Toolbar";
import Typography from "@mui/material/Typography";
import { useState } from "react";
import { menuList } from "../utils/menuData";
import { menuList } from "@/utils/menuData";
import { useLocation, useNavigate } from "react-router-dom";

const drawerWidth = 220;
Expand Down
8 changes: 4 additions & 4 deletions src/pages/Arknights.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import axios from "axios";
import { useState } from "react";
import { useQuery } from "react-query";
import EventCalendar from "../components/EventCalendar";
import EventCalendar from "@/components/EventCalendar";
import dayjs from "dayjs";
import customParseFormat from "dayjs/plugin/customParseFormat";
import { CalendarActivity } from "../components/EventCalendar/CalendarType";
import Loading from "../components/Loading";
import { BACKEND_URL } from "../services/note";
import { CalendarActivity } from "@/components/EventCalendar/CalendarType";
import Loading from "@/components/Loading";
import { BACKEND_URL } from "@/services/note";
dayjs.extend(customParseFormat);

function Arknights() {
Expand Down
8 changes: 4 additions & 4 deletions src/pages/FGO.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import axios from "axios";
import { useState } from "react";
import { useQuery } from "react-query";
import EventCalendar from "../components/EventCalendar";
import EventCalendar from "@/components/EventCalendar";
import dayjs from "dayjs";
import customParseFormat from "dayjs/plugin/customParseFormat";
import { CalendarActivity } from "../components/EventCalendar/CalendarType";
import Loading from "../components/Loading";
import { BACKEND_URL } from "../services/note";
import { CalendarActivity } from "@/components/EventCalendar/CalendarType";
import Loading from "@/components/Loading";
import { BACKEND_URL } from "@/services/note";
dayjs.extend(customParseFormat);

function FGO() {
Expand Down
10 changes: 5 additions & 5 deletions src/pages/Genshin.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// import EventCalendar from "../components/EventCalendar";
// import EventCalendar from "@/components/EventCalendar";
import dayjs from "dayjs";
import EventCalendar from "../components/EventCalendar";
import { useState } from "react";
import { useQuery } from "react-query";
import { CalendarActivity } from "../components/EventCalendar/CalendarType";
import Loading from "../components/Loading";
import { CalendarActivity } from "@/components/EventCalendar/CalendarType";
import Loading from "@/components/Loading";
import axios from "axios";
import { BACKEND_URL } from "../services/note";
import { BACKEND_URL } from "@/services/note";
import EventCalendar from "@/components/EventCalendar";

const ignored_ann_ids = [
495, // 有奖问卷调查开启!
Expand Down
8 changes: 4 additions & 4 deletions src/pages/Pcr.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useQuery } from "react-query";
import EventCalendar from "../components/EventCalendar";
import EventCalendar from "@/components/EventCalendar";
import dayjs from "dayjs";
import axios from "axios";
import Loading from "../components/Loading";
import Loading from "@/components/Loading";
import { useState } from "react";
import { CalendarActivity } from "../components/EventCalendar/CalendarType";
import { BACKEND_URL } from "../services/note";
import { CalendarActivity } from "@/components/EventCalendar/CalendarType";
import { BACKEND_URL } from "@/services/note";

function Pcr() {
const [eventData, setEventData] = useState<CalendarActivity[]>();
Expand Down
8 changes: 4 additions & 4 deletions src/pages/Pns.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import axios from "axios";
import { useState } from "react";
import { useQuery } from "react-query";
import EventCalendar from "../components/EventCalendar";
import EventCalendar from "@/components/EventCalendar";
import dayjs from "dayjs";
import customParseFormat from "dayjs/plugin/customParseFormat";
import { CalendarActivity } from "../components/EventCalendar/CalendarType";
import Loading from "../components/Loading";
import { BACKEND_URL } from "../services/note";
import { CalendarActivity } from "@/components/EventCalendar/CalendarType";
import Loading from "@/components/Loading";
import { BACKEND_URL } from "@/services/note";
dayjs.extend(customParseFormat);

function Pns() {
Expand Down
8 changes: 4 additions & 4 deletions src/pages/StarRail.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import axios from "axios";
import { useState } from "react";
import { useQuery } from "react-query";
import EventCalendar from "../components/EventCalendar";
import EventCalendar from "@/components/EventCalendar";
import dayjs from "dayjs";
import { CalendarActivity } from "../components/EventCalendar/CalendarType";
import Loading from "../components/Loading";
import { BACKEND_URL } from "../services/note";
import { CalendarActivity } from "@/components/EventCalendar/CalendarType";
import Loading from "@/components/Loading";
import { BACKEND_URL } from "@/services/note";

const ignored_ann_ids = [
194, // 有奖问卷调查开启!
Expand Down
8 changes: 4 additions & 4 deletions src/pages/wuthering-waves.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import axios from "axios";
import { useState } from "react";
import { useQuery } from "react-query";
import EventCalendar from "../components/EventCalendar";
import EventCalendar from "@/components/EventCalendar";
import dayjs from "dayjs";
import customParseFormat from "dayjs/plugin/customParseFormat";
import { CalendarActivity } from "../components/EventCalendar/CalendarType";
import Loading from "../components/Loading";
import { BACKEND_URL } from "../services/note";
import { CalendarActivity } from "@/components/EventCalendar/CalendarType";
import Loading from "@/components/Loading";
import { BACKEND_URL } from "@/services/note";
dayjs.extend(customParseFormat);

function WutheringWaves() {
Expand Down
14 changes: 7 additions & 7 deletions src/utils/menuData.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Pcr from "../pages/Pcr";
import Genshin from "../pages/Genshin";
import StarRail from "../pages/StarRail";
import FGO from "../pages/FGO";
import Arknights from "../pages/Arknights";
import WutheringWaves from "../pages/wuthering-waves";
import Pns from "../pages/Pns";
import Pcr from "@/pages/Pcr";
import Genshin from "@/pages/Genshin";
import StarRail from "@/pages/StarRail";
import FGO from "@/pages/FGO";
import Arknights from "@/pages/Arknights";
import WutheringWaves from "@/pages/wuthering-waves";
import Pns from "@/pages/Pns";

// 懒加载组件 要配合Suspense使用,避免白屏问题
// fast fresh问题 懒加载的组件里不能额外再导出别的东西
Expand Down
8 changes: 7 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,

// 配置 @
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
Expand Down
9 changes: 9 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), "");
return {
plugins: [react()],
resolve: {
// 配置别名 减少查找模块时间消耗
alias: [
{
find: "@",
replacement: "/src",
},
],
},
server: {
proxy: {
// string shorthand: http://localhost:5173/foo -> http://localhost:4567/foo
Expand Down

0 comments on commit 499ca47

Please sign in to comment.