Browse Source

修改生成预览视频

yangg 2 months ago
parent
commit
c88713dca7
2 changed files with 69 additions and 3 deletions
  1. 9 0
      src/views/digitalHuman/list/api.ts
  2. 60 3
      src/views/digitalHuman/list/crud.tsx

+ 9 - 0
src/views/digitalHuman/list/api.ts

@@ -53,3 +53,12 @@ export function GetVoiceList() {
         method: 'get',
         method: 'get',
     });
     });
 }
 }
+
+/* 生成预览数字人 */
+export function createDemo(obj:any) {
+    return request({
+        url: '/api/system/digital_human/generate_demo',
+      	method: 'post',
+		data: {...obj,tenant_id:1},
+    });
+}

+ 60 - 3
src/views/digitalHuman/list/crud.tsx

@@ -7,6 +7,7 @@ import tableSelector from '/@/components/tableSelector/index.vue';
 import { shallowRef, getCurrentInstance } from 'vue';
 import { shallowRef, getCurrentInstance } from 'vue';
 import { useRouter } from 'vue-router';
 import { useRouter } from 'vue-router';
 import { Plus } from '@element-plus/icons-vue';
 import { Plus } from '@element-plus/icons-vue';
+import { ElMessage, ElMessageBox } from 'element-plus';
 
 
 interface DigitalHumanForm {
 interface DigitalHumanForm {
 	id?: number;
 	id?: number;
@@ -37,10 +38,54 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 	const delRequest = async ({ row }: DelReq) => {
 	const delRequest = async ({ row }: DelReq) => {
 		return await api.DelObj(row.id);
 		return await api.DelObj(row.id);
 	};
 	};
-	const addRequest = async ({ form }: AddReq) => {
+	const addRequest = async ({ form }: AddReq) => { 
 		return await api.AddObj(form);
 		return await api.AddObj(form);
 	};
 	};
 
 
+	/**
+	 * 生成预览视频
+	 */
+	const generatePreviewVideo = async (row: DigitalHumanForm) => {
+		try {
+			ElMessageBox.confirm('确定要生成预览视频吗?', '提示', {
+				confirmButtonText: '确定',
+				cancelButtonText: '取消',
+				type: 'info',
+			}).then(async () => {
+				const loading = ElMessage({
+					message: '正在生成预览视频,请稍候...',
+					type: 'info',
+					duration: 0
+				});
+				
+				try {
+					const result = await api.createDemo({
+						digital_human_id: row.id,
+						text: '您好,我是您的数字人助手,很高兴为您服务!'
+					});
+					
+					loading.close();
+					
+					if (result.code === 2000) {
+						ElMessage.success('预览视频生成成功!');
+						// 刷新列表
+						crudExpose.refresh();
+					} else {
+						ElMessage.error(result.msg || '生成预览视频失败');
+					}
+				} catch (error) {
+					loading.close();
+					ElMessage.error('生成预览视频失败,请稍后重试');
+					console.error('生成预览视频错误:', error);
+				}
+			}).catch(() => {
+				// 用户取消操作
+			});
+		} catch (error) {
+			console.error('生成预览视频错误:', error);
+		}
+	};
+
 	/**
 	/**
 	 * 懒加载
 	 * 懒加载
 	 * @param row
 	 * @param row
@@ -88,7 +133,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 						show: true,
 						show: true,
 						size: 'small',
 						size: 'small',
 						click: () => {
 						click: () => {
-							crudExpose.emit('add-digital-human');
+							if (crudExpose && typeof crudExpose.openAdd === 'function') {
+								crudExpose.openAdd();
+							}
 						}
 						}
 					},
 					},
 				},
 				},
@@ -96,8 +143,17 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 			rowHandle: {
 			rowHandle: {
 				//固定右侧
 				//固定右侧
 				fixed: 'right',
 				fixed: 'right',
-				width: 300,
+				width: 350,
 				buttons: {
 				buttons: {
+					generatePreview: {
+						text: '生成预览视频',
+						size: 'small',
+						type: 'text',
+						show: true,
+						click: ({ row }) => {
+							generatePreviewVideo(row);
+						}
+					},
 					view: {
 					view: {
 						iconRight: 'view',
 						iconRight: 'view',
 						show: false,
 						show: false,
@@ -125,6 +181,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 						type: 'text',
 						type: 'text',
 						show: false//	auth('digitalHuma:Delete'),
 						show: false//	auth('digitalHuma:Delete'),
 					},
 					},
+					
 				},
 				},
 			},
 			},
 			pagination: {
 			pagination: {