앱 v1.2.0: exe 디스코드 로그인 · 유저 등록 · 관리자 페이지
- 사이트 서버: 앱 로그인(/auth/app/begin·start·poll, 기존 OAuth 콜백 재사용), 앱 토큰(/app/me, 해시 저장), 유저 등록 API(/app/admin/users, 등록·역할·해제는 최고 관리자만, 목록은 관리자도). 최고 관리자 2명 고정 - 앱: 등록된 계정으로 로그인해야 코어(봇·녹음·사이트 연결)를 띄운다. 미등록이면 "등록되지 않은 아이디" + 아이디 표시. 10분마다 재확인, 등록 해제 시 즉시 잠금. 서버 연결 실패 시 마지막 확인 후 3일 유예 - 겜녹이 봇 토큰을 exe 에 넣지 않고 로그인한 등록 유저에게 서버가 내려준다 (잠기면 삭제). win-ci 토큰 주입 제거 - 관리자 탭(유저 등록·목록·접속 기록), 관리자 전용 설정(봇 변경·TTS 안내·보관 기간·사이트·학습 데이터·파인튜닝)은 일반 유저에게 잠금 표시 + 메인 프로세스에서 차단 - 테스트: 서버 앱 로그인 2건, 앱↔서버 통합 3건, Electron 로그인 E2E 스크립트(scripts/login-e2e.mts) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
// 겜녹이 설정 창 렌더러 진입점. 라우팅: #/wizard[/단계] · #/settings/<탭>
|
||||
import { useEffect, useState, type ReactNode } from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import { ROLE_LABEL, isAdminRole } from '../core/roles';
|
||||
import tray from './assets/tray@2x.png';
|
||||
import { AuthGate } from './auth/Login';
|
||||
import { AppProvider, isMock, useApp } from './store';
|
||||
import './styles.css';
|
||||
import { AdminTab } from './tabs/AdminTab';
|
||||
import { AudioTab } from './tabs/AudioTab';
|
||||
import { DiagTab } from './tabs/DiagTab';
|
||||
import { DictTab } from './tabs/DictTab';
|
||||
@@ -12,7 +15,7 @@ import { GamesTab } from './tabs/GamesTab';
|
||||
import { GeneralTab } from './tabs/GeneralTab';
|
||||
import { StorageTab } from './tabs/StorageTab';
|
||||
import { SttTab } from './tabs/SttTab';
|
||||
import { Dot } from './ui';
|
||||
import { Avatar, Dot } from './ui';
|
||||
import { go } from './util';
|
||||
import { Wizard } from './wizard/Wizard';
|
||||
|
||||
@@ -26,6 +29,9 @@ const TABS: { id: string; icon: string; label: string; el: () => ReactNode }[] =
|
||||
{ id: 'diag', icon: '🔬', label: '진단', el: () => <DiagTab /> },
|
||||
{ id: 'general', icon: '⚙️', label: '일반', el: () => <GeneralTab /> },
|
||||
];
|
||||
/** 관리자 · 최고 관리자에게만 보이는 탭 */
|
||||
const ADMIN_TAB = { id: 'admin', icon: '🛡️', label: '관리자', el: () => <AdminTab /> };
|
||||
const tabsFor = (role: string | null) => (isAdminRole(role as never) ? [...TABS, ADMIN_TAB] : TABS);
|
||||
|
||||
function useHash(): string {
|
||||
const [h, setH] = useState(location.hash);
|
||||
@@ -38,7 +44,7 @@ function useHash(): string {
|
||||
}
|
||||
|
||||
function Router() {
|
||||
const { settings } = useApp();
|
||||
const { settings, state } = useApp();
|
||||
const hash = useHash();
|
||||
const parts = hash.replace(/^#\/?/, '').split('/');
|
||||
|
||||
@@ -53,10 +59,11 @@ function Router() {
|
||||
}, [isWizard]);
|
||||
|
||||
if (isWizard) return <Wizard step={Math.max(1, Math.min(5, Number(parts[1]) || 1))} />;
|
||||
const tab = TABS.find((t) => t.id === parts[1]) ?? TABS[0]!;
|
||||
const tabs = tabsFor(state.account.role);
|
||||
const tab = tabs.find((t) => t.id === parts[1]) ?? tabs[0]!;
|
||||
return (
|
||||
<div className="app">
|
||||
<Nav current={tab.id} />
|
||||
<Nav current={tab.id} tabs={tabs} />
|
||||
<main className="content" key={tab.id}>
|
||||
{tab.el()}
|
||||
</main>
|
||||
@@ -64,8 +71,9 @@ function Router() {
|
||||
);
|
||||
}
|
||||
|
||||
function Nav({ current }: { current: string }) {
|
||||
function Nav({ current, tabs }: { current: string; tabs: typeof TABS }) {
|
||||
const { state } = useApp();
|
||||
const acc = state.account;
|
||||
const bot = state.bot.status;
|
||||
const botTone = bot === 'ready' ? 'ok' : bot === 'connecting' ? 'warn' : bot === 'error' ? 'err' : 'off';
|
||||
const botText = bot === 'ready' ? (state.bot.recording.active ? '녹음 중' : '정상') : bot === 'connecting' ? '연결 중' : bot === 'error' ? '오류' : '꺼짐';
|
||||
@@ -74,13 +82,21 @@ function Nav({ current }: { current: string }) {
|
||||
const relayText = r === 'online' ? '연결됨' : r === 'connecting' ? '연결 중' : r === 'error' ? '오류' : '미등록';
|
||||
return (
|
||||
<nav className="side">
|
||||
{TABS.map((t) => (
|
||||
{tabs.map((t) => (
|
||||
<a key={t.id} href={`#/settings/${t.id}`} className={`tab ${t.id === current ? 'on' : ''}`}>
|
||||
<span className="ic">{t.icon}</span>
|
||||
{t.label}
|
||||
</a>
|
||||
))}
|
||||
<div className="nav-status">
|
||||
{acc.user && (
|
||||
<a href="#/settings/general" className="nav-account" title={acc.offline ? '사이트 서버에 연결되지 않아 마지막 확인 결과로 쓰는 중' : acc.user.id}>
|
||||
<Avatar name={acc.user.name} src={acc.user.avatar} size={18} />
|
||||
{acc.user.name}
|
||||
{acc.role && <span className={`role ${acc.role}`}>{ROLE_LABEL[acc.role]}</span>}
|
||||
{acc.offline && <span className="t-warn">·오프라인</span>}
|
||||
</a>
|
||||
)}
|
||||
<div className="brand-mini">
|
||||
<img src={tray} alt="" />
|
||||
겜녹이 v{state.version}
|
||||
@@ -101,7 +117,9 @@ function Nav({ current }: { current: string }) {
|
||||
}
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<AppProvider>
|
||||
<Router />
|
||||
</AppProvider>,
|
||||
<AuthGate>
|
||||
<AppProvider>
|
||||
<Router />
|
||||
</AppProvider>
|
||||
</AuthGate>,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user