diff --git a/src/api/user/index.ts b/src/api/user/index.ts index 41a7eca..6ba626a 100644 --- a/src/api/user/index.ts +++ b/src/api/user/index.ts @@ -21,4 +21,3 @@ export const oauthLogin = (type: string) => { method: "get", }); }; - diff --git a/src/components/Home/resources/Resources.tsx b/src/components/Home/resources/Resources.tsx index a2c20c9..cae9b3c 100644 --- a/src/components/Home/resources/Resources.tsx +++ b/src/components/Home/resources/Resources.tsx @@ -27,7 +27,7 @@ const Resources = () => {
{tabsContent[activeTab].cards.map((card: any) => { - return ; + return ; })}
diff --git a/src/components/LoadingPage/index.tsx b/src/components/LoadingPage/index.tsx index 0a986a6..3805be0 100644 --- a/src/components/LoadingPage/index.tsx +++ b/src/components/LoadingPage/index.tsx @@ -5,6 +5,7 @@ import "./index.less"; import { useNavigate, useSearchParams } from "react-router-dom"; import useStore from "@/utils/store/useStore.tsx"; import { observer } from "mobx-react"; +import localforage from "localforage"; const LoadingPage = () => { const [search] = useSearchParams(); @@ -14,6 +15,7 @@ const LoadingPage = () => { const store = useStore("user"); store.setToken(token); store.setUserId(userId); + localforage.setItem("token", token).then(); useEffect(() => { document.body.classList.add("loading-body"); if (store.getToken() !== null && store.getUserId() !== null) { diff --git a/src/router/modules/login/index.ts b/src/router/modules/login/index.ts index fc27405..898812e 100644 --- a/src/router/modules/login/index.ts +++ b/src/router/modules/login/index.ts @@ -1,9 +1,11 @@ -import { lazy } from 'react' +/** @format */ + +import { lazy } from "react"; const login = lazy( - () => - new Promise((resolve: any) => { - setTimeout(() => resolve(import('@/views/User/Login')), 500) - }), -) -export default login + () => + new Promise((resolve: any) => { + setTimeout(() => resolve(import("@/views/User/Login")), 500); + }), +); +export default login; diff --git a/src/utils/axios/web.ts b/src/utils/axios/web.ts index be12010..a800320 100644 --- a/src/utils/axios/web.ts +++ b/src/utils/axios/web.ts @@ -1,9 +1,12 @@ /** @format */ import Request from "./request"; -import { handleLocalforage } from "@/utils/localforage"; +import localforage from "localforage"; -const token = handleLocalforage.getItem("token").then(); +async function getToken() { + return await localforage.getItem("token"); +} +const token = await getToken(); const web: Request = new Request({ baseURL: import.meta.env.VITE_APP_BASE_API, headers: { diff --git a/src/views/Home/index.tsx b/src/views/Home/index.tsx index 00cf768..5f50853 100644 --- a/src/views/Home/index.tsx +++ b/src/views/Home/index.tsx @@ -1,11 +1,12 @@ /** @format */ import MainContainer from "@/components/Home/main-container/MainContainer.tsx"; +import { observer } from "mobx-react"; -export default () => { +export default observer(() => { return (
); -}; +}); diff --git a/src/views/User/Login/index.tsx b/src/views/User/Login/index.tsx index 939e8ce..60f69a6 100644 --- a/src/views/User/Login/index.tsx +++ b/src/views/User/Login/index.tsx @@ -56,6 +56,7 @@ export default observer(() => { async function oAuthLogin(type: string) { const res: any = await oauthLogin(type); + console.log(res); window.location.href = res.data; } diff --git a/tsconfig.json b/tsconfig.json index 1039b56..c0411e3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,44 +1,45 @@ { - "compilerOptions": { - "esModuleInterop": true, - "target": "ES2020", - "useDefineForClassFields": true, - "lib": [ - "ES2020", - "DOM", - "DOM.Iterable" - ], - "module": "ESNext", - "skipLibCheck": true, - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - "jsx": "react-jsx", - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true, - "baseUrl": "./", - "paths": { - "@/*": [ - "./src/*" - ], - } - }, - "include": [ - "src/**/*.ts", - "src/**/*.d.ts", - "src/**/*.tsx", - "types/*.d.ts", - "vite.config.ts", - ], - "references": [ - { - "path": "./tsconfig.node.json" - } - ] + "compilerOptions": { + "esModuleInterop": true, + "target": "ES2020", + "useDefineForClassFields": true, + "lib": [ + "ES2020", + "DOM", + "DOM.Iterable" + ], + "module": "ESNext", + "skipLibCheck": true, + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "experimentalDecorators": true, + "jsx": "react-jsx", + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "baseUrl": "./", + "paths": { + "@/*": [ + "./src/*" + ] + } + }, + "include": [ + "src/**/*.ts", + "src/**/*.d.ts", + "src/**/*.tsx", + "types/*.d.ts", + "vite.config.ts" + ], + "references": [ + { + "path": "./tsconfig.node.json" + } + ] }