Fix ElMessageBox callback

This commit is contained in:
Natsumi
2025-09-12 11:43:10 +12:00
parent 2bd916d408
commit 81bc54b1b8
5 changed files with 146 additions and 162 deletions
+54 -57
View File
@@ -660,30 +660,29 @@ export const useAuthStore = defineStore('Auth', () => {
inputPlaceholder: t('prompt.totp.input_placeholder'), inputPlaceholder: t('prompt.totp.input_placeholder'),
inputPattern: /^[0-9]{6}$/, inputPattern: /^[0-9]{6}$/,
inputErrorMessage: t('prompt.totp.input_error'), inputErrorMessage: t('prompt.totp.input_error'),
callback: (action, instance) => {
if (action === 'confirm') {
authRequest
.verifyTOTP({
code: instance.inputValue.trim()
})
.catch((err) => {
clearCookiesTryLogin();
throw err;
})
.then((args) => {
userStore.getCurrentUser();
return args;
});
} else if (action === 'cancel') {
promptOTP();
}
},
beforeClose: (action, instance, done) => { beforeClose: (action, instance, done) => {
state.twoFactorAuthDialogVisible = false; state.twoFactorAuthDialogVisible = false;
done(); done();
} }
} }
); ).then(({ value, action }) => {
if (action === 'confirm') {
authRequest
.verifyTOTP({
code: value.trim()
})
.catch((err) => {
clearCookiesTryLogin();
throw err;
})
.then((args) => {
userStore.getCurrentUser();
return args;
});
} else if (action === 'cancel') {
promptOTP();
}
});
} }
function promptOTP() { function promptOTP() {
@@ -701,30 +700,29 @@ export const useAuthStore = defineStore('Auth', () => {
inputPlaceholder: t('prompt.otp.input_placeholder'), inputPlaceholder: t('prompt.otp.input_placeholder'),
inputPattern: /^[a-z0-9]{4}-[a-z0-9]{4}$/, inputPattern: /^[a-z0-9]{4}-[a-z0-9]{4}$/,
inputErrorMessage: t('prompt.otp.input_error'), inputErrorMessage: t('prompt.otp.input_error'),
callback: (action, instance) => {
if (action === 'confirm') {
authRequest
.verifyOTP({
code: instance.inputValue.trim()
})
.catch((err) => {
clearCookiesTryLogin();
throw err;
})
.then((args) => {
userStore.getCurrentUser();
return args;
});
} else if (action === 'cancel') {
promptTOTP();
}
},
beforeClose: (action, instance, done) => { beforeClose: (action, instance, done) => {
state.twoFactorAuthDialogVisible = false; state.twoFactorAuthDialogVisible = false;
done(); done();
} }
} }
); ).then(({ value, action }) => {
if (action === 'confirm') {
authRequest
.verifyOTP({
code: value.trim()
})
.catch((err) => {
clearCookiesTryLogin();
throw err;
})
.then((args) => {
userStore.getCurrentUser();
return args;
});
} else if (action === 'cancel') {
promptTOTP();
}
});
} }
function promptEmailOTP() { function promptEmailOTP() {
@@ -743,30 +741,29 @@ export const useAuthStore = defineStore('Auth', () => {
inputPlaceholder: t('prompt.email_otp.input_placeholder'), inputPlaceholder: t('prompt.email_otp.input_placeholder'),
inputPattern: /^[0-9]{6}$/, inputPattern: /^[0-9]{6}$/,
inputErrorMessage: t('prompt.email_otp.input_error'), inputErrorMessage: t('prompt.email_otp.input_error'),
callback: (action, instance) => {
if (action === 'confirm') {
authRequest
.verifyEmailOTP({
code: instance.inputValue.trim()
})
.catch((err) => {
promptEmailOTP();
throw err;
})
.then((args) => {
userStore.getCurrentUser();
return args;
});
} else if (action === 'cancel') {
resendEmail2fa();
}
},
beforeClose: (action, instance, done) => { beforeClose: (action, instance, done) => {
state.twoFactorAuthDialogVisible = false; state.twoFactorAuthDialogVisible = false;
done(); done();
} }
} }
); ).then(({ value, action }) => {
if (action === 'confirm') {
authRequest
.verifyEmailOTP({
code: value.trim()
})
.catch((err) => {
promptEmailOTP();
throw err;
})
.then((args) => {
userStore.getCurrentUser();
return args;
});
} else if (action === 'cancel') {
resendEmail2fa();
}
});
} }
/** /**
+4 -5
View File
@@ -1410,11 +1410,10 @@ export const useGameLogStore = defineStore('GameLog', () => {
ElMessageBox.confirm('Continue? Disable GameLog', 'Confirm', { ElMessageBox.confirm('Continue? Disable GameLog', 'Confirm', {
confirmButtonText: 'Confirm', confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel', cancelButtonText: 'Cancel',
type: 'info', type: 'info'
callback: async (action) => { }).then(({ action }) => {
if (action === 'confirm') { if (action === 'confirm') {
advancedSettingsStore.setGameLogDisabled(); advancedSettingsStore.setGameLogDisabled();
}
} }
}); });
} else { } else {
+23 -29
View File
@@ -564,25 +564,22 @@ export const usePhotonStore = defineStore('Photon', () => {
distinguishCancelAndClose: true, distinguishCancelAndClose: true,
confirmButtonText: t('prompt.overlay_message_timeout.ok'), confirmButtonText: t('prompt.overlay_message_timeout.ok'),
cancelButtonText: t('prompt.overlay_message_timeout.cancel'), cancelButtonText: t('prompt.overlay_message_timeout.cancel'),
inputValue: state.photonOverlayMessageTimeout / 1000, inputValue: (
state.photonOverlayMessageTimeout / 1000
).toString(),
inputPattern: /\d+$/, inputPattern: /\d+$/,
inputErrorMessage: t( inputErrorMessage: t(
'prompt.overlay_message_timeout.input_error' 'prompt.overlay_message_timeout.input_error'
), )
callback: async (action, instance) => {
if (
action === 'confirm' &&
instance.inputValue &&
!isNaN(instance.inputValue)
) {
state.photonOverlayMessageTimeout = Math.trunc(
Number(instance.inputValue) * 1000
);
vrStore.updateVRConfigVars();
}
}
} }
); ).then(({ value, action }) => {
if (action === 'confirm' && value && !isNaN(Number(value))) {
state.photonOverlayMessageTimeout = Math.trunc(
Number(value) * 1000
);
vrStore.updateVRConfigVars();
}
});
} }
function promptPhotonLobbyTimeoutThreshold() { function promptPhotonLobbyTimeoutThreshold() {
@@ -593,22 +590,19 @@ export const usePhotonStore = defineStore('Photon', () => {
distinguishCancelAndClose: true, distinguishCancelAndClose: true,
confirmButtonText: t('prompt.photon_lobby_timeout.ok'), confirmButtonText: t('prompt.photon_lobby_timeout.ok'),
cancelButtonText: t('prompt.photon_lobby_timeout.cancel'), cancelButtonText: t('prompt.photon_lobby_timeout.cancel'),
inputValue: state.photonLobbyTimeoutThreshold / 1000, inputValue: (
state.photonLobbyTimeoutThreshold / 1000
).toString(),
inputPattern: /\d+$/, inputPattern: /\d+$/,
inputErrorMessage: t('prompt.photon_lobby_timeout.input_error'), inputErrorMessage: t('prompt.photon_lobby_timeout.input_error')
callback: async (action, instance) => {
if (
action === 'confirm' &&
instance.inputValue &&
!isNaN(instance.inputValue)
) {
state.photonLobbyTimeoutThreshold = Math.trunc(
Number(instance.inputValue) * 1000
);
}
}
} }
); ).then(({ value, action }) => {
if (action === 'confirm' && value && !isNaN(Number(value))) {
state.photonLobbyTimeoutThreshold = Math.trunc(
Number(value) * 1000
);
}
});
} }
function startLobbyWatcherLoop() { function startLobbyWatcherLoop() {
+11 -14
View File
@@ -355,22 +355,19 @@ export const useSearchStore = defineStore('Search', () => {
confirmButtonText: t('prompt.direct_access_omni.ok'), confirmButtonText: t('prompt.direct_access_omni.ok'),
cancelButtonText: t('prompt.direct_access_omni.cancel'), cancelButtonText: t('prompt.direct_access_omni.cancel'),
inputPattern: /\S+/, inputPattern: /\S+/,
inputErrorMessage: t('prompt.direct_access_omni.input_error'), inputErrorMessage: t('prompt.direct_access_omni.input_error')
callback: (action, instance) => { }
if (action === 'confirm' && instance.inputValue) { ).then(({ value, action }) => {
const input = instance.inputValue.trim(); if (action === 'confirm' && value) {
if (!directAccessParse(input)) { const input = value.trim();
ElMessage({ if (!directAccessParse(input)) {
message: t( ElMessage({
'prompt.direct_access_omni.message.error' message: t('prompt.direct_access_omni.message.error'),
), type: 'error'
type: 'error' });
});
}
}
} }
} }
); });
} }
function showGroupDialogShortCode(shortCode) { function showGroupDialogShortCode(shortCode) {
+54 -57
View File
@@ -530,33 +530,32 @@ export const useAdvancedSettingsStore = defineStore('AdvancedSettings', () => {
'view.settings.advanced.advanced.save_instance_prints_to_file.crop_convert_old_cancel' 'view.settings.advanced.advanced.save_instance_prints_to_file.crop_convert_old_cancel'
), ),
type: 'info', type: 'info',
showInput: false, showInput: false
callback: async (action) => { }
if (action === 'confirm') { ).then(async ({ action }) => {
const msgBox = ElMessage({ if (action === 'confirm') {
message: 'Batch print cropping in progress...', const msgBox = ElMessage({
type: 'warning', message: 'Batch print cropping in progress...',
duration: 0 type: 'warning',
}); duration: 0
try { });
await AppApi.CropAllPrints(state.ugcFolderPath); try {
ElMessage({ await AppApi.CropAllPrints(state.ugcFolderPath);
message: 'Batch print cropping complete', ElMessage({
type: 'success' message: 'Batch print cropping complete',
}); type: 'success'
} catch (err) { });
console.error(err); } catch (err) {
ElMessage({ console.error(err);
message: `Batch print cropping failed: ${err}`, ElMessage({
type: 'error' message: `Batch print cropping failed: ${err}`,
}); type: 'error'
} finally { });
msgBox.close(); } finally {
} msgBox.close();
}
} }
} }
); });
} }
function askDeleteAllScreenshotMetadata() { function askDeleteAllScreenshotMetadata() {
@@ -572,14 +571,13 @@ export const useAdvancedSettingsStore = defineStore('AdvancedSettings', () => {
'view.settings.advanced.advanced.delete_all_screenshot_metadata.confirm_no' 'view.settings.advanced.advanced.delete_all_screenshot_metadata.confirm_no'
), ),
type: 'warning', type: 'warning',
showInput: false, showInput: false
callback: async (action) => {
if (action === 'confirm') {
deleteAllScreenshotMetadata();
}
}
} }
); ).then(({ action }) => {
if (action === 'confirm') {
deleteAllScreenshotMetadata();
}
});
} }
function deleteAllScreenshotMetadata() { function deleteAllScreenshotMetadata() {
@@ -595,33 +593,32 @@ export const useAdvancedSettingsStore = defineStore('AdvancedSettings', () => {
'view.settings.advanced.advanced.save_instance_prints_to_file.crop_convert_old_cancel' 'view.settings.advanced.advanced.save_instance_prints_to_file.crop_convert_old_cancel'
), ),
type: 'warning', type: 'warning',
showInput: false, showInput: false
callback: async (action) => { }
if (action === 'confirm') { ).then(async ({ action }) => {
const msgBox = ElMessage({ if (action === 'confirm') {
message: 'Batch metadata removal in progress...', const msgBox = ElMessage({
type: 'warning', message: 'Batch metadata removal in progress...',
duration: 0 type: 'warning',
}); duration: 0
try { });
await AppApi.DeleteAllScreenshotMetadata(); try {
ElMessage({ await AppApi.DeleteAllScreenshotMetadata();
message: 'Batch metadata removal complete', ElMessage({
type: 'success' message: 'Batch metadata removal complete',
}); type: 'success'
} catch (err) { });
console.error(err); } catch (err) {
ElMessage({ console.error(err);
message: `Batch metadata removal failed: ${err}`, ElMessage({
type: 'error' message: `Batch metadata removal failed: ${err}`,
}); type: 'error'
} finally { });
msgBox.close(); } finally {
} msgBox.close();
}
} }
} }
); });
} }
function resetUGCFolder() { function resetUGCFolder() {