Vanessa 2022-06-11 11:58:53 +08:00
parent c03fba9ff7
commit f0f8ab895f

View File

@ -411,32 +411,38 @@
} }
} }
const exitSiYuan = () => { const exitSiYuan = () => {
fetch('/api/system/exit', { try {
method: 'POST', fetch('/api/system/exit', {
body: JSON.stringify({force: false}), method: 'POST',
}).then((response) => { body: JSON.stringify({force: false}),
return response.json() }).then((response) => {
}).then((response) => { return response.json()
if (response.code === 1) { }).then((response) => {
document.querySelector('#message').classList.add('b3-snackbar--show') if (response.code === 1) {
document.querySelector('#message').firstElementChild.textContent = response.msg document.querySelector('#message').classList.add('b3-snackbar--show')
const buttonElement = document.querySelector(`#message button`) document.querySelector('#message').firstElementChild.textContent = response.msg
if (buttonElement) { const buttonElement = document.querySelector(`#message button`)
buttonElement.addEventListener('click', () => { if (buttonElement) {
fetch('/api/system/exit', { buttonElement.addEventListener('click', () => {
method: 'POST', fetch('/api/system/exit', {
body: JSON.stringify({force: true}), method: 'POST',
}).then((response) => { body: JSON.stringify({force: true}),
return response.json() }).then((response) => {
}).then(() => { return response.json()
exitApp() }).then(() => {
exitApp()
})
}) })
}) }
} else {
exitApp()
} }
} else { }).catch(() =>{
exitApp() exitApp()
} })
}) } catch (e) {
exitApp()
}
} }
const inputElement = document.getElementById('authCode') const inputElement = document.getElementById('authCode')