jvs-ppt-ui 0.0.20 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jvs-ppt-ui",
3
3
  "private": false,
4
- "version": "0.0.20",
4
+ "version": "0.0.22",
5
5
  "type": "module",
6
6
  "main": "./dist/lib/jvs-ppt-ui.umd.js",
7
7
  "module": "./dist/lib/jvs-ppt-ui.es.js",
@@ -22,7 +22,7 @@
22
22
  ],
23
23
  "scripts": {
24
24
  "dev": "vite",
25
- "build": "node scripts/patch-pptxtojson.cjs && vue-tsc -b && vite build",
25
+ "build": "node scripts/patch-pptxtojson.cjs && vue-tsc -b && vite build && vite build --config vite.config.lib.ts",
26
26
  "build:web": "node scripts/patch-pptxtojson.cjs && vite build --config vite.config.web.ts",
27
27
  "build:lib": "node scripts/patch-pptxtojson.cjs && vite build --config vite.config.lib.ts",
28
28
  "preview": "vite preview",
@@ -41,7 +41,7 @@
41
41
  "jszip": "^3.10.1",
42
42
  "jvs-picker-color-v3": "^0.0.11",
43
43
  "jvs-pptxgenjs": "^0.0.8",
44
- "jvs-pptxtojson": "^0.0.26",
44
+ "jvs-pptxtojson": "^0.0.27",
45
45
  "svg-pathdata": "^7.2.0",
46
46
  "vue": "^3.5.34",
47
47
  "vuedraggable": "^4.1.0",
@@ -5960,12 +5960,35 @@ function changeQuickTextAlign(el: any, align: string) {
5960
5960
  }
5961
5961
  if (targetEl.text && targetEl.text.content) {
5962
5962
  targetEl.text.content = updateTextAlignInHtml(targetEl.text.content, align)
5963
+ } else if (typeof targetEl.text === 'string' && targetEl.text) {
5964
+ targetEl.text = updateTextAlignInHtml(targetEl.text, align)
5965
+ }
5966
+ const container = document.getElementById(`editable-${targetEl.id}`)
5967
+ if (container && (!targetEl.content || !targetEl.content.includes('<table')) && !targetEl.latex) {
5968
+ container.style.textAlign = align
5969
+ container.innerHTML = updateTextAlignInHtml(container.innerHTML, align)
5970
+ if (targetEl.type === 'shape') {
5971
+ if (targetEl.text && typeof targetEl.text === 'object') {
5972
+ targetEl.text.content = container.innerHTML
5973
+ } else {
5974
+ targetEl.text = container.innerHTML
5975
+ }
5976
+ } else if (targetEl.type === 'text') {
5977
+ targetEl.content = container.innerHTML
5978
+ }
5979
+ }
5980
+ if (targetEl.type === 'group' && Array.isArray(targetEl.elements)) {
5981
+ targetEl.elements.forEach((child: any) => {
5982
+ if (!child.style) child.style = {}
5983
+ child.style.textAlign = align
5984
+ syncHtmlAlign(child)
5985
+ })
5963
5986
  }
5964
5987
  }
5965
5988
 
