jvs-ppt-ui 0.0.32 → 0.0.34
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/README.md +152 -0
- package/dist/lib/jvs-ppt-ui.es.js +23678 -21439
- package/dist/lib/jvs-ppt-ui.umd.js +136 -100
- package/dist/lib/style.css +1 -1
- package/package.json +2 -1
- package/src/components/CanvasArea.vue +77 -35
- package/src/components/Header.vue +184 -26
- package/src/components/PitchImportDialog.vue +29 -6
- package/src/components/PptEditor.vue +53 -1
- package/src/components/QuickColorPopover.vue +2 -1
- package/src/components/SidebarLeft.vue +367 -41
- package/src/components/SidebarRight.vue +183 -134
- package/src/components/canvas/CanvasTransformHandles.vue +27 -36
- package/src/components/canvas/elements/CanvasMediaElement.vue +4 -3
- package/src/components/canvas/elements/CanvasShapeElement.vue +9 -6
- package/src/components/sidebar/panels/LayoutThumbSvg.vue +9 -6
- package/src/components/sidebar/panels/SidebarShapeFormatPanel.vue +1 -1
- package/src/components/sidebar/panels/SidebarTextFormatPanel.vue +1 -1
- package/src/composables/canvas/useCanvasFormatting.ts +20 -13
- package/src/composables/canvas/useCanvasText.ts +4 -3
- package/src/composables/canvas/useCanvasTransform.ts +37 -10
- package/src/composables/sidebar/useSidebarElementTransform.ts +86 -57
- package/src/composables/sidebar/useSidebarTextFormat.ts +242 -19
- package/src/composables/useSlides.ts +93 -28
- package/src/configs/slideTemplates.ts +1001 -0
- package/src/style.css +265 -2
- package/src/types/index.ts +37 -1
- package/src/utils/canvas/elementStyles.ts +55 -20
- package/src/utils/canvas/formatPainter.ts +177 -30
- package/src/utils/muxHlsToMp4.ts +569 -0
- package/src/utils/pitchConverter.ts +512 -13
- package/dist/lib/templates/index.json +0 -5
|
@@ -46,7 +46,7 @@ const {
|
|
|
46
46
|
enterMasterView, addMaster, deleteMaster, addLayout, deleteLayout, duplicateLayout,
|
|
47
47
|
clipboard, slideClipboard, handleUnifiedPaste, sortSlideElements, getEffectiveMasterElementsForSlide,
|
|
48
48
|
getEffectiveSlideBackground, isCanvasDragging, activeSlideVersion, pauseHistory,
|
|
49
|
-
activeSidebarTab, isReadonly
|
|
49
|
+
activeSidebarTab, isReadonly, isTemplateEnabled
|
|
50
50
|
} = useSlides()
|
|
51
51
|
|
|
52
52
|
const displaySlides = shallowRef<any[]>([...slides.value])
|
|
@@ -214,9 +214,178 @@ function handleEditSlideMaster(index: number) {
|
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
const { locale, t } = useI18n()
|
|
218
|
-
|
|
219
|
-
|
|
217
|
+
const { locale, t } = useI18n()
|
|
218
|
+
|
|
219
|
+
import { builtinStyleRecipes } from '../composables/presetThemes'
|
|
220
|
+
import {
|
|
221
|
+
builtinSlideTemplates,
|
|
222
|
+
cloneSlideForInsertion,
|
|
223
|
+
ensureTemplatesFirstPageLoaded,
|
|
224
|
+
fetchTemplateJsonWithFallback,
|
|
225
|
+
parseTemplateJsonToDeck,
|
|
226
|
+
type SlideTemplateItem
|
|
227
|
+
} from '../configs/slideTemplates'
|
|
228
|
+
|
|
229
|
+
const presetPopoverVisible = ref(false)
|
|
230
|
+
const presetActiveTab = ref<'templates' | 'layouts'>(isTemplateEnabled.value ? 'templates' : 'layouts')
|
|
231
|
+
const templateSearchQuery = ref('')
|
|
232
|
+
const selectedTemplateDeck = ref<SlideTemplateItem | null>(null)
|
|
233
|
+
const loadingTemplateId = ref<string | null>(null)
|
|
234
|
+
const templateJsonInputRef = ref<HTMLInputElement | null>(null)
|
|
235
|
+
|
|
236
|
+
watch(isTemplateEnabled, (enabled) => {
|
|
237
|
+
if (!enabled) {
|
|
238
|
+
presetActiveTab.value = 'layouts'
|
|
239
|
+
selectedTemplateDeck.value = null
|
|
240
|
+
}
|
|
241
|
+
}, { immediate: true })
|
|
242
|
+
|
|
243
|
+
watch(presetPopoverVisible, (visible) => {
|
|
244
|
+
if (visible && isTemplateEnabled.value) {
|
|
245
|
+
ensureTemplatesFirstPageLoaded()
|
|
246
|
+
}
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
const filteredSlideTemplates = computed(() => {
|
|
250
|
+
const q = templateSearchQuery.value.trim().toLowerCase()
|
|
251
|
+
if (!q) return builtinSlideTemplates
|
|
252
|
+
return builtinSlideTemplates.filter(tpl =>
|
|
253
|
+
tpl.name.toLowerCase().includes(q) ||
|
|
254
|
+
(tpl.category && tpl.category.toLowerCase().includes(q))
|
|
255
|
+
)
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
function switchPresetTab(tab: 'templates' | 'layouts') {
|
|
259
|
+
presetActiveTab.value = tab
|
|
260
|
+
if (tab === 'templates') {
|
|
261
|
+
selectedTemplateDeck.value = null
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
async function openTemplateDetail(tpl: SlideTemplateItem) {
|
|
266
|
+
if ((tpl.fileName || tpl.jsonUrl) && !tpl.loaded) {
|
|
267
|
+
loadingTemplateId.value = tpl.id
|
|
268
|
+
try {
|
|
269
|
+
let rawJson: any
|
|
270
|
+
if (tpl.fileName) {
|
|
271
|
+
rawJson = await fetchTemplateJsonWithFallback(tpl.fileName)
|
|
272
|
+
} else {
|
|
273
|
+
const res = await fetch(tpl.jsonUrl!)
|
|
274
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`)
|
|
275
|
+
rawJson = await res.json()
|
|
276
|
+
}
|
|
277
|
+
const parsed = parseTemplateJsonToDeck(rawJson, tpl.name)
|
|
278
|
+
tpl.slides = parsed.slides
|
|
279
|
+
tpl.slidesCount = parsed.slides.length
|
|
280
|
+
tpl.firstSlide = parsed.slides[0]
|
|
281
|
+
tpl.styleRecipes = parsed.styleRecipes
|
|
282
|
+
tpl.loaded = true
|
|
283
|
+
} catch (err: any) {
|
|
284
|
+
notify(`模板加载失败: ${err?.message || '网络请求异常'}`)
|
|
285
|
+
loadingTemplateId.value = null
|
|
286
|
+
return
|
|
287
|
+
} finally {
|
|
288
|
+
loadingTemplateId.value = null
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
selectedTemplateDeck.value = tpl
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function registerTemplateRecipes(tpl?: SlideTemplateItem | null) {
|
|
295
|
+
if (!tpl || !Array.isArray(tpl.styleRecipes) || tpl.styleRecipes.length === 0) return
|
|
296
|
+
for (let i = tpl.styleRecipes.length - 1; i >= 0; i--) {
|
|
297
|
+
const recipe = tpl.styleRecipes[i]
|
|
298
|
+
if (!recipe || !recipe.id) continue
|
|
299
|
+
const idx = builtinStyleRecipes.findIndex(r => r.id === recipe.id)
|
|
300
|
+
if (idx !== -1) {
|
|
301
|
+
builtinStyleRecipes[idx] = recipe
|
|
302
|
+
} else {
|
|
303
|
+
builtinStyleRecipes.unshift(recipe)
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function insertSingleTemplateSlide(tpl: SlideTemplateItem, slide: any, slideIdx: number) {
|
|
309
|
+
if (!slide) return
|
|
310
|
+
registerTemplateRecipes(tpl)
|
|
311
|
+
const cloned = cloneSlideForInsertion(slide)
|
|
312
|
+
if (!cloned.title) {
|
|
313
|
+
cloned.title = `${tpl.name} - 幻灯片 ${slideIdx + 1}`
|
|
314
|
+
}
|
|
315
|
+
const insertPos = Math.min(slides.value.length, Math.max(0, activeIndex.value + 1))
|
|
316
|
+
slides.value.splice(insertPos, 0, cloned)
|
|
317
|
+
activeIndex.value = insertPos
|
|
318
|
+
activeSlideVersion.value++
|
|
319
|
+
displaySlides.value = [...slides.value]
|
|
320
|
+
presetPopoverVisible.value = false
|
|
321
|
+
notify(`已插入模板页 "${cloned.title}"`)
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function insertAllTemplateSlides(tpl: SlideTemplateItem) {
|
|
325
|
+
if (!tpl || !Array.isArray(tpl.slides) || tpl.slides.length === 0) return
|
|
326
|
+
registerTemplateRecipes(tpl)
|
|
327
|
+
const clonedList = tpl.slides.map((s, idx) => {
|
|
328
|
+
const cloned = cloneSlideForInsertion(s)
|
|
329
|
+
if (!cloned.title) {
|
|
330
|
+
cloned.title = `${tpl.name} - 幻灯片 ${idx + 1}`
|
|
331
|
+
}
|
|
332
|
+
return cloned
|
|
333
|
+
})
|
|
334
|
+
const insertPos = Math.min(slides.value.length, Math.max(0, activeIndex.value + 1))
|
|
335
|
+
slides.value.splice(insertPos, 0, ...clonedList)
|
|
336
|
+
activeIndex.value = insertPos
|
|
337
|
+
activeSlideVersion.value++
|
|
338
|
+
displaySlides.value = [...slides.value]
|
|
339
|
+
presetPopoverVisible.value = false
|
|
340
|
+
notify(`已整套插入模板 "${tpl.name}"(共 ${clonedList.length} 页)`)
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function triggerImportTemplateJson() {
|
|
344
|
+
templateJsonInputRef.value?.click()
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
async function handleTemplateJsonFileChange(e: Event) {
|
|
348
|
+
const input = e.target as HTMLInputElement
|
|
349
|
+
const files = input?.files
|
|
350
|
+
if (!files || files.length === 0) return
|
|
351
|
+
|
|
352
|
+
let lastLoadedTpl: SlideTemplateItem | null = null
|
|
353
|
+
let loadedCount = 0
|
|
354
|
+
|
|
355
|
+
for (let i = 0; i < files.length; i++) {
|
|
356
|
+
const file = files[i]
|
|
357
|
+
try {
|
|
358
|
+
const text = await file.text()
|
|
359
|
+
const fallbackName = file.name.replace(/\.json$/i, '').replace(/-\d{10,16}$/, '').trim()
|
|
360
|
+
const parsed = parseTemplateJsonToDeck(text, fallbackName)
|
|
361
|
+
const existing = builtinSlideTemplates.find(
|
|
362
|
+
item => item.name.toLowerCase() === parsed.name.toLowerCase()
|
|
363
|
+
)
|
|
364
|
+
if (existing) {
|
|
365
|
+
existing.slides = parsed.slides
|
|
366
|
+
existing.slidesCount = parsed.slides.length
|
|
367
|
+
existing.firstSlide = parsed.slides[0]
|
|
368
|
+
existing.styleRecipes = parsed.styleRecipes
|
|
369
|
+
existing.loaded = true
|
|
370
|
+
lastLoadedTpl = existing
|
|
371
|
+
} else {
|
|
372
|
+
builtinSlideTemplates.unshift(parsed)
|
|
373
|
+
lastLoadedTpl = parsed
|
|
374
|
+
}
|
|
375
|
+
loadedCount++
|
|
376
|
+
} catch (err: any) {
|
|
377
|
+
notify(`解析模板 "${file.name}" 失败: ${err?.message || '格式错误'}`)
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
input.value = ''
|
|
382
|
+
if (loadedCount === 1 && lastLoadedTpl) {
|
|
383
|
+
selectedTemplateDeck.value = lastLoadedTpl
|
|
384
|
+
notify(`已加载模板 "${lastLoadedTpl.name}"(共 ${lastLoadedTpl.slides.length} 页)`)
|
|
385
|
+
} else if (loadedCount > 1) {
|
|
386
|
+
notify(`已成功加载 ${loadedCount} 套模板到模板库`)
|
|
387
|
+
}
|
|
388
|
+
}
|
|
220
389
|
|
|
221
390
|
|
|
222
391
|
|
|
@@ -469,8 +638,9 @@ function getLayoutSvgElements(elements: any[]) {
|
|
|
469
638
|
const isText = el.type === 'text'
|
|
470
639
|
|
|
471
640
|
const borderStyle = isPlaceholder ? 'dashed' : (el.style?.borderStyle || el.borderStyle || 'none')
|
|
472
|
-
const borderColor = isPlaceholder ? '#cbd5e1' : (getElementBorderColor(el) || parseColorString(el.style?.borderColor || el.borderColor, 'none'))
|
|
473
641
|
const borderWidth = isPlaceholder ? 1 : (getElementBorderWidth(el) || (el.style?.borderWidth ? parseFloat(el.style.borderWidth) : (el.borderWidth ? parseFloat(el.borderWidth) : 0)))
|
|
642
|
+
const hasBorderGrad = hasElementBorderGradient(el)
|
|
643
|
+
const borderColor = isPlaceholder ? '#cbd5e1' : ((!hasBorderGrad && borderWidth <= 0) ? 'none' : (getElementBorderColor(el) || parseColorString(el.style?.borderColor || el.borderColor, 'none')))
|
|
474
644
|
const textAlign = el.style?.textAlign || el.textAlign || (isTitle && !isVertical ? 'center' : 'left')
|
|
475
645
|
|
|
476
646
|
let shapePath = ''
|
|
@@ -1855,7 +2025,7 @@ const masterGroupedLayouts = computed(() => {
|
|
|
1855
2025
|
</g>
|
|
1856
2026
|
<g v-else-if="item.type === 'shape' && item.shapePath" :transform="item.transform">
|
|
1857
2027
|
<svg :x="item.x" :y="item.y" :width="item.w" :height="item.h" :viewBox="`0 0 ${item.shapeViewBox ? item.shapeViewBox[0] : 200} ${item.shapeViewBox ? item.shapeViewBox[1] : 200}`" preserveAspectRatio="none" style="overflow: visible;">
|
|
1858
|
-
<path :d="item.shapePath" :fill="item.gradient ? `url(#m-grad-${master.id}-${item.id})` : (item.fill && item.fill !== 'transparent' ? item.fill : 'none')" :stroke="item.borderGradient ? `url(#m-bgrad-${master.id}-${item.id})` : (item.borderColor && item.borderColor !== 'transparent' ? item.borderColor : 'none')" :stroke-width="item.borderWidth ? Math.min(1.5, Math.max(0.6, item.borderWidth * 0.8)) : 0
|
|
2028
|
+
<path :d="item.shapePath" :fill="item.gradient ? `url(#m-grad-${master.id}-${item.id})` : (item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getHexColorWithoutAlpha(item.fill) : 'none')" :fill-opacity="!item.gradient && item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getAlphaFromColor(item.fill) : undefined" :stroke="item.borderGradient ? `url(#m-bgrad-${master.id}-${item.id})` : (item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getHexColorWithoutAlpha(item.borderColor) : 'none')" :stroke-opacity="!item.borderGradient && item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getAlphaFromColor(item.borderColor) : undefined" :stroke-width="(item.borderGradient || item.borderWidth > 0) ? Math.min(1.5, Math.max(0.6, (item.borderWidth || 1) * 0.8)) : 0" vector-effect="non-scaling-stroke" />
|
|
1859
2029
|
</svg>
|
|
1860
2030
|
</g>
|
|
1861
2031
|
<g v-else-if="item.type === 'shape' && item.isCircle" :transform="item.transform">
|
|
@@ -1864,13 +2034,15 @@ const masterGroupedLayouts = computed(() => {
|
|
|
1864
2034
|
:cy="item.y + item.h / 2"
|
|
1865
2035
|
:rx="item.w / 2"
|
|
1866
2036
|
:ry="item.h / 2"
|
|
1867
|
-
:fill="item.gradient ? `url(#m-grad-${master.id}-${item.id})` : (item.fill && item.fill !== 'transparent' ? item.fill : 'none')"
|
|
1868
|
-
:
|
|
1869
|
-
:stroke
|
|
2037
|
+
:fill="item.gradient ? `url(#m-grad-${master.id}-${item.id})` : (item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getHexColorWithoutAlpha(item.fill) : 'none')"
|
|
2038
|
+
:fill-opacity="!item.gradient && item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getAlphaFromColor(item.fill) : undefined"
|
|
2039
|
+
:stroke="item.borderGradient ? `url(#m-bgrad-${master.id}-${item.id})` : (item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getHexColorWithoutAlpha(item.borderColor) : 'none')"
|
|
2040
|
+
:stroke-opacity="!item.borderGradient && item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getAlphaFromColor(item.borderColor) : undefined"
|
|
2041
|
+
:stroke-width="(item.borderGradient || item.borderWidth > 0) ? Math.min(1.5, Math.max(0.6, (item.borderWidth || 1) * 0.8)) : 0"
|
|
1870
2042
|
/>
|
|
1871
2043
|
</g>
|
|
1872
2044
|
<g v-else-if="item.type === 'shape'" :transform="item.transform">
|
|
1873
|
-
<rect :x="item.x" :y="item.y" :width="item.w" :height="item.h" :fill="item.gradient ? `url(#m-grad-${master.id}-${item.id})` : (item.fill && item.fill !== 'transparent' ? item.fill : 'none')" :stroke="item.borderGradient ? `url(#m-bgrad-${master.id}-${item.id})` : (item.borderColor && item.borderColor !== 'transparent' ? item.borderColor : 'none')" :stroke-width="item.borderWidth ? Math.min(1.5, Math.max(0.6, item.borderWidth * 0.8)) : 0
|
|
2045
|
+
<rect :x="item.x" :y="item.y" :width="item.w" :height="item.h" :fill="item.gradient ? `url(#m-grad-${master.id}-${item.id})` : (item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getHexColorWithoutAlpha(item.fill) : 'none')" :fill-opacity="!item.gradient && item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getAlphaFromColor(item.fill) : undefined" :stroke="item.borderGradient ? `url(#m-bgrad-${master.id}-${item.id})` : (item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getHexColorWithoutAlpha(item.borderColor) : 'none')" :stroke-opacity="!item.borderGradient && item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getAlphaFromColor(item.borderColor) : undefined" :stroke-width="(item.borderGradient || item.borderWidth > 0) ? Math.min(1.5, Math.max(0.6, (item.borderWidth || 1) * 0.8)) : 0" rx="1" />
|
|
1874
2046
|
</g>
|
|
1875
2047
|
<g v-else-if="item.type === 'title' || item.type === 'text'" :transform="item.transform">
|
|
1876
2048
|
<rect
|
|
@@ -2075,7 +2247,7 @@ const masterGroupedLayouts = computed(() => {
|
|
|
2075
2247
|
</g>
|
|
2076
2248
|
<g v-else-if="item.type === 'shape' && item.shapePath" :transform="item.transform">
|
|
2077
2249
|
<svg :x="item.x" :y="item.y" :width="item.w" :height="item.h" :viewBox="`0 0 ${item.shapeViewBox ? item.shapeViewBox[0] : 200} ${item.shapeViewBox ? item.shapeViewBox[1] : 200}`" preserveAspectRatio="none" style="overflow: visible;">
|
|
2078
|
-
<path :d="item.shapePath" :fill="item.gradient ? `url(#l-grad-${layout.id}-${item.id})` : (item.fill && item.fill !== 'transparent' ? item.fill : 'none')" :stroke="item.borderGradient ? `url(#l-bgrad-${layout.id}-${item.id})` : (item.borderColor && item.borderColor !== 'transparent' ? item.borderColor : 'none')" :stroke-width="item.borderWidth ? Math.min(1.5, Math.max(0.6, item.borderWidth * 0.8)) : 0
|
|
2250
|
+
<path :d="item.shapePath" :fill="item.gradient ? `url(#l-grad-${layout.id}-${item.id})` : (item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getHexColorWithoutAlpha(item.fill) : 'none')" :fill-opacity="!item.gradient && item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getAlphaFromColor(item.fill) : undefined" :stroke="item.borderGradient ? `url(#l-bgrad-${layout.id}-${item.id})` : (item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getHexColorWithoutAlpha(item.borderColor) : 'none')" :stroke-opacity="!item.borderGradient && item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getAlphaFromColor(item.borderColor) : undefined" :stroke-width="(item.borderGradient || item.borderWidth > 0) ? Math.min(1.5, Math.max(0.6, (item.borderWidth || 1) * 0.8)) : 0" vector-effect="non-scaling-stroke" />
|
|
2079
2251
|
</svg>
|
|
2080
2252
|
</g>
|
|
2081
2253
|
<g v-else-if="item.type === 'shape' && item.isCircle" :transform="item.transform">
|
|
@@ -2084,13 +2256,15 @@ const masterGroupedLayouts = computed(() => {
|
|
|
2084
2256
|
:cy="item.y + item.h / 2"
|
|
2085
2257
|
:rx="item.w / 2"
|
|
2086
2258
|
:ry="item.h / 2"
|
|
2087
|
-
:fill="item.gradient ? `url(#l-grad-${layout.id}-${item.id})` : (item.fill && item.fill !== 'transparent' ? item.fill : 'none')"
|
|
2088
|
-
:
|
|
2089
|
-
:stroke
|
|
2259
|
+
:fill="item.gradient ? `url(#l-grad-${layout.id}-${item.id})` : (item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getHexColorWithoutAlpha(item.fill) : 'none')"
|
|
2260
|
+
:fill-opacity="!item.gradient && item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getAlphaFromColor(item.fill) : undefined"
|
|
2261
|
+
:stroke="item.borderGradient ? `url(#l-bgrad-${layout.id}-${item.id})` : (item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getHexColorWithoutAlpha(item.borderColor) : 'none')"
|
|
2262
|
+
:stroke-opacity="!item.borderGradient && item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getAlphaFromColor(item.borderColor) : undefined"
|
|
2263
|
+
:stroke-width="(item.borderGradient || item.borderWidth > 0) ? Math.min(1.5, Math.max(0.6, (item.borderWidth || 1) * 0.8)) : 0"
|
|
2090
2264
|
/>
|
|
2091
2265
|
</g>
|
|
2092
2266
|
<g v-else-if="item.type === 'shape'" :transform="item.transform">
|
|
2093
|
-
<rect :x="item.x" :y="item.y" :width="item.w" :height="item.h" :fill="item.gradient ? `url(#l-grad-${layout.id}-${item.id})` : (item.fill && item.fill !== 'transparent' ? item.fill : 'none')" :stroke="item.borderGradient ? `url(#l-bgrad-${layout.id}-${item.id})` : (item.borderColor && item.borderColor !== 'transparent' ? item.borderColor : 'none')" :stroke-width="item.borderWidth ? Math.min(1.5, Math.max(0.6, item.borderWidth * 0.8)) : 0
|
|
2267
|
+
<rect :x="item.x" :y="item.y" :width="item.w" :height="item.h" :fill="item.gradient ? `url(#l-grad-${layout.id}-${item.id})` : (item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getHexColorWithoutAlpha(item.fill) : 'none')" :fill-opacity="!item.gradient && item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getAlphaFromColor(item.fill) : undefined" :stroke="item.borderGradient ? `url(#l-bgrad-${layout.id}-${item.id})` : (item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getHexColorWithoutAlpha(item.borderColor) : 'none')" :stroke-opacity="!item.borderGradient && item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getAlphaFromColor(item.borderColor) : undefined" :stroke-width="(item.borderGradient || item.borderWidth > 0) ? Math.min(1.5, Math.max(0.6, (item.borderWidth || 1) * 0.8)) : 0" rx="1" />
|
|
2094
2268
|
</g>
|
|
2095
2269
|
<g v-else-if="item.type === 'title' || item.type === 'text'" :transform="item.transform">
|
|
2096
2270
|
<rect
|
|
@@ -2209,30 +2383,181 @@ const masterGroupedLayouts = computed(() => {
|
|
|
2209
2383
|
</button>
|
|
2210
2384
|
</template>
|
|
2211
2385
|
|
|
2212
|
-
<div class="preset-layout-popover-container">
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
<div
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
</div>
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2386
|
+
<div class="preset-layout-popover-container">
|
|
2387
|
+
<!-- Hidden file input for loading local template JSON files (e.g. Launch.json, Async Pitch Deck.json) -->
|
|
2388
|
+
<input
|
|
2389
|
+
ref="templateJsonInputRef"
|
|
2390
|
+
type="file"
|
|
2391
|
+
accept=".json"
|
|
2392
|
+
multiple
|
|
2393
|
+
style="display: none;"
|
|
2394
|
+
@change="handleTemplateJsonFileChange"
|
|
2395
|
+
/>
|
|
2396
|
+
|
|
2397
|
+
<div class="preset-layout-tabs-header">
|
|
2398
|
+
<div class="preset-layout-tabs">
|
|
2399
|
+
<div
|
|
2400
|
+
v-if="isTemplateEnabled"
|
|
2401
|
+
class="preset-layout-tab"
|
|
2402
|
+
:class="{ 'is-active': presetActiveTab === 'templates' }"
|
|
2403
|
+
@click="switchPresetTab('templates')"
|
|
2404
|
+
>
|
|
2405
|
+
<span>模板</span>
|
|
2406
|
+
</div>
|
|
2407
|
+
<div
|
|
2408
|
+
class="preset-layout-tab"
|
|
2409
|
+
:class="{ 'is-active': presetActiveTab === 'layouts' }"
|
|
2410
|
+
@click="switchPresetTab('layouts')"
|
|
2411
|
+
>
|
|
2412
|
+
<span>版式</span>
|
|
2413
|
+
</div>
|
|
2414
|
+
</div>
|
|
2415
|
+
|
|
2416
|
+
<button
|
|
2417
|
+
v-if="isTemplateEnabled && presetActiveTab === 'templates' && !selectedTemplateDeck"
|
|
2418
|
+
type="button"
|
|
2419
|
+
class="preset-template-upload-btn"
|
|
2420
|
+
title="加载本地 JSON 模板文件 (支持多选)"
|
|
2421
|
+
@click="triggerImportTemplateJson"
|
|
2422
|
+
>
|
|
2423
|
+
<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2424
|
+
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
|
|
2425
|
+
<polyline points="17 8 12 3 7 8" />
|
|
2426
|
+
<line x1="12" y1="3" x2="12" y2="15" />
|
|
2427
|
+
</svg>
|
|
2428
|
+
<span>加载本地模板</span>
|
|
2429
|
+
</button>
|
|
2430
|
+
</div>
|
|
2431
|
+
|
|
2432
|
+
<!-- TAB 1: 模板 (Templates) -->
|
|
2433
|
+
<div v-if="presetActiveTab === 'templates'" class="preset-layout-body preset-template-body">
|
|
2434
|
+
<!-- 第一级:模板列表视图 (显示模板封面与名称) -->
|
|
2435
|
+
<template v-if="!selectedTemplateDeck">
|
|
2436
|
+
<div class="preset-template-search-box">
|
|
2437
|
+
<svg class="preset-template-search-icon" viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2">
|
|
2438
|
+
<circle cx="11" cy="11" r="8" />
|
|
2439
|
+
<line x1="21" y1="21" x2="16.65" y2="16.65" />
|
|
2440
|
+
</svg>
|
|
2441
|
+
<input
|
|
2442
|
+
v-model="templateSearchQuery"
|
|
2443
|
+
type="text"
|
|
2444
|
+
class="preset-template-search-input"
|
|
2445
|
+
placeholder="搜索模板名称..."
|
|
2446
|
+
/>
|
|
2447
|
+
<button
|
|
2448
|
+
v-if="templateSearchQuery"
|
|
2449
|
+
type="button"
|
|
2450
|
+
class="preset-template-search-clear"
|
|
2451
|
+
@click="templateSearchQuery = ''"
|
|
2452
|
+
>
|
|
2453
|
+
×
|
|
2454
|
+
</button>
|
|
2455
|
+
</div>
|
|
2456
|
+
|
|
2457
|
+
<div class="preset-layout-section-name preset-template-section-header">
|
|
2458
|
+
<span>精选模板库</span>
|
|
2459
|
+
<span class="preset-template-count-text">{{ filteredSlideTemplates.length }} 套</span>
|
|
2460
|
+
</div>
|
|
2461
|
+
|
|
2462
|
+
<div v-if="filteredSlideTemplates.length > 0" class="preset-layout-grid">
|
|
2463
|
+
<div
|
|
2464
|
+
v-for="tpl in filteredSlideTemplates"
|
|
2465
|
+
:key="tpl.id"
|
|
2466
|
+
class="preset-layout-item preset-template-card"
|
|
2467
|
+
@click="openTemplateDetail(tpl)"
|
|
2468
|
+
>
|
|
2469
|
+
<div
|
|
2470
|
+
class="preset-layout-thumb preset-template-thumb"
|
|
2471
|
+
:style="{ background: getSlideBackgroundCss((tpl.firstSlide || tpl.slides?.[0])?.background || '#ffffff') }"
|
|
2472
|
+
>
|
|
2473
|
+
<LayoutThumbSvg
|
|
2474
|
+
v-if="tpl.firstSlide || (tpl.slides && tpl.slides.length > 0)"
|
|
2475
|
+
:elements="(tpl.firstSlide || tpl.slides?.[0])?.elements || []"
|
|
2476
|
+
:background="(tpl.firstSlide || tpl.slides?.[0])?.background || '#ffffff'"
|
|
2477
|
+
/>
|
|
2478
|
+
<span class="preset-template-page-pill">{{ tpl.slidesCount || tpl.slides?.length || 0 }} 页</span>
|
|
2479
|
+
<div v-if="loadingTemplateId === tpl.id" class="preset-template-loading-mask">
|
|
2480
|
+
<span>加载全部幻灯片...</span>
|
|
2481
|
+
</div>
|
|
2482
|
+
</div>
|
|
2483
|
+
<span class="preset-layout-name preset-template-name" :title="tpl.name">{{ tpl.name }}</span>
|
|
2484
|
+
</div>
|
|
2485
|
+
</div>
|
|
2486
|
+
<div v-else class="preset-template-empty">
|
|
2487
|
+
未找到匹配的模板
|
|
2488
|
+
</div>
|
|
2489
|
+
</template>
|
|
2490
|
+
|
|
2491
|
+
<!-- 第二级:模板内全部 Slider 页面展开视图 -->
|
|
2492
|
+
<template v-else>
|
|
2493
|
+
<div class="preset-template-detail-header">
|
|
2494
|
+
<button
|
|
2495
|
+
type="button"
|
|
2496
|
+
class="preset-template-back-btn"
|
|
2497
|
+
@click="selectedTemplateDeck = null"
|
|
2498
|
+
>
|
|
2499
|
+
<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
|
2500
|
+
<polyline points="15 18 9 12 15 6" />
|
|
2501
|
+
</svg>
|
|
2502
|
+
<span>返回</span>
|
|
2503
|
+
</button>
|
|
2504
|
+
|
|
2505
|
+
<div class="preset-template-detail-title" :title="selectedTemplateDeck.name">
|
|
2506
|
+
<span class="detail-name-text">{{ selectedTemplateDeck.name }}</span>
|
|
2507
|
+
<span class="detail-count-badge">{{ selectedTemplateDeck.slides.length }} 页</span>
|
|
2508
|
+
</div>
|
|
2509
|
+
|
|
2510
|
+
<button
|
|
2511
|
+
type="button"
|
|
2512
|
+
class="preset-template-insert-all-btn"
|
|
2513
|
+
@click="insertAllTemplateSlides(selectedTemplateDeck)"
|
|
2514
|
+
>
|
|
2515
|
+
整套插入
|
|
2516
|
+
</button>
|
|
2517
|
+
</div>
|
|
2518
|
+
|
|
2519
|
+
<div class="preset-layout-grid preset-template-slides-grid">
|
|
2520
|
+
<div
|
|
2521
|
+
v-for="(tSlide, sIdx) in selectedTemplateDeck.slides"
|
|
2522
|
+
:key="tSlide.id || sIdx"
|
|
2523
|
+
class="preset-layout-item preset-template-slide-item"
|
|
2524
|
+
@click="insertSingleTemplateSlide(selectedTemplateDeck, tSlide, sIdx)"
|
|
2525
|
+
>
|
|
2526
|
+
<div
|
|
2527
|
+
class="preset-layout-thumb preset-template-slide-thumb"
|
|
2528
|
+
:style="{ background: getSlideBackgroundCss(tSlide.background || '#ffffff') }"
|
|
2529
|
+
>
|
|
2530
|
+
<span class="preset-template-slide-index">{{ String(sIdx + 1).padStart(2, '0') }}</span>
|
|
2531
|
+
<LayoutThumbSvg
|
|
2532
|
+
:elements="tSlide.elements || []"
|
|
2533
|
+
:background="tSlide.background || '#ffffff'"
|
|
2534
|
+
/>
|
|
2535
|
+
<div class="preset-template-slide-hover-badge">+ 插入此页</div>
|
|
2536
|
+
</div>
|
|
2537
|
+
<span class="preset-layout-name" :title="tSlide.title || `幻灯片 ${sIdx + 1}`">
|
|
2538
|
+
{{ tSlide.title || `幻灯片 ${sIdx + 1}` }}
|
|
2539
|
+
</span>
|
|
2540
|
+
</div>
|
|
2541
|
+
</div>
|
|
2542
|
+
</template>
|
|
2543
|
+
</div>
|
|
2544
|
+
|
|
2545
|
+
<!-- TAB 2: 版式 (Layouts) -->
|
|
2546
|
+
<div v-else class="preset-layout-body">
|
|
2547
|
+
<div v-for="masterGroup in masterGroupedLayouts" :key="masterGroup.id" class="preset-layout-master-group">
|
|
2548
|
+
<div v-if="masterGroupedLayouts.length > 1" class="preset-layout-section-name" :title="masterGroup.name">{{ masterGroup.name }}</div>
|
|
2549
|
+
|
|
2550
|
+
<div class="preset-layout-grid">
|
|
2551
|
+
<div v-for="layout in masterGroup.layouts" :key="layout.id" class="preset-layout-item" @click="addSlideWithLayout(layout.id)">
|
|
2552
|
+
<div class="preset-layout-thumb" :style="{ background: getSlideBackgroundCss(layout.background || masterGroup.background || '#ffffff') }">
|
|
2553
|
+
<LayoutThumbSvg :elements="layout.elements || []" :background="layout.background || masterGroup.background || '#ffffff'" />
|
|
2554
|
+
</div>
|
|
2555
|
+
<span class="preset-layout-name" :title="layout.name">{{ layout.name }}</span>
|
|
2556
|
+
</div>
|
|
2557
|
+
</div>
|
|
2558
|
+
</div>
|
|
2559
|
+
</div>
|
|
2560
|
+
</div>
|
|
2236
2561
|
</el-popover>
|
|
2237
2562
|
</div>
|
|
2238
2563
|
</div>
|
|
@@ -2398,8 +2723,9 @@ const masterGroupedLayouts = computed(() => {
|
|
|
2398
2723
|
</template>
|
|
2399
2724
|
</defs>
|
|
2400
2725
|
<path :d="el.path || el.content"
|
|
2401
|
-
:fill="getElementPattern(el) ? `url(#thumb-master-pat-${slide.id || index}-${el.id})` : (getElementGradientConfig(el) ? `url(#thumb-master-grad-${slide.id || index}-${el.id})` : (getSvgPureColor(el) || '#3b82f6'))"
|
|
2402
|
-
:
|
|
2726
|
+
:fill="getElementPattern(el) ? `url(#thumb-master-pat-${slide.id || index}-${el.id})` : (getElementGradientConfig(el) ? `url(#thumb-master-grad-${slide.id || index}-${el.id})` : getHexColorWithoutAlpha(getSvgPureColor(el) || '#3b82f6'))"
|
|
2727
|
+
:fill-opacity="(!getElementPattern(el) && !getElementGradientConfig(el)) ? getAlphaFromColor(getSvgPureColor(el) || '#3b82f6') : undefined"
|
|
2728
|
+
:stroke="hasElementBorderGradient(el) ? `url(#thumb-master-bgrad-${slide.id || index}-${el.id})` : ((el.style?.borderWidth || 0) > 0 ? (getElementBorderColor(el) || 'none') : 'none')" :stroke-width="el.style?.borderWidth || 0" />
|
|
2403
2729
|
</svg>
|
|
2404
2730
|
<div v-else :style="{
|
|
2405
2731
|
backgroundColor: getElementPattern(el) ? 'transparent' : ((getElementGradientCss(el) || (getElementFill(el) !== undefined && getElementFill(el) !== 'none')) ? (getElementGradientCss(el) ? 'transparent' : getElementFill(el)) : (getElementFill(el) === 'none' ? 'transparent' : '#3b82f6')),
|