Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
ops_2024_vue
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
ops_2024_vue
Commits
9e9e4f8f
Commit
9e9e4f8f
authored
Mar 31, 2024
by
heduo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(hd):登录异常问题
parent
754206f1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
33 deletions
+44
-33
src/api/sys/user.ts
src/api/sys/user.ts
+5
-2
src/layouts/default/header/components/user-dropdown/index.vue
...layouts/default/header/components/user-dropdown/index.vue
+7
-3
src/store/modules/user.ts
src/store/modules/user.ts
+23
-18
src/views/sys/login/LoginForm.vue
src/views/sys/login/LoginForm.vue
+9
-10
No files found.
src/api/sys/user.ts
View file @
9e9e4f8f
import
{
defHttp
,
tmallabHttp
}
from
'
/@/utils/http/axios
'
;
import
{
LoginParams
,
LoginResultModel
,
GetUserInfoModel
}
from
'
./model/userModel
'
;
import
{
LoginParams
,
LoginResultModel
}
from
'
./model/userModel
'
;
import
{
getAuthCache
}
from
'
/@/utils/auth
'
;
import
{
USER_INFO_KEY
}
from
'
/@/enums/cacheEnum
'
;
import
{
ErrorMessageMode
}
from
'
/#/axios
'
;
...
...
@@ -30,7 +32,8 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal')
* @description: getUserInfo
*/
export
function
getUserInfo
()
{
return
defHttp
.
get
<
GetUserInfoModel
>
({
url
:
Api
.
GetUserInfo
},
{
errorMessageMode
:
'
none
'
});
// return defHttp.get<GetUserInfoModel>({ url: Api.GetUserInfo }, { errorMessageMode: 'none' });
return
getAuthCache
(
USER_INFO_KEY
)
||
{};
}
export
function
getPermCode
()
{
...
...
src/layouts/default/header/components/user-dropdown/index.vue
View file @
9e9e4f8f
...
...
@@ -75,15 +75,19 @@
const
{
t
}
=
useI18n
();
const
{
getShowDoc
,
getUseLockPage
}
=
useHeaderSetting
();
const
userStore
=
useUserStore
();
const
getUserInfo
=
computed
(()
=>
{
console
.
log
(
'
------------
'
,
userStore
.
getUserInfo
)
console
.
log
(
'
------------
'
,
userStore
.
getUserInfo
)
;
const
{
userName
:
realName
=
''
,
avatar
,
desc
}
=
userStore
.
getUserInfo
||
{};
return
{
realName
,
avatar
:
avatar
||
headerImg
,
desc
};
});
const
{
changeRole
}
=
usePermission
();
const
roleList
=
ref
([]);
roleList
.
value
=
userStore
.
getUserInfo
.
roleList
;
roleList
.
value
=
userStore
.
getUserInfo
.
userRoles
.
map
((
v
)
=>
{
return
{
roleNum
:
v
.
roleNum
,
roleName
:
v
.
roleName
,
};
});
// const [register, { openModal }] = useModal();
const
[
register
]
=
useModal
();
...
...
src/store/modules/user.ts
View file @
9e9e4f8f
...
...
@@ -49,7 +49,7 @@ export const useUserStore = defineStore({
}),
getters
:
{
getUserInfo
():
GetUserInfoModel
{
return
this
.
userInfo
||
getAuthCache
<
UserInfo
>
(
USER_INFO_KEY
)
||
{};
return
getAuthCache
<
UserInfo
>
(
USER_INFO_KEY
)
||
{};
},
getToken
():
string
{
return
this
.
token
||
getAuthCache
<
string
>
(
TOKEN_KEY
);
...
...
@@ -119,15 +119,19 @@ export const useUserStore = defineStore({
},
//数据对接模拟登录
async
tmallabSimulationLogin
(
params
:
{
loginName
:
string
;
password
:
string
}):
Promise
<
any
>
{
try
{
const
data
=
await
tmallabLoginApi
(
params
);
this
.
setTmallabToken
(
data
.
token
);
return
data
;
this
.
setToken
(
data
.
token
);
return
this
.
afterLoginAction
(
true
,
data
);
}
catch
(
error
)
{
return
Promise
.
reject
(
error
);
}
},
async
afterLoginAction
(
goHome
?:
boolean
):
Promise
<
GetUserInfoModel
|
null
>
{
if
(
!
this
.
getToken
)
return
null
;
async
afterLoginAction
(
goHome
?:
boolean
,
data
?:
any
):
Promise
<
GetUserInfoModel
|
null
>
{
if
(
!
this
.
getT
mallabT
oken
)
return
null
;
// get user info
const
userInfo
=
await
getUserInfo
();
const
userInfo
=
await
this
.
getUserInfoAction
(
data
);
const
sessionTimeout
=
this
.
sessionTimeout
;
if
(
sessionTimeout
)
{
this
.
setSessionTimeout
(
false
);
...
...
@@ -147,19 +151,20 @@ export const useUserStore = defineStore({
this
.
setUserInfo
(
userInfo
);
return
userInfo
;
},
async
getUserInfoAction
():
Promise
<
UserInfo
|
null
>
{
if
(
!
this
.
getToken
)
return
null
;
let
userInfo
:
any
=
this
.
userInfo
;
if
(
!
userInfo
.
userId
)
{
userInfo
=
await
getUserInfo
();
}
const
{
roles
=
[]
}
=
userInfo
;
if
(
isArray
(
roles
))
{
const
role
=
userInfo
.
roleNum
;
async
getUserInfoAction
(
data
):
Promise
<
UserInfo
|
null
>
{
if
(
!
this
.
getTmallabToken
)
return
null
;
const
userInfo
=
data
;
// if (!userInfo.userId) {
// userInfo = await getUserInfo();
// }
const
{
userRoles
}
=
userInfo
;
if
(
isArray
(
userRoles
))
{
const
role
=
userInfo
.
userRoles
[
0
].
roleNum
;
//取第一个为默认角色
const
roleList
=
Array
.
from
(
RoleEnum
[
role
]);
this
.
setRoleList
(
roleList
as
[]);
}
else
{
userInfo
.
r
oles
=
[];
userInfo
.
userR
oles
=
[];
this
.
setRoleList
([]);
}
this
.
setUserInfo
(
userInfo
);
...
...
src/views/sys/login/LoginForm.vue
View file @
9e9e4f8f
...
...
@@ -135,8 +135,8 @@
const
rememberMe
=
ref
(
false
);
const
formData
=
reactive
({
account
:
'
t1
'
,
password
:
'
123456Aa@
'
,
account
:
''
,
password
:
''
,
});
const
{
validForm
}
=
useFormValid
(
formRef
);
...
...
@@ -150,18 +150,17 @@
if
(
!
data
)
return
;
try
{
loading
.
value
=
true
;
let
jsEncrypt
=
new
JSEncrypt
();
jsEncrypt
.
setPublicKey
(
RSA_PUBLIC_KEY
);
const
encryptPwd
:
string
=
jsEncrypt
.
encrypt
(
data
.
password
)
as
string
;
const
userInfo
=
await
userStore
.
login
({
password
:
encryptPwd
,
username
:
data
.
account
,
mode
:
'
none
'
,
//不要默认的错误提示
// let jsEncrypt = new JSEncrypt();
// jsEncrypt.setPublicKey(RSA_PUBLIC_KEY);
// const encryptPwd: string = jsEncrypt.encrypt(data.password) as string;
const
userInfo
=
await
userStore
.
tmallabSimulationLogin
({
password
:
formData
.
password
,
loginName
:
formData
.
account
,
});
if
(
userInfo
)
{
notification
.
success
({
message
:
t
(
'
sys.login.loginSuccessTitle
'
),
description
:
`
${
t
(
'
sys.login.loginSuccessDesc
'
)}
:
${
userInfo
.
userN
ame
}
`
,
description
:
`
${
t
(
'
sys.login.loginSuccessDesc
'
)}
:
${
userInfo
.
n
ame
}
`
,
duration
:
3
,
});
}
...
...
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