code refactor

This commit is contained in:
MaysWind
2024-12-30 23:11:03 +08:00
parent 2560a70e5e
commit 863e0205ff
6 changed files with 21 additions and 35 deletions
+3 -5
View File
@@ -77,12 +77,10 @@ export function allTransactionCategoriesWithVisibleCount(allTransactionCategorie
|| allowCategoryTypes[CategoryType.Expense.toString()]
|| allowCategoryTypes[CategoryType.Transfer.toString()]);
for (let key in CategoryType) {
if (!Object.prototype.hasOwnProperty.call(CategoryType, key)) {
continue;
}
const allCategoryTypes = [ CategoryType.Income, CategoryType.Expense, CategoryType.Transfer ];
const categoryType = CategoryType[key];
for (let i = 0; i < allCategoryTypes.length; i++) {
const categoryType = allCategoryTypes[i];
if (!allTransactionCategories[categoryType]) {
continue;
+3 -3
View File
@@ -206,11 +206,11 @@ function getCurrentLanguageDisplayName(i18nGlobal) {
return currentLanguageInfo.displayName;
}
function getLocalizedDisplayNameAndType(nameAndTypes, translateFn) {
function getLocalizedDisplayNameAndType(typeAndNames, translateFn) {
const ret = [];
for (let i = 0; i < nameAndTypes.length; i++) {
const nameAndType = nameAndTypes[i];
for (let i = 0; i < typeAndNames.length; i++) {
const nameAndType = typeAndNames[i];
ret.push({
type: nameAndType.type,
+2 -2
View File
@@ -1,6 +1,6 @@
import uaParser from 'ua-parser-js';
import { CliUserAgent, type TokenInfoResponse, SessionInfo } from '@/models/token.ts';
import { TOKEN_CLI_USER_AGENT, type TokenInfoResponse, SessionInfo } from '@/models/token.ts';
interface UserAgentInfo {
device: {
@@ -39,7 +39,7 @@ function parseUserAgent(ua: string): UserAgentInfo {
}
function isSessionUserAgentCreatedByCli(ua: string): boolean {
return ua === CliUserAgent;
return ua === TOKEN_CLI_USER_AGENT;
}
function parseDeviceInfo(uaInfo: UserAgentInfo): string {