mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
@@ -23,24 +23,6 @@ packages.forEach((package) => {
|
||||
.catch(() => process.exit(1))
|
||||
})
|
||||
|
||||
esbuild
|
||||
.build({
|
||||
define: {
|
||||
'process.env.NODE_ENV': shouldWatch
|
||||
? `'production'`
|
||||
: `'development'`,
|
||||
},
|
||||
entryPoints: [`packages/admin/resources/js/echo.js`],
|
||||
outfile: `packages/admin/dist/echo.js`,
|
||||
bundle: true,
|
||||
platform: 'neutral',
|
||||
mainFields: ['module', 'main'],
|
||||
watch: shouldWatch,
|
||||
minifySyntax: true,
|
||||
minifyWhitespace: true,
|
||||
})
|
||||
.catch(() => process.exit(1))
|
||||
|
||||
const formComponents = [
|
||||
'color-picker',
|
||||
'date-time-picker',
|
||||
|
||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"/app.js": "/app.js?id=ce779caac004e5d5d923bf38807f9566",
|
||||
"/echo.js": "/echo.js?id=22aa4e6bc6600bac3fe51d62296919c4",
|
||||
"/app.css": "/app.css?id=d6305677d9aca15f95c454b9e04e13f2"
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
import Chart from 'chart.js/auto'
|
||||
import Collapse from '@alpinejs/collapse'
|
||||
import Focus from '@alpinejs/focus'
|
||||
import Mousetrap from '@danharrin/alpine-mousetrap'
|
||||
import Persist from '@alpinejs/persist'
|
||||
import Tooltip from '@ryangjchandler/alpine-tooltip'
|
||||
|
||||
document.addEventListener('alpine:init', () => {
|
||||
window.Alpine.plugin(Collapse)
|
||||
window.Alpine.plugin(Focus)
|
||||
window.Alpine.plugin(Mousetrap)
|
||||
window.Alpine.plugin(Persist)
|
||||
window.Alpine.plugin(Tooltip)
|
||||
|
||||
window.Alpine.store('sidebar', {
|
||||
isOpen: window.Alpine.$persist(true).as('isOpen'),
|
||||
|
||||
collapsedGroups: window.Alpine.$persist([]).as('collapsedGroups'),
|
||||
|
||||
groupIsCollapsed: function (group) {
|
||||
return this.collapsedGroups.includes(group)
|
||||
},
|
||||
|
||||
collapseGroup: function (group) {
|
||||
if (this.collapsedGroups.includes(group)) {
|
||||
return
|
||||
}
|
||||
|
||||
this.collapsedGroups = this.collapsedGroups.concat(group)
|
||||
},
|
||||
|
||||
toggleCollapsedGroup: function (group) {
|
||||
this.collapsedGroups = this.collapsedGroups.includes(group)
|
||||
? this.collapsedGroups.filter(
|
||||
(collapsedGroup) => collapsedGroup !== group,
|
||||
)
|
||||
: this.collapsedGroups.concat(group)
|
||||
},
|
||||
|
||||
close: function () {
|
||||
this.isOpen = false
|
||||
},
|
||||
|
||||
open: function () {
|
||||
this.isOpen = true
|
||||
},
|
||||
})
|
||||
|
||||
window.Alpine.store(
|
||||
'theme',
|
||||
window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||
? 'dark'
|
||||
: 'light',
|
||||
)
|
||||
|
||||
window.addEventListener('dark-mode-toggled', (event) => {
|
||||
window.Alpine.store('theme', event.detail)
|
||||
})
|
||||
|
||||
window
|
||||
.matchMedia('(prefers-color-scheme: dark)')
|
||||
.addEventListener('change', (event) => {
|
||||
window.Alpine.store('theme', event.matches ? 'dark' : 'light')
|
||||
})
|
||||
})
|
||||
|
||||
Chart.defaults.font.family = `'DM Sans', sans-serif`
|
||||
Chart.defaults.color = '#6b7280'
|
||||
|
||||
window.Chart = Chart
|
||||
@@ -1,5 +1,5 @@
|
||||
import Echo from 'laravel-echo'
|
||||
import Pusher from 'pusher-js/dist/web/pusher'
|
||||
import Pusher from 'pusher-js'
|
||||
|
||||
window.EchoFactory = Echo
|
||||
window.Pusher = Pusher
|
||||
|
||||
@@ -11,6 +11,8 @@ Route::domain(config('filament.domain'))
|
||||
->name('filament.')
|
||||
->group(function () {
|
||||
Route::prefix(config('filament.core_path'))->group(function () {
|
||||
Route::get('/assets/{file}', AssetController::class)->where('file', '.*')->name('asset');
|
||||
|
||||
Route::post('/logout', function (Request $request): LogoutResponse {
|
||||
Filament::auth()->logout();
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Http\Controllers;
|
||||
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class AssetController
|
||||
{
|
||||
public function __invoke(string $file)
|
||||
{
|
||||
switch ($file) {
|
||||
case 'app.css':
|
||||
return $this->pretendResponseIsFile(__DIR__ . '/../../../dist/app.css', 'text/css; charset=utf-8');
|
||||
case 'app.css.map':
|
||||
return $this->pretendResponseIsFile(__DIR__ . '/../../../dist/app.css.map', 'text/css; charset=utf-8');
|
||||
case 'app.js':
|
||||
return $this->pretendResponseIsFile(__DIR__ . '/../../../dist/app.js', 'application/javascript; charset=utf-8');
|
||||
case 'app.js.map':
|
||||
return $this->pretendResponseIsFile(__DIR__ . '/../../../dist/app.js.map', 'application/json; charset=utf-8');
|
||||
case 'echo.js':
|
||||
return $this->pretendResponseIsFile(__DIR__ . '/../../../dist/echo.js', 'application/javascript; charset=utf-8');
|
||||
case 'echo.js.map':
|
||||
return $this->pretendResponseIsFile(__DIR__ . '/../../../dist/echo.js.map', 'application/json; charset=utf-8');
|
||||
}
|
||||
|
||||
if (Str::endsWith($file, '.js')) {
|
||||
$name = Str::beforeLast($file, '.js');
|
||||
|
||||
if (array_key_exists($name, Filament::getScripts())) {
|
||||
return $this->pretendResponseIsFile(Filament::getScripts()[$name], 'application/javascript; charset=utf-8');
|
||||
} elseif (array_key_exists($name, Filament::getBeforeCoreScripts())) {
|
||||
return $this->pretendResponseIsFile(Filament::getBeforeCoreScripts()[$name], 'application/javascript; charset=utf-8');
|
||||
} else {
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::endsWith($file, '.css')) {
|
||||
$name = Str::beforeLast($file, '.css');
|
||||
|
||||
abort_unless(
|
||||
array_key_exists($name, Filament::getStyles()),
|
||||
404,
|
||||
);
|
||||
|
||||
return $this->pretendResponseIsFile(Filament::getStyles()[$name], 'text/css; charset=utf-8');
|
||||
}
|
||||
|
||||
abort(404);
|
||||
}
|
||||
|
||||
protected function getHttpDate(int $timestamp)
|
||||
{
|
||||
return sprintf('%s GMT', gmdate('D, d M Y H:i:s', $timestamp));
|
||||
}
|
||||
|
||||
protected function pretendResponseIsFile(string $path, string $contentType)
|
||||
{
|
||||
abort_unless(
|
||||
file_exists($path) || file_exists($path = base_path($path)),
|
||||
404,
|
||||
);
|
||||
|
||||
$cacheControl = 'public, max-age=31536000';
|
||||
$expires = strtotime('+1 year');
|
||||
|
||||
$lastModified = filemtime($path);
|
||||
|
||||
if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'] ?? '') === $lastModified) {
|
||||
return response()->noContent(304, [
|
||||
'Expires' => $this->getHttpDate($expires),
|
||||
'Cache-Control' => $cacheControl,
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->file($path, [
|
||||
'Content-Type' => $contentType,
|
||||
'Expires' => $this->getHttpDate($expires),
|
||||
'Cache-Control' => $cacheControl,
|
||||
'Last-Modified' => $this->getHttpDate($lastModified),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,33 @@ namespace Filament;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Translation\MessageSelector;
|
||||
|
||||
if (! function_exists('Filament\get_asset_id')) {
|
||||
function get_asset_id(string $file, string $manifestPath = null): ?string
|
||||
{
|
||||
$manifestPath ??= __DIR__ . '/../dist/mix-manifest.json';
|
||||
|
||||
if (! file_exists($manifestPath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$manifest = json_decode(file_get_contents($manifestPath), associative: true);
|
||||
|
||||
$file = "/{$file}";
|
||||
|
||||
if (! array_key_exists($file, $manifest)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$file = $manifest[$file];
|
||||
|
||||
if (! str_contains($file, 'id=')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string) Str::of($file)->after('id=');
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('Filament\locale_has_pluralization')) {
|
||||
function locale_has_pluralization(): bool
|
||||
{
|
||||
|
||||
+9
-1
@@ -1,4 +1,5 @@
|
||||
const mix = require('laravel-mix')
|
||||
const tailwindcss = require('tailwindcss')
|
||||
|
||||
mix.disableSuccessNotifications()
|
||||
mix.options({
|
||||
@@ -10,4 +11,11 @@ mix.setPublicPath('packages/admin/dist')
|
||||
mix.setResourceRoot('packages/admin/resources')
|
||||
mix.version()
|
||||
|
||||
mix.js('packages/admin/resources/js/index.js', 'packages/admin/dist')
|
||||
mix.js('packages/admin/resources/js/app.js', 'packages/admin/dist')
|
||||
mix.js('packages/admin/resources/js/echo.js', 'packages/admin/dist')
|
||||
|
||||
mix.postCss('packages/admin/resources/css/app.css', 'packages/admin/dist', [
|
||||
tailwindcss('packages/admin/tailwind.config.js'),
|
||||
]).options({
|
||||
processCssUrls: false,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user