mirror of
https://github.com/9technologygroup/patchmon.net.git
synced 2025-11-18 21:48:58 +00:00
fix: add try-catch protection for Trianglify canvas generation to prevent runtime errors in Docker
This commit is contained in:
@@ -240,6 +240,7 @@ const Layout = ({ children }) => {
|
|||||||
// Generate Trianglify background for dark mode
|
// Generate Trianglify background for dark mode
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const generateBackground = () => {
|
const generateBackground = () => {
|
||||||
|
try {
|
||||||
if (
|
if (
|
||||||
bgCanvasRef.current &&
|
bgCanvasRef.current &&
|
||||||
themeConfig?.login &&
|
themeConfig?.login &&
|
||||||
@@ -263,6 +264,10 @@ const Layout = ({ children }) => {
|
|||||||
// Render to canvas
|
// Render to canvas
|
||||||
pattern.toCanvas(bgCanvasRef.current);
|
pattern.toCanvas(bgCanvasRef.current);
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// Canvas/trianglify not available, skip background generation
|
||||||
|
console.warn("Could not generate Trianglify background:", error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
generateBackground();
|
generateBackground();
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ const Login = () => {
|
|||||||
// Generate Trianglify background based on selected theme
|
// Generate Trianglify background based on selected theme
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const generateBackground = () => {
|
const generateBackground = () => {
|
||||||
|
try {
|
||||||
if (canvasRef.current && themeConfig?.login) {
|
if (canvasRef.current && themeConfig?.login) {
|
||||||
// Get current date as seed for daily variation
|
// Get current date as seed for daily variation
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
@@ -79,6 +80,10 @@ const Login = () => {
|
|||||||
// Render to canvas
|
// Render to canvas
|
||||||
pattern.toCanvas(canvasRef.current);
|
pattern.toCanvas(canvasRef.current);
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// Canvas/trianglify not available, skip background generation
|
||||||
|
console.warn("Could not generate Trianglify background:", error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
generateBackground();
|
generateBackground();
|
||||||
|
|||||||
Reference in New Issue
Block a user