From 65fdfc6dd82f0bcf6c6826fe1ab645b309f6045c Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期四, 23 十月 2025 19:37:06 +0800
Subject: [PATCH] fix: bug
---
src/utils/storage/storage.ts | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/utils/storage/storage.ts b/src/utils/storage/storage.ts
index 50f5804..f60ec37 100644
--- a/src/utils/storage/storage.ts
+++ b/src/utils/storage/storage.ts
@@ -1,9 +1,13 @@
+import { loadEnv } from '@build/index';
+
interface ProxyStorage {
getItem(key: string): any;
setItem(Key: string, value: string): void;
removeItem(key: string): void;
clear(): void;
}
+
+const { VITE_PUBLIC_PATH } = loadEnv();
//sessionStorage operate
class sessionStorageProxy implements ProxyStorage {
@@ -13,19 +17,23 @@
this.storage = storageModel;
}
+ getKey(key: string): string {
+ return `${VITE_PUBLIC_PATH}_${key}`;
+ }
+
// 瀛�
public setItem(key: string, value: any): void {
- this.storage.setItem(key, JSON.stringify(value));
+ this.storage.setItem(this.getKey(key), JSON.stringify(value));
}
// 鍙�
public getItem<T = any>(key: string): null | T {
- return JSON.parse(this.storage.getItem(key));
+ return JSON.parse(this.storage.getItem(this.getKey(key)));
}
// 鍒�
public removeItem(key: string): void {
- this.storage.removeItem(key);
+ this.storage.removeItem(this.getKey(key));
}
// 娓呯┖
--
Gitblit v1.9.1