избавился от jquery
This commit is contained in:
parent
cc44975ef4
commit
c2b9bf78aa
@ -13,7 +13,6 @@ import 'spectrum-colorpicker/spectrum.css';
|
||||
|
||||
// Импортируем зависимости как ES модули
|
||||
import * as THREE from 'three';
|
||||
import $ from 'jquery';
|
||||
import * as d3 from 'd3';
|
||||
import proj4 from 'proj4';
|
||||
import i18next from 'i18next';
|
||||
@ -121,8 +120,6 @@ const PotreeViewerDirect: React.FC = () => {
|
||||
|
||||
// Устанавливаем глобальные переменные для совместимости с Potree
|
||||
window.THREE = THREE;
|
||||
window.$ = $;
|
||||
window.jQuery = $;
|
||||
window.d3 = d3;
|
||||
window.proj4 = proj4;
|
||||
window.i18next = i18next;
|
||||
@ -131,12 +128,12 @@ const PotreeViewerDirect: React.FC = () => {
|
||||
|
||||
|
||||
// Загружаем jQuery UI динамически
|
||||
await loadJQueryUI();
|
||||
// await loadJQueryUI();
|
||||
|
||||
console.log('✅ Все модули готовы:', {
|
||||
THREE: !!window.THREE,
|
||||
jQuery: !!window.$,
|
||||
jQueryUI: !!window.$.ui,
|
||||
jQuery: false,
|
||||
jQueryUI: false,
|
||||
d3: !!window.d3,
|
||||
proj4: !!window.proj4,
|
||||
i18next: !!window.i18next,
|
||||
@ -154,58 +151,58 @@ const PotreeViewerDirect: React.FC = () => {
|
||||
};
|
||||
|
||||
// Функция для загрузки jQuery UI
|
||||
const loadJQueryUI = (): Promise<void> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
// Проверяем, не загружен ли уже jQuery UI
|
||||
if (window.$ && window.$.ui) {
|
||||
console.log('jQuery UI уже загружен');
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
// const loadJQueryUI = (): Promise<void> => {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// // Проверяем, не загружен ли уже jQuery UI
|
||||
// if (window.$ && window.$.ui) {
|
||||
// console.log('jQuery UI уже загружен');
|
||||
// resolve();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Загружаем CSS для jQuery UI
|
||||
const loadCSS = (href: string) => {
|
||||
if (!document.querySelector(`link[href="${href}"]`)) {
|
||||
const link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.type = 'text/css';
|
||||
link.href = href;
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
};
|
||||
// // Загружаем CSS для jQuery UI
|
||||
// const loadCSS = (href: string) => {
|
||||
// if (!document.querySelector(`link[href="${href}"]`)) {
|
||||
// const link = document.createElement('link');
|
||||
// link.rel = 'stylesheet';
|
||||
// link.type = 'text/css';
|
||||
// link.href = href;
|
||||
// document.head.appendChild(link);
|
||||
// }
|
||||
// };
|
||||
|
||||
// Пробуем загрузить CSS из public/libs
|
||||
loadCSS('/libs/jquery-ui/jquery-ui.min.css');
|
||||
// // Пробуем загрузить CSS из public/libs
|
||||
// loadCSS('/libs/jquery-ui/jquery-ui.min.css');
|
||||
|
||||
const script = document.createElement('script');
|
||||
script.src = '/libs/jquery-ui/jquery-ui.min.js'; // Используем из public/libs
|
||||
script.async = false;
|
||||
// const script = document.createElement('script');
|
||||
// script.src = '/libs/jquery-ui/jquery-ui.min.js'; // Используем из public/libs
|
||||
// script.async = false;
|
||||
|
||||
script.onload = () => {
|
||||
console.log('✅ jQuery UI загружен');
|
||||
resolve();
|
||||
};
|
||||
// script.onload = () => {
|
||||
// console.log('✅ jQuery UI загружен');
|
||||
// resolve();
|
||||
// };
|
||||
|
||||
script.onerror = (error) => {
|
||||
console.warn('⚠️ Не удалось загрузить jQuery UI из public/libs, пробуем из node_modules');
|
||||
// script.onerror = (error) => {
|
||||
// console.warn('⚠️ Не удалось загрузить jQuery UI из public/libs, пробуем из node_modules');
|
||||
|
||||
// Fallback - пробуем загрузить из node_modules
|
||||
const fallbackScript = document.createElement('script');
|
||||
fallbackScript.src = '/node_modules/jquery-ui-dist/jquery-ui.min.js';
|
||||
fallbackScript.onload = () => {
|
||||
console.log('✅ jQuery UI загружен из node_modules');
|
||||
resolve();
|
||||
};
|
||||
fallbackScript.onerror = () => {
|
||||
console.warn('⚠️ Продолжаем без jQuery UI');
|
||||
resolve(); // Не блокируем выполнение
|
||||
};
|
||||
document.head.appendChild(fallbackScript);
|
||||
};
|
||||
// // Fallback - пробуем загрузить из node_modules
|
||||
// const fallbackScript = document.createElement('script');
|
||||
// fallbackScript.src = '/node_modules/jquery-ui-dist/jquery-ui.min.js';
|
||||
// fallbackScript.onload = () => {
|
||||
// console.log('✅ jQuery UI загружен из node_modules');
|
||||
// resolve();
|
||||
// };
|
||||
// fallbackScript.onerror = () => {
|
||||
// console.warn('⚠️ Продолжаем без jQuery UI');
|
||||
// resolve(); // Не блокируем выполнение
|
||||
// };
|
||||
// document.head.appendChild(fallbackScript);
|
||||
// };
|
||||
|
||||
document.head.appendChild(script);
|
||||
});
|
||||
};
|
||||
// document.head.appendChild(script);
|
||||
// });
|
||||
// };
|
||||
|
||||
useEffect(() => {
|
||||
console.log('🚀🚀🚀 PotreeViewerDirect useEffect started - ES МОДУЛИ POTREE.JS 🚀🚀🚀');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user