diff --git a/public/css/custom.css b/public/css/custom.css index 0319927..c710f06 100644 --- a/public/css/custom.css +++ b/public/css/custom.css @@ -811,4 +811,10 @@ input:checked + .slider:before { } .mr-1{ margin-right: 0.25rem !important; +} + +.nickname-ellipsis { + white-space: nowrap; + max-width: 100px; + vertical-align: middle; } \ No newline at end of file diff --git a/src/components/board/BoardCommentArea.vue b/src/components/board/BoardCommentArea.vue index ed522cf..37813a0 100644 --- a/src/components/board/BoardCommentArea.vue +++ b/src/components/board/BoardCommentArea.vue @@ -41,6 +41,8 @@ v-model="nickname" placeholder="닉네임" @input="clearAlert('nickname')" + @keypress="noSpace" + :maxlength="6" />
| + + |
+
{{ selectedBoard === 'anonymous' ? '닉네임' : '작성자' }}
+
+ |
+
+
+ 제목
+
|
- 제목 | + |
+
{{ selectedBoard === 'anonymous' ? post.nickname : post.author }}
+
|
-
+
{{ truncateTitle(post.title) }}
[{{ post.commentCount }}]
@@ -120,97 +128,97 @@ const anonymousList = ref([]);
// 선택된 게시판에 따른 미리보기 목록 computed
const currentList = computed(() => {
-if (selectedBoard.value === 'notices') return noticeList.value;
-if (selectedBoard.value === 'general') return freeList.value;
-if (selectedBoard.value === 'anonymous') return anonymousList.value;
-return [];
+ if (selectedBoard.value === 'notices') return noticeList.value;
+ if (selectedBoard.value === 'general') return freeList.value;
+ if (selectedBoard.value === 'anonymous') return anonymousList.value;
+ return [];
});
// 날짜 포맷 함수: 오늘이면 HH:mm, 아니면 YYYY-MM-DD
const formatDate = dateString => {
-const date = dayjs(dateString);
-return date.isToday() ? date.format('HH:mm') : date.format('YYYY-MM-DD');
+ const date = dayjs(dateString);
+ return date.isToday() ? date.format('HH:mm') : date.format('YYYY-MM-DD');
};
// 제목이 14글자 넘어가면 ... 처리하는 함수
const truncateTitle = title => {
-return title.length > 7 ? title.slice(0, 7) + '...' : title;
+ return title.length > 7 ? title.slice(0, 7) + '...' : title;
};
// 공지사항 데이터 로드 (최대 5개)
const fetchNoticePosts = async () => {
-try {
- const { data } = await axios.get('board/notices', { params: { size: 8 } });
- if (data?.data) {
- noticeList.value = data.data.map(post => ({
- id: post.id,
- title: post.title,
- date: formatDate(post.date),
- rawDate: post.date,
- views: post.cnt || 0,
- commentCount: post.commentCount,
- img: post.firstImageUrl,
- author: post.author || '관리자',
- nickname: post.nickname || '관리자',
- hasAttachment: post.hasAttachment, // 첨부파일 유무
- }));
+ try {
+ const { data } = await axios.get('board/notices', { params: { size: 8 } });
+ if (data?.data) {
+ noticeList.value = data.data.map(post => ({
+ id: post.id,
+ title: post.title,
+ date: formatDate(post.date),
+ rawDate: post.date,
+ views: post.cnt || 0,
+ commentCount: post.commentCount,
+ img: post.firstImageUrl,
+ author: post.author || '관리자',
+ nickname: post.nickname || '관리자',
+ hasAttachment: post.hasAttachment, // 첨부파일 유무
+ }));
+ }
+ } catch (error) {
}
-} catch (error) {
-}
};
// board/general 게시글 로드 후 자유게시판과 익명게시판으로 분리 (최대 10개 조회 → 각각 최대 5개)
const fetchGeneralPosts = async () => {
-try {
- const { data } = await axios.get('board/general', { params: { size: 16 } });
- if (data?.data && data.data.list) {
- const freePosts = [];
- const anonymousPosts = [];
- data.data.list.forEach(post => {
- if (post.nickname) {
- // 닉네임이 있으면 익명게시판 데이터
- anonymousPosts.push({
- id: post.id,
- title: post.title,
- date: formatDate(post.date),
- img: post.firstImageUrl,
- rawDate: post.date,
- views: post.cnt || 0,
- commentCount: post.commentCount,
- nickname: post.nickname,
- hasAttachment: post.hasAttachment, // 첨부파일 유무
- });
- } else {
- // 닉네임이 없으면 자유게시판 데이터
- freePosts.push({
- id: post.id,
- title: post.title,
- date: formatDate(post.date),
- rawDate: post.date,
- views: post.cnt || 0,
- img: post.firstImageUrl,
- commentCount: post.commentCount,
- author: post.author || '익명',
- hasAttachment: post.hasAttachment, // 첨부파일 유무
+ try {
+ const { data } = await axios.get('board/general', { params: { size: 16 } });
+ if (data?.data && data.data.list) {
+ const freePosts = [];
+ const anonymousPosts = [];
+ data.data.list.forEach(post => {
+ if (post.nickname) {
+ // 닉네임이 있으면 익명게시판 데이터
+ anonymousPosts.push({
+ id: post.id,
+ title: post.title,
+ date: formatDate(post.date),
+ img: post.firstImageUrl,
+ rawDate: post.date,
+ views: post.cnt || 0,
+ commentCount: post.commentCount,
+ nickname: post.nickname,
+ hasAttachment: post.hasAttachment, // 첨부파일 유무
+ });
+ } else {
+ // 닉네임이 없으면 자유게시판 데이터
+ freePosts.push({
+ id: post.id,
+ title: post.title,
+ date: formatDate(post.date),
+ rawDate: post.date,
+ views: post.cnt || 0,
+ img: post.firstImageUrl,
+ commentCount: post.commentCount,
+ author: post.author || '익명',
+ hasAttachment: post.hasAttachment, // 첨부파일 유무
+ });
+ }
});
+ freeList.value = freePosts.slice(0, 8);
+ anonymousList.value = anonymousPosts.slice(0, 8);
}
- });
- freeList.value = freePosts.slice(0, 8);
- anonymousList.value = anonymousPosts.slice(0, 8);
+ } catch (error) {
+ console.error(error);
}
-} catch (error) {
- console.error(error);
-}
};
// 탭 변경 함수
const changeBoard = type => {
-selectedBoard.value = type;
+ selectedBoard.value = type;
};
// 상세 페이지 이동 (게시판 타입 전달)
const goDetail = (id, boardType) => {
-router.push({ name: 'BoardDetail', params: { id }, query: { type: boardType } });
+ router.push({ name: 'BoardDetail', params: { id }, query: { type: boardType } });
};
// 모달이 열릴 때 데이터 로드
@@ -220,6 +228,6 @@ fetchGeneralPosts();
diff --git a/src/views/board/BoardList.vue b/src/views/board/BoardList.vue
index 2613414..a6f4ada 100644
--- a/src/views/board/BoardList.vue
+++ b/src/views/board/BoardList.vue
@@ -80,7 +80,7 @@
N
|
- {{ notice.author }} | +{{ notice.author }} | {{ notice.date }} | {{ notice.views }} | @@ -105,7 +105,7 @@ N -{{ post.nickname ? post.nickname : post.author }} | +{{ post.nickname ? post.nickname : post.author }} | {{ post.date }} | {{ post.views }} | @@ -384,4 +384,5 @@ position: relative; top: -1px; } + diff --git a/src/views/board/BoardWrite.vue b/src/views/board/BoardWrite.vue index 6317db5..c44e3a3 100644 --- a/src/views/board/BoardWrite.vue +++ b/src/views/board/BoardWrite.vue @@ -50,6 +50,8 @@ v-model="nickname" @update:alert="nicknameAlert = $event" @input="validateNickname" + @keypress="noSpace" + :maxlength="6" />
|---|