소스 검색

添加token,修改url路由地址

LAPTOP-BJJ3IV5R\SIWEI 9 달 전
부모
커밋
c52340f0b9
1개의 변경된 파일23개의 추가작업 그리고 18개의 파일을 삭제
  1. 23 18
      src/api/zt/ztApi.js

+ 23 - 18
src/api/zt/ztApi.js

@@ -5,11 +5,12 @@ import { tansParams, blobValidate } from "@/utils/ruoyi";
 import cache from "@/plugins/cache";
 import { Notification, MessageBox, Message, Loading } from "element-ui";
 import { saveAs } from "file-saver";
+import { getToken } from "@/utils/auth";
 axios.defaults.headers["Content-Type"] = "application/json;charset=utf-8";
 // 创建axios实例
 const request = axios.create({
   // axios中请求配置有baseURL选项,表示请求URL公共部分
-  baseURL: window.ZTaxiosURI,
+  baseURL: window.axiosURI,
   //baseURL: "http://192.168.100.252:8080",
   // 超时
   timeout: 100000,
@@ -18,6 +19,10 @@ const request = axios.create({
 // request拦截器
 request.interceptors.request.use(
   (config) => {
+    //代码防止重复提交会导致浏览器内存溢出,因此没在这添加判断
+    if (getToken()) {
+      config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
+    }
     // 是否需要防止数据重复提交
     const isRepeatSubmit = (config.headers || {}).repeatSubmit === false;
     // get请求映射params参数
@@ -155,7 +160,7 @@ request.interceptors.response.use(
  */
 export async function getJZDJWord(data) {
   let response = await request({
-    url: "/sanya/exportWord/exportWord4",
+    url: "/model/exportWord/exportWord4",
     method: "post",
     responseType: "blob",
     data: data,
@@ -191,7 +196,7 @@ export async function getJZDJWord(data) {
  */
 export async function getZDBCWord(data) {
   let response = await request({
-    url: "/sanya/exportWord/exportWord3",
+    url: "/model/exportWord/exportWord3",
     method: "post",
     responseType: "blob",
     data: data,
@@ -223,7 +228,7 @@ export async function getZDBCWord(data) {
 // 查询项目信息列表
 export async function listProjectinformation(query) {
   return await request({
-    url: "/sanya/projectinformation/list",
+    url: "/model/projectinformation/list",
     method: "get",
     params: query,
   });
@@ -232,7 +237,7 @@ export async function listProjectinformation(query) {
 // 查询项目信息详细
 export async function getProjectinformation(id) {
   return await request({
-    url: "/sanya/projectinformation/" + id,
+    url: "/model/projectinformation/" + id,
     method: "get",
   });
 }
@@ -240,7 +245,7 @@ export async function getProjectinformation(id) {
 // 新增项目信息
 export async function addProjectinformation(data) {
   return await request({
-    url: "/sanya/projectinformation",
+    url: "/model/projectinformation",
     method: "post",
     data: data,
   });
@@ -249,7 +254,7 @@ export async function addProjectinformation(data) {
 // 修改项目信息
 export async function updateProjectinformation(data) {
   return await request({
-    url: "/sanya/projectinformation",
+    url: "/model/projectinformation",
     method: "put",
     data: data,
   });
@@ -258,7 +263,7 @@ export async function updateProjectinformation(data) {
 // 删除项目信息
 export async function delProjectinformation(id) {
   return await request({
-    url: "/sanya/projectinformation/" + id,
+    url: "/model/projectinformation/" + id,
     method: "delete",
   });
 }
@@ -266,7 +271,7 @@ export async function delProjectinformation(id) {
 // 查询报建模型列表
 export async function listConstructionmodel(query) {
   return await request({
-    url: "/sanya/constructionmodel/list",
+    url: "/model/constructionmodel/list",
     method: "get",
     params: query,
   });
@@ -275,7 +280,7 @@ export async function listConstructionmodel(query) {
 // 查询报建模型详细
 export async function getConstructionmodel(id) {
   return await request({
-    url: "/sanya/constructionmodel/" + id,
+    url: "/model/constructionmodel/" + id,
     method: "get",
   });
 }
@@ -283,7 +288,7 @@ export async function getConstructionmodel(id) {
 // 新增报建模型
 export async function addConstructionmodel(data) {
   return await request({
-    url: "/sanya/constructionmodel",
+    url: "/model/constructionmodel",
     method: "post",
     data: data,
   });
@@ -292,7 +297,7 @@ export async function addConstructionmodel(data) {
 // 修改报建模型
 export async function updateConstructionmodel(data) {
   return await request({
-    url: "/sanya/constructionmodel",
+    url: "/model/constructionmodel",
     method: "put",
     data: data,
   });
@@ -301,7 +306,7 @@ export async function updateConstructionmodel(data) {
 // 删除报建模型
 export async function delConstructionmodel(id) {
   return await request({
-    url: "/sanya/constructionmodel/" + id,
+    url: "/model/constructionmodel/" + id,
     method: "delete",
   });
 }
@@ -309,7 +314,7 @@ export async function delConstructionmodel(id) {
 // 查询基准地价信息列表
 export function listBenchmarkLandPrices(query) {
   return request({
-    url: "/sanya/BenchmarkLandPrices/list",
+    url: "/model/BenchmarkLandPrices/list",
     method: "get",
     params: query,
   });
@@ -318,7 +323,7 @@ export function listBenchmarkLandPrices(query) {
 // 查询基准地价信息详细
 export function getBenchmarkLandPrices(id) {
   return request({
-    url: "/sanya/BenchmarkLandPrices/" + id,
+    url: "/model/BenchmarkLandPrices/" + id,
     method: "get",
   });
 }
@@ -326,7 +331,7 @@ export function getBenchmarkLandPrices(id) {
 // 新增基准地价信息
 export function addBenchmarkLandPrices(data) {
   return request({
-    url: "/sanya/BenchmarkLandPrices",
+    url: "/model/BenchmarkLandPrices",
     method: "post",
     data: data,
   });
@@ -335,7 +340,7 @@ export function addBenchmarkLandPrices(data) {
 // 修改基准地价信息
 export function updateBenchmarkLandPrices(data) {
   return request({
-    url: "/sanya/BenchmarkLandPrices",
+    url: "/model/BenchmarkLandPrices",
     method: "put",
     data: data,
   });
@@ -344,7 +349,7 @@ export function updateBenchmarkLandPrices(data) {
 // 删除基准地价信息
 export function delBenchmarkLandPrices(id) {
   return request({
-    url: "/sanya/BenchmarkLandPrices/" + id,
+    url: "/model/BenchmarkLandPrices/" + id,
     method: "delete",
   });
 }