Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uni-helper/localforage-adapter
适用于 uni-app 的 localForage 适配器
https://github.com/uni-helper/localforage-adapter
localforage sqlite sqlite-android sqlite-ios uniapp unistorage
Last synced: 2 months ago
JSON representation
适用于 uni-app 的 localForage 适配器
- Host: GitHub
- URL: https://github.com/uni-helper/localforage-adapter
- Owner: uni-helper
- License: mit
- Created: 2023-10-24T07:50:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-21T04:03:00.000Z (9 months ago)
- Last Synced: 2024-05-21T05:22:23.041Z (9 months ago)
- Topics: localforage, sqlite, sqlite-android, sqlite-ios, uniapp, unistorage
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@uni-helper/localforage-adapter
- Size: 259 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @uni-helper/localforage-adapter
[![NPM version](https://img.shields.io/npm/v/@uni-helper/localforage-adapter?color=a1b858&label=)](https://www.npmjs.com/package/@uni-helper/localforage-adapter)
## 安装
```bash
# pnpm
pnpm install @uni-helper/localforage-adapter
# npm
npm install @uni-helper/localforage-adapter --save
# yarn
yarn add @uni-helper/localforage-adapter
```## 使用
- uniStorageDriver:使用uni-app内置的storage API,支持所有平台,但是性能较差,不建议在H5端和App端使用,仅建议小程序端使用
- sqliteDriver:使用基座包提供的SQLite模块,仅支持App端,性能较好,建议在App端使用```js
import { uniStorageDriver, sqliteDriver } from "@uni-helper/localforage-adapter"
import localforage from "localforage"localforage.defineDriver(uniStorageDriver); // 全端支持,但是还是建议在H5端使用lf自带的IndexedDB
localforage.defineDriver(sqliteDriver); // 仅支持APP端,并需要基座包支持SQLite模块
// 可以使用 #ifdef 等UniAPP特有条件编译注释符
localforage.setDriver([ //会按顺序依次尝试,直到找到可用的驱动
sqliteDriver._driver // 或者"sqliteDriver"
uniStorageDriver._driver // 或者"uniStorageDriver"
]);
```## License
[MIT](./LICENSE) License © 2023-PRESENT [Uni-Helper](https://github.com/uni-helper)