feat: fix bugs

pull/107/head
huoyong.msb 5 years ago
parent 5466a53323
commit 2ffe59f992

@ -49,7 +49,7 @@
"koa-router": "7.4.0",
"koa-session": "5.12.3",
"koa-static": "5.0.0",
"lodash": "4.17.19",
"lodash": "^4.17.19",
"markdown-to-jsx": "^6.11.4",
"mockjs": "1.1.0",
"moment": "2.24.0",

@ -9,6 +9,7 @@ import { makeStyles } from '@material-ui/styles'
import { SlideUp } from 'components/common/Transition'
import { Interface, Repository, RootState, Module } from '../../actions/types'
import { updateInterface, addInterface } from '../../actions/interface'
import { StoreStateRouterLocationURI, push } from 'family'
export const METHODS = ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'PATCH', 'HEAD']
export const STATUS_LIST = [200, 301, 403, 404, 500, 502, 503, 504]
@ -71,6 +72,7 @@ function InterfaceForm(props: Props) {
const { open, onClose, itf, title, repository, mod } = props
const classes = useStyles()
const dispatch = useDispatch()
const router = useSelector((state: RootState) => state.router)
return (
<Dialog
@ -98,8 +100,13 @@ function InterfaceForm(props: Props) {
moduleId: mod!.id,
}
dispatch(
addOrUpdateInterface(itf, () => {
// dispatch(refresh())
addOrUpdateInterface(itf, (e) => {
if (e && e.id) {
const href = StoreStateRouterLocationURI(router)
.setSearch('itf', e.id)
.href()
dispatch(push(href))
}
onClose(true)
})
)

@ -33,7 +33,7 @@ export function* addInterface(action: any) {
try {
const payload = yield call(EditorService.addInterface, action.interface)
yield put(InterfaceAction.addInterfaceSucceeded(payload))
if (action.onResolved) { action.onResolved() }
if (action.onResolved) { action.onResolved(payload.itf) }
} catch (e) {
console.error(e.message)
yield put(InterfaceAction.addInterfaceFailed(e.message))

Loading…
Cancel
Save