32 lines
788 B
JavaScript
32 lines
788 B
JavaScript
import { ref, onMounted } from 'vue';
|
|
import zoomAdapter from '../utils/zoomAdapter.js';
|
|
|
|
/**
|
|
* 简化版缩放适配组合式函数
|
|
*/
|
|
export function useZoomAdapter() {
|
|
const currentZoom = ref(1);
|
|
const isTooHighZoom = ref(false);
|
|
|
|
const handleZoomChange = (event) => {
|
|
const { zoom } = event.detail;
|
|
currentZoom.value = zoom;
|
|
isTooHighZoom.value = zoom > 3;
|
|
};
|
|
|
|
onMounted(() => {
|
|
if (!zoomAdapter.isInitialized) {
|
|
zoomAdapter.init();
|
|
}
|
|
window.addEventListener('zoomChanged', handleZoomChange);
|
|
});
|
|
|
|
return {
|
|
currentZoom,
|
|
isTooHighZoom,
|
|
getZoomAdaptiveClass: () => ({
|
|
'zoom-adaptive': true,
|
|
'too-high-zoom': isTooHighZoom.value
|
|
})
|
|
};
|
|
}
|