Browse Source

zzy ++ 上勘代理接入

zhiyuan-007 1 month ago
parent
commit
ed3d5ac28e

+ 2 - 0
.env.development

@@ -1,4 +1,6 @@
 VITE_BASE_API='/api'
 VITE_OPEN_API='/addressapi'
+VITE_PROXY_API='/api-v2'
 VITE_BASE_URL='http://localhost:9250'
 VITE_OPEN_URL='http://localhost:9250'
+VITE_PROXY_URL='http://localhost:9250'

+ 3 - 1
.env.production

@@ -1,4 +1,6 @@
 VITE_BASE_API='https://cimweb.zjw.sh.cegn.cn:2007/data-business-prod/'
 VITE_BASE_URL='https://cimweb.zjw.sh.cegn.cn:2007/data-business-prod/'
 VITE_OPEN_API='https://cimweb.zjw.sh.cegn.cn:2008/'
-VITE_OPEN_URL='https://cimweb.zjw.sh.cegn.cn:2008/'
+VITE_OPEN_URL='https://cimweb.zjw.sh.cegn.cn:2008/'
+VITE_PROXY_API='https://cimweb.zjw.sh.cegn.cn:2007/data-business-prod-2/'
+VITE_PROXY_URL='https://cimweb.zjw.sh.cegn.cn:2007/data-business-prod-2/'

+ 24 - 6
src/service/index.js

@@ -205,12 +205,30 @@ requestInstance_proxy_token.interceptors.response.use(function (res){
     return new Error(error);
 });
 
+const requestInstance_proxyProject_token = axios.create({
+    baseURL:import.meta.env.VITE_PROXY_API,
+    timeout,
+    method:"get",
+});
+requestInstance_proxyProject_token.interceptors.request.use((config) =>{
+    return config;
+},(error) =>{
+    return new Error(error);
+});
+requestInstance_proxyProject_token.interceptors.response.use(function (res){
+    return res.data;
+},function (error){
+    return new Error(error);
+});
+
+
+
 export {
-    requestInstance_Get,requestInstance_proxy_token
+    requestInstance_Get,requestInstance_proxy_token,requestInstance_proxyProject_token
 }
 
