Browse Source

feat: indexedDB

pull/1/head
wally 4 years ago
parent
commit
687394e744
  1. 11
      .hbuilderx/launch.json
  2. 15
      CHANGELOG.md
  3. 30
      src/utils/indexedDB.js

11
.hbuilderx/launch.json

@ -0,0 +1,11 @@
{ // launch.json configurations app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
// launchtypelocalremote, localremote
"version": "0.0",
"configurations": [{
"type": "uniCloud",
"default": {
"launchtype": "local"
}
}
]
}

15
CHANGELOG.md

@ -1,4 +1,11 @@
# [0.1.0](https://gitee.com/mongos/uni-cli-template/compare/v1.1.1...v0.1.0) (2021-07-16)
# [0.1.0](https://gitee.com/mongos/uni-cli-template/compare/v1.1.1...v0.1.0) (2021-07-19)
### 🌟 新功能
范围|描述|commitId
--|--|--
- | db store | [6414c4f](https://gitee.com/mongos/uni-cli-template/commits/6414c4f)
pinch | alloy finger实现图片的pinch放大缩小 | [de01343](https://gitee.com/mongos/uni-cli-template/commits/de01343)
### 🐛 Bug 修复
范围|描述|commitId
@ -17,12 +24,6 @@
- | !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
--|--|--

30
src/utils/indexedDB.js

@ -1,5 +1,21 @@
import { name, version } from '@/config';
// 创建表
const createTable = (Vue, db) => {
// projects项目表
Vue.prototype.$db.projects = db.createObjectStore('projects', { keyPath: 'id' });
// roles 角色表
Vue.prototype.$db.roles = db.createObjectStore('roles', { keyPath: 'id' });
// plan_tasks 定期任务
Vue.prototype.$db.plan_tasks = db.createObjectStore('plan_tasks', { keyPath: 'id' });
// fixed_tasks 固定全局任务
Vue.prototype.$db.fixed_tasks = db.createObjectStore('fixed_tasks', { keyPath: 'id' });
// variable_tasks 可变全局任务
Vue.prototype.$db.variable_tasks = db.createObjectStore('variable_tasks', { keyPath: 'id' });
// plugins 插件表
Vue.prototype.$db.plugins = db.createObjectStore('plugins', { keyPath: 'id' });
};
const install = Vue => {
Vue.prototype.$db.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
const request = window.indexedDB.open(name, version); // IDBRequest 对象
@ -10,19 +26,7 @@ const install = Vue => {
request.onupgradeneeded = event => {
Vue.prototype.$db.db = event.target.result;
// 创建表
// user表
// projects项目表
// roles 角色表
// plan_tasks 定期任务
// fixed_tasks 固定全局任务
// variable_tasks 可变全局任务
// plugins 插件表
createTable(Vue, Vue.prototype.$db.db);
};
};

Loading…
Cancel
Save