From 0224735fb1cba46f6549adfa1f60ffd6b5041b72 Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期三, 21 五月 2025 16:13:45 +0800
Subject: [PATCH] feat: UI

---
 apps/h5/src/utils/storage/storage.ts |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/apps/h5/src/utils/storage/storage.ts b/apps/h5/src/utils/storage/storage.ts
new file mode 100644
index 0000000..50f5804
--- /dev/null
+++ b/apps/h5/src/utils/storage/storage.ts
@@ -0,0 +1,46 @@
+interface ProxyStorage {
+  getItem(key: string): any;
+  setItem(Key: string, value: string): void;
+  removeItem(key: string): void;
+  clear(): void;
+}
+
+//sessionStorage operate
+class sessionStorageProxy implements ProxyStorage {
+  protected storage: ProxyStorage;
+
+  constructor(storageModel: ProxyStorage) {
+    this.storage = storageModel;
+  }
+
+  // 瀛�
+  public setItem(key: string, value: any): void {
+    this.storage.setItem(key, JSON.stringify(value));
+  }
+
+  // 鍙�
+  public getItem<T = any>(key: string): null | T {
+    return JSON.parse(this.storage.getItem(key));
+  }
+
+  // 鍒�
+  public removeItem(key: string): void {
+    this.storage.removeItem(key);
+  }
+
+  // 娓呯┖
+  public clear(): void {
+    this.storage.clear();
+  }
+}
+
+//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