Skip to content

Commit

Permalink
feat: window wake up support for last position (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayangweb committed Mar 20, 2023
1 parent 5e9a6e5 commit bcc0cac
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
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

0 comments on commit bcc0cac

Please sign in to comment.