Еще правки с урлами и верстка

This commit is contained in:
Primakov Alexandr Alexandrovich 2025-03-12 00:37:32 +03:00
parent dd589790c2
commit b5301f948a
10 changed files with 41 additions and 56 deletions

View File

@ -13,7 +13,9 @@
return '/ms/questioneer/static'; return '/ms/questioneer/static';
} else { } else {
// Для локальной разработки // Для локальной разработки
return window.location.pathname.split('/admin')[0] + '/static'; const basePath = window.location.pathname.split('/admin')[0];
// Проверяем, заканчивается ли путь на слеш
return basePath + (basePath.endsWith('/') ? 'static' : '/static');
} }
} }

View File

@ -13,7 +13,9 @@
return '/ms/questioneer/static'; return '/ms/questioneer/static';
} else { } else {
// Для локальной разработки // Для локальной разработки
return window.location.pathname.split('/create')[0] + '/static'; const basePath = window.location.pathname.split('/create')[0];
// Проверяем, заканчивается ли путь на слеш
return basePath + (basePath.endsWith('/') ? 'static' : '/static');
} }
} }

View File

@ -13,7 +13,9 @@
return '/ms/questioneer/static'; return '/ms/questioneer/static';
} else { } else {
// Для локальной разработки // Для локальной разработки
return window.location.pathname.split('/edit')[0] + '/static'; const basePath = window.location.pathname.split('/edit')[0];
// Проверяем, заканчивается ли путь на слеш
return basePath + (basePath.endsWith('/') ? 'static' : '/static');
} }
} }

View File

@ -16,7 +16,7 @@
// Для локальной разработки // Для локальной разработки
// Если путь заканчивается на слеш или на /questioneer, добавляем /static // Если путь заканчивается на слеш или на /questioneer, добавляем /static
if (pathname.endsWith('/') || pathname.endsWith('/questioneer')) { if (pathname.endsWith('/') || pathname.endsWith('/questioneer')) {
return pathname + 'static'; return pathname + '/static';
} else { } else {
return pathname + '/static'; return pathname + '/static';
} }

View File

@ -13,7 +13,9 @@
return '/ms/questioneer/static'; return '/ms/questioneer/static';
} else { } else {
// Для локальной разработки // Для локальной разработки
return window.location.pathname.split('/poll')[0] + '/static'; const basePath = window.location.pathname.split('/poll')[0];
// Проверяем, заканчивается ли путь на слеш
return basePath + (basePath.endsWith('/') ? 'static' : '/static');
} }
} }

View File

@ -13,16 +13,12 @@ $(document).ready(function() {
// Для продакшна: если в пути есть /ms/, то API доступно по /ms/questioneer/api // Для продакшна: если в пути есть /ms/, то API доступно по /ms/questioneer/api
return '/ms/questioneer/api'; return '/ms/questioneer/api';
} else { } else {
// Для локальной разработки: используем обычный путь // Для локальной разработки: формируем путь к API без учета текущей страницы
// Извлекаем базовый путь из URL страницы // Извлекаем базовый путь из URL страницы до /admin/[adminLink]
const pathParts = pathname.split('/'); const basePath = pathname.split('/admin')[0];
// Если последний сегмент пустой (из-за /) - удаляем его
if (pathParts[pathParts.length - 1] === '') {
pathParts.pop();
}
// Путь до корня приложения // Путь до API приложения
return pathParts.join('/') + '/api'; return basePath + '/api';
} }
}; };

View File

@ -16,16 +16,12 @@ $(document).ready(function() {
// Для продакшна: если в пути есть /ms/, то API доступно по /ms/questioneer/api // Для продакшна: если в пути есть /ms/, то API доступно по /ms/questioneer/api
return '/ms/questioneer/api'; return '/ms/questioneer/api';
} else { } else {
// Для локальной разработки: используем обычный путь // Для локальной разработки: формируем путь к API без учета текущей страницы
// Извлекаем базовый путь из URL страницы // Извлекаем базовый путь из URL страницы до /create
const pathParts = pathname.split('/'); const basePath = pathname.split('/create')[0];
// Если последний сегмент пустой (из-за /) - удаляем его
if (pathParts[pathParts.length - 1] === '') {
pathParts.pop();
}
// Путь до корня приложения // Путь до API приложения
return pathParts.join('/') + '/api'; return basePath + '/api';
} }
}; };

View File

@ -18,16 +18,15 @@ $(document).ready(function() {
// Для продакшна: если в пути есть /ms/, то API доступно по /ms/questioneer/api // Для продакшна: если в пути есть /ms/, то API доступно по /ms/questioneer/api
return '/ms/questioneer/api'; return '/ms/questioneer/api';
} else { } else {
// Для локальной разработки: используем обычный путь // Для локальной разработки: формируем путь к API без учета текущей страницы
// Извлекаем базовый путь из URL страницы // Извлекаем базовый путь из URL страницы до /edit/[adminLink]
const pathParts = pathname.split('/'); const basePath = pathname.split('/edit')[0];
// Если последний сегмент пустой (из-за /) - удаляем его
if (pathParts[pathParts.length - 1] === '') {
pathParts.pop();
}
// Путь до корня приложения // Убеждаемся, что путь не заканчивается на /admin, если это часть URL
return pathParts.join('/') + '/api'; const cleanPath = basePath.endsWith('/admin') ? basePath.slice(0, -6) : basePath;
// Путь до API приложения
return cleanPath + '/api';
} }
}; };

View File

@ -10,16 +10,12 @@ $(document).ready(function() {
// Для продакшна: если в пути есть /ms/, то API доступно по /ms/questioneer/api // Для продакшна: если в пути есть /ms/, то API доступно по /ms/questioneer/api
return '/ms/questioneer/api'; return '/ms/questioneer/api';
} else { } else {
// Для локальной разработки: используем обычный путь // Для локальной разработки: формируем путь к API для главной страницы
// Извлекаем базовый путь из URL страницы // Убираем завершающий слеш, если он есть
const pathParts = pathname.split('/'); const basePath = pathname.endsWith('/') ? pathname.slice(0, -1) : pathname;
// Если последний сегмент пустой (из-за /) - удаляем его
if (pathParts[pathParts.length - 1] === '') {
pathParts.pop();
}
// Путь до корня приложения // Путь до API приложения
return pathParts.join('/') + '/api'; return basePath + '/api';
} }
}; };

View File

@ -63,22 +63,12 @@ $(document).ready(function() {
// Для продакшна: если в пути есть /ms/, то API доступно по /ms/questioneer/api // Для продакшна: если в пути есть /ms/, то API доступно по /ms/questioneer/api
return '/ms/questioneer/api'; return '/ms/questioneer/api';
} else { } else {
// Для локальной разработки: используем обычный путь // Для локальной разработки: формируем путь к API без учета текущей страницы
// Извлекаем базовый путь из URL страницы // Извлекаем базовый путь из URL страницы до /poll
const pathParts = pathname.split('/'); const basePath = pathname.split('/poll')[0];
// Убираем slug и последний сегмент (poll/[id])
if (pathParts.length > 2) {
// Удаляем 2 последних сегмента пути (poll/[id])
pathParts.pop();
pathParts.pop();
}
// Если последний сегмент пустой (из-за /) - удаляем его
if (pathParts[pathParts.length - 1] === '') {
pathParts.pop();
}
// Путь до корня приложения // Путь до API приложения
return pathParts.join('/') + '/api'; return basePath + '/api';
} }
}; };