From b50d7c24e791ac1adb4d98a8dfde5c48a8b2ca54 Mon Sep 17 00:00:00 2001 From: "Wesley F. Young" Date: Sat, 31 Aug 2024 13:36:21 +0800 Subject: [PATCH] refactor: move CacheApi to cache.ts --- src/core/apis/cache.ts | 63 ++++++++++++++++++++++++++++++++++++++++++ src/core/apis/file.ts | 57 -------------------------------------- src/core/apis/index.ts | 3 +- 3 files changed, 65 insertions(+), 58 deletions(-) create mode 100644 src/core/apis/cache.ts diff --git a/src/core/apis/cache.ts b/src/core/apis/cache.ts new file mode 100644 index 00000000..64bdddd0 --- /dev/null +++ b/src/core/apis/cache.ts @@ -0,0 +1,63 @@ +import { + CacheFileListItem, + CacheFileType, + ChatCacheListItemBasic, + ChatType, + InstanceContext, + NapCatCore, +} from '@/core'; + +export class NTQQCacheApi { + context: InstanceContext; + core: NapCatCore; + + constructor(context: InstanceContext, core: NapCatCore) { + this.context = context; + this.core = core; + } + + async setCacheSilentScan(isSilent: boolean = true) { + return ''; + } + + getCacheSessionPathList() { + return ''; + } + + clearCache(cacheKeys: Array = ['tmp', 'hotUpdate']) { + // 参数未验证 + return this.context.session.getStorageCleanService().clearCacheDataByKeys(cacheKeys); + } + + addCacheScannedPaths(pathMap: object = {}) { + return this.context.session.getStorageCleanService().addCacheScanedPaths(pathMap); + } + + scanCache() { + //return (await this.context.session.getStorageCleanService().scanCache()).size; + } + + getHotUpdateCachePath() { + // 未实现 + return ''; + } + + getDesktopTmpPath() { + // 未实现 + return ''; + } + + getChatCacheList(type: ChatType, pageSize: number = 1000, pageIndex: number = 0) { + return this.context.session.getStorageCleanService().getChatCacheInfo(type, pageSize, 1, pageIndex); + } + + getFileCacheInfo(fileType: CacheFileType, pageSize: number = 1000, lastRecord?: CacheFileListItem) { + // const _lastRecord = lastRecord ? lastRecord : { fileType: fileType }; + // 需要五个参数 + // return napCatCore.session.getStorageCleanService().getFileCacheInfo(); + } + + async clearChatCache(chats: ChatCacheListItemBasic[] = [], fileKeys: string[] = []) { + return this.context.session.getStorageCleanService().clearChatCacheInfo(chats, fileKeys); + } +} diff --git a/src/core/apis/file.ts b/src/core/apis/file.ts index d265b145..4596c28f 100644 --- a/src/core/apis/file.ts +++ b/src/core/apis/file.ts @@ -1,7 +1,4 @@ import { - CacheFileListItem, - CacheFileType, - ChatCacheListItemBasic, ChatType, ElementType, IMAGE_HTTP_HOST, @@ -447,57 +444,3 @@ export class NTQQFileApi { } } -export class NTQQFileCacheApi { - context: InstanceContext; - core: NapCatCore; - - constructor(context: InstanceContext, core: NapCatCore) { - this.context = context; - this.core = core; - } - - async setCacheSilentScan(isSilent: boolean = true) { - return ''; - } - - getCacheSessionPathList() { - return ''; - } - - clearCache(cacheKeys: Array = ['tmp', 'hotUpdate']) { - // 参数未验证 - return this.context.session.getStorageCleanService().clearCacheDataByKeys(cacheKeys); - } - - addCacheScannedPaths(pathMap: object = {}) { - return this.context.session.getStorageCleanService().addCacheScanedPaths(pathMap); - } - - scanCache() { - //return (await this.context.session.getStorageCleanService().scanCache()).size; - } - - getHotUpdateCachePath() { - // 未实现 - return ''; - } - - getDesktopTmpPath() { - // 未实现 - return ''; - } - - getChatCacheList(type: ChatType, pageSize: number = 1000, pageIndex: number = 0) { - return this.context.session.getStorageCleanService().getChatCacheInfo(type, pageSize, 1, pageIndex); - } - - getFileCacheInfo(fileType: CacheFileType, pageSize: number = 1000, lastRecord?: CacheFileListItem) { - // const _lastRecord = lastRecord ? lastRecord : { fileType: fileType }; - // 需要五个参数 - // return napCatCore.session.getStorageCleanService().getFileCacheInfo(); - } - - async clearChatCache(chats: ChatCacheListItemBasic[] = [], fileKeys: string[] = []) { - return this.context.session.getStorageCleanService().clearChatCacheInfo(chats, fileKeys); - } -} diff --git a/src/core/apis/index.ts b/src/core/apis/index.ts index 4c0619e3..19b444dc 100644 --- a/src/core/apis/index.ts +++ b/src/core/apis/index.ts @@ -5,4 +5,5 @@ export * from './msg'; export * from './user'; export * from './webapi'; export * from './sign'; -export * from './system'; \ No newline at end of file +export * from './system'; +export * from './cache';