From 061ea6aab4718f24585b5d412dc3389e0a2b552e Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sun, 5 Jan 2025 13:14:08 +0800 Subject: [PATCH] code refactor --- src/components/common/MapView.vue | 14 +++++++------- src/components/mobile/InformationSheet.vue | 4 ++-- src/components/mobile/ItemIcon.vue | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/components/common/MapView.vue b/src/components/common/MapView.vue index 4f017724..be1e109a 100644 --- a/src/components/common/MapView.vue +++ b/src/components/common/MapView.vue @@ -26,8 +26,8 @@ const props = defineProps<{ const { tt, getCurrentLanguageInfo } = useI18n(); -const mapContainer: Ref = useTemplateRef('mapContainer'); -const mapInstance: Ref = ref(createMapInstance()); +const mapContainer: Ref = useTemplateRef('mapContainer'); +const mapInstance: Ref = ref(createMapInstance()); const initCenter: Ref = ref({ latitude: 0, longitude: 0 @@ -39,11 +39,11 @@ const mapSupported = computed(() => { }); const mapDependencyLoaded = computed(() => { - return mapInstance.value && mapInstance.value.dependencyLoaded; + return mapInstance.value?.dependencyLoaded || false; }); -const finalMapStyle = computed>(() => { - const styles = copyObjectTo(props.mapStyle, {}); +const finalMapStyle = computed>(() => { + const styles: Record = copyObjectTo(props.mapStyle, {}); if (props.height) { styles.height = props.height; @@ -60,7 +60,7 @@ function init() { let isFirstInit = false; let centerChanged = false; - if (!mapSupported.value || !mapDependencyLoaded.value) { + if (!mapSupported.value || !mapDependencyLoaded.value || !mapInstance.value) { return; } @@ -85,7 +85,7 @@ function init() { if (!mapInstance.value.inited) { const languageInfo = getCurrentLanguageInfo(); - mapInstance.value.initMapInstance(mapContainer.value, { + mapInstance.value.initMapInstance(mapContainer.value as HTMLElement, { language: languageInfo?.alternativeLanguageTag, initCenter: initCenter.value, zoomLevel: zoomLevel.value, diff --git a/src/components/mobile/InformationSheet.vue b/src/components/mobile/InformationSheet.vue index eff41fc5..03696a7a 100644 --- a/src/components/mobile/InformationSheet.vue +++ b/src/components/mobile/InformationSheet.vue @@ -43,9 +43,9 @@ const emit = defineEmits<{ (e: 'info:copied'): void }>(); -const iconCopyToClipboard: Ref = useTemplateRef('copyToClipboardIcon'); +const iconCopyToClipboard: Ref = useTemplateRef('copyToClipboardIcon'); -let clipboardHolder: ClipboardHolder = null; +let clipboardHolder: ClipboardHolder | null = null; function makeCopyToClipboardClickable() { if (clipboardHolder) { diff --git a/src/components/mobile/ItemIcon.vue b/src/components/mobile/ItemIcon.vue index a8335ac2..b5e883f5 100644 --- a/src/components/mobile/ItemIcon.vue +++ b/src/components/mobile/ItemIcon.vue @@ -13,7 +13,7 @@ const { style, getAccountIcon, getCategoryIcon } = useItemIcon(props); const f7IconValue = computed(() => { if (props.iconType === 'fixed-f7') { - return props.iconId; + return props.iconId.toString(); } else { return ''; } @@ -25,7 +25,7 @@ const icon = computed(() => { } else if (props.iconType === 'category') { return getCategoryIcon(props.iconId); } else if (props.iconType === 'fixed') { - return props.iconId; + return props.iconId.toString(); } else { return ''; }