Jelajahi Sumber

demo 优化

gsx 3 tahun lalu
induk
melakukan
8e897a58db
2 mengubah file dengan 12 tambahan dan 11 penghapusan
  1. 11 11
      electron/service/storage.js
  2. 1 0
      frontend/src/views/base/db/Index.vue

+ 11 - 11
electron/service/storage.js

@@ -12,8 +12,8 @@ class StorageService extends Service {
 
 
   constructor (ctx) {
   constructor (ctx) {
     super(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 = {
     this.systemDBKey = {
       cache: 'cache'
       cache: 'cache'
     };
     };
@@ -28,11 +28,11 @@ class StorageService extends Service {
    */
    */
   async addTestData(user) {
   async addTestData(user) {
     const key = this.demoDBKey.test_data;
     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)
     .get(key)
     .push(user)
     .push(user)
     .write();
     .write();
@@ -45,7 +45,7 @@ class StorageService extends Service {
    */
    */
   async delTestData(name = '') {
   async delTestData(name = '') {
     const key = this.demoDBKey.test_data;
     const key = this.demoDBKey.test_data;
-    const data = this.demoDB
+    const data = this.demoDB.db
     .get(key)
     .get(key)
     .remove({name: name})
     .remove({name: name})
     .write();
     .write();
@@ -58,7 +58,7 @@ class StorageService extends Service {
    */
    */
   async updateTestData(name= '', age = 0) {
   async updateTestData(name= '', age = 0) {
     const key = this.demoDBKey.test_data;
     const key = this.demoDBKey.test_data;
-    const data = this.demoDB
+    const data = this.demoDB.db
     .get(key)
     .get(key)
     .find({name: name}) // 修改找到的第一个数据,貌似无法批量修改 todo
     .find({name: name}) // 修改找到的第一个数据,貌似无法批量修改 todo
     .assign({age: age})
     .assign({age: age})
@@ -72,7 +72,7 @@ class StorageService extends Service {
    */
    */
   async getTestData(age = 0) {
   async getTestData(age = 0) {
     const key = this.demoDBKey.test_data;
     const key = this.demoDBKey.test_data;
-    let data = this.demoDB
+    let data = this.demoDB.db
     .get(key)
     .get(key)
     //.find({age: age}) 查找单个
     //.find({age: age}) 查找单个
     .filter(function(o) {
     .filter(function(o) {
@@ -96,10 +96,10 @@ class StorageService extends Service {
    */
    */
     async getAllTestData() {
     async getAllTestData() {
       const key = this.demoDBKey.test_data;
       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)
       .get(key)
       .value();
       .value();
   
   

+ 1 - 0
frontend/src/views/base/db/Index.vue

@@ -190,6 +190,7 @@ export default {
           self.userList = res.result;
           self.userList = res.result;
         }
         }
         if (res.all_list.length == 0) {
         if (res.all_list.length == 0) {
+          self.all_list = ['空'];
           return;
           return;
         }
         }
         self.all_list = res.all_list;
         self.all_list = res.all_list;