mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-16 07:57:33 +08:00
code refactor
This commit is contained in:
+3
-5
@@ -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
@@ -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
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user