Repo created
This commit is contained in:
parent
f3a6b3a320
commit
f954c78789
614 changed files with 135712 additions and 2 deletions
31
_scripts/_localforage.js
Normal file
31
_scripts/_localforage.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
import { readFile, writeFile } from '../src/renderer/helpers/android'
|
||||
|
||||
export function createInstance(_kwargs) {
|
||||
return {
|
||||
async getItem(key) {
|
||||
const dataLocationFile = await readFile('data://', 'data-location.json')
|
||||
if (dataLocationFile !== '') {
|
||||
const locationInfo = JSON.parse(dataLocationFile)
|
||||
const locationMap = Object.fromEntries(locationInfo.files.map((file) => { return [file.fileName, file.uri] }))
|
||||
if (key in locationMap) {
|
||||
return await readFile(locationMap[key])
|
||||
}
|
||||
}
|
||||
const data = await readFile('data://', key)
|
||||
return data
|
||||
},
|
||||
async setItem(key, value) {
|
||||
const dataLocationFile = await readFile('data://', 'data-location.json')
|
||||
if (dataLocationFile !== '') {
|
||||
const locationInfo = JSON.parse(dataLocationFile)
|
||||
const locationMap = Object.fromEntries(locationInfo.files.map((file) => { return [file.fileName, file.uri] }))
|
||||
if (key in locationMap) {
|
||||
await writeFile(locationMap[key], value)
|
||||
return
|
||||
}
|
||||
}
|
||||
await writeFile('data://', key, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue