Skip to content

Commit 732bf5c

Browse files
committed
fix(settings): consolidate About and use the runtime app version
1 parent 4a79c1a commit 732bf5c

11 files changed

Lines changed: 316 additions & 153 deletions

File tree

‎DESIGN.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ Interactive components must cover default, hover, focus-visible, active / select
233233

234234
### Forms, connection settings, and dialogs
235235

236-
- Settings opens on General, grouping theme, application updates, and Account & Plan. Keep account controls in this first category rather than a separate settings tab.
236+
- Settings opens on General, grouping theme, application updates, and Account & Plan. Keep account controls in this first category, with About at the bottom after Account & Plan. About reads the running Tauri app version, with the package version as a browser fallback. Opening General checks for updates without starting installation; show checking, available, current, and failure states beside the version. Keep repository and website links; omit unmaintained community links.
237237
- Reuse 32px Input / Select controls and the existing label / helper / error structure. Placeholders do not replace labels.
238238
- Group host, port, authentication, database, and related fields by task. Progressively reveal advanced SSL / SSH settings, retaining the conditional-field behavior in [SSL_UI_DESIGN.md](docs/SSL_UI_DESIGN.md).
239239
- Place validation near the field and explain the cause and remedy. Preserve entered content after failure; handle sensitive values under existing security policies.

‎src-tauri/src/commands/mod.rs‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,3 @@ pub use query::*;
1818
pub use server::*;
1919
pub use store::*;
2020
pub use transfer::*;
21-
22-
/// Returns the current app version from Cargo.toml.
23-
#[tauri::command]
24-
pub fn get_app_version() -> String {
25-
env!("CARGO_PKG_VERSION").to_string()
26-
}

