Commit 301a4d93 authored by GuanHua's avatar GuanHua

fix: 修改当前角色类型显示的问题

parent 338342cb
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Dropdown, Space, Menu, message } from 'antd'; import { Dropdown, Space, Menu, message } from 'antd';
import { CaretDownOutlined } from '@ant-design/icons'; import { CaretDownOutlined } from '@ant-design/icons';
import { getAuth, setAuth, setRouters } from '@/utils/auth'; import { getAuth, getCookieAuth, setAuth, setRouters } from '@/utils/auth';
import { postMemberLoginSwitchrole } from '@/services/MemberV2Api'; import { postMemberLoginSwitchrole } from '@/services/MemberV2Api';
import { useIntl } from 'umi' import { useIntl } from 'umi'
...@@ -17,12 +17,13 @@ const Roles: React.FC = () => { ...@@ -17,12 +17,13 @@ const Roles: React.FC = () => {
const [roles, setRoles] = useState<MemberRole[]>([]); const [roles, setRoles] = useState<MemberRole[]>([]);
useEffect(() => { useEffect(() => {
const userInfo = getAuth() || {}; const userInfo: any = getAuth() || {};
const cookieUserInfo: any = getCookieAuth() || {}
console.log(userInfo, 10086) console.log(userInfo, 10086)
setRoles(userInfo.roles || []); setRoles(userInfo.roles || []);
if (userInfo.roles && userInfo.roles.length) { if (userInfo.roles && userInfo.roles.length) {
const current = userInfo.roles.find(item => item.memberRoleId === userInfo.memberRoleId); const current = userInfo.roles.find(item => item.memberRoleId === cookieUserInfo.memberRoleId);
setCurRole(current); setCurRole(current);
} }
}, []); }, []);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment