diff --git a/backend/services/preferences_service.go b/backend/services/preferences_service.go index 0ef74d5..ef58fec 100644 --- a/backend/services/preferences_service.go +++ b/backend/services/preferences_service.go @@ -85,7 +85,7 @@ func (p *preferencesService) GetFontList() (resp types.JSResp) { return } -func (p *preferencesService) SetClientVersion(ver string) { +func (p *preferencesService) SetAppVersion(ver string) { if !strings.HasPrefix(ver, "v") { p.clientVersion = "v" + ver } else { @@ -93,6 +93,14 @@ func (p *preferencesService) SetClientVersion(ver string) { } } +func (p *preferencesService) GetAppVersion() (resp types.JSResp) { + resp.Success = true + resp.Data = map[string]any{ + "version": p.clientVersion, + } + return +} + type latestRelease struct { Name string `json:"name"` TagName string `json:"tag_name"` diff --git a/frontend/src/App.vue b/frontend/src/App.vue index c71774f..7fdce34 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -19,6 +19,7 @@ import { darkTheme } from 'naive-ui' import KeyFilterDialog from './components/dialogs/KeyFilterDialog.vue' import { WindowSetDarkTheme, WindowSetLightTheme } from 'wailsjs/runtime/runtime.js' import { themeOverrides } from '@/utils/theme.js' +import AboutDialog from '@/components/dialogs/AboutDialog.vue' hljs.registerLanguage('json', json) hljs.registerLanguage('plaintext', plaintext) @@ -57,9 +58,9 @@ watch( @@ -74,6 +75,7 @@ watch( + diff --git a/frontend/src/AppContent.vue b/frontend/src/AppContent.vue index 676e197..24d4bd8 100644 --- a/frontend/src/AppContent.vue +++ b/frontend/src/AppContent.vue @@ -13,7 +13,7 @@ import useConnectionStore from './stores/connections.js' import ContentLogPane from './components/content/ContentLogPane.vue' import ContentValueTab from '@/components/content/ContentValueTab.vue' import ToolbarControlWidget from '@/components/common/ToolbarControlWidget.vue' -import { WindowToggleMaximise } from 'wailsjs/runtime/runtime.js' +import { WindowIsFullscreen, WindowToggleMaximise } from 'wailsjs/runtime/runtime.js' import { isMacOS } from '@/utils/platform.js' import iconUrl from '@/assets/images/icon.png' @@ -81,8 +81,7 @@ watch( + :style="{ backgroundColor: themeVars.bodyColor, borderRadius: WindowIsFullscreen() ? '0' : '10px' }">
- +
+import iconUrl from '@/assets/images/icon.png' +import useDialog from 'stores/dialog.js' +import { useThemeVars } from 'naive-ui' +import { BrowserOpenURL } from 'wailsjs/runtime/runtime.js' +import { GetAppVersion } from 'wailsjs/go/services/preferencesService.js' +import { ref, onMounted } from 'vue' + +const themeVars = useThemeVars() +const dialogStore = useDialog() +const version = ref('') + +onMounted(() => { + GetAppVersion().then(({ data }) => { + version.value = data.version + }) +}) + +const onOpenSource = () => { + BrowserOpenURL('https://github.com/tiny-craft/tiny-rdm') +} + +const onOpenWebsite = () => { + BrowserOpenURL('https://redis.tinycraft.cc/') +} + + + + + diff --git a/frontend/src/components/sidebar/NavMenu.vue b/frontend/src/components/sidebar/NavMenu.vue index eeb5988..7d8668f 100644 --- a/frontend/src/components/sidebar/NavMenu.vue +++ b/frontend/src/components/sidebar/NavMenu.vue @@ -73,6 +73,14 @@ const preferencesOptions = computed(() => { label: i18n.t('menu.check_update'), key: 'update', }, + { + type: 'divider', + key: 'd1', + }, + { + label: i18n.t('menu.about'), + key: 'about', + }, ] }) @@ -90,6 +98,9 @@ const onSelectPreferenceMenu = (key) => { case 'update': preferencesStore.checkForUpdate(true) break + case 'about': + dialogStore.openAboutDialog() + break } } diff --git a/frontend/src/langs/en.json b/frontend/src/langs/en.json index 169da8b..2d6ecc4 100644 --- a/frontend/src/langs/en.json +++ b/frontend/src/langs/en.json @@ -181,6 +181,10 @@ "download_now": "Download", "later": "Later", "skip": "Skip This Update" + }, + "about": { + "source": "Source Code", + "website": "Official Website" } }, "menu": { @@ -190,7 +194,8 @@ "close": "Close", "preferences": "Preferences", "help": "Help", - "check_update": "Check for Updates..." + "check_update": "Check for Updates...", + "about": "About" }, "log": { "launch_log": "Launch Log", diff --git a/frontend/src/langs/zh-cn.json b/frontend/src/langs/zh-cn.json index 2dd0761..dd4adae 100644 --- a/frontend/src/langs/zh-cn.json +++ b/frontend/src/langs/zh-cn.json @@ -182,6 +182,10 @@ "download_now": "立即下载", "later": "稍后提醒我", "skip": "忽略本次更新" + }, + "about": { + "source": "源码地址", + "website": "官方网站" } }, "menu": { @@ -191,7 +195,8 @@ "close": "关闭", "preferences": "偏好设置", "help": "帮助", - "check_update": "检查更新..." + "check_update": "检查更新...", + "about": "关于" }, "log": { "launch_log": "运行日志", diff --git a/frontend/src/main.js b/frontend/src/main.js index 4036780..848aa21 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -1,5 +1,5 @@ import { createPinia } from 'pinia' -import { createApp } from 'vue' +import { createApp, nextTick } from 'vue' import App from './App.vue' import './styles/style.scss' import dayjs from 'dayjs' @@ -24,15 +24,16 @@ async function setupApp() { await setupDiscreteApi() app.config.errorHandler = (err, instance, info) => { // TODO: add "send error message to author" later - try { - const content = err.toString() - $notification.error({ - title: i18n.global.t('common.error'), - content, - // meta: err.stack, - }) - console.error(err) - } catch (e) {} + nextTick().then(() => { + try { + const content = err.toString() + $notification.error(content, { + title: i18n.global.t('common.error'), + meta: 'Please see console output for more detail', + }) + console.error(err) + } catch (e) {} + }) } app.config.warnHandler = (message) => { console.warn(message) diff --git a/frontend/src/stores/dialog.js b/frontend/src/stores/dialog.js index 5254546..6fc281a 100644 --- a/frontend/src/stores/dialog.js +++ b/frontend/src/stores/dialog.js @@ -66,6 +66,7 @@ const useDialogStore = defineStore('dialog', { ttlDialogVisible: false, preferencesDialogVisible: false, + aboutDialogVisible: false, }), actions: { openNewDialog() { @@ -211,6 +212,13 @@ const useDialogStore = defineStore('dialog', { closePreferencesDialog() { this.preferencesDialogVisible = false }, + + openAboutDialog() { + this.aboutDialogVisible = true + }, + closeAboutDialog() { + this.aboutDialogVisible = false + }, }, }) diff --git a/main.go b/main.go index 2f25343..a9605ca 100644 --- a/main.go +++ b/main.go @@ -27,13 +27,14 @@ func main() { app := NewApp() connSvc := services.Connection() prefSvc := services.Preferences() - prefSvc.SetClientVersion(version) + prefSvc.SetAppVersion(version) // menu appMenu := menu.NewMenu() if runtime.GOOS == "darwin" { appMenu.Append(menu.AppMenu()) appMenu.Append(menu.EditMenu()) + appMenu.Append(menu.WindowMenu()) } // Create application with options