diff --git a/src/stores/auth.js b/src/stores/auth.js index f2b580ef..70769fa7 100644 --- a/src/stores/auth.js +++ b/src/stores/auth.js @@ -660,30 +660,29 @@ export const useAuthStore = defineStore('Auth', () => { inputPlaceholder: t('prompt.totp.input_placeholder'), inputPattern: /^[0-9]{6}$/, 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) => { state.twoFactorAuthDialogVisible = false; 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() { @@ -701,30 +700,29 @@ export const useAuthStore = defineStore('Auth', () => { inputPlaceholder: t('prompt.otp.input_placeholder'), inputPattern: /^[a-z0-9]{4}-[a-z0-9]{4}$/, 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) => { state.twoFactorAuthDialogVisible = false; 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() { @@ -743,30 +741,29 @@ export const useAuthStore = defineStore('Auth', () => { inputPlaceholder: t('prompt.email_otp.input_placeholder'), inputPattern: /^[0-9]{6}$/, 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) => { state.twoFactorAuthDialogVisible = false; 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(); + } + }); } /** diff --git a/src/stores/gameLog.js b/src/stores/gameLog.js index 3c2d23d2..f8e5ddcf 100644 --- a/src/stores/gameLog.js +++ b/src/stores/gameLog.js @@ -1410,11 +1410,10 @@ export const useGameLogStore = defineStore('GameLog', () => { ElMessageBox.confirm('Continue? Disable GameLog', 'Confirm', { confirmButtonText: 'Confirm', cancelButtonText: 'Cancel', - type: 'info', - callback: async (action) => { - if (action === 'confirm') { - advancedSettingsStore.setGameLogDisabled(); - } + type: 'info' + }).then(({ action }) => { + if (action === 'confirm') { + advancedSettingsStore.setGameLogDisabled(); } }); } else { diff --git a/src/stores/photon.js b/src/stores/photon.js index d92be261..54babfd9 100644 --- a/src/stores/photon.js +++ b/src/stores/photon.js @@ -564,25 +564,22 @@ export const usePhotonStore = defineStore('Photon', () => { distinguishCancelAndClose: true, confirmButtonText: t('prompt.overlay_message_timeout.ok'), cancelButtonText: t('prompt.overlay_message_timeout.cancel'), - inputValue: state.photonOverlayMessageTimeout / 1000, + inputValue: ( + state.photonOverlayMessageTimeout / 1000 + ).toString(), inputPattern: /\d+$/, inputErrorMessage: t( '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() { @@ -593,22 +590,19 @@ export const usePhotonStore = defineStore('Photon', () => { distinguishCancelAndClose: true, confirmButtonText: t('prompt.photon_lobby_timeout.ok'), cancelButtonText: t('prompt.photon_lobby_timeout.cancel'), - inputValue: state.photonLobbyTimeoutThreshold / 1000, + inputValue: ( + state.photonLobbyTimeoutThreshold / 1000 + ).toString(), inputPattern: /\d+$/, - 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 - ); - } - } + inputErrorMessage: t('prompt.photon_lobby_timeout.input_error') } - ); + ).then(({ value, action }) => { + if (action === 'confirm' && value && !isNaN(Number(value))) { + state.photonLobbyTimeoutThreshold = Math.trunc( + Number(value) * 1000 + ); + } + }); } function startLobbyWatcherLoop() { diff --git a/src/stores/search.js b/src/stores/search.js index e2081456..6f922b2d 100644 --- a/src/stores/search.js +++ b/src/stores/search.js @@ -355,22 +355,19 @@ export const useSearchStore = defineStore('Search', () => { confirmButtonText: t('prompt.direct_access_omni.ok'), cancelButtonText: t('prompt.direct_access_omni.cancel'), inputPattern: /\S+/, - inputErrorMessage: t('prompt.direct_access_omni.input_error'), - callback: (action, instance) => { - if (action === 'confirm' && instance.inputValue) { - const input = instance.inputValue.trim(); - if (!directAccessParse(input)) { - ElMessage({ - message: t( - 'prompt.direct_access_omni.message.error' - ), - type: 'error' - }); - } - } + inputErrorMessage: t('prompt.direct_access_omni.input_error') + } + ).then(({ value, action }) => { + if (action === 'confirm' && value) { + const input = value.trim(); + if (!directAccessParse(input)) { + ElMessage({ + message: t('prompt.direct_access_omni.message.error'), + type: 'error' + }); } } - ); + }); } function showGroupDialogShortCode(shortCode) { diff --git a/src/stores/settings/advanced.js b/src/stores/settings/advanced.js index 198c8877..9e19f996 100644 --- a/src/stores/settings/advanced.js +++ b/src/stores/settings/advanced.js @@ -530,33 +530,32 @@ export const useAdvancedSettingsStore = defineStore('AdvancedSettings', () => { 'view.settings.advanced.advanced.save_instance_prints_to_file.crop_convert_old_cancel' ), type: 'info', - showInput: false, - callback: async (action) => { - if (action === 'confirm') { - const msgBox = ElMessage({ - message: 'Batch print cropping in progress...', - type: 'warning', - duration: 0 - }); - try { - await AppApi.CropAllPrints(state.ugcFolderPath); - ElMessage({ - message: 'Batch print cropping complete', - type: 'success' - }); - } catch (err) { - console.error(err); - ElMessage({ - message: `Batch print cropping failed: ${err}`, - type: 'error' - }); - } finally { - msgBox.close(); - } - } + showInput: false + } + ).then(async ({ action }) => { + if (action === 'confirm') { + const msgBox = ElMessage({ + message: 'Batch print cropping in progress...', + type: 'warning', + duration: 0 + }); + try { + await AppApi.CropAllPrints(state.ugcFolderPath); + ElMessage({ + message: 'Batch print cropping complete', + type: 'success' + }); + } catch (err) { + console.error(err); + ElMessage({ + message: `Batch print cropping failed: ${err}`, + type: 'error' + }); + } finally { + msgBox.close(); } } - ); + }); } function askDeleteAllScreenshotMetadata() { @@ -572,14 +571,13 @@ export const useAdvancedSettingsStore = defineStore('AdvancedSettings', () => { 'view.settings.advanced.advanced.delete_all_screenshot_metadata.confirm_no' ), type: 'warning', - showInput: false, - callback: async (action) => { - if (action === 'confirm') { - deleteAllScreenshotMetadata(); - } - } + showInput: false } - ); + ).then(({ action }) => { + if (action === 'confirm') { + 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' ), type: 'warning', - showInput: false, - callback: async (action) => { - if (action === 'confirm') { - const msgBox = ElMessage({ - message: 'Batch metadata removal in progress...', - type: 'warning', - duration: 0 - }); - try { - await AppApi.DeleteAllScreenshotMetadata(); - ElMessage({ - message: 'Batch metadata removal complete', - type: 'success' - }); - } catch (err) { - console.error(err); - ElMessage({ - message: `Batch metadata removal failed: ${err}`, - type: 'error' - }); - } finally { - msgBox.close(); - } - } + showInput: false + } + ).then(async ({ action }) => { + if (action === 'confirm') { + const msgBox = ElMessage({ + message: 'Batch metadata removal in progress...', + type: 'warning', + duration: 0 + }); + try { + await AppApi.DeleteAllScreenshotMetadata(); + ElMessage({ + message: 'Batch metadata removal complete', + type: 'success' + }); + } catch (err) { + console.error(err); + ElMessage({ + message: `Batch metadata removal failed: ${err}`, + type: 'error' + }); + } finally { + msgBox.close(); } } - ); + }); } function resetUGCFolder() {