Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ethan
/
ant-admin-pro
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 88501355
authored
2018-02-06 11:25:00 +0800
by
ethanlamzs
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
嵌入--自有业务系统的权限验证模块控制逻辑
1 parent
0753a98b
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
58 additions
and
18 deletions
.roadhogrc.mock.js
mock/rule.js
src/routes/devutil/schoollist.js
src/services/devutil.js
src/services/user.js
src/utils/authority.js
src/utils/request.js
.roadhogrc.mock.js
View file @
8850135
...
...
@@ -32,6 +32,7 @@ const proxy = {
avatar
:
'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png'
,
userid
:
'00000001'
,
notifyCount
:
12
,
//code:'10007',
},
},
// GET POST 可省略
...
...
@@ -73,6 +74,20 @@ const proxy = {
'GET /api/fake_chart_data'
:
getFakeChartData
,
'GET /api/profile/basic'
:
getProfileBasicData
,
'GET /api/profile/advanced'
:
getProfileAdvancedData
,
'POST /api/token/get'
:
(
req
,
res
)
=>
{
const
{
secret
,
account
,
type
}
=
req
.
body
;
if
(
secret
===
'888888'
&&
account
===
'admin'
){
res
.
send
({
token
:{
value
:
'xxxxxxx---xxxxx----xxxx'
},
ext
:{
status
:
'ok'
,
type
,
currentAuthority
:
'admin'
}
});
return
;
}
},
'POST /api/login/account'
:
(
req
,
res
)
=>
{
const
{
secret
,
account
,
type
}
=
req
.
body
;
if
(
secret
===
'888888'
&&
account
===
'admin'
){
...
...
@@ -170,4 +185,5 @@ const proxy = {
},
};
export
default
noProxy
?
{
"GET /*"
:
"http://127.0.0.1:8091/"
,
"POST /*"
:
"http://127.0.0.1:8091/"
}
:
delay
(
proxy
,
1000
);
//export default noProxy ? { "GET /*": "http://www.weixiao100.cn/","POST /*": "http://www.weixiao100.cn/" } : delay(proxy, 1000);
export
default
noProxy
?
{
"GET /*"
:
"http://127.0.0.1:8091/"
,
"POST /*"
:
"http://127.0.0.1:8091/"
}
:
delay
(
proxy
,
1000
);
\ No newline at end of file
mock/rule.js
View file @
8850135
...
...
@@ -62,6 +62,7 @@ export function getRule(req, res, u) {
const
result
=
{
list
:
dataSource
,
//code:'10007',
pagination
:
{
total
:
dataSource
.
length
,
pageSize
,
...
...
src/routes/devutil/schoollist.js
View file @
8850135
...
...
@@ -130,6 +130,8 @@ export default class schoollist extends PureComponent {
renderSimpleForm
()
{
const
{
getFieldDecorator
}
=
this
.
props
.
form
;
const
{
areas
:{
list
}}
=
this
.
props
;
let
area_SellectOption
=
(
list
==
null
||
list
==
undefined
)?[]:
list
;
return
(
<
Form
onSubmit
=
{
this
.
handleSearch
}
layout
=
"inline"
>
<
Row
gutter
=
{{
md
:
8
,
lg
:
24
,
xl
:
48
}}
>
...
...
@@ -137,7 +139,7 @@ export default class schoollist extends PureComponent {
<
FormItem
label
=
"地区"
>
{
getFieldDecorator
(
'areaCode'
)(
<
Select
placeholder
=
"非精确查询,需要选择地区"
style
=
{{
width
:
'100%'
}}
>
{
this
.
renderSellectOption
(
this
.
props
.
areas
.
list
.
sort
(
this
.
areasort
))}
{
this
.
renderSellectOption
(
area_SellectOption
.
sort
(
this
.
areasort
))}
<
/Select
>
)}
<
/FormItem
>
...
...
src/services/devutil.js
View file @
8850135
import
{
stringify
}
from
'qs'
;
import
request
from
'../utils/request'
;
import
{
getToken
}
from
'../utils/authority'
;
import
{
getToken
,
availToken
}
from
'../utils/authority'
;
//处理请求的合法性问题
export
function
availToken
(
params
){
console
.
log
(
'availToken'
);
if
(
params
==
undefined
)
params
=
{
}
console
.
log
(
params
);
let
tokeninfo
=
getToken
();
params
.
tpAccount
=
tokeninfo
.
tpAccount
;
params
.
tpToken
=
tokeninfo
.
tpToken
;
console
.
log
(
params
);
return
params
;
}
//获取微校的学校数据
...
...
src/services/user.js
View file @
8850135
import
{
stringify
}
from
'qs'
;
import
request
from
'../utils/request'
;
import
{
getToken
,
availToken
}
from
'../utils/authority'
;
export
async
function
query
()
{
return
request
(
'/api/users'
);
}
export
async
function
queryCurrent
()
{
return
request
(
'/api/currentUser'
);
let
params
=
availToken
(
null
);
return
request
(
`/api/currentUser?
${
stringify
(
params
)}
`
);
}
src/utils/authority.js
View file @
8850135
...
...
@@ -17,4 +17,18 @@ export function getToken(){
tpAccount
:
localStorage
.
getItem
(
'tpAccount'
),
tpToken
:
localStorage
.
getItem
(
'session_token'
)
};
}
//处理请求的合法性问题
export
function
availToken
(
params
){
//console.log('availToken');
if
(
params
==
undefined
)
params
=
{
}
//console.log(params);
let
tokeninfo
=
getToken
();
params
.
tpAccount
=
tokeninfo
.
tpAccount
;
params
.
tpToken
=
tokeninfo
.
tpToken
;
//console.log(params);
return
params
;
}
\ No newline at end of file
src/utils/request.js
View file @
8850135
...
...
@@ -63,8 +63,22 @@ export default function request(url, options) {
return
response
.
text
();
}
return
response
.
json
();
})
.
catch
((
e
)
=>
{
}).
then
((
data
)
=>
{
console
.
log
(
'request....result=>'
+
url
);
console
.
log
(
data
);
if
(
data
&&
data
.
code
){
if
(
parseInt
(
data
.
code
)
>=
10005
&&
parseInt
(
data
.
code
)
<=
10008
){
console
.
log
(
'系统异常登陆...'
);
const
{
dispatch
}
=
store
;
console
.
log
(
data
);
dispatch
({
type
:
'login/logout'
,
});
return
data
;
}
}
return
data
;
}).
catch
((
e
)
=>
{
const
{
dispatch
}
=
store
;
if
(
e
.
name
===
401
)
{
dispatch
({
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment