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
+24 -27
View File
@@ -660,11 +660,16 @@ 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) => { beforeClose: (action, instance, done) => {
state.twoFactorAuthDialogVisible = false;
done();
}
}
).then(({ value, action }) => {
if (action === 'confirm') { if (action === 'confirm') {
authRequest authRequest
.verifyTOTP({ .verifyTOTP({
code: instance.inputValue.trim() code: value.trim()
}) })
.catch((err) => { .catch((err) => {
clearCookiesTryLogin(); clearCookiesTryLogin();
@@ -677,13 +682,7 @@ export const useAuthStore = defineStore('Auth', () => {
} else if (action === 'cancel') { } else if (action === 'cancel') {
promptOTP(); promptOTP();
} }
}, });
beforeClose: (action, instance, done) => {
state.twoFactorAuthDialogVisible = false;
done();
}
}
);
} }
function promptOTP() { function promptOTP() {
@@ -701,11 +700,16 @@ 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) => { beforeClose: (action, instance, done) => {
state.twoFactorAuthDialogVisible = false;
done();
}
}
).then(({ value, action }) => {
if (action === 'confirm') { if (action === 'confirm') {
authRequest authRequest
.verifyOTP({ .verifyOTP({
code: instance.inputValue.trim() code: value.trim()
}) })
.catch((err) => { .catch((err) => {
clearCookiesTryLogin(); clearCookiesTryLogin();
@@ -718,13 +722,7 @@ export const useAuthStore = defineStore('Auth', () => {
} else if (action === 'cancel') { } else if (action === 'cancel') {
promptTOTP(); promptTOTP();
} }
}, });
beforeClose: (action, instance, done) => {
state.twoFactorAuthDialogVisible = false;
done();
}
}
);
} }
function promptEmailOTP() { function promptEmailOTP() {
@@ -743,11 +741,16 @@ 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) => { beforeClose: (action, instance, done) => {
state.twoFactorAuthDialogVisible = false;
done();
}
}
).then(({ value, action }) => {
if (action === 'confirm') { if (action === 'confirm') {
authRequest authRequest
.verifyEmailOTP({ .verifyEmailOTP({
code: instance.inputValue.trim() code: value.trim()
}) })
.catch((err) => { .catch((err) => {
promptEmailOTP(); promptEmailOTP();
@@ -760,13 +763,7 @@ export const useAuthStore = defineStore('Auth', () => {
} else if (action === 'cancel') { } else if (action === 'cancel') {
resendEmail2fa(); resendEmail2fa();
} }
}, });
beforeClose: (action, instance, done) => {
state.twoFactorAuthDialogVisible = false;
done();
}
}
);
} }
/** /**
+2 -3
View File
@@ -1410,12 +1410,11 @@ 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 {
advancedSettingsStore.setGameLogDisabled(); advancedSettingsStore.setGameLogDisabled();
+18 -24
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 ( ).then(({ value, action }) => {
action === 'confirm' && if (action === 'confirm' && value && !isNaN(Number(value))) {
instance.inputValue &&
!isNaN(instance.inputValue)
) {
state.photonOverlayMessageTimeout = Math.trunc( state.photonOverlayMessageTimeout = Math.trunc(
Number(instance.inputValue) * 1000 Number(value) * 1000
); );
vrStore.updateVRConfigVars(); 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 ( ).then(({ value, action }) => {
action === 'confirm' && if (action === 'confirm' && value && !isNaN(Number(value))) {
instance.inputValue &&
!isNaN(instance.inputValue)
) {
state.photonLobbyTimeoutThreshold = Math.trunc( state.photonLobbyTimeoutThreshold = Math.trunc(
Number(instance.inputValue) * 1000 Number(value) * 1000
); );
} }
} });
}
);
} }
function startLobbyWatcherLoop() { function startLobbyWatcherLoop() {
+7 -10
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) {
const input = value.trim();
if (!directAccessParse(input)) { if (!directAccessParse(input)) {
ElMessage({ ElMessage({
message: t( message: t('prompt.direct_access_omni.message.error'),
'prompt.direct_access_omni.message.error'
),
type: 'error' type: 'error'
}); });
} }
} }
} });
}
);
} }
function showGroupDialogShortCode(shortCode) { function showGroupDialogShortCode(shortCode) {
+12 -15
View File
@@ -530,8 +530,9 @@ 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) => { }
).then(async ({ action }) => {
if (action === 'confirm') { if (action === 'confirm') {
const msgBox = ElMessage({ const msgBox = ElMessage({
message: 'Batch print cropping in progress...', message: 'Batch print cropping in progress...',
@@ -554,9 +555,7 @@ export const useAdvancedSettingsStore = defineStore('AdvancedSettings', () => {
msgBox.close(); 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) => { }
).then(({ action }) => {
if (action === 'confirm') { if (action === 'confirm') {
deleteAllScreenshotMetadata(); deleteAllScreenshotMetadata();
} }
} });
}
);
} }
function deleteAllScreenshotMetadata() { function deleteAllScreenshotMetadata() {
@@ -595,8 +593,9 @@ 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) => { }
).then(async ({ action }) => {
if (action === 'confirm') { if (action === 'confirm') {
const msgBox = ElMessage({ const msgBox = ElMessage({
message: 'Batch metadata removal in progress...', message: 'Batch metadata removal in progress...',
@@ -619,9 +618,7 @@ export const useAdvancedSettingsStore = defineStore('AdvancedSettings', () => {
msgBox.close(); msgBox.close();
} }
} }
} });
}
);
} }
function resetUGCFolder() { function resetUGCFolder() {