Skip to content

Commit

Permalink
Fix user data path
Browse files Browse the repository at this point in the history
  • Loading branch information
gavingaozhangmin committed Aug 2, 2023
1 parent cbe46ad commit 1378cfa
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 61,719 deletions.
6 changes: 3 additions & 3 deletions electron/main/core/ipcEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ export default class ipcEvent {
app.setLoginItemSettings(settings)
} else if (data.cmd && Object.hasOwn(data.cmd, 'appUserDataPath')) {
const userDataPath = data.cmd.appUserDataPath
const localVersion = getResourcesPath('userdir.config')
writeFileSync(localVersion, userDataPath, 'utf-8')
const userCachePath = getResourcesPath('userdir.config')
writeFileSync(userCachePath, userDataPath, 'utf-8')
} else {
event.sender.send('ElectronToWeb', 'mainsenddata')
}
Expand Down Expand Up @@ -429,4 +429,4 @@ export default class ipcEvent {
})
})
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"consola": "^3.1.0",
"crypto-js": "^4.1.1",
"dayjs": "^1.11.7",
"dexie": "^3.2.3",
"dexie": "^3.2.4",
"digest-fetch": "^3.0.4",
"dom-to-image": "^2.6.0",
"electron": "^21.4.4",
Expand Down
5 changes: 4 additions & 1 deletion src/setting/settingstore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ function _loadSetting(val: any) {


setting.downSavePath = defaultString(val.downSavePath, '')
setting.appUserDataPath = defaultString(val.appUserDataPath, getUserData())
setting.appUserDataPath = defaultString(val.appUserDataPath, '')
setting.downSavePathDefault = defaultBool(val.downSavePathDefault, true)
setting.downSavePathFull = defaultBool(val.downSavePathFull, true)
setting.downSaveBreakWeiGui = defaultBool(val.downSaveBreakWeiGui, true)
Expand Down Expand Up @@ -341,6 +341,9 @@ function LoadSetting() {
const val = JSON.parse(settingstr)
_loadSetting(val)
useAppStore().toggleTheme(setting.uiTheme)
if (setting.appUserDataPath !== '') {
window.WebToElectron({ cmd: { appUserDataPath: setting.appUserDataPath} })
}
} else {
SaveSetting()
}
Expand Down
9 changes: 5 additions & 4 deletions src/utils/appcache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ export default class AppCache {
const userData = getUserData()
if (!userData) return
const dirSize = await AppCache.LoadDirSize(userData)
if (dirSize > 800 * 1024 * 1024) message.warning('缓存文件夹体积较大,该去 设置 里清理了')

useSettingStore().debugCacheSize = humanSize(dirSize)
useSettingStore().debugCacheSize = humanSize(dirSize)
if (dirSize > 500 * 1024 * 1024) {
message.warning('缓存文件夹体积较大,该去设置点击"清理缓存", 否则会影响启动速度')
}
}


static async aClearCache(delby: string): Promise<void> {
const dir = getUserData()
// await AppCache.DeleteDir(path.join(dir, 'Cache'))
if (delby == 'all') {
// window.WebClearCache({ cache: true })
if (window.WebClearCache)
window.WebClearCache({
storages: ['appcache', 'cookies', 'filesystem', 'shadercache', 'serviceworkers', 'cachestorage', 'indexdb', 'localstorage', 'websql'],
Expand All @@ -81,6 +81,7 @@ export default class AppCache {
} else if (delby == 'db') {
await AppCache.DeleteDir(path.join(dir, 'databases')).catch(() => {})
}
await AppCache.DeleteDir(path.join(dir, 'Cache'))
await AppCache.DeleteDir(path.join(dir, 'Code Cache', 'js')).catch(() => {})
await AppCache.DeleteDir(path.join(dir, 'Code Cache', 'wasm')).catch(() => {})

Expand Down
Loading

0 comments on commit 1378cfa

Please sign in to comment.