Skip to content

Commit

Permalink
chore: rename indexedDB
Browse files Browse the repository at this point in the history
  • Loading branch information
oct16 committed Mar 17, 2020
1 parent 8fade7f commit 801e498
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const elementList: [HTMLElement, string][] = [

Gzip一般是在网络应用层里对传输数据进行压缩,但是我们的数据不一定只存在数据库里,可能会有三种储存方式
1. 服务器存储 TCP => DB
2. 本地储存 localStorage、indexDB、web SQL
2. 本地储存 localStorage、indexedDB、web SQL
3. 保存为本地文件,例如直接导出可运行的HTML文件

利用客户端的运算能力,在进行导出或者传输之前,可以对数据进行压缩,极大程度的减小体积
Expand All @@ -205,7 +205,7 @@ Gzip一般是在网络应用层里对传输数据进行压缩,但是我们的
##### 数据上传

对于客户端的数据,可以利用浏览器提供的IndexDB进行存储,毕竟IndexDB会比LocalStorage容量大得多,一般来说不少于 250MB,甚至没有上限,此外它使用object store存储,而且支持transaction,另外很重要的一点它是异步的,意味着不会阻塞录屏器的运行
对于客户端的数据,可以利用浏览器提供的indexedDB进行存储,毕竟indexedDB会比LocalStorage容量大得多,一般来说不少于 250MB,甚至没有上限,此外它使用object store存储,而且支持transaction,另外很重要的一点它是异步的,意味着不会阻塞录屏器的运行
之后数据可以通过WebSocket或其他方式持续上传到OSS服务器中,由于数据是分块进行传输的,在同步之后还可以增加数据校验码来保证一致性避免错误


Expand Down
4 changes: 2 additions & 2 deletions packages/player/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { ContainerComponent } from './container'
import { Panel } from './panel'

export async function replay() {
const indexDB = await DBPromise
const { width, height, vNode, data } = await indexDB.getData()
const indexedDB = await DBPromise
const { width, height, vNode, data } = await indexedDB.getData()

const container = new ContainerComponent({ vNode, width, height })
new Panel(container, data)
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './store/listener'
export * from './store/node'
export * from './store/data'
export * from './store/idb'
export * from './redux'
export * from './tool'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SnapshotData, WindowSnapshotData, DOMSnapshotData } from '@WebReplay/snapshot'

export class IndexDBOperator {
export class IndexedDBOperator {
db: IDBDatabase
DBName: string
version: number
Expand All @@ -13,7 +13,7 @@ export class IndexDBOperator {

const request = window.indexedDB.open(DBName, version)
request.onerror = e => {
console.error('open IndexDB on error')
console.error('open indexedDB on error')
}

request.onsuccess = e => {
Expand Down Expand Up @@ -43,7 +43,7 @@ export class IndexDBOperator {
.add(data)

request.onerror = e => {
throw new Error('write IndexDB on error')
throw new Error('write indexedDB on error')
}
}

Expand Down Expand Up @@ -77,8 +77,8 @@ export class IndexDBOperator {
}
}

export const DBPromise: Promise<IndexDBOperator> = new Promise(resolve => {
const indexDB = new IndexDBOperator('wr_db', 1, 'wr_data', () => {
resolve(indexDB)
export const DBPromise: Promise<IndexedDBOperator> = new Promise(resolve => {
const indexedDB = new IndexedDBOperator('wr_db', 1, 'wr_data', () => {
resolve(indexedDB)
})
})

0 comments on commit 801e498

Please sign in to comment.