Skip to content

Commit

Permalink
feat(core): 增加错误通知
Browse files Browse the repository at this point in the history
  • Loading branch information
stbui committed Oct 30, 2019
1 parent 396386b commit da941df
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/core/src/controller/useShowController.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/**
* @license
* Copyright Stbui All Rights Reserved.
* https://github.com/stbui
* https://github.com/stbui/prophet
*/

import { useGetOne } from '../dataProvider';
import { useNotify } from '../sideEffect';

export interface ShowProps {
resource: string;
Expand All @@ -14,8 +15,13 @@ export interface ShowProps {

export const useShowController = (props: ShowProps) => {
const { resource, basePath, id } = props;
const notify = useNotify();

const { data: record, loading } = useGetOne(resource, id);
const { data: record, loading } = useGetOne(resource, id, {
onFailure: () => {
notify('获取失败', 'error');
},
});

return {
resource,
Expand Down

0 comments on commit da941df

Please sign in to comment.