diff --git a/src/components/article/upsert/index.ts b/src/components/article/upsert/index.ts index 273649e03..7f67e8942 100644 --- a/src/components/article/upsert/index.ts +++ b/src/components/article/upsert/index.ts @@ -23,7 +23,7 @@ export default OakComponent({ id: article?.id, content: article?.content, name: article?.name, - articleMenuId: article?.articleMenuId + articleMenuId: article?.articleMenuId, }; }, data: { @@ -42,14 +42,14 @@ export default OakComponent({ next.editor.setHtml(next.content); } }, - 'oakId'(prev, next) { - if(prev.oakId !== next.oakId) { + oakId(prev, next) { + if (prev.oakId !== next.oakId) { const { editor } = this.state; - if (editor == null) return; - editor.destroy(); - this.setEditor(null); + if (editor == null) return; + editor.destroy(); + this.setEditor(null); } - } + }, }, lifetimes: { async ready() { @@ -62,7 +62,7 @@ export default OakComponent({ const { editor } = this.state; editor?.setHtml(''); this.update({ - content: '' + content: '', }); } } else { @@ -87,8 +87,11 @@ export default OakComponent({ return result; }, - uploadFile(extraFile: EntityDict['extraFile']['CreateSingle']['data']) { - return this.features.extraFile.upload(extraFile); + async uploadFile( + extraFile: EntityDict['extraFile']['CreateSingle']['data'] + ) { + const result = await this.features.extraFile.upload(extraFile); + return result; }, setEditor(editor: IDomEditor | null) { @@ -110,7 +113,7 @@ export default OakComponent({ this.state.html !== '


' ) { await this.execute(); - if(this.props.changeIsEdit) { + if (this.props.changeIsEdit) { this.props.changeIsEdit(); } } else if (this.state.name && this.state.name.length > 0) { @@ -118,7 +121,11 @@ export default OakComponent({ content: '请填写文章内容!', type: 'warning', }); - } else if (this.state.content && this.state.content.length > 0 && this.state.html !== '


') { + } else if ( + this.state.content && + this.state.content.length > 0 && + this.state.html !== '


' + ) { this.setMessage({ content: '请填写文章标题!', type: 'warning', diff --git a/src/components/article/upsert/web.tsx b/src/components/article/upsert/web.tsx index fc33aee54..86e9493a2 100644 --- a/src/components/article/upsert/web.tsx +++ b/src/components/article/upsert/web.tsx @@ -16,7 +16,6 @@ import { IToolbarConfig } from "@wangeditor/editor"; import { EntityDict } from "./../../../oak-app-domain"; import { WebComponentProps } from "oak-frontend-base"; import Style from "./web.module.less"; -import useFeatures from "../../../hooks/useFeatures"; import { EyeOutlined, } from "@ant-design/icons"; @@ -98,8 +97,8 @@ export default function Render( gotoPreview, } = method; const { id, content, editor, origin1, oakFullpath, html, oakId, articleMenuId, changeIsEdit } = data; - const features = useFeatures(); const [articleId, setArticleId] = useState(""); + useEffect(() => { if (id) { setArticleId(id); @@ -169,8 +168,7 @@ export default function Render( try { // 自己实现上传,并得到图片 url alt href - const { url, bucket } = - await features.extraFile.upload(extraFile); + const { url, bucket } = await uploadFile(extraFile); extraFile.bucket = bucket; extraFile.extra1 = null; await addExtraFile(extraFile); @@ -213,8 +211,7 @@ export default function Render( try { // 自己实现上传,并得到图片 url alt href - const { url, bucket } = - await features.extraFile.upload(extraFile); + const { url, bucket } = await uploadFile(extraFile); extraFile.bucket = bucket; extraFile.extra1 = null; await addExtraFile(extraFile); diff --git a/src/components/extraFile/avatar/web.tsx b/src/components/extraFile/avatar/web.tsx index e27de5021..b8b6e7908 100644 --- a/src/components/extraFile/avatar/web.tsx +++ b/src/components/extraFile/avatar/web.tsx @@ -7,7 +7,6 @@ import classNames from 'classnames'; import Style from './web.module.less'; import { WebComponentProps } from 'oak-frontend-base'; import { EntityDict } from '../../../oak-app-domain'; -import useFeatures from '../../../hooks/useFeatures'; export default function render( @@ -27,7 +26,6 @@ export default function render( ) { const { style, className, avatarUrl } = props.data; const { onPickByWeb } = props.methods; - const features = useFeatures(); return ( <> diff --git a/src/components/extraFile/gallery/web.tsx b/src/components/extraFile/gallery/web.tsx index e7e3c5775..e1c26f994 100644 --- a/src/components/extraFile/gallery/web.tsx +++ b/src/components/extraFile/gallery/web.tsx @@ -8,7 +8,6 @@ import classNames from "classnames"; import Style from "./web.module.less"; import { WebComponentProps } from "oak-frontend-base"; import { EntityDict } from "../../../oak-app-domain"; -import useFeatures from "../../../hooks/useFeatures"; import { DndProvider, useDrag, useDrop } from "react-dnd"; import { HTML5Backend } from "react-dnd-html5-backend"; import { TouchBackend } from "react-dnd-touch-backend";