get/set/clear registry functions

This commit is contained in:
SpikeHD 2022-04-30 00:07:43 -07:00
parent 860f88daf5
commit 07c331051b
2 changed files with 27 additions and 0 deletions

1
.gitignore vendored
View File

@ -4,6 +4,7 @@ bin/
dist/
ext/
temp/
tools/
resources/js/neutralino.js
resources/bg/official

View File

@ -103,6 +103,32 @@ async function openGrasscutterFolder() {
openInExplorer(folder)
}
async function getRegistryLoginDetails() {
const results = await Neutralino.os.execCommand('.\\tools\\mtools.exe show')
const out = results.stdErr
if (!out) return {}
const parsed = JSON.parse(out)
return parsed.data
}
async function clearRegistryLoginDetails() {
createCmdWindow(`.\\tools\\mtools.exe set -a "" -u "" -t "" -d ""`)
}
async function setRegistryLoginDetails(tokenOrAccount, loginUid) {
const accList = await getRegistryLoginDetails()
const cur = accList.find(a => a.is_login)
// Required fields: uid, token, account, deviceId
const { token, deviceId } = cur
createCmdWindow(`.\\tools\\mtools.exe set -a ${tokenOrAccount} -u ${loginUid} -t ${token} -d ${deviceId}`)
}
/**
* Minimize the window
*/