display chinese character alert

This commit is contained in:
SpikeHD 2022-05-03 21:14:02 -07:00
parent 73a3d173e8
commit a55db33f42
3 changed files with 8 additions and 4 deletions

View File

@ -79,5 +79,7 @@
"stableInstall": "Download",
"devInstall": "Download",
"updateNotifText": "A new update is available! Newest version: "
"updateNotifText": "A new update is available! Newest version: ",
"chineseCharacterAlert": "The file path set contains Chinese characters, this may cause problems!"
}

View File

@ -105,8 +105,8 @@ async function openGrasscutterFolder() {
// https://www.jimzhao.us/2015/09/javascript-detect-chinese-character.html
function hasChineseChars(str) {
let re1 = new RegExp(/^[\u4E00-\uFA29]*$/) //Chinese character range
let re2 = new RegExp(/^[\uE7C7-\uE7F3]*$/) //non Chinese character range
let re1 = new RegExp(/[\u4E00-\uFA29]/) //Chinese character range
let re2 = new RegExp(/[\uE7C7-\uE7F3]/) //non Chinese character range
str = str.replace(/\s/g, '')
if (!re1.test(str) || re2.test(str)) {

View File

@ -411,6 +411,7 @@ async function setGameExe() {
})
if (!gameExe[0]) return
if (hasChineseChars(gameExe[0])) displayAlert(localeObj.chineseCharacterAlert)
// Set the folder in our configuration
const config = await getCfg()
@ -434,6 +435,7 @@ async function setGrasscutterFolder() {
})
if (!folder[0]) return
if (hasChineseChars(folder[0])) displayAlert(localeObj.chineseCharacterAlert)
// Set the folder in our configuration
const config = await getCfg()