Skip to content
This repository was archived by the owner on May 11, 2021. It is now read-only.

Commit 9881baa

Browse files
committed
修改 - localforage 注释
1 parent 028b15e commit 9881baa

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/common/js/cache.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
// localStorage 仓库
22

3-
// localforage 库是异步本地储存的,因异步读取机制, state 中无法得到 localStorage 正确的值,故弃用,转而使用 store.js 进行同步存储和读取数据
3+
/**
4+
* 弃用 localforage 原因:
5+
* 1. localforage 库是异步本地储存的,因异步读取机制。
6+
* 2. 除非将整个 state 对象包裹在异步函数中,否则 state 中依赖 localStorage 的值属性
7+
* 无法异步被赋值为 localStorage 的值,故弃用,转而使用 store.js 进行同步存储和读取数
8+
* 据
9+
* 3. 个人认为将 state 包裹在回调中略丑陋,不够简洁
10+
*/
411

512
import localStorage from 'store/dist/store.modern'
613

src/store/state.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ const state = { // 只保留最基础的数据,由基础数据可计算得到
1515
}
1616

1717
export default state
18+
19+
// TODO: 待验证 vuex searchHistory 异步被赋值

0 commit comments

Comments
 (0)