fix путей
This commit is contained in:
@@ -4,7 +4,44 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Участие в опросе</title>
|
||||
<link rel="stylesheet" href="/questioneer/static/css/style.css">
|
||||
<!-- Добавляем проверку на различные пути -->
|
||||
<script>
|
||||
// Определяем путь к статическим файлам с учетом prod и dev окружений
|
||||
function getStaticPath() {
|
||||
if (window.location.pathname.includes('/ms/questioneer')) {
|
||||
// Для продакшна
|
||||
return '/ms/questioneer/static';
|
||||
} else {
|
||||
// Для локальной разработки
|
||||
return window.location.pathname.split('/poll')[0] + '/static';
|
||||
}
|
||||
}
|
||||
|
||||
// Динамически добавляем CSS
|
||||
const cssLink = document.createElement('link');
|
||||
cssLink.rel = 'stylesheet';
|
||||
cssLink.href = getStaticPath() + '/css/style.css';
|
||||
document.head.appendChild(cssLink);
|
||||
</script>
|
||||
|
||||
<!-- Добавляем jQuery -->
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Динамически добавляем скрипты
|
||||
const scriptPaths = [
|
||||
'/js/common.js',
|
||||
'/js/poll.js'
|
||||
];
|
||||
|
||||
const staticPath = getStaticPath();
|
||||
scriptPaths.forEach(path => {
|
||||
const script = document.createElement('script');
|
||||
script.src = staticPath + path;
|
||||
document.body.appendChild(script);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
@@ -35,11 +72,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.7.1.min.js"
|
||||
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo="
|
||||
crossorigin="anonymous"></script>
|
||||
<script src="/questioneer/static/js/common.js"></script>
|
||||
<script src="/questioneer/static/js/poll.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user