|
|
@ -3,7 +3,7 @@ import VueRouter from "vue-router";
|
|
|
|
import store from "@/store";
|
|
|
|
import store from "@/store";
|
|
|
|
import NProgress from "nprogress";
|
|
|
|
import NProgress from "nprogress";
|
|
|
|
import "@/assets/css/nprogress.css";
|
|
|
|
import "@/assets/css/nprogress.css";
|
|
|
|
import Cookies from "js-cookie";
|
|
|
|
import { isLooseLoggedIn } from "@/utils/auth";
|
|
|
|
|
|
|
|
|
|
|
|
NProgress.configure({ showSpinner: false, trickleSpeed: 100 });
|
|
|
|
NProgress.configure({ showSpinner: false, trickleSpeed: 100 });
|
|
|
|
|
|
|
|
|
|
|
@ -12,7 +12,7 @@ const routes = [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: "/",
|
|
|
|
path: "/",
|
|
|
|
name: "home",
|
|
|
|
name: "home",
|
|
|
|
component: () => import("@/views/home"),
|
|
|
|
component: () => import("@/views/home.vue"),
|
|
|
|
meta: {
|
|
|
|
meta: {
|
|
|
|
keepAlive: true,
|
|
|
|
keepAlive: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -20,32 +20,32 @@ const routes = [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: "/login",
|
|
|
|
path: "/login",
|
|
|
|
name: "login",
|
|
|
|
name: "login",
|
|
|
|
component: () => import("@/views/login"),
|
|
|
|
component: () => import("@/views/login.vue"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: "/login/username",
|
|
|
|
path: "/login/username",
|
|
|
|
name: "loginUsername",
|
|
|
|
name: "loginUsername",
|
|
|
|
component: () => import("@/views/loginUsername"),
|
|
|
|
component: () => import("@/views/loginUsername.vue"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: "/login/account",
|
|
|
|
path: "/login/account",
|
|
|
|
name: "loginAccount",
|
|
|
|
name: "loginAccount",
|
|
|
|
component: () => import("@/views/loginAccount"),
|
|
|
|
component: () => import("@/views/loginAccount.vue"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: "/playlist/:id",
|
|
|
|
path: "/playlist/:id",
|
|
|
|
name: "playlist",
|
|
|
|
name: "playlist",
|
|
|
|
component: () => import("@/views/playlist"),
|
|
|
|
component: () => import("@/views/playlist.vue"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: "/album/:id",
|
|
|
|
path: "/album/:id",
|
|
|
|
name: "album",
|
|
|
|
name: "album",
|
|
|
|
component: () => import("@/views/album"),
|
|
|
|
component: () => import("@/views/album.vue"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: "/artist/:id",
|
|
|
|
path: "/artist/:id",
|
|
|
|
name: "artist",
|
|
|
|
name: "artist",
|
|
|
|
component: () => import("@/views/artist"),
|
|
|
|
component: () => import("@/views/artist.vue"),
|
|
|
|
meta: {
|
|
|
|
meta: {
|
|
|
|
keepAlive: true,
|
|
|
|
keepAlive: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -53,12 +53,12 @@ const routes = [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: "/mv/:id",
|
|
|
|
path: "/mv/:id",
|
|
|
|
name: "mv",
|
|
|
|
name: "mv",
|
|
|
|
component: () => import("@/views/mv"),
|
|
|
|
component: () => import("@/views/mv.vue"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: "/next",
|
|
|
|
path: "/next",
|
|
|
|
name: "next",
|
|
|
|
name: "next",
|
|
|
|
component: () => import("@/views/next"),
|
|
|
|
component: () => import("@/views/next.vue"),
|
|
|
|
meta: {
|
|
|
|
meta: {
|
|
|
|
keepAlive: true,
|
|
|
|
keepAlive: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -66,17 +66,17 @@ const routes = [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: "/search",
|
|
|
|
path: "/search",
|
|
|
|
name: "search",
|
|
|
|
name: "search",
|
|
|
|
component: () => import("@/views/search"),
|
|
|
|
component: () => import("@/views/search.vue"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: "/new-album",
|
|
|
|
path: "/new-album",
|
|
|
|
name: "newAlbum",
|
|
|
|
name: "newAlbum",
|
|
|
|
component: () => import("@/views/newAlbum"),
|
|
|
|
component: () => import("@/views/newAlbum.vue"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: "/explore",
|
|
|
|
path: "/explore",
|
|
|
|
name: "explore",
|
|
|
|
name: "explore",
|
|
|
|
component: () => import("@/views/explore"),
|
|
|
|
component: () => import("@/views/explore.vue"),
|
|
|
|
meta: {
|
|
|
|
meta: {
|
|
|
|
keepAlive: true,
|
|
|
|
keepAlive: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -84,7 +84,7 @@ const routes = [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: "/library",
|
|
|
|
path: "/library",
|
|
|
|
name: "library",
|
|
|
|
name: "library",
|
|
|
|
component: () => import("@/views/library"),
|
|
|
|
component: () => import("@/views/library.vue"),
|
|
|
|
meta: {
|
|
|
|
meta: {
|
|
|
|
requireLogin: true,
|
|
|
|
requireLogin: true,
|
|
|
|
keepAlive: true,
|
|
|
|
keepAlive: true,
|
|
|
@ -93,7 +93,7 @@ const routes = [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: "/library/liked-songs",
|
|
|
|
path: "/library/liked-songs",
|
|
|
|
name: "likedSongs",
|
|
|
|
name: "likedSongs",
|
|
|
|
component: () => import("@/views/playlist"),
|
|
|
|
component: () => import("@/views/playlist.vue"),
|
|
|
|
meta: {
|
|
|
|
meta: {
|
|
|
|
requireLogin: true,
|
|
|
|
requireLogin: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -101,7 +101,7 @@ const routes = [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: "/settings",
|
|
|
|
path: "/settings",
|
|
|
|
name: "settings",
|
|
|
|
name: "settings",
|
|
|
|
component: () => import("@/views/settings"),
|
|
|
|
component: () => import("@/views/settings.vue"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
];
|
|
|
|
const router = new VueRouter({
|
|
|
|
const router = new VueRouter({
|
|
|
@ -116,17 +116,15 @@ const router = new VueRouter({
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
|
|
|
|
|
// 需要登录的逻辑
|
|
|
|
if (to.meta.requireLogin) {
|
|
|
|
if (to.meta.requireLogin) {
|
|
|
|
if (store.state.settings.user.nickname === undefined) {
|
|
|
|
if (store.state.settings.user.nickname === undefined) {
|
|
|
|
next({ path: "/login" });
|
|
|
|
next({ path: "/login" });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (
|
|
|
|
if (isLooseLoggedIn()) {
|
|
|
|
Cookies.get("MUSIC_U") === undefined &&
|
|
|
|
|
|
|
|
Cookies.get("loginMode") === "account"
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
next({ path: "/login" });
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
next();
|
|
|
|
next();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
next({ path: "/login" });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
next();
|
|
|
|
next();
|
|
|
|