-const requestInstance_proxy_form = axios.create({
-    baseURL:import.meta.env.VITE_OPEN_API,
+const requestInstance_proxyProject_form = axios.create({
+    baseURL:import.meta.env.VITE_PROXY_API,
     timeout,
     method:"post",
     headers:{
@@ -218,19 +236,19 @@ const requestInstance_proxy_form = axios.create({
     },
     responseType: "blob",
 });
-requestInstance_proxy_form.interceptors.request.use((config) =>{
+requestInstance_proxyProject_form.interceptors.request.use((config) =>{
     return config;
 },(error) =>{
     return new Error(error);
 });
-requestInstance_proxy_form.interceptors.response.use(function (res){
+requestInstance_proxyProject_form.interceptors.response.use(function (res){
     return res.data;
 },function (error){
     return new Error(error);
 });
 
 export {
-    requestInstance_proxy_form
+    requestInstance_proxyProject_form
 }
 
 

+ 15 - 15
src/service/my-apply.js

@@ -1,8 +1,8 @@
 import {
  requestInstance,
  requestInstance_Address,
- requestInstance_Boat, requestInstance_proxy_form,
- requestInstance_proxy_token
+ requestInstance_Boat,
+ requestInstance_proxy_token, requestInstance_proxyProject_form, requestInstance_proxyProject_token
 } from "@/service/index";
 export function getMyApplyHomeTableDataSj(params) {
  return requestInstance({
@@ -94,8 +94,8 @@ export function pipeCollision(params){
 
 
 export function getGeologyAnalysisData(params){
- return requestInstance_proxy_token({
-  url:'/CIMAPI/api/v1/momitor/cfy/getGeologyAnalysisData',
+ return requestInstance_proxyProject_token({
+  url:'/shangKan/getGeologyAnalysisData',
   params:{
    "modelId":1075,
    "x":params.x,
@@ -105,11 +105,11 @@ export function getGeologyAnalysisData(params){
 }
 
 export function getGeologyProfileByPoints(params){
- return requestInstance_proxy_token({
-  url:'/CIMAPI/api/v1/momitor/cfy/getGeologyProfileByPoints',
+ return requestInstance_proxyProject_token({
+  url:'/shangKan/getGeologyProfileByPoints',
   params:{
    "modelId":1075,
-   "positions":params.positions,
+   "positions":encodeURIComponent(params.positions),
    "height":"200",
   }
  })
@@ -117,11 +117,11 @@ export function getGeologyProfileByPoints(params){
 
 
 export function getGeologyAnalysisDataByPoints(params){
- return requestInstance_proxy_token({
-  url:'/CIMAPI/api/v1/momitor/cfy/getGeologyAnalysisDataByPoints',
+ return requestInstance_proxyProject_token({
+  url:'/shangKan/getGeologyAnalysisDataByPoints',
   params:{
    "modelId":1075,
-   "positions":params.positions,
+   "positions":encodeURIComponent(params.positions),
    "height":params.height,
   }
  })
@@ -129,12 +129,12 @@ export function getGeologyAnalysisDataByPoints(params){
 
 
 export function getPileBearingCapacityData(params){
- return requestInstance_proxy_token({
-  url:'/CIMAPI/api/v1/momitor/cfy/getPileBearingCapacityData',
+ return requestInstance_proxyProject_token({
+  url:'/shangKan/getPileBearingCapacityData',
   params:{
    //"modelId":1075,
    "modelId":params.modelId,
-   "positions":params.positions,
+   "positions":encodeURIComponent(params.positions),
    "lengthX":params.distance,
    "length":params.length,
   }
@@ -149,8 +149,8 @@ export function mergeHoleFenceng(params,file){
  Object.keys(params).forEach(key => {
   formData.append(key, params[key]);
  });
- return requestInstance_proxy_form({
-  url:'/CIMAPI/api/v1/Stratseq/mergeHoleFenceng',
+ return requestInstance_proxyProject_form({
+  url:'/shangKan/mergeHoleFenceng',
   data:formData
  })
 }

+ 2 - 2
src/views/c-views/right-tool/geologyTheme/normalizationProcessing/NormalizationProcessing.vue

@@ -68,7 +68,7 @@ export default {
     })
     function downloadModel(){
       try{
-        let url = import.meta.env.VITE_OPEN_API+"/CIMAPI/model/%E6%A8%A1%E6%9D%BF.xls";
+        let url = import.meta.env.VITE_PROXY_API+"/shangKan/xlsxTemplate";
         let elementIframe = document.createElement("iframe");
         elementIframe.src = url;
         elementIframe.style.display = "none";
@@ -78,7 +78,7 @@ export default {
       }
     }
     function getAction(){
-      return import.meta.env.VITE_OPEN_API + "/CIMAPI/api/v1/Stratseq/mergeFenceng";
+      return import.meta.env.VITE_PROXY_API + "/shangKan/mergeFenceng";
     }
     function removeFile(){
       fieldList.value = [];

+ 17 - 0
vite.config.js

@@ -13,6 +13,23 @@ export default defineConfig({
   server:{
     cors: true,
     proxy: {
+      '^/api-v2': {
+        // 代理请求之后的请求地址(你的真实接口地址)
+        //target: 'https://cimweb.zjw.sh.cegn.cn:2007/data-business-prod-2/',
+        target: 'http://192.168.3.32:9250/',
+        secure: false,
+        ws: true,
+        // 跨域
+        changeOrigin: true,
+        rewrite: (path) => path.replace(/^\/api-v2/, ''),
+        configure: (proxy) => {
+          proxy.on('proxyReq', function (proxyReq) {
+            proxyReq.removeHeader('referer')
+            proxyReq.removeHeader('origin')
+            proxyReq.setHeader('host','cimweb.zjw.sh.cegn.cn:2007')
+          })
+        },
+      },
       // 代理所有 /api 的请求,该求情将被代理到 target 中
       '/api': {
         // 代理请求之后的请求地址(你的真实接口地址)