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

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';
} 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';
} 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';
} 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
if (pathname.endsWith('/') || pathname.endsWith('/questioneer')) {
return pathname + 'static';
return pathname + '/static';
} else {
return pathname + '/static';
}

View File

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

View File

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

View File

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

View File

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