This commit is contained in:
이진석
2020-02-05 16:24:17 +09:00
parent d2b0765250
commit 8ac66c6e5a
4 changed files with 64 additions and 2 deletions

View File

@@ -16,6 +16,10 @@
<div>
<button type="button" @click="logout">로그아웃</button>
</div>
<div>
<router-link to="/me">My</router-link>
</div>
</div>
</template>

View File

@@ -45,12 +45,13 @@
if (id) {
try {
const result = await articleApi.getArticle(id);
const {title, content} = result.data;
const { data } = await articleApi.getArticle(id);
const {title, content} = data;
this.title = title;
this.content = content;
this.isEdit = true;
} catch (err) {
alert('문제가 발생하였습니다.');
console.log(err);
}
}

View File

@@ -0,0 +1,52 @@
<template>
<div>
<div v-if="user">
<table>
<tr>
<td>이름</td>
<td>{{ user.name }}</td>
</tr>
<tr>
<td>이메일</td>
<td>{{ user.email }}</td>
</tr>
<tr>
<td>가입일</td>
<td>{{ user.createdAt || '-' }}</td>
</tr>
</table>
</div>
</div>
</template>
<script>
import authApi from "../../api/authApi";
export default {
name: "Info",
data() {
return {
user: null,
init: false
}
},
async beforeCreate() {
authApi.bind(this);
try {
const { data } = await authApi.session();
this.user = data;
} catch (err) {
console.log(err);
await this.$router.replace('/auth/login');
}
}
}
</script>
<style scoped>
.row {
display: flex;
justify-content: space-between;
}
</style>

View File

@@ -7,6 +7,7 @@ import Register from "../pages/auth/Register";
import Articles from "../pages/articles/List";
import WriteArticle from '../pages/articles/Write';
import DetailArticle from '../pages/articles/Detail';
import Info from "../pages/me/Info";
Vue.use(VueRouter);
@@ -38,6 +39,10 @@ export const router = new VueRouter({
path: '/articles/:id',
name: 'DetailArticle',
component: DetailArticle
},
{
path: '/me',
component: Info
}
]
});