diff --git a/.eslintrc-auto-import.json b/.eslintrc-auto-import.json index e5d49c5..2e26b7a 100644 --- a/.eslintrc-auto-import.json +++ b/.eslintrc-auto-import.json @@ -86,6 +86,7 @@ "readonly": true, "ref": true, "request": true, + "resizeWindow": true, "resolveComponent": true, "saveImage": true, "saveImageFromBase64": true, diff --git a/src/components/Settings/components/Modal.vue b/src/components/Settings/components/Modal.vue index 0b43b2c..b16a8b8 100644 --- a/src/components/Settings/components/Modal.vue +++ b/src/components/Settings/components/Modal.vue @@ -20,7 +20,7 @@ watch( ([newValue]) => { if (newValue.length !== 51) return - getCredit() + // getCredit() }, { immediate: true @@ -77,7 +77,8 @@ watch(
-
账户余额:$ {{ usedCredit }} / {{ totalCredit }}
+ +
余额查询暂不可用
温馨提示:软件使用 gpt-3.5-turbo-0301 模型
diff --git a/src/hooks/useInit.ts b/src/hooks/useInit.ts index 619d77d..01c7536 100644 --- a/src/hooks/useInit.ts +++ b/src/hooks/useInit.ts @@ -12,6 +12,8 @@ export const useInit = () => { invoke('close_splashscreen') + resizeWindow() + useObserverLink() useDisableShortcuts() @@ -24,6 +26,12 @@ export const useInit = () => { }, 100) }) + // 监听显示设备变化时,重置窗口位置到中间,以防止窗口位置偏移到屏幕外 + appWindow.onScaleChanged(() => { + resizeWindow() + appWindow.center() + }) + if (import.meta.env.PROD) { document.addEventListener('contextmenu', function (event) { if (!window.getSelection()?.toString()) { diff --git a/src/stores/settings.ts b/src/stores/settings.ts index c070478..f0a6a64 100644 --- a/src/stores/settings.ts +++ b/src/stores/settings.ts @@ -120,11 +120,6 @@ export const useSettingsStore = defineStore( autoStart.value ? enable() : disable() }) - // 监听显示设备变化时,重置窗口位置到中间,以防止窗口位置偏移到屏幕外 - appWindow.onScaleChanged(() => { - appWindow.center() - }) - return { themeMode, uuid, diff --git a/src/utils/saveMarkdown.ts b/src/utils/saveMarkdown.ts index 56eb8df..7facabf 100644 --- a/src/utils/saveMarkdown.ts +++ b/src/utils/saveMarkdown.ts @@ -1,10 +1,9 @@ +import { getName } from '@tauri-apps/api/app' import { writeTextFile, BaseDirectory } from '@tauri-apps/api/fs' export const saveMarkdown = throttle(async (content: any) => { try { - const { currentSession } = useSessionStore() - - const file = `${currentSession?.title.slice(0, 10)}-${Date.now()}.md` + const file = `${await getName()}-${Date.now()}.md` await writeTextFile(file, content?.prompt || content, { dir: BaseDirectory.Download diff --git a/src/utils/tauri.ts b/src/utils/tauri.ts index 2ca5e62..67ba1e0 100644 --- a/src/utils/tauri.ts +++ b/src/utils/tauri.ts @@ -1,8 +1,9 @@ import { invoke } from '@tauri-apps/api/tauri' import { downloadDir } from '@tauri-apps/api/path' import { type } from '@tauri-apps/api/os' -import { appWindow } from '@tauri-apps/api/window' +import { appWindow, PhysicalSize } from '@tauri-apps/api/window' import { hide, show } from '@tauri-apps/api/app' +import { currentMonitor } from '@tauri-apps/api/window' /** * 打开文件所在位置 @@ -43,3 +44,14 @@ export const hideWindow = async () => { appWindow.hide() } } + +export const resizeWindow = async () => { + const monitor = await currentMonitor() + + if (!monitor) return + + const resizeHeight = Math.ceil(monitor.size.height * (600 / 1080)) + const resizeWidth = Math.ceil(resizeHeight * 1.3) + + appWindow.setSize(new PhysicalSize(resizeWidth, resizeHeight)) +}