Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
op-web-service
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
bp
op-web-service
Commits
1389ded3
Commit
1389ded3
authored
May 31, 2021
by
lvweichao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: api uri
parent
5908974b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
22 deletions
+6
-22
App.vue
src/App.vue
+1
-17
common.js
src/service/common.js
+1
-1
user.js
src/service/user.js
+3
-3
index.js
src/store/index.js
+1
-1
No files found.
src/App.vue
View file @
1389ded3
<
template
>
<
template
>
<div>
<div>
<router-view
/>
<router-view
/>
<!--
<layout>
</layout>
-->
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
// Layout 为布局组件,控制页面基础布局,通过 slot 实现
// import Layout from '@/layouts';
import
{
fetchCurrentUser
}
from
'./service/user'
;
import
{
fetchCurrentUser
}
from
'./service/user'
;
// async function isUserLogged() {
// const res = await fetchCurrentUser()
// return res.status === 'success';
// }
function
redirectToLogin
()
{
function
redirectToLogin
()
{
const
loginUrl
=
'//pandora.yidian-inc.com/tools/admin/login'
;
const
loginUrl
=
'//pandora.yidian-inc.com/tools/admin/login'
;
const
cbUrl
=
location
.
href
;
const
cbUrl
=
location
.
href
;
...
@@ -24,21 +15,14 @@ function redirectToLogin() {
...
@@ -24,21 +15,14 @@ function redirectToLogin() {
export
default
{
export
default
{
async
mounted
()
{
async
mounted
()
{
// http://dev.yidian-inc.com:8081/home
const
{
status
,
user
}
=
await
fetchCurrentUser
();
const
{
status
,
user
}
=
await
fetchCurrentUser
();
// {"status":"success","user":{"userid":"732473439","name":"吕伟朝","email":"lvweichao@yidian-inc.com","avatar":""}}
// {"status":"success","user":{"userid":"732473439","name":"吕伟朝","email":"lvweichao@yidian-inc.com","avatar":""}}
if
(
status
===
'success'
)
{
if
(
status
===
'success'
)
{
this
.
$store
.
dispatch
(
'updateUserPermission'
,
{
email
:
user
.
email
})
this
.
$store
.
dispatch
(
'updateUserPermission'
,
{
email
:
user
.
email
})
this
.
$store
.
commit
(
'updateUserInfo'
,
user
)
this
.
$store
.
commit
(
'updateUserInfo'
,
user
)
}
else
{
}
else
{
redirectToLogin
();
redirectToLogin
();
}
}
// if (!(await isUserLogged())) {
// redirectToLogin();
// } else {
// }
},
},
};
};
</
script
>
</
script
>
...
...
src/service/common.js
View file @
1389ded3
import
axios
from
'../utils/request'
;
import
axios
from
'../utils/request'
;
export
async
function
userLogin
(
email
,
password
)
{
export
async
function
userLogin
(
email
,
password
)
{
let
res
=
await
axios
.
post
(
`api/v1/login`
,
{
let
res
=
await
axios
.
post
(
`
/
api/v1/login`
,
{
email
,
password
,
authCode
:
''
email
,
password
,
authCode
:
''
});
});
return
res
.
data
;
return
res
.
data
;
...
...
src/service/user.js
View file @
1389ded3
import
axios
from
'../utils/request'
;
import
axios
from
'../utils/request'
;
export
async
function
login
(
email
,
password
)
{
export
async
function
login
(
email
,
password
)
{
const
res
=
await
axios
.
post
(
`api/v1/login`
,
{
const
res
=
await
axios
.
post
(
`
/
api/v1/login`
,
{
email
,
password
,
authCode
:
''
email
,
password
,
authCode
:
''
});
});
return
res
.
data
;
return
res
.
data
;
}
}
export
async
function
fetchCurrentUser
()
{
export
async
function
fetchCurrentUser
()
{
return
await
axios
.
get
(
"api/v1/fetch_user"
);
return
await
axios
.
get
(
"
/
api/v1/fetch_user"
);
}
}
export
async
function
getPermissions
(
email
)
{
export
async
function
getPermissions
(
email
)
{
console
.
log
(
"fe service, getPermissions:::"
,
email
)
console
.
log
(
"fe service, getPermissions:::"
,
email
)
return
await
axios
.
get
(
"api/v1/user/get_permissions"
,
{
params
:
{
email
}
});
return
await
axios
.
get
(
"
/
api/v1/user/get_permissions"
,
{
params
:
{
email
}
});
}
}
\ No newline at end of file
src/store/index.js
View file @
1389ded3
...
@@ -16,7 +16,7 @@ export default createStore({
...
@@ -16,7 +16,7 @@ export default createStore({
},
},
actions
:
{
actions
:
{
async
updateUserPermission
({
commit
},
payload
)
{
async
updateUserPermission
({
commit
},
payload
)
{
const
permissions
=
await
getPermissions
(
payload
.
email
);
const
{
permissions
=
[]
}
=
await
getPermissions
(
payload
.
email
);
console
.
log
(
"VUEX action updateUserPermission::"
,
permissions
);
console
.
log
(
"VUEX action updateUserPermission::"
,
permissions
);
commit
(
'updateUserPermission'
,
permissions
)
commit
(
'updateUserPermission'
,
permissions
)
}
}
...
...
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