From 722d9945369506b3f2f795656654ba1c8e796462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BC=8A=E5=A2=A8?= <1905672206@qq.com> Date: Sun, 2 Aug 2026 13:43:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=8B=96=E6=94=BE?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E4=B8=AD=E4=BD=8D=E7=BD=AE=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../preference/components/model/components/upload/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/preference/components/model/components/upload/index.vue b/src/pages/preference/components/model/components/upload/index.vue index 5d037a043..87fb8be4b 100644 --- a/src/pages/preference/components/model/components/upload/index.vue +++ b/src/pages/preference/components/model/components/upload/index.vue @@ -28,7 +28,7 @@ onMounted(() => { const { type } = payload if (type === 'over') { - const { x, y } = payload.position + const { x, y } = payload.position.toLogical(devicePixelRatio) if (dropRef.value) { const { left, right, top, bottom } = dropRef.value.getBoundingClientRect() From c3287f023cb816e796fd6ffc0c745deec71a8f21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BC=8A=E5=A2=A8?= <1905672206@qq.com> Date: Sun, 2 Aug 2026 14:20:20 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E4=BC=98=E5=85=88=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=20appWindow.scaleFactor=20=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=83=8F=E7=B4=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/composables/useWindowState.ts | 9 ++++++++- .../components/model/components/upload/index.vue | 10 ++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/composables/useWindowState.ts b/src/composables/useWindowState.ts index ef2f4d6be..12b65d9dc 100644 --- a/src/composables/useWindowState.ts +++ b/src/composables/useWindowState.ts @@ -1,4 +1,5 @@ import type { Event } from '@tauri-apps/api/event' +import type { ScaleFactorChanged } from '@tauri-apps/api/window' import { PhysicalPosition, PhysicalSize } from '@tauri-apps/api/dpi' import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow' @@ -12,7 +13,7 @@ import { useAppStore } from '@/stores/app' import { useCatStore } from '@/stores/cat' import { getCursorMonitor } from '@/utils/monitor' -export type WindowState = Record | undefined> +export type WindowState = Record> | undefined> const appWindow = getCurrentWebviewWindow() const { label } = appWindow @@ -28,6 +29,7 @@ export function useWindowState() { appWindow.onResized(onChange) appWindow.onScaleChanged(clampToMonitor) + appWindow.onScaleChanged(onSacleChanged) }) const clampToMonitor = useDebounceFn(async () => { @@ -54,6 +56,11 @@ export function useWindowState() { return appWindow.setPosition(new PhysicalPosition(clampedX, clampedY)) }, 500) + const onSacleChanged = (event: Event) => { + appStore.windowState[label] ??= {} + appStore.windowState[label].scaleFactor = event.payload.scaleFactor + } + watch(() => catStore.window.keepInScreen, clampToMonitor) const onChange = async (event: Event) => { diff --git a/src/pages/preference/components/model/components/upload/index.vue b/src/pages/preference/components/model/components/upload/index.vue index 87fb8be4b..2c5ef1dd3 100644 --- a/src/pages/preference/components/model/components/upload/index.vue +++ b/src/pages/preference/components/model/components/upload/index.vue @@ -6,12 +6,13 @@ import { open } from '@tauri-apps/plugin-dialog' import { readDir } from '@tauri-apps/plugin-fs' import { message } from 'antdv-next' import { nanoid } from 'nanoid' -import { onMounted, ref, useTemplateRef, watch } from 'vue' +import { computed, onMounted, ref, useTemplateRef, watch } from 'vue' import { useI18n } from 'vue-i18n' import type { ModelMode } from '@/stores/model' import { INVOKE_KEY } from '@/constants' +import { useAppStore } from '@/stores/app' import { useModelStore } from '@/stores/model' import { join } from '@/utils/path' @@ -19,16 +20,17 @@ const dropRef = useTemplateRef('drop') const dragenter = ref(false) const selectPaths = ref([]) const modelStore = useModelStore() +const appStore = useAppStore() const { t } = useI18n() +const appWindow = getCurrentWebviewWindow() +const scaleFactor = computed(() => appStore.windowState[appWindow.label]?.scaleFactor ?? devicePixelRatio) onMounted(() => { - const appWindow = getCurrentWebviewWindow() - appWindow.onDragDropEvent(({ payload }) => { const { type } = payload if (type === 'over') { - const { x, y } = payload.position.toLogical(devicePixelRatio) + const { x, y } = payload.position.toLogical(scaleFactor.value) if (dropRef.value) { const { left, right, top, bottom } = dropRef.value.getBoundingClientRect() From f398c4daf6d8cb99ded6419e5990703647a84a41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BC=8A=E5=A2=A8?= <1905672206@qq.com> Date: Sun, 2 Aug 2026 14:26:30 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20onScaleChanged?= =?UTF-8?q?=20=E5=87=BD=E6=95=B0=E5=90=8D=E7=A7=B0=E6=8B=BC=E5=86=99?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/composables/useWindowState.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/composables/useWindowState.ts b/src/composables/useWindowState.ts index 12b65d9dc..bbfb1d1e4 100644 --- a/src/composables/useWindowState.ts +++ b/src/composables/useWindowState.ts @@ -29,7 +29,7 @@ export function useWindowState() { appWindow.onResized(onChange) appWindow.onScaleChanged(clampToMonitor) - appWindow.onScaleChanged(onSacleChanged) + appWindow.onScaleChanged(onScaleChanged) }) const clampToMonitor = useDebounceFn(async () => { @@ -56,7 +56,7 @@ export function useWindowState() { return appWindow.setPosition(new PhysicalPosition(clampedX, clampedY)) }, 500) - const onSacleChanged = (event: Event) => { + const onScaleChanged = (event: Event) => { appStore.windowState[label] ??= {} appStore.windowState[label].scaleFactor = event.payload.scaleFactor }