+ 炽灼残渣新增保存功能

+ 格式化代码
This commit is contained in:
2022-11-20 00:19:56 +08:00
parent 0cff88322b
commit c120bf3fdd
9 changed files with 481 additions and 398 deletions

34
modules/tools.js Normal file
View File

@@ -0,0 +1,34 @@
class IO {
constructor(scope) {
this.scope = scope
}
read(id) {
let key = `${this.scope}/${id}`
return localStorage.getItem(key)
}
write(id, data) {
let key = `${this.scope}/${id}`
localStorage.setItem(key, data)
}
remove(id) {
let key = `${this.scope}/${id}`
localStorage.removeItem(key)
}
listKeys() {
let keys = []
for (const key in localStorage) {
if (Object.hasOwnProperty.call(localStorage, key) &&
key.startsWith(this.scope)) {
let i = key.indexOf('/') + 1
keys.push(key.slice(i))
}
}
return keys
}
}
export { IO }