diff --git a/package.json b/package.json index bd0557b..3ea53b6 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "dev-test": "vite --host --mode=test", "dev-lang-en": "set APP_LANGUAGE=en-US && vite --host --mode=lang-en", "build": "tsc && vite build", - "build-zh": "cross-env APP_LANGUAGE=zh-CN tsc && vite build --mode=production", - "build-en": "cross-env APP_LANGUAGE=en-US vite build --mode=production", + "zh": "cross-env APP_LANGUAGE=zh-CN tsc && vite build --mode=production", + "en": "cross-env APP_LANGUAGE=en-US vite build --mode=production", "build-test": "tsc && vite build --mode=test", "build-relative": "tsc && vite build --mode=relative", "build-prod": "tsc && vite build --mode=production", diff --git a/src/assets/core.scss b/src/assets/core.scss index e362078..42d06ca 100644 --- a/src/assets/core.scss +++ b/src/assets/core.scss @@ -160,6 +160,12 @@ &.disabled{ @apply border-primary-blue bg-[#f4f7fc]; } + &.status-generating{ + background: rgba(209, 209, 209, 1); + } + &.status-generate-failed{ + background: rgba(255, 0, 0, 0.12); + } &.header-row{ @apply text-sm; background: none; @@ -179,7 +185,7 @@ &:after { @apply absolute; - border-right: solid 1px #e8e8e8; + border-right: solid 1px rgba(0,0,0,0.1); content: ' '; top: 2px; bottom: 2px; @@ -211,8 +217,8 @@ } .operation { - @apply flex items-center ml-2 gap-4 text-lg text-gray-400 justify-center; - width: 120px; + @apply flex items-center ml-2 text-lg text-gray-400 justify-center; + width: 150px; padding: 0; } } diff --git a/src/components/icons/index.tsx b/src/components/icons/index.tsx index ecaf57c..02ea972 100644 --- a/src/components/icons/index.tsx +++ b/src/components/icons/index.tsx @@ -168,6 +168,25 @@ export const IconPlaying = ({style, className}: IconProps) => ( stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/> ) +export const IconGenerating = ({style, className}: IconProps) => ( + + + +) +export const IconGenerateFailed = ({style, className}: IconProps) => ( + + + +) +export const IconRegenerate = ({style, className}: IconProps) => ( + + + +) + export const IconPlay = ({style, className}: IconProps) => ( void; onPlay?: () => void; onEdit?: () => void; + onRegenerate?: () => void; + hideCheckBox?: boolean; onItemClick?: () => void; onRemove?: () => void; id: number; @@ -31,7 +41,8 @@ export const VideoListItem = ( { id, video, onRemove, checked,playing, onCheckedChange, onEdit, active, editable, - className, sortable, type, index,onItemClick + className, sortable, type, index,onItemClick, + additionOperation,onRegenerate,hideCheckBox }: Props) => { const { attributes, listeners, @@ -44,13 +55,14 @@ export const VideoListItem = ( setState({checked}) }, [checked]) - const generating = (type == 'create' && video.status == VideoStatus.Generating ) + const generating = (type == 'create' && video.status == VideoStatus.Generating) + const failed = (type == 'create' && (video.status != VideoStatus.Generating && video.status != VideoStatus.Generated) ) return
-
+
{generating && -
- {t('video.generating')} +
+
+ +
{t('video.generating')}
+
+
+ } + {failed && +
+
+ +
{t('video.generate_failed')}
+
} {/* && active*/} - {!generating && playing &&
+ {!generating && !failed && playing &&
-
{t('video.playing')}
+
{t('video.playing')}
}
@@ -92,7 +115,7 @@ export const VideoListItem = ( {/* : )}*/} -
+
{editable && !generating && <> {onEdit && } + {onRegenerate && + } {onRemove && } - { + {hideCheckBox ? : { if (onCheckedChange) { onCheckedChange(!state.checked) } else { setState({checked: !state.checked}) } - }} /> + }} />} } + {additionOperation}
diff --git a/src/i18n/translations/en-US.json b/src/i18n/translations/en-US.json index 17d364b..d19667e 100644 --- a/src/i18n/translations/en-US.json +++ b/src/i18n/translations/en-US.json @@ -136,6 +136,7 @@ "delete_empty": "Select the video you want to delete", "download": "Download", "generating": "Generating", + "generate_failed": "Generate Failed", "playing": "Playing", "push_confirm": "Are you sure you want to streaming these video?", "push_empty": "Select the video you want to streaming", diff --git a/src/i18n/translations/zh-CN.json b/src/i18n/translations/zh-CN.json index 676c3e3..a81d41e 100644 --- a/src/i18n/translations/zh-CN.json +++ b/src/i18n/translations/zh-CN.json @@ -136,6 +136,7 @@ "delete_empty": "请选择要删除的视频", "download": "下载视频", "generating": "生成中", + "generate_failed": "生成失败", "playing": "播放中", "push_confirm": "是否确定一键推流选中新闻视频?", "push_empty": "请选择要推流的新闻视频", diff --git a/src/pages/news/index.tsx b/src/pages/news/index.tsx index 59a4117..d718921 100644 --- a/src/pages/news/index.tsx +++ b/src/pages/news/index.tsx @@ -56,11 +56,11 @@ export default function NewsIndex() { } }) - const handleViewNewsDetail = (id: number) => { + const handleViewNewsDetail = (id: number,internal_article_id:number) => { const {update, close} = showLoading(`${t('news.get_detail')}...`) getById(id).then(res => { close() - setActiveNews({...res, id}) + setActiveNews({...res, id,internal_article_id}) }).catch(() => { update(t('news.get_detail_error'), 'info') }) @@ -95,7 +95,7 @@ export default function NewsIndex() { closeIcon={null} open={true} width={1000} footer={null} onCancel={() => setActiveNews(undefined)} > -
+
{activeNews?.title}
@@ -111,11 +111,11 @@ export default function NewsIndex() { setActiveNews(undefined)}/>
-
- + {activeNews.internal_article_id <= 0 && handleCheckChange(activeNews!.id)} - >{t('select.text')} + >{t('select.text')}}
@@ -157,7 +157,7 @@ export default function NewsIndex() {
{ - handleViewNewsDetail(item.id) + handleViewNewsDetail(item.id,item.internal_article_id) }}>{item.title}
{ - setCheckedIdArray(state.checkedAll ? [] : videoData.map(v => v.id)) + setCheckedIdArray(state.checkedAll ? [] : videoData.filter(s=>s.status == VideoStatus.Generated).map(v => v.id)) setState({ checkedAll: !state.checkedAll }) @@ -142,6 +142,12 @@ export default function VideoIndex() { loadList() }).catch(showErrorToast) } + const processGenerateVideo = async (video: VideoInfo) => { + regenerateById(video.article_id).then(() => { + //showToast(t('delete_success'), 'success') + loadList() + }).catch(showErrorToast) + } return (
@@ -236,7 +242,7 @@ export default function VideoIndex() { active={checkedIdArray.includes(v.id)} playing={state.playingId == v.id} checked={checkedIdArray.includes(v.id)} - className={`list-item-${index} mt-3 mb-2 list-item-state-${v.status}`} + className={`list-item-${index} mt-3 mb-2 list-item-state-${v.status} `} onCheckedChange={(checked) => { setCheckedIdArray(idArray => { const newArr = checked ? idArray.concat(v.id) : idArray.filter(id => id != v.id); @@ -246,17 +252,21 @@ export default function VideoIndex() { }} onItemClick={() => playVideo(v)} onRemove={() => processDeleteVideo([v.id])} - onEdit={v.status == VideoStatus.Generating ? undefined : () => { + onEdit={v.status == VideoStatus.Generated ? () => { setEditId(v.article_id) - }} + }:undefined} + onRegenerate={v.status != VideoStatus.Generating && v.status != VideoStatus.Generated?()=>{ + processGenerateVideo(v) + }:undefined} + hideCheckBox={v.status != VideoStatus.Generating && v.status != VideoStatus.Generated} editable={v.status != VideoStatus.Generating} - sortable={v.status != VideoStatus.Generating} + sortable={v.status == VideoStatus.Generated} />))}
} -
+
diff --git a/src/service/api/video.ts b/src/service/api/video.ts index 3101ad9..5cffff9 100644 --- a/src/service/api/video.ts +++ b/src/service/api/video.ts @@ -1,4 +1,5 @@ -import {get, post} from "@/service/request.ts"; +import {post} from "@/service/request.ts"; +import {getById as getArticle} from "./article" export function getList() { return post>('/video/list') @@ -27,6 +28,11 @@ export function regenerate(title: string, metahuman_text: string, content_group: } }) } +// 重新生成视频 +export async function regenerateById(article_id: Id) { + const article = await getArticle(article_id); + return await regenerate(article.title, article.metahuman_text, article.content_group, article_id) +} export function getById(id: Id) { return post({url: '/video/detail/' + id}) diff --git a/src/types/core.d.ts b/src/types/core.d.ts index dc8f558..0545cd2 100644 --- a/src/types/core.d.ts +++ b/src/types/core.d.ts @@ -37,6 +37,7 @@ declare interface ArticleDetail { declare interface NewsInfo { id: number; + internal_article_id: number; title: string; content: string; media_name: string;