mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-24 03:57:27 +08:00
Use submodule for admin assets
This commit is contained in:
@@ -14,12 +14,69 @@
|
||||
secure_path: "{{ $secure_path }}",
|
||||
};
|
||||
</script>
|
||||
<script type="module" crossorigin src="/assets/admin/assets/index.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/admin/assets/index.css" />
|
||||
<link rel="stylesheet" crossorigin href="/assets/admin/assets/vendor.css">
|
||||
<script src="/assets/admin/locales/en-US.js"></script>
|
||||
<script src="/assets/admin/locales/zh-CN.js"></script>
|
||||
<script src="/assets/admin/locales/ko-KR.js"></script>
|
||||
@php
|
||||
$manifestPath = public_path('assets/admin/manifest.json');
|
||||
$manifest = file_exists($manifestPath) ? json_decode(file_get_contents($manifestPath), true) : null;
|
||||
$entry = is_array($manifest) ? ($manifest['index.html'] ?? null) : null;
|
||||
$scripts = [];
|
||||
$styles = [];
|
||||
$locales = [];
|
||||
|
||||
if (is_array($entry)) {
|
||||
$visited = [];
|
||||
$collectAssets = function ($chunkName) use (&$collectAssets, &$manifest, &$visited, &$scripts, &$styles) {
|
||||
if (isset($visited[$chunkName]) || !isset($manifest[$chunkName]) || !is_array($manifest[$chunkName])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$visited[$chunkName] = true;
|
||||
$chunk = $manifest[$chunkName];
|
||||
|
||||
if (!empty($chunk['css']) && is_array($chunk['css'])) {
|
||||
foreach ($chunk['css'] as $cssFile) {
|
||||
$styles[$cssFile] = $cssFile;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($chunk['imports']) && is_array($chunk['imports'])) {
|
||||
foreach ($chunk['imports'] as $import) {
|
||||
$collectAssets($import);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($chunk['isEntry']) && !empty($chunk['file'])) {
|
||||
$scripts[$chunk['file']] = $chunk['file'];
|
||||
}
|
||||
};
|
||||
|
||||
$collectAssets('index.html');
|
||||
}
|
||||
|
||||
foreach (glob(public_path('assets/admin/locales/*.js')) ?: [] as $localeFile) {
|
||||
$locales[] = 'locales/' . basename($localeFile);
|
||||
}
|
||||
sort($locales);
|
||||
@endphp
|
||||
|
||||
@if($entry && count($scripts) > 0)
|
||||
@foreach($styles as $css)
|
||||
<link rel="stylesheet" crossorigin href="/assets/admin/{{ $css }}" />
|
||||
@endforeach
|
||||
@foreach($locales as $locale)
|
||||
<script src="/assets/admin/{{ $locale }}"></script>
|
||||
@endforeach
|
||||
@foreach($scripts as $js)
|
||||
<script type="module" crossorigin src="/assets/admin/{{ $js }}"></script>
|
||||
@endforeach
|
||||
@else
|
||||
{{-- Fallback: hardcoded paths for backward compatibility --}}
|
||||
<script type="module" crossorigin src="/assets/admin/assets/index.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/admin/assets/index.css" />
|
||||
<link rel="stylesheet" crossorigin href="/assets/admin/assets/vendor.css">
|
||||
<script src="/assets/admin/locales/en-US.js"></script>
|
||||
<script src="/assets/admin/locales/zh-CN.js"></script>
|
||||
<script src="/assets/admin/locales/ko-KR.js"></script>
|
||||
@endif
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user