Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: window wake up support for last position #30

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: window wake up support for last position
  • Loading branch information
ayangweb committed Mar 20, 2023
commit f99ba241e8f053bf71e75d753328df15a1b8ff11
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chat_gpt"
version = "0.0.1"
version = "0.0.2"
description = "ChatGPT-Desktop"
authors = ["orangelckc", "bilibili-ayang"]
license = "MIT"
Expand Down
6 changes: 4 additions & 2 deletions src/components/Function/components/SettingsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import ShortcutKey from './ShortcutKey.vue'
defineProps<{ visible: boolean; setVisible: () => void }>()
const { apiKey, autoStart, isMemory } = storeToRefs(useSettingsStore())
const { apiKey, autoStart, isMemory, isRememberPosition } = storeToRefs(
useSettingsStore()
)
</script>

<template>
Expand All @@ -22,7 +24,7 @@ const { apiKey, autoStart, isMemory } = storeToRefs(useSettingsStore())
<div class="flex flex-col gap-6">
<div class="flex gap-2">
<a-checkbox v-model="autoStart">开机自启动</a-checkbox>
<!-- <a-checkbox>隐藏菜单栏图标</a-checkbox> -->
<a-checkbox v-model="isRememberPosition">记住上次窗口位置</a-checkbox>
</div>

<!-- 热键绑定 -->
Expand Down
13 changes: 10 additions & 3 deletions src/stores/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export const useSettingsStore = defineStore(
// 记忆对话
const isMemory = ref(false)

// 是否记住上次位置
const isRememberPosition = ref(false)

// 切换主题
const toggleTheme = () => {
themeMode.value =
Expand All @@ -49,8 +52,10 @@ export const useSettingsStore = defineStore(
register(shortcutKeys.value.join('+'), () => {
// 如果窗口已经显示,就隐藏
if (!windowFocused.value) {
// 窗口打开时居中
appWindow.center()
// 窗口打开时居中还是上次位置
if (!isRememberPosition.value) {
appWindow.center()
}
appWindow.show()
appWindow.setFocus()
} else {
Expand Down Expand Up @@ -112,6 +117,7 @@ export const useSettingsStore = defineStore(
isBinding,
autoStart,
isMemory,
isRememberPosition,
toggleTheme
}
},
Expand All @@ -123,7 +129,8 @@ export const useSettingsStore = defineStore(
'apiKey',
'shortcutKeys',
'autoStart',
'isMemory'
'isMemory',
'isRememberPosition'
]
}
}
Expand Down