mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-21 02:04:26 +08:00
code refactor
This commit is contained in:
@@ -34,13 +34,8 @@ const initCenter = ref<MapPosition>({
|
|||||||
});
|
});
|
||||||
const zoomLevel = ref<number>(1);
|
const zoomLevel = ref<number>(1);
|
||||||
|
|
||||||
const mapSupported = computed<boolean>(() => {
|
const mapSupported = computed<boolean>(() => !!mapInstance.value);
|
||||||
return !!mapInstance.value;
|
const mapDependencyLoaded = computed<boolean>(() => mapInstance.value?.dependencyLoaded || false);
|
||||||
});
|
|
||||||
|
|
||||||
const mapDependencyLoaded = computed<boolean>(() => {
|
|
||||||
return mapInstance.value?.dependencyLoaded || false;
|
|
||||||
});
|
|
||||||
|
|
||||||
const finalMapStyle = computed<Record<string, unknown>>(() => {
|
const finalMapStyle = computed<Record<string, unknown>>(() => {
|
||||||
const styles: Record<string, unknown> = copyObjectTo(props.mapStyle, {});
|
const styles: Record<string, unknown> = copyObjectTo(props.mapStyle, {});
|
||||||
|
|||||||
@@ -72,9 +72,7 @@ const icons = {
|
|||||||
const dropdownMenu = useTemplateRef<HTMLElement>('dropdownMenu');
|
const dropdownMenu = useTemplateRef<HTMLElement>('dropdownMenu');
|
||||||
const itemPerRow = ref<number>(props.columnCount || 7);
|
const itemPerRow = ref<number>(props.columnCount || 7);
|
||||||
|
|
||||||
const allColorRows = computed<ColorInfo[][]>(() => {
|
const allColorRows = computed<ColorInfo[][]>(() => getColorsInRows(props.allColorInfos, itemPerRow.value));
|
||||||
return getColorsInRows(props.allColorInfos, itemPerRow.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
const color = computed<ColorValue>({
|
const color = computed<ColorValue>({
|
||||||
get: () => props.modelValue,
|
get: () => props.modelValue,
|
||||||
|
|||||||
@@ -99,9 +99,7 @@ const firstDayOfWeek = computed<number>(() => userStore.currentUserFirstDayOfWee
|
|||||||
const dayNames = computed<string[]>(() => arrangeArrayWithNewStartIndex(getAllMinWeekdayNames(), firstDayOfWeek.value));
|
const dayNames = computed<string[]>(() => arrangeArrayWithNewStartIndex(getAllMinWeekdayNames(), firstDayOfWeek.value));
|
||||||
const isYearFirst = computed<boolean>(() => isLongDateMonthAfterYear());
|
const isYearFirst = computed<boolean>(() => isLongDateMonthAfterYear());
|
||||||
const is24Hour = computed<boolean>(() => isLongTime24HourFormat());
|
const is24Hour = computed<boolean>(() => isLongTime24HourFormat());
|
||||||
const displayTime = computed<string>(() => {
|
const displayTime = computed<string>(() => formatUnixTimeToLongDateTime(getActualUnixTimeForStore(getUnixTime(dateTime.value), getTimezoneOffsetMinutes(), getBrowserTimezoneOffsetMinutes())));
|
||||||
return formatUnixTimeToLongDateTime(getActualUnixTimeForStore(getUnixTime(dateTime.value), getTimezoneOffsetMinutes(), getBrowserTimezoneOffsetMinutes()));
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -70,9 +70,7 @@ const icons = {
|
|||||||
const dropdownMenu = useTemplateRef<HTMLElement>('dropdownMenu');
|
const dropdownMenu = useTemplateRef<HTMLElement>('dropdownMenu');
|
||||||
const itemPerRow = ref<number>(props.columnCount || 7);
|
const itemPerRow = ref<number>(props.columnCount || 7);
|
||||||
|
|
||||||
const allIconRows = computed<IconInfoWithId[][]>(() => {
|
const allIconRows = computed<IconInfoWithId[][]>(() => getIconsInRows(props.allIconInfos, itemPerRow.value));
|
||||||
return getIconsInRows(props.allIconInfos, itemPerRow.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
const icon = computed<string>({
|
const icon = computed<string>({
|
||||||
get: () => props.modelValue,
|
get: () => props.modelValue,
|
||||||
|
|||||||
@@ -63,9 +63,7 @@ const emit = defineEmits<{
|
|||||||
(e: 'step:change', stepName: string): void;
|
(e: 'step:change', stepName: string): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const isClickable = computed<boolean>(() => {
|
const isClickable = computed<boolean>(() => props.clickable !== 'false' && props.clickable !== false);
|
||||||
return props.clickable !== 'false' && props.clickable !== false;
|
|
||||||
});
|
|
||||||
|
|
||||||
function changeStep(step: StepBarItem): void {
|
function changeStep(step: StepBarItem): void {
|
||||||
if (isClickable.value) {
|
if (isClickable.value) {
|
||||||
|
|||||||
@@ -55,9 +55,7 @@ const { tt } = useI18n();
|
|||||||
const currentValue = ref<ColorValue>(props.modelValue);
|
const currentValue = ref<ColorValue>(props.modelValue);
|
||||||
const itemPerRow = ref<number>(props.columnCount || 7);
|
const itemPerRow = ref<number>(props.columnCount || 7);
|
||||||
|
|
||||||
const allColorRows = computed<ColorInfo[][]>(() => {
|
const allColorRows = computed<ColorInfo[][]>(() => getColorsInRows(props.allColorInfos, itemPerRow.value));
|
||||||
return getColorsInRows(props.allColorInfos, itemPerRow.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
function onColorClicked(colorInfo: ColorInfo): void {
|
function onColorClicked(colorInfo: ColorInfo): void {
|
||||||
currentValue.value = colorInfo.color;
|
currentValue.value = colorInfo.color;
|
||||||
|
|||||||
@@ -109,9 +109,7 @@ const isDarkMode = computed<boolean>(() => environmentsStore.framework7DarkMode
|
|||||||
const firstDayOfWeek = computed<number>(() => userStore.currentUserFirstDayOfWeek);
|
const firstDayOfWeek = computed<number>(() => userStore.currentUserFirstDayOfWeek);
|
||||||
const dayNames = computed<string[]>(() => arrangeArrayWithNewStartIndex(getAllMinWeekdayNames(), firstDayOfWeek.value));
|
const dayNames = computed<string[]>(() => arrangeArrayWithNewStartIndex(getAllMinWeekdayNames(), firstDayOfWeek.value));
|
||||||
const isYearFirst = computed<boolean>(() => isLongDateMonthAfterYear());
|
const isYearFirst = computed<boolean>(() => isLongDateMonthAfterYear());
|
||||||
const displayTime = computed<string>(() => {
|
const displayTime = computed<string>(() => formatUnixTimeToLongDateTime(getActualUnixTimeForStore(getUnixTime(dateTime.value), getTimezoneOffsetMinutes(), getBrowserTimezoneOffsetMinutes())));
|
||||||
return formatUnixTimeToLongDateTime(getActualUnixTimeForStore(getUnixTime(dateTime.value), getTimezoneOffsetMinutes(), getBrowserTimezoneOffsetMinutes()));
|
|
||||||
});
|
|
||||||
const switchButtonTitle = computed<string>(() => mode.value === 'time' ? 'Date' : 'Time');
|
const switchButtonTitle = computed<string>(() => mode.value === 'time' ? 'Date' : 'Time');
|
||||||
|
|
||||||
function switchMode(): void {
|
function switchMode(): void {
|
||||||
|
|||||||
@@ -56,9 +56,7 @@ const { tt } = useI18n();
|
|||||||
const currentValue = ref<string>(props.modelValue);
|
const currentValue = ref<string>(props.modelValue);
|
||||||
const itemPerRow = ref<number>(props.columnCount || 7);
|
const itemPerRow = ref<number>(props.columnCount || 7);
|
||||||
|
|
||||||
const allIconRows = computed<IconInfoWithId[][]>(() => {
|
const allIconRows = computed<IconInfoWithId[][]>(() => getIconsInRows(props.allIconInfos, itemPerRow.value));
|
||||||
return getIconsInRows(props.allIconInfos, itemPerRow.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
const heightClass = computed<string>(() => {
|
const heightClass = computed<string>(() => {
|
||||||
if (allIconRows.value.length > 10) {
|
if (allIconRows.value.length > 10) {
|
||||||
|
|||||||
@@ -50,9 +50,7 @@ const { tt } = useI18n();
|
|||||||
|
|
||||||
const currentPinCode = ref<string>('');
|
const currentPinCode = ref<string>('');
|
||||||
|
|
||||||
const currentPinCodeValid = computed<boolean>(() => {
|
const currentPinCodeValid = computed<boolean>(() => currentPinCode.value?.length === 6 || false);
|
||||||
return currentPinCode.value?.length === 6 || false;
|
|
||||||
});
|
|
||||||
|
|
||||||
function confirm(): void {
|
function confirm(): void {
|
||||||
if (!currentPinCodeValid.value || props.confirmDisabled) {
|
if (!currentPinCodeValid.value || props.confirmDisabled) {
|
||||||
|
|||||||
@@ -210,8 +210,6 @@ import { ThemeType } from '@/core/theme.ts';
|
|||||||
import { isUserScheduledTransactionEnabled } from '@/lib/server_settings.ts';
|
import { isUserScheduledTransactionEnabled } from '@/lib/server_settings.ts';
|
||||||
import { getSystemTheme, setExpenseAndIncomeAmountColor } from '@/lib/ui/common.ts';
|
import { getSystemTheme, setExpenseAndIncomeAmountColor } from '@/lib/ui/common.ts';
|
||||||
|
|
||||||
type SnackBarType = InstanceType<typeof SnackBar>;
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
mdiMenu,
|
mdiMenu,
|
||||||
mdiHomeOutline,
|
mdiHomeOutline,
|
||||||
@@ -235,6 +233,8 @@ import {
|
|||||||
mdiLogout
|
mdiLogout
|
||||||
} from '@mdi/js';
|
} from '@mdi/js';
|
||||||
|
|
||||||
|
type SnackBarType = InstanceType<typeof SnackBar>;
|
||||||
|
|
||||||
const display = useDisplay();
|
const display = useDisplay();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
@@ -277,21 +277,11 @@ const showVerticalOverlayMenu = ref<boolean>(false);
|
|||||||
const showLoading = ref<boolean>(false);
|
const showLoading = ref<boolean>(false);
|
||||||
const showMobileQrCode = ref<boolean>(false);
|
const showMobileQrCode = ref<boolean>(false);
|
||||||
|
|
||||||
const mdAndDown = computed<boolean>(() => {
|
const mdAndDown = computed<boolean>(() => display.mdAndDown.value);
|
||||||
return display.mdAndDown.value;
|
const currentRoutePath = computed<string>(() => route.path);
|
||||||
});
|
|
||||||
|
|
||||||
const currentRoutePath = computed<string>(() => {
|
const currentNickName = computed<string>(() => userStore.currentUserNickname || tt('User'));
|
||||||
return route.path;
|
const currentUserAvatar = computed<string | null>(() => userStore.getUserAvatarUrl(userStore.currentUserBasicInfo, true));
|
||||||
});
|
|
||||||
|
|
||||||
const currentNickName = computed<string>(() => {
|
|
||||||
return userStore.currentUserNickname || tt('User');
|
|
||||||
});
|
|
||||||
|
|
||||||
const currentUserAvatar = computed<string | null>(() => {
|
|
||||||
return userStore.getUserAvatarUrl(userStore.currentUserBasicInfo, true);
|
|
||||||
});
|
|
||||||
|
|
||||||
const currentTheme = computed<string>({
|
const currentTheme = computed<string>({
|
||||||
get: () => {
|
get: () => {
|
||||||
@@ -310,9 +300,7 @@ const currentTheme = computed<string>({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const isEnableApplicationLock = computed<boolean>(() => {
|
const isEnableApplicationLock = computed<boolean>(() => settingsStore.appSettings.applicationLock);
|
||||||
return settingsStore.appSettings.applicationLock;
|
|
||||||
});
|
|
||||||
|
|
||||||
function handleNavScroll(e: Event): void {
|
function handleNavScroll(e: Event): void {
|
||||||
isVerticalNavScrolled.value = (e.target as HTMLElement).scrollTop > 0;
|
isVerticalNavScrolled.value = (e.target as HTMLElement).scrollTop > 0;
|
||||||
|
|||||||
@@ -98,9 +98,7 @@ const pinCode = ref<string>('');
|
|||||||
const enablingWebAuthn = ref<boolean>(false);
|
const enablingWebAuthn = ref<boolean>(false);
|
||||||
const transactionsStore = useTransactionsStore();
|
const transactionsStore = useTransactionsStore();
|
||||||
|
|
||||||
const pinCodeValid = computed<boolean>(() => {
|
const pinCodeValid = computed<boolean>(() => pinCode.value?.length === 6 || false);
|
||||||
return pinCode.value?.length === 6 || false;
|
|
||||||
});
|
|
||||||
|
|
||||||
function confirm(): void {
|
function confirm(): void {
|
||||||
if (isEnableApplicationLock.value) {
|
if (isEnableApplicationLock.value) {
|
||||||
|
|||||||
@@ -410,9 +410,7 @@ const avatarUrl = ref<string>('');
|
|||||||
const avatarProvider = ref<string | undefined>('');
|
const avatarProvider = ref<string | undefined>('');
|
||||||
const avatarNoCacheId = ref<string>('');
|
const avatarNoCacheId = ref<string>('');
|
||||||
|
|
||||||
const currentUserAvatar = computed<string | null>(() => {
|
const currentUserAvatar = computed<string | null>(() => userStore.getUserAvatarUrl(avatarUrl.value, avatarNoCacheId.value));
|
||||||
return userStore.getUserAvatarUrl(avatarUrl.value, avatarNoCacheId.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
function init(): void {
|
function init(): void {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user