From d3fd4b0ab851bab89c30c199e27245f7f45f1c0e Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期六, 08 十一月 2025 08:01:12 +0800
Subject: [PATCH] feat:实现了微信上传图片
---
app/utils/storage.js | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/app/utils/storage.js b/app/utils/storage.js
index 4c5fdec..8081920 100644
--- a/app/utils/storage.js
+++ b/app/utils/storage.js
@@ -26,6 +26,58 @@
},
clean: function() {
uni.removeStorageSync(storageKey)
+ },
+ // 鏂板锛氳幏鍙栧瓨鍌ㄤ俊鎭�
+ getStorageInfo: function() {
+ try {
+ const info = uni.getStorageInfoSync()
+ console.log('馃捑 瀛樺偍淇℃伅:', {
+ keys: info.keys,
+ currentSize: info.currentSize,
+ limitSize: info.limitSize,
+ usage: ((info.currentSize / info.limitSize) * 100).toFixed(2) + '%'
+ })
+ return info
+ } catch (e) {
+ console.error('鑾峰彇瀛樺偍淇℃伅澶辫触:', e)
+ return null
+ }
+ },
+ // 鏂板锛氭竻鐞嗘墍鏈夊瓨鍌紙鎱庣敤锛�
+ clearAll: function() {
+ try {
+ uni.clearStorageSync()
+ console.log('鉁� 娓呯悊鎵�鏈夊瓨鍌ㄦ垚鍔�')
+ } catch (e) {
+ console.error('娓呯悊瀛樺偍澶辫触:', e)
+ }
+ },
+ // 鏂板锛氭鏌ュ苟娓呯悊杩囨湡鏁版嵁
+ checkAndClean: function() {
+ try {
+ const info = uni.getStorageInfoSync()
+ const usagePercent = (info.currentSize / info.limitSize) * 100
+
+ // 濡傛灉浣跨敤瓒呰繃 80%锛屾彁绀虹敤鎴�
+ if (usagePercent > 80) {
+ console.warn('鈿狅笍 瀛樺偍绌洪棿浣跨敤瓒呰繃 80%:', usagePercent.toFixed(2) + '%')
+
+ // 鑷姩娓呯悊闈炲繀瑕佺殑缂撳瓨
+ const keysToKeep = [storageKey, 'token', 'uni-id-pages-userInfo']
+ info.keys.forEach(key => {
+ if (!keysToKeep.includes(key)) {
+ try {
+ uni.removeStorageSync(key)
+ console.log('馃棏锔� 娓呯悊缂撳瓨:', key)
+ } catch (e) {
+ console.error('娓呯悊澶辫触:', key, e)
+ }
+ }
+ })
+ }
+ } catch (e) {
+ console.error('妫�鏌ュ瓨鍌ㄥけ璐�:', e)
+ }
}
}
--
Gitblit v1.9.1