diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index 3e1edba..56a0412 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -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, diff --git a/resources/js/app.tsx b/resources/js/app.tsx index 68ab22a..c90085a 100644 --- a/resources/js/app.tsx +++ b/resources/js/app.tsx @@ -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); diff --git a/resources/js/types/global.d.ts b/resources/js/types/global.d.ts index c5c462d..56296ff 100644 --- a/resources/js/types/global.d.ts +++ b/resources/js/types/global.d.ts @@ -31,6 +31,7 @@ export interface PageProps { declare global { interface Window { axios: AxiosInstance; + appName: string; } var route: typeof routeFn; diff --git a/resources/views/app.blade.php b/resources/views/app.blade.php index f8527c2..7726ce3 100644 --- a/resources/views/app.blade.php +++ b/resources/views/app.blade.php @@ -18,6 +18,9 @@ @viteReactRefresh @vite(['resources/js/app.tsx', "resources/js/Pages/{$page['component']}.tsx"]) @inertiaHead + @inertia