Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
linweijiong
jinfa-platform
Commits
fa1af3ad
Commit
fa1af3ad
authored
Apr 22, 2022
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复重现登录、切换角色之后最近访问数据还是上个账号/角色的问题
parent
aafd4f4d
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
51 additions
and
5 deletions
+51
-5
Roles.tsx
src/layouts/components/Roles.tsx
+2
-0
index.tsx
src/pages/home/components/RecentVisit/index.tsx
+2
-1
index.less
src/pages/srmHome/components/RecentlyVisited/index.less
+4
-0
index.tsx
src/pages/srmHome/components/RecentlyVisited/index.tsx
+3
-2
index.tsx
...nsaction/dealAbility/inquiryOffer/inquirySearch/index.tsx
+2
-0
LoginWrap.tsx
src/pages/user/components/LoginWrap.tsx
+2
-0
ScanLoginWrap.tsx
src/pages/user/components/ScanLoginWrap.tsx
+2
-0
lru.ts
src/utils/lru.ts
+4
-2
recentVisit.ts
src/utils/recentVisit.ts
+30
-0
No files found.
src/layouts/components/Roles.tsx
View file @
fa1af3ad
...
...
@@ -5,6 +5,7 @@ import { getAuth, getCookieAuth, setAuth, setRouters } from '@/utils/auth';
import
{
postMemberLoginSwitchrole
}
from
'@/services/MemberV2Api'
;
import
{
useIntl
}
from
'umi'
import
defaultHomePath
from
'@/utils/defaultHomePath'
;
import
{
clearRecentVisit
}
from
'@/utils/recentVisit'
;
interface
MemberRole
{
memberRoleId
:
number
;
...
...
@@ -49,6 +50,7 @@ const Roles: React.FC = () => {
}
setAuth
(
res
.
data
);
setRouters
(
res
.
data
.
auth
);
clearRecentVisit
();
setTimeout
(()
=>
{
window
.
location
.
replace
(
defaultHomePath
());
},
800
);
...
...
src/pages/home/components/RecentVisit/index.tsx
View file @
fa1af3ad
...
...
@@ -3,11 +3,12 @@ import styles from './index.less';
import
menu_zh
from
'@/locales/zh-CN/menu'
;
import
{
Tooltip
}
from
'antd'
;
import
{
Link
,
useIntl
}
from
'umi'
;
import
{
getRecentVisit
}
from
'@/utils/recentVisit'
;
interface
Iprops
{
}
const
RecentVisit
:
React
.
FC
<
Iprops
>
=
()
=>
{
const
intl
=
useIntl
();
const
recentVisit
=
localStorage
.
getItem
(
'recentVisit'
)
&&
JSON
.
parse
(
localStorage
.
getItem
(
'recentVisit'
))
||
{}
;
const
recentVisit
=
getRecentVisit
()
;
return
(
<
div
className=
{
styles
.
recentVisit
}
>
<
div
className=
{
styles
.
header
}
>
...
...
src/pages/srmHome/components/RecentlyVisited/index.less
View file @
fa1af3ad
...
...
@@ -15,6 +15,10 @@
width: 33.33%;
&-content {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
padding: @padding-sm - 2;
border-radius: 4px;
font-size: @font-size-sm;
...
...
src/pages/srmHome/components/RecentlyVisited/index.tsx
View file @
fa1af3ad
/**
* @Description
消息提醒
* @Description
最近访问
*/
import
React
from
'react'
;
import
{
history
}
from
'umi'
;
import
{
getRecentVisit
}
from
'@/utils/recentVisit'
;
import
MellowCard
from
'@/components/MellowCard'
;
import
styles
from
'./index.less'
;
const
RecentlyVisited
:
React
.
FC
=
()
=>
{
const
recentVisit
=
localStorage
.
getItem
(
'recentVisit'
)
&&
JSON
.
parse
(
localStorage
.
getItem
(
'recentVisit'
))
||
{}
;
const
recentVisit
=
getRecentVisit
()
;
const
handleJump
=
(
url
:
string
)
=>
{
history
.
push
(
url
);
...
...
src/pages/transaction/dealAbility/inquiryOffer/inquirySearch/index.tsx
View file @
fa1af3ad
...
...
@@ -12,6 +12,7 @@ import { isEmpty } from '@antv/util';
import
{
postMemberLoginSwitchrole
}
from
'@/services/MemberV2Api'
;
import
{
getTransactionProductInquiryList
,
getTransactionQuotationtInquiryExternalStateEnum
}
from
'@/services/TransactionV2Api'
;
import
{
AuthUrl
}
from
'@/components/AuthButton/AuthUrl'
;
import
{
clearRecentVisit
}
from
'@/utils/recentVisit'
;
interface
MemberRole
{
memberRoleId
:
number
;
...
...
@@ -41,6 +42,7 @@ const InquirySearch = () => {
}
setAuth
(
res
.
data
);
setRouters
(
res
.
data
.
auth
);
clearRecentVisit
();
setTimeout
(()
=>
{
window
.
location
.
replace
(
`/memberCenter/tranactionAbility/productInquiry/waitAddInquiry/two?id=
${
id
}
`
);
},
800
);
...
...
src/pages/user/components/LoginWrap.tsx
View file @
fa1af3ad
...
...
@@ -13,6 +13,7 @@ import { setUserCookie } from '@/utils/siteCookie';
import
{
omit
}
from
'@/utils'
;
import
defaultHomePath
from
'@/utils/defaultHomePath'
;
import
styles
from
'./index.less'
import
{
clearRecentVisit
}
from
'@/utils/recentVisit'
;
const
intl
=
getIntl
();
const
LoginWrap
:
React
.
FC
=
()
=>
{
...
...
@@ -32,6 +33,7 @@ const LoginWrap: React.FC = () => {
setRouters
(
data
.
auth
)
// 设置同域名cookie缓存
setAuth
(
data
)
clearRecentVisit
()
// 此处需使用href跳转, 否则无法触发app.ts中的路由初始化校验
if
(
redirect
)
{
window
.
location
.
replace
(
decodeURIComponent
(
Base64
.
decode
(
redirect
)))
...
...
src/pages/user/components/ScanLoginWrap.tsx
View file @
fa1af3ad
...
...
@@ -5,6 +5,7 @@ import { setAuth, setRouters } from '@/utils/auth';
import
QRCode
from
'qrcode'
;
import
{
postMemberLoginAuthUrl
,
postMemberLoginInfo
}
from
'@/services/MemberV2Api'
;
import
defaultHomePath
from
'@/utils/defaultHomePath'
;
import
{
clearRecentVisit
}
from
'@/utils/recentVisit'
;
const
intl
=
getIntl
();
const
ScanLoginWrap
:
React
.
FC
=
()
=>
{
...
...
@@ -68,6 +69,7 @@ const ScanLoginWrap: React.FC = () => {
message
.
success
(
intl
.
formatMessage
({
id
:
'user.dengluchenggong'
}))
setAuth
(
data
)
setRouters
(
data
.
auth
)
clearRecentVisit
()
// 此处需使用href跳转, 否则无法触发app.ts中的路由初始化校验
if
(
redirect
)
{
window
.
location
.
replace
(
decodeURIComponent
(
atob
(
redirect
)))
...
...
src/utils/lru.ts
View file @
fa1af3ad
...
...
@@ -4,6 +4,8 @@
* 双向链表 用JSON.stringify 会报错,应该是因为有一个环
*/
import
{
setRecentVisit
,
getRecentVisit
}
from
'./recentVisit'
;
const
LRUCache
=
function
(
capacity
:
number
)
{
this
.
cache
=
new
Map
();
...
...
@@ -12,7 +14,7 @@ const LRUCache = function (capacity: number) {
};
LRUCache
.
prototype
.
init
=
function
()
{
const
recentVisit
=
localStorage
.
getItem
(
'recentVisit'
)
&&
JSON
.
parse
(
localStorage
.
getItem
(
'recentVisit'
))
||
{}
;
const
recentVisit
=
getRecentVisit
()
;
Object
.
keys
(
recentVisit
).
map
((
item
)
=>
{
this
.
cache
.
set
(
item
,
recentVisit
[
item
]);
})
...
...
@@ -33,7 +35,7 @@ LRUCache.prototype.put = function (key: string, value: string) {
for
(
var
[
k
,
v
]
of
this
.
cache
)
{
data
[
k
]
=
v
}
localStorage
.
setItem
(
"recentVisit"
,
JSON
.
stringify
(
data
))
setRecentVisit
(
data
);
};
...
...
src/utils/recentVisit.ts
0 → 100644
View file @
fa1af3ad
type
RecentVisitType
=
{
[
key
:
string
]:
string
}
const
recentVisitKey
=
'recentVisit'
;
/**
* 设置最近访问本地存储数据
* @param data
*/
export
const
setRecentVisit
=
(
data
:
RecentVisitType
)
=>
{
localStorage
.
setItem
(
recentVisitKey
,
JSON
.
stringify
(
data
));
};
/**
* 获取最近访问本地存储数据
* @param data
*/
export
const
getRecentVisit
=
():
RecentVisitType
=>
{
const
stora
=
localStorage
.
getItem
(
recentVisitKey
);
const
recentVisit
:
RecentVisitType
=
stora
?
JSON
.
parse
(
stora
)
:
{};
return
recentVisit
;
};
/**
* 清除最近访问本地存储数据
* @param data
*/
export
const
clearRecentVisit
=
()
=>
{
localStorage
.
removeItem
(
recentVisitKey
);
};
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment