jvs-ppt-ui 0.0.26 → 0.0.27

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.26",
4
+ "version": "0.0.27",
5
5
  "type": "module",
6
6
  "main": "./dist/lib/jvs-ppt-ui.umd.js",
7
7
  "module": "./dist/lib/jvs-ppt-ui.es.js",
@@ -2,6 +2,7 @@
2
2
  import { ref, computed, watch, onMounted, onBeforeUnmount, nextTick, useSlots, getCurrentInstance, defineAsyncComponent, toRaw, type Ref } from 'vue'
3
3
  import jvsPickerColorV3 from 'jvs-picker-color-v3'
4
4
  import '../assets/iconfont/iconfont.js'
5
+ import '../../public/jvs-ppt-ui/fonts/fonts.css'
5
6
  import { saveAs } from 'file-saver'
6
7
  import Header from './Header.vue'
7
8
  import Toolbar from './Toolbar.vue'
@@ -926,7 +927,62 @@ const computedToolbarMode = computed(() => {
926
927
  return 'auto'
927
928
  })
928
929
 
930
+ let fontStyleObserver: MutationObserver | null = null
931
+ const FONT_SHIELD_SCOPE_SELECTOR = '.jvs-ppt-editor-root, .sidebar-select-popper, .autofit-popover-panel, .text-popover-popper, .style-builder-dialog'
932
+
933
+ function syncElementFontVar(el: Element) {
934
+ if (!(el instanceof HTMLElement || el instanceof SVGElement)) return
935
+ const style = el.style
936
+ if (!style) return
937
+ const rawFont = style.fontFamily?.trim() || ''
938
+ const curVar = style.getPropertyValue('--ppt-font-family').trim()
939
+ if (rawFont && rawFont !== 'inherit' && rawFont !== '默认字体') {
940
+ if (curVar !== rawFont) {
941
+ style.setProperty('--ppt-font-family', rawFont)
942
+ }
943
+ } else if (curVar) {
944
+ style.removeProperty('--ppt-font-family')
945
+ }
946
+ }
947
+
948
+ function syncSubtreeFontVars(root: Element | Document) {
949
+ if (root instanceof Element) {
950
+ syncElementFontVar(root)
951
+ }
952
+ const nodes = root.querySelectorAll('[style*="font-family"], [style*="--ppt-font-family"]')
953
+ for (let i = 0; i < nodes.length; i++) {
954
+ syncElementFontVar(nodes[i])
955
+ }
956
+ }
957
+
929
958
  onMounted(async () => {
959
+ if (typeof document !== 'undefined' && typeof MutationObserver !== 'undefined') {
960
+ syncSubtreeFontVars(document)
961
+ fontStyleObserver = new MutationObserver((mutations) => {
962
+ for (let i = 0; i < mutations.length; i++) {
963
+ const m = mutations[i]
964
+ if (m.type === 'attributes' && m.target instanceof Element) {
965
+ if (m.target.closest(FONT_SHIELD_SCOPE_SELECTOR)) {
966
+ syncElementFontVar(m.target)
967
+ }
968
+ } else if (m.type === 'childList' && m.addedNodes.length > 0) {
969
+ for (let j = 0; j < m.addedNodes.length; j++) {
970
+ const node = m.addedNodes[j]
971
+ if (node instanceof Element && (node.matches(FONT_SHIELD_SCOPE_SELECTOR) || node.closest(FONT_SHIELD_SCOPE_SELECTOR))) {
972
+ syncSubtreeFontVars(node)
973
+ }
974
+ }
975
+ }
976
+ }
977
+ })
978
+ fontStyleObserver.observe(document.body, {
979
+ attributes: true,
980
+ attributeFilter: ['style'],
981
+ childList: true,
982
+ subtree: true
983
+ })
984
+ }
985
+
930
986
  // 触发 ready 事件
931
987
  emit('ready', editorApi)
932
988
 
@@ -953,6 +1009,13 @@ onMounted(async () => {
953
1009
  }
954
1010
  }
955
1011
  })
1012
+
1013
+ onBeforeUnmount(() => {
1014
+ if (fontStyleObserver) {
1015
+ fontStyleObserver.disconnect()
1016
+ fontStyleObserver = null
1017
+ }
1018
+ })
956
1019
  </script>
957
1020
 
958
1021
  <template>
