From d1e575a0bda38faec15c9a246ee34bf8c987f8af Mon Sep 17 00:00:00 2001
From: wen <1515>
Date: Sat, 29 Oct 2022 12:13:53 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=99=BB=E5=85=A5=E9=94=99?=
=?UTF-8?q?=E8=AF=AF=E4=BF=A1=E6=81=AF=E6=8F=90=E7=A4=BA=EF=BC=8C=E4=BB=A5?=
=?UTF-8?q?=E5=8F=8A=E7=94=A8vuex=E8=AE=BE=E7=BD=AE=E8=AE=BF=E9=97=AE?=
=?UTF-8?q?=E5=85=B6=E4=BB=96=E9=A1=B5=E9=9D=A2=E5=A6=82=E6=9E=9C=E6=9C=AA?=
=?UTF-8?q?=E7=99=BB=E5=85=A5=E5=88=99=E8=B7=B3=E5=88=B0=E7=99=BB=E5=85=A5?=
=?UTF-8?q?=E9=A1=B5=EF=BC=8C=E5=88=A0=E9=99=A4=E8=B0=83=E8=AF=95=E4=BB=A3?=
=?UTF-8?q?=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
dist/index.html | 2 +-
src/components/Breadcrumb/index.vue | 2 +-
src/permission.js | 71 +++++++++++++++--------------
src/store/modules/user.js | 8 ++--
src/views/login/index.vue | 24 ++++++++--
5 files changed, 62 insertions(+), 45 deletions(-)
diff --git a/dist/index.html b/dist/index.html
index 3035cb1..45ac424 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -1 +1 @@
-
嘉洛马 — 文件后台管理系统
\ No newline at end of file
+嘉洛马 — 文件后台管理系统
\ No newline at end of file
diff --git a/src/components/Breadcrumb/index.vue b/src/components/Breadcrumb/index.vue
index 52c94c3..ec8935f 100644
--- a/src/components/Breadcrumb/index.vue
+++ b/src/components/Breadcrumb/index.vue
@@ -89,7 +89,7 @@ export default {
this.levelList2 = [];
}
this.levelList2.unshift(ancestorsDir)
- console.log(this.levelList2);
+ //console.log(this.levelList2);
this.breadcrumbq = false;
// console.log(currentid);
// console.log(this.extractChild);
diff --git a/src/permission.js b/src/permission.js
index e9252da..0f0f9c4 100644
--- a/src/permission.js
+++ b/src/permission.js
@@ -19,44 +19,45 @@ router.beforeEach(async(to, from, next) => {
document.title = getPageTitle(to.meta.title)
next()
// determine whether the user has logged in
-// const hasToken = getToken()
+ const hasToken = getToken()
-// if (hasToken) {
-// if (to.path === '/login') {
-// // if is logged in, redirect to the home page
-// next({ path: '/' })
-// NProgress.done()
-// } else {
-// const hasGetUserInfo = store.getters.name
-// if (hasGetUserInfo) {
-// next()
-// } else {
-// try {
-// // get user info
-// await store.dispatch('user/getInfo')
+ if (hasToken) {
+ if (to.path === '/login') {
+ // if is logged in, redirect to the home page
+ next({ path: '/' })
+ NProgress.done()
+ }
+ // else {
+ // const hasGetUserInfo = store.getters.name
+ // if (hasGetUserInfo) {
+ // next()
+ // } else {
+ // try {
+ // // get user info
+ // await store.dispatch('user/getInfo')
-// next()
-// } catch (error) {
-// // remove token and go to login page to re-login
-// await store.dispatch('user/resetToken')
-// Message.error(error || 'Has Error')
-// next(`/login?redirect=${to.path}`)
-// NProgress.done()
-// }
-// }
-// }
-// } else {
-// /* has no token*/
+ // next()
+ // } catch (error) {
+ // // remove token and go to login page to re-login
+ // await store.dispatch('user/resetToken')
+ // Message.error(error || 'Has Error')
+ // next(`/login?redirect=${to.path}`)
+ // NProgress.done()
+ // }
+ // }
+ // }
+ } else {
+ /* has no token*/
-// if (whiteList.indexOf(to.path) !== -1) {
-// // in the free login whitelist, go directly
-// next()
-// } else {
-// // other pages that do not have permission to access are redirected to the login page.
-// next(`/login?redirect=${to.path}`)
-// NProgress.done()
-// }
-// }
+ if (whiteList.indexOf(to.path) !== -1) {
+ // in the free login whitelist, go directly
+ next()
+ } else {
+ // other pages that do not have permission to access are redirected to the login page.
+ next(`/login?redirect=${to.path}`)
+ NProgress.done()
+ }
+ }
})
router.afterEach(() => {
diff --git a/src/store/modules/user.js b/src/store/modules/user.js
index f77b10c..1ab6b42 100644
--- a/src/store/modules/user.js
+++ b/src/store/modules/user.js
@@ -33,10 +33,10 @@ const actions = {
const { username, password, captcha} = userInfo
return new Promise((resolve, reject) => {
login({ username: username.trim(), password: password, captcha: captcha}).then(response => {
- const { data } = response
- commit('SET_TOKEN', data.token)
- setToken(data.token)
- resolve()
+ const { data } = 1
+ commit('SET_TOKEN', data)
+ setToken(data)
+ resolve(response)
}).catch(error => {
reject(error)
})
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index b2a1ce0..a0ded53 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -170,11 +170,27 @@ export default {
if (valid) {
this.loading = true
let thiss = this;
- this.$store.dispatch('user/login', this.loginForm).then(() => {
- //this.$router.push({ path: this.redirect || '/' })
- this.$router.push({path: '/filemange/index'})
+ this.$store.dispatch('user/login', this.loginForm).then(response => {
+ console.log(response);
+ let datamain = response.data;
+ if (datamain.code == 1) {
+ //console.log(datamain);
+
+ this.$router.push({ path: this.redirect || '/filemange/index' })
+ this.$message({showClose: true,message: datamain.msg, type:'success'});
+ } else if (datamain.code == 0) {
+ this.$message({showClose: true,message: datamain.err, type:'error'});
+ }
+
this.loading = false
- }).catch(() => {
+ }).catch((error) => {
+ if (error.response) {
+ thiss.$message({showClose: true,message: error.response.data.err,type: 'error'});
+ } else if (error.request) {
+ thiss.$message({showClose: true,message: error.request,type: 'error'});
+ } else {
+ thiss.$message({showClose: true,message: error.message,type: 'error'});
+ }
this.loading = false
})
// login(this.loginForm).then(response => {