diff --git a/package.json b/package.json
index 6396d49..95f6177 100644
--- a/package.json
+++ b/package.json
@@ -10,8 +10,10 @@
"dependencies": {
"axios": "^0.20.0",
"core-js": "^3.6.5",
+ "crypto-js": "^4.0.0",
"dayjs": "^1.8.36",
"howler": "^2.2.0",
+ "js-cookie": "^2.2.1",
"nprogress": "^0.2.0",
"plyr": "^3.6.2",
"register-service-worker": "^1.7.1",
diff --git a/public/img/logos/netease-music.png b/public/img/logos/netease-music.png
new file mode 100644
index 0000000..268aa96
Binary files /dev/null and b/public/img/logos/netease-music.png differ
diff --git a/public/img/logos/yesplaymusic.png b/public/img/logos/yesplaymusic.png
new file mode 100644
index 0000000..e819dd0
Binary files /dev/null and b/public/img/logos/yesplaymusic.png differ
diff --git a/src/api/auth.js b/src/api/auth.js
new file mode 100644
index 0000000..da40e6a
--- /dev/null
+++ b/src/api/auth.js
@@ -0,0 +1,42 @@
+import request from "@/utils/request";
+
+export function loginWithPhone(params) {
+ //必选参数 :
+ // phone: 手机号码
+ // password: 密码
+ // 可选参数 :
+ // countrycode: 国家码,用于国外手机号登录,例如美国传入:1
+ // md5_password: md5加密后的密码,传入后 password 将失效
+ return request({
+ url: "/login/cellphone",
+ method: "post",
+ params,
+ });
+}
+
+export function loginWithEmail(params) {
+ // 必选参数 :
+ // email: 163 网易邮箱
+ // password: 密码
+ // 可选参数 :
+ // md5_password: md5加密后的密码,传入后 password 将失效
+ return request({
+ url: "/login",
+ method: "post",
+ params,
+ });
+}
+
+export function loginRefresh() {
+ return request({
+ url: "/login/refresh",
+ method: "post",
+ });
+}
+
+export function logout() {
+ return request({
+ url: "/logout",
+ method: "post",
+ });
+}
diff --git a/src/assets/icons/lock.svg b/src/assets/icons/lock.svg
new file mode 100644
index 0000000..59c1e32
--- /dev/null
+++ b/src/assets/icons/lock.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/assets/icons/mail.svg b/src/assets/icons/mail.svg
new file mode 100644
index 0000000..e0c6e57
--- /dev/null
+++ b/src/assets/icons/mail.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/assets/icons/mobile.svg b/src/assets/icons/mobile.svg
new file mode 100644
index 0000000..ae8b81b
--- /dev/null
+++ b/src/assets/icons/mobile.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/assets/icons/x.svg b/src/assets/icons/x.svg
new file mode 100644
index 0000000..8144622
--- /dev/null
+++ b/src/assets/icons/x.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/router/index.js b/src/router/index.js
index 3f45870..7d3056d 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -3,6 +3,7 @@ import VueRouter from "vue-router";
import store from "@/store";
import NProgress from "nprogress";
import "@/assets/css/nprogress.css";
+import Cookies from "js-cookie";
NProgress.configure({ showSpinner: false, trickleSpeed: 100 });
@@ -16,7 +17,21 @@ const routes = [
keepAlive: true,
},
},
- { path: "/login", name: "login", component: () => import("@/views/login") },
+ {
+ path: "/login",
+ name: "login",
+ component: () => import("@/views/login"),
+ },
+ {
+ path: "/login/username",
+ name: "loginUsername",
+ component: () => import("@/views/loginUsername"),
+ },
+ {
+ path: "/login/account",
+ name: "loginAccount",
+ component: () => import("@/views/loginAccount"),
+ },
{
path: "/playlist/:id",
name: "playlist",
@@ -88,11 +103,6 @@ const router = new VueRouter({
routes,
scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
- // return new Promise((resolve) => {
- // setTimeout(() => {
- // resolve(savedPosition);
- // }, 100);
- // });
return savedPosition;
} else {
return { x: 0, y: 0 };
@@ -104,6 +114,12 @@ router.beforeEach((to, from, next) => {
if (to.meta.requireLogin) {
if (store.state.settings.user.nickname === undefined) {
next({ path: "/login" });
+ }
+ if (
+ Cookies.get("MUSIC_U") === undefined &&
+ Cookies.get("loginMode") === "account"
+ ) {
+ next({ path: "/login" });
} else {
next();
}
diff --git a/src/utils/auth.js b/src/utils/auth.js
new file mode 100644
index 0000000..480c84d
--- /dev/null
+++ b/src/utils/auth.js
@@ -0,0 +1,12 @@
+import Cookies from "js-cookie";
+import { logout } from "@/api/auth";
+
+export function doLogout() {
+ console.log("logout");
+ logout();
+ Cookies.remove("loginMode");
+}
+
+export function isLoggedIn() {
+ return Cookies.get("MUSIC_U") !== undefined ? true : false;
+}
diff --git a/src/utils/request.js b/src/utils/request.js
index 6ca3492..795d218 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -12,6 +12,10 @@ service.interceptors.response.use(
if (res.code !== 200) {
if (res.code === 401) {
alert("token expired");
+ } else if (res.code === 502) {
+ alert(res.msg);
+ } else if (res.code === 301) {
+ alert("required login");
} else {
alert("unknow error");
}
diff --git a/src/views/login.vue b/src/views/login.vue
index 1dee3e5..129c2f9 100644
--- a/src/views/login.vue
+++ b/src/views/login.vue
@@ -1,95 +1,64 @@
-
-
Login
-
-
-
- 按Enter搜索
-
-
- 在列表中选中你的账号
-
-
-
-
![]()
-
- {{ user.nickname }}
-
-
-
-
-
确定
+

+
+

+
+
+
+
diff --git a/src/views/loginUsername.vue b/src/views/loginUsername.vue
new file mode 100644
index 0000000..4683b77
--- /dev/null
+++ b/src/views/loginUsername.vue
@@ -0,0 +1,194 @@
+
+
+
+
用户名登录
+
+
+
+ 按Enter搜索
+
+
+ 在列表中选中你的账号
+
+
+
+
![]()
+
+ {{ user.nickname }}
+
+
+
+
+
确定
+
+
+
+
+
+
+
diff --git a/yarn.lock b/yarn.lock
index 640dba8..3836b5b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2840,6 +2840,11 @@ crypto-browserify@^3.11.0:
randombytes "^2.0.0"
randomfill "^1.0.3"
+crypto-js@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.0.0.tgz#2904ab2677a9d042856a2ea2ef80de92e4a36dcc"
+ integrity sha512-bzHZN8Pn+gS7DQA6n+iUmBfl0hO5DJq++QP3U6uTucDtk/0iGpXd/Gg7CGR0p8tJhofJyaKoWBuJI4eAO00BBg==
+
css-color-names@0.0.4, css-color-names@^0.0.4:
version "0.0.4"
resolved "https://registry.npm.taobao.org/css-color-names/download/css-color-names-0.0.4.tgz#808adc2e79cf84738069b646cb20ec27beb629e0"
@@ -5042,6 +5047,11 @@ js-base64@^2.1.9:
resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.6.4.tgz#f4e686c5de1ea1f867dbcad3d46d969428df98c4"
integrity sha512-pZe//GGmwJndub7ZghVHz7vjb2LgC1m8B07Au3eYqeqv9emhESByMXxaEgkUkEqJe87oBbSniGYoQNIBklc7IQ==
+js-cookie@^2.2.1:
+ version "2.2.1"
+ resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8"
+ integrity sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ==
+
js-message@1.0.5:
version "1.0.5"
resolved "https://registry.npm.taobao.org/js-message/download/js-message-1.0.5.tgz#2300d24b1af08e89dd095bc1a4c9c9cfcb892d15"