‎src-tauri/src/lib.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ pub fn run() {
389389
commands::auto_map_migration_columns,
390390
commands::generate_ddl_for_objects,
391391
commands::execute_sql_content,
392-
commands::get_app_version,
393392
crate::consume_pending_auth,
394393
crate::entitlement::refresh_entitlement,
395394
crate::entitlement::get_entitlement,
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<script setup lang="ts">
2+
import { getVersion } from '@tauri-apps/api/app'
3+
import { computed, onMounted, ref } from 'vue'
4+
import { useI18n } from 'vue-i18n'
5+
import { SettingsFeedback } from '@/components/settings'
6+
import { Button } from '@/components/ui/button'
7+
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
8+
import { useAppUpdater } from '@/composables/useAppUpdater'
9+
import { version as buildVersion } from '../../../../package.json'
10+
11+
const { t } = useI18n()
12+
const version = ref(buildVersion)
13+
const {
14+
checkForUpdates,
15+
downloadAndInstall,
16+
isChecking,
17+
isDownloading,
18+
isInstalling,
19+
updateAvailable,
20+
updateInfo,
21+
downloadProgress,
22+
updateError,
23+
isRestarting,
24+
isUpToDate,
25+
} = useAppUpdater()
26+
27+
const busy = computed(() => isChecking.value || isDownloading.value || isInstalling.value || isRestarting.value)
28+
const updateLabel = computed(() => {
29+
if (isRestarting.value)
30+
return t('updater.restarting')
31+
if (isInstalling.value)
32+
return t('pages.settings.updates.installing')
33+
if (isDownloading.value)
34+
return downloadProgress.value === null ? t('updater.downloading') : t('updater.downloadingPercent', { percent: downloadProgress.value })
35+
if (isChecking.value)
36+
return t('pages.settings.updates.checking')
37+
return updateAvailable.value ? t('updater.updateNow') : t('pages.settings.updates.check')
38+
})
39+
const feedbackLabel = computed(() => {
40+
if (updateError.value)
41+
return t('pages.settings.feedback.failed')
42+
if (busy.value)
43+
return updateLabel.value
44+
return updateAvailable.value
45+
? t('updater.newVersion', { version: updateInfo.value?.version })
46+
: t('updater.upToDate')
47+
})
48+
49+
const handleUpdate = async () => {
50+
if (updateAvailable.value)
51+
await downloadAndInstall()
52+
else
53+
await checkForUpdates(true, { includeSkipped: true })
54+
}
55+
56+
onMounted(() => {
57+
getVersion().then(value => version.value = value).catch(() => {})
58+
void checkForUpdates(false, { includeSkipped: true })
59+
})
60+
</script>
61+
62+
<template>
63+
<Card>
64+
<CardHeader>
65+
<CardTitle>{{ t('pages.settings.about.title') }}</CardTitle>
66+
<CardDescription>{{ t('pages.settings.about.description') }}</CardDescription>
67+
</CardHeader>
68+
<CardContent class="space-y-5">
69+
<div class="flex flex-wrap gap-3 items-center justify-between">
70+
<div class="space-y-1">
71+
<p class="text-sm font-medium flex gap-2 items-center">
72+
{{ t('pages.settings.about.version') }}
73+
<span class="text-muted-foreground font-mono">{{ version }}</span>
74+
</p>
75+
<p class="text-xs text-muted-foreground max-w-lg">
76+
{{ t('pages.settings.updates.checkForUpdatesHelp') }}
77+
</p>
78+
</div>
79+
<Button variant="outline" size="sm" :disabled="busy" @click="handleUpdate">
80+
<span v-if="busy" class="i-carbon-circle-dash mr-2 shrink-0 h-4 w-4 animate-spin" aria-hidden="true" />
81+
{{ updateLabel }}
82+
</Button>
83+
</div>
84+
<SettingsFeedback
85+
v-if="busy || updateError || (isUpToDate && !updateAvailable)"
86+
:state="updateError ? 'error' : busy ? 'pending' : 'success'"
87+
:label="feedbackLabel"
88+
:detail="updateError"
89+
:progress="isDownloading ? downloadProgress : null"
90+
/>
91+
<p v-if="updateAvailable && !busy && !updateError" class="text-sm text-primary-text" role="status">
92+
{{ feedbackLabel }}
93+
</p>
94+
<div class="text-sm flex gap-3 items-center justify-between">
95+
<span class="font-medium">{{ t('pages.settings.about.license') }}</span>
96+
<span class="text-muted-foreground">{{ t('pages.settings.about.licenseName') }}</span>
97+
</div>
98+
<div class="border-t border-border/40" />
99+
<a
100+
href="https://github.com/geek-fun/sqlkit" target="_blank" rel="noopener noreferrer"
101+
class="text-sm p-2 rounded-md flex flex-wrap gap-2 transition-colors items-center justify-between -mx-2 hover:bg-muted/50"
102+
>
103+
<span class="font-medium">{{ t('pages.settings.about.repository') }}</span>
104+
<span class="text-muted-foreground flex gap-2 items-center">
105+
geek-fun/sqlkit <span class="i-carbon-launch h-4 w-4" aria-hidden="true" />
106+
</span>
107+
</a>
108+
<a
109+
href="https://www.geekfun.club" target="_blank" rel="noopener noreferrer"
110+
class="text-sm p-2 rounded-md flex flex-wrap gap-2 transition-colors items-center justify-between -mx-2 hover:bg-muted/50"
111+
>
112+
<span class="font-medium">{{ t('pages.settings.about.website') }}</span>
113+
<span class="text-muted-foreground flex gap-2 items-center">
114+
geekfun.club <span class="i-carbon-launch h-4 w-4" aria-hidden="true" />
115+
</span>
116+
</a>
117+
<p class="text-xs text-muted-foreground pt-2 text-center border-t border-border/40">
118+
{{ t('pages.settings.about.copyright', { year: new Date().getFullYear() }) }}
119+
</p>
120+
</CardContent>
121+
</Card>
122+
</template>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as SettingsAbout } from './SettingsAbout.vue'

