fix,refac: 회의실에서 줄 바꿈이 표기 안되는 버그 수정

This commit is contained in:
2022-07-12 00:09:58 +09:00
parent 48fe26e4b1
commit 87e063e03e
3 changed files with 94 additions and 118 deletions
+18 -39
View File
@@ -32,7 +32,7 @@
</div>
<div id="board">
<template v-if="articles && articles.length">
<board-article
<BoardArticle
v-for="article in articles"
:key="article.no"
:article="article"
@@ -46,8 +46,8 @@
</div>
</template>
<script lang="ts">
import { defineComponent, onMounted, reactive, ref } from "vue";
<script setup lang="ts">
import { onMounted, reactive, ref } from "vue";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
import BoardArticle from "@/components/BoardArticle.vue";
@@ -55,7 +55,6 @@ import { convertFormData } from "@util/convertFormData";
import axios from "axios";
import type { InvalidResponse } from "@/defs";
import { autoResizeTextarea } from "@util/autoResizeTextarea";
import { unwrap } from "@util/unwrap";
export type BoardResponse = {
result: true;
articles: Record<number, BoardArticleItem>;
@@ -85,21 +84,13 @@ export type BoardCommentItem = {
text: string;
};
export default defineComponent({
name: "PageBoard",
components: {
TopBackBar,
BottomBar,
BoardArticle,
},
props: {
const props = defineProps({
isSecretBoard: {
type: Boolean,
required: true,
},
},
});
setup(props) {
const newArticleTextForm = ref<HTMLInputElement>();
const articles = reactive<BoardArticleItem[]>([]);
@@ -135,25 +126,14 @@ export default defineComponent({
await reloadArticles();
});
return {
newArticleTextForm,
articles,
reloadArticles,
};
},
data() {
return {
title: this.isSecretBoard ? "기밀실" : "회의실",
newArticle: {
const title = ref(props.isSecretBoard ? "기밀실" : "회의실");
const newArticle = ref({
title: "",
text: "",
},
};
},
methods: {
autoResizeTextarea,
async submitArticle() {
const { title, text } = this.newArticle;
});
async function submitArticle() {
const { title, text } = newArticle.value;
if (!title && !text) {
return;
}
@@ -166,7 +146,7 @@ export default defineComponent({
method: "post",
responseType: "json",
data: convertFormData({
isSecret: this.isSecretBoard,
isSecret: props.isSecretBoard,
title,
text,
}),
@@ -181,12 +161,11 @@ export default defineComponent({
return;
}
this.newArticle = { title: "", text: "" };
const newArticleTextForm = unwrap(this.newArticleTextForm);
newArticleTextForm.style.height = "auto";
newArticle.value = { title: "", text: "" };
if (newArticleTextForm.value !== undefined) {
newArticleTextForm.value.style.height = "auto";
}
await this.reloadArticles();
},
},
});
await reloadArticles();
}
</script>
+3 -3
View File
@@ -20,7 +20,7 @@
</div>
</div>
<div class="commentList">
<board-comment v-for="comment in article.comment" :key="comment.no" :comment="comment" />
<BoardComment v-for="comment in article.comment" :key="comment.no" :comment="comment" />
</div>
<div class="row gx-0">
<div class="bg2 inputCommentHeader center d-grid">
@@ -98,8 +98,8 @@ async function submitComment() {
}
</script>
<style>
td.text {
<style scoped>
.text {
white-space: pre;
}
</style>
+3 -6
View File
@@ -15,17 +15,14 @@
</div>
</div>
</template>
<script lang="ts">
<script setup lang="ts">
import type { BoardCommentItem } from "@/PageBoard.vue";
import { defineComponent, type PropType } from "vue";
import type { PropType } from "vue";
export default defineComponent({
name: "BoardComment",
props: {
defineProps({
comment: {
type: Object as PropType<BoardCommentItem>,
required: true,
},
},
});
</script>