Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
app-manage-console
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
ReactNative
app-manage-console
Commits
295c43c4
提交
295c43c4
authored
11月 10, 2017
作者:
vipcxj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
去掉domain相关页面和models
上级
3b9bb58a
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
4 行增加
和
247 行删除
+4
-247
domain.js
src/models/domain.js
+0
-52
login.js
src/models/login.js
+1
-1
index.js
src/models/main/index.js
+1
-40
router.js
src/router.js
+1
-20
index.js
src/routes/domain/index.js
+0
-87
index.less
src/routes/domain/index.less
+0
-22
header.js
src/routes/main/header.js
+1
-25
没有找到文件。
src/models/domain.js
deleted
100644 → 0
浏览文件 @
3b9bb58a
import
{
routerRedux
}
from
'dva/router'
;
import
{
fetchDomains
,
switchDomain
,
currentDomain
}
from
'../services/domain'
;
import
{
fullPath
}
from
'../utils/helper'
;
import
{
getDomain
,
setDomain
}
from
'../utils/auth'
;
export
default
{
namespace
:
'domain'
,
state
:
{
init
:
undefined
,
list
:
[],
},
subscriptions
:
{
setup
({
dispatch
})
{
// eslint-disable-line
},
},
effects
:
{
*
fetch
(
ignored
,
{
put
,
call
})
{
const
domain
=
yield
call
(
getDomain
);
const
init
=
domain
?
domain
.
path
:
undefined
;
const
list
=
yield
call
(
fetchDomains
,
'/'
,
true
);
yield
put
({
type
:
'queryInit'
,
payload
:
init
});
yield
put
({
type
:
'queryList'
,
payload
:
list
});
},
*
switch
({
payload
:
domainPath
},
{
put
,
call
})
{
yield
call
(
switchDomain
,
domainPath
);
const
{
path
,
name
}
=
yield
call
(
currentDomain
);
yield
call
(
setDomain
,
name
,
path
);
yield
put
({
type
:
'queryInit'
,
payload
:
path
});
yield
put
(
routerRedux
.
push
(
fullPath
(
'/main'
)));
},
},
reducers
:
{
queryInit
(
state
,
{
payload
:
init
})
{
return
{
...
state
,
init
,
};
},
queryList
(
state
,
{
payload
:
list
})
{
return
{
...
state
,
list
,
};
},
},
};
src/models/login.js
浏览文件 @
295c43c4
...
@@ -22,7 +22,7 @@ export default {
...
@@ -22,7 +22,7 @@ export default {
yield
call
(
setToken
,
tokenId
);
yield
call
(
setToken
,
tokenId
);
const
uInfo
=
yield
call
(
userInfo
);
const
uInfo
=
yield
call
(
userInfo
);
yield
call
(
setUser
,
uInfo
.
id
,
uInfo
.
name
);
yield
call
(
setUser
,
uInfo
.
id
,
uInfo
.
name
);
yield
put
(
routerRedux
.
push
(
fullPath
(
'/
do
main'
)));
yield
put
(
routerRedux
.
push
(
fullPath
(
'/main'
)));
},
},
},
},
subscriptions
:
{},
subscriptions
:
{},
...
...
src/models/main/index.js
浏览文件 @
295c43c4
import
{
routerRedux
}
from
'dva/router'
;
import
{
routerRedux
}
from
'dva/router'
;
import
{
isString
}
from
'lodash'
;
import
{
isString
}
from
'lodash'
;
import
{
logout
}
from
'../../services/main'
;
import
{
logout
}
from
'../../services/main'
;
import
{
fetchDomains
,
switchDomain
,
currentDomain
}
from
'../../services/domain'
;
import
{
getMenus
,
getModuleInfo
}
from
'../../data/modules'
;
import
{
getMenus
,
getModuleInfo
}
from
'../../data/modules'
;
import
{
fullPath
}
from
'../../utils/helper'
;
import
{
fullPath
}
from
'../../utils/helper'
;
import
{
delToken
,
get
Domain
,
setDomain
,
delDomain
,
get
User
,
delUser
}
from
'../../utils/auth'
;
import
{
delToken
,
getUser
,
delUser
}
from
'../../utils/auth'
;
const
createMenu
=
async
(
configure
)
=>
{
const
createMenu
=
async
(
configure
)
=>
{
const
menu
=
{
const
menu
=
{
...
@@ -75,8 +74,6 @@ export default {
...
@@ -75,8 +74,6 @@ export default {
state
:
{
state
:
{
user
:
''
,
user
:
''
,
domain
:
''
,
domainList
:
[],
menus
:
[],
menus
:
[],
},
},
...
@@ -86,29 +83,6 @@ export default {
...
@@ -86,29 +83,6 @@ export default {
},
},
effects
:
{
effects
:
{
*
fetchDomain
(
ignored
,
{
put
,
call
})
{
const
domain
=
getDomain
();
let
domainName
;
if
(
!
domain
)
{
const
{
path
,
name
}
=
yield
call
(
currentDomain
);
yield
call
(
setDomain
,
name
,
path
);
domainName
=
name
;
}
else
{
domainName
=
domain
.
name
;
}
yield
put
({
type
:
'switchDomainSuccess'
,
payload
:
domainName
});
},
*
fetchDomains
(
ignored
,
{
put
,
call
})
{
const
list
=
yield
call
(
fetchDomains
,
'/'
,
true
);
yield
put
({
type
:
'queryDomainsSuccess'
,
payload
:
list
});
},
*
switchDomain
({
payload
:
domainId
},
{
put
,
call
})
{
yield
call
(
switchDomain
,
domainId
);
const
{
path
,
name
}
=
yield
call
(
currentDomain
);
yield
call
(
setDomain
,
name
,
path
);
yield
put
({
type
:
'switchDomainSuccess'
,
payload
:
name
});
yield
put
(
routerRedux
.
push
(
fullPath
(
'/main'
)));
},
*
fetchUser
(
ignored
,
{
put
,
call
})
{
*
fetchUser
(
ignored
,
{
put
,
call
})
{
const
user
=
yield
call
(
getUser
);
const
user
=
yield
call
(
getUser
);
if
(
!
user
)
{
if
(
!
user
)
{
...
@@ -125,7 +99,6 @@ export default {
...
@@ -125,7 +99,6 @@ export default {
yield
call
(
logout
);
yield
call
(
logout
);
yield
call
(
delToken
);
yield
call
(
delToken
);
yield
call
(
delUser
);
yield
call
(
delUser
);
yield
call
(
delDomain
);
yield
put
(
routerRedux
.
push
(
fullPath
(
'/login'
)));
yield
put
(
routerRedux
.
push
(
fullPath
(
'/login'
)));
},
},
},
},
...
@@ -137,18 +110,6 @@ export default {
...
@@ -137,18 +110,6 @@ export default {
user
,
user
,
};
};
},
},
queryDomainsSuccess
(
state
,
{
payload
:
list
})
{
return
{
...
state
,
domainList
:
list
,
};
},
switchDomainSuccess
(
state
,
{
payload
:
domain
})
{
return
{
...
state
,
domain
,
};
},
queryMenusSuccess
(
state
,
{
payload
:
menus
})
{
queryMenusSuccess
(
state
,
{
payload
:
menus
})
{
return
{
return
{
...
state
,
...
state
,
...
...
src/router.js
浏览文件 @
295c43c4
...
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
...
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import
{
Router
}
from
'dva/router'
;
import
{
Router
}
from
'dva/router'
;
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
config
from
'./utils/config'
;
import
config
from
'./utils/config'
;
import
{
isAuthed
,
hasDomain
}
from
'./utils/auth'
;
import
{
isAuthed
}
from
'./utils/auth'
;
import
{
fullPath
,
makePromise0
}
from
'./utils/helper'
;
import
{
fullPath
,
makePromise0
}
from
'./utils/helper'
;
import
{
processError
}
from
'./utils/error'
;
import
{
processError
}
from
'./utils/error'
;
import
App
from
'./routes/app'
;
import
App
from
'./routes/app'
;
...
@@ -25,15 +25,8 @@ const maybeLogin = async (replace) => {
...
@@ -25,15 +25,8 @@ const maybeLogin = async (replace) => {
}
}
};
};
const
maybeSwitch
=
async
(
replace
)
=>
{
if
(
!
(
await
hasDomain
()))
{
return
replace
(
fullPath
(
'/domain'
));
}
};
const
authenticated
=
async
(
replace
)
=>
{
const
authenticated
=
async
(
replace
)
=>
{
await
maybeLogin
(
replace
);
await
maybeLogin
(
replace
);
await
maybeSwitch
(
replace
);
};
};
const
createRoute
=
async
(
app
,
{
name
,
showName
,
modules
,
children
})
=>
{
const
createRoute
=
async
(
app
,
{
name
,
showName
,
modules
,
children
})
=>
{
...
@@ -117,18 +110,6 @@ function RouterConfig({ history, app }) {
...
@@ -117,18 +110,6 @@ function RouterConfig({ history, app }) {
},
'login'
);
},
'login'
);
},
},
},
},
{
path
:
'domain'
,
onEnter
:
(
ignored
,
replace
,
cb
)
=>
{
maybeLogin
(
replace
).
then
(()
=>
cb
()).
catch
(
err
=>
cb
(
err
));
},
getComponent
(
ignored
,
cb
)
{
require
.
ensure
([],
(
require
)
=>
{
registerModel
(
app
,
require
(
'./models/domain'
));
cb
(
null
,
require
(
'./routes/domain'
));
},
'domain'
);
},
},
{
{
path
:
'main'
,
path
:
'main'
,
onEnter
:
(
ignored
,
replace
,
cb
)
=>
{
onEnter
:
(
ignored
,
replace
,
cb
)
=>
{
...
...
src/routes/domain/index.js
deleted
100644 → 0
浏览文件 @
3b9bb58a
import
React
from
'react'
;
import
PropTypes
from
'prop-types'
;
import
{
Form
,
Select
,
Button
}
from
'antd'
;
import
{
connect
}
from
'dva'
;
import
styles
from
'./index.less'
;
const
FormItem
=
Form
.
Item
;
class
Domain
extends
React
.
Component
{
constructor
(
props
,
context
)
{
super
(
props
,
context
);
this
.
handleSubmit
=
this
::
this
.
handleSubmit
;
}
componentDidMount
()
{
this
.
props
.
dispatch
({
type
:
'domain/fetch'
});
}
handleSubmit
(
e
)
{
e
.
preventDefault
();
this
.
props
.
form
.
validateFields
((
err
,
values
)
=>
{
if
(
!
err
)
{
this
.
props
.
dispatch
({
type
:
'domain/switch'
,
payload
:
values
.
domain
,
});
}
});
}
render
()
{
const
{
form
,
domain
,
loading
}
=
this
.
props
;
const
currentDomain
=
domain
.
init
;
const
selectOptions
=
{};
const
decoratorOptions
=
{
rules
:
[
{
required
:
true
},
],
};
if
(
!
currentDomain
)
{
selectOptions
.
placeholder
=
'请选择项目...'
;
}
else
{
decoratorOptions
.
initialValue
=
currentDomain
;
}
return
(
<
div
className
=
{
styles
.
canvas
}
>
<
div
className
=
{
styles
.
container
}
>
<
Form
onSubmit
=
{
this
.
handleSubmit
}
>
<
FormItem
>
{
form
.
getFieldDecorator
(
'domain'
,
decoratorOptions
)(
<
Select
{...
selectOptions
}
>
{
domain
.
list
.
map
(({
path
,
name
})
=>
{
return
<
Select
.
Option
value
=
{
path
}
key
=
{
path
}
>
{
name
}
<
/Select.Option>
;
})}
<
/Select>
,
)
}
<
/FormItem
>
<
FormItem
>
<
Button
type
=
"primary"
htmlType
=
"submit"
className
=
{
styles
.
submit
}
loading
=
{
loading
}
>
确定
<
/Button
>
<
/FormItem
>
<
/Form
>
<
/div
>
<
/div
>
);
}
}
Domain
.
propTypes
=
{
domain
:
PropTypes
.
object
,
loading
:
PropTypes
.
bool
,
form
:
PropTypes
.
object
,
};
const
mapStateToProps
=
({
domain
,
loading
})
=>
{
return
{
domain
,
loading
:
loading
.
effects
[
'domain/switch'
],
};
};
export
default
connect
(
mapStateToProps
)(
Form
.
create
()(
Domain
));
src/routes/domain/index.less
deleted
100644 → 0
浏览文件 @
3b9bb58a
.canvas {
width: 100%;
height: 100%;
position: relative;
background-color: #555555;
}
.container {
width: 320px;
height: 160px;
position: absolute;
background-color: white;
top: 50%;
left: 50%;
padding: 36px;
margin: -80px 0 0 -160px;
box-shadow: 0 0 100px rgba(0,0,0,.08);
}
.submit {
width: 100%;
}
src/routes/main/header.js
浏览文件 @
295c43c4
...
@@ -18,24 +18,16 @@ class HeaderPane extends React.Component {
...
@@ -18,24 +18,16 @@ class HeaderPane extends React.Component {
dispatch
({
type
:
'main/fetchDomains'
});
dispatch
({
type
:
'main/fetchDomains'
});
}
}
render
()
{
render
()
{
const
{
dispatch
,
user
,
domain
,
domainList
,
routes
,
params
}
=
this
.
props
;
const
{
dispatch
,
user
,
routes
,
params
}
=
this
.
props
;
const
userTitle
=
(
const
userTitle
=
(
<
span
>
<
span
>
<
Icon
type
=
"user"
/>
<
Icon
type
=
"user"
/>
{
user
}
{
user
}
<
/span
>
<
/span
>
);
);
const
domainTitle
=
(
<
span
>
<
Icon
type
=
"home"
/>
{
domain
}
<
/span
>
);
const
onClick
=
({
keyPath
})
=>
{
const
onClick
=
({
keyPath
})
=>
{
if
(
keyPath
[
1
]
===
'user'
&&
keyPath
[
0
]
===
'logout'
)
{
if
(
keyPath
[
1
]
===
'user'
&&
keyPath
[
0
]
===
'logout'
)
{
dispatch
({
type
:
'main/logout'
});
dispatch
({
type
:
'main/logout'
});
}
else
if
(
keyPath
[
1
]
===
'domain'
)
{
dispatch
({
type
:
'main/switchDomain'
,
payload
:
keyPath
[
0
]
});
}
}
};
};
const
breadsProps
=
{
const
breadsProps
=
{
...
@@ -72,15 +64,6 @@ class HeaderPane extends React.Component {
...
@@ -72,15 +64,6 @@ class HeaderPane extends React.Component {
<
/span
>
<
/span
>
<
/MenuItem
>
<
/MenuItem
>
<
/SubMenu
>
<
/SubMenu
>
<
SubMenu
title
=
{
domainTitle
}
key
=
"domain"
>
{
domainList
.
map
(
dm
=>
(
<
MenuItem
key
=
{
dm
.
path
}
>
{
dm
.
name
}
<
/MenuItem
>
))
}
<
/SubMenu
>
<
/Menu
>
<
/Menu
>
<
/div
>
<
/div
>
);
);
...
@@ -90,18 +73,11 @@ class HeaderPane extends React.Component {
...
@@ -90,18 +73,11 @@ class HeaderPane extends React.Component {
HeaderPane
.
propTypes
=
{
HeaderPane
.
propTypes
=
{
dispatch
:
PropTypes
.
func
,
dispatch
:
PropTypes
.
func
,
user
:
PropTypes
.
string
,
user
:
PropTypes
.
string
,
domain
:
PropTypes
.
string
,
domainList
:
PropTypes
.
arrayOf
(
PropTypes
.
shape
({
id
:
PropTypes
.
number
,
name
:
PropTypes
.
string
,
})),
};
};
const
mapStateToProps
=
({
main
})
=>
{
const
mapStateToProps
=
({
main
})
=>
{
return
{
return
{
user
:
main
.
user
,
user
:
main
.
user
,
domain
:
main
.
domain
,
domainList
:
main
.
domainList
,
};
};
};
};
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论