mirror of
https://github.com/marktext/marktext.git
synced 2025-05-03 06:49:14 +08:00
Rearrange the buttons on the message box for unsaved files
This commit is contained in:
parent
aed36dbf32
commit
b0dd7cc8f8
@ -161,23 +161,23 @@ const handleResponseForSave = async (e, { id, filename, markdown, pathname, opti
|
|||||||
const showUnsavedFilesMessage = async (win, files) => {
|
const showUnsavedFilesMessage = async (win, files) => {
|
||||||
const { response } = await dialog.showMessageBox(win, {
|
const { response } = await dialog.showMessageBox(win, {
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
buttons: ['Save', 'Cancel', 'Don\'t save'],
|
buttons: ['Save', 'Don\'t save', 'Cancel'],
|
||||||
defaultId: 0,
|
defaultId: 0,
|
||||||
message: `Do you want to save the changes you made to ${files.length} ${files.length === 1 ? 'file' : 'files'}?\n\n${files.map(f => f.filename).join('\n')}`,
|
message: `Do you want to save the changes you made to ${files.length} ${files.length === 1 ? 'file' : 'files'}?\n\n${files.map(f => f.filename).join('\n')}`,
|
||||||
detail: 'Your changes will be lost if you don\'t save them.',
|
detail: 'Your changes will be lost if you don\'t save them.',
|
||||||
cancelId: 1,
|
cancelId: 2,
|
||||||
noLink: true
|
noLink: true
|
||||||
})
|
})
|
||||||
|
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case 2:
|
|
||||||
return { needSave: false }
|
|
||||||
case 0:
|
case 0:
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
resolve({ needSave: true })
|
resolve({ needSave: true })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
case 1:
|
||||||
|
return { needSave: false }
|
||||||
default:
|
default:
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user