Skip to content

Commit ab3ce98

Browse files
committed
fix: 代码格式化 & 兼容前后台登录用户身份信息识别
1 parent b54ab23 commit ab3ce98

File tree

7 files changed

+28
-13
lines changed

7 files changed

+28
-13
lines changed

src/components/ErrorMessage/403.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { Button, Result } from "antd";
21
import { useNavigate } from "react-router-dom";
2+
import { Button, Result } from "antd";
3+
34
import { HOME_URL } from "@/config/config";
5+
46
import "./index.less";
57

68
const NotAuth = () => {

src/components/ErrorMessage/404.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { Button, Result } from "antd";
21
import { useNavigate } from "react-router-dom";
2+
import { Button, Result } from "antd";
3+
34
import { HOME_URL } from "@/config/config";
5+
46
import "./index.less";
57

68
const NotFound = () => {

src/components/ErrorMessage/500.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { Button, Result } from "antd";
21
import { useNavigate } from "react-router-dom";
2+
import { Button, Result } from "antd";
3+
34
import { HOME_URL } from "@/config/config";
5+
46
import "./index.less";
57

68
const NotNetwork = () => {

src/components/Loading/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Spin } from "antd";
2+
23
import "./index.less";
34

45
const Loading = ({ tip = "Loading" }: { tip?: string }) => {

src/components/SwitchDark/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { Switch } from "antd";
21
import { connect } from "react-redux";
2+
import { Switch } from "antd";
3+
34
import { setThemeConfig } from "@/redux/modules/global/action";
45

56
const SwitchDark = (props: any) => {

src/layouts/components/Header/index.tsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,23 @@ import Theme from "./components/Theme";
1313
import "./index.less";
1414

1515
const LayoutHeader = (props: any) => {
16+
const { setToken, setUserInfo } = props;
1617
let { userInfo } = props || {};
17-
if (!userInfo || JSON.stringify(userInfo) === "{}") {
18+
let toCheck = !userInfo || JSON.stringify(userInfo) === "{}";
19+
if (toCheck) {
1820
let fetchUsrInfo = async () => {
19-
const { status, result } = await loginUserInfo();
20-
if (status && status.code == 0 && result && result?.userId > 0) {
21-
// fixme 拿登录的用户名、用户头像来替换默认的用户名头像
22-
setToken(result?.userId);
21+
try {
22+
const { status, result } = await loginUserInfo();
23+
console.log("请求用户信息: ", result);
24+
if (status && status.code == 0 && result && result?.userId > 0) {
25+
// fixme 拿登录的用户名、用户头像来替换默认的用户名头像
26+
setToken(result?.userId);
2327

24-
setUserInfo(result);
25-
userInfo = result;
28+
setUserInfo(result);
29+
userInfo = result;
30+
}
31+
} catch (e) {
32+
console.log("初始化用户身份异常!", e);
2633
}
2734
};
2835
// 未拿到用户信息时,主动去拿一下
@@ -51,5 +58,5 @@ const LayoutHeader = (props: any) => {
5158
};
5259

5360
const mapStateToProps = (state: any) => state.global;
54-
const mapDispatchToProps = {};
61+
const mapDispatchToProps = { setToken, setUserInfo };
5562
export default connect(mapStateToProps, mapDispatchToProps)(LayoutHeader);

src/views/column/article/components/tableselect/TableSelect.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/* eslint-disable prettier/prettier */
22
import React, { FC, useEffect, useState } from "react";
3+
import { PoweroffOutlined } from "@ant-design/icons";
34
import { Avatar,Button, Checkbox, Divider, Input, Select, Table } from "antd";
45
import type { ColumnsType } from "antd/es/table";
56

67
import { getArticleListApi } from "@/api/modules/article";
78
import { initPagination,IPagination } from "@/enums/common";
89
import { MapItem } from "@/typings/common";
9-
import { PoweroffOutlined } from "@ant-design/icons";
1010

1111
const { Option } = Select;
1212

0 commit comments

Comments
 (0)