mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-12 23:24:35 +01:00
fix dialog clicking
This commit is contained in:
@@ -23,3 +23,8 @@ pub fn rename(path: String, new_name: String) {
|
||||
pub fn dir_exists(path: &str) -> bool {
|
||||
return fs::metadata(&path).is_ok();
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn dir_is_empty(path: &str) -> bool {
|
||||
return fs::read_dir(&path).unwrap().count() == 0;
|
||||
}
|
||||
@@ -56,6 +56,7 @@ fn main() {
|
||||
unzip::unzip,
|
||||
file_helpers::rename,
|
||||
file_helpers::dir_exists,
|
||||
file_helpers::dir_is_empty,
|
||||
downloader::download_file,
|
||||
downloader::stop_download,
|
||||
lang::get_lang,
|
||||
|
||||
@@ -16,7 +16,14 @@ export default class MiniDialog extends React.Component<IProps, never> {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
document.addEventListener('mousedown', this.props.closeFn)
|
||||
document.addEventListener('mousedown', (evt) => {
|
||||
const tgt = evt.target as HTMLElement
|
||||
const isInside = tgt.closest('.MiniDialog') !== null
|
||||
|
||||
if (!isInside) {
|
||||
this.props.closeFn()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
@@ -149,6 +149,15 @@ export default class Downloads extends React.Component<IProps, IState> {
|
||||
async downloadResources() {
|
||||
const folder = await this.getGrasscutterFolder()
|
||||
this.props.downloadManager.addDownload(RESOURCES_DOWNLOAD, folder + '\\resources.zip', async () => {
|
||||
// Delete the existing folder if it exists
|
||||
if (await invoke('dir_exists', {
|
||||
path: folder + '\\resources'
|
||||
})) {
|
||||
await invoke('delete_dir', {
|
||||
path: folder + '\\resources'
|
||||
})
|
||||
}
|
||||
|
||||
await unzip(folder + '\\resources.zip', folder + '\\', () => {
|
||||
// Rename folder to resources
|
||||
invoke('rename', {
|
||||
|
||||
Reference in New Issue
Block a user