mirror of
https://github.com/headporter81/specialsource-homepage-frontend.git
synced 2026-12-06 07:11:02 +09:00
This commit is contained in:
1 parent
203d36b89b
commit
816a1d7711
2 files changed
+313
-1
No files matched your search
+209
-1
@@ -111,6 +111,78 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="activeMenu === 'board'" class="sub-page board-page" key="board">
|
||||
<h2 class="page-title">> EXECUTING COMMUNITY_FEED.EXE</h2>
|
||||
|
||||
<div class="board-layout">
|
||||
<div class="board-rail">
|
||||
<button
|
||||
class="rail-item"
|
||||
:class="{ active: activeBoardKey === '' }"
|
||||
@click="selectBoardSource('')"
|
||||
>
|
||||
<span>ALL</span>
|
||||
</button>
|
||||
<button
|
||||
v-for="src in boardSources"
|
||||
:key="src.boardKey"
|
||||
class="rail-item"
|
||||
:class="{ active: activeBoardKey === src.boardKey }"
|
||||
@click="selectBoardSource(src.boardKey)"
|
||||
>
|
||||
<span>{{ src.siteName }} · {{ src.boardName }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="board-feed">
|
||||
<div v-if="board.error === 'auth'" class="board-status">
|
||||
로그인이 필요한 기능입니다.
|
||||
<button class="board-login-btn" @click="changeMenu('login')">LOGIN</button>
|
||||
</div>
|
||||
<div v-else-if="board.loading && board.posts.length === 0" class="board-status">SYNCING BOARD DATA...</div>
|
||||
<div v-else-if="board.error" class="board-status">FAILED TO LOAD BOARD DATA.</div>
|
||||
<div v-else-if="board.posts.length === 0" class="board-status">NO POSTS FOUND.</div>
|
||||
<template v-else>
|
||||
<button
|
||||
v-for="post in board.posts"
|
||||
:key="post.id"
|
||||
class="board-card"
|
||||
@click="openPostDetail(post)"
|
||||
>
|
||||
<img
|
||||
v-if="post.images[0]"
|
||||
:src="post.images[0]"
|
||||
referrerpolicy="no-referrer"
|
||||
loading="lazy"
|
||||
class="board-thumb"
|
||||
@error="$event.target.style.visibility = 'hidden'"
|
||||
/>
|
||||
<div v-else class="board-thumb board-thumb-empty"></div>
|
||||
<div class="board-card-body">
|
||||
<div class="board-card-top">
|
||||
<span class="board-tag">{{ post.sourceLabel }}</span>
|
||||
</div>
|
||||
<div class="board-card-title">{{ post.title }}</div>
|
||||
<div class="board-card-meta">
|
||||
<span v-if="post.createdAt">{{ post.createdAt }}</span>
|
||||
<span v-if="post.views !== null">조회 {{ post.views }}</span>
|
||||
<span v-if="post.likes !== null">추천 {{ post.likes }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
v-if="board.hasMore"
|
||||
class="board-load-more"
|
||||
:disabled="board.loading"
|
||||
@click="loadMoreBoardPosts"
|
||||
>
|
||||
{{ board.loading ? 'LOADING...' : '더 보기' }}
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="activeMenu === 'login'" class="sub-page login-page" key="login">
|
||||
<div class="login-terminal-frame">
|
||||
<h2 class="login-gate-title">> SECURE_AUTHENTICATION_GATEWAY.EXE</h2>
|
||||
@@ -196,6 +268,12 @@
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<transition name="fade">
|
||||
<div v-if="postDetail.show" class="tui-global-overlay" @click.self="closePostDetail">
|
||||
<TuiPostDetail :post="postDetail.post" @close="closePostDetail" />
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<transition name="fade">
|
||||
<div v-if="isBooting" class="boot-log-screen">
|
||||
<div class="boot-log-box">
|
||||
@@ -212,6 +290,7 @@ import { ref, onMounted, onUnmounted, computed, watch } from 'vue';
|
||||
import axios from 'axios';
|
||||
import TuiProgressBar from '@/components/TuiProgressBar.vue';
|
||||
import TuiAlert from '@/components/TuiAlert.vue';
|
||||
import TuiPostDetail from '@/components/TuiPostDetail.vue';
|
||||
|
||||
const videos = ref([]);
|
||||
const terminalRef = ref(null);
|
||||
@@ -258,6 +337,9 @@ const BOOT_SEQUENCE = [
|
||||
'[SUCCESS] BOOT SEQUENCE COMPLETE.'
|
||||
];
|
||||
|
||||
const BOOT_LOG_STORAGE_KEY = 'lastBootLogTimestamp';
|
||||
const BOOT_LOG_INTERVAL_MS = 60 * 60 * 1000;
|
||||
|
||||
const runBootSequence = () => {
|
||||
let i = 0;
|
||||
const pushLine = () => {
|
||||
@@ -274,6 +356,15 @@ const runBootSequence = () => {
|
||||
pushLine();
|
||||
};
|
||||
|
||||
const shouldShowBootLog = () => {
|
||||
const lastShown = Number(localStorage.getItem(BOOT_LOG_STORAGE_KEY));
|
||||
return !lastShown || Date.now() - lastShown >= BOOT_LOG_INTERVAL_MS;
|
||||
};
|
||||
|
||||
const markBootLogShown = () => {
|
||||
localStorage.setItem(BOOT_LOG_STORAGE_KEY, String(Date.now()));
|
||||
};
|
||||
|
||||
const systemAlert = ref({ show: false, message: '' });
|
||||
const showSystemAlert = (message) => {
|
||||
systemAlert.value = { show: true, message };
|
||||
@@ -353,9 +444,121 @@ const fetchWeatherData = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const BOARD_PAGE_SIZE = 20;
|
||||
|
||||
const board = ref({ loading: false, error: null, loaded: false, posts: [], page: 0, hasMore: false });
|
||||
const boardSources = ref([]);
|
||||
const activeBoardKey = ref('');
|
||||
const postDetail = ref({ show: false, post: null });
|
||||
|
||||
const boardAuthHeaders = () => ({ Authorization: `Bearer ${authToken.value}` });
|
||||
|
||||
const mapScrapedPost = (row) => ({
|
||||
id: row.id,
|
||||
source: row.boardKey,
|
||||
sourceLabel: `${row.siteName} · ${row.boardName}`,
|
||||
title: row.title || '(제목 없음)',
|
||||
url: row.link || null,
|
||||
author: row.author || '',
|
||||
createdAt: row.postedAt || '',
|
||||
views: row.viewCount ?? null,
|
||||
likes: row.likeCount ?? null,
|
||||
content: row.content || '',
|
||||
images: Array.isArray(row.imageUrls) ? row.imageUrls : []
|
||||
});
|
||||
|
||||
const fetchBoardMeta = async () => {
|
||||
try {
|
||||
const apiBaseUrl = import.meta.env.VITE_API_URL || '';
|
||||
const res = await axios.get(`${apiBaseUrl}/api/scraped-posts/boards`, {
|
||||
withCredentials: true,
|
||||
headers: boardAuthHeaders()
|
||||
});
|
||||
boardSources.value = res.data || [];
|
||||
} catch (err) {
|
||||
console.error("게시판 목록 로드 실패:", err);
|
||||
}
|
||||
};
|
||||
|
||||
const fetchBoardPosts = async (reset) => {
|
||||
if (reset) {
|
||||
board.value.page = 0;
|
||||
board.value.posts = [];
|
||||
}
|
||||
board.value.loading = true;
|
||||
board.value.error = null;
|
||||
try {
|
||||
const apiBaseUrl = import.meta.env.VITE_API_URL || '';
|
||||
const res = await axios.get(`${apiBaseUrl}/api/scraped-posts`, {
|
||||
params: {
|
||||
board: activeBoardKey.value || undefined,
|
||||
page: board.value.page,
|
||||
size: BOARD_PAGE_SIZE
|
||||
},
|
||||
withCredentials: true,
|
||||
headers: boardAuthHeaders()
|
||||
});
|
||||
const rows = (res.data && res.data.content) || [];
|
||||
const mapped = rows.map(mapScrapedPost);
|
||||
board.value.posts = reset ? mapped : board.value.posts.concat(mapped);
|
||||
board.value.hasMore = res.data.last === false;
|
||||
board.value.loaded = true;
|
||||
} catch (err) {
|
||||
console.error("게시판 데이터 로드 실패:", err);
|
||||
board.value.error = err?.response?.status === 401 || err?.response?.status === 403 ? 'auth' : 'network';
|
||||
} finally {
|
||||
board.value.loading = false;
|
||||
}
|
||||
};
|
||||
|
||||
const selectBoardSource = (boardKey) => {
|
||||
if (activeBoardKey.value === boardKey) return;
|
||||
activeBoardKey.value = boardKey;
|
||||
fetchBoardPosts(true);
|
||||
};
|
||||
|
||||
const loadMoreBoardPosts = () => {
|
||||
board.value.page += 1;
|
||||
fetchBoardPosts(false);
|
||||
};
|
||||
|
||||
const openPostDetail = async (post) => {
|
||||
postDetail.value = { show: true, post };
|
||||
|
||||
try {
|
||||
const apiBaseUrl = import.meta.env.VITE_API_URL || '';
|
||||
await axios.post(`${apiBaseUrl}/api/scraped-posts/${post.id}/view`, null, {
|
||||
withCredentials: true,
|
||||
headers: boardAuthHeaders()
|
||||
});
|
||||
board.value.posts = board.value.posts.filter((p) => p.id !== post.id);
|
||||
} catch (err) {
|
||||
console.error("게시물 조회 처리 실패:", err);
|
||||
}
|
||||
};
|
||||
|
||||
const closePostDetail = () => {
|
||||
postDetail.value.show = false;
|
||||
};
|
||||
|
||||
watch(activeMenu, (id) => {
|
||||
if (id !== 'board') return;
|
||||
|
||||
if (!authToken.value) {
|
||||
board.value.error = 'auth';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!board.value.loaded && !board.value.loading) {
|
||||
fetchBoardMeta();
|
||||
fetchBoardPosts(true);
|
||||
}
|
||||
});
|
||||
|
||||
const menuItems = [
|
||||
{ id: 'main', name: 'HOME' },
|
||||
{ id: 'youtube', name: 'YOUTUBE' },
|
||||
{ id: 'board', name: 'BOARD' },
|
||||
// { id: 'project', name: 'PROJECT' },
|
||||
{ id: 'about', name: 'ABOUT' },
|
||||
{ id: 'contact', name: 'CONTACT' }
|
||||
@@ -574,7 +777,12 @@ const handleLoginSubmit = async () => {
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
runBootSequence();
|
||||
if (shouldShowBootLog()) {
|
||||
runBootSequence();
|
||||
markBootLogShown();
|
||||
} else {
|
||||
isBooting.value = false;
|
||||
}
|
||||
|
||||
fetchVideos();
|
||||
fetchAnalyticsData();
|
||||
|
||||
Reference in new issue
Block a user