guonan
2025-05-01 0d4c3c3877bee1c92f574d26c67118dadb4a3dc7
后端ip暴露
已修改6个文件
49 ■■■■■ 文件已修改
public/index.html 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
public/js/config.js 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/requestTR.js 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/simAPI.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/left/CitySim.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
vue.config.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
public/index.html
@@ -7,13 +7,13 @@
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <link rel="icon" href="<%= BASE_URL %>favicon.ico">
  <link rel="stylesheet" href="./CimSDK/CimSDK.min.css">
  <script src="./js/config.js"></script>
  <script src="./js/city.js"></script>
  <script src="./js/turf.min.js"></script>
  <!-- <script src="./js/peer-stream.js"></script> -->
  <script src="./CimSDK/Workers/jquery-3.5.0.min.js"></script>
  <script src="./CimSDK/CimSDK.min.js"></script>
  <script src="./js/proj4.js"></script>
  <script src="./js/config.js"></script>
  <title>地质灾害孪生平台</title>
</head>
public/js/config.js
@@ -1,13 +1,2 @@
const mapDataUrl = "http://localhost:18055/北京地质灾害研究所项目";
// 像素流配置
const defaultStreamUrl = "ws://localhost:88"
window.ps = {
  emitMessage: function (message) {
    // console.log("emitMessage", message)
  }
}
const BASE_URL = "http://192.168.56.107:8077"
console.log('config.js 被加载', new Date().toISOString());
src/api/requestTR.js
@@ -1,13 +1,26 @@
import axios from "axios";
// 判断当前是否是开发环境
let API_URL;
if (process.env.NODE_ENV === 'development') {
  // 开发环境使用 '/api'
  API_URL = '/api';
} else {
  // 生产环境使用实际的配置地址
  API_URL = `${BASE_URL.endsWith('/') ? BASE_URL.slice(0, -1) : BASE_URL}/api`;
}
// 创建 Axios 实例
const instance = axios.create({
  baseURL: "/api", // 使用你配置的 /auth 代理
  baseURL: API_URL,
  timeout: 1000 * 60, // 请求超时时间(单位:毫秒)
  headers: {
    "Content-Type": "application/x-www-form-urlencoded", // 默认请求头application/json
    "Content-Type": "application/x-www-form-urlencoded", // 默认请求头
  },
});
console.log('当前 BaseUrl:', API_URL);
// 请求拦截器
// instance.interceptors.request.use(
//   (config) => {
src/store/simAPI.js
@@ -57,7 +57,7 @@
        try {
            const params = {
                geom: forms.geom,
                geom: forms.geom.value,
                areaType: getAreaType(selectTab.value),
                createTime: Date.now(),
                name: forms.name,
src/views/left/CitySim.vue
@@ -41,6 +41,7 @@
          v-if="simStore.selectTab == '行政区划仿真'"
        >
          <el-select
            @change="changeGeom"
            v-model="forms.geom"
            placeholder="Select"
            style="max-width: 600px"
@@ -49,7 +50,7 @@
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
              :value="item"
            />
          </el-select>
        </el-form-item>
@@ -66,7 +67,7 @@
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
              :value="item"
            />
          </el-select>
        </el-form-item>
@@ -196,6 +197,10 @@
  hours: null,
});
const changeGeom = (val) => {
  console.log(val,'aaaaaaaaaaaaaaa')
}
const { calculateHoursDifference } = inject("calculateHours");
const change = (val) => {
vue.config.js
@@ -21,8 +21,8 @@
    hot: true,
    proxy: {
      '/api': {
        // target: 'http://192.168.56.107:8077',
        target: 'http://192.168.1.104:8078',
        target: 'http://192.168.56.107:8077',
        // target: 'http://192.168.1.104:8078',
        changeOrigin: true,
        // pathRewrite: {
        //   '^/api': ''