Skip to content

Commit

Permalink
Add webcache clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
NotThorny committed Sep 16, 2023
1 parent 695252c commit 7a41753
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src-tauri/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"un_elevated": "Run the game non-elevated (no admin)",
"redirect_more": "Also redirect other MHY games",
"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": {
"grasscutter_fullbuild": "Download Grasscutter All-in-One",
Expand Down
26 changes: 26 additions & 0 deletions src/ui/components/menu/Options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export default class Options extends React.Component<IProps, IState> {
this.setCustomBackground = this.setCustomBackground.bind(this)
this.toggleEncryption = this.toggleEncryption.bind(this)
this.removeRSA = this.removeRSA.bind(this)
this.deleteWebCache = this.deleteWebCache.bind(this)
this.addMigotoDelay = this.addMigotoDelay.bind(this)
this.toggleUnElevatedGame = this.toggleUnElevatedGame.bind(this)
}
Expand Down Expand Up @@ -333,6 +334,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) {
const changedVal = !(await getConfigOption(opt))

Expand Down Expand Up @@ -643,6 +656,19 @@ export default class Options extends React.Component<IProps, IState> {
</select>
</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>
)
}
Expand Down

0 comments on commit 7a41753

Please sign in to comment.