migrate to typescript

This commit is contained in:
MaysWind
2024-12-29 14:24:37 +08:00
parent b638a73e4d
commit 2560a70e5e
171 changed files with 3402 additions and 2557 deletions
+10 -10
View File
@@ -149,11 +149,11 @@
import { mapStores } from 'pinia';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import categoryConstants from '@/consts/category.js';
import iconConstants from '@/consts/icon.js';
import colorConstants from '@/consts/color.js';
import { getNameByKeyValue } from '@/lib/common.js';
import { generateRandomUUID } from '@/lib/misc.js';
import { CategoryType } from '@/core/category.ts';
import { ALL_CATEGORY_ICONS } from '@/consts/icon.ts';
import { ALL_CATEGORY_COLORS } from '@/consts/color.ts';
import { getNameByKeyValue } from '@/lib/common.ts';
import { generateRandomUUID } from '@/lib/misc.ts';
import {
setCategoryModelByAnotherCategory,
allVisiblePrimaryTransactionCategoriesByType
@@ -205,10 +205,10 @@ export default {
}
},
allCategoryIcons() {
return iconConstants.allCategoryIcons;
return ALL_CATEGORY_ICONS;
},
allCategoryColors() {
return colorConstants.allCategoryColors;
return ALL_CATEGORY_COLORS;
},
inputIsEmpty() {
return !!this.inputEmptyProblemMessage;
@@ -251,9 +251,9 @@ export default {
} else if (query.parentId) {
const categoryType = parseInt(query.type);
if (categoryType !== categoryConstants.allCategoryTypes.Income &&
categoryType !== categoryConstants.allCategoryTypes.Expense &&
categoryType !== categoryConstants.allCategoryTypes.Transfer) {
if (categoryType !== CategoryType.Income &&
categoryType !== CategoryType.Expense &&
categoryType !== CategoryType.Transfer) {
self.$toast('Parameter Invalid');
self.loadingError = 'Parameter Invalid';
return;
+8 -8
View File
@@ -90,13 +90,13 @@
import { mapStores } from 'pinia';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import categoryConstants from '@/consts/category.js';
import { CategoryType } from '@/core/category.ts';
import {
isNoAvailableCategory,
getFirstShowingId,
getLastShowingId
} from '@/lib/category.js';
import { onSwipeoutDeleted } from '@/lib/ui.mobile.js';
import { onSwipeoutDeleted } from '@/lib/ui/mobile.js';
export default {
props: [
@@ -142,13 +142,13 @@ export default {
let title = '';
switch (this.categoryType) {
case categoryConstants.allCategoryTypes.Income:
case CategoryType.Income:
title = 'Income';
break;
case categoryConstants.allCategoryTypes.Expense:
case CategoryType.Expense:
title = 'Expense';
break;
case categoryConstants.allCategoryTypes.Transfer:
case CategoryType.Transfer:
title = 'Transfer';
break;
default:
@@ -186,9 +186,9 @@ export default {
self.categoryType = parseInt(query.type);
if (self.categoryType !== categoryConstants.allCategoryTypes.Income &&
self.categoryType !== categoryConstants.allCategoryTypes.Expense &&
self.categoryType !== categoryConstants.allCategoryTypes.Transfer) {
if (self.categoryType !== CategoryType.Income &&
self.categoryType !== CategoryType.Expense &&
self.categoryType !== CategoryType.Transfer) {
self.$toast('Parameter Invalid');
self.loadingError = 'Parameter Invalid';
return;
+8 -8
View File
@@ -59,8 +59,8 @@
import { mapStores } from 'pinia';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import categoryConstants from '@/consts/category.js';
import { getObjectOwnFieldCount, categorizedArrayToPlainArray } from '@/lib/common.js';
import { CategoryType } from '@/core/category.ts';
import { getObjectOwnFieldCount, categorizedArrayToPlainArray } from '@/lib/common.ts';
export default {
props: [
@@ -98,9 +98,9 @@ export default {
self.categoryType = parseInt(query.type);
if (self.categoryType !== 0 &&
self.categoryType !== categoryConstants.allCategoryTypes.Income &&
self.categoryType !== categoryConstants.allCategoryTypes.Expense &&
self.categoryType !== categoryConstants.allCategoryTypes.Transfer) {
self.categoryType !== CategoryType.Income &&
self.categoryType !== CategoryType.Expense &&
self.categoryType !== CategoryType.Transfer) {
self.$toast('Parameter Invalid');
self.loadingError = 'Parameter Invalid';
}
@@ -137,11 +137,11 @@ export default {
},
getCategoryTypeName(categoryType) {
switch (categoryType) {
case categoryConstants.allCategoryTypes.Income.toString():
case CategoryType.Income.toString():
return this.$t('Income Categories');
case categoryConstants.allCategoryTypes.Expense.toString():
case CategoryType.Expense.toString():
return this.$t('Expense Categories');
case categoryConstants.allCategoryTypes.Transfer.toString():
case CategoryType.Transfer.toString():
return this.$t('Transfer Categories');
default:
return this.$t('Transaction Categories');