me page
This commit is contained in:
@@ -16,6 +16,10 @@
|
||||
<div>
|
||||
<button type="button" @click="logout">로그아웃</button>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<router-link to="/me">My</router-link>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
52
src/front/src/pages/me/Info.vue
Normal file
52
src/front/src/pages/me/Info.vue
Normal 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>
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user