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

View File

@@ -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();
}
});
}
/**

View File

@@ -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 {

View File

@@ -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() {

View File

@@ -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) {

View File

@@ -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() {