mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	初始化管理后台的 uniapp 版本
This commit is contained in:
		
							
								
								
									
										33
									
								
								yudao-ui-admin-uniapp/utils/storage.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								yudao-ui-admin-uniapp/utils/storage.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| import constant from './constant' | ||||
|  | ||||
| // 存储变量名 | ||||
| let storageKey = 'storage_data' | ||||
|  | ||||
| // 存储节点变量名 | ||||
| let storageNodeKeys = [constant.avatar, constant.name, constant.roles, constant.permissions] | ||||
|  | ||||
| // 存储的数据 | ||||
| let storageData = uni.getStorageSync(storageKey) || {} | ||||
|  | ||||
| const storage = { | ||||
|   set: function(key, value) { | ||||
|     if (storageNodeKeys.indexOf(key) != -1) { | ||||
|       let tmp = uni.getStorageSync(storageKey) | ||||
|       tmp = tmp ? tmp : {} | ||||
|       tmp[key] = value | ||||
|       uni.setStorageSync(storageKey, tmp) | ||||
|     } | ||||
|   }, | ||||
|   get: function(key) { | ||||
|     return storageData[key] || "" | ||||
|   }, | ||||
|   remove: function(key) { | ||||
|     delete storageData[key] | ||||
|     uni.setStorageSync(storageKey, storageData) | ||||
|   }, | ||||
|   clean: function() { | ||||
|     uni.removeStorageSync(storageKey) | ||||
|   } | ||||
| } | ||||
|  | ||||
| export default storage | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV