tanyanfei il y a 5 ans
Parent
commit
2433ba4194
4 fichiers modifiés avec 12 ajouts et 13 suppressions
  1. 3 0
      src/api.js
  2. 2 1
      src/style/home.scss
  3. 6 11
      src/views/Home.vue
  4. 1 1
      src/views/project/Index.vue

+ 3 - 0
src/api.js

@@ -50,6 +50,9 @@ export default {
 	login: params => {
 		return axios.post(`${baseURL}/api/account/login`, params);
 	},
+	logout: params => {
+		return axios.post(`${baseURL}/api/account/logout`, params);
+	},
 	//获取验证码
 	getCode: params => {
 		return axios.get(`${baseURL}/api/account/imgcode`)

+ 2 - 1
src/style/home.scss

@@ -5,7 +5,7 @@ $height: 50px;
 	background: $color;
 	color: #fff;
 	height: 60px !important;
-	padding: 0 48px;
+	padding: 0 24px;
 	.logo{
 		height: 50px;
 		margin-top: 5px;
@@ -26,6 +26,7 @@ $height: 50px;
 			color: #fff;
 			font-size: 16px;
 			padding: 0 10px;
+			cursor: pointer;
 		}
 	}
 }

+ 6 - 11
src/views/Home.vue

@@ -18,7 +18,7 @@
 				<span>
 					<!-- <img width="16" src="../images/msg.png" alt="">  -->
 					肖</span>
-        <span>退出登录</span>
+        <span @click="logout">退出登录</span>
 			</div>
 		</el-header>
 		<el-container class="main">
@@ -68,18 +68,13 @@ export default {
 		};
 	},
 	methods: {
-	
+		logout(){
+			this.$api.logout().then(res=>{
+				this.$router.push({path:'/login'})
+			})
+		}
 	},
 	$route(to){
-		// if(to.path.indexOf('add')){
-		// 	this.path=to.path.split('/add')[0]
-		// }
-		// if(to.path.indexOf('edit')){
-		// 	this.path=to.path.split('/edit')[0]
-		// }
-		// if(to.path.indexOf('detail')){
-		// 	this.path=to.path.split('/detail')[0]
-		// }
     },
 	created(){
 		// if(this.$route.path.indexOf('add')>=0){

+ 1 - 1
src/views/project/Index.vue

@@ -182,7 +182,7 @@ export default {
                       this.add=0
                       this.getData()
                   }else{
-                      this.$message.error("保存失败");
+                      this.$message.error(res.data.message);
                   }
               })
           }else{