code refactor

This commit is contained in:
MaysWind
2025-03-09 00:39:54 +08:00
parent 34247be52c
commit 09574f1c75
9 changed files with 95 additions and 71 deletions
+5 -27
View File
@@ -90,30 +90,10 @@
<v-row>
<v-col cols="12" md="12">
<v-select
item-title="nativeDisplayName"
item-value="languageTag"
:disabled="submitting || navigateToHomePage"
:label="languageTitle"
:placeholder="languageTitle"
:items="allLanguages"
v-model="currentLocale"
>
<template #item="{ props, item }">
<v-list-item :value="item.value" v-bind="props">
<template #title>
<v-list-item-title>
<div class="d-flex align-center">
<span>{{ item.title }}</span>
<v-spacer />
<v-icon :icon="mdiCheck" v-if="currentLocale == item.raw.languageTag" />
<span class="text-field-append-text" v-if="currentLocale !== item.raw.languageTag">{{ item.raw.displayName }}</span>
</div>
</v-list-item-title>
</template>
</v-list-item>
</template>
</v-select>
<language-select :disabled="submitting || navigateToHomePage"
:label="languageTitle"
:placeholder="languageTitle"
:use-model-value="true" v-model="currentLocale" />
</v-col>
</v-row>
@@ -243,7 +223,6 @@ import { ref, computed, useTemplateRef } from 'vue';
import { useRouter } from 'vue-router';
import { useTheme } from 'vuetify';
import type { LanguageOption } from '@/locales/index.ts';
import { useI18n } from '@/locales/helpers.ts';
import { useSignupPageBase } from '@/views/base/SignupPageBase.ts';
@@ -269,7 +248,7 @@ type SnackBarType = InstanceType<typeof SnackBar>;
const router = useRouter();
const theme = useTheme();
const { tt, getAllLanguageOptions, getAllCurrencies, getAllWeekDays, getAllTransactionDefaultCategories } = useI18n();
const { tt, getAllCurrencies, getAllWeekDays, getAllTransactionDefaultCategories } = useI18n();
const {
user,
@@ -291,7 +270,6 @@ const usePresetCategories = ref<boolean>(false);
const finalResultMessage = ref<string | null>(null);
const navigateToHomePage = ref<boolean>(false);
const allLanguages = computed<LanguageOption[]>(() => getAllLanguageOptions(false));
const allCurrencies = computed<LocalizedCurrencyInfo[]>(() => getAllCurrencies());
const allWeekDays = computed<TypeAndDisplayName[]>(() => getAllWeekDays());
const allPresetCategories = computed<PartialRecord<CategoryType, LocalizedPresetCategory[]>>(() => getAllTransactionDefaultCategories(0, currentLocale.value));
@@ -116,31 +116,11 @@
<v-card-text>
<v-row>
<v-col cols="12" md="6">
<v-select
item-title="nativeDisplayName"
item-value="languageTag"
persistent-placeholder
:disabled="loading || saving"
:label="languageTitle"
:placeholder="languageTitle"
:items="allLanguages"
v-model="newProfile.language"
>
<template #item="{ props, item }">
<v-list-item :value="item.value" v-bind="props">
<template #title>
<v-list-item-title>
<div class="d-flex align-center">
<span>{{ item.title }}</span>
<v-spacer />
<v-icon :icon="mdiCheck" v-if="newProfile.language == item.raw.languageTag" />
<span class="text-field-append-text" v-if="newProfile.language !== item.raw.languageTag">{{ item.raw.displayName }}</span>
</div>
</v-list-item-title>
</template>
</v-list-item>
</template>
</v-select>
<language-select :disabled="loading || saving"
:label="languageTitle"
:placeholder="languageTitle"
:include-system-default="true"
:use-model-value="true" v-model="newProfile.language" />
</v-col>
<v-col cols="12" md="6">
@@ -366,8 +346,7 @@ import { isUserVerifyEmailEnabled } from '@/lib/server_settings.ts';
import {
mdiAccount,
mdiAccountEditOutline,
mdiCheck
mdiAccountEditOutline
} from '@mdi/js';
type ConfirmDialogType = InstanceType<typeof ConfirmDialog>;
@@ -382,7 +361,6 @@ const {
loading,
resending,
saving,
allLanguages,
allCurrencies,
allVisibleAccounts,
allVisibleCategorizedAccounts,