mirror of
https://github.com/Buriburizaem0n/admin-frontend-domain.git
synced 2026-02-05 13:10:08 +00:00
optimize fm (#82)
* optimize fm * chore: auto-fix linting and formatting issues * fix: type * chore: auto-fix linting and formatting issues --------- Co-authored-by: uubulb <uubulb@users.noreply.github.com> Co-authored-by: naiba <hi@nai.ba> Co-authored-by: naiba <naiba@users.noreply.github.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { oauth2callback } from "@/api/oauth2"
|
||||
import { getProfile, login as loginRequest } from "@/api/user"
|
||||
import { AuthContextProps } from "@/types"
|
||||
import { createContext, useContext, useEffect, useMemo } from "react"
|
||||
@@ -5,13 +6,12 @@ import { useNavigate } from "react-router-dom"
|
||||
import { toast } from "sonner"
|
||||
|
||||
import { useMainStore } from "./useMainStore"
|
||||
import { oauth2callback } from "@/api/oauth2"
|
||||
|
||||
const AuthContext = createContext<AuthContextProps>({
|
||||
profile: undefined,
|
||||
login: () => { },
|
||||
loginOauth2: () => { },
|
||||
logout: () => { },
|
||||
login: () => {},
|
||||
loginOauth2: () => {},
|
||||
logout: () => {},
|
||||
})
|
||||
|
||||
export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
@@ -19,7 +19,7 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
const setProfile = useMainStore((store) => store.setProfile)
|
||||
|
||||
useEffect(() => {
|
||||
; (async () => {
|
||||
;(async () => {
|
||||
try {
|
||||
const user = await getProfile()
|
||||
user.role = user.role || 0
|
||||
|
||||
@@ -3,6 +3,8 @@ import { GithubComNezhahqNezhaModelSettingResponseModelConfig } from "@/types"
|
||||
import useSWR from "swr"
|
||||
|
||||
export default function useSetting() {
|
||||
return useSWR<GithubComNezhahqNezhaModelSettingResponseModelConfig>("/api/v1/setting", swrFetcher)
|
||||
return useSWR<GithubComNezhahqNezhaModelSettingResponseModelConfig>(
|
||||
"/api/v1/setting",
|
||||
swrFetcher,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user