mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 01:04:25 +08:00
code refactor
This commit is contained in:
@@ -205,10 +205,7 @@ export const ALL_TIMEZONES: TimezoneInfo[] = [
|
|||||||
timezoneName: 'Atlantic/Cape_Verde'
|
timezoneName: 'Atlantic/Cape_Verde'
|
||||||
},
|
},
|
||||||
// UTC
|
// UTC
|
||||||
{
|
UTC_TIMEZONE,
|
||||||
displayName: 'Coordinated Universal Time',
|
|
||||||
timezoneName: 'Etc/GMT'
|
|
||||||
},
|
|
||||||
// UTC+00:00
|
// UTC+00:00
|
||||||
{
|
{
|
||||||
displayName: 'Dublin, Edinburgh, Lisbon, London',
|
displayName: 'Dublin, Edinburgh, Lisbon, London',
|
||||||
|
|||||||
+3
-5
@@ -77,12 +77,10 @@ export function allTransactionCategoriesWithVisibleCount(allTransactionCategorie
|
|||||||
|| allowCategoryTypes[CategoryType.Expense.toString()]
|
|| allowCategoryTypes[CategoryType.Expense.toString()]
|
||||||
|| allowCategoryTypes[CategoryType.Transfer.toString()]);
|
|| allowCategoryTypes[CategoryType.Transfer.toString()]);
|
||||||
|
|
||||||
for (let key in CategoryType) {
|
const allCategoryTypes = [ CategoryType.Income, CategoryType.Expense, CategoryType.Transfer ];
|
||||||
if (!Object.prototype.hasOwnProperty.call(CategoryType, key)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const categoryType = CategoryType[key];
|
for (let i = 0; i < allCategoryTypes.length; i++) {
|
||||||
|
const categoryType = allCategoryTypes[i];
|
||||||
|
|
||||||
if (!allTransactionCategories[categoryType]) {
|
if (!allTransactionCategories[categoryType]) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
+3
-3
@@ -206,11 +206,11 @@ function getCurrentLanguageDisplayName(i18nGlobal) {
|
|||||||
return currentLanguageInfo.displayName;
|
return currentLanguageInfo.displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLocalizedDisplayNameAndType(nameAndTypes, translateFn) {
|
function getLocalizedDisplayNameAndType(typeAndNames, translateFn) {
|
||||||
const ret = [];
|
const ret = [];
|
||||||
|
|
||||||
for (let i = 0; i < nameAndTypes.length; i++) {
|
for (let i = 0; i < typeAndNames.length; i++) {
|
||||||
const nameAndType = nameAndTypes[i];
|
const nameAndType = typeAndNames[i];
|
||||||
|
|
||||||
ret.push({
|
ret.push({
|
||||||
type: nameAndType.type,
|
type: nameAndType.type,
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
import uaParser from 'ua-parser-js';
|
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 {
|
interface UserAgentInfo {
|
||||||
device: {
|
device: {
|
||||||
@@ -39,7 +39,7 @@ function parseUserAgent(ua: string): UserAgentInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isSessionUserAgentCreatedByCli(ua: string): boolean {
|
function isSessionUserAgentCreatedByCli(ua: string): boolean {
|
||||||
return ua === CliUserAgent;
|
return ua === TOKEN_CLI_USER_AGENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseDeviceInfo(uaInfo: UserAgentInfo): string {
|
function parseDeviceInfo(uaInfo: UserAgentInfo): string {
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
export const CliUserAgent: string = 'ezbookkeeping Cli';
|
export const TOKEN_CLI_USER_AGENT: string = 'ezbookkeeping Cli';
|
||||||
|
|
||||||
export interface TokenInfoResponse {
|
export interface TokenInfoResponse {
|
||||||
readonly tokenId: string;
|
readonly tokenId: string;
|
||||||
|
|||||||
@@ -166,8 +166,6 @@ export default {
|
|||||||
'f7router'
|
'f7router'
|
||||||
],
|
],
|
||||||
data: function () {
|
data: function () {
|
||||||
const self = this;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
loading: true,
|
loading: true,
|
||||||
loadingError: null,
|
loadingError: null,
|
||||||
@@ -175,7 +173,17 @@ export default {
|
|||||||
allowCategoryTypes: null,
|
allowCategoryTypes: null,
|
||||||
filterCategoryIds: {},
|
filterCategoryIds: {},
|
||||||
showHidden: false,
|
showHidden: false,
|
||||||
collapseStates: self.getCollapseStates(),
|
collapseStates: {
|
||||||
|
[CategoryType.Income]: {
|
||||||
|
opened: true
|
||||||
|
},
|
||||||
|
[CategoryType.Expense]: {
|
||||||
|
opened: true
|
||||||
|
},
|
||||||
|
[CategoryType.Transfer]: {
|
||||||
|
opened: true
|
||||||
|
}
|
||||||
|
},
|
||||||
showMoreActionSheet: false
|
showMoreActionSheet: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -367,23 +375,6 @@ export default {
|
|||||||
},
|
},
|
||||||
isSubCategoriesHasButNotAllChecked(category, filterCategoryIds) {
|
isSubCategoriesHasButNotAllChecked(category, filterCategoryIds) {
|
||||||
return isSubCategoriesHasButNotAllChecked(category, filterCategoryIds);
|
return isSubCategoriesHasButNotAllChecked(category, filterCategoryIds);
|
||||||
},
|
|
||||||
getCollapseStates() {
|
|
||||||
const collapseStates = {};
|
|
||||||
|
|
||||||
for (const categoryTypeField in CategoryType) {
|
|
||||||
if (!Object.prototype.hasOwnProperty.call(CategoryType, categoryTypeField)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const categoryType = CategoryType[categoryTypeField];
|
|
||||||
|
|
||||||
collapseStates[categoryType] = {
|
|
||||||
opened: true
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return collapseStates;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user