Compare commits
4 Commits
d4cef2cd84
...
852370cfe0
| Author | SHA1 | Date | |
|---|---|---|---|
| 852370cfe0 | |||
| 965418077b | |||
| c3af92c85c | |||
| cca49b5fe8 |
@@ -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,
|
||||
@@ -58,7 +65,12 @@ class HandleInertiaRequests extends Middleware
|
||||
'branding' => function () {
|
||||
$tenant = tenancy()->tenant;
|
||||
if (!$tenant) {
|
||||
return null;
|
||||
// 中央後台預設 Branding
|
||||
return [
|
||||
'logo_url' => \Storage::url('defaults/logo.png'), // 中央後台也使用預設 Logo
|
||||
'primary_color' => '#4F46E5',
|
||||
'text_color' => '#1a1a1a',
|
||||
];
|
||||
}
|
||||
|
||||
$logoUrl = null;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateActivityLogTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->create(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('log_name')->nullable();
|
||||
$table->text('description');
|
||||
$table->nullableMorphs('subject', 'subject');
|
||||
$table->nullableMorphs('causer', 'causer');
|
||||
$table->json('properties')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index('log_name');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->dropIfExists(config('activitylog.table_name'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddEventColumnToActivityLogTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->string('event')->nullable()->after('subject_type');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->dropColumn('event');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddBatchUuidColumnToActivityLogTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->uuid('batch_uuid')->nullable()->after('properties');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->dropColumn('batch_uuid');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
// 單欄索引:事件類型(高頻過濾條件)
|
||||
$table->index('event', 'idx_event');
|
||||
|
||||
// 單欄索引:批次 UUID(未來批次操作查詢)
|
||||
$table->index('batch_uuid', 'idx_batch_uuid');
|
||||
|
||||
// 複合索引 1:時間 + 事件類型(最常見的組合查詢)
|
||||
$table->index(['created_at', 'event'], 'idx_created_event');
|
||||
|
||||
// 複合索引 2:主體類型 + 主體 ID + 時間(查詢特定資源的操作歷史)
|
||||
$table->index(['subject_type', 'subject_id', 'created_at'], 'idx_subject_created');
|
||||
|
||||
// 複合索引 3:操作者 + 時間(查詢特定使用者的操作紀錄)
|
||||
$table->index(['causer_id', 'created_at'], 'idx_causer_created');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->dropIndex('idx_event');
|
||||
$table->dropIndex('idx_batch_uuid');
|
||||
$table->dropIndex('idx_created_event');
|
||||
$table->dropIndex('idx_subject_created');
|
||||
$table->dropIndex('idx_causer_created');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -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);
|
||||
|
||||
1
resources/js/types/global.d.ts
vendored
1
resources/js/types/global.d.ts
vendored
@@ -31,6 +31,7 @@ export interface PageProps {
|
||||
declare global {
|
||||
interface Window {
|
||||
axios: AxiosInstance;
|
||||
appName: string;
|
||||
}
|
||||
|
||||
var route: typeof routeFn;
|
||||
|
||||
@@ -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
|
||||
|
||||
0
storage/app/public/defaults/.gitkeep
Normal file
0
storage/app/public/defaults/.gitkeep
Normal file
BIN
storage/app/public/defaults/login_bg.jpg
Normal file
BIN
storage/app/public/defaults/login_bg.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 451 KiB |
BIN
storage/app/public/defaults/logo.png
Normal file
BIN
storage/app/public/defaults/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 588 KiB |
Reference in New Issue
Block a user