From 23d25433fa008fc0eaa36038f64439f0b9e6c6fa Mon Sep 17 00:00:00 2001 From: qier222 <68148142+qier222@users.noreply.github.com> Date: Fri, 23 Oct 2020 00:00:17 +0800 Subject: [PATCH] feat: add settings page & move change lang button to settings page --- src/App.vue | 4 + src/assets/icons/logout.svg | 1 + src/components/Footer.vue | 26 ----- src/components/Navbar.vue | 22 ---- src/router/index.js | 10 +- src/utils/auth.js | 3 +- src/views/home.vue | 22 +++- src/views/settings.vue | 204 ++++++++++++++++++++++++++++++++++++ 8 files changed, 241 insertions(+), 51 deletions(-) create mode 100644 src/assets/icons/logout.svg delete mode 100644 src/components/Footer.vue create mode 100644 src/views/settings.vue diff --git a/src/App.vue b/src/App.vue index fdad45a..8d1f41f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -71,8 +71,12 @@ main { } } +select, button { font-family: inherit; +} + +button { background: none; border: none; cursor: pointer; diff --git a/src/assets/icons/logout.svg b/src/assets/icons/logout.svg new file mode 100644 index 0000000..5c9daff --- /dev/null +++ b/src/assets/icons/logout.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/Footer.vue b/src/components/Footer.vue deleted file mode 100644 index b639e81..0000000 --- a/src/components/Footer.vue +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/src/components/Navbar.vue b/src/components/Navbar.vue index 322fbda..9bd5669 100644 --- a/src/components/Navbar.vue +++ b/src/components/Navbar.vue @@ -41,9 +41,6 @@ -
- -
@@ -80,16 +77,6 @@ export default { query: { keywords: this.keywords }, }); }, - changeLang() { - let lang = ""; - if (this.$i18n.locale === "zh-CN") { - lang = "en"; - } else { - lang = "zh-CN"; - } - this.$i18n.locale = lang; - this.$store.commit("changeLang", lang); - }, }, }; @@ -213,13 +200,4 @@ nav { width: 24px; } } - -.locale-changer { - position: relative; - .translation { - margin-left: 16px; - height: 48px; - width: 48px; - } -} diff --git a/src/router/index.js b/src/router/index.js index 5135fef..3d228b2 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -98,6 +98,11 @@ const routes = [ requireLogin: true, }, }, + { + path: "/settings", + name: "settings", + component: () => import("@/views/settings"), + }, ]; const router = new VueRouter({ routes, @@ -129,7 +134,10 @@ router.beforeEach((to, from, next) => { }); router.afterEach((to) => { - if (to.matched.some((record) => !record.meta.keepAlive)) { + if ( + to.matched.some((record) => !record.meta.keepAlive) && + !["settings"].includes(to.name) + ) { NProgress.start(); } }); diff --git a/src/utils/auth.js b/src/utils/auth.js index 480c84d..239ddcb 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -1,10 +1,11 @@ import Cookies from "js-cookie"; import { logout } from "@/api/auth"; +import store from "@/store"; export function doLogout() { - console.log("logout"); logout(); Cookies.remove("loginMode"); + store.commit("updateUser", { id: 0 }); } export function isLoggedIn() { diff --git a/src/views/home.vue b/src/views/home.vue index 33ff372..f38f3ab 100644 --- a/src/views/home.vue +++ b/src/views/home.vue @@ -47,6 +47,16 @@ :imageSize="1024" /> + + @@ -57,10 +67,11 @@ import { byAppleMusic } from "@/utils/staticPlaylist"; import { newAlbums } from "@/api/album"; import NProgress from "nprogress"; import CoverRow from "@/components/CoverRow.vue"; +import ButtonTwoTone from "@/components/ButtonTwoTone.vue"; export default { name: "Home", - components: { CoverRow }, + components: { CoverRow, ButtonTwoTone }, data() { return { show: false, @@ -114,6 +125,9 @@ export default { ); }); }, + goTo(path) { + this.$router.push({ path }); + }, }, activated() { this.loadData(); @@ -180,4 +194,10 @@ export default { } } } + +footer { + display: flex; + justify-content: center; + margin-top: 48px; +} diff --git a/src/views/settings.vue b/src/views/settings.vue new file mode 100644 index 0000000..8bad1c4 --- /dev/null +++ b/src/views/settings.vue @@ -0,0 +1,204 @@ + + + + +