App-prefix template transferred to javascript to support the vite dev server

pull/1048/head
leviofanh 2025-12-18 07:14:24 +01:00
parent f58e572558
commit e6dcef2b01
No known key found for this signature in database
GPG Key ID: 9AF0F85076CB323E
2 changed files with 26 additions and 4 deletions

View File

@ -6,13 +6,24 @@
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="application-name" content="WGDashboard">
<meta name="apple-mobile-web-app-title" content="WGDashboard">
<base href="{{ APP_PREFIX if APP_PREFIX else '' }}/">
<link rel="manifest" href="./json/manifest.json">
<link rel="icon" href="./img/Logo-2-512x512.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WGDashboard</title>
<script>
window.APP_PREFIX = "{{ APP_PREFIX if APP_PREFIX else '' }}";
let appPrefix = "{{ APP_PREFIX if APP_PREFIX else '' }}";
if (appPrefix.includes('{' + '{')) {
appPrefix = '';
}
window.APP_PREFIX = appPrefix;
const isViteDevMode = document.querySelector('script[src*="@vite/client"]') !== null;
const base = document.createElement('base');
if (isViteDevMode) {
base.href = '/';
} else {
base.href = (window.APP_PREFIX || '') + '/';
}
document.head.insertBefore(base, document.head.firstChild);
</script>
</head>
<body>

View File

@ -2,7 +2,6 @@
<html lang="">
<head>
<meta charset="UTF-8">
<base href="{{ APP_PREFIX if APP_PREFIX else '' }}/client/">
<link rel="icon" href="./img/Logo-2-128x128.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WGDashboard Client</title>
@ -30,7 +29,19 @@
}
</style>
<script>
window.APP_PREFIX = "{{ APP_PREFIX if APP_PREFIX else '' }}";
let appPrefix = "{{ APP_PREFIX if APP_PREFIX else '' }}";
if (appPrefix.includes('{' + '{')) {
appPrefix = '';
}
window.APP_PREFIX = appPrefix;
const isViteDevMode = document.querySelector('script[src*="@vite/client"]') !== null;
const base = document.createElement('base');
if (isViteDevMode) {
base.href = '/';
} else {
base.href = (window.APP_PREFIX || '') + '/client/';
}
document.head.insertBefore(base, document.head.firstChild);
</script>
</head>
<body>