diff --git a/src/App.vue b/src/App.vue index e5b55fd6b62f6342dacdc4c20dfe450c2bdc0e60..0e0eb97601de5b23ba32a93607818b87b8b76ab3 100644 --- a/src/App.vue +++ b/src/App.vue @@ -18,7 +18,6 @@ const { locale } = useI18n(); const locales = computed(() => appStore.locale); const appStore = useAppStore(); const {downLoading} = storeToRefs(appStore); -const { changeParentToken } = appStore; // 新增路由状态标记 const isManualNavigation = ref(false); @@ -41,7 +40,9 @@ const handleMessage = (e: MessageEvent) => { }else if(e.data?.type === 'parentToken') { const token = e.data.parentToken; if(token){ - changeParentToken(token); + if(location.origin.includes('localhost')){ + localStorage.setItem('ECSESSION', token) + } }else{ ElMessage({ message: '未获取到token数据!', diff --git a/src/utils/downloadFun.ts b/src/utils/downloadFun.ts index f4b38379562caaa40e822194391a5cd0fb4ebe02..92e2e771c64455d9f89a9775ab2e9a6afc5a1e61 100644 --- a/src/utils/downloadFun.ts +++ b/src/utils/downloadFun.ts @@ -1,10 +1,7 @@ import { useAppStore, useAppStoreHook } from '@/store'; -import { storeToRefs } from 'pinia'; export function downloadFun(url: string) { - const appStore = useAppStore(); - const { parentToken } = storeToRefs(appStore); - const token = parentToken.value || localStorage.getItem('ECSESSION'); + const token = localStorage.getItem('ECSESSION'); if (!token) { ElMessage.error(`Token is not available yet`); return; diff --git a/src/utils/request.ts b/src/utils/request.ts index fcd5408a335ef44b9a216e2260f6f35bce4e6fa7..212bb101bcb0ee1b81c4caed65df38cedf58bcaa 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -22,15 +22,11 @@ const service = axios.create({ // 请求拦截器 service.interceptors.request.use( (config: InternalAxiosRequestConfig) => { - const appStore = useAppStore(); - const { parentToken } = storeToRefs(appStore); const accessToken = localStorage.getItem(TOKEN_KEY); if (accessToken) { config.headers.Authorization = accessToken; } - if (parentToken.value) { - config.headers['Authorization'] = `Bearer ${parentToken.value}`; - } + config.headers['Authorization'] = `Bearer ${localStorage.getItem('ECSESSION')}`; return config; }, (error: any) => {