Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sun
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
1
Merge Requests
1
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
alpha
sun
Commits
69fac6b5
Commit
69fac6b5
authored
Nov 16, 2018
by
Davve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加登陆登出功能
parent
c667d57b
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
49 additions
and
54 deletions
+49
-54
account.py
api/account.py
+35
-0
urls.py
api/urls.py
+4
-0
login.js
vu/src/api/login.js
+2
-2
pick.js
vu/src/api/pick.js
+1
-0
index.js
vu/src/mock/index.js
+1
-1
user.js
vu/src/store/modules/user.js
+1
-1
Navbar.vue
vu/src/views/layout/components/Navbar.vue
+3
-6
index.vue
vu/src/views/login/index.vue
+2
-44
No files found.
api/account.py
0 → 100644
View file @
69fac6b5
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# __author__ = "chenwei"
# Date: 2018/11/16
from
utils.base
import
APIView
class
LoginView
(
APIView
):
def
post
(
self
,
request
):
username
=
request
.
POST
.
get
(
'username'
)
password
=
request
.
POST
.
get
(
'password'
)
if
username
==
'admin'
and
password
==
'123123'
:
return
{
'roles'
:
[
'admin'
],
'token'
:
'admin'
,
'introduction'
:
'我是超级管理员'
,
'avatar'
:
'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif'
,
'name'
:
'Super Admin'
}
else
:
return
{
'roles'
:
[
'editor'
],
'token'
:
'editor'
,
'introduction'
:
'我是编辑'
,
'avatar'
:
'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif'
,
'name'
:
'Normal Editor'
}
class
LogoutView
(
APIView
):
def
post
(
self
,
request
):
pass
\ No newline at end of file
api/urls.py
View file @
69fac6b5
...
...
@@ -12,8 +12,12 @@ from .group import *
from
.user
import
*
from
.topic
import
*
from
.star
import
*
from
.account
import
*
urlpatterns
=
[
# 登陆,注销相关
url
(
r'account/login$'
,
LoginView
.
as_view
()),
url
(
r'account/logout'
,
LogoutView
.
as_view
()),
# user相关
url
(
r'user/list$'
,
UserListView
.
as_view
()),
...
...
vu/src/api/login.js
View file @
69fac6b5
...
...
@@ -6,7 +6,7 @@ export function loginByUsername(username, password) {
password
}
return
request
({
url
:
'/
login
/login'
,
url
:
'/
api/account
/login'
,
method
:
'post'
,
data
})
...
...
@@ -14,7 +14,7 @@ export function loginByUsername(username, password) {
export
function
logout
()
{
return
request
({
url
:
'/
login
/logout'
,
url
:
'/
api/account
/logout'
,
method
:
'post'
})
}
...
...
vu/src/api/pick.js
View file @
69fac6b5
...
...
@@ -10,6 +10,7 @@ export function fetchList(query) {
export
function
OffLineOrOnLine
(
data
)
{
console
.
log
(
data
)
return
request
({
url
:
'/api/pick/update_or_create'
,
method
:
'post'
,
...
...
vu/src/mock/index.js
View file @
69fac6b5
...
...
@@ -19,7 +19,7 @@ Mock.XHR.prototype.send = function() {
// })
// 登录相关
Mock
.
mock
(
/
\/
login
\/
login/
,
'post'
,
loginAPI
.
loginByUsername
)
//
Mock.mock(/\/login\/login/, 'post', loginAPI.loginByUsername)
Mock
.
mock
(
/
\/
login
\/
logout/
,
'post'
,
loginAPI
.
logout
)
Mock
.
mock
(
/
\/
user
\/
info
\.
*/
,
'get'
,
loginAPI
.
getUserInfo
)
...
...
vu/src/store/modules/user.js
View file @
69fac6b5
...
...
@@ -49,7 +49,7 @@ const user = {
const
username
=
userInfo
.
username
.
trim
()
return
new
Promise
((
resolve
,
reject
)
=>
{
loginByUsername
(
username
,
userInfo
.
password
).
then
(
response
=>
{
const
data
=
response
.
data
const
data
=
response
.
data
.
data
commit
(
'SET_TOKEN'
,
data
.
token
)
setToken
(
response
.
data
.
token
)
resolve
()
...
...
vu/src/views/layout/components/Navbar.vue
View file @
69fac6b5
...
...
@@ -16,7 +16,6 @@
<size-select
class=
"international right-menu-item"
/>
</el-tooltip>
<lang-select
class=
"international right-menu-item"
/>
<el-tooltip
:content=
"$t('navbar.theme')"
effect=
"dark"
placement=
"bottom"
>
<theme-picker
class=
"theme-switch right-menu-item"
/>
...
...
@@ -31,16 +30,16 @@
<el-dropdown-menu
slot=
"dropdown"
>
<router-link
to=
"/"
>
<el-dropdown-item>
{{ $t('navbar.dashboard') }}
账号中心
</el-dropdown-item>
</router-link>
<a
target=
"_blank"
href=
"https://github.com/PanJiaChen/vue-element-admin/"
>
<el-dropdown-item>
{{ $t('navbar.github') }}
修改密码
</el-dropdown-item>
</a>
<el-dropdown-item
divided
>
<span
style=
"display:block;"
@
click=
"logout"
>
{{ $t('navbar.logOut') }}
</span>
<span
style=
"display:block;"
@
click=
"logout"
>
退出账户
</span>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
...
...
@@ -55,7 +54,6 @@ import Hamburger from '@/components/Hamburger'
import
ErrorLog
from
'@/components/ErrorLog'
import
Screenfull
from
'@/components/Screenfull'
import
SizeSelect
from
'@/components/SizeSelect'
import
LangSelect
from
'@/components/LangSelect'
import
ThemePicker
from
'@/components/ThemePicker'
export
default
{
...
...
@@ -65,7 +63,6 @@ export default {
ErrorLog
,
Screenfull
,
SizeSelect
,
LangSelect
,
ThemePicker
},
computed
:
{
...
...
vu/src/views/login/index.vue
View file @
69fac6b5
...
...
@@ -4,8 +4,7 @@
<el-form
ref=
"loginForm"
:model=
"loginForm"
:rules=
"loginRules"
class=
"login-form"
auto-complete=
"on"
label-position=
"left"
>
<div
class=
"title-container"
>
<h3
class=
"title"
>
{{
$t
(
'login.title'
)
}}
</h3>
<lang-select
class=
"set-language"
/>
<h3
class=
"title"
>
更美社区后台
</h3>
</div>
<el-form-item
prop=
"username"
>
...
...
@@ -36,40 +35,17 @@
<svg-icon
icon-class=
"eye"
/>
</span>
</el-form-item>
<el-button
:loading=
"loading"
type=
"primary"
style=
"width:100%;margin-bottom:30px;"
@
click
.
native
.
prevent=
"handleLogin"
>
{{
$t
(
'login.logIn'
)
}}
</el-button>
<div
class=
"tips"
>
<span>
{{
$t
(
'login.username'
)
}}
: admin
</span>
<span>
{{
$t
(
'login.password'
)
}}
:
{{
$t
(
'login.any'
)
}}
</span>
</div>
<div
class=
"tips"
>
<span
style=
"margin-right:18px;"
>
{{
$t
(
'login.username'
)
}}
: editor
</span>
<span>
{{
$t
(
'login.password'
)
}}
:
{{
$t
(
'login.any'
)
}}
</span>
</div>
<el-button
class=
"thirdparty-button"
type=
"primary"
@
click=
"showDialog=true"
>
{{
$t
(
'login.thirdparty'
)
}}
</el-button>
</el-form>
<el-dialog
:title=
"$t('login.thirdparty')"
:visible
.
sync=
"showDialog"
append-to-body
>
{{
$t
(
'login.thirdpartyTips'
)
}}
<br>
<br>
<br>
<social-sign
/>
</el-dialog>
</div>
</
template
>
<
script
>
import
{
isvalidUsername
}
from
'@/utils/validate'
import
LangSelect
from
'@/components/LangSelect'
import
SocialSign
from
'./socialsignin'
export
default
{
name
:
'Login'
,
components
:
{
LangSelect
,
SocialSign
},
data
()
{
const
validateUsername
=
(
rule
,
value
,
callback
)
=>
{
if
(
!
isvalidUsername
(
value
))
{
...
...
@@ -88,7 +64,7 @@ export default {
return
{
loginForm
:
{
username
:
'admin'
,
password
:
'1
111111
'
password
:
'1
23123
'
},
loginRules
:
{
username
:
[{
required
:
true
,
trigger
:
'blur'
,
validator
:
validateUsername
}],
...
...
@@ -139,24 +115,6 @@ export default {
}
})
},
afterQRScan
()
{
// const hash = window.location.hash.slice(1)
// const hashObj = getQueryObject(hash)
// const originUrl = window.location.origin
// history.replaceState({}, '', originUrl)
// const codeMap = {
// wechat: 'code',
// tencent: 'code'
// }
// const codeName = hashObj[codeMap[this.auth_type]]
// if (!codeName) {
// alert('第三方登录失败')
// } else {
// this.$store.dispatch('LoginByThirdparty', codeName).then(() => {
// this.$router.push({ path: '/' })
// })
// }
}
}
}
</
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