mirror of
https://gitee.com/dromara/electron-egg.git
synced 2026-06-13 11:14:37 +08:00
demo 优化
This commit is contained in:
@@ -12,8 +12,8 @@ class StorageService extends Service {
|
||||
|
||||
constructor (ctx) {
|
||||
super(ctx);
|
||||
this.systemDB = Storage.JsonDB.connection('system').db;
|
||||
this.demoDB = Storage.JsonDB.connection('demo').db;
|
||||
this.systemDB = Storage.JsonDB.connection('system');
|
||||
this.demoDB = Storage.JsonDB.connection('demo');
|
||||
this.systemDBKey = {
|
||||
cache: 'cache'
|
||||
};
|
||||
@@ -28,11 +28,11 @@ class StorageService extends Service {
|
||||
*/
|
||||
async addTestData(user) {
|
||||
const key = this.demoDBKey.test_data;
|
||||
if (!this.demoDB.has(key).value()) {
|
||||
this.demoDB.set(key, []).write();
|
||||
if (!this.demoDB.db.has(key).value()) {
|
||||
this.demoDB.db.set(key, []).write();
|
||||
}
|
||||
|
||||
const data = this.demoDB
|
||||
const data = this.demoDB.db
|
||||
.get(key)
|
||||
.push(user)
|
||||
.write();
|
||||
@@ -45,7 +45,7 @@ class StorageService extends Service {
|
||||
*/
|
||||
async delTestData(name = '') {
|
||||
const key = this.demoDBKey.test_data;
|
||||
const data = this.demoDB
|
||||
const data = this.demoDB.db
|
||||
.get(key)
|
||||
.remove({name: name})
|
||||
.write();
|
||||
@@ -58,7 +58,7 @@ class StorageService extends Service {
|
||||
*/
|
||||
async updateTestData(name= '', age = 0) {
|
||||
const key = this.demoDBKey.test_data;
|
||||
const data = this.demoDB
|
||||
const data = this.demoDB.db
|
||||
.get(key)
|
||||
.find({name: name}) // 修改找到的第一个数据,貌似无法批量修改 todo
|
||||
.assign({age: age})
|
||||
@@ -72,7 +72,7 @@ class StorageService extends Service {
|
||||
*/
|
||||
async getTestData(age = 0) {
|
||||
const key = this.demoDBKey.test_data;
|
||||
let data = this.demoDB
|
||||
let data = this.demoDB.db
|
||||
.get(key)
|
||||
//.find({age: age}) 查找单个
|
||||
.filter(function(o) {
|
||||
@@ -96,10 +96,10 @@ class StorageService extends Service {
|
||||
*/
|
||||
async getAllTestData() {
|
||||
const key = this.demoDBKey.test_data;
|
||||
if (!this.demoDB.has(key).value()) {
|
||||
this.demoDB.set(key, []).write();
|
||||
if (!this.demoDB.db.has(key).value()) {
|
||||
this.demoDB.db.set(key, []).write();
|
||||
}
|
||||
let data = this.demoDB
|
||||
let data = this.demoDB.db
|
||||
.get(key)
|
||||
.value();
|
||||
|
||||
|
||||
@@ -190,6 +190,7 @@ export default {
|
||||
self.userList = res.result;
|
||||
}
|
||||
if (res.all_list.length == 0) {
|
||||
self.all_list = ['空'];
|
||||
return;
|
||||
}
|
||||
self.all_list = res.all_list;
|
||||
|
||||
Reference in New Issue
Block a user