@@ -426,26 +426,17 @@ function applyTextStyleToHtml(html: string, styles: any) {
426
426
  const spans = div.querySelectorAll('span')
427
427
  const paragraphs = div.querySelectorAll('p')
428
428
 
429
- if (spans.length === 0 && paragraphs.length === 0) {
430
- if (div.children.length === 0) {
431
- const colorStyle = styles.color ? `color: ${styles.color};` : ''
432
- const bgStyle = (styles.textBackground && styles.textBackground !== 'transparent') ? `background-color: ${styles.textBackground};` : ''
433
- const fontStyle = styles.fontFamily ? `font-family: ${styles.fontFamily};` : ''
434
- const sizeStyle = styles.fontSize ? `font-size: ${styles.fontSize};` : ''
435
- return `<p><span style="${colorStyle}${bgStyle}${fontStyle}${sizeStyle}">${html}</span></p>`
436
- }
437
- div.querySelectorAll('*').forEach((child: any) => {
438
- if (styles.color) child.style.color = styles.color
439
- if (styles.fontFamily) child.style.fontFamily = styles.fontFamily
440
- if (styles.fontSize) child.style.fontSize = styles.fontSize
441
- })
442
- return div.innerHTML
443
- }
444
-
445
429
  const applyTextStyles = (elem: HTMLElement) => {
446
430
  if (styles.color) elem.style.color = styles.color
447
431
  if (styles.fontSize) elem.style.fontSize = styles.fontSize
448
- if (styles.fontFamily) elem.style.fontFamily = styles.fontFamily
432
+ if (styles.fontFamily) {
433
+ elem.style.fontFamily = styles.fontFamily
434
+ if (styles.fontFamily !== 'inherit' && styles.fontFamily !== '默认字体') {
435
+ elem.style.setProperty('--ppt-font-family', styles.fontFamily)
436
+ } else {
437
+ elem.style.removeProperty('--ppt-font-family')
438
+ }
439
+ }
449
440
  if (styles.fontWeight) elem.style.fontWeight = styles.fontWeight
450
441
  if (styles.fontStyle) elem.style.fontStyle = styles.fontStyle
451
442
  if (styles.textDecoration) elem.style.textDecoration = styles.textDecoration
@@ -460,20 +451,47 @@ function applyTextStyleToHtml(html: string, styles: any) {
460
451
  }
461
452
  }
462
453
 
454
+ if (spans.length === 0 && paragraphs.length === 0) {
455
+ if (div.children.length === 0) {
456
+ const colorStyle = styles.color ? `color: ${styles.color};` : ''
457
+ const bgStyle = (styles.textBackground && styles.textBackground !== 'transparent') ? `background-color: ${styles.textBackground};` : ''
458
+ const fontStyle = styles.fontFamily ? `font-family: ${styles.fontFamily}; --ppt-font-family: ${styles.fontFamily};` : ''
459
+ const sizeStyle = styles.fontSize ? `font-size: ${styles.fontSize};` : ''
460
+ const weightStyle = styles.fontWeight ? `font-weight: ${styles.fontWeight};` : ''
461
+ const italicStyle = styles.fontStyle ? `font-style: ${styles.fontStyle};` : ''
462
+ return `<p><span style="${colorStyle}${bgStyle}${fontStyle}${sizeStyle}${weightStyle}${italicStyle}">${html}</span></p>`
463
+ }
464
+ div.querySelectorAll('*').forEach((child: any) => {
465
+ applyTextStyles(child)
466
+ })
467
+ return div.innerHTML
468
+ }
469
+
463
470
  spans.forEach(applyTextStyles)
464
471
  if (spans.length === 0) {
465
472
  paragraphs.forEach(applyTextStyles)
466
473
  }
467
474
 
468
- // 综合处理字体与样式覆盖:如果指定了 fontFamily 或 fontSize,清理/更新所有块级和内联节点的原有硬编码值
469
- if (styles.fontFamily || styles.fontSize) {
475
+ // 综合处理字体与样式覆盖:如果指定了 fontFamily、fontSize、fontWeight 或 fontStyle,清理/更新所有块级和内联节点的原有硬编码值
476
+ if (styles.fontFamily || styles.fontSize || styles.fontWeight || styles.fontStyle) {
470
477
  div.querySelectorAll('p, div, li, h1, h2, h3, h4, h5, h6, span, b, strong, i, em, a').forEach((elem: any) => {
471
478
  if (styles.fontFamily && elem.style && elem.style.fontFamily) {
472
479
  elem.style.fontFamily = styles.fontFamily
480
+ if (styles.fontFamily !== 'inherit' && styles.fontFamily !== '默认字体') {
481
+ elem.style.setProperty('--ppt-font-family', styles.fontFamily)
482
+ } else {
483
+ elem.style.removeProperty('--ppt-font-family')
484
+ }
473
485
  }
474
486
  if (styles.fontSize && elem.style && elem.style.fontSize) {
475
487
  elem.style.fontSize = styles.fontSize
476
488
  }
489
+ if (styles.fontWeight && elem.style && elem.style.fontWeight) {
490
+ elem.style.fontWeight = styles.fontWeight
491
+ }
492
+ if (styles.fontStyle && elem.style && elem.style.fontStyle) {
493
+ elem.style.fontStyle = styles.fontStyle
494
+ }
477
495
  })
478
496
  }
479
497
 
@@ -534,6 +552,10 @@ function setStyleVal(prop: string, val: any) {
534
552
  el.content = applyTextStyleToHtml(el.content, { fontFamily: val })
535
553
  } else if (prop === 'fontSize') {
536
554
  el.content = applyTextStyleToHtml(el.content, { fontSize: val })
555
+ } else if (prop === 'fontWeight') {
556
+ el.content = applyTextStyleToHtml(el.content, { fontWeight: val })
557
+ } else if (prop === 'fontStyle') {
558
+ el.content = applyTextStyleToHtml(el.content, { fontStyle: val })
537
559
  } else if (prop === 'color' || prop === 'textColor') {
538
560
  el.content = applyTextStyleToHtml(el.content, { color: val })
539
561
  } else if (prop === 'textBackground') {
@@ -549,6 +571,10 @@ function setStyleVal(prop: string, val: any) {
549
571
  el.text.content = applyTextStyleToHtml(el.text.content, { fontFamily: val })
550
572
  } else if (prop === 'fontSize') {
551
573
  el.text.content = applyTextStyleToHtml(el.text.content, { fontSize: val })
574
+ } else if (prop === 'fontWeight') {
575
+ el.text.content = applyTextStyleToHtml(el.text.content, { fontWeight: val })
576
+ } else if (prop === 'fontStyle') {
577
+ el.text.content = applyTextStyleToHtml(el.text.content, { fontStyle: val })
552
578
  } else if (prop === 'color' || prop === 'textColor') {
553
579
  el.text.content = applyTextStyleToHtml(el.text.content, { color: val })
554
580
  } else if (prop === 'textBackground') {
@@ -563,6 +589,10 @@ function setStyleVal(prop: string, val: any) {
563
589
  el.text = applyTextStyleToHtml(el.text, { fontFamily: val })
564
590
  } else if (prop === 'fontSize') {
565
591
  el.text = applyTextStyleToHtml(el.text, { fontSize: val })
592
+ } else if (prop === 'fontWeight') {
593
+ el.text = applyTextStyleToHtml(el.text, { fontWeight: val })
594
+ } else if (prop === 'fontStyle') {
595
+ el.text = applyTextStyleToHtml(el.text, { fontStyle: val })
566
596
  } else if (prop === 'color' || prop === 'textColor') {
567
597
  el.text = applyTextStyleToHtml(el.text, { color: val })
568
598
  } else if (prop === 'textBackground') {
@@ -574,15 +604,22 @@ function setStyleVal(prop: string, val: any) {
574
604
  }
575
605
  }
576
606
 
577
- if (prop === 'fontFamily' || prop === 'fontSize' || prop === 'textAlign') {
607
+ if (prop === 'fontFamily' || prop === 'fontSize' || prop === 'fontWeight' || prop === 'fontStyle' || prop === 'textAlign') {
578
608
  const container = document.getElementById(`editable-${el.id}`)
579
609
  if (container && (!el.content || !el.content.includes('<table')) && !el.latex) {
580
610
  if (prop === 'fontFamily') {
581
611
  container.style.fontFamily = val
612
+ container.style.setProperty('--ppt-font-family', val)
582
613
  container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontFamily: val })
583
614
  } else if (prop === 'fontSize') {
584
615
  container.style.fontSize = val
585
616
  container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontSize: val })
617
+ } else if (prop === 'fontWeight') {
618
+ container.style.fontWeight = val
619
+ container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontWeight: val })
620
+ } else if (prop === 'fontStyle') {
621
+ container.style.fontStyle = val
622
+ container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontStyle: val })
586
623
  } else if (prop === 'textAlign') {
587
624
  container.style.textAlign = val
588
625
  container.innerHTML = updateTextAlignInHtml(container.innerHTML, val)
@@ -638,6 +675,10 @@ function setStyleVal(prop: string, val: any) {
638
675
  el.content = applyTextStyleToHtml(el.content, { fontFamily: val })
639
676
  } else if (prop === 'fontSize') {
640
677
  el.content = applyTextStyleToHtml(el.content, { fontSize: val })
678
+ } else if (prop === 'fontWeight') {
679
+ el.content = applyTextStyleToHtml(el.content, { fontWeight: val })
680
+ } else if (prop === 'fontStyle') {
681
+ el.content = applyTextStyleToHtml(el.content, { fontStyle: val })
641
682
  } else if (prop === 'color' || prop === 'textColor') {
642
683
  el.content = applyTextStyleToHtml(el.content, { color: val })
643
684
  } else if (prop === 'textBackground') {
@@ -653,6 +694,10 @@ function setStyleVal(prop: string, val: any) {
653
694
  el.text.content = applyTextStyleToHtml(el.text.content, { fontFamily: val })
654
695
  } else if (prop === 'fontSize') {
655
696
  el.text.content = applyTextStyleToHtml(el.text.content, { fontSize: val })
697
+ } else if (prop === 'fontWeight') {
698
+ el.text.content = applyTextStyleToHtml(el.text.content, { fontWeight: val })
699
+ } else if (prop === 'fontStyle') {
700
+ el.text.content = applyTextStyleToHtml(el.text.content, { fontStyle: val })
656
701
  } else if (prop === 'color' || prop === 'textColor') {
657
702
  el.text.content = applyTextStyleToHtml(el.text.content, { color: val })
658
703
  } else if (prop === 'textBackground') {
@@ -667,6 +712,10 @@ function setStyleVal(prop: string, val: any) {
667
712
  el.text = applyTextStyleToHtml(el.text, { fontFamily: val })
668
713
  } else if (prop === 'fontSize') {
669
714
  el.text = applyTextStyleToHtml(el.text, { fontSize: val })
715
+ } else if (prop === 'fontWeight') {
716
+ el.text = applyTextStyleToHtml(el.text, { fontWeight: val })
717
+ } else if (prop === 'fontStyle') {
718
+ el.text = applyTextStyleToHtml(el.text, { fontStyle: val })
670
719
  } else if (prop === 'color' || prop === 'textColor') {
671
720
  el.text = applyTextStyleToHtml(el.text, { color: val })
672
721
  } else if (prop === 'textBackground') {
@@ -678,15 +727,22 @@ function setStyleVal(prop: string, val: any) {
678
727
  }
679
728
  }
680
729
 
681
- if (prop === 'fontFamily' || prop === 'fontSize' || prop === 'textAlign') {
730
+ if (prop === 'fontFamily' || prop === 'fontSize' || prop === 'fontWeight' || prop === 'fontStyle' || prop === 'textAlign') {
682
731
  const container = document.getElementById(`editable-${el.id}`)
683
732
  if (container && (!el.content || !el.content.includes('<table')) && !el.latex) {
684
733
  if (prop === 'fontFamily') {
685
734
  container.style.fontFamily = val
735
+ container.style.setProperty('--ppt-font-family', val)
686
736
  container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontFamily: val })
687
737
  } else if (prop === 'fontSize') {
688
738
  container.style.fontSize = val
689
739
  container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontSize: val })
740
+ } else if (prop === 'fontWeight') {
741
+ container.style.fontWeight = val
742
+ container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontWeight: val })
743
+ } else if (prop === 'fontStyle') {
744
+ container.style.fontStyle = val
745
+ container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontStyle: val })
690
746
  } else if (prop === 'textAlign') {
691
747
  container.style.textAlign = val
692
748
  container.innerHTML = updateTextAlignInHtml(container.innerHTML, val)
@@ -472,7 +472,7 @@ const radarPolygons = computed(() => {
472
472
  <template>
473
473
  <svg
474
474
  :viewBox="`0 0 ${width} ${height}`"
475
- style="width: 100%; height: 100%; display: block; overflow: visible; user-select: none;"
475
+ :style="{ width: '100%', height: '100%', display: 'block', overflow: 'visible', userSelect: 'none', fontFamily: fontFamily, '--ppt-font-family': fontFamily }"
476
476
  >
477
477
  <!-- Background Grid & Ticks (Cartesian charts only) -->
478
478
  <g v-if="['bar', 'line', 'area', 'scatter'].includes(chartType) && showGridlines">
@@ -1187,6 +1187,12 @@ const loading = ref(false)
1187
1187
  const pagedMaterials = ref<MaterialItem[]>([])
1188
1188
  const currentPage = ref(1)
1189
1189
  const pageSize = 24
1190
+ const brokenImgMap = ref<Record<string, boolean>>({})
1191
+
1192
+ function markMaterialImgBroken(id?: string | number) {
1193
+ if (id === undefined || id === null) return
1194
+ brokenImgMap.value[String(id)] = true
1195
+ }
1190
1196
 
1191
1197
  const loadingMore = ref(false)
1192
1198
  const loadFailed = ref(false)
@@ -1931,14 +1937,22 @@ watch([() => materialApiUrl?.value, () => materialPageApiUrl?.value, () => mater
1931
1937
 
1932
1938
  <!-- 图片 / 矢量 / 插画 / 图标卡片 -->
1933
1939
  <img
1934
- v-else-if="getMaterialThumb(item)"
1940
+ v-else-if="getMaterialThumb(item) && !brokenImgMap[item.id]"
1935
1941
  :src="getMaterialThumb(item)"
1936
- :alt="item.title || cat.label"
1942
+ alt=""
1937
1943
  loading="lazy"
1938
1944
  class="overview-thumb-img"
1939
1945
  :class="{ 'is-icon-img': cat.subType === 'Icons' || isIconMaterial(item) }"
1940
1946
  @load="updateRowScrollState(cat.key)"
1947
+ @error="markMaterialImgBroken(item.id)"
1941
1948
  />
1949
+ <div v-else class="detail-card-placeholder">
1950
+ <svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#94a3b8" stroke-width="1.5">
1951
+ <rect x="3" y="3" width="18" height="18" rx="2" ry="2" />
1952
+ <circle cx="8.5" cy="8.5" r="1.5" />
1953
+ <polyline points="21 15 16 10 5 21" />
1954
+ </svg>
1955
+ </div>
1942
1956
  <span v-if="cat.subType === 'Videos' || isVideoMaterial(item)" class="video-badge-icon">
1943
1957
  <el-icon><VideoPlay /></el-icon>
1944
1958
  </span>
@@ -2090,12 +2104,13 @@ watch([() => materialApiUrl?.value, () => materialPageApiUrl?.value, () => mater
2090
2104
 
2091
2105
  <!-- 详情页图片 / 矢量 / 插画 / 图标卡片 -->
2092
2106
  <img
2093
- v-else-if="getMaterialThumb(item)"
2107
+ v-else-if="getMaterialThumb(item) && !brokenImgMap[item.id]"
2094
2108
  :src="getMaterialThumb(item)"
2095
- :alt="item.title || '素材'"
2109
+ alt=""
2096
2110
  loading="lazy"
2097
2111
  class="detail-card-img"
2098
2112
  :class="{ 'is-icon-img': filterParams.activeSubType === 'Icons' || isIconMaterial(item) }"
2113
+ @error="markMaterialImgBroken(item.id)"
2099
2114
  />
2100
2115
  <div v-else class="detail-card-placeholder">
2101
2116
  <svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#94a3b8" stroke-width="1.5">
@@ -2103,6 +2118,7 @@ watch([() => materialApiUrl?.value, () => materialPageApiUrl?.value, () => mater
2103
2118
  <circle cx="8.5" cy="8.5" r="1.5" />
2104
2119
  <polyline points="21 15 16 10 5 21" />
2105
2120
  </svg>
2121
+ <span style="font-size: 11px; color: #94a3b8; margin-top: 4px;">图片已失效</span>
2106
2122
  </div>
2107
2123
 
2108
2124
  <span v-if="filterParams.activeSubType === 'Videos' || isVideoMaterial(item)" class="video-badge-icon">
@@ -2270,11 +2286,20 @@ watch([() => materialApiUrl?.value, () => materialPageApiUrl?.value, () => mater
2270
2286
  class="preview-stage-img"
2271
2287
  />
2272
2288
  <img
2273
- v-else-if="currentPreviewItem?.url"
2289
+ v-else-if="currentPreviewItem?.url && !brokenImgMap['preview_' + currentPreviewItem.url]"
2274
2290
  :src="currentPreviewItem.url"
2275
- :alt="currentPreviewItem.title"
2291
+ alt=""
2276
2292
  class="preview-stage-img"
2293
+ @error="markMaterialImgBroken('preview_' + currentPreviewItem.url)"
2277
2294
  />
2295
+ <div v-else class="detail-card-placeholder" style="width: 320px; height: 220px; border-radius: 12px; background: rgba(30, 41, 59, 0.7);">
2296
+ <svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="#94a3b8" stroke-width="1.5">
2297
+ <rect x="3" y="3" width="18" height="18" rx="2" ry="2" />
2298
+ <circle cx="8.5" cy="8.5" r="1.5" />
2299
+ <polyline points="21 15 16 10 5 21" />
2300
+ </svg>
2301
+ <span style="font-size: 13px; color: #94a3b8; margin-top: 8px;">图片已失效</span>
2302
+ </div>
2278
2303
  </div>
2279
2304
 
2280
2305
  <div class="preview-footer-bar">
@@ -3611,10 +3636,15 @@ watch([() => materialApiUrl?.value, () => materialPageApiUrl?.value, () => mater
3611
3636
  }
3612
3637
 
3613
3638
  .detail-card-placeholder {
3614
- height: 90px;
3639
+ width: 100%;
3640
+ min-width: 96px;
3641
+ height: 96px;
3615
3642
  display: flex;
3643
+ flex-direction: column;
3616
3644
  align-items: center;
3617
3645
  justify-content: center;
3646
+ background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
3647
+ border-radius: 8px;
3618
3648
  }
3619
3649
 
3620
3650
  .detail-card-preview-btn {
@@ -858,6 +858,11 @@ function formatShapeHtml(el: any): string {
858
858
  : ((element.fontFamily && element.fontFamily !== '默认字体' && element.fontFamily !== 'inherit')
859
859
  ? element.fontFamily
860
860
  : (themeRecipe?.styleFonts?.bodyFont || 'SourceHanSansCN')),
861
+ '--ppt-font-family': (element.style?.fontFamily && element.style?.fontFamily !== '默认字体' && element.style?.fontFamily !== 'inherit')
862
+ ? element.style.fontFamily
863
+ : ((element.fontFamily && element.fontFamily !== '默认字体' && element.fontFamily !== 'inherit')
864
+ ? element.fontFamily
865
+ : (themeRecipe?.styleFonts?.bodyFont || 'SourceHanSansCN')),
861
866
  fontSize: element.style?.fontSize || ((isImagePlaceholder && isImagePlaceholder(element)) ? '15px' : '16px'),
862
867
  fontWeight: element.style?.fontWeight || ((isImagePlaceholder && isImagePlaceholder(element)) ? '600' : (getFontVariantStyle(element.style?.fontFamily || element.fontFamily, element.style?.fontFamilyStyle).fontWeight !== 'normal' ? getFontVariantStyle(element.style?.fontFamily || element.fontFamily, element.style?.fontFamilyStyle).fontWeight : 'normal')),
863
868
  fontStyle: element.style?.fontStyle || getFontVariantStyle(element.style?.fontFamily || element.fontFamily, element.style?.fontFamilyStyle).fontStyle,
@@ -226,6 +226,11 @@ function handleMaskMouseDown(e: MouseEvent) {
226
226
  : ((element.fontFamily && element.fontFamily !== '默认字体' && element.fontFamily !== 'inherit')
227
227
  ? element.fontFamily
228
228
  : ((element.id && element.id.startsWith('title') ? themeRecipe?.styleFonts?.titleFont : themeRecipe?.styleFonts?.bodyFont) || 'SourceHanSansCN')),
229
+ '--ppt-font-family': (element.style?.fontFamily && element.style?.fontFamily !== '默认字体' && element.style?.fontFamily !== 'inherit')
230
+ ? element.style.fontFamily
231
+ : ((element.fontFamily && element.fontFamily !== '默认字体' && element.fontFamily !== 'inherit')
232
+ ? element.fontFamily
233
+ : ((element.id && element.id.startsWith('title') ? themeRecipe?.styleFonts?.titleFont : themeRecipe?.styleFonts?.bodyFont) || 'SourceHanSansCN')),
229
234
  fontWeight: element.style?.fontWeight || (getFontVariantStyle(element.style?.fontFamily || element.fontFamily, element.style?.fontFamilyStyle).fontWeight !== 'normal' ? getFontVariantStyle(element.style?.fontFamily || element.fontFamily, element.style?.fontFamilyStyle).fontWeight : (element.content && element.content.includes('<') ? 'normal' : (element.id && element.id.startsWith('title') ? '700' : '500'))),
230
235
  fontStyle: element.style?.fontStyle || getFontVariantStyle(element.style?.fontFamily || element.fontFamily, element.style?.fontFamilyStyle).fontStyle,
231
236
  textDecoration: element.style?.textDecoration || 'none',
@@ -207,6 +207,12 @@ const showVideoRatioDropdown = ref(false)
207
207
  const isGenerating = ref(false)
208
208
  const currentSessionId = ref<string | undefined>(undefined)
209
209
  const generatedResults = ref<MaterialItem[]>([])
210
+ const brokenImgMap = ref<Record<string, boolean>>({})
211
+
212
+ function markImgBroken(key: string) {
213
+ if (!key) return
214
+ brokenImgMap.value = { ...brokenImgMap.value, [key]: true }
215
+ }
210
216
 
211
217
  const currentImageModelMeta = computed(() => {
212
218
  return imageModels.value.find(m => m.model === selectedImageModel.value) || imageModels.value[0] || DEFAULT_IMAGE_MODELS[0]
@@ -773,7 +779,14 @@ defineExpose({
773
779
  :title="`点击在提示词中引用 @img${idx + 1}`"
774
780
  @click="insertRefTagToPrompt(idx)"
775
781
  >
776
- <img :src="refItem.url" :alt="refItem.name" class="thumb-img" />
782
+ <div v-if="brokenImgMap[refItem.id]" class="thumb-img-placeholder">
783
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.6">
784
+ <rect x="3" y="3" width="18" height="18" rx="2" ry="2" />
785
+ <circle cx="8.5" cy="8.5" r="1.5" />
786
+ <polyline points="21 15 16 10 5 21" />
787
+ </svg>
788
+ </div>
789
+ <img v-else :src="refItem.url" alt="" class="thumb-img" @error="markImgBroken(refItem.id)" />
777
790
  <span class="thumb-tag">
778
791
  <template v-if="refItem.type === 'style'">★</template>
779
792
  @img{{ idx + 1 }}
@@ -905,7 +918,14 @@ defineExpose({
905
918
  class="picker-mini-card"
906
919
  @click="addReferenceItem({ id: String(asset.id), name: asset.title, url: asset.url || '', assetId: String(asset.id) })"
907
920
  >
908
- <img :src="asset.previewUrl || asset.url" :alt="asset.title" />
921
+ <div v-if="brokenImgMap[`picker_${asset.id}`]" class="picker-mini-placeholder">
922
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.6">
923
+ <rect x="3" y="3" width="18" height="18" rx="2" ry="2" />
924
+ <circle cx="8.5" cy="8.5" r="1.5" />
925
+ <polyline points="21 15 16 10 5 21" />
926
+ </svg>
927
+ </div>
928
+ <img v-else :src="asset.previewUrl || asset.url" alt="" @error="markImgBroken(`picker_${asset.id}`)" />
909
929
  <span>{{ asset.title }}</span>
910
930
  </div>
911
931
  </div>
@@ -1183,11 +1203,20 @@ defineExpose({
1183
1203
  :alt="resItem.title"
1184
1204
  class="result-media"
1185
1205
  />
1206
+ <div v-else-if="brokenImgMap[`res_${resItem.id}`]" class="result-media-placeholder">
1207
+ <svg viewBox="0 0 24 24" width="26" height="26" fill="none" stroke="currentColor" stroke-width="1.5">
1208
+ <rect x="3" y="3" width="18" height="18" rx="2.5" ry="2.5" />
1209
+ <circle cx="8.5" cy="8.5" r="1.5" />
1210
+ <polyline points="21 15 16 10 5 21" />
1211
+ </svg>
1212
+ <span>图片已失效</span>
1213
+ </div>
1186
1214
  <img
1187
1215
  v-else
1188
1216
  :src="resItem.url"
1189
- :alt="resItem.title"
1217
+ alt=""
1190
1218
  class="result-media"
1219
+ @error="markImgBroken(`res_${resItem.id}`)"
1191
1220
  />
1192
1221
 
1193
1222
  <span v-if="resItem.type === 'video'" class="video-badge">
@@ -1591,6 +1620,15 @@ defineExpose({
1591
1620
  display: block;
1592
1621
  }
1593
1622
 
1623
+ .thumb-img-placeholder {
1624
+ width: 100%;
1625
+ height: 100%;
1626
+ display: flex;
1627
+ align-items: center;
1628
+ justify-content: center;
1629
+ background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
1630
+ }
1631
+
1594
1632
  .thumb-tag {
1595
1633
  position: absolute;
1596
1634
  left: 4px;
@@ -1765,6 +1803,16 @@ defineExpose({
1765
1803
  display: block;
1766
1804
  }
1767
1805
 
1806
+ .picker-mini-placeholder {
1807
+ width: 100%;
1808
+ height: 44px;
1809
+ display: flex;
1810
+ align-items: center;
1811
+ justify-content: center;
1812
+ color: #94a3b8;
1813
+ background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
1814
+ }
1815
+
1768
1816
  span {
1769
1817
  display: block;
1770
1818
  font-size: 10px;
@@ -2164,6 +2212,19 @@ defineExpose({
2164
2212
  display: block;
2165
2213
  }
2166
2214
 
2215
+ .result-media-placeholder {
2216
+ width: 100%;
2217
+ height: 100%;
2218
+ display: flex;
2219
+ flex-direction: column;
2220
+ align-items: center;
2221
+ justify-content: center;
2222
+ gap: 5px;
2223
+ color: #94a3b8;
2224
+ background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
2225
+ font-size: 11px;
2226
+ }
2227
+
2167
2228
  .video-badge {
2168
2229
  position: absolute;
2169
2230
  left: 6px;
@@ -60,6 +60,31 @@ const pageSize = 20
60
60
  const reachEnd = ref(false)
61
61
  const assetList = ref<MaterialItem[]>([])
62
62
  const fileInputRef = ref<HTMLInputElement | null>(null)
63
+ // 记录图片加载状态:0/undefined=默认, 1=回退尝试url, 2=加载失败展示默认占位图
64
+ const imageLoadState = ref<Record<string, number>>({})
65
+
66
+ function getAssetImageSrc(item: MaterialItem): string {
67
+ const state = imageLoadState.value[item.id] || 0
68
+ if (state === 1 && item.url && item.url !== item.previewUrl) {
69
+ return item.url
70
+ }
71
+ return item.previewUrl || item.url || ''
72
+ }
73
+
74
+ function isAssetImageBroken(item: MaterialItem): boolean {
75
+ const src = item.previewUrl || item.url || ''
76
+ if (!src) return true
77
+ return (imageLoadState.value[item.id] || 0) >= 2
78
+ }
79
+
80
+ function handleAssetImageError(item: MaterialItem) {
81
+ const cur = imageLoadState.value[item.id] || 0
82
+ if (cur === 0 && item.url && item.previewUrl && item.url !== item.previewUrl) {
83
+ imageLoadState.value = { ...imageLoadState.value, [item.id]: 1 }
84
+ } else {
85
+ imageLoadState.value = { ...imageLoadState.value, [item.id]: 2 }
86
+ }
87
+ }
63
88
 
64
89
  const PROJECT_COLORS = ['#3b82f6', '#10b981', '#8b5cf6', '#f59e0b', '#ec4899']
65
90
 
@@ -864,12 +889,24 @@ defineExpose({
864
889
  :alt="item.title"
865
890
  class="mine-card-media"
866
891
  />
892
+ <div
893
+ v-else-if="isAssetImageBroken(item)"
894
+ class="mine-card-placeholder"
895
+ >
896
+ <svg viewBox="0 0 24 24" width="26" height="26" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
897
+ <rect x="3" y="3" width="18" height="18" rx="2.5" ry="2.5" />
898
+ <circle cx="8.5" cy="8.5" r="1.5" />
899
+ <polyline points="21 15 16 10 5 21" />
900
+ </svg>
901
+ <span class="placeholder-tip">图片已失效</span>
902
+ </div>
867
903
  <img
868
904
  v-else
869
- :src="item.previewUrl || item.url"
870
- :alt="item.title"
905
+ :src="getAssetImageSrc(item)"
906
+ alt=""
871
907
  loading="lazy"
872
908
  class="mine-card-media"
909
+ @error="handleAssetImageError(item)"
873
910
  />
874
911
 
875
912
  <!-- 左上角来源徽标 -->
@@ -1349,13 +1386,34 @@ defineExpose({
1349
1386
  .mine-card-media {
1350
1387
  width: 100%;
1351
1388
  height: auto;
1352
- min-height: 64px;
1389
+ min-height: 88px;
1353
1390
  max-height: 210px;
1354
1391
  object-fit: cover;
1355
1392
  display: block;
1356
1393
  transition: transform 0.22s ease;
1357
1394
  }
1358
1395
 
1396
+ .mine-card-placeholder {
1397
+ width: 100%;
1398
+ min-height: 104px;
1399
+ padding: 20px 10px 28px;
1400
+ box-sizing: border-box;
1401
+ display: flex;
1402
+ flex-direction: column;
1403
+ align-items: center;
1404
+ justify-content: center;
1405
+ gap: 5px;
1406
+ color: #94a3b8;
1407
+ background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
1408
+ user-select: none;
1409
+
1410
+ .placeholder-tip {
1411
+ font-size: 11px;
1412
+ color: #94a3b8;
1413
+ line-height: 1.2;
1414
+ }
1415
+ }
1416
+
1359
1417
  .mine-card-badge {
1360
1418
  position: absolute;
1361
1419
  top: 6px;