Thu Jul 6 08:43:00 UTC 2023 inscode

上级 523fa757
...@@ -414,9 +414,9 @@ export default { ...@@ -414,9 +414,9 @@ export default {
for (let id = start; id < end; id++) { for (let id = start; id < end; id++) {
tmpHistory.push(this.message[id]) tmpHistory.push(this.message[id])
} }
StorageApi.set(this.history.name, cacheKey, JSON.stringify(tmpHistory)) StorageApi.put(this.history.name, cacheKey, JSON.stringify(tmpHistory))
} else { } else {
StorageApi.set(this.history.name, cacheKey, JSON.stringify(this.message)) StorageApi.put(this.history.name, cacheKey, JSON.stringify(this.message))
} }
}, },
......
...@@ -49,6 +49,25 @@ export default { ...@@ -49,6 +49,25 @@ export default {
} }
}) })
}, },
put(tableName = defaultTableName, key, val, id = 100){
let request = db.transaction(tableName, 'readwrite')
.objectStore(tableName)
.put({
id: id,
key: key,
data: val
})
return new Promise((resolve, reject) => {
request.onsuccess = (event) => {
console.info('添加成功', event)
resolve(event)
}
request.onerror = (event) => {
console.info('添加失败')
reject(event)
}
})
},
getAll(tableName = defaultTableName){ getAll(tableName = defaultTableName){
let request = db.transaction(tableName, 'readwrite') let request = db.transaction(tableName, 'readwrite')
.objectStore(tableName) .objectStore(tableName)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册