code refactor
This commit is contained in:
@@ -26,8 +26,8 @@ const props = defineProps<{
|
|||||||
|
|
||||||
const { tt, getCurrentLanguageInfo } = useI18n();
|
const { tt, getCurrentLanguageInfo } = useI18n();
|
||||||
|
|
||||||
const mapContainer: Ref<HTMLElement> = useTemplateRef('mapContainer');
|
const mapContainer: Ref<HTMLElement | null> = useTemplateRef('mapContainer');
|
||||||
const mapInstance: Ref<MapInstance> = ref(createMapInstance());
|
const mapInstance: Ref<MapInstance | null> = ref(createMapInstance());
|
||||||
const initCenter: Ref<MapPosition> = ref({
|
const initCenter: Ref<MapPosition> = ref({
|
||||||
latitude: 0,
|
latitude: 0,
|
||||||
longitude: 0
|
longitude: 0
|
||||||
@@ -39,11 +39,11 @@ const mapSupported = computed<boolean>(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const mapDependencyLoaded = computed<boolean>(() => {
|
const mapDependencyLoaded = computed<boolean>(() => {
|
||||||
return mapInstance.value && mapInstance.value.dependencyLoaded;
|
return mapInstance.value?.dependencyLoaded || false;
|
||||||
});
|
});
|
||||||
|
|
||||||
const finalMapStyle = computed<Record<string, string>>(() => {
|
const finalMapStyle = computed<Record<string, unknown>>(() => {
|
||||||
const styles = copyObjectTo(props.mapStyle, {});
|
const styles: Record<string, unknown> = copyObjectTo(props.mapStyle, {});
|
||||||
|
|
||||||
if (props.height) {
|
if (props.height) {
|
||||||
styles.height = props.height;
|
styles.height = props.height;
|
||||||
@@ -60,7 +60,7 @@ function init() {
|
|||||||
let isFirstInit = false;
|
let isFirstInit = false;
|
||||||
let centerChanged = false;
|
let centerChanged = false;
|
||||||
|
|
||||||
if (!mapSupported.value || !mapDependencyLoaded.value) {
|
if (!mapSupported.value || !mapDependencyLoaded.value || !mapInstance.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ function init() {
|
|||||||
if (!mapInstance.value.inited) {
|
if (!mapInstance.value.inited) {
|
||||||
const languageInfo = getCurrentLanguageInfo();
|
const languageInfo = getCurrentLanguageInfo();
|
||||||
|
|
||||||
mapInstance.value.initMapInstance(mapContainer.value, {
|
mapInstance.value.initMapInstance(mapContainer.value as HTMLElement, {
|
||||||
language: languageInfo?.alternativeLanguageTag,
|
language: languageInfo?.alternativeLanguageTag,
|
||||||
initCenter: initCenter.value,
|
initCenter: initCenter.value,
|
||||||
zoomLevel: zoomLevel.value,
|
zoomLevel: zoomLevel.value,
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ const emit = defineEmits<{
|
|||||||
(e: 'info:copied'): void
|
(e: 'info:copied'): void
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const iconCopyToClipboard: Ref<HTMLElement> = useTemplateRef('copyToClipboardIcon');
|
const iconCopyToClipboard: Ref<unknown> = useTemplateRef('copyToClipboardIcon');
|
||||||
|
|
||||||
let clipboardHolder: ClipboardHolder = null;
|
let clipboardHolder: ClipboardHolder | null = null;
|
||||||
|
|
||||||
function makeCopyToClipboardClickable() {
|
function makeCopyToClipboardClickable() {
|
||||||
if (clipboardHolder) {
|
if (clipboardHolder) {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const { style, getAccountIcon, getCategoryIcon } = useItemIcon(props);
|
|||||||
|
|
||||||
const f7IconValue = computed<string>(() => {
|
const f7IconValue = computed<string>(() => {
|
||||||
if (props.iconType === 'fixed-f7') {
|
if (props.iconType === 'fixed-f7') {
|
||||||
return props.iconId;
|
return props.iconId.toString();
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ const icon = computed<string>(() => {
|
|||||||
} else if (props.iconType === 'category') {
|
} else if (props.iconType === 'category') {
|
||||||
return getCategoryIcon(props.iconId);
|
return getCategoryIcon(props.iconId);
|
||||||
} else if (props.iconType === 'fixed') {
|
} else if (props.iconType === 'fixed') {
|
||||||
return props.iconId;
|
return props.iconId.toString();
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user