feat: 标签及模板接口联调完成
This commit is contained in:
parent
611a00a550
commit
6fc064fbc8
@ -405,7 +405,11 @@
|
|||||||
.ant-message {
|
.ant-message {
|
||||||
z-index: var(--message-z-index);
|
z-index: var(--message-z-index);
|
||||||
}
|
}
|
||||||
|
.background-template-popover{
|
||||||
|
.ant-popover-inner{
|
||||||
|
background-color: #E9E9E9;
|
||||||
|
}
|
||||||
|
}
|
||||||
.ant-modal-root {
|
.ant-modal-root {
|
||||||
.ant-modal-mask {
|
.ant-modal-mask {
|
||||||
@apply bg-black/20;
|
@apply bg-black/20;
|
||||||
|
@ -119,7 +119,10 @@ export default function ArticleEditModal(props: Props) {
|
|||||||
const [groups, setGroups] = useState<BlockContent[][]>([]);
|
const [groups, setGroups] = useState<BlockContent[][]>([]);
|
||||||
const [title, setTitle] = useState('');
|
const [title, setTitle] = useState('');
|
||||||
const [tag, setTag] = useState('');
|
const [tag, setTag] = useState('');
|
||||||
const [backgroundImage, setBackgroundImage] = useState('1');
|
const [articleTemplateInfo, setArticleTemplateInfo] = useState<ArticleTemplateInfo>({
|
||||||
|
select:'',
|
||||||
|
options:[]
|
||||||
|
});
|
||||||
const [hotNews, setHotNews] = useState<HotNewsData>({
|
const [hotNews, setHotNews] = useState<HotNewsData>({
|
||||||
list: ['', '', ''],
|
list: ['', '', ''],
|
||||||
mode: 'auto'
|
mode: 'auto'
|
||||||
@ -160,6 +163,8 @@ export default function ArticleEditModal(props: Props) {
|
|||||||
metahuman_text: groups[0][0].content,
|
metahuman_text: groups[0][0].content,
|
||||||
content_group: groups.slice(1),
|
content_group: groups.slice(1),
|
||||||
hot_news: hotNews.mode == 'auto' ? [''] : hotNews.list,
|
hot_news: hotNews.mode == 'auto' ? [''] : hotNews.list,
|
||||||
|
video_tag:tag,
|
||||||
|
background: articleTemplateInfo.select,
|
||||||
id: props.id && props.id > 0 ? props.id : undefined
|
id: props.id && props.id > 0 ? props.id : undefined
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
props.onClose?.(true);
|
props.onClose?.(true);
|
||||||
@ -194,6 +199,8 @@ export default function ArticleEditModal(props: Props) {
|
|||||||
metahuman_text: groups[0][0].content,
|
metahuman_text: groups[0][0].content,
|
||||||
content_group: groups.slice(1),
|
content_group: groups.slice(1),
|
||||||
hot_news: hotNews.mode == 'auto' ? [''] : hotNews.list,
|
hot_news: hotNews.mode == 'auto' ? [''] : hotNews.list,
|
||||||
|
video_tag:tag,
|
||||||
|
background: articleTemplateInfo.select,
|
||||||
id: props.id
|
id: props.id
|
||||||
});
|
});
|
||||||
push2video([props.id]).then(() => {
|
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]));
|
setGroups(rebuildGroups([[{ content: res.metahuman_text, type: 'text' }], ...res.content_group]));
|
||||||
setTitle(res.title);
|
setTitle(res.title);
|
||||||
|
setTag(res.video_tag)
|
||||||
|
setArticleTemplateInfo(res.template_info)
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// 新增
|
// 新增
|
||||||
@ -282,9 +291,24 @@ export default function ArticleEditModal(props: Props) {
|
|||||||
<div className="row bg flex items-center my-3">
|
<div className="row bg flex items-center my-3">
|
||||||
<span className="mr-2">{t('news.edit.bg')}</span>
|
<span className="mr-2">{t('news.edit.bg')}</span>
|
||||||
<div className="bg-radio-container">
|
<div className="bg-radio-container">
|
||||||
<Radio.Group>
|
<Radio.Group
|
||||||
<Popover placement="bottomLeft" arrow={false} content={<img src={Bg1} />}><Radio value="1">背景1</Radio></Popover>
|
value={articleTemplateInfo.select}
|
||||||
<Popover placement="bottomLeft" arrow={false} content={<img src={Bg2} />}><Radio value="2">背景2</Radio></Popover>
|
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>
|
</Radio.Group>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -296,8 +320,12 @@ export default function ArticleEditModal(props: Props) {
|
|||||||
</div>
|
</div>
|
||||||
<div className="modal-control-footer flex justify-end">
|
<div className="modal-control-footer flex justify-end">
|
||||||
<div className="flex gap-10 ">
|
<div className="flex gap-10 ">
|
||||||
{props.type == 'news' && props.id ? <button className="text-gray-400 hover:text-gray-800"
|
{props.type == 'news' && props.id ? <button
|
||||||
onClick={handlePush2Video}>{t('news.edit_generate_video')}{state.pushed ? `${i18n.language == 'zh-CN' ? '中' : ''}...` : (state.generating ? `${i18n.language == 'zh-CN' ? '推送中' : 'Pushing'}...` : '')}</button> : null}
|
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 className="text-gray-400 hover:text-gray-800" onClick={() => props.onClose?.()}>{t('cancel')}</button>
|
||||||
<button onClick={handleSave}
|
<button onClick={handleSave}
|
||||||
className="text-gray-800 hover:text-blue-500">{props.type == 'news' ? t('news.save_text') : t('news.edit_generate_again')}</button>
|
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})
|
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)
|
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[];
|
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 {
|
declare interface ArticleDetail {
|
||||||
id: number;
|
id: number;
|
||||||
title: string;
|
title: string;
|
||||||
metahuman_text: string;
|
metahuman_text: string;
|
||||||
|
video_tag: string;
|
||||||
|
template_info: ArticleTemplateInfo;
|
||||||
hot_news_mode?: string;
|
hot_news_mode?: string;
|
||||||
hot_news: string[]; // 4月 6 日新增
|
hot_news: string[]; // 4月 6 日新增
|
||||||
content_group: BlockContent[][]
|
content_group: BlockContent[][];
|
||||||
}
|
}
|
||||||
|
|
||||||
declare interface NewsInfo {
|
declare interface NewsInfo {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user