Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pptist
Project
Project
Details
Activity
Releases
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
viitto
pptist
Commits
965eec33
Commit
965eec33
authored
May 21, 2024
by
罗超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改自动登录
parent
b3aa323e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
31 deletions
+39
-31
UserService.ts
src/services/UserService.ts
+3
-3
user.ts
src/store/user.ts
+25
-17
AutoLogin.vue
src/views/Auth/AutoLogin.vue
+11
-11
No files found.
src/services/UserService.ts
View file @
965eec33
...
@@ -3,9 +3,9 @@ import Api,{ HttpResponse, Result } from './../utils/request';
...
@@ -3,9 +3,9 @@ import Api,{ HttpResponse, Result } from './../utils/request';
class
UserServices
{
class
UserServices
{
static
async
AutoLoginAsync
(
userId
:
number
):
Promise
<
HttpResponse
>
{
static
async
AutoLoginAsync
(
t
:
string
):
Promise
<
HttpResponse
>
{
let
msg
=
{
EmployeeId
:
userId
}
let
msg
=
{
t
}
return
Api
.
Post
(
"
admin_get_GetErpLoginInfoByUid
"
,
msg
)
return
Api
.
Post
(
"
travel_auto_login
"
,
msg
)
}
}
static
async
PasswordLoginAsync
(
account
:
string
,
pwd
:
string
,
tid
:
string
=
''
):
Promise
<
HttpResponse
>
{
static
async
PasswordLoginAsync
(
account
:
string
,
pwd
:
string
,
tid
:
string
=
''
):
Promise
<
HttpResponse
>
{
...
...
src/store/user.ts
View file @
965eec33
...
@@ -23,6 +23,10 @@ export interface UserLoginResult {
...
@@ -23,6 +23,10 @@ export interface UserLoginResult {
status
:
'ERROR'
|
'CHOSEN'
|
'SUCCESS'
,
status
:
'ERROR'
|
'CHOSEN'
|
'SUCCESS'
,
data
?:
any
[]
data
?:
any
[]
}
}
export
interface
AutoLoginResult
{
isSuccess
:
boolean
,
message
:
string
}
export
const
useUserStore
=
defineStore
(
'user'
,
{
export
const
useUserStore
=
defineStore
(
'user'
,
{
state
:()
=>
({
state
:()
=>
({
...
@@ -46,34 +50,38 @@ export const useUserStore = defineStore('user', {
...
@@ -46,34 +50,38 @@ export const useUserStore = defineStore('user', {
},
},
},
},
actions
:{
actions
:{
async
setUserAutoLoginAsync
(
userId
:
number
)
{
async
setUserAutoLoginAsync
(
tempToken
:
string
):
Promise
<
AutoLoginResult
>
{
try
{
try
{
let
response
=
await
UserService
.
AutoLoginAsync
(
userId
)
const
response
=
await
UserService
.
AutoLoginAsync
(
tempToken
)
if
(
response
.
data
.
resultCode
==
ApiResult
.
SUCCESS
)
{
if
(
response
.
data
.
resultCode
==
ApiResult
.
SUCCESS
)
{
const
d
=
response
.
data
.
data
const
d
=
response
.
data
.
data
// d.nickname=d.emName
// d.photo = d.Icon
// d.company = d.GroupName
// d.logo = d.GroupPic
// d.isTemplate = d.IsEditTripTemplate
// d.ia = 0
// d.it = true
// d.expire = d.Expire
// d.ic = d.IsGroupCreate
// d.id = d.DisplayId
// d.iv = 0
this
.
token
=
d
.
token
this
.
token
=
d
.
token
d
.
nickname
=
d
.
emName
this
.
userInfo
=
d
.
userinfo
d
.
photo
=
d
.
Icon
d
.
company
=
d
.
GroupName
d
.
logo
=
d
.
GroupPic
d
.
isTemplate
=
d
.
IsEditTripTemplate
d
.
ia
=
0
d
.
it
=
true
d
.
expire
=
d
.
Expire
d
.
ic
=
d
.
IsGroupCreate
d
.
id
=
d
.
DisplayId
d
.
iv
=
0
this
.
userInfo
=
d
if
(
!
this
.
userInfo
.
photo
||
!
this
.
userInfo
.
photo
.
includes
(
'http://'
)
||
!
this
.
userInfo
.
photo
.
includes
(
'https://'
)){
if
(
!
this
.
userInfo
.
photo
||
!
this
.
userInfo
.
photo
.
includes
(
'http://'
)
||
!
this
.
userInfo
.
photo
.
includes
(
'https://'
)){
this
.
userInfo
.
photo
=
USER_DEFAULT_HEADER
this
.
userInfo
.
photo
=
USER_DEFAULT_HEADER
}
}
if
(
!
this
.
userInfo
.
logo
||
!
this
.
userInfo
.
logo
.
includes
(
'http://'
)
||
!
this
.
userInfo
.
logo
.
includes
(
'https://'
)){
if
(
!
this
.
userInfo
.
logo
||
!
this
.
userInfo
.
logo
.
includes
(
'http://'
)
||
!
this
.
userInfo
.
logo
.
includes
(
'https://'
)){
this
.
userInfo
.
logo
=
ENTERPRISE_DEFAULT_HEADER
this
.
userInfo
.
logo
=
ENTERPRISE_DEFAULT_HEADER
}
}
return
true
return
{
isSuccess
:
true
,
message
:
''
}
}
else
{
return
{
isSuccess
:
false
,
message
:
response
.
data
.
message
}
}
}
}
catch
(
error
)
{}
}
catch
(
error
)
{
return
false
return
{
isSuccess
:
false
,
message
:
'登录异常,请刷新页面重试'
}
}
},
},
setUserLoginOut
(){
setUserLoginOut
(){
this
.
token
=
''
this
.
token
=
''
...
...
src/views/Auth/AutoLogin.vue
View file @
965eec33
<
template
>
<
template
>
<div
class=
"full-height column flex-center items-center"
v-if=
"
!result
"
>
<div
class=
"full-height column flex-center items-center"
v-if=
"
result && !result.isSuccess
"
>
<el-empty
:image-size=
"200"
description=
"抱歉,你的账户信息不存在
"
/>
<el-empty
:image-size=
"200"
:description=
"result.message
"
/>
</div>
</div>
</
template
>
</
template
>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
useUserStore
}
from
'@/store/user'
;
import
{
AutoLoginResult
,
useUserStore
}
from
'@/store/user'
;
import
{
query
}
from
'@/utils/common'
;
import
{
query
}
from
'@/utils/common'
;
import
{
ElLoading
}
from
'element-plus'
;
import
{
ElLoading
}
from
'element-plus'
;
import
{
ref
}
from
'vue'
;
import
{
ref
}
from
'vue'
;
...
@@ -14,16 +14,16 @@ import { useRouter } from 'vue-router';
...
@@ -14,16 +14,16 @@ import { useRouter } from 'vue-router';
const
router
=
useRouter
();
const
router
=
useRouter
();
const
forword
=
decodeURIComponent
(
router
.
currentRoute
.
value
.
query
.
forword
)
const
forword
=
decodeURIComponent
(
router
.
currentRoute
.
value
.
query
.
forword
)
const
param
=
query
(
forword
)
const
param
=
query
(
forword
)
const
result
=
ref
(
true
)
const
result
=
ref
<
AutoLoginResult
|
null
>
(
null
)
const
userLoginHandler
=
async
()
=>
{
const
userLoginHandler
=
async
()
=>
{
const
loading
=
ElLoading
.
service
({
const
loading
=
ElLoading
.
service
({
fullscreen
:
true
,
fullscreen
:
true
,
lock
:
true
lock
:
true
})
})
if
(
param
.
uid
){
if
(
param
.
uid
&&
param
.
uid
!=
''
){
let
response
=
await
useUserStore
().
setUserAutoLoginAsync
(
parseInt
(
param
.
uid
)
)
const
response
=
await
useUserStore
().
setUserAutoLoginAsync
(
param
.
uid
)
if
(
response
){
if
(
response
.
isSuccess
){
if
(
param
.
model
==
'0'
)
{
if
(
param
.
model
==
'0'
)
{
router
.
push
({
router
.
push
({
path
:
`/team_editor/
${
param
.
ConfigId
}
`
path
:
`/team_editor/
${
param
.
ConfigId
}
`
...
@@ -37,11 +37,11 @@ const userLoginHandler = async ()=>{
...
@@ -37,11 +37,11 @@ const userLoginHandler = async ()=>{
path
:
"/space"
path
:
"/space"
})
})
}
}
return
}
}
}
result
.
value
=
false
result
.
value
=
response
}
else
result
.
value
=
{
isSuccess
:
false
,
message
:
'无法获取到令牌信息'
}
loading
.
close
()
}
}
userLoginHandler
()
userLoginHandler
()
</
script
>
</
script
>
...
...
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