Add visual CMS, media library and product directory

This commit is contained in:
2026-11-21 19:27:46 +08:00
parent 188a63fb2f
commit 474008b06e
42 changed files with 1710 additions and 134 deletions
+8 -4
View File
@@ -10,17 +10,21 @@ final class View
{
public static function render(string $template, array $data, int $status = 200, bool $admin = false): Response
{
$cdn = $admin || !empty($data['previewMode']) ? '' : ($data['site']['cdn']['origin'] ?? '');
$data['cdn'] = $cdn;
$html = self::fragment($template, $data);
$page = self::fragment($admin ? 'admin-layout' : 'layout', $data + ['content' => $html]);
$page = Assets::rewrite(self::fragment($admin ? 'admin-layout' : 'layout', $data + ['content' => $html]), $cdn);
$assetSources = $cdn === '' ? "'self'" : "'self' " . $cdn;
$headers = [
'Content-Type' => 'text/html; charset=utf-8',
'X-Content-Type-Options' => 'nosniff',
'Referrer-Policy' => 'strict-origin-when-cross-origin',
'X-Frame-Options' => 'DENY',
'X-Frame-Options' => !empty($data['previewMode']) ? 'SAMEORIGIN' : 'DENY',
'Content-Security-Policy' => "default-src 'self'; img-src 'self' https:; media-src 'self' https:; "
. "style-src 'self'; script-src 'self'; frame-ancestors 'none'; form-action 'self'; base-uri 'none'; object-src 'none'",
. "style-src $assetSources; script-src $assetSources; font-src $assetSources; frame-src 'self'; frame-ancestors "
. (!empty($data['previewMode']) ? "'self'" : "'none'") . "; form-action 'self'; base-uri 'none'; object-src 'none'",
];
if ($admin) {
if ($admin || !empty($data['previewMode'])) {
$headers['Cache-Control'] = 'no-store';
$headers['X-Robots-Tag'] = 'noindex, nofollow';
} elseif (($data['noindex'] ?? false) || $status >= 400) {