fix 修复 无法获取token问题 将 globalHeaders 改为函数

This commit is contained in:
疯狂的狮子Li 2023-08-09 12:59:18 +08:00
parent 53ac5fb43c
commit 50891e99ac
6 changed files with 11 additions and 9 deletions

View File

@ -50,7 +50,7 @@ const props = defineProps({
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const upload = reactive<UploadOption>({ const upload = reactive<UploadOption>({
headers: globalHeaders, headers: globalHeaders(),
url: import.meta.env.VITE_APP_BASE_API + '/resource/oss/upload' url: import.meta.env.VITE_APP_BASE_API + '/resource/oss/upload'
}) })
const myQuillEditor = ref(); const myQuillEditor = ref();

View File

@ -66,7 +66,7 @@ const uploadList = ref<any[]>([]);
const baseUrl = import.meta.env.VITE_APP_BASE_API; const baseUrl = import.meta.env.VITE_APP_BASE_API;
const uploadFileUrl = ref(baseUrl + "/resource/oss/upload"); // const uploadFileUrl = ref(baseUrl + "/resource/oss/upload"); //
const headers = ref(globalHeaders); const headers = ref(globalHeaders());
const fileList = ref<any[]>([]); const fileList = ref<any[]>([]);
const showTip = computed( const showTip = computed(

View File

@ -70,7 +70,7 @@ const dialogVisible = ref(false);
const baseUrl = import.meta.env.VITE_APP_BASE_API; const baseUrl = import.meta.env.VITE_APP_BASE_API;
const uploadImgUrl = ref(baseUrl + "/resource/oss/upload"); // const uploadImgUrl = ref(baseUrl + "/resource/oss/upload"); //
const headers = ref(globalHeaders); const headers = ref(globalHeaders());
const fileList = ref<any[]>([]); const fileList = ref<any[]>([]);
const showTip = computed( const showTip = computed(

View File

@ -16,7 +16,7 @@ export default {
method: 'get', method: 'get',
url: url, url: url,
responseType: 'blob', responseType: 'blob',
headers: globalHeaders, headers: globalHeaders(),
}); });
const isBlob = blobValidate(res.data); const isBlob = blobValidate(res.data);
if (isBlob) { if (isBlob) {
@ -40,7 +40,7 @@ export default {
method: 'get', method: 'get',
url: url, url: url,
responseType: 'blob', responseType: 'blob',
headers: globalHeaders, headers: globalHeaders(),
}); });
const isBlob = blobValidate(res.data); const isBlob = blobValidate(res.data);
if (isBlob) { if (isBlob) {

View File

@ -14,9 +14,11 @@ import { encrypt } from '@/utils/jsencrypt';
let downloadLoadingInstance: LoadingInstance; let downloadLoadingInstance: LoadingInstance;
// 是否显示重新登录 // 是否显示重新登录
export const isRelogin = { show: false }; export const isRelogin = { show: false };
export const globalHeaders = { export const globalHeaders = () => {
return {
Authorization: "Bearer " + getToken(), Authorization: "Bearer " + getToken(),
clientid: import.meta.env.VITE_APP_CLIENT_ID clientid: import.meta.env.VITE_APP_CLIENT_ID
}
} }
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'; axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8';

View File

@ -335,7 +335,7 @@ const upload = reactive<ImportOption>({
// //
updateSupport: 0, updateSupport: 0,
// //
headers: globalHeaders, headers: globalHeaders(),
// //
url: import.meta.env.VITE_APP_BASE_API + "/system/user/importData" url: import.meta.env.VITE_APP_BASE_API + "/system/user/importData"
}) })