fix:跨域设置

main
zhoulexin 4 months ago
parent 2944af0f06
commit ecdbb44bc5

@ -9,7 +9,7 @@
<link rel="stylesheet" href="/3Dpoints/static/js/lib/jquery-ui-1.12.1/jquery-ui.min.css">
<script src="/3Dpoints/static/js/lib/jquery-ui-1.12.1/jquery-ui.min.js"></script> -->
<link type="text/css" rel="stylesheet" href="/3Dpoints/static/css/main.css">
<!-- <link type="text/css" rel="stylesheet" href="/3Dpoints/static/css/main.css"> -->
</head>
@ -1032,7 +1032,7 @@
</div>
</div>
<div id="log-wrapper" class="popup-window-wrapper" tabindex='-1'>
<div id="log-wrapper" class="popup-window-wrapper" tabindex='-1' style="display: none;">
<div id="view">
<div id="header">
<span id="title">终端</span>
@ -1301,7 +1301,47 @@
</div>
</template>
<script src="/3Dpoints/static/js/lib/ml/tf.min.js"></script>
<script type="module" src="/3Dpoints/static/js/main.js"></script>
<!-- <script src="/3Dpoints/static/js/lib/ml/tf.min.js"></script> -->
<!-- <script type="module" src="/3Dpoints/static/js/main.js"></script> -->
<script>
function loadDynamicResources() {
// 定义不同环境下的基础路径
const basePath = (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1' || window.location.hostname === '192.168.5.177')
? '.'
: '/3Dpoints';
// 动态加载CSS
const links = [
`${basePath}/static/css/main.css`
]
links.forEach(linkHref => {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = `${basePath}/static/css/main.css`;
document.head.appendChild(link);
});
// 动态加载JavaScript
const scripts = [
{type:'text/javascript', src:`${basePath}/static/js/lib/ml/tf.min.js`},
{type:'module', src:`${basePath}/static/js/main.js`}
];
scripts.forEach(item => {
const script = document.createElement('script');
script.src = item.src;
script.type = item.type;
document.head.appendChild(script);
});
}
console.log(window.location.href)
try {
loadDynamicResources();
} catch (error) {
document.addEventListener('DOMContentLoaded', loadDynamicResources);
}
</script>
</body>
</html>

@ -1001,7 +1001,7 @@ function Editor(editorUi, wrapperUi, editorCfg, data, name = "editor") {
this.frame_changed = function (event) {
var sceneName = this.editorUi.querySelector("#scene-selector").value;
console.log(sceneName,'--------------')
if (sceneName.length == 0 && this.data.world) {
sceneName = this.data.world.frameInfo.scene;
}

@ -63,6 +63,7 @@ function Lidar(sceneMeta, world, frameInfo) {
};
this.preload = function (on_preload_finished) {
console.log('载入钱')
this.on_preload_finished = on_preload_finished;
var loader = new PCDLoader();
@ -81,7 +82,6 @@ function Lidar(sceneMeta, world, frameInfo) {
_self.points_parse_time - _self.create_time,
"ms"
);
// if (_self.frameInfo.transform_matrix){
// var arr = position;

@ -1,2 +1,5 @@
const request = location.host.indexOf('localhost')!=-1 ? '' : '/3Dpoints'
const request = location.host.indexOf('localhost:8080')!=-1 ?
'/3d-point-cloud' :
location.host.indexOf('localhost:8081')!=-1 || location.host.indexOf('192.168.5.177:8081')!=-1 ?
'' : '/3Dpoints'
export default request

@ -6,6 +6,7 @@ import { Lidar } from "./lidar.js";
import { Annotation } from "./annotation.js";
import { EgoPose } from "./ego_pose.js";
import { logger } from "./log.js";
import request from "./request.js";
import {
euler_angle_to_rotate_matrix,
euler_angle_to_rotate_matrix_3by3,
@ -36,21 +37,21 @@ function FrameInfo(data, sceneMeta, sceneName, frame) {
(this.get_pcd_path = function () {
return (
"data/" + this.scene + "/lidar/" + this.frame + this.sceneMeta.lidar_ext
request + "/data/" + this.scene + "/lidar/" + this.frame + this.sceneMeta.lidar_ext
);
});
this.get_radar_path = function (name) {
return `data/${this.scene}/radar/${name}/${this.frame}${this.sceneMeta.radar_ext}`;
return `${request}/data/${this.scene}/radar/${name}/${this.frame}${this.sceneMeta.radar_ext}`;
};
this.get_aux_lidar_path = function (name) {
return `data/${this.scene}/aux_lidar/${name}/${this.frame}${this.sceneMeta.radar_ext}`;
return `${request}/data/${this.scene}/aux_lidar/${name}/${this.frame}${this.sceneMeta.radar_ext}`;
};
this.get_anno_path = function () {
if (this.annotation_format == "psr") {
return "data/" + this.scene + "/label/" + this.frame + ".json";
return request + "/data/" + this.scene + "/label/" + this.frame + ".json";
} else {
return "data/" + this.scene + "/bbox.xyz/" + this.frame + ".bbox.txt";
return request + "/data/" + this.scene + "/bbox.xyz/" + this.frame + ".bbox.txt";
}
};

@ -5,6 +5,7 @@ server.socket_port = 8081
[/]
tools.sessions.on = True
tools.staticdir.root = os.path.abspath(os.getcwd())
tools.cors.on = True # ✅ 新增:启用跨域中间件
[/static]
tools.staticdir.on = True

Loading…
Cancel
Save