chore: update dexie v4(#342)

This commit is contained in:
zxc 2025-04-14 21:21:50 +08:00
parent b6a96f73a2
commit 302c8206fb
5 changed files with 24 additions and 31 deletions

View File

@ -70,7 +70,7 @@ A. 大家都知道,对于一般的插件/库而言一个封装好的npm包
#### Q. 关于 AI PPT #### Q. 关于 AI PPT
A. 我不想蹭AI的热度但无奈太多人将AI看得太重了于是我做了这个DEMO它真的没那么复杂目前此功能仅作参考内部实现了最基础的AIPPT生成逻辑模板定制 + AI生成数据与模板结合 + 配图替换。为控制成本暂时只能做到这里但为了达到生产环节的效果你还需要做更多例如更多的模板、更细致的AI工作流程。 A. 首先需要说明AIPPT不是PPTist的重点现在或以后都不是它只是PPTist众多功能中非常小的一部分而已并且是比较简单一部分你可以理解为这只是一个跟风的小功能点我不想蹭AI的热度但无奈太多人将AI看得太重要太复杂于是我做了这个DEMO它真的没那么复杂目前此功能仅作参考内部实现了最基础的AIPPT生成逻辑模板定制 + AI生成数据与模板结合 + 配图替换。为控制成本暂时只能做到这里但为了达到生产环节的效果你还需要做更多例如更多的模板、更细致的AI工作流程。
配图替换仅提供方法不提供实际演示功能你需要自己提供图片源接入如AI文生图、图库搜索匹配等方法 配图替换仅提供方法不提供实际演示功能你需要自己提供图片源接入如AI文生图、图库搜索匹配等方法

17
package-lock.json generated
View File

@ -13,7 +13,7 @@
"axios": "^1.7.9", "axios": "^1.7.9",
"clipboard": "^2.0.11", "clipboard": "^2.0.11",
"crypto-js": "^4.2.0", "crypto-js": "^4.2.0",
"dexie": "3.0.3", "dexie": "^4.0.11",
"echarts": "^5.5.1", "echarts": "^5.5.1",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"hfmath": "^0.0.2", "hfmath": "^0.0.2",
@ -2301,12 +2301,9 @@
"integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==" "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw=="
}, },
"node_modules/dexie": { "node_modules/dexie": {
"version": "3.0.3", "version": "4.0.11",
"resolved": "https://registry.npmmirror.com/dexie/-/dexie-3.0.3.tgz", "resolved": "https://registry.npmmirror.com/dexie/-/dexie-4.0.11.tgz",
"integrity": "sha512-BSFhGpngnCl1DOr+8YNwBDobRMH0ziJs2vts69VilwetHYOtEDcLqo7d/XiIphM0tJZ2rPPyAGd31lgH2Ln3nw==", "integrity": "sha512-SOKO002EqlvBYYKQSew3iymBoN2EQ4BDw/3yprjh7kAfFzjBYkaMNa/pZvcA7HSWlcKSQb9XhPe3wKyQ0x4A8A=="
"engines": {
"node": ">=6.0"
}
}, },
"node_modules/dir-glob": { "node_modules/dir-glob": {
"version": "3.0.1", "version": "3.0.1",
@ -6947,9 +6944,9 @@
"integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==" "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw=="
}, },
"dexie": { "dexie": {
"version": "3.0.3", "version": "4.0.11",
"resolved": "https://registry.npmmirror.com/dexie/-/dexie-3.0.3.tgz", "resolved": "https://registry.npmmirror.com/dexie/-/dexie-4.0.11.tgz",
"integrity": "sha512-BSFhGpngnCl1DOr+8YNwBDobRMH0ziJs2vts69VilwetHYOtEDcLqo7d/XiIphM0tJZ2rPPyAGd31lgH2Ln3nw==" "integrity": "sha512-SOKO002EqlvBYYKQSew3iymBoN2EQ4BDw/3yprjh7kAfFzjBYkaMNa/pZvcA7HSWlcKSQb9XhPe3wKyQ0x4A8A=="
}, },
"dir-glob": { "dir-glob": {
"version": "3.0.1", "version": "3.0.1",

View File

@ -18,7 +18,7 @@
"axios": "^1.7.9", "axios": "^1.7.9",
"clipboard": "^2.0.11", "clipboard": "^2.0.11",
"crypto-js": "^4.2.0", "crypto-js": "^4.2.0",
"dexie": "3.0.3", "dexie": "^4.0.11",
"echarts": "^5.5.1", "echarts": "^5.5.1",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"hfmath": "^0.0.2", "hfmath": "^0.0.2",

View File

@ -38,7 +38,7 @@ export const useSnapshotStore = defineStore('snapshot', {
const newFirstSnapshot = { const newFirstSnapshot = {
index: slidesStore.slideIndex, index: slidesStore.slideIndex,
slides: slidesStore.slides, slides: JSON.parse(JSON.stringify(slidesStore.slides)),
} }
await db.snapshots.add(newFirstSnapshot) await db.snapshots.add(newFirstSnapshot)
this.setSnapshotCursor(0) this.setSnapshotCursor(0)
@ -63,7 +63,7 @@ export const useSnapshotStore = defineStore('snapshot', {
// 添加新快照 // 添加新快照
const snapshot = { const snapshot = {
index: slidesStore.slideIndex, index: slidesStore.slideIndex,
slides: slidesStore.slides, slides: JSON.parse(JSON.stringify(slidesStore.slides)),
} }
await db.snapshots.add(snapshot) await db.snapshots.add(snapshot)
@ -83,7 +83,7 @@ export const useSnapshotStore = defineStore('snapshot', {
db.snapshots.update(allKeys[snapshotLength - 2] as number, { index: slidesStore.slideIndex }) db.snapshots.update(allKeys[snapshotLength - 2] as number, { index: slidesStore.slideIndex })
} }
await db.snapshots.bulkDelete(needDeleteKeys) await db.snapshots.bulkDelete(needDeleteKeys as number[])
this.setSnapshotCursor(snapshotLength - 1) this.setSnapshotCursor(snapshotLength - 1)
this.setSnapshotLength(snapshotLength) this.setSnapshotLength(snapshotLength)

View File

@ -1,14 +1,15 @@
import Dexie from 'dexie' import Dexie, { type EntityTable } from 'dexie'
import { databaseId } from '@/store/main' import { databaseId } from '@/store/main'
import type { Slide } from '@/types/slides' import type { Slide } from '@/types/slides'
import { LOCALSTORAGE_KEY_DISCARDED_DB } from '@/configs/storage' import { LOCALSTORAGE_KEY_DISCARDED_DB } from '@/configs/storage'
export interface writingBoardImg { export interface writingBoardImg {
id: string id: number
dataURL: string dataURL: string
} }
export interface Snapshot { export interface Snapshot {
id: number
index: number index: number
slides: Slide[] slides: Slide[]
} }
@ -41,19 +42,14 @@ export const deleteDiscardedDB = async () => {
localStorage.removeItem(LOCALSTORAGE_KEY_DISCARDED_DB) localStorage.removeItem(LOCALSTORAGE_KEY_DISCARDED_DB)
} }
class PPTistDB extends Dexie { const db = new Dexie(`${databaseNamePrefix}_${databaseId}_${new Date().getTime()}`) as Dexie & {
public snapshots: Dexie.Table<Snapshot, number> snapshots: EntityTable<Snapshot, 'id'>,
public writingBoardImgs: Dexie.Table<writingBoardImg, number> writingBoardImgs: EntityTable<writingBoardImg, 'id'>,
public constructor() {
super(`${databaseNamePrefix}_${databaseId}_${new Date().getTime()}`)
this.version(1).stores({
snapshots: '++id',
writingBoardImgs: '++id',
})
this.snapshots = this.table('snapshots')
this.writingBoardImgs = this.table('writingBoardImgs')
}
} }
export const db = new PPTistDB() db.version(1).stores({
snapshots: '++id',
writingBoardImgs: '++id',
})
export { db }