adminizer 4.6.0-build.212 → 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/lib/I18n.js
CHANGED
|
@@ -89,7 +89,11 @@ export class I18n {
|
|
|
89
89
|
}
|
|
90
90
|
try {
|
|
91
91
|
const data = fs.readFileSync(file, "utf8");
|
|
92
|
-
|
|
92
|
+
const parsed = JSON.parse(data);
|
|
93
|
+
I18n.locales[locale] = {
|
|
94
|
+
...(I18n.locales[locale] || {}),
|
|
95
|
+
...parsed
|
|
96
|
+
};
|
|
93
97
|
if (!this.devMode) {
|
|
94
98
|
I18n.localeCache[file] = I18n.locales[locale];
|
|
95
99
|
}
|
|
@@ -51,6 +51,7 @@ export declare class WidgetHandler {
|
|
|
51
51
|
getById(id: string): WidgetType | undefined;
|
|
52
52
|
removeById(id: string): void;
|
|
53
53
|
getAll(user: UserAP, i18n: I18n): Promise<WidgetConfig[]>;
|
|
54
|
+
private translateWidgetConfig;
|
|
54
55
|
getWidgetsDB(id: number, auth: boolean, i18n: I18n): Promise<{
|
|
55
56
|
widgets: WidgetConfig[];
|
|
56
57
|
layout: WidgetsLayouts;
|
|
@@ -119,6 +119,13 @@ export class WidgetHandler {
|
|
|
119
119
|
}
|
|
120
120
|
return Promise.resolve(widgets);
|
|
121
121
|
}
|
|
122
|
+
translateWidgetConfig(widget, i18n) {
|
|
123
|
+
return {
|
|
124
|
+
...widget,
|
|
125
|
+
name: typeof widget.name === "string" ? i18n.__(widget.name) : widget.name,
|
|
126
|
+
description: typeof widget.description === "string" ? i18n.__(widget.description) : widget.description
|
|
127
|
+
};
|
|
128
|
+
}
|
|
122
129
|
async getWidgetsDB(id, auth, i18n) {
|
|
123
130
|
let user;
|
|
124
131
|
let result = {
|
|
@@ -142,7 +149,7 @@ export class WidgetHandler {
|
|
|
142
149
|
}
|
|
143
150
|
else {
|
|
144
151
|
// User has saved widgets - return them
|
|
145
|
-
result.widgets = user.widgets.widgets;
|
|
152
|
+
result.widgets = (user.widgets.widgets || []).map((widget) => this.translateWidgetConfig(widget, i18n));
|
|
146
153
|
result.layout = user.widgets.layout;
|
|
147
154
|
}
|
|
148
155
|
return result;
|
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>
|