From 88c3d952d38605c7b90e0d27f84089e1c2178285 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Fri, 4 Mar 2022 23:20:42 +0800 Subject: [PATCH] Improve settings page's UI/UX on mobile --- src/layouts/Layout.vue | 2 +- src/pages/Settings.vue | 48 +++++++++++++++++++++++++++++++----------- src/router.js | 1 - 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/layouts/Layout.vue b/src/layouts/Layout.vue index 75173e1f..1a769a0d 100644 --- a/src/layouts/Layout.vue +++ b/src/layouts/Layout.vue @@ -157,7 +157,7 @@ export default { overflow: hidden; text-decoration: none; - &.router-link-exact-active { + &.router-link-exact-active, &.active { color: $primary; font-weight: bold; } diff --git a/src/pages/Settings.vue b/src/pages/Settings.vue index 58162f57..1717dd52 100644 --- a/src/pages/Settings.vue +++ b/src/pages/Settings.vue @@ -6,7 +6,7 @@
-
+
-
-
+
+
{{ subMenus[currentPage].title }}
@@ -41,7 +41,6 @@ export default { data() { return { show: true, - settings: {}, settingsLoaded: false, }; @@ -52,11 +51,19 @@ export default { let pathSplit = useRoute().path.split("/"); let pathEnd = pathSplit[pathSplit.length - 1]; if (!pathEnd || pathEnd === "settings") { - return "general"; + return null; } return pathEnd; }, + showSubMenu() { + if (this.$root.isMobile) { + return !this.currentPage; + } else { + return true; + } + }, + subMenus() { return { general: { @@ -84,11 +91,26 @@ export default { }, }, + watch: { + "$root.isMobile"() { + this.loadGeneralPage(); + } + }, + mounted() { this.loadSettings(); + this.loadGeneralPage(); }, methods: { + + // For desktop only, mobile do nothing + loadGeneralPage() { + if (!this.currentPage && !this.$root.isMobile) { + this.$router.push("/settings/general"); + } + }, + loadSettings() { this.$root.getSocket().emit("getSettings", (res) => { this.settings = res.data; @@ -115,7 +137,7 @@ export default { this.loadSettings(); }); }, - }, + } }; @@ -136,9 +158,6 @@ footer { } .settings-menu { - flex: 0 0 auto; - width: 300px; - a { text-decoration: none !important; } @@ -171,9 +190,6 @@ footer { } .settings-content { - flex: 0 0 auto; - width: calc(100% - 300px); - .settings-content-header { width: calc(100% + 20px); border-bottom: 1px solid #dee2e6; @@ -187,6 +203,14 @@ footer { background: $dark-header-bg; border-bottom: 0; } + + .mobile & { + padding: 15px 0 0 0; + + .dark & { + background-color: transparent; + } + } } } diff --git a/src/router.js b/src/router.js index a2414eb6..c881dc97 100644 --- a/src/router.js +++ b/src/router.js @@ -70,7 +70,6 @@ const routes = [ children: [ { path: "general", - alias: "", component: General, }, {