Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
app-manage-console
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
ReactNative
app-manage-console
Commits
0495c15c
提交
0495c15c
authored
9月 07, 2017
作者:
vipcxj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: delete方法不能保护http body,传参必须用query参数。
fix: 生成菜单数据出错。
上级
76451936
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
54 行增加
和
35 行删除
+54
-35
index.js
src/models/main/index.js
+36
-14
delete.js
src/utils/delete.js
+18
-21
没有找到文件。
src/models/main/index.js
浏览文件 @
0495c15c
import
{
routerRedux
}
from
'dva/router'
;
import
{
routerRedux
}
from
'dva/router'
;
import
{
isString
}
from
'lodash'
;
import
{
logout
}
from
'../../services/main'
;
import
{
logout
}
from
'../../services/main'
;
import
{
fetchDomains
,
switchDomain
,
currentDomain
}
from
'../../services/domain'
;
import
{
fetchDomains
,
switchDomain
,
currentDomain
}
from
'../../services/domain'
;
import
{
cookie
}
from
'../../utils/config'
;
import
{
cookie
}
from
'../../utils/config'
;
import
{
getMenus
}
from
'../../data/modules'
;
import
{
getMenus
,
getModuleInfo
}
from
'../../data/modules'
;
import
{
setCookie
,
delCookie
,
fullPath
,
getCookie
}
from
'../../utils/helper'
;
import
{
setCookie
,
delCookie
,
fullPath
,
getCookie
}
from
'../../utils/helper'
;
const
createMenu
=
(
configure
)
=>
{
const
createMenu
=
async
(
configure
)
=>
{
return
{
const
menu
=
{
name
:
configure
.
name
,
name
:
configure
.
name
,
icon
:
configure
.
icon
,
icon
:
configure
.
icon
,
text
:
configure
.
showName
,
text
:
configure
.
showName
,
children
:
[
...(
configure
.
children
||
[]).
map
(
child
=>
createMenu
(
child
)),
...(
configure
.
modules
||
[]).
map
(
module
=>
({
name
:
module
.
name
,
icon
:
module
.
icon
,
text
:
module
.
showName
,
})),
],
};
};
if
(
!
menu
.
children
)
{
menu
.
children
=
[];
}
if
(
configure
.
children
)
{
for
(
const
child
of
configure
.
children
)
{
menu
.
children
.
push
(
await
createMenu
(
child
));
}
}
if
(
configure
.
modules
)
{
for
(
const
module
of
configure
.
modules
)
{
let
info
=
module
;
if
(
isString
(
module
))
{
info
=
await
getModuleInfo
(
module
);
}
menu
.
children
.
push
({
name
:
info
.
name
,
icon
:
info
.
icon
,
text
:
info
.
showName
,
});
}
}
return
menu
;
};
};
const
createMenus
=
(
menusConfigure
)
=>
{
const
createMenus
=
async
(
menusConfigure
)
=>
{
return
(
menusConfigure
||
[]).
map
(
configure
=>
createMenu
(
configure
));
const
menus
=
[];
if
(
menusConfigure
)
{
for
(
const
configure
of
menusConfigure
)
{
menus
.
push
(
await
createMenu
(
configure
));
}
}
return
menus
;
};
};
// const createMenus = () => {
// const createMenus = () => {
...
@@ -122,7 +143,8 @@ export default {
...
@@ -122,7 +143,8 @@ export default {
},
},
*
fetchModules
(
action
,
{
put
,
call
})
{
*
fetchModules
(
action
,
{
put
,
call
})
{
const
configures
=
yield
call
(
getMenus
);
const
configures
=
yield
call
(
getMenus
);
yield
put
({
type
:
'queryMenusSuccess'
,
payload
:
createMenus
(
configures
)
});
const
menus
=
yield
call
(
createMenus
,
configures
);
yield
put
({
type
:
'queryMenusSuccess'
,
payload
:
menus
});
},
},
*
logout
(
action
,
{
put
,
call
})
{
*
logout
(
action
,
{
put
,
call
})
{
yield
call
(
logout
);
yield
call
(
logout
);
...
...
src/utils/delete.js
浏览文件 @
0495c15c
/* eslint-disable no-param-reassign */
import
fetch
from
'dva/fetch'
;
import
fetch
from
'dva/fetch'
;
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
{
getCookie
,
encrypt
}
from
'./helper'
;
import
{
getCookie
,
encrypt
}
from
'./helper'
;
import
{
checkStatus
,
normParams
,
parseObject
}
from
'./http-helper'
;
import
{
cookie
}
from
'./config'
;
import
{
cookie
}
from
'./config'
;
import
{
errors
}
from
'./error'
;
import
{
errors
}
from
'./error'
;
import
{
checkStatus
,
normParams
,
parseObject
}
from
'./http-helper'
;
const
defaultOptions
=
{
const
defaultOptions
=
{
headers
:
{
headers
:
{
Accept
:
'application/json'
},
Accept
:
'application/json'
,
},
};
};
/**
export
default
function
doDelete
(
url
,
data
,
params
=
{},
options
=
{},
auth
=
true
)
{
* Requests a URL, returning a promise.
if
(
!
data
)
{
*
data
=
{};
* @param {string} url The URL we want to request
}
* @param auth
* @param params
* @param {object} [options] The options we want to pass to "fetch"
* @return {object} An object containing either "data" or "err"
*/
export
default
function
doDelete
(
url
,
params
=
{},
options
=
{},
auth
=
true
)
{
let
token
;
if
(
auth
)
{
if
(
auth
)
{
const
token
=
getCookie
(
cookie
.
token
);
token
=
getCookie
(
cookie
.
token
);
if
(
!
token
)
{
if
(
!
token
)
{
return
Promise
.
reject
(
errors
.
tokenMissing
());
return
Promise
.
reject
(
errors
.
tokenMissing
());
}
}
data
.
token
=
encrypt
(
token
);
token
=
encrypt
(
token
);
}
}
let
queryParams
=
normParams
(
params
);
let
queryParams
=
token
?
[...
normParams
(
params
),
[
'token'
,
token
]]
:
normParams
(
params
);
queryParams
=
queryParams
.
map
(([
k
,
v
])
=>
(
_
.
isNil
(
v
)
?
k
:
`
${
k
}
=
${
encodeURIComponent
(
v
)}
`
));
queryParams
=
queryParams
.
map
(([
k
,
v
])
=>
(
_
.
isNil
(
v
)
?
k
:
`
${
k
}
=
${
encodeURIComponent
(
v
)}
`
));
queryParams
=
queryParams
.
join
(
'&'
);
queryParams
=
queryParams
.
join
(
'&'
);
let
realUrl
=
url
;
let
realUrl
=
url
;
...
@@ -32,15 +35,9 @@ export default function doDelete(url, data, params = {}, options = {}, auth = tr
...
@@ -32,15 +35,9 @@ export default function doDelete(url, data, params = {}, options = {}, auth = tr
realUrl
=
`
${
url
}
?
${
queryParams
}
`
;
realUrl
=
`
${
url
}
?
${
queryParams
}
`
;
}
}
const
realOptions
=
_
.
defaults
(
options
,
defaultOptions
);
const
realOptions
=
_
.
defaults
(
options
,
defaultOptions
);
if
(
!
realOptions
.
headers
)
{
realOptions
.
method
=
'POST'
;
realOptions
.
headers
=
{
Accept
:
'application/json'
,
};
}
realOptions
.
headers
[
'Content-Type'
]
=
'application/json'
;
realOptions
.
method
=
'DELETE'
;
realOptions
.
body
=
JSON
.
stringify
(
data
);
return
fetch
(
realUrl
,
realOptions
)
return
fetch
(
realUrl
,
realOptions
)
.
then
(
checkStatus
)
.
then
(
checkStatus
)
.
then
(
parseObject
);
.
then
(
parseObject
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论