feat: 标签及模板接口联调完成
This commit is contained in:
parent
611a00a550
commit
6fc064fbc8
@ -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;
|
||||
|
@ -119,7 +119,10 @@ export default function ArticleEditModal(props: Props) {
|
||||
const [groups, setGroups] = useState<BlockContent[][]>([]);
|
||||
const [title, setTitle] = useState('');
|
||||
const [tag, setTag] = useState('');
|
||||
const [backgroundImage, setBackgroundImage] = useState('1');
|
||||
const [articleTemplateInfo, setArticleTemplateInfo] = useState<ArticleTemplateInfo>({
|
||||
select:'',
|
||||
options:[]
|
||||
});
|
||||
const [hotNews, setHotNews] = useState<HotNewsData>({
|
||||
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) {
|
||||
<div className="row bg flex items-center my-3">
|
||||
<span className="mr-2">{t('news.edit.bg')}</span>
|
||||
<div className="bg-radio-container">
|
||||
<Radio.Group>
|
||||
<Popover placement="bottomLeft" arrow={false} content={<img src={Bg1} />}><Radio value="1">背景1</Radio></Popover>
|
||||
<Popover placement="bottomLeft" arrow={false} content={<img src={Bg2} />}><Radio value="2">背景2</Radio></Popover>
|
||||
<Radio.Group
|
||||
value={articleTemplateInfo.select}
|
||||
onChange={e=>{
|
||||
setArticleTemplateInfo(prev=>(
|
||||
{
|
||||
...prev,
|
||||
select: e.target.value
|
||||
}
|
||||
))
|
||||
}}>
|
||||
{articleTemplateInfo.options.map((opt,idx)=>(
|
||||
<Popover
|
||||
rootClassName="background-template-popover"
|
||||
key={idx} placement="bottomLeft" arrow={false}
|
||||
content={<img className="w-[150px] rounded" src={opt.background} />}
|
||||
>
|
||||
<Radio value={opt.template_id}>背景{idx + 1}</Radio></Popover>
|
||||
))}
|
||||
</Radio.Group>
|
||||
</div>
|
||||
</div>
|
||||
@ -296,8 +320,12 @@ export default function ArticleEditModal(props: Props) {
|
||||
</div>
|
||||
<div className="modal-control-footer flex justify-end">
|
||||
<div className="flex gap-10 ">
|
||||
{props.type == 'news' && props.id ? <button className="text-gray-400 hover:text-gray-800"
|
||||
onClick={handlePush2Video}>{t('news.edit_generate_video')}{state.pushed ? `${i18n.language == 'zh-CN' ? '中' : ''}...` : (state.generating ? `${i18n.language == 'zh-CN' ? '推送中' : 'Pushing'}...` : '')}</button> : null}
|
||||
{props.type == 'news' && props.id ? <button
|
||||
className="text-gray-400 hover:text-gray-800"
|
||||
onClick={handlePush2Video}
|
||||
>
|
||||
{t('news.edit_generate_video')}{state.pushed ? `${i18n.language == 'zh-CN' ? '中' : ''}...` : (state.generating ? `${i18n.language == 'zh-CN' ? '推送中' : 'Pushing'}...` : '')}
|
||||
</button> : null}
|
||||
<button className="text-gray-400 hover:text-gray-800" onClick={() => props.onClose?.()}>{t('cancel')}</button>
|
||||
<button onClick={handleSave}
|
||||
className="text-gray-800 hover:text-blue-500">{props.type == 'news' ? t('news.save_text') : t('news.edit_generate_again')}</button>
|
||||
|
@ -20,7 +20,7 @@ export function getById(id: Id) {
|
||||
return post<ArticleDetail>({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)
|
||||
}
|
||||
|
||||
|
24
src/types/core.d.ts
vendored
24
src/types/core.d.ts
vendored
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user