5966
5989
  if (selectedElementIds.value.length > 1 && activeSlide.value) {
5967
5990
  // 嵌套感知解析:组合内子元素也要能命中(findElementInSlide 走 elementMaps,含组内子元素)
5968
- const els = selectedElementIds.value.map((id: string) => findElementInSlide(id)).filter((e: any) => Boolean(e))
5991
+ const els = selectedElementIds.value.map((id: string) => findElementInSlide(id)).filter((e: any) => Boolean(e))
5969
5992
  els.forEach((item: any) => {
5970
5993
  if (item.style) item.style.textAlign = align
5971
5994
  syncHtmlAlign(item)
@@ -3923,7 +3923,12 @@ const parsePPTXJSONData = (json: any, zipMeta?: any) => {
3923
3923
  const metrics = getParagraphMetrics(el.content, fontScale, defaultFontSize)
3924
3924
  const shapeEl: any = {
3925
3925
  type: 'shape',
3926
- id: generateAndRegisterId(el.id),
3926
+ id: generateAndRegisterId(el.id),
3927
+ name: el.name,
3928
+ phType: el.phType,
3929
+ isPlaceholder: el.isPlaceholder,
3930
+ placeholderType: el.placeholderType,
3931
+ placeholder: el.placeholder,
3927
3932
  order: el.order !== undefined ? el.order : undefined,
3928
3933
  width: el.width,
3929
3934
  height: el.height,
@@ -4058,7 +4063,12 @@ const parsePPTXJSONData = (json: any, zipMeta?: any) => {
4058
4063
  const metrics = getParagraphMetrics(el.content, ratio, defaultFontSize)
4059
4064
  const textEl: any = {
4060
4065
  type: 'text',
4061
- id: generateAndRegisterId(el.id),
4066
+ id: generateAndRegisterId(el.id),
4067
+ name: el.name,
4068
+ phType: el.phType,
4069
+ isPlaceholder: el.isPlaceholder,
4070
+ placeholderType: el.placeholderType,
4071
+ placeholder: el.placeholder,
4062
4072
  order: el.order !== undefined ? el.order : undefined,
4063
4073
  width: el.width,
4064
4074
  height: el.height,
@@ -4425,7 +4435,12 @@ const parsePPTXJSONData = (json: any, zipMeta?: any) => {
4425
4435
 
4426
4436
  const element: any = {
4427
4437
  type: 'shape',
4428
- id: generateAndRegisterId(el.id),
4438
+ id: generateAndRegisterId(el.id),
4439
+ name: el.name,
4440
+ phType: el.phType,
4441
+ isPlaceholder: el.isPlaceholder,
4442
+ placeholderType: el.placeholderType,
4443
+ placeholder: el.placeholder,
4429
4444
  order: el.order !== undefined ? el.order : undefined,
4430
4445
  width: el.width,
4431
4446
  height: el.height,
@@ -4471,7 +4486,8 @@ const parsePPTXJSONData = (json: any, zipMeta?: any) => {
4471
4486
  }
4472
4487
  element.style.borderColor = el.borderColor || (el.outline?.color || 'transparent')
4473
4488
  element.style.borderWidth = el.borderWidth !== undefined ? `${+(el.borderWidth * ratio).toFixed(2)}px` : (el.outline?.width !== undefined ? `${el.outline.width}px` : '0px')
4474
- element.style.borderStyle = el.borderType || (el.outline?.style || 'solid')
4489
+ element.style.borderStyle = el.borderType || (el.outline?.style || 'solid')
4490
+ if (el.placeholderType === 'pic' && el.borderWidth > 0) element.style.enableBorder = true
4475
4491
  if (lineCap) {
4476
4492
  element.style.borderLineCap = lineCap
4477
4493
  element.style.strokeLinecap = lineCap === 'round' ? 'round' : (lineCap === 'square' ? 'square' : 'butt')
@@ -736,7 +736,7 @@ watch(
736
736
  (val) => {
737
737
  if (isInternalUpdating) return
738
738
  if (!val) return
739
- if (val === lastEmittedModelValue) return
739
+ if (val === lastEmittedModelValue || toRaw(val) === toRaw(lastEmittedModelValue)) return
740
740
  loadDeck(val as any)
741
741
  },
742
742
  { immediate: true, deep: true }
@@ -574,14 +574,25 @@ function setStyleVal(prop: string, val: any) {
574
574
  }
575
575
  }
576
576
 
577
- if (prop === 'fontFamily' || prop === 'fontSize') {
577
+ if (prop === 'fontFamily' || prop === 'fontSize' || prop === 'textAlign') {
578
578
  const container = document.getElementById(`editable-${el.id}`)
579
- if (container) {
580
- if (prop === 'fontFamily') container.style.fontFamily = val
581
- else container.style.fontSize = val
582
- container.innerHTML = applyTextStyleToHtml(container.innerHTML, { [prop]: val })
579
+ if (container && (!el.content || !el.content.includes('<table')) && !el.latex) {
580
+ if (prop === 'fontFamily') {
581
+ container.style.fontFamily = val
582
+ container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontFamily: val })
583
+ } else if (prop === 'fontSize') {
584
+ container.style.fontSize = val
585
+ container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontSize: val })
586
+ } else if (prop === 'textAlign') {
587
+ container.style.textAlign = val
588
+ container.innerHTML = updateTextAlignInHtml(container.innerHTML, val)
589
+ }
583
590
  if (el.type === 'shape') {
584
- el.text = container.innerHTML
591
+ if (el.text && typeof el.text === 'object') {
592
+ el.text.content = container.innerHTML
593
+ } else {
594
+ el.text = container.innerHTML
595
+ }
585
596
  } else {
586
597
  el.content = container.innerHTML
587
598
  }
@@ -667,13 +678,25 @@ function setStyleVal(prop: string, val: any) {
667
678
  }
668
679
  }
669
680
 
670
- if (prop === 'fontFamily') {
681
+ if (prop === 'fontFamily' || prop === 'fontSize' || prop === 'textAlign') {
671
682
  const container = document.getElementById(`editable-${el.id}`)
672
- if (container) {
673
- container.style.fontFamily = val
674
- container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontFamily: val })
683
+ if (container && (!el.content || !el.content.includes('<table')) && !el.latex) {
684
+ if (prop === 'fontFamily') {
685
+ container.style.fontFamily = val
686
+ container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontFamily: val })
687
+ } else if (prop === 'fontSize') {
688
+ container.style.fontSize = val
689
+ container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontSize: val })
690
+ } else if (prop === 'textAlign') {
691
+ container.style.textAlign = val
692
+ container.innerHTML = updateTextAlignInHtml(container.innerHTML, val)
693
+ }
675
694
  if (el.type === 'shape') {
676
- el.text = container.innerHTML
695
+ if (el.text && typeof el.text === 'object') {
696
+ el.text.content = container.innerHTML
697
+ } else {
698
+ el.text = container.innerHTML
699
+ }
677
700
  } else {
678
701
  el.content = container.innerHTML
679
702
  }
@@ -735,6 +758,35 @@ function setStyleVal(prop: string, val: any) {
735
758
  } else if (prop === 'textAlign') {
736
759
  child.text.content = updateTextAlignInHtml(child.text.content, val)
737
760
  }
761
+ } else if (typeof child.text === 'string' && child.text) {
762
+ if (prop === 'fontFamily') {
763
+ child.text = applyTextStyleToHtml(child.text, { fontFamily: val })
764
+ } else if (prop === 'fontSize') {
765
+ child.text = applyTextStyleToHtml(child.text, { fontSize: val })
766
+ } else if (prop === 'color' || prop === 'textColor') {
767
+ child.text = applyTextStyleToHtml(child.text, { color: val })
768
+ } else if (prop === 'textBackground') {
769
+ child.text = applyTextStyleToHtml(child.text, { textBackground: val })
770
+ } else if (prop === 'textShadow') {
771
+ child.text = applyTextStyleToHtml(child.text, { textShadow: val })
772
+ } else if (prop === 'textAlign') {
773
+ child.text = updateTextAlignInHtml(child.text, val)
774
+ }
775
+ }
776
+ if (prop === 'fontFamily' || prop === 'fontSize' || prop === 'textAlign') {
777
+ const childContainer = document.getElementById(`editable-${child.id}`)
778
+ if (childContainer && (!child.content || !child.content.includes('<table')) && !child.latex) {
779
+ if (prop === 'fontFamily') {
780
+ childContainer.style.fontFamily = val
781
+ childContainer.innerHTML = applyTextStyleToHtml(childContainer.innerHTML, { fontFamily: val })
782
+ } else if (prop === 'fontSize') {
783
+ childContainer.style.fontSize = val
784
+ childContainer.innerHTML = applyTextStyleToHtml(childContainer.innerHTML, { fontSize: val })
785
+ } else if (prop === 'textAlign') {
786
+ childContainer.style.textAlign = val
787
+ childContainer.innerHTML = updateTextAlignInHtml(childContainer.innerHTML, val)
788
+ }
789
+ }
738
790
  }
739
791
  if (child.type === 'group' && Array.isArray(child.elements)) {
740
792
  child.elements.forEach(applyToGroupChild)
@@ -15,6 +15,7 @@ import { isImagePlaceholder } from '../utils/canvas/elementStyles'
15
15
  import { useDamAuth } from './material/useDamAuth'
16
16
  import MyAssetsPanel from './material/MyAssetsPanel.vue'
17
17
  import CreateMaterialPanel from './material/CreateMaterialPanel.vue'
18
+ import VideoCoverThumb from './material/VideoCoverThumb.vue'
18
19
 
19
20
  const {
20
21
  addElement,
@@ -855,7 +856,7 @@ function handleSelectMaterial(meta: MaterialItem) {
855
856
  (resolveActivePlaceholderTargetId ? resolveActivePlaceholderTargetId() : null) ||
856
857
  (explicitTargetId && (!currentSelectedEl || currentSelectedEl.id === explicitTargetId)
857
858
  ? explicitTargetId
858
- : (currentSelectedEl && isImagePlaceholder(currentSelectedEl) ? currentSelectedEl.id : null))
859
+ : (currentSelectedEl && (isImagePlaceholder(currentSelectedEl) || (currentSelectedEl as any).isPlaceholderReplaced || (currentSelectedEl as any).replaced || (currentSelectedEl as any).fromImagePlaceholder) ? currentSelectedEl.id : null))
859
860
 
860
861
  if (targetPlaceholderId && replacePlaceholderElement) {
861
862
  const replaced = replacePlaceholderElement(targetPlaceholderId, targetUrl, {
@@ -1074,16 +1075,13 @@ watch([() => materialApiUrl?.value, () => materialPageApiUrl?.value, () => mater
1074
1075
  class="overview-thumb-card"
1075
1076
  @click="handleSelectMaterial(item)"
1076
1077
  >
1077
- <video
1078
- v-if="isVideoUrl(getMaterialThumb(item))"
1079
- :src="getMaterialThumb(item)"
1080
- muted
1081
- preload="metadata"
1082
- playsinline
1078
+ <VideoCoverThumb
1079
+ v-if="cat.subType === 'Videos' || isVideoMaterial(item) || isVideoUrl(getMaterialThumb(item))"
1080
+ :video-url="item.sourceUrl || item.url || getMaterialThumb(item)"
1081
+ :cover-url="item.coverUrl || item.image || item.thumbnail || (!isVideoUrl(item.previewUrl) ? item.previewUrl : '')"
1082
+ :alt="item.title || cat.label"
1083
1083
  class="overview-thumb-img"
1084
- @loadeddata="updateRowScrollState(cat.key)"
1085
- @mouseenter="($event.target as HTMLVideoElement)?.play?.()"
1086
- @mouseleave="($event.target as HTMLVideoElement)?.pause?.()"
1084
+ @loaded="updateRowScrollState(cat.key)"
1087
1085
  />
1088
1086
  <img
1089
1087
  v-else-if="getMaterialThumb(item)"
@@ -1217,15 +1215,12 @@ watch([() => materialApiUrl?.value, () => materialPageApiUrl?.value, () => mater
1217
1215
  class="detail-masonry-card"
1218
1216
  @click="handleSelectMaterial(item)"
1219
1217
  >
1220
- <video
1221
- v-if="isVideoUrl(getMaterialThumb(item))"
1222
- :src="getMaterialThumb(item)"
1223
- muted
1224
- preload="metadata"
1225
- playsinline
1218
+ <VideoCoverThumb
1219
+ v-if="filterParams.activeSubType === 'Videos' || isVideoMaterial(item) || isVideoUrl(getMaterialThumb(item))"
1220
+ :video-url="item.sourceUrl || item.url || getMaterialThumb(item)"
1221
+ :cover-url="item.coverUrl || item.image || item.thumbnail || (!isVideoUrl(item.previewUrl) ? item.previewUrl : '')"
1222
+ :alt="item.title || '素材'"
1226
1223
  class="detail-card-img"
1227
- @mouseenter="($event.target as HTMLVideoElement)?.play?.()"
1228
- @mouseleave="($event.target as HTMLVideoElement)?.pause?.()"
1229
1224
  />
1230
1225
  <img
1231
1226
  v-else-if="getMaterialThumb(item)"
@@ -331,7 +331,7 @@ function getRawText(el: any): string {
331
331
 
332
332
  function getImagePlaceholderFill(el: any): string {
333
333
  const fill = getElementFill(el)
334
- if (!fill || fill === '#f1f5f9' || fill === '#f8fafc') {
334
+ if (!fill || fill === 'none' || fill === 'transparent' || fill === '#f1f5f9' || fill === '#f8fafc') {
335
335
  return '#d9dde3'
336
336
  }
337
337
  return fill
@@ -668,7 +668,7 @@ function formatShapeHtml(el: any): string {
668
668
  :rx="getRectRadiusInVb(element).rx"
669
669
  :ry="getRectRadiusInVb(element).ry"
670
670
  vector-effect="non-scaling-stroke"
671
- :fill="hasElementFill(element) ? (getElementPattern(element) ? `url(#shape-pattern-${svgIdKey})` : (getElementGradientConfig(element) ? `url(#shape-gradient-${svgIdKey})` : (getElementFill(element) !== undefined ? getElementFill(element) : '#3b82f6'))) : 'none'"
671
+ :fill="hasElementFill(element) ? (getElementPattern(element) ? `url(#shape-pattern-${svgIdKey})` : (getElementGradientConfig(element) ? `url(#shape-gradient-${svgIdKey})` : (getElementFill(element) !== undefined ? getElementFill(element) : '#3b82f6'))) : ((isImagePlaceholder && isImagePlaceholder(element)) ? getImagePlaceholderFill(element) : 'none')"
672
672
  :stroke="(isImagePlaceholder && isImagePlaceholder(element) && element.style?.enableBorder !== true) ? 'none' : (element.style?.enableBorder === false ? 'none' : getEffectiveBorderColor(element, 'none'))"
673
673
  :stroke-width="(isImagePlaceholder && isImagePlaceholder(element) && element.style?.enableBorder !== true) ? 0 : (element.style?.enableBorder === false ? 0 : getElementBorderWidth(element))"
674
674
  :stroke-linecap="element.style?.strokeLinecap || element.borderLineCap || element.lineCap || (element.shapType === 'arc' ? 'round' : (isOpenLineShape(element) ? 'butt' : undefined))"
@@ -678,7 +678,7 @@ function formatShapeHtml(el: any): string {
678
678
  v-else
679
679
  vector-effect="non-scaling-stroke"
680
680
  :d="element.path || element.content"
681
- :fill="hasElementFill(element) ? (getElementPattern(element) ? `url(#shape-pattern-${svgIdKey})` : (getElementGradientConfig(element) ? `url(#shape-gradient-${svgIdKey})` : (getElementFill(element) !== undefined ? getElementFill(element) : '#3b82f6'))) : 'none'"
681
+ :fill="hasElementFill(element) ? (getElementPattern(element) ? `url(#shape-pattern-${svgIdKey})` : (getElementGradientConfig(element) ? `url(#shape-gradient-${svgIdKey})` : (getElementFill(element) !== undefined ? getElementFill(element) : '#3b82f6'))) : ((isImagePlaceholder && isImagePlaceholder(element)) ? getImagePlaceholderFill(element) : 'none')"
682
682
  :stroke="(isImagePlaceholder && isImagePlaceholder(element) && element.style?.enableBorder !== true) ? 'none' : (element.style?.enableBorder === false ? 'none' : getEffectiveBorderColor(element, 'none'))"
683
683
  :stroke-width="(isImagePlaceholder && isImagePlaceholder(element) && element.style?.enableBorder !== true) ? 0 : (element.style?.enableBorder === false ? 0 : getElementBorderWidth(element))"
684
684
  :stroke-linecap="element.style?.strokeLinecap || element.borderLineCap || element.lineCap || (element.shapType === 'arc' ? 'round' : (isOpenLineShape(element) ? 'butt' : undefined))"
@@ -3,6 +3,7 @@ import { ref, computed, onMounted, onUnmounted } from 'vue'
3
3
  import { View, Plus, VideoPlay } from '@element-plus/icons-vue'
4
4
  import { useSlides } from '../../composables/useSlides'
5
5
  import { useDamAuth } from './useDamAuth'
6
+ import VideoCoverThumb from './VideoCoverThumb.vue'
6
7
  import type { MaterialItem } from '../TemplateGallery.vue'
7
8
 
8
9
  export interface ImageModelMetaVO {
@@ -1165,7 +1166,7 @@ defineExpose({
1165
1166
  <div v-if="generatedResults.length > 0" class="generated-results-section">
1166
1167
  <div class="results-header">
1167
1168
  <span class="results-title">本次生成结果 ({{ generatedResults.length }})</span>
1168
- <span class="results-sub">已同步至「我的素材」</span>
1169
+ <span class="results-sub">已同步至「我的空间」</span>
1169
1170
  </div>
1170
1171
 
1171
1172
  <div class="results-grid">
@@ -1175,14 +1176,12 @@ defineExpose({
1175
1176
  class="result-card"
1176
1177
  @click="emit('select', resItem)"
1177
1178
  >
1178
- <video
1179
+ <VideoCoverThumb
1179
1180
  v-if="resItem.type === 'video'"
1180
- :src="resItem.url"
1181
- muted
1182
- playsinline
1181
+ :video-url="resItem.sourceUrl || resItem.url"
1182
+ :cover-url="resItem.coverUrl || resItem.previewUrl"
1183
+ :alt="resItem.title"
1183
1184
  class="result-media"
1184
- @mouseenter="($event.target as HTMLVideoElement)?.play?.()"
1185
- @mouseleave="($event.target as HTMLVideoElement)?.pause?.()"
1186
1185
  />
1187
1186
  <img
1188
1187
  v-else
@@ -8,6 +8,7 @@ import {
8
8
  } from '@element-plus/icons-vue'
9
9
  import { useSlides } from '../../composables/useSlides'
10
10
  import { useDamAuth } from './useDamAuth'
11
+ import VideoCoverThumb from './VideoCoverThumb.vue'
11
12
  import type { MaterialItem } from '../TemplateGallery.vue'
12
13
 
13
14
  export interface DamProjectItem {
@@ -204,11 +205,28 @@ function selectFolderNode(proj: DamProjectItem, folder: DamFolderNode) {
204
205
  reloadAssets()
205
206
  }
206
207
 
207
- function isVideoAsset(raw: any): boolean {
208
- const assetType = String(raw.assetType || raw.mediaType || raw.type || '').toUpperCase()
208
+ function isVideoUrlString(url?: string): boolean {
209
+ if (!url) return false
210
+ const u = String(url).split('?')[0].split('#')[0].toLowerCase()
211
+ return (
212
+ u.endsWith('.mp4') ||
213
+ u.endsWith('.webm') ||
214
+ u.endsWith('.mov') ||
215
+ u.endsWith('.m4v') ||
216
+ u.endsWith('.avi') ||
217
+ u.endsWith('.mkv')
218
+ )
219
+ }
220
+
221
+ function isVideoAsset(raw: any, meta?: any): boolean {
222
+ const assetType = String(raw.assetType || raw.mediaType || raw.type || meta?.assetType || '').toUpperCase()
209
223
  if (assetType === 'VIDEO') return true
210
- const u = String(raw.fileUrl || raw.url || raw.ossUrl || raw.imageUrl || '').split('?')[0].toLowerCase()
211
- return u.endsWith('.mp4') || u.endsWith('.webm') || u.endsWith('.mov') || u.endsWith('.m4v')
224
+ const subType = String(raw.assetSubType || meta?.assetSubType || meta?.category || '').toLowerCase()
225
+ if (['videos', 'video', 'footage', 'motion-graphics', 'video-templates'].includes(subType)) return true
226
+ const ext = String(raw.fileExtension || '').toLowerCase()
227
+ if (['mp4', 'webm', 'mov', 'm4v', 'avi', 'mkv'].includes(ext)) return true
228
+ const u = String(raw.fileUrl || raw.url || raw.ossUrl || raw.imageUrl || meta?.sourceUrl || '')
229
+ return isVideoUrlString(u)
212
230
  }
213
231
 
214
232
  /**
@@ -219,7 +237,16 @@ function normalizeDamAsset(raw: any): MaterialItem | null {
219
237
  // semantic/search 接口返回的条目可能包裹在 asset 属性中
220
238
  const entity = raw.asset && typeof raw.asset === 'object' ? { ...raw.asset, score: raw.score } : raw
221
239
 
222
- const url =
240
+ let meta: any = {}
241
+ if (entity.metaDataJson) {
242
+ try {
243
+ meta = typeof entity.metaDataJson === 'string' ? JSON.parse(entity.metaDataJson) : entity.metaDataJson
244
+ } catch {
245
+ meta = {}
246
+ }
247
+ }
248
+
249
+ const primaryFileUrl =
223
250
  entity.fileUrl ||
224
251
  entity.imageUrl ||
225
252
  entity.ossUrl ||
@@ -228,17 +255,32 @@ function normalizeDamAsset(raw: any): MaterialItem | null {
228
255
  entity.previewUrl ||
229
256
  entity.sourceUrl ||
230
257
  ''
231
- if (!url) return null
258
+ const metaSourceUrl = meta.sourceUrl || meta.videoUrl || meta.downloadUrl || ''
259
+ if (!primaryFileUrl && !metaSourceUrl) return null
260
+
261
+ const isVid = isVideoAsset(entity, meta)
262
+
263
+ // 针对视频资产,区分真实视频播放源地址 (sourceUrl) 与静态封面图 (coverUrl / previewUrl)
264
+ const videoPlayUrl = isVid
265
+ ? (meta._fileIsCoverFallback
266
+ ? (metaSourceUrl || primaryFileUrl)
267
+ : (isVideoUrlString(primaryFileUrl) ? primaryFileUrl : (metaSourceUrl || primaryFileUrl)))
268
+ : (primaryFileUrl || metaSourceUrl)
269
+
270
+ const staticCoverCandidate =
271
+ entity.coverUrl ||
272
+ entity.thumbnailUrl ||
273
+ (entity.previewUrl && !isVideoUrlString(entity.previewUrl) ? entity.previewUrl : '') ||
274
+ meta.coverUrl ||
275
+ meta.thumbnail ||
276
+ meta.poster ||
277
+ (meta.previewUrl && !isVideoUrlString(meta.previewUrl) ? meta.previewUrl : '') ||
278
+ (meta.image && !isVideoUrlString(meta.image) ? meta.image : '') ||
279
+ (isVid && primaryFileUrl && !isVideoUrlString(primaryFileUrl) ? primaryFileUrl : '') ||
280
+ ''
232
281
 
233
- const isVid = isVideoAsset(entity)
234
- let meta: any = {}
235
- if (entity.metaDataJson) {
236
- try {
237
- meta = typeof entity.metaDataJson === 'string' ? JSON.parse(entity.metaDataJson) : entity.metaDataJson
238
- } catch {
239
- meta = {}
240
- }
241
- }
282
+ const url = videoPlayUrl || primaryFileUrl
283
+ const previewUrl = isVid ? (staticCoverCandidate || videoPlayUrl) : (entity.previewUrl || staticCoverCandidate || url)
242
284
 
243
285
  const rawTitle =
244
286
  entity.name ||
@@ -270,7 +312,8 @@ function normalizeDamAsset(raw: any): MaterialItem | null {
270
312
  sourceType: sourceType || (activeSourceSubTab.value === 'ai' ? 'GENERATE' : 'UPLOAD'),
271
313
  badgeLabel,
272
314
  url,
273
- previewUrl: entity.previewUrl || url,
315
+ previewUrl,
316
+ coverUrl: staticCoverCandidate || undefined,
274
317
  sourceUrl: url,
275
318
  originalWidth: w > 0 ? w : undefined,
276
319
  originalHeight: h > 0 ? h : undefined,
@@ -814,15 +857,12 @@ defineExpose({
814
857
  class="mine-asset-card"
815
858
  @click="emit('select', item)"
816
859
  >
817
- <video
860
+ <VideoCoverThumb
818
861
  v-if="item.type === 'video'"
819
- :src="item.url"
820
- muted
821
- preload="metadata"
822
- playsinline
862
+ :video-url="item.sourceUrl || item.url"
863
+ :cover-url="item.coverUrl || item.previewUrl"
864
+ :alt="item.title"
823
865
  class="mine-card-media"
824
- @mouseenter="($event.target as HTMLVideoElement)?.play?.()"
825
- @mouseleave="($event.target as HTMLVideoElement)?.pause?.()"
826
866
  />
827
867
  <img
828
868
  v-else