jvs-ppt-ui 0.0.30 → 0.0.32

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.
@@ -1384,6 +1384,15 @@ watch(extractTab, () => {
1384
1384
  </div>
1385
1385
  </div>
1386
1386
  </div>
1387
+
1388
+ <!-- 新增主题样式按钮 -->
1389
+ <button type="button" class="add-theme-recipe-btn" @click="emit('openStyleBuilder', isMasterEditingView ? 'all' : 'single', 'new-custom', true)">
1390
+ <svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round">
1391
+ <line x1="8" y1="3" x2="8" y2="13" />
1392
+ <line x1="3" y1="8" x2="13" y2="8" />
1393
+ </svg>
1394
+ <span>新增主题样式</span>
1395
+ </button>
1387
1396
  </div>
1388
1397
  </div>
1389
1398
 
@@ -2447,6 +2456,29 @@ watch(extractTab, () => {
2447
2456
  }
2448
2457
  }
2449
2458
 
2459
+ .add-theme-recipe-btn {
2460
+ display: flex;
2461
+ align-items: center;
2462
+ justify-content: center;
2463
+ gap: 6px;
2464
+ width: 100%;
2465
+ height: 38px;
2466
+ border: 1px dashed #cbd5e1;
2467
+ border-radius: 8px;
2468
+ background: #f8fafc;
2469
+ color: #475569;
2470
+ font-size: 13px;
2471
+ font-weight: 500;
2472
+ cursor: pointer;
2473
+ transition: all 0.15s ease;
2474
+
2475
+ &:hover {
2476
+ border-color: #2563eb;
2477
+ background: #eff6ff;
2478
+ color: #2563eb;
2479
+ }
2480
+ }
2481
+
2450
2482
  .theme-preview-box {
2451
2483
  width: 100%;
2452
2484
  box-sizing: border-box;
@@ -1,3 +1,4 @@
1
+ import { reactive, watch } from 'vue'
1
2
  import { generateMonoPalette } from '../utils/palette'
2
3
 
3
4
  export interface PresetTheme {
@@ -147,7 +148,9 @@ export const defaultStyleRecipe: StyleRecipe = {
147
148
  }
148
149
  }
149
150
 
150
- export const builtinStyleRecipes: StyleRecipe[] = [
151
+ const STYLE_RECIPES_STORAGE_KEY = 'jvs_ppt_custom_style_recipes_v1'
152
+
153
+ const defaultBuiltinStyleRecipes: StyleRecipe[] = [
151
154
  {
152
155
  id: 'tech-blue',
153
156
  name: '商务科技蓝',
@@ -321,6 +324,51 @@ export const builtinStyleRecipes: StyleRecipe[] = [
321
324
  }
322
325
  ]
323
326
 
327
+ function loadPersistedStyleRecipes(): StyleRecipe[] {
328
+ const baseList: StyleRecipe[] = JSON.parse(JSON.stringify(defaultBuiltinStyleRecipes))
329
+ if (typeof window === 'undefined' || !window.localStorage) {
330
+ return baseList
331
+ }
332
+ try {
333
+ const raw = window.localStorage.getItem(STYLE_RECIPES_STORAGE_KEY)
334
+ if (!raw) return baseList
335
+ const saved = JSON.parse(raw)
336
+ if (!Array.isArray(saved)) return baseList
337
+
338
+ for (const item of saved) {
339
+ if (!item || typeof item !== 'object' || !item.id) continue
340
+ const existingIdx = baseList.findIndex(r => r.id === item.id)
341
+ if (existingIdx >= 0) {
342
+ baseList[existingIdx] = item
343
+ } else {
344
+ baseList.push(item)
345
+ }
346
+ }
347
+ } catch (err) {
348
+ console.warn('Failed to load persisted style recipes:', err)
349
+ }
350
+ return baseList
351
+ }
352
+
353
+ export const builtinStyleRecipes: StyleRecipe[] = reactive(loadPersistedStyleRecipes())
354
+
355
+ export function saveStyleRecipesToStorage(recipes: StyleRecipe[] = builtinStyleRecipes) {
356
+ if (typeof window === 'undefined' || !window.localStorage) return
357
+ try {
358
+ window.localStorage.setItem(STYLE_RECIPES_STORAGE_KEY, JSON.stringify(recipes))
359
+ } catch (err) {
360
+ console.warn('Failed to save style recipes to localStorage:', err)
361
+ }
362
+ }
363
+
364
+ watch(
365
+ () => builtinStyleRecipes,
366
+ (val) => {
367
+ saveStyleRecipesToStorage(val)
368
+ },
369
+ { deep: true }
370
+ )
371
+
324
372
  // 全手工调色配置 100 个极具品味、极富差异感与高对比度的独立商业主题配方
325
373
  export const presetThemes: PresetTheme[] = [
326
374
  {