disable data downloader when gc folder not set

This commit is contained in:
SpikeHD 2022-05-07 21:51:49 -07:00
parent fecd82fe75
commit 2ded1f69ae
2 changed files with 14 additions and 6 deletions

View File

@ -111,20 +111,20 @@ async function openLatestDownload() {
async function openGameFolder() {
const config = await getCfg()
const folder = config.gameexe.match(/.*\\|.*\//g, '')
const folder = config.gameexe?.match(/.*\\|.*\//g, '')
debug.log('Opening game folder: ', folder)
if (folder.length > 0) openInExplorer(folder[0].replace(/\//g, '\\'))
if (folder?.length > 0) openInExplorer(folder[0].replace(/\//g, '\\'))
}
async function openGrasscutterFolder() {
const config = await getCfg()
const folder = config.serverFolder.match(/.*\\|.*\//g, '')
const folder = config.serverFolder?.match(/.*\\|.*\//g, '')
debug.log('Opening grasscutter folder: ', folder)
if (folder.length > 0) openInExplorer(folder[0].replace(/\//g, '\\'))
if (folder?.length > 0) openInExplorer(folder[0].replace(/\//g, '\\'))
}
// https://www.jimzhao.us/2015/09/javascript-detect-chinese-character.html

View File

@ -284,13 +284,21 @@ async function openDownloads() {
// Disable the resource download button if a serverFolder path is not set
if (!config.serverFolder) {
debug.log('Server folder not set, disabling resource download button')
debug.log('Server folder not set, disabling resource download button and data download button')
document.querySelector('#resourceInstall').disabled = true
document.querySelector('#resourceInstall').classList.add('disabled')
// Disable data installer
document.querySelector('#dataInstall').disabled = true
document.querySelector('#dataInstall').classList.add('disabled')
} else {
debug.log('Server folder is set, enabling resource download button')
debug.log('Server folder is set, enabling resource download button and data download button')
document.querySelector('#resourceInstall').disabled = false
document.querySelector('#resourceInstall').classList.remove('disabled')
// Enable data installer
document.querySelector('#dataInstall').disabled = false
document.querySelector('#dataInstall').classList.remove('disabled')
}
}