mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 13:17:46 +00:00
feat: 计算缓存文件夹大小
This commit is contained in:
parent
c3ae012d06
commit
ca4725a46e
4 changed files with 46 additions and 18 deletions
|
|
@ -9,6 +9,9 @@ import { TypedElectronStore } from './index'
|
||||||
import { APIs } from '../shared/CacheAPIs'
|
import { APIs } from '../shared/CacheAPIs'
|
||||||
import { YPMTray } from './tray'
|
import { YPMTray } from './tray'
|
||||||
import { Thumbar } from './windowsTaskbar'
|
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>(
|
const on = <T extends keyof IpcChannelsParams>(
|
||||||
channel: T,
|
channel: T,
|
||||||
|
|
@ -121,6 +124,20 @@ function initOtherIpcMain() {
|
||||||
cache.set(APIs.CoverColor, { id, color })
|
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环境)
|
* 导出tables到json文件,方便查看table大小(dev环境)
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,8 @@
|
||||||
"electron-log": "^4.4.6",
|
"electron-log": "^4.4.6",
|
||||||
"electron-store": "^8.0.1",
|
"electron-store": "^8.0.1",
|
||||||
"express": "^4.18.1",
|
"express": "^4.18.1",
|
||||||
"fast-folder-size": "^1.6.1"
|
"fast-folder-size": "^1.6.1",
|
||||||
|
"pretty-bytes": "^6.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@electron/universal": "1.2.1",
|
"@electron/universal": "1.2.1",
|
||||||
|
|
|
||||||
|
|
@ -3,24 +3,25 @@ import { RepeatMode } from './playerDataTypes'
|
||||||
import { Store } from '@/shared/store'
|
import { Store } from '@/shared/store'
|
||||||
|
|
||||||
export const enum IpcChannels {
|
export const enum IpcChannels {
|
||||||
ClearAPICache = 'clear-api-cache',
|
ClearAPICache = 'ClearAPICache',
|
||||||
Minimize = 'minimize',
|
Minimize = 'Minimize',
|
||||||
MaximizeOrUnmaximize = 'maximize-or-unmaximize',
|
MaximizeOrUnmaximize = 'MaximizeOrUnmaximize',
|
||||||
Close = 'close',
|
Close = 'Close',
|
||||||
IsMaximized = 'is-maximized',
|
IsMaximized = 'IsMaximized',
|
||||||
GetApiCacheSync = 'get-api-cache-sync',
|
GetApiCacheSync = 'GetApiCacheSync',
|
||||||
DevDbExportJson = 'dev-db-export-json',
|
DevDbExportJson = 'DevDbExportJson',
|
||||||
CacheCoverColor = 'cache-cover-color',
|
CacheCoverColor = 'CacheCoverColor',
|
||||||
SetTrayTooltip = 'set-tray-tooltip',
|
SetTrayTooltip = 'SetTrayTooltip',
|
||||||
// 准备三个播放相关channel, 为 mpris 预留接口
|
// 准备三个播放相关channel, 为 mpris 预留接口
|
||||||
Play = 'play',
|
Play = 'Play',
|
||||||
Pause = 'pause',
|
Pause = 'Pause',
|
||||||
PlayOrPause = 'play-or-pause',
|
PlayOrPause = 'PlayOrPause',
|
||||||
Next = 'next',
|
Next = 'Next',
|
||||||
Previous = 'previous',
|
Previous = 'Previous',
|
||||||
Like = 'like',
|
Like = 'Like',
|
||||||
Repeat = 'repeat',
|
Repeat = 'Repeat',
|
||||||
SyncSettings = 'sync-settings',
|
SyncSettings = 'SyncSettings',
|
||||||
|
GetAudioCacheSize = 'GetAudioCacheSize',
|
||||||
}
|
}
|
||||||
|
|
||||||
// ipcMain.on params
|
// ipcMain.on params
|
||||||
|
|
@ -54,6 +55,7 @@ export interface IpcChannelsParams {
|
||||||
mode: RepeatMode
|
mode: RepeatMode
|
||||||
}
|
}
|
||||||
[IpcChannels.SyncSettings]: Store['settings']
|
[IpcChannels.SyncSettings]: Store['settings']
|
||||||
|
[IpcChannels.GetAudioCacheSize]: void
|
||||||
}
|
}
|
||||||
|
|
||||||
// ipcRenderer.on params
|
// ipcRenderer.on params
|
||||||
|
|
@ -74,4 +76,5 @@ export interface IpcChannelsReturns {
|
||||||
[IpcChannels.Previous]: void
|
[IpcChannels.Previous]: void
|
||||||
[IpcChannels.Like]: void
|
[IpcChannels.Like]: void
|
||||||
[IpcChannels.Repeat]: RepeatMode
|
[IpcChannels.Repeat]: RepeatMode
|
||||||
|
[IpcChannels.GetAudioCacheSize]: void
|
||||||
}
|
}
|
||||||
|
|
|
||||||
7
pnpm-lock.yaml
generated
7
pnpm-lock.yaml
generated
|
|
@ -54,6 +54,7 @@ importers:
|
||||||
picocolors: ^1.0.0
|
picocolors: ^1.0.0
|
||||||
prettier: '*'
|
prettier: '*'
|
||||||
prettier-plugin-tailwindcss: ^0.1.10
|
prettier-plugin-tailwindcss: ^0.1.10
|
||||||
|
pretty-bytes: ^6.0.0
|
||||||
typescript: '*'
|
typescript: '*'
|
||||||
wait-on: ^6.0.1
|
wait-on: ^6.0.1
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
@ -69,6 +70,7 @@ importers:
|
||||||
express: 4.18.1
|
express: 4.18.1
|
||||||
fast-folder-size: 1.6.2
|
fast-folder-size: 1.6.2
|
||||||
NeteaseCloudMusicApi: 4.5.14
|
NeteaseCloudMusicApi: 4.5.14
|
||||||
|
pretty-bytes: 6.0.0
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@electron/universal': 1.2.1
|
'@electron/universal': 1.2.1
|
||||||
'@types/better-sqlite3': 7.5.0
|
'@types/better-sqlite3': 7.5.0
|
||||||
|
|
@ -6890,6 +6892,11 @@ packages:
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/pretty-bytes/6.0.0:
|
||||||
|
resolution: {integrity: sha512-6UqkYefdogmzqAZWzJ7laYeJnaXDy2/J+ZqiiMtS7t7OfpXWTlaeGMwX8U6EFvPV/YWWEKRkS8hKS4k60WHTOg==}
|
||||||
|
engines: {node: ^14.13.1 || >=16.0.0}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/pretty-format/27.5.1:
|
/pretty-format/27.5.1:
|
||||||
resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==}
|
resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==}
|
||||||
engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
|
engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue