forked from devsam/core
- eslint에 prettier 조합 - prettierrc에 width 120, tabWidth 2 - gameStor->map_theme 제거 - map_theme, mapTheme를 GameConst::$mapName으로 대체 - eslint에서 vue/vue3-essential 대신 vue3-recommended 적용 - vue/max-attributes-per-line 완화 - vue/v-on-event-hyphenation 해제 - vue/attribute-hyphenation 해제 - 일부 tsc import type warning 해결 - 일부 vue template type warning 해결 - 일부 vue SFC를 script setup으로 변경 - TipTap - TopBackBar - BottomBackBar - BoardArticle - ProcessCity
106 lines
2.5 KiB
Vue
106 lines
2.5 KiB
Vue
<template>
|
|
<div class="articleFrame bg0">
|
|
<div class="bg1 row gx-0">
|
|
<div class="authorName center">
|
|
{{ article.author }}
|
|
</div>
|
|
<div class="col articleTitle center">
|
|
{{ article.title }}
|
|
</div>
|
|
<div class="col-2 col-md-1 date center">
|
|
{{ article.date.slice(5, 16) }}
|
|
</div>
|
|
</div>
|
|
<div class="row gx-0 s-border-b">
|
|
<div class="col-2 col-md-1 authorIcon center">
|
|
<img class="generalIcon" width="64" height="64" :src="article.author_icon" />
|
|
</div>
|
|
<div class="col text">
|
|
{{ article.text }}
|
|
</div>
|
|
</div>
|
|
<div class="commentList">
|
|
<board-comment v-for="comment in article.comment" :key="comment.no" :comment="comment" />
|
|
</div>
|
|
<div class="row gx-0">
|
|
<div class="bg2 inputCommentHeader center d-grid">
|
|
<div class="align-self-center">댓글 달기</div>
|
|
</div>
|
|
<div class="col d-grid">
|
|
<input
|
|
v-model.trim="newCommentText"
|
|
class="commentText"
|
|
type="text"
|
|
maxlength="250"
|
|
placeholder="새 댓글 내용"
|
|
@keyup.enter="submitComment"
|
|
/>
|
|
</div>
|
|
<div class="col-2 col-md-1 d-grid">
|
|
<b-button class="submitComment" size="sm" @click="submitComment"> 등록 </b-button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<script lang="ts" setup>
|
|
import type { BoardArticleItem } from "@/PageBoard.vue";
|
|
import BoardComment from "@/components/BoardComment.vue";
|
|
import { ref, type PropType } from "vue";
|
|
import axios from "axios";
|
|
import { convertFormData } from "@util/convertFormData";
|
|
import type { InvalidResponse } from "@/defs";
|
|
|
|
const newCommentText = ref("");
|
|
|
|
const props = defineProps({
|
|
article: {
|
|
type: Object as PropType<BoardArticleItem>,
|
|
required: true,
|
|
},
|
|
});
|
|
|
|
const emit = defineEmits<{
|
|
(event: "submit-comment"): void;
|
|
}>();
|
|
|
|
async function submitComment() {
|
|
const comment = newCommentText.value;
|
|
if (!comment) {
|
|
return;
|
|
}
|
|
const articleNo = props.article.no;
|
|
|
|
let result: InvalidResponse;
|
|
|
|
try {
|
|
const response = await axios({
|
|
url: "j_board_comment_add.php",
|
|
method: "post",
|
|
responseType: "json",
|
|
data: convertFormData({
|
|
articleNo: articleNo,
|
|
text: comment,
|
|
}),
|
|
});
|
|
result = response.data;
|
|
if (!result.result) {
|
|
throw result.reason;
|
|
}
|
|
} catch (e) {
|
|
console.error(e);
|
|
alert(`실패했습니다: ${e}`);
|
|
return;
|
|
}
|
|
|
|
newCommentText.value = "";
|
|
|
|
emit("submit-comment");
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
td.text {
|
|
white-space: pre;
|
|
}
|
|
</style>
|