feat(ui): dynamic page title based on tenant context
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
Koori-ERP-Deploy-System / deploy-production (push) Successful in 49s

This commit is contained in:
2026-01-28 13:58:54 +08:00
parent cca49b5fe8
commit c3af92c85c
4 changed files with 12 additions and 1 deletions

View File

@@ -37,8 +37,15 @@ class HandleInertiaRequests extends Middleware
{
$user = $request->user();
$tenant = tenancy()->tenant;
$appName = $tenant ? ($tenant->name ?? 'Star ERP') : 'Star ERP 中央後台';
// 分享給 Blade View (給 app.blade.php 使用)
\Illuminate\Support\Facades\View::share('appName', $appName);
return [
...parent::share($request),
'appName' => $appName,
'auth' => [
'user' => $user ? [
'id' => $user->id,

View File

@@ -8,7 +8,7 @@ import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
createInertiaApp({
title: (title) => `${title} - ${appName}`,
title: (title) => `${title} - ${window.appName || appName}`,
resolve: (name) => resolvePageComponent(`./Pages/${name}.tsx`, import.meta.glob('./Pages/**/*.tsx')),
setup({ el, App, props }) {
const root = createRoot(el);

View File

@@ -31,6 +31,7 @@ export interface PageProps {
declare global {
interface Window {
axios: AxiosInstance;
appName: string;
}
var route: typeof routeFn;

View File

@@ -18,6 +18,9 @@
@viteReactRefresh
@vite(['resources/js/app.tsx', "resources/js/Pages/{$page['component']}.tsx"])
@inertiaHead
<script>
window.appName = "{{ $appName ?? config('app.name') }}";
</script>
</head>
<body class="font-sans antialiased">
@inertia