From 5750170f5ea9dc011f8743c6c380a233ab388b71 Mon Sep 17 00:00:00 2001
From: tiny-craft <137850705+tiny-craft@users.noreply.github.com>
Date: Wed, 2 Aug 2023 17:13:03 +0800
Subject: [PATCH] refactor: move style files to "styles" folder fix: adjust
light/dark theme in windows
---
README.md | 4 ++--
README_zh.md | 4 ++--
backend/storage/preferences.go | 2 +-
frontend/index.html | 2 +-
frontend/src/App.vue | 4 ++++
frontend/src/AppContent.vue | 2 +-
.../src/components/content/ContentLogPane.vue | 2 +-
.../components/dialogs/PreferencesDialog.vue | 1 +
.../src/components/new_value/NewHashValue.vue | 2 +-
frontend/src/components/sidebar/NavMenu.vue | 4 ----
frontend/src/langs/en.json | 2 +-
frontend/src/langs/zh-cn.json | 2 +-
frontend/src/main.js | 4 ++--
frontend/src/stores/preferences.js | 2 +-
.../content => styles}/content.scss | 0
frontend/src/{ => styles}/style.scss | 2 +-
frontend/vite.config.js | 6 ++++++
main.go | 18 ++++++++++++++++++
wails.json | 13 ++++++++++---
19 files changed, 54 insertions(+), 22 deletions(-)
rename frontend/src/{components/content => styles}/content.scss (100%)
rename frontend/src/{ => styles}/style.scss (96%)
diff --git a/README.md b/README.md
index 7e3fa72..ed715ee 100644
--- a/README.md
+++ b/README.md
@@ -5,8 +5,8 @@ Tiny RDM is a modern lightweight cross-platform Redis desktop manager available
![](screenshots/light_en.png)
## Feature
-* Built on Webview, no embedded browsers (Thanks to Wails).
-* More elegant UI and visualized layout (Thanks to Naive UI).
+* Built on Webview, no embedded browsers (Thanks to [Wails](https://github.com/wailsapp/wails)).
+* More elegant UI and visualized layout (Thanks to [Naive UI](https://github.com/tusen-ai/naive-ui)).
* Multi-language support (Click here to contribute and support more languages).
* Convenient data viewing and editing.
* More features under continuous development...
diff --git a/README_zh.md b/README_zh.md
index 5799eb7..a27a1f1 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -6,8 +6,8 @@ Tiny RDM是一个现代化轻量级的跨平台Redis桌面客户端,支持Mac
## 功能特性
-* 基于Webview,无内嵌浏览器(感谢Wails)
-* 更精美的界面和直观的结构布局(感谢Naive UI)
+* 基于Webview,无内嵌浏览器(感谢[Wails](https://github.com/wailsapp/wails))
+* 更精美的界面和直观的结构布局(感谢[Naive UI](https://github.com/tusen-ai/naive-ui))
* 多国语言支持(点我贡献和完善多国语言支持)
* 便捷的数据查看和编辑修改
* 更多功能持续开发中…
diff --git a/backend/storage/preferences.go b/backend/storage/preferences.go
index b0912cf..d0672db 100644
--- a/backend/storage/preferences.go
+++ b/backend/storage/preferences.go
@@ -21,7 +21,7 @@ func NewPreferences() *PreferencesStorage {
func (p *PreferencesStorage) DefaultPreferences() map[string]any {
return map[string]any{
"general": map[string]any{
- "language": "en",
+ "language": "auto",
"font": "",
"font_size": 14,
"use_sys_proxy": false,
diff --git a/frontend/index.html b/frontend/index.html
index 23c8eb9..943c011 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -4,7 +4,7 @@
+
diff --git a/frontend/src/components/content/ContentLogPane.vue b/frontend/src/components/content/ContentLogPane.vue
index bf82df1..3ea2a72 100644
--- a/frontend/src/components/content/ContentLogPane.vue
+++ b/frontend/src/components/content/ContentLogPane.vue
@@ -35,7 +35,7 @@ const loadHistory = () => {
connectionStore
.getCmdHistory()
.then((list) => {
- data.history = list
+ data.history = list || []
})
.finally(() => {
data.loading = false
diff --git a/frontend/src/components/dialogs/PreferencesDialog.vue b/frontend/src/components/dialogs/PreferencesDialog.vue
index 2f5f785..c77bce8 100644
--- a/frontend/src/components/dialogs/PreferencesDialog.vue
+++ b/frontend/src/components/dialogs/PreferencesDialog.vue
@@ -63,6 +63,7 @@ const onClose = () => {
:close-on-esc="false"
:mask-closable="false"
:show-icon="false"
+ :auto-focus="false"
:title="$t('preferences')"
preset="dialog"
transform-origin="center"
diff --git a/frontend/src/components/new_value/NewHashValue.vue b/frontend/src/components/new_value/NewHashValue.vue
index 63d6572..09ec90a 100644
--- a/frontend/src/components/new_value/NewHashValue.vue
+++ b/frontend/src/components/new_value/NewHashValue.vue
@@ -25,7 +25,7 @@ const onUpdate = (val) => {
val = reject(val, { key: '' })
emit(
'update:value',
- flatMap(val, (item) => [item.key, item.value])
+ flatMap(val, (item) => [item.key, item.value]),
)
}
diff --git a/frontend/src/components/sidebar/NavMenu.vue b/frontend/src/components/sidebar/NavMenu.vue
index 6ff857a..4d159ab 100644
--- a/frontend/src/components/sidebar/NavMenu.vue
+++ b/frontend/src/components/sidebar/NavMenu.vue
@@ -68,10 +68,6 @@ const preferencesOptions = computed(() => {
key: 'help',
icon: renderIcon(Help),
},
- {
- label: i18n.t('about'),
- key: 'about',
- },
{
label: i18n.t('check_update'),
key: 'update',
diff --git a/frontend/src/langs/en.json b/frontend/src/langs/en.json
index 1e307d7..429585b 100644
--- a/frontend/src/langs/en.json
+++ b/frontend/src/langs/en.json
@@ -7,6 +7,7 @@
"warning": "Warning",
"save": "Save",
"none": "None",
+ "default": "Default",
"new_conn": "Add New Connection",
"new_group": "Add New Group",
"rename_group": "Rename Group",
@@ -135,7 +136,6 @@
"server": "Server",
"browser": "Browser",
"log": "Log",
- "about": "About",
"help": "Help",
"check_update": "Check for Updates...",
"auto_refresh": "Auto Refresh",
diff --git a/frontend/src/langs/zh-cn.json b/frontend/src/langs/zh-cn.json
index 0ddaf40..c14fac9 100644
--- a/frontend/src/langs/zh-cn.json
+++ b/frontend/src/langs/zh-cn.json
@@ -7,6 +7,7 @@
"warning": "警告",
"save": "保存",
"none": "无",
+ "default": "默认",
"new_conn": "添加新连接",
"new_group": "添加新分组",
"rename_group": "重命名分组",
@@ -137,7 +138,6 @@
"server": "服务器",
"browser": "浏览器",
"log": "日志",
- "about": "关于",
"help": "帮助",
"check_update": "检查更新...",
"auto_refresh": "自动刷新",
diff --git a/frontend/src/main.js b/frontend/src/main.js
index c7fe6de..9dd0bcc 100644
--- a/frontend/src/main.js
+++ b/frontend/src/main.js
@@ -3,7 +3,7 @@ import { createApp } from 'vue'
import { createI18n } from 'vue-i18n'
import App from './App.vue'
import { lang } from './langs'
-import './style.scss'
+import './styles/style.scss'
import dayjs from 'dayjs'
import duration from 'dayjs/plugin/duration'
import relativeTime from 'dayjs/plugin/relativeTime'
@@ -21,7 +21,7 @@ app.use(
messages: {
...lang,
},
- })
+ }),
)
app.use(createPinia())
app.mount('#app')
diff --git a/frontend/src/stores/preferences.js b/frontend/src/stores/preferences.js
index 08f8a2e..3aee42c 100644
--- a/frontend/src/stores/preferences.js
+++ b/frontend/src/stores/preferences.js
@@ -96,7 +96,7 @@ const usePreferencesStore = defineStore('preferences', {
}))
option.splice(0, 0, {
value: '',
- label: i18n.t('none'),
+ label: i18n.t('default'),
path: '',
})
return option
diff --git a/frontend/src/components/content/content.scss b/frontend/src/styles/content.scss
similarity index 100%
rename from frontend/src/components/content/content.scss
rename to frontend/src/styles/content.scss
diff --git a/frontend/src/style.scss b/frontend/src/styles/style.scss
similarity index 96%
rename from frontend/src/style.scss
rename to frontend/src/styles/style.scss
index df9856d..196c185 100644
--- a/frontend/src/style.scss
+++ b/frontend/src/styles/style.scss
@@ -28,7 +28,7 @@ body {
font-style: normal;
font-weight: 400;
src: local(""),
- url("assets/fonts/nunito-v16-latin-regular.woff2") format("woff2");
+ url("../assets/fonts/nunito-v16-latin-regular.woff2") format("woff2");
}
#app {
diff --git a/frontend/vite.config.js b/frontend/vite.config.js
index 9c141c8..3fcbf95 100644
--- a/frontend/vite.config.js
+++ b/frontend/vite.config.js
@@ -5,6 +5,7 @@ import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'
import { defineConfig } from 'vite'
+const rootPath = new URL('.', import.meta.url).pathname
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
@@ -21,4 +22,9 @@ export default defineConfig({
}),
Icons(),
],
+ resolve: {
+ alias: {
+ '@': rootPath + 'src',
+ },
+ },
})
diff --git a/main.go b/main.go
index daec7b3..773c61e 100644
--- a/main.go
+++ b/main.go
@@ -4,21 +4,33 @@ import (
"context"
"embed"
"github.com/wailsapp/wails/v2"
+ "github.com/wailsapp/wails/v2/pkg/menu"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"github.com/wailsapp/wails/v2/pkg/options/mac"
+ "runtime"
"tinyrdm/backend/services"
)
//go:embed all:frontend/dist
var assets embed.FS
+//go:embed build/appicon.png
+var icon []byte
+
func main() {
// Create an instance of the app structure
app := NewApp()
connSvc := services.Connection()
prefSvc := services.Preferences()
+ // menu
+ appMenu := menu.NewMenu()
+ if runtime.GOOS == "darwin" {
+ appMenu.Append(menu.AppMenu())
+ appMenu.Append(menu.EditMenu())
+ }
+
// Create application with options
err := wails.Run(&options.App{
Title: "Tiny RDM",
@@ -26,6 +38,7 @@ func main() {
Height: 768,
MinWidth: 1024,
MinHeight: 768,
+ Menu: appMenu,
AssetServer: &assetserver.Options{
Assets: assets,
},
@@ -51,6 +64,11 @@ func main() {
UseToolbar: false,
HideToolbarSeparator: true,
},
+ About: &mac.AboutInfo{
+ Title: "Tiny RDM",
+ Message: "Copyright © 2023",
+ Icon: icon,
+ },
//WebviewIsTransparent: true,
//WindowIsTranslucent: true,
},
diff --git a/wails.json b/wails.json
index 04266cc..d9803d6 100644
--- a/wails.json
+++ b/wails.json
@@ -1,13 +1,20 @@
{
"$schema": "https://wails.io/schemas/config.v2.json",
"name": "Tiny RDM",
- "outputfilename": "tiny-rdm",
+ "outputfilename": "Tiny RDM",
"frontend:install": "npm install",
"frontend:build": "npm run build",
"frontend:dev:watcher": "npm run dev",
"frontend:dev:serverUrl": "auto",
"author": {
- "name": "Lykin",
- "email": "huangliu3060@qq.com"
+ "name": "tiny-craft",
+ "email": "lykinhuang@outlook.com"
+ },
+ "info": {
+ "companyName": "Tiny Craft",
+ "productName": "Tiny RDM",
+ "productVersion": "1.0.0",
+ "copyright": "Copyright © 2023",
+ "comments": "Tiny Redis Desktop Manager"
}
}