@snail-js/api 0.1.23 → 0.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/snail-api.js CHANGED
@@ -3467,7 +3467,7 @@ class MemoryCache {
3467
3467
  data: null
3468
3468
  });
3469
3469
  }
3470
- resolve({ error: null, data });
3470
+ resolve({ error: null, data: data.data });
3471
3471
  } catch (error) {
3472
3472
  console.error("[MemoryCache]获取缓存错误:", error);
3473
3473
  reject(error);
@@ -3545,7 +3545,7 @@ class LocalStorageCache {
3545
3545
  data: null
3546
3546
  });
3547
3547
  }
3548
- resolve({ error: null, data });
3548
+ resolve({ error: null, data: data.data });
3549
3549
  } catch (error) {
3550
3550
  reject({ error, data: null });
3551
3551
  }
@@ -3648,7 +3648,7 @@ class IndexDBCache {
3648
3648
  this.delete(key);
3649
3649
  return resolve({ error: new Error("缓存已过期"), data: null });
3650
3650
  }
3651
- resolve({ error: null, data: result.data });
3651
+ resolve({ error: null, data: result.data.data });
3652
3652
  };
3653
3653
  select.onerror = (event) => {
3654
3654
  reject({
@@ -3695,7 +3695,10 @@ class IndexDBCache {
3695
3695
  async clear() {
3696
3696
  return new Promise(async (resolve, reject) => {
3697
3697
  if (!this.db) await this.init();
3698
- const transaction = this.db.transaction(INDEXDB_OBJECT_STORE_NAME, "readwrite");
3698
+ const transaction = this.db.transaction(
3699
+ INDEXDB_OBJECT_STORE_NAME,
3700
+ "readwrite"
3701
+ );
3699
3702
  const request = transaction.objectStore(INDEXDB_OBJECT_STORE_NAME).clear();
3700
3703
  request.onsuccess = () => resolve(true);
3701
3704
  request.onerror = (event) => {
@@ -3707,7 +3710,10 @@ class IndexDBCache {
3707
3710
  async keys() {
3708
3711
  return new Promise(async (resolve, reject) => {
3709
3712
  if (!this.db) await this.init();
3710
- const transaction = this.db.transaction(INDEXDB_OBJECT_STORE_NAME, "readonly");
3713
+ const transaction = this.db.transaction(
3714
+ INDEXDB_OBJECT_STORE_NAME,
3715
+ "readonly"
3716
+ );
3711
3717
  const request = transaction.objectStore(INDEXDB_OBJECT_STORE_NAME).getAllKeys();
3712
3718
  request.onsuccess = () => resolve(request.result.map((key) => key.toString()));
3713
3719
  request.onerror = (event) => {
@@ -4120,7 +4126,7 @@ class SnailMethod {
4120
4126
  "response"
4121
4127
  );
4122
4128
  if (!isNoCache) {
4123
- !isSpecial && await this.setCacheData(serverName, response);
4129
+ !isSpecial && await this.setCacheData(serverName, response.data);
4124
4130
  }
4125
4131
  this.Response = response;
4126
4132
  this.applyHitSource(serverName);
@@ -3471,7 +3471,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3471
3471
  data: null
3472
3472
  });
3473
3473
  }
3474
- resolve({ error: null, data });
3474
+ resolve({ error: null, data: data.data });
3475
3475
  } catch (error) {
3476
3476
  console.error("[MemoryCache]获取缓存错误:", error);
3477
3477
  reject(error);
@@ -3549,7 +3549,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3549
3549
  data: null
3550
3550
  });
3551
3551
  }
3552
- resolve({ error: null, data });
3552
+ resolve({ error: null, data: data.data });
3553
3553
  } catch (error) {
3554
3554
  reject({ error, data: null });
3555
3555
  }
@@ -3652,7 +3652,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3652
3652
  this.delete(key);
3653
3653
  return resolve({ error: new Error("缓存已过期"), data: null });
3654
3654
  }
3655
- resolve({ error: null, data: result.data });
3655
+ resolve({ error: null, data: result.data.data });
3656
3656
  };
3657
3657
  select.onerror = (event) => {
3658
3658
  reject({
@@ -3699,7 +3699,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3699
3699
  async clear() {
3700
3700
  return new Promise(async (resolve, reject) => {
3701
3701
  if (!this.db) await this.init();
3702
- const transaction = this.db.transaction(INDEXDB_OBJECT_STORE_NAME, "readwrite");
3702
+ const transaction = this.db.transaction(
3703
+ INDEXDB_OBJECT_STORE_NAME,
3704
+ "readwrite"
3705
+ );
3703
3706
  const request = transaction.objectStore(INDEXDB_OBJECT_STORE_NAME).clear();
3704
3707
  request.onsuccess = () => resolve(true);
3705
3708
  request.onerror = (event) => {
@@ -3711,7 +3714,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3711
3714
  async keys() {
3712
3715
  return new Promise(async (resolve, reject) => {
3713
3716
  if (!this.db) await this.init();
3714
- const transaction = this.db.transaction(INDEXDB_OBJECT_STORE_NAME, "readonly");
3717
+ const transaction = this.db.transaction(
3718
+ INDEXDB_OBJECT_STORE_NAME,
3719
+ "readonly"
3720
+ );
3715
3721
  const request = transaction.objectStore(INDEXDB_OBJECT_STORE_NAME).getAllKeys();
3716
3722
  request.onsuccess = () => resolve(request.result.map((key) => key.toString()));
3717
3723
  request.onerror = (event) => {
@@ -4124,7 +4130,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4124
4130
  "response"
4125
4131
  );
4126
4132
  if (!isNoCache) {
4127
- !isSpecial && await this.setCacheData(serverName, response);
4133
+ !isSpecial && await this.setCacheData(serverName, response.data);
4128
4134
  }
4129
4135
  this.Response = response;
4130
4136
  this.applyHitSource(serverName);
@@ -2,7 +2,9 @@ import MemoryCache from "../cache/memoryCache";
2
2
  import LocalStorageCache from "../cache/localstorageCache";
3
3
  import IndexDBCache from "../cache/indexDBCache";
4
4
  export interface CacheSetData<T = any> {
5
- data: T;
5
+ data: {
6
+ data: T;
7
+ };
6
8
  exp: number;
7
9
  }
8
10
  export type CacheGetData<T = any> = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snail-js/api",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "description": "Http Request with Decorators Api, build on axios",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",