replace ElMessageBox.prompt

This commit is contained in:
pa
2026-01-15 11:46:03 +09:00
committed by Natsumi
parent 87dc871578
commit fc13dca0a4
22 changed files with 413 additions and 408 deletions

View File

@@ -1,5 +1,4 @@
import { reactive, ref, watch } from 'vue';
import { ElMessageBox } from 'element-plus';
import { defineStore } from 'pinia';
import { toast } from 'vue-sonner';
import { useI18n } from 'vue-i18n';
@@ -855,23 +854,22 @@ export const useAdvancedSettingsStore = defineStore('AdvancedSettings', () => {
}
function promptAutoClearVRCXCacheFrequency() {
ElMessageBox.prompt(
t('prompt.auto_clear_cache.description'),
t('prompt.auto_clear_cache.header'),
{
distinguishCancelAndClose: true,
confirmButtonText: t('prompt.auto_clear_cache.ok'),
cancelButtonText: t('prompt.auto_clear_cache.cancel'),
modalStore
.prompt({
title: t('prompt.auto_clear_cache.header'),
description: t('prompt.auto_clear_cache.description'),
confirmText: t('prompt.auto_clear_cache.ok'),
cancelText: t('prompt.auto_clear_cache.cancel'),
inputValue: (
vrcxStore.clearVRCXCacheFrequency /
3600 /
2
).toString(),
inputPattern: /\d+$/,
inputErrorMessage: t('prompt.auto_clear_cache.input_error')
}
)
.then(async ({ value }) => {
pattern: /\d+$/,
errorMessage: t('prompt.auto_clear_cache.input_error')
})
.then(async ({ ok, value }) => {
if (!ok) return;
if (value && !isNaN(parseInt(value, 10))) {
vrcxStore.clearVRCXCacheFrequency = Math.trunc(
parseInt(value, 10) * 3600 * 2

View File

@@ -1,5 +1,4 @@
import { computed, ref, watch } from 'vue';
import { ElMessageBox } from 'element-plus';
import { defineStore } from 'pinia';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
@@ -17,6 +16,7 @@ import { loadLocalizedStrings } from '../../plugin';
import { useElementTheme } from '../../composables/useElementTheme';
import { useFeedStore } from '../feed';
import { useGameLogStore } from '../gameLog';
import { useModalStore } from '../modal';
import { useUiStore } from '../ui';
import { useUserStore } from '../user';
import { useVrStore } from '../vr';
@@ -36,6 +36,7 @@ export const useAppearanceSettingsStore = defineStore(
const userStore = useUserStore();
const router = useRouter();
const uiStore = useUiStore();
const modalStore = useModalStore();
const { t, locale } = useI18n();
@@ -746,19 +747,18 @@ export const useAppearanceSettingsStore = defineStore(
}
function promptMaxTableSizeDialog() {
ElMessageBox.prompt(
t('prompt.change_table_size.description'),
t('prompt.change_table_size.header'),
{
distinguishCancelAndClose: true,
confirmButtonText: t('prompt.change_table_size.save'),
cancelButtonText: t('prompt.change_table_size.cancel'),
modalStore
.prompt({
title: t('prompt.change_table_size.header'),
description: t('prompt.change_table_size.description'),
confirmText: t('prompt.change_table_size.save'),
cancelText: t('prompt.change_table_size.cancel'),
inputValue: vrcxStore.maxTableSize.toString(),
inputPattern: /\d+$/,
inputErrorMessage: t('prompt.change_table_size.input_error')
}
)
.then(async ({ value }) => {
pattern: /\d+$/,
errorMessage: t('prompt.change_table_size.input_error')
})
.then(async ({ ok, value }) => {
if (!ok) return;
if (value) {
let processedValue = Number(value);
if (processedValue > 10000) {

View File

@@ -1,9 +1,9 @@
import { ElMessageBox } from 'element-plus';
import { defineStore } from 'pinia';
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useFriendStore } from '../friend';
import { useModalStore } from '../modal';
import { useVRCXUpdaterStore } from '../vrcxUpdater';
import { useVrcxStore } from '../vrcx';
@@ -15,6 +15,7 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => {
const vrcxStore = useVrcxStore();
const VRCXUpdaterStore = useVRCXUpdaterStore();
const friendStore = useFriendStore();
const modalStore = useModalStore();
const { t } = useI18n();
@@ -231,32 +232,32 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => {
}
function promptProxySettings() {
ElMessageBox.prompt(
t('prompt.proxy_settings.description'),
t('prompt.proxy_settings.header'),
{
distinguishCancelAndClose: true,
confirmButtonText: t('prompt.proxy_settings.restart'),
cancelButtonText: t('prompt.proxy_settings.close'),
inputValue: vrcxStore.proxyServer,
inputPlaceholder: t('prompt.proxy_settings.placeholder')
}
)
.then(async ({ value }) => {
vrcxStore.proxyServer = value;
await VRCXStorage.Set(
'VRCX_ProxyServer',
vrcxStore.proxyServer
);
await VRCXStorage.Save();
await new Promise((resolve) => {
workerTimers.setTimeout(resolve, 100);
});
const { restartVRCX } = VRCXUpdaterStore;
const isUpgrade = false;
restartVRCX(isUpgrade);
// Element Plus: prompt(message, title, options)
modalStore
.prompt({
title: t('prompt.proxy_settings.header'),
description: t('prompt.proxy_settings.description'),
confirmText: t('prompt.proxy_settings.restart'),
cancelText: t('prompt.proxy_settings.close'),
inputValue: vrcxStore.proxyServer
})
.catch(async () => {
.then(async ({ ok, value }) => {
if (ok) {
vrcxStore.proxyServer = value;
await VRCXStorage.Set(
'VRCX_ProxyServer',
vrcxStore.proxyServer
);
await VRCXStorage.Save();
await new Promise((resolve) => {
workerTimers.setTimeout(resolve, 100);
});
const { restartVRCX } = VRCXUpdaterStore;
const isUpgrade = false;
restartVRCX(isUpgrade);
return;
}
// User clicked close/cancel, still save the value but don't restart
if (vrcxStore.proxyServer !== undefined) {
await VRCXStorage.Set(
@@ -268,6 +269,9 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => {
workerTimers.setTimeout(resolve, 100);
});
}
})
.catch((err) => {
console.error(err);
});
}

View File

@@ -1,9 +1,9 @@
import { ElMessageBox } from 'element-plus';
import { defineStore } from 'pinia';
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { sharedFeedFiltersDefaults } from '../../shared/constants';
import { useModalStore } from '../modal';
import { useVrStore } from '../vr';
import configRepository from '../../service/config';
@@ -12,6 +12,7 @@ export const useNotificationsSettingsStore = defineStore(
'NotificationsSettings',
() => {
const vrStore = useVrStore();
const modalStore = useModalStore();
const { t } = useI18n();
@@ -410,21 +411,18 @@ export const useNotificationsSettingsStore = defineStore(
}
function promptNotificationTimeout() {
ElMessageBox.prompt(
t('prompt.notification_timeout.description'),
t('prompt.notification_timeout.header'),
{
distinguishCancelAndClose: true,
confirmButtonText: t('prompt.notification_timeout.ok'),
cancelButtonText: t('prompt.notification_timeout.cancel'),
modalStore
.prompt({
title: t('prompt.notification_timeout.header'),
description: t('prompt.notification_timeout.description'),
confirmText: t('prompt.notification_timeout.ok'),
cancelText: t('prompt.notification_timeout.cancel'),
inputValue: notificationTimeout.value / 1000,
inputPattern: /\d+$/,
inputErrorMessage: t(
'prompt.notification_timeout.input_error'
)
}
)
.then(async ({ value }) => {
pattern: /\d+$/,
errorMessage: t('prompt.notification_timeout.input_error')
})
.then(async ({ ok, value }) => {
if (!ok) return;
if (value && !isNaN(value)) {
notificationTimeout.value = Math.trunc(
Number(value) * 1000