HWDataManager.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // HWDataManager.h
  3. // VclustersGemini
  4. //
  5. // Created by 余衡武 on 2021/11/23.
  6. // Copyright © 2021 APPLE. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. /**数据持久化*/
  10. NS_ASSUME_NONNULL_BEGIN
  11. @interface HWDataManager : NSObject
  12. #pragma mark NSUserDefaults
  13. /**1、Bool*/
  14. + (BOOL)getBoolWithKey:(NSString* _Nonnull)key;
  15. + (void)setBoolWithKey:(NSString* _Nonnull)key value:(BOOL)value;
  16. /**2、NSInteger*/
  17. + (NSInteger)getIntegerWithKey:(NSString* _Nonnull)key;
  18. + (void)setIntegerWithKey:(NSString* _Nonnull)key value:(NSInteger)value;
  19. /**3、NSNumber*/
  20. + (NSNumber *)getNumberWithKey:(NSString* _Nonnull)key;
  21. + (void)setNumberWithKey:(NSString* _Nonnull)key value:(NSNumber *)value;
  22. /**4、NSString*/
  23. + (NSString* _Nonnull)getStringWithKey:(NSString* _Nonnull)key;
  24. + (void)setStringWithKey:(NSString* _Nonnull)key value:(NSString* _Nonnull)value;
  25. /**5、NSObject*/
  26. + (nullable id)getObjectWithKey:(NSString* _Nonnull)key;
  27. + (void)setObjectWithKey:(NSString* _Nonnull)key value:(nullable id)value;
  28. #pragma mark Plist
  29. /** Plist - plistFolder plist文件夹路径 */
  30. + (nullable id)readObjectFromPlistFolder:(NSString *)plistFolder;
  31. + (void)archiveObject:(nullable id)object toPlistFolder:(NSString *)plistFolder;
  32. /** Plist - plistPath plist文件路径 */
  33. + (nullable id)readObjectFromPlistPath:(NSString *)plistPath;
  34. + (void)archiveObject:(nullable id)object toPlistPath:(NSString *)plistPath;
  35. /**
  36. * @brief 获取设备辅助标签信息
  37. *
  38. * @param account 账号
  39. *
  40. * @param sn 设备唯一标识符
  41. *
  42. */
  43. + (NSString *)pathForDeviceDriftWithAccount:(NSString *)account sn:(NSString *)sn;
  44. #pragma mark 沙盒路径
  45. #define DocumentPath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
  46. #define CachesPath [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]
  47. /**截图保存路径*/
  48. #define kPath_ScreenShot [NSString stringWithFormat:@"%@/ScreenShot",CachesPath]
  49. /**浏览器当前窗口索引-ID*/
  50. #define BrowserWindowsCurrentID @"BrowserWindowsCurrentID"
  51. #pragma mark FMDB数据库 - Model
  52. /**浏览器窗口数据-数据库缓存表名*/
  53. #define DB_BrowserWindows_TableName @"DB_BrowserWindows_TableName"
  54. /**书签数据-数据库缓存表名*/
  55. #define DB_BookMark_TableName @"DB_BookMark_TableName"
  56. /**浏览器历史数据-数据库缓存表名*/
  57. #define DB_Bookmark_History_TableName @"DB_Bookmark_History_TableName"
  58. #pragma mark 自定义方法
  59. + (instancetype)shareInstance;
  60. /**保存截图保存路径*/
  61. + (NSString *)writeScreenShotImageToLocal:(UIImage *)image withName:(NSString *)fileName;
  62. /** 读取指定路径下的文件or文件夹 */
  63. + (NSArray *)getFileOrFolderAtPath:(NSString *)basePath;
  64. /**
  65. * @brief 获取设备缩略图路劲
  66. *
  67. * @param account 账号
  68. * *
  69. * @param deviceId 设备唯一标识符
  70. *
  71. */
  72. + (NSString *)pathForDevicePhotoWithAccount:(NSString *)account deviceId:(NSString *)deviceId;
  73. #pragma mark FileManager - File
  74. /**
  75. * 文件路径:DocumentPath/account/fileFolder
  76. * account 路径不需要拼接账号时 传@""
  77. */
  78. + (NSString *)documentPathForAccount:(NSString *)account fileFolder:(NSString *)fileFolder;
  79. /**
  80. * 文件路径:CachesPath/account/fileFolder
  81. * account 路径不需要拼接账号时 传@""
  82. */
  83. + (NSString *)cachesPathForAccount:(NSString *)account fileFolder:(NSString *)fileFolder;
  84. @end
  85. NS_ASSUME_NONNULL_END