adminizer 4.6.0-build.213 → 4.6.0-build.214
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -26,6 +26,14 @@ interface DashboardConfig {
|
|
|
26
26
|
}
|
|
27
27
|
export interface AdminpanelConfig {
|
|
28
28
|
routePrefix: string;
|
|
29
|
+
/**
|
|
30
|
+
* Custom favicon URL for admin pages.
|
|
31
|
+
* - absolute URL is used as-is (`https://...`, `//...`, `data:...`)
|
|
32
|
+
* - path starting with `/` is treated as absolute path from site root
|
|
33
|
+
* - relative path is resolved from `routePrefix`
|
|
34
|
+
* @default `${routePrefix}/files/favicon.png`
|
|
35
|
+
*/
|
|
36
|
+
favicon?: string;
|
|
29
37
|
/** prepare to impl dashboard*/
|
|
30
38
|
dashboard?: boolean | DashboardConfig;
|
|
31
39
|
theme?: string;
|
package/package.json
CHANGED
package/system/bindInertia.js
CHANGED
|
@@ -4,6 +4,24 @@ import fs from "fs";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { InertiaMenuHelper } from "../helpers/inertiaMenuHelper.js";
|
|
6
6
|
export function bindInertia(adminizer) {
|
|
7
|
+
const escapeHtmlAttribute = (value) => value
|
|
8
|
+
.replace(/&/g, "&")
|
|
9
|
+
.replace(/"/g, """)
|
|
10
|
+
.replace(/</g, "<")
|
|
11
|
+
.replace(/>/g, ">");
|
|
12
|
+
const resolveFaviconHref = () => {
|
|
13
|
+
const customFavicon = adminizer.config.favicon?.trim();
|
|
14
|
+
if (!customFavicon) {
|
|
15
|
+
return `${adminizer.config.routePrefix}/files/favicon.png`;
|
|
16
|
+
}
|
|
17
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(customFavicon) || customFavicon.startsWith("//")) {
|
|
18
|
+
return customFavicon;
|
|
19
|
+
}
|
|
20
|
+
if (customFavicon.startsWith("/")) {
|
|
21
|
+
return customFavicon;
|
|
22
|
+
}
|
|
23
|
+
return `${adminizer.config.routePrefix}/${customFavicon.replace(/^\/+/, "")}`;
|
|
24
|
+
};
|
|
7
25
|
const viteRender = () => {
|
|
8
26
|
if (process.env.VITE_ENV === 'dev') {
|
|
9
27
|
return `
|
|
@@ -69,12 +87,13 @@ export function bindInertia(adminizer) {
|
|
|
69
87
|
}
|
|
70
88
|
};
|
|
71
89
|
const getHtml = (page, _viewData) => {
|
|
90
|
+
const faviconHref = escapeHtmlAttribute(resolveFaviconHref());
|
|
72
91
|
return `
|
|
73
92
|
<!DOCTYPE html><html lang="${_viewData.lang}">
|
|
74
93
|
<head>
|
|
75
94
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
76
95
|
<meta charset="utf-8"><title inertia></title>
|
|
77
|
-
<link rel="icon" type="image/png" href="${
|
|
96
|
+
<link rel="icon" type="image/png" href="${faviconHref}">
|
|
78
97
|
${viteRender()}
|
|
79
98
|
</head>
|
|
80
99
|
<body>
|