Files
specialsource-homepage-fron…/src/views/Main.vue
T
headporter 35e73e1b52
SpecialSource Frontend CD / deploy (push) Successful in 7s
chore : 배포 테스트
2026-11-11 14:11:02 +09:00

1038 lines
37 KiB
Vue

<template>
<div :class="['homepage-wrapper', `theme-${activeTheme}`, { 'intro-done': logoDone }]">
<nav class="auth-nav">
<div class="nav-left">
<span class="status-dot" :class="{ 'secure-mode': isLoggedIn }"></span>
<span class="brand">SPECIALSOURCE.SYSTEM</span>
<span :class="['server-badge', currentServerSource]">
[{{ currentServerSourceDisplay }}]
</span>
<div v-if="isLoggedIn" class="nav-stats">
[LIVE:<span class="pulse-text">{{ activeNow }}</span>|TODAY:{{ todayUnique }}]
</div>
<select v-model="activeTheme" class="theme-selector">
<option value="green">IBM 5151 (그린)</option>
<option value="amber">ZVM-1240 (호박)</option>
<option value="vga">IBM 8503 (회색)</option>
<option value="ega">IBM 5154 (청록)</option>
<option value="white">VT220 (백색)</option>
<option value="plasma">GRiD COMPASS (플라즈마)</option>
</select>
<button
class="pc-mode-btn"
:class="{ active: pcTongsinMode }"
@click="togglePcTongsinMode"
>
PC통신 모드
</button>
</div>
<div class="nav-menu">
<button
v-for="item in menuItems"
:key="item.id"
@click="changeMenu(item.id)"
:class="['menu-btn', { active: activeMenu === item.id }]"
>
{{ item.name }}
</button>
</div>
<div class="nav-right">
<div v-if="!isLoggedIn" class="auth-group">
<button @click="changeMenu('login')" :class="['nav-item', { 'active-auth': activeMenu === 'login' }]">LOGIN</button>
<button @click="handleRegister" class="nav-item btn-reg">SIGN UP</button>
</div>
<div v-else class="auth-group">
<span class="user-info">ACCESS GRANTED: ADMIN</span>
<button @click="handleLogout" class="nav-item btn-logout">LOGOUT</button>
</div>
</div>
</nav>
<main class="content-area">
<transition name="fade" mode="out-in">
<div v-if="activeMenu === 'main'" class="sub-page main-page" key="main">
<template v-if="!pcTongsinMode">
<div class="ascii-container" :class="{ 'is-collapsed': logoDone }">
<div class="ascii-clip">
<transition name="fade">
<pre
v-if="!isBooting && !logoDone"
class="ascii-art"
v-html="formattedAscii"
@animationend="logoDone = true"
></pre>
</transition>
</div>
</div>
<div v-if="!isBooting" class="dash-grid">
<div v-if="isLoggedIn" class="dash-panel">
<h4>LIVE SESSION</h4>
<div class="dash-stat"><span>LIVE</span><b class="pulse-text">{{ activeNow }}</b></div>
<div class="dash-stat"><span>TODAY</span><b>{{ todayUnique }}</b></div>
</div>
<div class="dash-panel">
<h4>SERVER SOURCE</h4>
<span :class="['dash-chip', currentServerSource]">[{{ currentServerSourceDisplay }}]</span>
</div>
<div class="dash-panel weather-panel">
<h4>SEOUL WEATHER</h4>
<div v-if="weather.loading" class="weather-loading">SYNCING...</div>
<div v-else-if="weather.error" class="weather-loading">SYNC FAILED</div>
<template v-else>
<pre class="weather-ascii">{{ weatherIcon }}</pre>
<div class="dash-stat"><span>TEMP</span><b>{{ weather.temp }}°C</b></div>
<div class="dash-stat"><span>COND</span><b>{{ weatherLabel }}</b></div>
</template>
</div>
<div class="dash-panel">
<h4>SESSION</h4>
<div class="dash-stat"><span>USER</span><b>{{ isLoggedIn ? currentUsername : 'anonymous' }}</b></div>
<div class="dash-stat"><span>DISPLAY</span><b>{{ activeThemeLabel }}</b></div>
</div>
</div>
</template>
<div v-else class="pc-tongsin-screen">
<div class="pc-titlebar">
<span>SPECIALSOURCE-BBS v3.2</span>
<span>{{ isLoggedIn ? `ONLINE · ${currentUsername || 'admin'} 접속중` : 'ONLINE · 비로그인' }}</span>
</div>
<div class="pc-body">
<div class="pc-screen-title">SPECIALSOURCE.SYSTEM 메인 메뉴</div>
<div class="pc-screen-sub">하단 터미널에 번호나 메뉴명을 입력하거나, 줄을 클릭하세요.</div>
<hr class="pc-rule">
<div
v-for="(entry, idx) in pcMenuEntries"
:key="entry.id"
class="pc-menu-row"
@click="activatePcMenuEntry(entry)"
>
<span class="pc-menu-num">{{ idx + 1 }}.</span>
<span class="pc-menu-label">{{ entry.name }}</span>
<span v-if="entry.id === 'board' && board.loaded" class="pc-menu-badge">(안읽음 {{ board.posts.length }})</span>
</div>
<hr class="pc-rule">
<div class="pc-footer-hint">예) <b>3</b> 또는 <b>board</b> 입력 → 자유게시판 이동</div>
</div>
</div>
</div>
<div v-else-if="activeMenu === 'youtube'" id="videos-container" key="youtube">
<div
v-for="(video, index) in videos"
:key="video.id.videoId"
class="video-card"
:class="{ 'new-item': index === 0 }"
@click="openVideo(video.id.videoId)"
>
<iframe
:src="`https://www.youtube-nocookie.com/embed/${video.id.videoId}`"
frameborder="0"
allowfullscreen
></iframe>
<h5 class="video-title">{{ video.snippet.title }}</h5>
</div>
</div>
<div v-else-if="activeMenu === 'board'" class="sub-page board-page" key="board">
<div class="board-page-head">
<h2 class="page-title">> EXECUTING COMMUNITY_FEED.EXE</h2>
<div class="board-mode-toggle">
<button
class="mode-toggle-btn"
:class="{ active: boardViewMode === 'unread' }"
@click="setBoardViewMode('unread')"
>
안 읽음
</button>
<button
class="mode-toggle-btn"
:class="{ active: boardViewMode === 'viewed' }"
@click="setBoardViewMode('viewed')"
>
읽음
</button>
</div>
</div>
<div v-if="!pcTongsinMode" 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">
{{ boardViewMode === 'viewed' ? '아직 읽은 게시물이 없습니다.' : '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>
<span v-if="boardViewMode === 'viewed' && post.viewedAt">읽음 {{ post.viewedAt }}</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>
<p class="login-gate-desc">WARNING: UNAUTHORIZED ACCESS IS STRICTLY PROHIBITED BY COMPLIANCE LAW.</p>
<div class="login-form-form">
<div class="login-input-group">
<label class="login-label">ACCESS ID_</label>
<input
v-model="loginId"
type="text"
class="login-input"
placeholder="ENTER ACCESS ID"
@keyup.enter="handleLoginSubmit"
/>
</div>
<div class="login-input-group">
<label class="login-label">ACCESS KEY_</label>
<input
v-model="loginPw"
type="password"
class="login-input"
placeholder="ENTER ENCRYPTION KEY"
@keyup.enter="handleLoginSubmit"
/>
</div>
<button @click="handleLoginSubmit" class="login-submit-btn">
[ INITIALIZE DECRYPT & ACCESS ]
</button>
</div>
</div>
</div>
<div v-else-if="activeMenu === 'project'" class="sub-page project-page" key="project">
<h2 class="page-title">> EXECUTING PROJECTS_LOG.EXE</h2>
<div class="project-grid">
<div class="project-item" v-for="i in 3" :key="i">
<div class="item-header">PROJ_00{{i}}</div>
<p>스페셜소스 자동 배포 시스템 고도화 프로젝트 진행 중...</p>
<div class="status">STATUS: COMPLETED</div>
</div>
</div>
</div>
<div v-else-if="activeMenu === 'about'" class="sub-page about-page" key="about">
<h2 class="page-title">> ACCESSING CORE_IDENTITY.DAT</h2>
<p class="about-text">
스페셜소스는 2021년 설립된 기술 중심의 컴퍼니입니다.<br>
우리는 인프라 자동화와 효율적인 배포 파이프라인을 구축하여<br>
개발자가 비즈니스 로직에만 집중할 수 있는 환경을 만듭니다.
</p>
</div>
<div v-else-if="activeMenu === 'contact'" class="sub-page contact-page" key="contact">
<h2 class="page-title">> INITIALIZING ENCRYPTED_COMM.INK</h2>
<div class="contact-form">
<p>EMAIL: sungjin.choi@specialsource.company</p>
<p>LOCATION: SEOUL, SOUTH KOREA</p>
</div>
</div>
</transition>
</main>
<div class="crt-monitor-frame">
<div class="monitor-header">
<span class="monitor-title">📟 SECURE TERMINAL CONSOLE V3.2 [ROOT/{{ activeMenu.toUpperCase() }}]</span>
<span class="monitor-status">ACTIVE</span>
</div>
<div class="crt-screen-overlay">
<div ref="terminalRef" class="terminal-box"></div>
</div>
</div>
<transition name="fade">
<div v-if="isProcessing" class="tui-global-overlay">
<TuiProgressBar :progress="overlayProgress" :status="overlayStatus" />
</div>
</transition>
<transition name="fade">
<div v-if="systemAlert.show" class="tui-global-overlay" @click.self="systemAlert.show = false">
<TuiAlert :message="systemAlert.message" @close="systemAlert.show = false" />
</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">
<p v-for="(line, idx) in bootLines" :key="idx" class="boot-log-line">{{ line }}</p>
<span class="boot-cursor">_</span>
</div>
</div>
</transition>
</div>
</template>
<script setup>
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);
const termInstance = ref(null);
const loginId = ref('');
const loginPw = ref('');
const activeMenu = ref('main');
const authToken = ref(localStorage.getItem('token'));
const currentUsername = ref(localStorage.getItem('username') || '');
const THEME_LABELS = {
green: 'IBM 5151 (그린)',
amber: 'ZVM-1240 (호박)',
vga: 'IBM 8503 (회색)',
ega: 'IBM 5154 (청록)',
white: 'VT220 (백색)',
plasma: 'GRiD COMPASS (플라즈마)'
};
const VALID_THEMES = Object.keys(THEME_LABELS);
const storedTheme = localStorage.getItem('theme');
const activeTheme = ref(VALID_THEMES.includes(storedTheme) ? storedTheme : 'green');
const activeThemeLabel = computed(() => THEME_LABELS[activeTheme.value]);
watch(activeTheme, (theme) => {
localStorage.setItem('theme', theme);
});
const isProcessing = ref(false);
const overlayProgress = ref(0);
const overlayStatus = ref('');
const isBooting = ref(true);
const logoDone = ref(false);
const bootLines = ref([]);
const BOOT_SEQUENCE = [
'[SYS] SPECIALSOURCE.SYSTEM BIOS V3.2',
'[SYS] PERFORMING MEMORY CHECK... OK',
'[SYS] INITIALIZING KERNEL MODULES...',
'[SYS] MOUNTING VIRTUAL FILESYSTEM... OK',
'[SYS] ESTABLISHING SECURE NETWORK LINK...',
'[SYS] LOADING DASHBOARD INTERFACE...',
'[SYS] SPAWNING TERMINAL CONSOLE...',
'[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 = () => {
if (i < BOOT_SEQUENCE.length) {
bootLines.value.push(BOOT_SEQUENCE[i]);
i++;
setTimeout(pushLine, 220);
} else {
setTimeout(() => {
isBooting.value = false;
}, 500);
}
};
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 };
};
const todayUnique = ref(0);
const activeNow = ref(0);
let analyticsTimer = null;
let weatherTimer = null;
const currentServerSource = ref('nas');
const WEATHER_ICONS = {
clear: " \\ /\n .-.\n ― ( ) ―\n `-'\n / \\",
cloudy: " .--.\n .-( ).\n (___.__)__)",
overcast: " .--.\n .-( ).\n (___.__)__)",
fog: " _ - _ - _\n_ - _ - _ -\n _ - _ - _",
drizzle: " .-.\n ( ).\n (___(__)\n ' ' ' '",
rain: " .-.\n ( ).\n (___(__)\n ' ' ' ' '",
snow: " .-.\n ( ).\n (___(__)\n * * *",
thunder: " .-.\n ( ).\n (___(__)\n ⚡ ' ⚡"
};
const WEATHER_LABELS = {
clear: '맑음',
cloudy: '구름 조금',
overcast: '흐림',
fog: '안개',
drizzle: '이슬비',
rain: '비',
snow: '눈',
thunder: '뇌우'
};
const getWeatherIconKey = (code) => {
if (code === 0) return 'clear';
if (code === 1 || code === 2) return 'cloudy';
if (code === 3) return 'overcast';
if (code === 45 || code === 48) return 'fog';
if ([51, 53, 55, 56, 57].includes(code)) return 'drizzle';
if ([61, 63, 65, 66, 67, 80, 81, 82].includes(code)) return 'rain';
if ([71, 73, 75, 77, 85, 86].includes(code)) return 'snow';
if ([95, 96, 99].includes(code)) return 'thunder';
return 'cloudy';
};
const weather = ref({ loading: true, error: false, temp: null, iconKey: 'clear' });
const weatherIcon = computed(() => WEATHER_ICONS[weather.value.iconKey] || WEATHER_ICONS.cloudy);
const weatherLabel = computed(() => WEATHER_LABELS[weather.value.iconKey] || '');
const fetchWeatherData = async () => {
try {
const res = await axios.get('https://api.open-meteo.com/v1/forecast', {
params: {
latitude: 37.5665,
longitude: 126.9780,
current_weather: true,
timezone: 'Asia/Seoul'
}
});
const current = res.data && res.data.current_weather;
if (current) {
weather.value = {
loading: false,
error: false,
temp: Math.round(current.temperature),
iconKey: getWeatherIconKey(current.weathercode)
};
} else {
weather.value.loading = false;
weather.value.error = true;
}
} catch (err) {
console.error("날씨 데이터 로드 실패:", err);
weather.value.loading = false;
weather.value.error = true;
}
};
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 boardViewMode = ref('unread'); // 'unread' | 'viewed'
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 : [],
viewedAt: row.viewedAt || null
});
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 endpoint = boardViewMode.value === 'viewed' ? '/api/scraped-posts/viewed' : '/api/scraped-posts';
const res = await axios.get(`${apiBaseUrl}${endpoint}`, {
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 setBoardViewMode = (mode) => {
if (boardViewMode.value === mode) return;
boardViewMode.value = mode;
fetchBoardPosts(true);
};
const loadMoreBoardPosts = () => {
board.value.page += 1;
fetchBoardPosts(false);
};
const openPostDetail = async (post) => {
postDetail.value = { show: true, post };
// '읽음' 목록에서는 조회 처리를 다시 할 필요도, 목록에서 뺄 필요도 없다.
if (boardViewMode.value === 'viewed') return;
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' }
];
const isLoggedIn = computed(() => !!authToken.value);
const terminalPrompt = () => `${isLoggedIn.value && currentUsername.value ? currentUsername.value : 'anonymous'}@specialsource:~$ `;
const syncTerminalPrompt = () => {
if (termInstance.value) {
termInstance.value.set_prompt(terminalPrompt());
}
};
const currentServerSourceDisplay = computed(() => {
if (currentServerSource.value === 'firebase_night') {
return 'SYS: CLOUD_REDUNDANCY (NIGHT)';
}
if (currentServerSource.value === 'firebase_failover') {
return 'SYS: EMERGENCY_MIRROR (FAILOVER)';
}
if (currentServerSource.value === 'firebase_direct') {
return 'SYS: CLOUD_DIRECT (BYPASS)';
}
return 'SYS: LOCAL_CORE (ACTIVE)';
});
const detectRealtimeServerSource = async () => {
const hostname = window.location.hostname;
if (hostname.includes('web.app') || hostname.includes('firebase')) {
currentServerSource.value = 'firebase_direct';
return;
}
try {
const res = await fetch(window.location.origin, { method: 'HEAD' });
const servedBy = res.headers.get('x-served-by');
if (servedBy) {
currentServerSource.value = servedBy;
} else {
currentServerSource.value = 'nas';
}
} catch (err) {
console.error("실시간 서버 소스 판별 실패:", err);
currentServerSource.value = 'firebase_failover';
}
};
const rawAscii = `
███████╗██████╗ ███████╗ ██████╗██╗ █████╗ ██╗
██╔════╝██╔══██╗██╔════╝██╔════╝██║██╔══██╗██║
███████╗██████╔╝█████╗ ██║ ██║███████║██║
╚════██║██╔═══╝ ██╔══╝ ██║ ██║██╔══██║██║
███████║██║ ███████╗╚██████╗██║██║ ██║███████╗
╚══════╝╚═╝ ╚══════╝ ╚═════╝╚═╝╚═╝ ╚═╝╚══════╝
███████╗██████╗ ██╗ ██╗██████╗ ██████╗███████╗
██╔════╝██╔═══██╗██║ ██║██╔══██╗██╔════╝██╔════╝
███████╗██║ ██║██║ ██║██████╔╝██║ █████╗
╚════██║██║ ██║██║ ██║██╔══██╗██║ ██╔══╝
███████║╚██████╔╝╚██████╔╝██║ ██║╚██████╗███████╗
╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
██████╗ ██████╗ ███╗ ███╗██████╗ █████╗ ███╗ ██╗██╗ ██╗
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔══██╗████╗ ██║╚██╗ ██╔╝
██║ ██║ ██║██╔████╔██║██████╔╝███████║██╔██╗ ██║ ╚████╔╝
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██╔══██║██║╚██╗██║ ╚██╔╝
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ██║ ██║██║ ╚████║ ██║
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═╝`;
const formattedAscii = computed(() => {
return rawAscii.replace(/ /g, '<span class="bg-block">█</span>');
});
const fetchAnalyticsData = async () => {
try {
const apiBaseUrl = import.meta.env.VITE_API_URL || '';
const res = await axios.get(`${apiBaseUrl}/api/analytics/live`, { withCredentials: true });
if (res.data) {
todayUnique.value = res.data.todayUnique || 0;
activeNow.value = res.data.activeNow || 0;
}
} catch (err) {
console.error("관제 통계 데이터 로드 실패:", err);
}
};
const changeMenu = (id) => {
if (activeMenu.value === id) return;
isProcessing.value = true;
overlayProgress.value = 0;
overlayStatus.value = `INITIALIZING ROUTE ACCESS: /${id.toUpperCase()}...`;
if (termInstance.value) {
termInstance.value.echo(`\n[[b;var(--tui-color);]>] NAVIGATING TO /${id.toUpperCase()}... INITIALIZING PIPELINE.`);
}
const interval = setInterval(() => {
overlayProgress.value += 5;
if (overlayProgress.value === 25) {
overlayStatus.value = `ALLOCATING MEMORY BUFFER FOR VUE_COMPONENT...`;
}
if (overlayProgress.value === 55) {
overlayStatus.value = `DECRYPTING INTERFACE LOGS & SECURE ASSETS...`;
}
if (overlayProgress.value === 85) {
activeMenu.value = id;
overlayStatus.value = `MOUNTING VIRTUAL DOM TREE... SUCCESS.`;
}
if (overlayProgress.value >= 100) {
clearInterval(interval);
if (termInstance.value) {
termInstance.value.echo(`[[b;var(--tui-color);][SUCCESS]] COMPONENT LOADED PERFECTLY.`);
}
setTimeout(() => {
isProcessing.value = false;
}, 120);
}
}, 20);
};
const apiKey = 'AIzaSyD51LHwqoY8spjq6rsY_RlhBXzb96j7D6o';
const channelId = 'UC8L92ju0V88s6TcmLPb8Bkg';
const maxResults = 8;
const apiUrl = `https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=${channelId}&maxResults=${maxResults}&order=date&type=video&key=${apiKey}`;
const fetchVideos = async () => {
try {
const res = await axios.get(apiUrl);
videos.value = res.data.items || [];
} catch (err) { console.error("유튜브 로드 실패:", err); }
};
const openVideo = (id) => window.open(`https://www.youtube.com/watch?v=${id}`);
const handleRegister = () => showSystemAlert("회원가입은 현재 관리자 승인제로 운영됩니다.");
const handleLogout = () => {
localStorage.removeItem('token');
localStorage.removeItem('username');
authToken.value = null;
currentUsername.value = '';
activeMenu.value = 'main';
if (termInstance.value) {
termInstance.value.echo(`\n[[b;red;][ALERT]] SESSION TERMINATED. USER LOGGED OUT.`);
}
syncTerminalPrompt();
};
const handleLoginSubmit = async () => {
if (!loginId.value || !loginPw.value) {
showSystemAlert("아이디와 비밀번호를 모두 입력해 주세요.");
return;
}
isProcessing.value = true;
overlayProgress.value = 10;
overlayStatus.value = 'Transmitting encryption keys to gateway...';
if (termInstance.value) {
termInstance.value.echo(`\n[SYS] INITIALIZING SECURITY GATEWAY CONNECTION...`);
termInstance.value.echo(`[SYS] TRANSMITTING CREDENTIALS [USER: ${loginId.value}]`);
}
try {
const apiBaseUrl = import.meta.env.VITE_API_URL || '';
overlayProgress.value = 40;
overlayStatus.value = 'Validating query signature against PostgreSQL DB...';
const response = await axios.post(`${apiBaseUrl}/api/login`, {
username: loginId.value,
password: loginPw.value
}, {
withCredentials: true
});
if (response.data && response.data.token) {
overlayProgress.value = 85;
overlayStatus.value = 'Access Granted. Generating JWT Session token...';
localStorage.setItem('token', response.data.token);
localStorage.setItem('username', loginId.value);
authToken.value = response.data.token;
currentUsername.value = loginId.value;
syncTerminalPrompt();
if (termInstance.value) {
termInstance.value.echo(`[[b;var(--tui-color);][SUCCESS]] ACCESS GRANTED. CREDENTIALS VERIFIED.`);
}
overlayProgress.value = 100;
overlayStatus.value = 'Session injection complete.';
setTimeout(() => {
isProcessing.value = false;
loginId.value = '';
loginPw.value = '';
activeMenu.value = 'main';
}, 400);
}
} catch (error) {
console.error("로그인 실패:", error);
isProcessing.value = false;
if (termInstance.value) {
termInstance.value.echo(`[[b;red;][CRITICAL ERROR]] ACCESS DENIED! INVALID ACCESS KEY.`);
}
showSystemAlert("인증에 실패했습니다. 액세스 키를 확인하세요.");
}
};
const pcTongsinMode = ref(false);
const pcMenuEntries = computed(() => {
const authEntry = isLoggedIn.value
? { id: '__logout', name: 'LOGOUT' }
: { id: 'login', name: 'LOGIN' };
return [...menuItems, authEntry];
});
const activatePcMenuEntry = (entry) => {
if (entry.id === '__logout') {
handleLogout();
} else {
changeMenu(entry.id);
}
};
const pcTongsinCommand = (raw) => {
const term = termInstance.value;
const input = (raw || '').trim();
if (!term || !input) return;
const lower = input.toLowerCase();
if (activeMenu.value === 'board') {
if (lower === 'm' || lower === '메인') {
changeMenu('main');
return;
}
if (lower === 'l' || lower === '목록') {
term.echo('[SYS] 현재 목록입니다.');
return;
}
const idx = Number(input);
if (!Number.isNaN(idx) && board.value.posts[idx - 1]) {
openPostDetail(board.value.posts[idx - 1]);
return;
}
term.error(`※ 목록에 없는 번호입니다: "${input}"`);
return;
}
const numIdx = Number(input);
if (!Number.isNaN(numIdx) && pcMenuEntries.value[numIdx - 1]) {
activatePcMenuEntry(pcMenuEntries.value[numIdx - 1]);
return;
}
if (lower === 'm' || lower === '메인') {
changeMenu('main');
return;
}
const found = pcMenuEntries.value.find(
(entry) => entry.id.toLowerCase() === lower || entry.name.toLowerCase() === lower
);
if (found) {
activatePcMenuEntry(found);
return;
}
term.error(`※ 알 수 없는 명령입니다: "${input}"`);
};
const togglePcTongsinMode = () => {
pcTongsinMode.value = !pcTongsinMode.value;
if (!termInstance.value) return;
if (pcTongsinMode.value) {
termInstance.value.push(pcTongsinCommand, { name: 'pctongsin', prompt: '번호/메뉴 > ' });
termInstance.value.echo('[SYS] PC통신 모드 진입. 번호나 메뉴명을 입력하세요 (예: 3 또는 board).');
} else {
termInstance.value.pop();
termInstance.value.echo('[SYS] PC통신 모드 종료.');
}
};
watch(activeMenu, (id) => {
if (!pcTongsinMode.value || !termInstance.value) return;
const label = id === 'board' ? '게시판' : '메인';
termInstance.value.set_prompt(`${label} > `);
});
onMounted(() => {
if (shouldShowBootLog()) {
runBootSequence();
markBootLogShown();
} else {
isBooting.value = false;
}
fetchVideos();
fetchAnalyticsData();
fetchWeatherData();
detectRealtimeServerSource();
analyticsTimer = setInterval(() => {
fetchAnalyticsData();
detectRealtimeServerSource();
}, 30000);
weatherTimer = setInterval(fetchWeatherData, 600000);
const globaljQuery = window.$;
if (globaljQuery && terminalRef.value) {
termInstance.value = globaljQuery(terminalRef.value).terminal({
'hello': function () { this.echo('Hello, Welcome to Specialsource.company'); },
'specialsource': function () { this.echo('SPECIALSOURCE Established 2021.01.'); },
'email': function () { this.echo('sungjin.choi@specialsource.company'); },
'status': function () {
const term = this;
term.pause();
const lines = [
"============================================",
" 📟 SPECIALSOURCE TRAFFIC ARCHITECTURE",
"============================================",
`- CURRENT ACTIVE USERS (5m) : ${activeNow.value} ACTIVE`,
`- TOTAL UNIQUE VISITORS TODAY : ${todayUnique.value} UVs`,
"--------------------------------------------"
];
term.echo("\n[SYS] INITIALIZING SECURE PIPELINE CHANNEL...");
term.echo("[SYS] EXTRACTING POSTGRESQL METADATA... SNAPSHOT READY.");
let index = 0;
const typingInterval = setInterval(() => {
if (index < lines.length) {
term.echo(lines[index]);
index++;
} else {
clearInterval(typingInterval);
term.resume();
}
}, 110);
},
'login': function () {
const term = this;
if (isLoggedIn.value) {
term.echo(`\n[[b;red;][ERROR]] ALREADY AUTHENTICATED AS ${currentUsername.value || 'ADMIN'}. TYPE 'logout' FIRST TO SWITCH USER.`);
return;
}
term.echo(`\n[SYS] LOGIN: ENTER CREDENTIALS TO AUTHENTICATE.`);
term.read('ACCESS ID: ').then((id) => {
term.set_mask(true);
return term.read('ACCESS KEY: ').then((pw) => {
term.set_mask(false);
return { id, pw };
});
}).then(({ id, pw }) => {
if (!id || !pw) {
term.echo(`[[b;red;][ERROR]] ACCESS ID/KEY CANNOT BE EMPTY.`);
return;
}
loginId.value = id;
loginPw.value = pw;
handleLoginSubmit();
}).catch(() => {
term.set_mask(false);
term.echo(`\n[[b;red;][LOGIN]] AUTHENTICATION CANCELLED.`);
});
},
'logout': function () {
const term = this;
if (!isLoggedIn.value) {
term.echo(`\n[[b;red;][ERROR]] NOT AUTHENTICATED. NOTHING TO LOG OUT OF.`);
return;
}
handleLogout();
},
'help': function () {
this.echo(`- hello : Say hello\n- specialsource : Core info\n- email : Contact\n- status : Check Live Connected Users\n- login : Login via ID/Password prompt\n- logout : Log out of current session\n- clear : Clear console`);
},
}, {
greetings: `[SYSTEM V3.2] INTERFACE ONLINE. TYPE 'help' FOR COMMANDS.`,
prompt: terminalPrompt()
});
}
});
onUnmounted(() => {
if (analyticsTimer) clearInterval(analyticsTimer);
if (weatherTimer) clearInterval(weatherTimer);
});
</script>