code refactor

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