feat: Oauth update
This commit is contained in:
@@ -21,4 +21,3 @@ export const oauthLogin = (type: string) => {
|
|||||||
method: "get",
|
method: "get",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@ const Resources = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div className={style.tabInfoContainer}>
|
<div className={style.tabInfoContainer}>
|
||||||
{tabsContent[activeTab].cards.map((card: any) => {
|
{tabsContent[activeTab].cards.map((card: any) => {
|
||||||
return <TabCard key={card.key} {...card} />;
|
return <TabCard key={card.key} title={card.title} icon={card.icon} />;
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
@@ -5,6 +5,7 @@ import "./index.less";
|
|||||||
import { useNavigate, useSearchParams } from "react-router-dom";
|
import { useNavigate, useSearchParams } from "react-router-dom";
|
||||||
import useStore from "@/utils/store/useStore.tsx";
|
import useStore from "@/utils/store/useStore.tsx";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
|
import localforage from "localforage";
|
||||||
|
|
||||||
const LoadingPage = () => {
|
const LoadingPage = () => {
|
||||||
const [search] = useSearchParams();
|
const [search] = useSearchParams();
|
||||||
@@ -14,6 +15,7 @@ const LoadingPage = () => {
|
|||||||
const store = useStore("user");
|
const store = useStore("user");
|
||||||
store.setToken(token);
|
store.setToken(token);
|
||||||
store.setUserId(userId);
|
store.setUserId(userId);
|
||||||
|
localforage.setItem("token", token).then();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.body.classList.add("loading-body");
|
document.body.classList.add("loading-body");
|
||||||
if (store.getToken() !== null && store.getUserId() !== null) {
|
if (store.getToken() !== null && store.getUserId() !== null) {
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
import { lazy } from 'react'
|
/** @format */
|
||||||
|
|
||||||
|
import { lazy } from "react";
|
||||||
|
|
||||||
const login = lazy(
|
const login = lazy(
|
||||||
() =>
|
() =>
|
||||||
new Promise((resolve: any) => {
|
new Promise((resolve: any) => {
|
||||||
setTimeout(() => resolve(import('@/views/User/Login')), 500)
|
setTimeout(() => resolve(import("@/views/User/Login")), 500);
|
||||||
}),
|
}),
|
||||||
)
|
);
|
||||||
export default login
|
export default login;
|
||||||
|
@@ -1,9 +1,12 @@
|
|||||||
/** @format */
|
/** @format */
|
||||||
|
|
||||||
import Request from "./request";
|
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({
|
const web: Request = new Request({
|
||||||
baseURL: import.meta.env.VITE_APP_BASE_API,
|
baseURL: import.meta.env.VITE_APP_BASE_API,
|
||||||
headers: {
|
headers: {
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
/** @format */
|
/** @format */
|
||||||
|
|
||||||
import MainContainer from "@/components/Home/main-container/MainContainer.tsx";
|
import MainContainer from "@/components/Home/main-container/MainContainer.tsx";
|
||||||
|
import { observer } from "mobx-react";
|
||||||
|
|
||||||
export default () => {
|
export default observer(() => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<MainContainer />
|
<MainContainer />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
@@ -56,6 +56,7 @@ export default observer(() => {
|
|||||||
|
|
||||||
async function oAuthLogin(type: string) {
|
async function oAuthLogin(type: string) {
|
||||||
const res: any = await oauthLogin(type);
|
const res: any = await oauthLogin(type);
|
||||||
|
console.log(res);
|
||||||
window.location.href = res.data;
|
window.location.href = res.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
/* Linting */
|
/* Linting */
|
||||||
"strict": true,
|
"strict": true,
|
||||||
@@ -26,7 +27,7 @@
|
|||||||
"paths": {
|
"paths": {
|
||||||
"@/*": [
|
"@/*": [
|
||||||
"./src/*"
|
"./src/*"
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
@@ -34,7 +35,7 @@
|
|||||||
"src/**/*.d.ts",
|
"src/**/*.d.ts",
|
||||||
"src/**/*.tsx",
|
"src/**/*.tsx",
|
||||||
"types/*.d.ts",
|
"types/*.d.ts",
|
||||||
"vite.config.ts",
|
"vite.config.ts"
|
||||||
],
|
],
|
||||||
"references": [
|
"references": [
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user