Make the distribution source and brand configurable
Nothing about the install was overridable: the archive could only come from one GitHub repo, the connectivity precheck pinged github.com whatever the source was, and the product name was duplicated across install.sh, the CLI banner and two spots in App.tsx. install.sh now reads REPO_BASE (default the Gitea mirror), REPO_FALLBACK (default GitHub), ARCHIVE_URL and BRAND from the environment. Gitea and GitHub share the same release path, so one scheme covers both: download_extract tries the primary, warns and falls back to the secondary, and fails with both URLs listed. The fallback carries real weight today — the Gitea repo is a pull mirror that does not sync releases, so artifacts live only on GitHub until release sync is enabled there. The precheck now probes the hosts actually used. BRAND flows install.sh -> cli.env -> CLI banner and awg-ui, which exposes it via GET /ui/brand along with the package version. That route is unauthenticated because the wordmark is on the login screen, before a JWT exists; the SPA falls back to a constant if it fails. Renaming a fork is one environment variable, and no version string is hardcoded in the UI or the CLI any more. Also adds /ui to the Vite dev proxy (GET /ui/brand and the API-keys tab were unreachable in dev), documents the overrides in the README, fixes a typo in the API.md base URL and states there that the API is not bound to any host.
This commit is contained in:
+18
-4
@@ -4,7 +4,7 @@
|
||||
import { useState, useEffect, useRef, useCallback } from 'react';
|
||||
import axios from 'axios';
|
||||
import './App.css';
|
||||
import { TOKEN_KEY, THEME_KEY, apiFetch, type ServerInfo } from './lib/shared';
|
||||
import { TOKEN_KEY, THEME_KEY, BRAND_FALLBACK, apiFetch, type ServerInfo, type Brand } from './lib/shared';
|
||||
import { IcoMenu, IcoLogout, IcoSun, IcoMoon, IcoRefresh } from './components/icons';
|
||||
import ServerBar from './components/ServerBar';
|
||||
import { TABS } from './tabs';
|
||||
@@ -22,6 +22,7 @@ export default function App() {
|
||||
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||
const [activeTab, setActiveTab] = useState(TABS[0].id);
|
||||
const [restarting, setRestarting] = useState(false);
|
||||
const [brand, setBrand] = useState<Brand>({ brand: BRAND_FALLBACK, version: '' });
|
||||
const [theme, setTheme] = useState<'light' | 'dark'>(() =>
|
||||
localStorage.getItem(THEME_KEY) === 'dark' ? 'dark' : 'light');
|
||||
const touchStartX = useRef(0);
|
||||
@@ -110,6 +111,17 @@ export default function App() {
|
||||
}
|
||||
}, [startSession]);
|
||||
|
||||
// Имя продукта и версия — с сервера, до логина (роут без авторизации).
|
||||
// Если не ответил, остаётся фолбэк из констант.
|
||||
useEffect(() => {
|
||||
axios.get('/ui/brand')
|
||||
.then(({ data }) => setBrand({
|
||||
brand: data.brand || BRAND_FALLBACK,
|
||||
version: data.version || '',
|
||||
}))
|
||||
.catch(() => { /* остаётся фолбэк */ });
|
||||
}, []);
|
||||
|
||||
// Применять и сохранять тему
|
||||
useEffect(() => {
|
||||
document.documentElement.setAttribute('data-theme', theme);
|
||||
@@ -163,7 +175,7 @@ export default function App() {
|
||||
{!token ? (
|
||||
<div className="login-screen">
|
||||
<div className="login-card">
|
||||
<span className="logo-name">Forgetting</span>
|
||||
<span className="logo-name">{brand.brand}</span>
|
||||
<p className="login-sub">Войдите, чтобы продолжить</p>
|
||||
<input
|
||||
className="field"
|
||||
@@ -216,8 +228,10 @@ export default function App() {
|
||||
onTouchEnd={handleTouchEnd}
|
||||
>
|
||||
<div className="sidebar-logo">
|
||||
<span className="logo-name">Forgetting</span>
|
||||
<span className="sidebar-version">Alpha 0.1.4.2</span>
|
||||
<span className="logo-name">{brand.brand}</span>
|
||||
<span className="sidebar-version">
|
||||
{brand.version ? `Alpha ${brand.version}` : 'Alpha'}
|
||||
</span>
|
||||
</div>
|
||||
<hr className="drawer-divider" />
|
||||
{TABS.map(t => (
|
||||
|
||||
Reference in New Issue
Block a user