code refactor

This commit is contained in:
MaysWind
2025-03-23 21:57:20 +08:00
parent f9b7be2f74
commit 399b5c03a2
4 changed files with 64 additions and 6 deletions
@@ -67,6 +67,7 @@ import { useTransactionCategoriesStore } from '@/stores/transactionCategory.ts';
import type { PartialRecord } from '@/core/base.ts';
import { type LocalizedPresetCategory, CategoryType } from '@/core/category.ts';
import { categorizedArrayToPlainArray } from '@/lib/common.ts';
import { localizedPresetCategoriesToTransactionCategoryCreateWithSubCategories } from '@/lib/category.ts';
type SnackBarType = InstanceType<typeof SnackBar>;
@@ -113,7 +114,8 @@ function getCategoryTypeName(categoryType: CategoryType): string {
function save(): void {
submitting.value = true;
const submitCategories = categorizedArrayToPlainArray(allPresetCategories.value);
const presetCategoriesArray = categorizedArrayToPlainArray(allPresetCategories.value);
const submitCategories = localizedPresetCategoriesToTransactionCategoryCreateWithSubCategories(presetCategoriesArray);
transactionCategoriesStore.addCategories({
categories: submitCategories
+3 -1
View File
@@ -68,6 +68,7 @@ import type { PartialRecord } from '@/core/base.ts';
import type { LanguageOption } from '@/locales/index.ts';
import { type LocalizedPresetCategory, CategoryType } from '@/core/category.ts';
import { getObjectOwnFieldCount, categorizedArrayToPlainArray } from '@/lib/common.ts';
import { localizedPresetCategoriesToTransactionCategoryCreateWithSubCategories } from '@/lib/category.ts';
const props = defineProps<{
f7route: Router.Route;
@@ -109,7 +110,8 @@ function save(): void {
submitting.value = true;
showLoading(() => submitting.value);
const submitCategories = categorizedArrayToPlainArray(allPresetCategories.value);
const presetCategoriesArray = categorizedArrayToPlainArray(allPresetCategories.value);
const submitCategories = localizedPresetCategoriesToTransactionCategoryCreateWithSubCategories(presetCategoriesArray);
transactionCategoriesStore.addCategories({
categories: submitCategories