Kennzeichne die Entwicklungsumgebung in der Oberflaeche, damit sie sich von Produktion unterscheiden laesst. #3
No files matched your search
@@ -63,6 +63,8 @@ services:
|
||||
build:
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
VITE_TSUMUGU_ENV: development
|
||||
ports:
|
||||
- "${TSUMUGU_FRONTEND_PORT:-3094}:80"
|
||||
depends_on:
|
||||
|
||||
@@ -65,6 +65,8 @@ services:
|
||||
build:
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
VITE_TSUMUGU_ENV: production
|
||||
container_name: tsumugu-ui
|
||||
ports:
|
||||
- "${TSUMUGU_FRONTEND_PORT:-3007}:80"
|
||||
|
||||
+3
-1
@@ -5,9 +5,11 @@ WORKDIR /src
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
|
||||
COPY index.html vite.config.js ./
|
||||
COPY index.html vite.config.js mark-environment.mjs ./
|
||||
COPY public ./public
|
||||
COPY src ./src
|
||||
ARG VITE_TSUMUGU_ENV=production
|
||||
ENV VITE_TSUMUGU_ENV=$VITE_TSUMUGU_ENV
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:alpine
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import fs from "node:fs";
|
||||
|
||||
if (process.env.VITE_TSUMUGU_ENV !== "development") {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const manifestPath = new URL("./dist/manifest.webmanifest", import.meta.url);
|
||||
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
||||
manifest.name = "Tsumugu Entwicklung";
|
||||
manifest.short_name = "Tsumugu Dev";
|
||||
manifest.theme_color = "#8a5a12";
|
||||
fs.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
|
||||
|
||||
const indexPath = new URL("./dist/index.html", import.meta.url);
|
||||
const html = fs
|
||||
.readFileSync(indexPath, "utf8")
|
||||
.replace("<title>Tsumugu</title>", "<title>Tsumugu · Entwicklung</title>")
|
||||
.replace('name="apple-mobile-web-app-title" content="Tsumugu"', 'name="apple-mobile-web-app-title" content="Tsumugu Dev"')
|
||||
.replace('name="theme-color" content="#085041"', 'name="theme-color" content="#8a5a12"');
|
||||
fs.writeFileSync(indexPath, html);
|
||||
@@ -4,7 +4,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"build": "vite build && node mark-environment.mjs",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
+40
-19
@@ -14,6 +14,17 @@ import { Users } from "./pages/Users.jsx";
|
||||
import { Work } from "./pages/Work.jsx";
|
||||
import { Settings } from "./pages/Settings.jsx";
|
||||
import { Reader } from "./pages/Reader.jsx";
|
||||
import { appTitle, isDevelopment } from "./environment.js";
|
||||
|
||||
function EnvironmentBanner() {
|
||||
useEffect(() => {
|
||||
document.title = appTitle;
|
||||
if (!isDevelopment) return;
|
||||
document.querySelector('meta[name="theme-color"]')?.setAttribute("content", "#8a5a12");
|
||||
}, []);
|
||||
if (!isDevelopment) return null;
|
||||
return <p className="env-banner" role="status">Entwicklungsumgebung</p>;
|
||||
}
|
||||
|
||||
export function App() {
|
||||
const [session, setSession] = useState(undefined);
|
||||
@@ -66,31 +77,41 @@ export function App() {
|
||||
}
|
||||
|
||||
if (session === undefined) {
|
||||
return <p className="boot">Tsumugu wird geladen …</p>;
|
||||
return (
|
||||
<div className="app-root">
|
||||
<EnvironmentBanner />
|
||||
<p className="boot">Tsumugu wird geladen …</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const value = { session, setSession, refresh, changeScope, logout };
|
||||
|
||||
return (
|
||||
<SessionContext.Provider value={value}>
|
||||
<Routes>
|
||||
<Route path="/login" element={session ? <Navigate to="/" replace /> : <Login />} />
|
||||
<Route element={session ? <Shell /> : <Navigate to="/login" replace />}>
|
||||
<Route index element={<Overview />} />
|
||||
<Route path="cases" element={<CaseList />} />
|
||||
<Route path="cases/:id" element={<CaseDetail />} />
|
||||
<Route path="matters" element={<MatterList />} />
|
||||
<Route path="matters/:id" element={<MatterDetail />} />
|
||||
<Route path="matters/:id/items/:bindingId" element={<Reader />} />
|
||||
<Route path="cases/:id/items/:bindingId" element={<Reader />} />
|
||||
<Route path="work" element={<Work />} />
|
||||
<Route path="settings" element={<Settings />} />
|
||||
<Route path="rooms" element={<Rooms />} />
|
||||
<Route path="sources" element={<Sources />} />
|
||||
<Route path="users" element={<Users />} />
|
||||
<Route path="search" element={<Search />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
<div className="app-root">
|
||||
<EnvironmentBanner />
|
||||
<div className="app-root__main">
|
||||
<Routes>
|
||||
<Route path="/login" element={session ? <Navigate to="/" replace /> : <Login />} />
|
||||
<Route element={session ? <Shell /> : <Navigate to="/login" replace />}>
|
||||
<Route index element={<Overview />} />
|
||||
<Route path="cases" element={<CaseList />} />
|
||||
<Route path="cases/:id" element={<CaseDetail />} />
|
||||
<Route path="matters" element={<MatterList />} />
|
||||
<Route path="matters/:id" element={<MatterDetail />} />
|
||||
<Route path="matters/:id/items/:bindingId" element={<Reader />} />
|
||||
<Route path="cases/:id/items/:bindingId" element={<Reader />} />
|
||||
<Route path="work" element={<Work />} />
|
||||
<Route path="settings" element={<Settings />} />
|
||||
<Route path="rooms" element={<Rooms />} />
|
||||
<Route path="sources" element={<Sources />} />
|
||||
<Route path="users" element={<Users />} />
|
||||
<Route path="search" element={<Search />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</div>
|
||||
</div>
|
||||
</SessionContext.Provider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// Dieselbe Quellfassung läuft nach dem Merge in beiden Deployments.
|
||||
// Development setzt VITE_TSUMUGU_ENV beim Image-Build. Der lokale Vite-Server gilt ebenfalls als Entwicklung.
|
||||
export const isDevelopment =
|
||||
import.meta.env.VITE_TSUMUGU_ENV === "development" ||
|
||||
(import.meta.env.DEV && import.meta.env.VITE_TSUMUGU_ENV !== "production");
|
||||
|
||||
export const appTitle = isDevelopment ? "Tsumugu · Entwicklung" : "Tsumugu";
|
||||
@@ -141,6 +141,37 @@ label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(-
|
||||
.error { color: var(--danger); font-size: 14px; }
|
||||
.banner { margin: 0 16px 8px; }
|
||||
|
||||
.app-root {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.app-root__main {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.app-root__main > .app-shell,
|
||||
.app-root__main > .login,
|
||||
.app-root > .boot {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
height: auto;
|
||||
}
|
||||
.env-banner {
|
||||
margin: 0;
|
||||
flex: none;
|
||||
background: var(--warn);
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
padding: calc(6px + env(safe-area-inset-top, 0px)) 12px 6px;
|
||||
}
|
||||
|
||||
.boot, .login {
|
||||
min-height: 100%;
|
||||
display: grid;
|
||||
|
||||
Reference in new issue
Block a user