Skip to content

Commit

Permalink
feat: 新建文章或草稿自动跳转到编辑页面
Browse files Browse the repository at this point in the history
  • Loading branch information
Mereithhh committed Feb 16, 2023
1 parent 97444fa commit baf4e3c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/admin/src/components/NewArticleModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export default function (props) {
washedValues[k.replace('C', '')] = v;
}

await createArticle(washedValues);
const { data } = await createArticle(washedValues);
if (onFinish) {
onFinish();
onFinish(data);
}

return true;
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/src/components/NewDraftModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export default function (props) {
washedValues[k.replace('C', '')] = v;
}

await createDraft(washedValues);
const { data } = await createDraft(washedValues);
if (onFinish) {
onFinish();
onFinish(data);
}
return true;
}}
Expand Down
3 changes: 2 additions & 1 deletion packages/admin/src/pages/Article/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ export default () => {
</Button>,
<NewArticleModal
key="newArticle123"
onFinish={() => {
onFinish={(data) => {
actionRef?.current?.reload();
history.push(`/editor?type=article&id=${data.id}`);
}}
/>,
<ImportArticleModal
Expand Down
5 changes: 3 additions & 2 deletions packages/admin/src/pages/Draft/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { useNum } from '@/services/van-blog/useNum';
import { PageContainer, ProTable } from '@ant-design/pro-components';
import RcResizeObserver from 'rc-resize-observer';
import { useMemo, useRef, useState } from 'react';
import { history } from 'umi';
import { columns, draftKeysObj, draftKeysObjSmall } from './columes';

export default () => {
const actionRef = useRef();
const [colKeys, setColKeys] = useState(draftKeysObj);
Expand Down Expand Up @@ -138,8 +138,9 @@ export default () => {
toolBarRender={() => [
<NewDraftModal
key="newDraft123"
onFinish={() => {
onFinish={(data) => {
actionRef?.current?.reload();
history.push(`/editor?type=draft&id=${data.id}`);
}}
/>,
<ImportDraftModal
Expand Down

0 comments on commit baf4e3c

Please sign in to comment.