feat: loginOut
This commit is contained in:
@@ -14,7 +14,7 @@ import {
|
||||
ProFormCheckbox,
|
||||
ProFormText,
|
||||
} from "@ant-design/pro-components";
|
||||
import { history, useModel } from "@umijs/max";
|
||||
import { history, useModel, useNavigate } from "@umijs/max";
|
||||
import { Button, Divider, Space, Tabs, theme, message } from "antd";
|
||||
import type { CSSProperties } from "react";
|
||||
import { useState } from "react";
|
||||
@@ -34,6 +34,7 @@ const Page = () => {
|
||||
const { token } = theme.useToken();
|
||||
const [messageApi, contextHolder] = message.useMessage();
|
||||
const { initialState, setInitialState } = useModel("@@initialState");
|
||||
const navigate = useNavigate();
|
||||
// 获取租户 ID
|
||||
const getTenantId = async (name: string) => {
|
||||
const res = await getTenantIdByName({ name });
|
||||
@@ -72,12 +73,11 @@ const Page = () => {
|
||||
if (res.code === 0) {
|
||||
// 登录成功
|
||||
messageApi.success("登录成功!");
|
||||
|
||||
// 跳转到首页
|
||||
authUtil.setToken(res.data);
|
||||
await fetchUserInfo();
|
||||
const urlParams = new URL(window.location.href).searchParams;
|
||||
window.location.href = urlParams.get("redirect") || "/";
|
||||
navigate(urlParams.get("redirect") || "/");
|
||||
} else {
|
||||
// 登录失败
|
||||
messageApi.error(res.msg || "登录失败,请重试!");
|
||||
|
||||
Reference in New Issue
Block a user