From 1910e9f27373b8b4da75f076762025ceb3419965 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期四, 12 六月 2025 15:40:50 +0800
Subject: [PATCH] fix: 暂时隐藏电信充值通道
---
apps/h5/src/utils/storage/storage.ts | 51 +++++++++++++++++++++++++++++----------------------
1 files changed, 29 insertions(+), 22 deletions(-)
diff --git a/apps/h5/src/utils/storage/storage.ts b/apps/h5/src/utils/storage/storage.ts
index f15fbd6..50f5804 100644
--- a/apps/h5/src/utils/storage/storage.ts
+++ b/apps/h5/src/utils/storage/storage.ts
@@ -1,39 +1,46 @@
-/* eslint-disable @typescript-eslint/no-explicit-any */
-import Taro from '@tarojs/taro';
+interface ProxyStorage {
+ getItem(key: string): any;
+ setItem(Key: string, value: string): void;
+ removeItem(key: string): void;
+ clear(): void;
+}
//sessionStorage operate
-class localStorageProxy {
- constructor() {}
+class sessionStorageProxy implements ProxyStorage {
+ protected storage: ProxyStorage;
+
+ constructor(storageModel: ProxyStorage) {
+ this.storage = storageModel;
+ }
// 瀛�
public setItem(key: string, value: any): void {
- return Taro.setStorageSync(key, JSON.stringify(value));
+ this.storage.setItem(key, JSON.stringify(value));
}
// 鍙�
- public getItem<T = any>(key: string): Nullable<T> {
- try {
- const value = Taro.getStorageSync(key);
- if (value) {
- // Do something with return value
- return JSON.parse(value);
- }
- return null;
- } catch (e) {
- // Do something when catch error
- return null;
- }
+ public getItem<T = any>(key: string): null | T {
+ return JSON.parse(this.storage.getItem(key));
}
// 鍒�
- public removeItem(key: string) {
- return Taro.removeStorageSync(key);
+ public removeItem(key: string): void {
+ this.storage.removeItem(key);
}
// 娓呯┖
- public clear() {
- return Taro.clearStorage();
+ public clear(): void {
+ this.storage.clear();
}
}
-export const storageLocal = new localStorageProxy();
+//localStorage operate
+class localStorageProxy extends sessionStorageProxy implements ProxyStorage {
+ constructor(localStorage: ProxyStorage) {
+ super(localStorage);
+ }
+}
+
+export const storageSession = new sessionStorageProxy(sessionStorage);
+
+export const storageLocal = new localStorageProxy(localStorage);
--
Gitblit v1.9.1