-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
213 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Outlet } from "react-router-dom"; | ||
|
||
const ContentLayout = () => { | ||
return <Outlet />; | ||
}; | ||
|
||
export default ContentLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Outlet } from "react-router-dom"; | ||
|
||
const MainLayout = () => { | ||
return <Outlet />; | ||
}; | ||
|
||
export default MainLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const Login = () => { | ||
return <LoginContent />; | ||
}; | ||
|
||
export const LoginContent = () => { | ||
return <div>LoginContent</div>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { LoginContent } from "@/pages/login"; | ||
|
||
export const Login = () => { | ||
return <LoginContent />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { createHashRouter } from "react-router-dom"; | ||
|
||
import ContentLayout from "../layout/ContentLayout/index.tsx"; | ||
import MainLayout from "../layout/MainLayout.tsx"; | ||
import thirdRoutes from "./thirdRoutes.ts"; | ||
|
||
const router = createHashRouter([ | ||
{ | ||
path: "/", | ||
element: <MainLayout />, | ||
children: [ | ||
{ | ||
path: "/", | ||
element: <ContentLayout />, | ||
children: [], | ||
}, | ||
{ | ||
path: "login", | ||
async lazy() { | ||
const { Login } = await import("@/pages/login"); | ||
return { Component: Login }; | ||
}, | ||
}, | ||
], | ||
}, | ||
{ | ||
path: "third", | ||
children: thirdRoutes, | ||
}, | ||
]); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const thirdRoutes = [ | ||
{ | ||
path: "login", | ||
async lazy() { | ||
const { Login } = await import("@/pages/third/login"); | ||
return { Component: Login }; | ||
}, | ||
}, | ||
]; | ||
|
||
export default thirdRoutes; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import axios from "axios"; | ||
|
||
const createAxiosInstance = (baseURL: string) => { | ||
const serves = axios.create({ | ||
baseURL, | ||
timeout: 3000, | ||
}); | ||
|
||
serves.interceptors.request.use( | ||
(config) => { | ||
return config; | ||
}, | ||
(err) => Promise.reject(err), | ||
); | ||
|
||
serves.interceptors.response.use( | ||
(res) => { | ||
if (res.data.errCode !== 0) { | ||
return Promise.reject(res.data); | ||
} | ||
return res.data; | ||
}, | ||
(err) => { | ||
if (err.message.includes("timeout")) { | ||
console.error("error", err); | ||
} | ||
if (err.message.includes("Network Error")) { | ||
console.error("error", err); | ||
} | ||
return Promise.reject(err); | ||
}, | ||
); | ||
|
||
return serves; | ||
}; | ||
|
||
export default createAxiosInstance; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const TOKEN = "USER_TOKEN"; | ||
const LOCALE = "USER_LOCALE"; | ||
|
||
export type LocaleString = "zh-CN" | "en-US"; | ||
|
||
export const getIMToken = () => localStorage.getItem(TOKEN); | ||
export const getLocale = (): LocaleString => | ||
(localStorage.getItem(LOCALE) as LocaleString) || | ||
window.navigator.language || | ||
"en-US"; | ||
|
||
export const setTMToken = (token: string) => localStorage.setItem(TOKEN, token); | ||
export const setLocale = (locale: string) => localStorage.setItem(LOCALE, locale); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters