Skip to content

Commit

Permalink
Merge pull request #158 from Docent-Inc/feature/리소스최적화
Browse files Browse the repository at this point in the history
Feature/리소스최적화 - 리소스 로딩 속도 최적화
  • Loading branch information
yusiny authored Jan 21, 2024
2 parents 9d1defd + 1fec920 commit a1cadbb
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 80 deletions.
39 changes: 21 additions & 18 deletions assets/scss/base/font.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
font-weight: 700;
src:
local("Spoqa Han Sans Bold"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Bold.woff2")
format("woff2"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Bold.woff")
format("woff"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Bold.eot")
format("eot"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Bold.otf")
format("otf"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Bold.ttf")
format("truetype"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Bold.woff")
format("woff"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Bold.woff2")
format("woff2");
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Bold.otf")
format("otf");

font-display: swap;
}

Expand All @@ -24,16 +25,17 @@
font-weight: 500;
src:
local("Spoqa Han Sans Medium"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Medium.woff2")
format("woff2"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Medium.woff")
format("woff"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Medium.eot")
format("eot"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Medium.otf")
format("otf"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Medium.ttf")
format("truetype"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Medium.woff")
format("woff"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Medium.woff2")
format("woff2");
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Medium.otf")
format("otf");

font-display: swap;
}

Expand All @@ -42,16 +44,17 @@
font-weight: 400;
src:
local("Spoqa Han Sans Regular"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Regular.woff2")
format("woff2"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Regular.woff")
format("woff"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Regular.eot")
format("eot"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Regular.otf")
format("otf"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Regular.ttf")
format("truetype"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Regular.woff")
format("woff"),
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Regular.woff2")
format("woff2");
url("../../fonts/SpoqaHanSansNeo/SpoqaHanSansNeo-Regular.otf")
format("otf");

font-display: swap;
}

Expand Down
116 changes: 58 additions & 58 deletions components/diary/BoardDiary.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<template>
<div class="item-board-diary" @click="showDetail">
<img v-if="diary.image_url !== ''" :src="diary.image_url" />
<img v-if="diary.image_url !== ''" v-lazyload="diary.image_url" />
<div v-else class="diary-contents">
<div v-if="diary.diary_name === ''">
<div class="diary-text-only">
{{ diary.content }}
<div v-if="diary.diary_name === ''">
<div class="diary-text-only">
{{ diary.content }}
</div>
</div>
</div>
<div v-else>
<div class="diary-title">
{{ diary.diary_name }}
<div v-else>
<div class="diary-title">
{{ diary.diary_name }}
</div>
<div class="diary-text">
{{ diary.content === "" ? "" : diary.content }}
</div>
</div>
<div class="diary-text">
{{ diary.content === "" ? "" : diary.content }}
</div>
</div>
</div>
<div class="diary-date">
{{ this.$dayjs(this.diary.create_date).format("YYYY.MM.DD") }}
Expand Down Expand Up @@ -81,54 +81,54 @@ export default {
font-size: 12px;
line-height: 160%;
}
.diary-contents {
height: 100%;
width: 100%;
padding-top: 100%;
position: relative;
background: var(--white, #FFF);
overflow: hidden;
.diary-contents {
height: 100%;
width: 100%;
padding-top: 100%;
position: relative;
background: var(--white, #fff);
overflow: hidden;
.diary-title {
position: absolute;
top: 12px;
left: 20px;
right: 20px;
color: var(--gray-700, #374151);
font-family: "Pretendard Bold";
font-size: 20px;
white-space: nowrap;
overflow: hidden;
max-height: 30px;
text-overflow: ellipsis;
}
.diary-text {
position: absolute;
max-height: 76px;
top: 54px;
left: 20px;
right: 20px;
color: var(--gray-400, #9CA3AF);
font-family: "Pretendard";
font-size: 12px;
overflow: hidden;
line-height: 160%;
text-overflow: ellipsis;
}
.diary-text-only {
position: absolute;
max-height: 110px;
top: 12px;
left: 20px;
right: 20px;
color: var(--gray-400, #9CA3AF);
font-family: "Pretendard";
line-height: 160%;
font-size: 12px;
overflow: hidden;
text-overflow: ellipsis;
.diary-title {
position: absolute;
top: 12px;
left: 20px;
right: 20px;
color: var(--gray-700, #374151);
font-family: "Pretendard Bold";
font-size: 20px;
white-space: nowrap;
overflow: hidden;
max-height: 30px;
text-overflow: ellipsis;
}
.diary-text {
position: absolute;
max-height: 76px;
top: 54px;
left: 20px;
right: 20px;
color: var(--gray-400, #9ca3af);
font-family: "Pretendard";
font-size: 12px;
overflow: hidden;
line-height: 160%;
text-overflow: ellipsis;
}
.diary-text-only {
position: absolute;
max-height: 110px;
top: 12px;
left: 20px;
right: 20px;
color: var(--gray-400, #9ca3af);
font-family: "Pretendard";
line-height: 160%;
font-size: 12px;
overflow: hidden;
text-overflow: ellipsis;
}
}
}
.diary_icon {
position: absolute;
right: 0;
Expand Down
1 change: 1 addition & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,6 @@ export default defineNuxtConfig({
"~/plugins/axios",
"~/plugins/native", // Native App 함수 호출
"~/plugins/functions", // Receive From Native App (JavaScript Functions)
"~/plugins/directives",
],
});
41 changes: 41 additions & 0 deletions plugins/directives.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* directives.ts
* 커스텀 디렉티브
*/

// v-lazyload (참고: https://url.kr/l5bxa1)
const lazyloadDirective = {
mounted(el, binding) {
function loadImage(targetElement, imageUrl) {
const imgElement = targetElement;
imgElement.setAttribute("src", imageUrl);
}

function callIntersectionApi() {
const options = {
root: null,
threshold: 0.5,
rootMargin: "0px",
};

const callback = (entries, observer) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
loadImage(entry.target, binding.value);
observer.unobserve(entry.target);
}
});
};

const lazyLoadingIO = new IntersectionObserver(callback, options);
lazyLoadingIO.observe(el);
}

// 지원하는 경우에만 Observe
window.IntersectionObserver ? callIntersectionApi() : loadImage(el);
},
};

export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.directive("lazyload", lazyloadDirective);
});
8 changes: 4 additions & 4 deletions store/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ export const useChatStore = defineStore("chat", {
};
this.addChat(resultChat);

if (result.text_type === 1 || result.text_type === 2) {
const { addOptimisticRecord } = useRecordStore();
addOptimisticRecord(result.content as Record, result.text_type);
}
// if (result.text_type === 1 || result.text_type === 2) {
// const { addOptimisticRecord } = useRecordStore();
// addOptimisticRecord(result.content as Record, result.text_type);
// }
return res;
},
/**
Expand Down

0 comments on commit a1cadbb

Please sign in to comment.