feat: 计算缓存文件夹大小

This commit is contained in:
qier222 2022-05-13 18:18:28 +08:00
parent c3ae012d06
commit ca4725a46e
No known key found for this signature in database
GPG key ID: 9C85007ED905F14D
4 changed files with 46 additions and 18 deletions

View file

@ -9,6 +9,9 @@ import { TypedElectronStore } from './index'
import { APIs } from '../shared/CacheAPIs'
import { YPMTray } from './tray'
import { Thumbar } from './windowsTaskbar'
import fastFolderSize from 'fast-folder-size'
import path from 'path'
import prettyBytes from 'pretty-bytes'
const on = <T extends keyof IpcChannelsParams>(
channel: T,
@ -121,6 +124,20 @@ function initOtherIpcMain() {
cache.set(APIs.CoverColor, { id, color })
})
/**
*
*/
on(IpcChannels.GetAudioCacheSize, event => {
fastFolderSize(
path.join(app.getPath('userData'), './audio_cache'),
(error, bytes) => {
if (error) throw error
event.returnValue = prettyBytes(bytes ?? 0)
}
)
})
/**
* tables到json文件便table大小dev环境
*/