Add webcache clearing

This commit is contained in:
Thoronium
2023-09-16 17:09:49 -06:00
parent 96bf4ef3fe
commit 73a9e18712
2 changed files with 28 additions and 1 deletions

View File

@@ -35,7 +35,8 @@
"un_elevated": "Run the game non-elevated (no admin)", "un_elevated": "Run the game non-elevated (no admin)",
"redirect_more": "Also redirect other MHY games", "redirect_more": "Also redirect other MHY games",
"check_aagl": "For more options, check the other launcher", "check_aagl": "For more options, check the other launcher",
"grasscutter_elevation": "Method of running GC on restricted ports" "grasscutter_elevation": "Method of running GC on restricted ports",
"web_cache": "Delete webCaches folder"
}, },
"downloads": { "downloads": {
"grasscutter_fullbuild": "Download Grasscutter All-in-One", "grasscutter_fullbuild": "Download Grasscutter All-in-One",

View File

@@ -103,6 +103,7 @@ export default class Options extends React.Component<IProps, IState> {
this.setCustomBackground = this.setCustomBackground.bind(this) this.setCustomBackground = this.setCustomBackground.bind(this)
this.toggleEncryption = this.toggleEncryption.bind(this) this.toggleEncryption = this.toggleEncryption.bind(this)
this.removeRSA = this.removeRSA.bind(this) this.removeRSA = this.removeRSA.bind(this)
this.deleteWebCache = this.deleteWebCache.bind(this)
this.addMigotoDelay = this.addMigotoDelay.bind(this) this.addMigotoDelay = this.addMigotoDelay.bind(this)
this.toggleUnElevatedGame = this.toggleUnElevatedGame.bind(this) this.toggleUnElevatedGame = this.toggleUnElevatedGame.bind(this)
} }
@@ -336,6 +337,18 @@ export default class Options extends React.Component<IProps, IState> {
}) })
} }
async deleteWebCache() {
alert('Cultivation may freeze for a moment while this occurs!')
// Get webCaches folder path
const pathArr = this.state.game_install_path.replace(/\\/g, '/').split('/')
pathArr.pop()
const path = pathArr.join('/') + '/GenshinImpact_Data/webCaches'
// Delete the folder
await invoke('dir_delete', { path: path })
}
async toggleOption(opt: keyof Configuration) { async toggleOption(opt: keyof Configuration) {
const changedVal = !(await getConfigOption(opt)) const changedVal = !(await getConfigOption(opt))
@@ -646,6 +659,19 @@ export default class Options extends React.Component<IProps, IState> {
</select> </select>
</div> </div>
</div> </div>
<Divider />
<div className="OptionSection" id="menuOptionsContainerAdvanced">
<div className="OptionLabel" id="menuOptionsLabelWebCache">
<Tr text="options.web_cache" />
</div>
<div className="OptionValue" id="menuOptionsButtondeleteWebcache">
<BigButton onClick={this.deleteWebCache} id="deleteWebcache">
<Tr text="components.delete" />
</BigButton>
</div>
</div>
</Menu> </Menu>
) )
} }