‎src/composables/useAppUpdater.ts‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const skipVersion = useLocalStorage('sqlkit-skip-version', '')
1313
const updateAvailable = ref(false)
1414
const updateInfo = ref<Update | null>(null)
1515
const isChecking = ref(false)
16+
const isUpToDate = ref(false)
17+
let includeSkippedInCheck = false
1618
const isDownloading = ref(false)
1719
const isInstalling = ref(false)
1820
const isRestarting = ref(false)
@@ -34,16 +36,23 @@ const updateError = ref('')
3436
export function useAppUpdater() {
3537
const { t } = useI18n()
3638

37-
const checkForUpdates = async (showToast = false): Promise<Update | null> => {
38-
if (isChecking.value)
39+
const checkForUpdates = async (showToast = false, options: { includeSkipped?: boolean } = {}): Promise<Update | null> => {
40+
if (isChecking.value) {
41+
includeSkippedInCheck ||= !!options.includeSkipped
42+
return null
43+
}
44+
if (isDownloading.value || isInstalling.value || isRestarting.value)
3945
return null
4046

4147
try {
4248
isChecking.value = true
49+
isUpToDate.value = false
50+
includeSkippedInCheck = !!options.includeSkipped
4351
updateError.value = ''
4452
const update = await check()
53+
isUpToDate.value = !update
4554

46-
if (update && update.version !== skipVersion.value) {
55+
if (update && (includeSkippedInCheck || update.version !== skipVersion.value)) {
4756
updateAvailable.value = true
4857
updateInfo.value = update
4958

@@ -56,6 +65,8 @@ export function useAppUpdater() {
5665
return update
5766
}
5867
else {
68+
updateAvailable.value = false
69+
updateInfo.value = null
5970
if (showToast) {
6071
toast.success(t('updater.upToDate'))
6172
}
@@ -64,8 +75,7 @@ export function useAppUpdater() {
6475
}
6576
catch (error) {
6677
console.error('Failed to check for updates:', error)
67-
if (showToast)
68-
updateError.value = error instanceof Error ? error.message : String(error)
78+
updateError.value = error instanceof Error ? error.message : String(error)
6979
if (showToast) {
7080
toast.error(t('updater.checkFailed'), {
7181
description: error instanceof Error ? error.message : String(error),
@@ -140,6 +150,7 @@ export function useAppUpdater() {
140150
skipVersion.value = updateInfo.value.version
141151
}
142152
updateAvailable.value = false
153+
isUpToDate.value = false
143154
updateInfo.value = null
144155
updateError.value = ''
145156
downloadedBytes.value = 0
@@ -148,6 +159,7 @@ export function useAppUpdater() {
148159

149160
const dismissUpdate = () => {
150161
updateAvailable.value = false
162+
isUpToDate.value = false
151163
updateInfo.value = null
152164
updateError.value = ''
153165
downloadedBytes.value = 0
@@ -162,6 +174,7 @@ export function useAppUpdater() {
162174
updateAvailable,
163175
updateInfo,
164176
isChecking,
177+
isUpToDate,
165178
isDownloading,
166179
isInstalling,
167180
isRestarting,

‎src/lang/enUS.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,6 @@ export const enUS = {
603603
license: 'License',
604604
licenseName: 'Apache 2.0',
605605
repository: 'Repository',
606-
community: 'Community',
607-
discord: 'Discord',
608606
website: 'Website',
609607
copyright: '© {year} GEEKFUN. All rights reserved.',
610608
description: 'SqlKit is an agentic cross-platform SQL database GUI client. Built with Rust + Tauri.',
@@ -847,7 +845,7 @@ export const enUS = {
847845
title: 'Updates',
848846
description: 'Check for application updates',
849847
checkForUpdates: 'Check for Updates',
850-
checkForUpdatesHelp: 'Manually check for new versions',
848+
checkForUpdatesHelp: 'Checks automatically when you open General. Updates install only when you choose Update Now.',
851849
check: 'Check Now',
852850
checking: 'Checking...',
853851
downloading: 'Downloading...',

‎src/lang/zhCN.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,6 @@ export const zhCN = {
603603
license: '许可证',
604604
licenseName: 'Apache 2.0',
605605
repository: '代码仓库',
606-
community: '社区',
607-
discord: 'Discord',
608606
website: '官网',
609607
copyright: '© {year} GEEKFUN. 保留所有权利。',
610608
description: 'SqlKit 是一款智能跨平台 SQL 数据库图形化客户端。基于 Rust + Tauri 构建。',
@@ -847,7 +845,7 @@ export const zhCN = {
847845
title: '更新',
848846
description: '检查应用程序更新',
849847
checkForUpdates: '检查更新',
850-
checkForUpdatesHelp: '手动检查新版本',
848+
checkForUpdatesHelp: '打开常规设置时自动检查新版本,仅在点击“立即更新”后安装。',
851849
check: '立即检查',
852850
checking: '检查中...',
853851
upToDate: '已是最新版本',

0 commit comments

Comments
 (0)