mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
refactor: move CacheApi to cache.ts
This commit is contained in:
parent
f05cf68945
commit
b50d7c24e7
63
src/core/apis/cache.ts
Normal file
63
src/core/apis/cache.ts
Normal file
@ -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<string> = ['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);
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,4 @@
|
|||||||
import {
|
import {
|
||||||
CacheFileListItem,
|
|
||||||
CacheFileType,
|
|
||||||
ChatCacheListItemBasic,
|
|
||||||
ChatType,
|
ChatType,
|
||||||
ElementType,
|
ElementType,
|
||||||
IMAGE_HTTP_HOST,
|
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<string> = ['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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -5,4 +5,5 @@ export * from './msg';
|
|||||||
export * from './user';
|
export * from './user';
|
||||||
export * from './webapi';
|
export * from './webapi';
|
||||||
export * from './sign';
|
export * from './sign';
|
||||||
export * from './system';
|
export * from './system';
|
||||||
|
export * from './cache';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user