【update】- 请求头中增加externalTerminalShow参数

This commit is contained in:
fengchenchen
2023-08-23 18:00:34 +08:00
parent 377c32a2fb
commit 9de29dfdb9
8 changed files with 34 additions and 6 deletions
+3 -1
View File
@@ -1,5 +1,6 @@
import api from './index' import api from './index'
import { axios } from '@/utils/request' import { axios } from '@/utils/request'
import {isExternalTerminal} from '../utils/util'
/** /**
* login func * login func
@@ -52,7 +53,8 @@ export function logout(logoutToken) {
method: 'post', method: 'post',
headers: { headers: {
'Content-Type': 'application/json;charset=UTF-8', 'Content-Type': 'application/json;charset=UTF-8',
'X-Access-Token': logoutToken 'X-Access-Token': logoutToken,
'externalTerminalShow': isExternalTerminal ? 'external' : 'inside'
} }
}) })
} }
+5 -1
View File
@@ -34,6 +34,7 @@
import { ACCESS_TOKEN } from '@/store/mutation-types' import { ACCESS_TOKEN } from '@/store/mutation-types'
import { getFileAccessHttpUrl } from '@/api/manage' import { getFileAccessHttpUrl } from '@/api/manage'
import {getFileInfo} from '@api/api' import {getFileInfo} from '@api/api'
import {isExternalTerminal} from '../../utils/util'
// eslint-disable-next-line // eslint-disable-next-line
const Base64 = require('js-base64').Base64 const Base64 = require('js-base64').Base64
@@ -120,7 +121,10 @@
}, },
created(){ created(){
const token = Vue.ls.get(ACCESS_TOKEN) const token = Vue.ls.get(ACCESS_TOKEN)
this.headers = {'X-Access-Token':token} this.headers = {
'X-Access-Token': token,
'externalTerminalShow': isExternalTerminal ? 'external' : 'inside'
}
}, },
methods:{ methods:{
async initFileList(paths){ async initFileList(paths){
+5 -1
View File
@@ -54,6 +54,7 @@ import Vue from 'vue'
import {ACCESS_TOKEN} from '@/store/mutation-types' import {ACCESS_TOKEN} from '@/store/mutation-types'
import {getFileAccessHttpUrl, downloadFile} from '@/api/manage' import {getFileAccessHttpUrl, downloadFile} from '@/api/manage'
import {getFileInfo} from '@/api/api' import {getFileInfo} from '@/api/api'
import {isExternalTerminal} from '../../utils/util'
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
// const Base64 = require('js-base64').Base64 // const Base64 = require('js-base64').Base64
@@ -186,7 +187,10 @@ export default {
created() { created() {
const token = Vue.ls.get(ACCESS_TOKEN) const token = Vue.ls.get(ACCESS_TOKEN)
//---------------------------- begin 图片左右换位置 ------------------------------------- //---------------------------- begin 图片左右换位置 -------------------------------------
this.headers = {'X-Access-Token': token} this.headers = {
'X-Access-Token': token,
'externalTerminalShow': isExternalTerminal ? 'external' : 'inside'
}
this.containerId = 'container-ty-' + new Date().getTime() this.containerId = 'container-ty-' + new Date().getTime()
//---------------------------- end 图片左右换位置 ------------------------------------- //---------------------------- end 图片左右换位置 -------------------------------------
}, },
+5 -1
View File
@@ -9,6 +9,7 @@ import Vue from 'vue'
import {ACCESS_TOKEN, TENANT_ID} from '@/store/mutation-types' import {ACCESS_TOKEN, TENANT_ID} from '@/store/mutation-types'
import store from '@/store' import store from '@/store'
import {Modal} from 'ant-design-vue' import {Modal} from 'ant-design-vue'
import {isExternalTerminal} from '../utils/util'
const defaultSorter = { const defaultSorter = {
column: 'createTime', column: 'createTime',
@@ -69,7 +70,10 @@ export const JeroListMixin = {
computed: { computed: {
//token header //token header
tokenHeader() { tokenHeader() {
let head = {'X-Access-Token': Vue.ls.get(ACCESS_TOKEN)} let head = {
'X-Access-Token': Vue.ls.get(ACCESS_TOKEN),
'externalTerminalShow': isExternalTerminal ? 'external' : 'inside'
}
let tenantid = Vue.ls.get(TENANT_ID) let tenantid = Vue.ls.get(TENANT_ID)
if (tenantid) { if (tenantid) {
head['tenant_id'] = tenantid head['tenant_id'] = tenantid
+3
View File
@@ -3,6 +3,7 @@ import axios from 'axios'
import store from '@/store' import store from '@/store'
import { Modal, notification } from 'ant-design-vue' import { Modal, notification } from 'ant-design-vue'
import { ACCESS_TOKEN, TENANT_ID } from '@/store/mutation-types' import { ACCESS_TOKEN, TENANT_ID } from '@/store/mutation-types'
import {isExternalTerminal} from '../utils/util'
/** /**
* 【指定 axios的 baseURL】 * 【指定 axios的 baseURL】
@@ -100,6 +101,8 @@ service.interceptors.request.use(config => {
if (token) { if (token) {
config.headers['X-Access-Token'] = token // 让每个请求携带自定义 token 请根据实际情况自行修改 config.headers['X-Access-Token'] = token // 让每个请求携带自定义 token 请根据实际情况自行修改
} }
// 请求头里面放是否是外网展示的标识
config.headers['externalTerminalShow'] = isExternalTerminal ? 'external' : 'inside'
} }
//update-begin-author:taoyan date:2020707 for:多租户 //update-begin-author:taoyan date:2020707 for:多租户
let tenantid = Vue.ls.get(TENANT_ID) let tenantid = Vue.ls.get(TENANT_ID)
+3
View File
@@ -3,6 +3,7 @@ import axios from 'axios'
import store from '@/store' import store from '@/store'
import {Modal, notification} from 'ant-design-vue' import {Modal, notification} from 'ant-design-vue'
import { ACCESS_TOKEN, TENANT_ID } from '@/store/mutation-types' import { ACCESS_TOKEN, TENANT_ID } from '@/store/mutation-types'
import {isExternalTerminal} from './util'
/** /**
* 【指定 axios的 baseURL】 * 【指定 axios的 baseURL】
@@ -95,6 +96,8 @@ const err = (error) => {
// request interceptor // request interceptor
service.interceptors.request.use(config => { service.interceptors.request.use(config => {
// 请求头里面放是否是外网展示的标识
config.headers['externalTerminalShow'] = isExternalTerminal ? 'external' : 'inside'
const token = Vue.ls.get(ACCESS_TOKEN) const token = Vue.ls.get(ACCESS_TOKEN)
if (token) { if (token) {
config.headers[ 'X-Access-Token' ] = token // 让每个请求携带自定义 token 请根据实际情况自行修改 config.headers[ 'X-Access-Token' ] = token // 让每个请求携带自定义 token 请根据实际情况自行修改
@@ -79,6 +79,7 @@ import { downloadFile } from '../../../../api/manage'
import { ACCESS_TOKEN } from '../../../../store/mutation-types' import { ACCESS_TOKEN } from '../../../../store/mutation-types'
import { Modal } from 'ant-design-vue' import { Modal } from 'ant-design-vue'
import store from '@/store' import store from '@/store'
import {isExternalTerminal} from '../../../../utils/util'
const FILE_TYPE_ALL = 'all' const FILE_TYPE_ALL = 'all'
const columns = [ const columns = [
@@ -144,7 +145,10 @@ export default {
computed: { computed: {
//token header //token header
tokenHeader() { tokenHeader() {
let head = {'X-Access-Token': Vue.ls.get(ACCESS_TOKEN)} let head = {
'X-Access-Token': Vue.ls.get(ACCESS_TOKEN),
'externalTerminalShow': isExternalTerminal ? 'external' : 'inside'
}
return head return head
}, },
importExcelUrl: function () { importExcelUrl: function () {
+5 -1
View File
@@ -202,6 +202,7 @@ import {passwordReg} from '@/utils/validate'
import {checkPhone, checkEmail, checkUserName} from '@/utils/validateOnly' import {checkPhone, checkEmail, checkUserName} from '@/utils/validateOnly'
import {getRSAPublicKey} from '@/api/login.js' import {getRSAPublicKey} from '@/api/login.js'
import {encrypt} from '@/utils/util' import {encrypt} from '@/utils/util'
import {isExternalTerminal} from '../../../utils/util'
export default { export default {
@@ -316,7 +317,10 @@ export default {
}, },
created() { created() {
const token = Vue.ls.get(ACCESS_TOKEN) const token = Vue.ls.get(ACCESS_TOKEN)
this.headers = {'X-Access-Token': token} this.headers = {
'X-Access-Token': token,
'externalTerminalShow': isExternalTerminal ? 'external' : 'inside'
}
// this.initTenantList() // this.initTenantList()
}, },