登录刷新code

main
king 1 year ago
parent 4556afa855
commit d1d1dec42e
  1. 10
      src/api/user.ts
  2. 4
      src/pages/login/login.tsx

@ -1,10 +1,12 @@
import {request} from "./request"; import {request} from "./request";
interface Login { interface Code {
access_token: string
code?: {
image: string image: string
} }
interface Login {
access_token: string
code?: Code
company: Company company: Company
token: string token: string
user: User user: User
@ -48,6 +50,6 @@ export const userApi = {
return request<DepListData>(`/api/v1/user/detail`, "GET") return request<DepListData>(`/api/v1/user/detail`, "GET")
}, },
code(catch_key: string) { code(catch_key: string) {
return request(`/api/v1/auth/login/code`, "GET", {open_id:catch_key}) return request<{ code: Code }>(`/api/v1/auth/login/code`, "POST", {openid: catch_key})
} }
} }

@ -26,8 +26,8 @@ const Bing: FC<BingProps> = ({code, catch_key}: BingProps) => {
async function refreshCode() { async function refreshCode() {
try { try {
await userApi.code(catch_key) const {code} = await userApi.code(catch_key)
setUseCode(code.image)
} catch (e) { } catch (e) {
} }
} }

Loading…
Cancel
Save