feat: add studio manual web viewer
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
# Leave empty in Kubernetes. nginx proxies /api to studio-admin-be.
|
||||||
|
# VITE_MANUAL_API_BASE_URL=/api
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
*.tsbuildinfo
|
||||||
|
.env
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
FROM node:22-alpine AS build
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm ci
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
FROM nginx:1.27-alpine
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
COPY --from=build /app/dist /usr/share/nginx/html
|
||||||
|
EXPOSE 80
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Studio Manual Frontend
|
||||||
|
|
||||||
|
Static manual viewer for Autonomy Studio.
|
||||||
|
|
||||||
|
The browser requests `GET /api/manuals/public?appKey=LMS` and expects this response:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"documents": [
|
||||||
|
{
|
||||||
|
"id": "b5e71111-fdd0-48e4-95db-42f87d62f1bf",
|
||||||
|
"appKey": "LMS",
|
||||||
|
"title": "설치하기",
|
||||||
|
"body": "# 설치하기",
|
||||||
|
"updatedAt": "2026-07-14T00:00:00.000Z"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The nginx container proxies `/api` to `studio-admin-be` in the cluster, so published Markdown changes are reflected without rebuilding this frontend image.
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="ko">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<meta name="theme-color" content="#0b0f14" />
|
||||||
|
<title>Autonomy Studio Manual</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<script type="module" src="/src/main.tsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name _;
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass http://studio-admin-be.studio-system.svc.cluster.local:4500/api/;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+3412
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"name": "studio-manual-fe",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "tsc -b && vite build",
|
||||||
|
"preview": "vite preview"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"highlight.js": "^11.11.1",
|
||||||
|
"react": "^19.2.4",
|
||||||
|
"react-dom": "^19.2.4",
|
||||||
|
"react-markdown": "^10.1.0",
|
||||||
|
"rehype-highlight": "^7.0.2",
|
||||||
|
"remark-gfm": "^4.0.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/react": "^19.2.7",
|
||||||
|
"@types/react-dom": "^19.2.3",
|
||||||
|
"@vitejs/plugin-react": "^5.1.1",
|
||||||
|
"typescript": "~5.9.3",
|
||||||
|
"vite": "^7.2.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+97
@@ -0,0 +1,97 @@
|
|||||||
|
import { useEffect, useMemo, useState } from 'react'
|
||||||
|
import ReactMarkdown from 'react-markdown'
|
||||||
|
import rehypeHighlight from 'rehype-highlight'
|
||||||
|
import remarkGfm from 'remark-gfm'
|
||||||
|
|
||||||
|
type ManualDocument = {
|
||||||
|
id: string
|
||||||
|
appKey: string
|
||||||
|
title: string
|
||||||
|
body: string
|
||||||
|
updatedAt?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
type ManualResponse = {
|
||||||
|
documents?: ManualDocument[]
|
||||||
|
}
|
||||||
|
|
||||||
|
const API_BASE_URL = (import.meta.env.VITE_MANUAL_API_BASE_URL || '/api').replace(/\/+$/, '')
|
||||||
|
|
||||||
|
function App(): React.JSX.Element {
|
||||||
|
const [documents, setDocuments] = useState<ManualDocument[]>([])
|
||||||
|
const [activeId, setActiveId] = useState('')
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
|
const [error, setError] = useState('')
|
||||||
|
const appKey = new URLSearchParams(window.location.search).get('appKey')?.trim() || ''
|
||||||
|
|
||||||
|
const activeDocument = useMemo(
|
||||||
|
() => documents.find((document) => document.id === activeId) ?? documents[0] ?? null,
|
||||||
|
[activeId, documents],
|
||||||
|
)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let cancelled = false
|
||||||
|
|
||||||
|
const params = new URLSearchParams()
|
||||||
|
if (appKey) params.set('appKey', appKey)
|
||||||
|
fetch(`${API_BASE_URL}/manuals/public${params.size ? `?${params.toString()}` : ''}`, { cache: 'no-store' })
|
||||||
|
.then(async (response) => {
|
||||||
|
if (!response.ok) throw new Error('매뉴얼을 불러오지 못했습니다.')
|
||||||
|
return response.json() as Promise<ManualResponse>
|
||||||
|
})
|
||||||
|
.then((payload) => {
|
||||||
|
if (cancelled) return
|
||||||
|
const nextDocuments = (payload.documents ?? []).filter((document) => document.id && document.title)
|
||||||
|
setDocuments(nextDocuments)
|
||||||
|
setActiveId(nextDocuments[0]?.id ?? '')
|
||||||
|
})
|
||||||
|
.catch((loadError: unknown) => {
|
||||||
|
if (!cancelled) setError(loadError instanceof Error ? loadError.message : '매뉴얼을 불러오지 못했습니다.')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
if (!cancelled) setLoading(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
cancelled = true
|
||||||
|
}
|
||||||
|
}, [appKey])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<main className="manual-shell">
|
||||||
|
<aside className="manual-sidebar">
|
||||||
|
<nav aria-label="매뉴얼 목록">
|
||||||
|
{documents.map((document) => (
|
||||||
|
<button
|
||||||
|
key={document.id}
|
||||||
|
type="button"
|
||||||
|
className={document.id === activeDocument?.id ? 'nav-item active' : 'nav-item'}
|
||||||
|
onClick={() => setActiveId(document.id)}
|
||||||
|
>
|
||||||
|
{document.title}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</nav>
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
<section className="manual-content">
|
||||||
|
{loading && <p className="state-message">매뉴얼을 불러오는 중입니다.</p>}
|
||||||
|
{!loading && error && <p className="state-message error">{error}</p>}
|
||||||
|
{!loading && !error && !activeDocument && <p className="state-message">등록된 매뉴얼이 없습니다.</p>}
|
||||||
|
{!loading && !error && activeDocument && (
|
||||||
|
<article className="markdown-body">
|
||||||
|
<header>
|
||||||
|
<h1>{activeDocument.title}</h1>
|
||||||
|
{activeDocument.updatedAt && <p className="updated-at">최종 수정 {new Intl.DateTimeFormat('ko-KR', { dateStyle: 'medium' }).format(new Date(activeDocument.updatedAt))}</p>}
|
||||||
|
</header>
|
||||||
|
<ReactMarkdown remarkPlugins={[remarkGfm]} rehypePlugins={[rehypeHighlight]} skipHtml>
|
||||||
|
{activeDocument.body}
|
||||||
|
</ReactMarkdown>
|
||||||
|
</article>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
</main>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default App
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { StrictMode } from 'react'
|
||||||
|
import { createRoot } from 'react-dom/client'
|
||||||
|
import App from './App'
|
||||||
|
import './styles.css'
|
||||||
|
|
||||||
|
createRoot(document.getElementById('root')!).render(
|
||||||
|
<StrictMode>
|
||||||
|
<App />
|
||||||
|
</StrictMode>,
|
||||||
|
)
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
@import 'highlight.js/styles/github-dark.css';
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'NanumGothic';
|
||||||
|
src: url('/fonts/NanumGothicLight.woff2') format('woff2');
|
||||||
|
font-weight: 300;
|
||||||
|
font-style: normal;
|
||||||
|
font-display: swap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'NanumGothic';
|
||||||
|
src: url('/fonts/NanumGothic.woff2') format('woff2');
|
||||||
|
font-weight: 400;
|
||||||
|
font-style: normal;
|
||||||
|
font-display: swap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'NanumGothic';
|
||||||
|
src: url('/fonts/NanumGothicBold.woff2') format('woff2');
|
||||||
|
font-weight: 700;
|
||||||
|
font-style: normal;
|
||||||
|
font-display: swap;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root {
|
||||||
|
background: #050505;
|
||||||
|
color: #e7edf4;
|
||||||
|
font-family: 'NanumGothic', sans-serif;
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
|
||||||
|
* { box-sizing: border-box; }
|
||||||
|
html, body, #root { min-height: 100%; margin: 0; }
|
||||||
|
button { font: inherit; }
|
||||||
|
|
||||||
|
::-webkit-scrollbar { width: 10px; height: 10px; }
|
||||||
|
::-webkit-scrollbar-track { background: transparent; }
|
||||||
|
::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: 99px; background: rgba(255, 255, 255, .15); background-clip: padding-box; }
|
||||||
|
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .28); background-clip: padding-box; }
|
||||||
|
|
||||||
|
.manual-shell { display: grid; min-height: 100vh; grid-template-columns: 224px minmax(0, 1fr); }
|
||||||
|
.manual-sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid rgba(255,255,255,.09); background: #090909; padding: 20px 14px; }
|
||||||
|
.eyebrow { color: #8491a1; font-size: 10px; font-weight: 700; letter-spacing: .14em; }
|
||||||
|
.manual-sidebar nav { display: grid; gap: 4px; }
|
||||||
|
.nav-item { position: relative; width: 100%; border: 0; border-radius: 4px; background: transparent; color: #9eacba; cursor: pointer; padding: 9px 12px; text-align: left; font-size: 12px; transition: background .15s, color .15s; }
|
||||||
|
.nav-item:hover { background: rgba(255,255,255,.055); color: #e7edf4; }
|
||||||
|
.nav-item.active { background: rgba(59,127,250,.14); color: #3b7ffa; font-weight: 700; }
|
||||||
|
.nav-item.active::before { position: absolute; top: 8px; bottom: 8px; left: 0; width: 2px; border-radius: 0 3px 3px 0; background: #3b7ffa; box-shadow: 0 0 12px rgba(59,127,250,.45); content: ''; }
|
||||||
|
.manual-content { min-width: 0; padding: 52px clamp(24px, 4vw, 72px); }
|
||||||
|
.markdown-body { max-width: 880px; margin: 0 auto; color: #cad3dd; font-size: 14px; line-height: 1.75; }
|
||||||
|
.markdown-body header { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 16px; border-bottom: 1px solid rgba(255,255,255,.28); margin-bottom: 20px; padding-bottom: 18px; }
|
||||||
|
.markdown-body h1 { color: #f5f8fc; font-size: 25px; line-height: 1.3; margin: 8px 0 0; }
|
||||||
|
.markdown-body h2 { color: #f2f6fa; font-size: 18px; line-height: 1.4; margin: 36px 0 12px; }
|
||||||
|
.markdown-body h3 { color: #edf2f7; font-size: 15px; line-height: 1.5; margin: 26px 0 8px; }
|
||||||
|
.markdown-body p { margin: 0; }
|
||||||
|
.markdown-body ul, .markdown-body ol { margin: 0 0 14px; }
|
||||||
|
.markdown-body ul, .markdown-body ol { padding-left: 24px; }
|
||||||
|
.markdown-body hr { height: 0; border: 0; border-top: 1px solid rgba(255,255,255,.2); margin: 12px 0; }
|
||||||
|
.markdown-body li + li { margin-top: 4px; }
|
||||||
|
.markdown-body a { color: #82aaff; }
|
||||||
|
.markdown-body code { border: 1px solid rgba(255,255,255,.1); border-radius: 4px; background: #131313; color: #e6e6e6; padding: 2px 5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
|
||||||
|
.markdown-body pre { overflow-x: auto; border: 1px solid rgba(255,255,255,.1); border-radius: 6px; background: #111; margin: 18px 0; padding: 16px; }
|
||||||
|
.markdown-body pre code { border: 0; background: transparent; padding: 0; }
|
||||||
|
.markdown-body pre code.hljs { display: block; overflow-x: auto; background: transparent; }
|
||||||
|
.markdown-body table { width: 100%; border-collapse: collapse; margin: 20px 0; }
|
||||||
|
.markdown-body th, .markdown-body td { border: 1px solid rgba(255,255,255,.12); padding: 9px 11px; text-align: left; }
|
||||||
|
.markdown-body th { background: #151c25; color: #ecf2f8; }
|
||||||
|
.markdown-body .updated-at { margin: 0; margin-bottom: 0; padding: 0; color: #8491a1; font-size: 11px; white-space: nowrap; }
|
||||||
|
.state-message { margin: 20vh auto; color: #9eacba; max-width: 880px; text-align: center; font-size: 13px; }
|
||||||
|
.state-message.error { color: #ff9898; }
|
||||||
|
|
||||||
|
@media (max-width: 720px) {
|
||||||
|
.manual-shell { grid-template-columns: 1fr; }
|
||||||
|
.manual-sidebar { position: static; height: auto; border-bottom: 1px solid rgba(255,255,255,.09); border-right: 0; padding: 18px 14px; }
|
||||||
|
.manual-sidebar nav { display: flex; overflow-x: auto; }
|
||||||
|
.nav-item { flex: 0 0 auto; width: auto; }
|
||||||
|
.manual-content { padding: 34px 22px; }
|
||||||
|
.markdown-body { font-size: 13px; }
|
||||||
|
.markdown-body header { display: block; }
|
||||||
|
.updated-at { margin-top: 8px; }
|
||||||
|
}
|
||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||||
|
"target": "ES2022",
|
||||||
|
"useDefineForClassFields": true,
|
||||||
|
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
||||||
|
"allowJs": false,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"strict": true,
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "Bundler",
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"jsx": "react-jsx"
|
||||||
|
},
|
||||||
|
"include": ["src"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"files": [],
|
||||||
|
"references": [
|
||||||
|
{ "path": "./tsconfig.app.json" },
|
||||||
|
{ "path": "./tsconfig.node.json" }
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||||
|
"target": "ES2023",
|
||||||
|
"lib": ["ES2023"],
|
||||||
|
"module": "ESNext",
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"moduleResolution": "Bundler",
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"moduleDetection": "force",
|
||||||
|
"noEmit": true
|
||||||
|
},
|
||||||
|
"include": ["vite.config.ts"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { defineConfig } from 'vite'
|
||||||
|
import react from '@vitejs/plugin-react'
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [react()],
|
||||||
|
server: {
|
||||||
|
proxy: {
|
||||||
|
'/api': {
|
||||||
|
target: 'http://localhost:4500',
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user