fix: UX improvement

master
qier222 4 years ago
parent d69080b695
commit 4cbe9f98ce
No known key found for this signature in database
GPG Key ID: 9C85007ED905F14D

@ -0,0 +1 @@
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="sign-in-alt" class="svg-inline--fa fa-sign-in-alt fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M416 448h-84c-6.6 0-12-5.4-12-12v-40c0-6.6 5.4-12 12-12h84c17.7 0 32-14.3 32-32V160c0-17.7-14.3-32-32-32h-84c-6.6 0-12-5.4-12-12V76c0-6.6 5.4-12 12-12h84c53 0 96 43 96 96v192c0 53-43 96-96 96zm-47-201L201 79c-15-15-41-4.5-41 17v96H24c-13.3 0-24 10.7-24 24v96c0 13.3 10.7 24 24 24h136v96c0 21.5 26 32 41 17l168-168c9.3-9.4 9.3-24.6 0-34z"></path></svg>

After

Width:  |  Height:  |  Size: 579 B

@ -1,83 +1,102 @@
<template> <template>
<nav> <div>
<div class="win32-titlebar"> <nav>
<div class="title">YesPlayMusic</div> <div class="win32-titlebar">
<div class="controls"> <div class="title">YesPlayMusic</div>
<div <div class="controls">
class="button minimize codicon codicon-chrome-minimize" <div
@click="windowMinimize" class="button minimize codicon codicon-chrome-minimize"
></div> @click="windowMinimize"
<div ></div>
class="button max-restore codicon" <div
@click="windowMaxRestore" class="button max-restore codicon"
:class="{ @click="windowMaxRestore"
'codicon-chrome-restore': windowIsMaximized, :class="{
'codicon-chrome-maximize': !windowIsMaximized, 'codicon-chrome-restore': windowIsMaximized,
}" 'codicon-chrome-maximize': !windowIsMaximized,
></div> }"
<div ></div>
class="button close codicon codicon-chrome-close" <div
@click="windowClose" class="button close codicon codicon-chrome-close"
></div> @click="windowClose"
></div>
</div>
</div>
<div class="navigation-buttons">
<button-icon @click.native="go('back')"
><svg-icon icon-class="arrow-left"
/></button-icon>
<button-icon @click.native="go('forward')"
><svg-icon icon-class="arrow-right"
/></button-icon>
</div>
<div class="navigation-links">
<router-link to="/" :class="{ active: this.$route.name === 'home' }">{{
$t("nav.home")
}}</router-link>
<router-link
to="/explore"
:class="{ active: this.$route.name === 'explore' }"
>{{ $t("nav.explore") }}</router-link
>
<router-link
to="/library"
:class="{ active: this.$route.name === 'library' }"
>{{ $t("nav.library") }}</router-link
>
</div> </div>
</div> <div class="right-part">
<div class="navigation-buttons"> <div class="search-box">
<button-icon @click.native="go('back')" <div class="container" :class="{ active: inputFocus }">
><svg-icon icon-class="arrow-left" <svg-icon icon-class="search" />
/></button-icon> <div class="input">
<button-icon @click.native="go('forward')" <input
><svg-icon icon-class="arrow-right" ref="searchInput"
/></button-icon> :placeholder="inputFocus ? '' : $t('nav.search')"
</div> v-model="keywords"
<div class="navigation-links"> @keydown.enter="doSearch"
<router-link to="/" :class="{ active: this.$route.name === 'home' }">{{ @focus="inputFocus = true"
$t("nav.home") @blur="inputFocus = false"
}}</router-link> />
<router-link </div>
to="/explore"
:class="{ active: this.$route.name === 'explore' }"
>{{ $t("nav.explore") }}</router-link
>
<router-link
to="/library"
:class="{ active: this.$route.name === 'library' }"
>{{ $t("nav.library") }}</router-link
>
</div>
<div class="right-part">
<a
href="https://github.com/qier222/YesPlayMusic"
target="blank"
v-if="settings.showGithubIcon !== false"
><svg-icon icon-class="github" class="github"
/></a>
<div class="search-box">
<div class="container" :class="{ active: inputFocus }">
<svg-icon icon-class="search" />
<div class="input">
<input
ref="searchInput"
:placeholder="inputFocus ? '' : $t('nav.search')"
v-model="keywords"
@keydown.enter="doSearch"
@focus="inputFocus = true"
@blur="inputFocus = false"
/>
</div> </div>
</div> </div>
<img class="avatar" :src="avatarUrl" @click="showUserProfileMenu" />
</div>
</nav>
<ContextMenu ref="userProfileMenu">
<div class="item" @click="toLogin" v-if="!isLooseLoggedIn">
<svg-icon icon-class="login" />
登录
</div>
<div class="item" @click="toSettings">
<svg-icon icon-class="settings" />
{{ $t("library.userProfileMenu.settings") }}
</div> </div>
</div> <div class="item" @click="logout" v-if="isLooseLoggedIn">
</nav> <svg-icon icon-class="logout" />
{{ $t("library.userProfileMenu.logout") }}
</div>
<hr />
<div class="item" @click="toGitHub">
<svg-icon icon-class="github" /> GitHub仓库
</div>
</ContextMenu>
</div>
</template> </template>
<script> <script>
import ButtonIcon from "@/components/ButtonIcon.vue";
import { mapState } from "vuex"; import { mapState } from "vuex";
import { isLooseLoggedIn, doLogout } from "@/utils/auth";
// import icons for win32 title bar // import icons for win32 title bar
// icons by https://github.com/microsoft/vscode-codicons // icons by https://github.com/microsoft/vscode-codicons
import "vscode-codicons/dist/codicon.css"; import "vscode-codicons/dist/codicon.css";
import ContextMenu from "@/components/ContextMenu.vue";
import ButtonIcon from "@/components/ButtonIcon.vue";
let win = undefined; let win = undefined;
if (process.env.IS_ELECTRON === true) { if (process.env.IS_ELECTRON === true) {
const electron = require("electron"); const electron = require("electron");
@ -88,6 +107,7 @@ export default {
name: "Navbar", name: "Navbar",
components: { components: {
ButtonIcon, ButtonIcon,
ContextMenu,
}, },
data() { data() {
return { return {
@ -98,7 +118,15 @@ export default {
}; };
}, },
computed: { computed: {
...mapState(["settings"]), ...mapState(["settings", "data"]),
isLooseLoggedIn() {
return isLooseLoggedIn();
},
avatarUrl() {
return this.data.user.avatarUrl
? `${this.data.user.avatarUrl}?param=512y512`
: "http://s4.music.126.net/style/web2/img/default/default_avatar.jpg?param=60y60";
},
}, },
methods: { methods: {
go(where) { go(where) {
@ -118,6 +146,20 @@ export default {
params: { keywords: this.keywords }, params: { keywords: this.keywords },
}); });
}, },
showUserProfileMenu(e) {
this.$refs.userProfileMenu.openMenu(e);
},
logout() {
if (!confirm("确定要退出登录吗?")) return;
doLogout();
this.$router.push({ name: "home" });
},
toSettings() {
this.$router.push({ name: "settings" });
},
toGitHub() {
window.open("https://github.com/qier222/YesPlayMusic");
},
windowMinimize() { windowMinimize() {
win.minimize(); win.minimize();
}, },
@ -352,12 +394,15 @@ nav {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: flex-end; justify-content: flex-end;
.github { .avatar {
margin-right: 16px; height: 30px;
height: 24px; margin-left: 12px;
width: 24px; vertical-align: -7px;
color: var(--color-text); border-radius: 50%;
-webkit-app-region: no-drag; cursor: pointer;
&:hover {
filter: brightness(80%);
}
} }
.search-button { .search-button {
display: none; display: none;

@ -27,7 +27,7 @@ export default {
newPlayList: "新建歌单", newPlayList: "新建歌单",
userProfileMenu: { userProfileMenu: {
settings: "设置", settings: "设置",
logout: "退出登录", logout: "登出",
}, },
}, },
explore: { explore: {

@ -4,9 +4,6 @@
<img class="avatar" :src="data.user.avatarUrl | resizeImage" />{{ <img class="avatar" :src="data.user.avatarUrl | resizeImage" />{{
data.user.nickname data.user.nickname
}}{{ $t("library.sLibrary") }} }}{{ $t("library.sLibrary") }}
<button-icon @click.native="showUserProfileMenu"
><svg-icon icon-class="arrow-right"
/></button-icon>
</h1> </h1>
<div class="section-one"> <div class="section-one">
<div class="liked-songs" @click="goToLikedSongsList"> <div class="liked-songs" @click="goToLikedSongsList">
@ -112,17 +109,6 @@
<MvRow :mvs="mvs" /> <MvRow :mvs="mvs" />
</div> </div>
</div> </div>
<ContextMenu ref="userProfileMenu">
<div class="item" @click="settings">
<svg-icon icon-class="settings" />
{{ $t("library.userProfileMenu.settings") }}
</div>
<div class="item" @click="logout">
<svg-icon icon-class="logout" />
{{ $t("library.userProfileMenu.logout") }}
</div>
</ContextMenu>
</div> </div>
</template> </template>
@ -139,11 +125,9 @@ import {
} from "@/api/user"; } from "@/api/user";
import { randomNum, dailyTask } from "@/utils/common"; import { randomNum, dailyTask } from "@/utils/common";
import { getPlaylistDetail } from "@/api/playlist"; import { getPlaylistDetail } from "@/api/playlist";
import { isAccountLoggedIn, doLogout } from "@/utils/auth"; import { isAccountLoggedIn } from "@/utils/auth";
import NProgress from "nprogress"; import NProgress from "nprogress";
import ContextMenu from "@/components/ContextMenu.vue";
import ButtonIcon from "@/components/ButtonIcon.vue";
import TrackList from "@/components/TrackList.vue"; import TrackList from "@/components/TrackList.vue";
import CoverRow from "@/components/CoverRow.vue"; import CoverRow from "@/components/CoverRow.vue";
import SvgIcon from "@/components/SvgIcon.vue"; import SvgIcon from "@/components/SvgIcon.vue";
@ -151,7 +135,7 @@ import MvRow from "@/components/MvRow.vue";
export default { export default {
name: "Library", name: "Library",
components: { SvgIcon, CoverRow, TrackList, MvRow, ButtonIcon, ContextMenu }, components: { SvgIcon, CoverRow, TrackList, MvRow },
data() { data() {
return { return {
show: false, show: false,
@ -344,17 +328,6 @@ export default {
value: true, value: true,
}); });
}, },
showUserProfileMenu(e) {
this.$refs.userProfileMenu.openMenu(e);
},
logout() {
if (!confirm("确定要退出登录吗?")) return;
doLogout();
this.$router.push({ name: "home" });
},
settings() {
this.$router.push({ name: "settings" });
},
}, },
watch: { watch: {
likedSongsInState() { likedSongsInState() {
@ -377,12 +350,6 @@ h1 {
border-radius: 50%; border-radius: 50%;
border: rgba(0, 0, 0, 0.2); border: rgba(0, 0, 0, 0.2);
} }
.svg-icon {
width: 28px;
height: 28px;
opacity: 0.18;
}
} }
.section-one { .section-one {

Loading…
Cancel
Save