From d19a906dd26f6100cae9bf398f052a3050e7f287 Mon Sep 17 00:00:00 2001 From: jinyaoMa Date: Tue, 27 Sep 2022 22:28:13 -0400 Subject: [PATCH] . --- backend/services/settings.go | 22 +++++++++++++++++++ backend/tray/listeners.go | 18 +++++---------- .../components/menu/src/menu-group.vue | 15 +++++++------ frontend/src/App.vue | 5 ++++- frontend/src/router/index.ts | 9 +++++--- frontend/src/views/About.vue | 17 ++++++++++++++ frontend/src/views/Home.vue | 17 ++++++++++++++ frontend/src/views/Settings.vue | 22 +++++++++++++++++++ 8 files changed, 101 insertions(+), 24 deletions(-) create mode 100644 backend/services/settings.go create mode 100644 frontend/src/views/About.vue create mode 100644 frontend/src/views/Home.vue create mode 100644 frontend/src/views/Settings.vue diff --git a/backend/services/settings.go b/backend/services/settings.go new file mode 100644 index 0000000..991faca --- /dev/null +++ b/backend/services/settings.go @@ -0,0 +1,22 @@ +package services + +import ( + "my-app/backend/app" + "my-app/backend/model" +) + +func SaveColorThemeOption(theme string) error { + option := model.MyOption{ + Name: app.CfgColorTheme, + } + result := option.Update(theme) + return result.Error +} + +func SaveDisplayLanguageOption(lang string) error { + option := model.MyOption{ + Name: app.CfgDisplayLanguage, + } + result := option.Update(lang) + return result.Error +} diff --git a/backend/tray/listeners.go b/backend/tray/listeners.go index f3c94c4..cdf0046 100644 --- a/backend/tray/listeners.go +++ b/backend/tray/listeners.go @@ -3,8 +3,8 @@ package tray import ( "fmt" "my-app/backend/app" - "my-app/backend/model" "my-app/backend/pkg/i18n" + "my-app/backend/services" "my-app/backend/tray/menus" "my-app/backend/web" @@ -63,12 +63,8 @@ func (t *tray) displayLanguageListener() menus.DisplayLanguageListener { t.colorTheme.SetLocale() t.quit.SetLocale() - option := model.MyOption{ - Name: app.CfgDisplayLanguage, - } - result := option.Update(locale.Lang.Code) - if result.Error != nil { - app.App().TrayLog().Fatalf("failed to update language option: %+v\n", result.Error) + if err := services.SaveDisplayLanguageOption(locale.Lang.Code); err != nil { + app.App().TrayLog().Fatalf("failed to update language option: %+v\n", err) } return true, func() { @@ -92,12 +88,8 @@ func (t *tray) colorThemeListener() menus.ColorThemeListener { } runtime.EventsEmit(t.wailsCtx, "onColorThemeChanged", theme) - option := model.MyOption{ - Name: app.CfgColorTheme, - } - result := option.Update(theme) - if result.Error != nil { - app.App().TrayLog().Fatalf("failed to update theme option: %+v\n", result.Error) + if err := services.SaveColorThemeOption(theme); err != nil { + app.App().TrayLog().Fatalf("failed to update theme option: %+v\n", err) } return true, func() { diff --git a/frontend/packages/components/menu/src/menu-group.vue b/frontend/packages/components/menu/src/menu-group.vue index f25b3f0..344a320 100644 --- a/frontend/packages/components/menu/src/menu-group.vue +++ b/frontend/packages/components/menu/src/menu-group.vue @@ -26,13 +26,13 @@ const menuSize = inject("my-menu-size") || ref(props.size); const style = computed(() => { const size = props.size || menuSize.value; - let marginBottom = 0.6; + let marginBottom = 1; switch (size) { case "large": - marginBottom += 0.3; + marginBottom += 0.5; break; case "small": - marginBottom -= 0.3; + marginBottom -= 0.5; } return { marginBottom: marginBottom + "em", @@ -41,16 +41,16 @@ const style = computed(() => { const titleStyle = computed(() => { const size = props.size || menuSize.value; - let lineHeight = 2.6; + let marginBottom = 0.5; switch (size) { case "large": - lineHeight += 0.3; + marginBottom += 0.2; break; case "small": - lineHeight -= 0.3; + marginBottom -= 0.2; } return { - lineHeight, + marginBottom: marginBottom + "em", }; }); @@ -62,6 +62,7 @@ const titleStyle = computed(() => { &__title { font-size: var(--my-font-size-xs); + line-height: var(--my-line-height-sm); color: var(--my-color-text-secondary); } diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 917ef63..6bc050a 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -22,7 +22,7 @@ EventsOn("onColorThemeChanged", (theme: string) => { - + @@ -33,6 +33,9 @@ EventsOn("onColorThemeChanged", (theme: string) => { border-top: var(--my-border-width) solid var(--my-color-border-extra-light); &-main { padding: 2em; + &-inner { + margin: 0 auto; + } } } diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index 3e9e23f..4756c01 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -1,21 +1,24 @@ import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router"; import Test from "@/views/Test.vue"; +import Home from "@/views/Home.vue"; +import Settings from "@/views/Settings.vue"; +import About from "@/views/About.vue"; export const routes: Array = [ { path: "/", name: "Home", - component: Test, + component: Home, }, { path: "/settings", name: "Settings", - component: Test, + component: Settings, }, { path: "/about", name: "About", - component: Test, + component: About, }, { path: "/test", diff --git a/frontend/src/views/About.vue b/frontend/src/views/About.vue new file mode 100644 index 0000000..c2f70d6 --- /dev/null +++ b/frontend/src/views/About.vue @@ -0,0 +1,17 @@ + + + + + diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue new file mode 100644 index 0000000..7078763 --- /dev/null +++ b/frontend/src/views/Home.vue @@ -0,0 +1,17 @@ + + + + + diff --git a/frontend/src/views/Settings.vue b/frontend/src/views/Settings.vue new file mode 100644 index 0000000..e7db14d --- /dev/null +++ b/frontend/src/views/Settings.vue @@ -0,0 +1,22 @@ + + + + +