Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b972209c2f |
@@ -4,7 +4,7 @@
|
||||
|
||||
- 프로젝트명: 10 Minute Planner 웹 UI
|
||||
- 기술 스택: Vue 3 + Vite + TailwindCSS + JavaScript
|
||||
- 현재 기준 버전: `v0.1.21` 준비 중
|
||||
- 현재 기준 버전: `v0.1.22` 준비 중
|
||||
- Git 원격 저장소: `https://git.sori.studio/zenn/planner.sori.studio.git`
|
||||
|
||||
## 기준 디자인
|
||||
@@ -155,6 +155,9 @@
|
||||
- `planner_entries.payload`는 문자열이 아니라 PostgreSQL `JSONB`로 저장되도록 바뀌었다.
|
||||
- `docker-compose.yml` 기준으로 `postgres`, `backend`, `frontend(nginx)` 3개 서비스 초안이 추가되었다.
|
||||
- 프론트는 nginx에서 `/api`를 백엔드로 프록시하는 구조라서, 배포 시 브라우저가 별도 API 포트를 직접 알 필요가 없다.
|
||||
- 프론트 API 클라이언트는 `VITE_API_BASE_URL` 끝에 `/api`가 포함되어 있어도 `/api/api/...` 중복 주소가 생기지 않도록 정규화한다.
|
||||
- 로그인 실패 시에는 내부 라우트 문자열이나 서버 경로를 그대로 노출하지 않고, 사용자용 안내 문구만 보여준다.
|
||||
- 비로그인 상태에서는 왼쪽 사이드 내비게이션을 숨기고, 중앙 로그인 안내 화면만 보여주도록 정리했다.
|
||||
- 현재 환경에서는 Docker 데몬이 꺼져 있어서 `docker compose build` 실검증은 하지 못했고, 데몬 시작 후 다시 확인이 필요하다.
|
||||
- 이미지 저장 기능은 추후 `print-only` 또는 별도 export 전용 레이아웃을 기준으로 구현하면 화면/인쇄/공유 결과를 맞추기 쉽다.
|
||||
- Docker Compose는 프론트엔드와 백엔드를 함께 올리는 기준으로 설계하되, NAS 환경에 맞는 볼륨과 재시작 정책도 함께 고려한다.
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "ten-minute-planner",
|
||||
"version": "0.1.21",
|
||||
"version": "0.1.22",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "ten-minute-planner",
|
||||
"version": "0.1.21",
|
||||
"version": "0.1.22",
|
||||
"dependencies": {
|
||||
"vue": "^3.5.13"
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "ten-minute-planner",
|
||||
"private": true,
|
||||
"version": "0.1.21",
|
||||
"version": "0.1.22",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
15
src/App.vue
15
src/App.vue
@@ -16,6 +16,7 @@ import {
|
||||
updatePassword,
|
||||
updateProfile,
|
||||
} from './lib/authClient'
|
||||
import { toUserFacingApiError } from './lib/apiBase'
|
||||
import { createGoal, deleteGoal, fetchGoals, updateGoal } from './lib/goalsApi'
|
||||
import { deletePlannerEntry, fetchPlannerEntries, savePlannerEntry } from './lib/plannerApi'
|
||||
import {
|
||||
@@ -849,7 +850,7 @@ async function submitAuthForm() {
|
||||
|
||||
await applyAuthSuccess(result)
|
||||
} catch (error) {
|
||||
authMessage.value = error.message || '인증 처리 중 문제가 발생했습니다.'
|
||||
authMessage.value = toUserFacingApiError(error, '인증 처리 중 문제가 발생했습니다.')
|
||||
} finally {
|
||||
authBusy.value = false
|
||||
}
|
||||
@@ -1296,8 +1297,14 @@ onMounted(() => {
|
||||
|
||||
<template>
|
||||
<main class="min-h-screen px-4 py-6 text-ink sm:px-6 lg:px-10 xl:h-screen xl:overflow-hidden">
|
||||
<div class="print-root mx-auto flex max-w-[1760px] flex-col gap-6 xl:h-[calc(100vh-3rem)] xl:grid xl:grid-cols-[300px_minmax(0,1fr)] xl:items-start">
|
||||
<aside class="scrollbar-hide print-hidden rounded-[28px] border border-white/60 bg-white/70 p-5 backdrop-blur sm:p-6 xl:h-full xl:overflow-y-auto">
|
||||
<div
|
||||
class="print-root mx-auto flex max-w-[1760px] flex-col gap-6 xl:h-[calc(100vh-3rem)] xl:items-start"
|
||||
:class="isAuthenticated ? 'xl:grid xl:grid-cols-[300px_minmax(0,1fr)]' : ''"
|
||||
>
|
||||
<aside
|
||||
v-if="isAuthenticated"
|
||||
class="scrollbar-hide print-hidden rounded-[28px] border border-white/60 bg-white/70 p-5 backdrop-blur sm:p-6 xl:h-full xl:overflow-y-auto"
|
||||
>
|
||||
<div class="space-y-6">
|
||||
<div class="space-y-2">
|
||||
<p class="text-[11px] font-bold uppercase tracking-[0.28em] text-stone-500">10 Minute Planner</p>
|
||||
@@ -1452,7 +1459,7 @@ onMounted(() => {
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<div class="min-w-0 space-y-6 xl:h-full xl:overflow-hidden">
|
||||
<div class="min-w-0 space-y-6" :class="isAuthenticated ? 'xl:h-full xl:overflow-hidden' : ''">
|
||||
<section
|
||||
v-if="!isAuthenticated"
|
||||
class="scrollbar-hide print-hidden rounded-[28px] border border-white/60 bg-white/65 p-6 shadow-[0_24px_80px_rgba(28,25,23,0.08)] sm:p-8 xl:h-full xl:overflow-y-auto"
|
||||
|
||||
46
src/lib/apiBase.js
Normal file
46
src/lib/apiBase.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const DEFAULT_API_BASE_URL = 'http://localhost:3001'
|
||||
|
||||
function normalizeBaseUrl(baseUrl) {
|
||||
return (baseUrl || DEFAULT_API_BASE_URL).replace(/\/+$/, '')
|
||||
}
|
||||
|
||||
function normalizePath(path) {
|
||||
return path.startsWith('/') ? path : `/${path}`
|
||||
}
|
||||
|
||||
export function buildApiUrl(path) {
|
||||
const baseUrl = normalizeBaseUrl(import.meta.env.VITE_API_BASE_URL)
|
||||
const normalizedPath = normalizePath(path)
|
||||
|
||||
if (baseUrl.endsWith('/api') && normalizedPath.startsWith('/api/')) {
|
||||
return `${baseUrl}${normalizedPath.slice(4)}`
|
||||
}
|
||||
|
||||
return `${baseUrl}${normalizedPath}`
|
||||
}
|
||||
|
||||
export function toUserFacingApiError(error, fallbackMessage) {
|
||||
const rawMessage = `${error?.message ?? ''}`.trim()
|
||||
|
||||
if (!rawMessage) {
|
||||
return fallbackMessage
|
||||
}
|
||||
|
||||
if (
|
||||
rawMessage.includes('Failed to fetch') ||
|
||||
rawMessage.includes('NetworkError') ||
|
||||
rawMessage.includes('Load failed')
|
||||
) {
|
||||
return '서버에 연결하지 못했습니다. 잠시 후 다시 시도해 주세요.'
|
||||
}
|
||||
|
||||
if (
|
||||
rawMessage.includes('Route ') ||
|
||||
rawMessage.includes('not found') ||
|
||||
rawMessage.includes('/api/')
|
||||
) {
|
||||
return '로그인 요청을 처리하지 못했습니다. 잠시 후 다시 시도해 주세요.'
|
||||
}
|
||||
|
||||
return rawMessage
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
const AUTH_STORAGE_KEY = 'ten-minute-planner-auth'
|
||||
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:3001'
|
||||
import { buildApiUrl, toUserFacingApiError } from './apiBase'
|
||||
|
||||
function buildHeaders(token, extraHeaders = {}) {
|
||||
return {
|
||||
@@ -10,7 +10,7 @@ function buildHeaders(token, extraHeaders = {}) {
|
||||
}
|
||||
|
||||
async function request(path, { method = 'GET', token, body } = {}) {
|
||||
const response = await fetch(`${API_BASE_URL}${path}`, {
|
||||
const response = await fetch(buildApiUrl(path), {
|
||||
method,
|
||||
headers: buildHeaders(token),
|
||||
body: body ? JSON.stringify(body) : undefined,
|
||||
@@ -19,7 +19,7 @@ async function request(path, { method = 'GET', token, body } = {}) {
|
||||
const data = await response.json().catch(() => ({}))
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(data.message || '요청 처리 중 문제가 발생했습니다.')
|
||||
throw new Error(toUserFacingApiError(data, '요청 처리 중 문제가 발생했습니다.'))
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:3001'
|
||||
import { buildApiUrl, toUserFacingApiError } from './apiBase'
|
||||
|
||||
function buildHeaders(token) {
|
||||
return {
|
||||
@@ -8,7 +8,7 @@ function buildHeaders(token) {
|
||||
}
|
||||
|
||||
async function request(path, { method = 'GET', token, body } = {}) {
|
||||
const response = await fetch(`${API_BASE_URL}${path}`, {
|
||||
const response = await fetch(buildApiUrl(path), {
|
||||
method,
|
||||
headers: buildHeaders(token),
|
||||
body: body ? JSON.stringify(body) : undefined,
|
||||
@@ -17,7 +17,7 @@ async function request(path, { method = 'GET', token, body } = {}) {
|
||||
const data = await response.json().catch(() => ({}))
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(data.message || '목표 데이터를 처리하지 못했습니다.')
|
||||
throw new Error(toUserFacingApiError(data, '목표 데이터를 처리하지 못했습니다.'))
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:3001'
|
||||
import { buildApiUrl, toUserFacingApiError } from './apiBase'
|
||||
|
||||
function buildHeaders(token) {
|
||||
return {
|
||||
@@ -8,7 +8,7 @@ function buildHeaders(token) {
|
||||
}
|
||||
|
||||
async function request(path, { method = 'GET', token, body } = {}) {
|
||||
const response = await fetch(`${API_BASE_URL}${path}`, {
|
||||
const response = await fetch(buildApiUrl(path), {
|
||||
method,
|
||||
headers: buildHeaders(token),
|
||||
body: body ? JSON.stringify(body) : undefined,
|
||||
@@ -17,7 +17,7 @@ async function request(path, { method = 'GET', token, body } = {}) {
|
||||
const data = await response.json().catch(() => ({}))
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(data.message || '플래너 데이터를 처리하지 못했습니다.')
|
||||
throw new Error(toUserFacingApiError(data, '플래너 데이터를 처리하지 못했습니다.'))
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
Reference in New Issue
Block a user