Browse Source

feat: db store

pull/1/head
wally 4 years ago
parent
commit
6414c4f785
  1. 26
      CHANGELOG.md
  2. 12
      README.md
  3. 1
      package.json
  4. 3
      src/config/db.js
  5. 3
      src/store/db/actions.js
  6. 3
      src/store/db/getters.js
  7. 12
      src/store/db/index.js
  8. 3
      src/store/db/mutations.js
  9. 7
      src/store/db/state.js
  10. 0
      src/store/index.js
  11. 3
      src/store/user/actions.js
  12. 3
      src/store/user/getters.js
  13. 12
      src/store/user/index.js
  14. 3
      src/store/user/mutations.js
  15. 3
      src/store/user/state.js
  16. 29
      src/utils/indexedDB.js
  17. 9
      yarn.lock

26
CHANGELOG.md

@ -1,21 +1,32 @@
# [0.1.0](https://gitee.com/mongos/uni-cli-template/compare/v1.1.1...v0.1.0) (2021-07-15)
# [0.1.0](https://gitee.com/mongos/uni-cli-template/compare/v1.1.1...v0.1.0) (2021-07-16)
### 🌟 新功能
### 🐛 Bug 修复
范围|描述|commitId
--|--|--
pinch | alloy finger实现图片的pinch放大缩小 | [de01343](https://gitee.com/mongos/uni-cli-template/commits/de01343)
- | 修改main | [749ae9a](https://gitee.com/mongos/uni-cli-template/commits/749ae9a)
### 📝 文档
### chore
范围|描述|commitId
--|--|--
- | README.md | [ab0eb05](https://gitee.com/mongos/uni-cli-template/commits/ab0eb05)
pwa 小程序 | 移除了pwa,alloyFinger添加平台判断 | [875fab4](https://gitee.com/mongos/uni-cli-template/commits/875fab4)
### chore
范围|描述|commitId
--|--|--
pwa 小程序 | 移除了pwa,alloyFinger添加平台判断 | [875fab4](https://gitee.com/mongos/uni-cli-template/commits/875fab4)
- | !2 基础模板v1.1.0 | [f5e61dd](https://gitee.com/mongos/uni-cli-template/commits/f5e61dd)
### 🌟 新功能
范围|描述|commitId
--|--|--
pinch | alloy finger实现图片的pinch放大缩小 | [de01343](https://gitee.com/mongos/uni-cli-template/commits/de01343)
### 📝 文档
范围|描述|commitId
--|--|--
- | README.md | [ab0eb05](https://gitee.com/mongos/uni-cli-template/commits/ab0eb05)
# [1.1.0](https://gitee.com/mongos/uni-cli-template/compare/v1.0.1...v1.1.0) (2021-06-23)
@ -47,3 +58,4 @@
范围|描述|commitId
--|--|--
- | init | [c0f1deb](https://gitee.com/mongos/uni-cli-template/commits/c0f1deb)

12
README.md

@ -71,3 +71,15 @@ yarn cz
+ commitlint git commit信息校验
+ husky lint-staged git钩子处理commit校验及eslint代码检测
+ vue-cli-plugin-mock mock数据
## H5 indexedDB
### 设计概要
db挂载到全局的store上,store存放的数据:
```js
{
db: null, // object
name: 'TALL_indexedDB', // string
version: 1, // number
}
```

1
package.json

@ -69,6 +69,7 @@
"postcss": "^7",
"regenerator-runtime": "^0.12.1",
"register-service-worker": "^1.7.1",
"right-pad": "^1.0.1",
"tailwindcss": "npm:@tailwindcss/postcss7-compat",
"uview-ui": "^1.8.4",
"vue": "^2.6.11",

3
src/config/db.js

@ -0,0 +1,3 @@
export const db = null; // indexedDB 对象
export const name = 'TALL_indexedDB'; // indexDB name
export const version = 1; // indexDB version

3
src/store/db/actions.js

@ -0,0 +1,3 @@
const actions = {};
export default actions;

3
src/store/db/getters.js

@ -0,0 +1,3 @@
const getters = {};
export default getters;

12
src/store/db/index.js

@ -0,0 +1,12 @@
import state from './state';
import getters from './getters';
import mutations from './mutations';
import actions from './actions';
export default {
namespaced: true,
state,
getters,
mutations,
actions,
};

3
src/store/db/mutations.js

@ -0,0 +1,3 @@
const mutations = {};
export default mutations;

7
src/store/db/state.js

@ -0,0 +1,7 @@
const state = {
db: null, // indexedDB对象
name: 'TALL_indexedDB',
version: 1,
};
export default state;

0
src/store/index.js

3
src/store/user/actions.js

@ -0,0 +1,3 @@
const actions = {};
export default actions;

3
src/store/user/getters.js

@ -0,0 +1,3 @@
const getters = {};
export default getters;

12
src/store/user/index.js

@ -0,0 +1,12 @@
import state from './state';
import getters from './getters';
import mutations from './mutations';
import actions from './actions';
export default {
namespaced: true,
state,
getters,
mutations,
actions,
};

3
src/store/user/mutations.js

@ -0,0 +1,3 @@
const mutations = {};
export default mutations;

3
src/store/user/state.js

@ -0,0 +1,3 @@
const state = {};
export default state;

29
src/utils/indexedDB.js

@ -0,0 +1,29 @@
import { name, version } from '@/config';
const install = Vue => {
Vue.prototype.$db.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
const request = window.indexedDB.open(name, version); // IDBRequest 对象
request.onerror = error => console.error('打开数据库失败', error);
request.onsuccess = event => {
Vue.prototype.$db.db = event.target.result;
};
request.onupgradeneeded = event => {
Vue.prototype.$db.db = event.target.result;
// 创建表
// user表
// projects项目表
// roles 角色表
// plan_tasks 定期任务
// fixed_tasks 固定全局任务
// variable_tasks 可变全局任务
// plugins 插件表
};
};
export default { install };

9
yarn.lock

@ -5995,13 +5995,6 @@ flush-write-stream@^1.0.0:
inherits "^2.0.3"
readable-stream "^2.3.6"
flyio@^0.6.2:
version "0.6.14"
resolved "https://registry.npm.taobao.org/flyio/download/flyio-0.6.14.tgz#c5d83eb7a9b4fc1c915a463d2ea6dfce755c2d6f"
integrity sha1-xdg+t6m0/ByRWkY9LqbfznVcLW8=
dependencies:
request "^2.85.0"
follow-redirects@^1.0.0:
version "1.14.1"
resolved "https://registry.nlark.com/follow-redirects/download/follow-redirects-1.14.1.tgz?cache=0&sync_timestamp=1620555234886&other_urls=https%3A%2F%2Fregistry.nlark.com%2Ffollow-redirects%2Fdownload%2Ffollow-redirects-1.14.1.tgz#d9114ded0a1cfdd334e164e6662ad02bfd91ff43"
@ -10951,7 +10944,7 @@ request-promise-native@^1.0.7:
stealthy-require "^1.1.1"
tough-cookie "^2.3.3"
request@^2.85.0, request@^2.88.0, request@^2.88.2:
request@^2.88.0, request@^2.88.2:
version "2.88.2"
resolved "https://registry.nlark.com/request/download/request-2.88.2.tgz?cache=0&sync_timestamp=1618847131102&other_urls=https%3A%2F%2Fregistry.nlark.com%2Frequest%2Fdownload%2Frequest-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3"
integrity sha1-1zyRhzHLWofaBH4gcjQUb2ZNErM=

Loading…
Cancel
Save