diff --git a/public/js/main.js b/public/js/main.js index b1dcbc9..c118e86 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -2,116 +2,121 @@ * Main */ -'use strict' +(function () { + // Initialize menu + //----------------- + let menu, animate; +<<<<<<< HEAD var menu, animate; (function () { // Initialize menu //----------------- +======= + let layoutMenuEl = document.querySelectorAll('#layout-menu'); + layoutMenuEl.forEach(function (element) { + menu = new Menu(element, { + orientation: 'vertical', + closeChildren: false, + }); + // Change parameter to true if you want scroll animation + window.Helpers.scrollToActive((animate = false)); + window.Helpers.mainMenu = menu; + }); +>>>>>>> board-comment - let layoutMenuEl = document.querySelectorAll('#layout-menu') - layoutMenuEl.forEach(function (element) { - menu = new Menu(element, { - orientation: 'vertical', - closeChildren: false, - }) - // Change parameter to true if you want scroll animation - window.Helpers.scrollToActive((animate = false)) - window.Helpers.mainMenu = menu - }) + // Initialize menu togglers and bind click on each + let menuToggler = document.querySelectorAll('.layout-menu-toggle'); + menuToggler.forEach(item => { + item.addEventListener('click', event => { + event.preventDefault(); + window.Helpers.toggleCollapsed(); + }); + }); - // Initialize menu togglers and bind click on each - let menuToggler = document.querySelectorAll('.layout-menu-toggle') - menuToggler.forEach((item) => { - item.addEventListener('click', (event) => { - event.preventDefault() - window.Helpers.toggleCollapsed() - }) - }) + // Display menu toggle (layout-menu-toggle) on hover with delay + let delay = function (elem, callback) { + let timeout = null; + elem.onmouseenter = function () { + // Set timeout to be a timer which will invoke callback after 300ms (not for small screen) + if (!Helpers.isSmallScreen()) { + timeout = setTimeout(callback, 300); + } else { + timeout = setTimeout(callback, 0); + } + }; - // Display menu toggle (layout-menu-toggle) on hover with delay - let delay = function (elem, callback) { - let timeout = null - elem.onmouseenter = function () { - // Set timeout to be a timer which will invoke callback after 300ms (not for small screen) - if (!Helpers.isSmallScreen()) { - timeout = setTimeout(callback, 300) - } else { - timeout = setTimeout(callback, 0) - } + elem.onmouseleave = function () { + // Clear any timers set to timeout + document.querySelector('.layout-menu-toggle').classList.remove('d-block'); + clearTimeout(timeout); + }; + }; + if (document.getElementById('layout-menu')) { + delay(document.getElementById('layout-menu'), function () { + // not for small screen + if (!Helpers.isSmallScreen()) { + document.querySelector('.layout-menu-toggle').classList.add('d-block'); + } + }); } - elem.onmouseleave = function () { - // Clear any timers set to timeout - document.querySelector('.layout-menu-toggle').classList.remove('d-block') - clearTimeout(timeout) + // Display in main menu when menu scrolls + let menuInnerContainer = document.getElementsByClassName('menu-inner'), + menuInnerShadow = document.getElementsByClassName('menu-inner-shadow')[0]; + if (menuInnerContainer.length > 0 && menuInnerShadow) { + menuInnerContainer[0].addEventListener('ps-scroll-y', function () { + if (this.querySelector('.ps__thumb-y').offsetTop) { + menuInnerShadow.style.display = 'block'; + } else { + menuInnerShadow.style.display = 'none'; + } + }); } - } - if (document.getElementById('layout-menu')) { - delay(document.getElementById('layout-menu'), function () { - // not for small screen - if (!Helpers.isSmallScreen()) { - document.querySelector('.layout-menu-toggle').classList.add('d-block') - } - }) - } - // Display in main menu when menu scrolls - let menuInnerContainer = document.getElementsByClassName('menu-inner'), - menuInnerShadow = document.getElementsByClassName('menu-inner-shadow')[0] - if (menuInnerContainer.length > 0 && menuInnerShadow) { - menuInnerContainer[0].addEventListener('ps-scroll-y', function () { - if (this.querySelector('.ps__thumb-y').offsetTop) { - menuInnerShadow.style.display = 'block' - } else { - menuInnerShadow.style.display = 'none' - } - }) - } + // Init helpers & misc + // -------------------- - // Init helpers & misc - // -------------------- + // Init BS Tooltip + const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')); + tooltipTriggerList.map(function (tooltipTriggerEl) { + return new bootstrap.Tooltip(tooltipTriggerEl); + }); - // Init BS Tooltip - const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')) - tooltipTriggerList.map(function (tooltipTriggerEl) { - return new bootstrap.Tooltip(tooltipTriggerEl) - }) + // Accordion active class + const accordionActiveFunction = function (e) { + if (e.type == 'show.bs.collapse' || e.type == 'show.bs.collapse') { + e.target.closest('.accordion-item').classList.add('active'); + } else { + e.target.closest('.accordion-item').classList.remove('active'); + } + }; - // Accordion active class - const accordionActiveFunction = function (e) { - if (e.type == 'show.bs.collapse' || e.type == 'show.bs.collapse') { - e.target.closest('.accordion-item').classList.add('active') - } else { - e.target.closest('.accordion-item').classList.remove('active') + const accordionTriggerList = [].slice.call(document.querySelectorAll('.accordion')); + const accordionList = accordionTriggerList.map(function (accordionTriggerEl) { + accordionTriggerEl.addEventListener('show.bs.collapse', accordionActiveFunction); + accordionTriggerEl.addEventListener('hide.bs.collapse', accordionActiveFunction); + }); + + // Auto update layout based on screen size + window.Helpers.setAutoUpdate(true); + + // Toggle Password Visibility + window.Helpers.initPasswordToggle(); + + // Speech To Text + window.Helpers.initSpeechToText(); + + // Manage menu expanded/collapsed with templateCustomizer & local storage + //------------------------------------------------------------------ + + // If current layout is horizontal OR current window screen is small (overlay menu) than return from here + if (window.Helpers.isSmallScreen()) { + return; } - } - const accordionTriggerList = [].slice.call(document.querySelectorAll('.accordion')) - const accordionList = accordionTriggerList.map(function (accordionTriggerEl) { - accordionTriggerEl.addEventListener('show.bs.collapse', accordionActiveFunction) - accordionTriggerEl.addEventListener('hide.bs.collapse', accordionActiveFunction) - }) + // If current layout is vertical and current window screen is > small - // Auto update layout based on screen size - window.Helpers.setAutoUpdate(true) - - // Toggle Password Visibility - window.Helpers.initPasswordToggle() - - // Speech To Text - window.Helpers.initSpeechToText() - - // Manage menu expanded/collapsed with templateCustomizer & local storage - //------------------------------------------------------------------ - - // If current layout is horizontal OR current window screen is small (overlay menu) than return from here - if (window.Helpers.isSmallScreen()) { - return - } - - // If current layout is vertical and current window screen is > small - - // Auto update menu collapsed/expanded based on the themeConfig - window.Helpers.setCollapsed(true, false) -})() + // Auto update menu collapsed/expanded based on the themeConfig + window.Helpers.setCollapsed(true, false); +})(); diff --git a/src/common/common.js b/src/common/common.js index e761219..5436651 100644 --- a/src/common/common.js +++ b/src/common/common.js @@ -15,35 +15,69 @@ import Quill from 'quill'; $common.변수 */ const common = { - // JSON 문자열로 Delta 타입을 변환 - contentToHtml(content) { - try { - if (content.startsWith('{') || content.startsWith('[')) { - // Delta 형식으로 변환 - const delta = JSON.parse(content); - const quill = new Quill(document.createElement('div')); - quill.setContents(delta); - return quill.root.innerHTML; // HTML 반환 - } - return content; // 이미 HTML일 경우 그대로 반환 - } catch (error) { - console.error('콘텐츠 변환 오류:', error); - return content; // 오류 발생 시 원본 반환 - } - }, - // Delta 타입을 JSON 문자열로 변환 - deltaAsJson(content) { - if (content && content.ops) { - return JSON.stringify(content.ops); // Delta 객체에서 ops 속성만 JSON 문자열로 변환 - } - console.error('잘못된 Delta 객체:', content); - return null; // Delta 객체가 아니거나 ops가 없을 경우 null 반환 - } + // JSON 문자열로 Delta 타입을 변환 + contentToHtml(content) { + try { + if (content.startsWith('{') || content.startsWith('[')) { + // Delta 형식으로 변환 + const delta = JSON.parse(content); + const quill = new Quill(document.createElement('div')); + quill.setContents(delta); + return quill.root.innerHTML; // HTML 반환 + } + return content; // 이미 HTML일 경우 그대로 반환 + } catch (error) { + console.error('콘텐츠 변환 오류:', error); + return content; // 오류 발생 시 원본 반환 + } + }, + // Delta 타입을 JSON 문자열로 변환 + deltaAsJson(content) { + if (content && content.ops) { + return JSON.stringify(content.ops); // Delta 객체에서 ops 속성만 JSON 문자열로 변환 + } + console.error('잘못된 Delta 객체:', content); + return null; // Delta 객체가 아니거나 ops가 없을 경우 null 반환 + }, -} + /** + * Date 타입 문자열 포멧팅 + * + * @param {string} dateStr + * @return + * 1. Date type 인 경우 예시 '25-02-24 12:02' + * 2. Date type 이 아닌 경우 입력값 리턴 + * + */ + dateFormatter(dateStr) { + const date = new Date(dateStr); + const dateCheck = date.getTime(); + + if (isNaN(dateCheck)) { + return dateStr; + } else { + const { year, month, day, hours, minutes } = this.formatDateTime(date); + return `${year}-${month}-${day} ${hours}:${minutes}`; + } + }, + + formatDateTime(date) { + const zeroFormat = num => (num < 10 ? `0${num}` : num); + + return { + year: date.getFullYear(), + month: zeroFormat(date.getMonth() + 1), + day: zeroFormat(date.getDate()), + hours: zeroFormat(date.getHours()), + minutes: zeroFormat(date.getMinutes()), + seconds: zeroFormat(date.getSeconds()), + }; + }, +}; export default { - install(app) { - app.config.globalProperties.$common = common; - } + install(app) { + app.config.globalProperties.$common = common; + app.provide('common', common); + }, }; diff --git a/src/common/formattedDate.js b/src/common/formattedDate.js new file mode 100644 index 0000000..01956d6 --- /dev/null +++ b/src/common/formattedDate.js @@ -0,0 +1,13 @@ +/** 날짜 포맷1 (YYYY-MM-DD HH:MM) */ +export const formattedDate = (dateString) => { + if (!dateString) return "날짜 없음"; + const dateObj = new Date(dateString); + return `${dateObj.getFullYear()}-${String(dateObj.getMonth() + 1).padStart(2, '0')}-${String(dateObj.getDate()).padStart(2, '0')} ${String(dateObj.getHours()).padStart(2, '0')}:${String(dateObj.getMinutes()).padStart(2, '0')}`; +}; + +/** 날짜 포맷2 (YYYY-MM-DD) */ +export const formatDate = (dateString) => { + if (!dateString) return "날짜 없음"; + const dateObj = new Date(dateString); + return `${dateObj.getFullYear()}-${String(dateObj.getMonth() + 1).padStart(2, '0')}-${String(dateObj.getDate()).padStart(2, '0')}`; +}; diff --git a/src/components/board/BoardComment.vue b/src/components/board/BoardComment.vue index 932c36f..2d0c784 100644 --- a/src/components/board/BoardComment.vue +++ b/src/components/board/BoardComment.vue @@ -2,18 +2,20 @@
+ /> +
@@ -27,7 +29,9 @@
{{ passwordCommentAlert }}
- +

authorId:{{ comment.authorId }}

+

코멘트 비교: {{comment.isCommentAuthor}}

+
- + diff --git a/src/layouts/TheTop.vue b/src/layouts/TheTop.vue index 9957c39..9d219e8 100644 --- a/src/layouts/TheTop.vue +++ b/src/layouts/TheTop.vue @@ -152,7 +152,7 @@