新增缓存清理功能
parent
4a510393ab
commit
7a334f0099
|
@ -1,6 +1,7 @@
|
|||
#### 新增
|
||||
|
||||
- 新增“我的收藏”本地播放列表
|
||||
- 新增缓存清理功能,可到**设置-其他**查看与清理软件缓存
|
||||
|
||||
#### 优化
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
require('./request')
|
||||
// require('./appName')
|
||||
require('./progressBar')
|
||||
require('./trafficLight')
|
||||
require('./musicMeta')
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@ app.on('second-instance', (event, argv, cwd) => {
|
|||
})
|
||||
|
||||
require('./events')
|
||||
require('./events/progressBar')
|
||||
require('./events/trafficLight')
|
||||
const autoUpdate = require('./utils/autoUpdate')
|
||||
const { isLinux, isMac } = require('../common/utils')
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ export const getRandom = (min, max) => Math.floor(Math.random() * (max - min)) +
|
|||
|
||||
export const sizeFormate = size => {
|
||||
// https://gist.github.com/thomseddon/3511330
|
||||
if (!size) return '0 b'
|
||||
let units = ['b', 'kB', 'MB', 'GB', 'TB']
|
||||
if (!size) return '0 B'
|
||||
let units = ['B', 'KB', 'MB', 'GB', 'TB']
|
||||
let number = Math.floor(Math.log(size) / Math.log(1024))
|
||||
return `${(size / Math.pow(1024, Math.floor(number))).toFixed(2)} ${units[number]}`
|
||||
}
|
||||
|
@ -337,3 +337,16 @@ export const asyncSetArray = (from, to, num = 100) => new Promise(resolve => {
|
|||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* 获取缓存大小
|
||||
* @param {*} win
|
||||
*/
|
||||
export const getCacheSize = () => remote.getCurrentWindow().webContents.session.getCacheSize()
|
||||
|
||||
/**
|
||||
* 清除缓存
|
||||
* @param {*} win
|
||||
*/
|
||||
export const clearCache = () => remote.getCurrentWindow().webContents.session.clearCache()
|
||||
|
|
|
@ -96,6 +96,15 @@ div.scroll(:class="$style.setting")
|
|||
div
|
||||
material-btn(:class="[$style.btn, $style.gapLeft]" min @click="handleImportAllData") 导入
|
||||
material-btn(:class="[$style.btn, $style.gapLeft]" min @click="handleExportAllData") 导出
|
||||
dt 其他
|
||||
dd
|
||||
h3 缓存大小(清理缓存后图片等资源将需要重新下载)
|
||||
div
|
||||
p
|
||||
| 软件已使用缓存大小:
|
||||
span.auto-hidden(title="当前已用缓存") {{cacheSize}}
|
||||
p
|
||||
material-btn(:class="$style.btn" min @click="clearCache") 清理缓存
|
||||
dt 软件更新
|
||||
dd
|
||||
p.small
|
||||
|
@ -153,7 +162,17 @@ div.scroll(:class="$style.setting")
|
|||
|
||||
<script>
|
||||
import { mapGetters, mapMutations } from 'vuex'
|
||||
import { openDirInExplorer, openSelectDir, openSaveDir, updateSetting, openUrl, clipboardWriteText } from '../utils'
|
||||
import {
|
||||
openDirInExplorer,
|
||||
openSelectDir,
|
||||
openSaveDir,
|
||||
updateSetting,
|
||||
openUrl,
|
||||
clipboardWriteText,
|
||||
getCacheSize,
|
||||
clearCache,
|
||||
sizeFormate,
|
||||
} from '../utils'
|
||||
import { rendererSend } from '../../common/icp'
|
||||
import fs from 'fs'
|
||||
|
||||
|
@ -261,6 +280,7 @@ export default {
|
|||
value: '歌名',
|
||||
},
|
||||
],
|
||||
cacheSize: '0 B',
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -289,6 +309,7 @@ export default {
|
|||
...mapMutations('list', ['setList']),
|
||||
init() {
|
||||
this.current_setting = JSON.parse(JSON.stringify(this.setting))
|
||||
this.getCacheSize()
|
||||
},
|
||||
handleChangeSavePath() {
|
||||
openSelectDir({
|
||||
|
@ -466,8 +487,15 @@ export default {
|
|||
handleProxyChange(key) {
|
||||
window.globalObj.proxy[key] = this.current_setting.network.proxy[key]
|
||||
},
|
||||
openRewardModal() {
|
||||
|
||||
getCacheSize() {
|
||||
getCacheSize().then(size => {
|
||||
this.cacheSize = sizeFormate(size)
|
||||
})
|
||||
},
|
||||
clearCache() {
|
||||
clearCache().then(() => {
|
||||
this.getCacheSize()
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue