Fix domain routing fallback and add dynamic favicons for student and admin portals
Build and Deploy (Gitea) / build-and-deploy (push) Successful in 44s
Details
Build and Deploy (Gitea) / build-and-deploy (push) Successful in 44s
Details
This commit is contained in:
parent
2045c33525
commit
4c71df1c9a
|
|
@ -0,0 +1,4 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<rect x="0" y="0" width="24" height="24" rx="4" fill="#E50914" stroke="none" />
|
||||
<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" fill="white" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 313 B |
|
|
@ -0,0 +1,4 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<rect x="0" y="0" width="24" height="24" rx="4" fill="#E50914" stroke="none" />
|
||||
<polygon points="10 8 16 12 10 16 10 8" fill="white" stroke="white" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 314 B |
21
src/Root.tsx
21
src/Root.tsx
|
|
@ -5,20 +5,33 @@ import AdminApp from './AdminApp.tsx';
|
|||
export default function Root() {
|
||||
const [simulatedDomain] = useState<'student' | 'admin'>(() => {
|
||||
// 1. Check hostname
|
||||
if (window.location.hostname.includes('admin')) {
|
||||
if (window.location.hostname.includes('admin-estudo') || window.location.hostname.startsWith('admin')) {
|
||||
return 'admin';
|
||||
}
|
||||
// 2. Check path
|
||||
if (window.location.pathname.startsWith('/admin')) {
|
||||
return 'admin';
|
||||
}
|
||||
// 3. Fallback to localStorage
|
||||
const saved = localStorage.getItem('microtecflix_simulated_domain');
|
||||
return saved === 'admin' ? 'admin' : 'student';
|
||||
|
||||
// Always default to student if not explicitly admin
|
||||
return 'student';
|
||||
});
|
||||
|
||||
const isAdmin = simulatedDomain === 'admin';
|
||||
|
||||
React.useEffect(() => {
|
||||
// Dynamically update document title and favicon
|
||||
document.title = isAdmin ? 'MicrotecFlix - Admin Portal' : 'MicrotecFlix - Plataforma de Estudos';
|
||||
|
||||
let link = document.querySelector("link[rel~='icon']") as HTMLLinkElement;
|
||||
if (!link) {
|
||||
link = document.createElement('link');
|
||||
link.rel = 'icon';
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
link.href = isAdmin ? '/favicon-admin.svg' : '/favicon-student.svg';
|
||||
}, [isAdmin]);
|
||||
|
||||
return (
|
||||
<div className="relative min-h-screen">
|
||||
{isAdmin ? <AdminApp /> : <App />}
|
||||
|
|
|
|||
Loading…
Reference in New Issue