From 6fc064fbc80e78edcf0072a94992a2ee2e20b950 Mon Sep 17 00:00:00 2001 From: callmeyan Date: Thu, 24 Apr 2025 17:09:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A0=87=E7=AD=BE=E5=8F=8A=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E6=8E=A5=E5=8F=A3=E8=81=94=E8=B0=83=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/core.scss | 6 +++- src/components/article/edit-modal.tsx | 40 +++++++++++++++++++++++---- src/service/api/article.ts | 2 +- src/types/core.d.ts | 24 +++++++++++++++- 4 files changed, 63 insertions(+), 9 deletions(-) diff --git a/src/assets/core.scss b/src/assets/core.scss index 71d1854..8fd32a8 100644 --- a/src/assets/core.scss +++ b/src/assets/core.scss @@ -405,7 +405,11 @@ .ant-message { z-index: var(--message-z-index); } - +.background-template-popover{ + .ant-popover-inner{ + background-color: #E9E9E9; + } +} .ant-modal-root { .ant-modal-mask { @apply bg-black/20; diff --git a/src/components/article/edit-modal.tsx b/src/components/article/edit-modal.tsx index 1567dca..2bf5c65 100644 --- a/src/components/article/edit-modal.tsx +++ b/src/components/article/edit-modal.tsx @@ -119,7 +119,10 @@ export default function ArticleEditModal(props: Props) { const [groups, setGroups] = useState([]); const [title, setTitle] = useState(''); const [tag, setTag] = useState(''); - const [backgroundImage, setBackgroundImage] = useState('1'); + const [articleTemplateInfo, setArticleTemplateInfo] = useState({ + select:'', + options:[] + }); const [hotNews, setHotNews] = useState({ list: ['', '', ''], mode: 'auto' @@ -160,6 +163,8 @@ export default function ArticleEditModal(props: Props) { metahuman_text: groups[0][0].content, content_group: groups.slice(1), hot_news: hotNews.mode == 'auto' ? [''] : hotNews.list, + video_tag:tag, + background: articleTemplateInfo.select, id: props.id && props.id > 0 ? props.id : undefined }).then(() => { props.onClose?.(true); @@ -194,6 +199,8 @@ export default function ArticleEditModal(props: Props) { metahuman_text: groups[0][0].content, content_group: groups.slice(1), hot_news: hotNews.mode == 'auto' ? [''] : hotNews.list, + video_tag:tag, + background: articleTemplateInfo.select, id: props.id }); push2video([props.id]).then(() => { @@ -226,6 +233,8 @@ export default function ArticleEditModal(props: Props) { } setGroups(rebuildGroups([[{ content: res.metahuman_text, type: 'text' }], ...res.content_group])); setTitle(res.title); + setTag(res.video_tag) + setArticleTemplateInfo(res.template_info) }); } else { // 新增 @@ -282,9 +291,24 @@ export default function ArticleEditModal(props: Props) {
{t('news.edit.bg')}
- - }>背景1 - }>背景2 + { + setArticleTemplateInfo(prev=>( + { + ...prev, + select: e.target.value + } + )) + }}> + {articleTemplateInfo.options.map((opt,idx)=>( + } + > + 背景{idx + 1} + ))}
@@ -296,8 +320,12 @@ export default function ArticleEditModal(props: Props) {
- {props.type == 'news' && props.id ? : null} + {props.type == 'news' && props.id ? : null} diff --git a/src/service/api/article.ts b/src/service/api/article.ts index 70f0662..6631a11 100644 --- a/src/service/api/article.ts +++ b/src/service/api/article.ts @@ -20,7 +20,7 @@ export function getById(id: Id) { return post({url: '/article/detail/' + id}) } -export function save(params:{title: string, metahuman_text: string, content_group: BlockContent[][],hot_news: string[], id?: number}) { +export function save(params:ArticleSaveParam) { return post<{ content: string }>(params.id && params.id > 0 ? '/article/modify' : '/article/create/new',params) } diff --git a/src/types/core.d.ts b/src/types/core.d.ts index 8a227f7..7d615db 100644 --- a/src/types/core.d.ts +++ b/src/types/core.d.ts @@ -28,13 +28,35 @@ declare interface ArticleContentGroup { blocks: BlockContent[]; } +interface TemplateOption { + background: string; + template_id: string; +} + +interface ArticleTemplateInfo { + select: string; + options: TemplateOption[]; +} + +interface ArticleSaveParam { + title: string; + metahuman_text: string; + video_tag?: string; + background?: string; + content_group: BlockContent[][]; + hot_news: string[]; + id?: number; +} + declare interface ArticleDetail { id: number; title: string; metahuman_text: string; + video_tag: string; + template_info: ArticleTemplateInfo; hot_news_mode?: string; hot_news: string[]; // 4月 6 日新增 - content_group: BlockContent[][] + content_group: BlockContent[][]; } declare interface NewsInfo {