|
@@ -293,7 +293,19 @@
|
|
|
let priceChart = null;
|
|
let priceChart = null;
|
|
|
let diffChart = null;
|
|
let diffChart = null;
|
|
|
let autoRefreshInterval = null;
|
|
let autoRefreshInterval = null;
|
|
|
- const API_BASE = 'http://localhost:5000/api';
|
|
|
|
|
|
|
+ // 动态设置API基础URL
|
|
|
|
|
+ let API_BASE = '';
|
|
|
|
|
+
|
|
|
|
|
+ // 检查当前域名来决定API地址
|
|
|
|
|
+ if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
|
|
|
|
|
+ // 本地开发环境
|
|
|
|
|
+ API_BASE = 'http://localhost:5000/api';
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 生产环境
|
|
|
|
|
+ API_BASE = `http://${window.location.hostname}:5000/api`;
|
|
|
|
|
+ // 如果不需要显示端口号,可以使用下面的代码
|
|
|
|
|
+ // API_BASE = `http://${window.location.hostname}/api`;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 初始化
|
|
// 初始化
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
document.addEventListener('DOMContentLoaded', function() {
|