From 2a91a33825a52d04743320d5ee7873b61da2cee3 Mon Sep 17 00:00:00 2001 From: old burden Date: Wed, 1 Apr 2026 15:56:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AF=B9=E6=8E=A5=E7=B4=A0=E6=9D=90?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- portal-ui/src/components/VideoComposeCard.vue | 94 +++++++++++++-- portal-ui/src/views/AssetGroupManage.vue | 9 +- portal-ui/src/views/AssetManage.vue | 114 +++++++++++++++--- .../java/com/ruoyi/api/ByteApiController.java | 2 - .../src/main/resources/application.yml | 12 +- .../ruoyi/ai/service/impl/ByteService.java | 22 ++-- 6 files changed, 206 insertions(+), 47 deletions(-) diff --git a/portal-ui/src/components/VideoComposeCard.vue b/portal-ui/src/components/VideoComposeCard.vue index 9d8245e..66105db 100644 --- a/portal-ui/src/components/VideoComposeCard.vue +++ b/portal-ui/src/components/VideoComposeCard.vue @@ -58,7 +58,15 @@
- + + + 刷新分组 + 查询资产 @@ -66,6 +74,12 @@ 上传资产
+
+ + + 新建素材组 + +
@@ -207,6 +221,9 @@ const mentionVisible = ref(false) const mentionActiveIndex = ref(-1) const assetGroupId = ref('') const assetLoading = ref(false) +const groupLoading = ref(false) +const assetGroups = ref([]) +const newGroupName = ref('') watch( () => props.modelValue, @@ -244,6 +261,9 @@ onMounted(() => { if (editorRef.value && localPrompt.value) { editorRef.value.innerText = localPrompt.value } + if (isReference.value) { + loadAssetGroups() + } }) const mediaList = computed(() => internalMediaList.value) @@ -368,6 +388,62 @@ const mergeAssetsToMediaList = (assets) => { setMediaList(next.slice(0, props.maxMediaCount)) } +const loadAssetGroups = async () => { + if (!proxy?.$axios) return + groupLoading.value = true + try { + const res = await proxy.$axios({ + url: 'api/byteAssetGroup/listAssetGroups', + method: 'POST', + data: { + Filter: { GroupType: 'AIGC' }, + PageNumber: 1, + PageSize: 100, + SortBy: 'CreateTime', + SortOrder: 'Desc' + } + }) + const rows = Array.isArray(res?.data?.Items) ? res.data.Items : [] + assetGroups.value = rows + if (!assetGroupId.value && rows.length) { + assetGroupId.value = rows[0]?.Id || rows[0]?.id || '' + } + } catch (err) { + Message.error(err?.message || '加载素材组失败') + } finally { + groupLoading.value = false + } +} + +const createAssetGroup = async () => { + const name = String(newGroupName.value || '').trim() + if (!name) { + Message.warning('请输入素材组名称') + return + } + if (!proxy?.$axios) return + groupLoading.value = true + try { + const res = await proxy.$axios({ + url: 'api/byteAssetGroup/createAssetGroup', + method: 'POST', + data: { + Name: name, + ProjectName: 'default' + } + }) + const gid = res?.data?.Id || res?.data?.id || '' + newGroupName.value = '' + await loadAssetGroups() + if (gid) assetGroupId.value = gid + Message.success('素材组创建成功') + } catch (err) { + Message.error(err?.message || '创建素材组失败') + } finally { + groupLoading.value = false + } +} + const loadAssetsByGroup = async () => { const gid = String(assetGroupId.value || '').trim() if (!gid) { @@ -381,7 +457,7 @@ const loadAssetsByGroup = async () => { assetLoading.value = true try { const res = await proxy.$axios({ - url: 'api/portal/asset/listAssets', + url: 'api/byteAsset/listAssets', method: 'POST', data: { Filter: { @@ -509,15 +585,15 @@ const loadAssetsByGroup = async () => { const mt = entry.mediaType || 'image' const assetType = mt === 'video' ? 'Video' : mt === 'audio' ? 'Audio' : 'Image' + const fd = new FormData() + fd.append('file', entry._fileRef) + fd.append('groupId', gid) + fd.append('assetType', assetType) + fd.append('name', entry?.name || '') const createRes = await proxy.$axios({ - url: 'api/portal/asset/createAsset', + url: 'api/byteAsset/createAsset', method: 'POST', - data: { - GroupId: gid, - URL: url, - Name: entry?.name || '', - AssetType: assetType - } + data: fd }) assetId = createRes?.data?.Id || createRes?.data?.id || '' if (!assetId) throw new Error(createRes?.msg || '创建素材失败:未返回资产ID') diff --git a/portal-ui/src/views/AssetGroupManage.vue b/portal-ui/src/views/AssetGroupManage.vue index ee36d31..326878f 100644 --- a/portal-ui/src/views/AssetGroupManage.vue +++ b/portal-ui/src/views/AssetGroupManage.vue @@ -176,12 +176,13 @@ export default { this.createLoading = true try { const res = await this.$axios({ - url: 'api/portal/asset/post', + url: 'api/byteAssetGroup/createAssetGroup', method: 'POST', data: { Name: name, Description: String(this.createForm.description || '').trim(), - GroupType: 'AIGC' + GroupType: 'AIGC', + ProjectName: 'default' } }) if (res.code === 200) { @@ -217,7 +218,7 @@ export default { if (ids.length) payload.Filter.GroupIds = ids const res = await this.$axios({ - url: 'api/portal/asset/list', + url: 'api/byteAssetGroup/listAssetGroups', method: 'POST', data: payload }) @@ -255,7 +256,7 @@ export default { this.detailLoadingId = id try { const res = await this.$axios({ - url: 'api/portal/asset/get', + url: 'api/byteAssetGroup/getAssetGroup', method: 'POST', data: { Id: id } }) diff --git a/portal-ui/src/views/AssetManage.vue b/portal-ui/src/views/AssetManage.vue index 988eecc..bc19266 100644 --- a/portal-ui/src/views/AssetManage.vue +++ b/portal-ui/src/views/AssetManage.vue @@ -3,6 +3,16 @@
素材组树
刷新分组 +
+
+ + +
+
+ 新建分组 + 更新分组 +
+
- - + + +
{{ createForm.fileName || '未选择文件' }}
@@ -143,11 +154,14 @@