From 500c8491405634cd2443031cf9dd451d6fd8dfaf Mon Sep 17 00:00:00 2001 From: callmeyan Date: Mon, 7 Apr 2025 23:24:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=EF=B8=8F=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E8=A7=86=E9=A2=91=E7=8A=B6=E6=80=81=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=8F=8A=E5=9B=BD=E9=99=85=E5=8C=96=E6=94=AF=E6=8C=81?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E7=83=AD=E7=82=B9=E6=96=B0=E9=97=BB?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=8A=A0=E8=BD=BD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/article/edit-modal.tsx | 29 +++++++++++++++++---------- src/pages/news/edit.tsx | 1 + 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/components/article/edit-modal.tsx b/src/components/article/edit-modal.tsx index 9f0c29f..6d81d04 100644 --- a/src/components/article/edit-modal.tsx +++ b/src/components/article/edit-modal.tsx @@ -15,6 +15,7 @@ type Props = { id?: number; type: 'news' | 'video'; onClose?: (saved?: boolean) => void; + onRefresh?: ()=>void } const DEFAULT_STATE = { @@ -106,7 +107,7 @@ function checkHotNewsValid(hotNews: HotNewsData,modal:ModalHookAPI,t:TFunction<" } export default function ArticleEditModal(props: Props) { - const {t} = useTranslation() + const {t,i18n} = useTranslation() const {modal} = App.useApp() const [groups, setGroups] = useState([]); const [title, setTitle] = useState('') @@ -116,7 +117,8 @@ export default function ArticleEditModal(props: Props) { }) const [state, setState] = useSetState({ ...DEFAULT_STATE, - generating:false + generating:false, + pushed: false, }) // 保存数据 @@ -159,7 +161,7 @@ export default function ArticleEditModal(props: Props) { }); } const handlePush2Video = async () =>{ - // + if(state.pushed) return; if (!title) { // setState({msgTitle: '请输入标题内容'}); return; @@ -187,6 +189,9 @@ export default function ArticleEditModal(props: Props) { }) push2video([props.id]).then(() => { showToast(t('news.push_stream_success'), 'success') + setState({pushed:true}) + props.onClose?.(true) + // props.onRefresh?.(); // navigate('/create?state=push-success',{ // state: 'push-success' // }) @@ -201,13 +206,15 @@ export default function ArticleEditModal(props: Props) { // 如果传入了id则获取数据 if (props.id > 0) { article.getById(props.id).then(res => { - const len = res.hot_news.length - const list = len >= 3 ? res.hot_news :res.hot_news.concat(Array(3 - len).fill('')) - const mode = res.hot_news && res.hot_news.filter(s=>s.length > 0).length == 3 ?'manual':'auto'; - setHotNews({ - list, - mode - }) + if(res.hot_news){ + const len = res.hot_news.length + const list = len >= 3 ? res.hot_news :res.hot_news.concat(Array(3 - len).fill('')) + const mode = res.hot_news && res.hot_news.filter(s=>s.length > 0).length == 3 ?'manual':'auto'; + setHotNews({ + list, + mode + }) + } setGroups(rebuildGroups([[{content: res.metahuman_text, type: "text"}], ...res.content_group])) setTitle(res.title) }) @@ -260,7 +267,7 @@ export default function ArticleEditModal(props: Props) {
- {props.type == 'news' && props.id ? : null} + {props.type == 'news' && props.id ? : null}
diff --git a/src/pages/news/edit.tsx b/src/pages/news/edit.tsx index e9c2070..0da75d9 100644 --- a/src/pages/news/edit.tsx +++ b/src/pages/news/edit.tsx @@ -179,6 +179,7 @@ export default function NewEdit() { { setEditId(-1) if (saved) refresh()