@snail-js/api 0.1.24 → 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 +11 -5
- package/dist/snail-api.umd.cjs +11 -5
- package/dist/typings/cache.type.d.ts +3 -1
- package/package.json +1 -1
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(
|
|
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(
|
|
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) => {
|
package/dist/snail-api.umd.cjs
CHANGED
|
@@ -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(
|
|
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(
|
|
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) => {
|
|
@@ -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:
|
|
5
|
+
data: {
|
|
6
|
+
data: T;
|
|
7
|
+
};
|
|
6
8
|
exp: number;
|
|
7
9
|
}
|
|
8
10
|
export type CacheGetData<T = any> = {
|