更新Pinia store中的token

This commit is contained in:
syruan 2025-12-17 19:35:50 +08:00
parent 6035372b02
commit 8f8b096baf
2 changed files with 7 additions and 6 deletions

View File

@ -22,9 +22,14 @@ const handleMessage = (event: MessageEvent) => {
console.log('B项目收到来自A项目的token')
if (token && typeof token === 'string') {
// tokenlocalStorageaxios使
// 1. tokenlocalStorageaxios使
localStorage.setItem('tokenNew', token)
console.log('Token已成功保存到localStorage后续请求将自动携带Authorization头')
// 2. Pinia storetoken
userStore.setToken(token)
console.log('✅ Token已成功保存到localStorage和Pinia store')
console.log('✅ 后续请求将自动携带Authorization头路由守卫也会放行')
// A
if (event.source && typeof event.source.postMessage === 'function') {

View File

@ -98,10 +98,6 @@
</div>
</div>
<div style="text-align: right">
<!-- <el-button type="primary" round icon="ChatDotRound">在线聊</el-button> -->
<el-button type="primary" class="primary-lease" round icon="ChatDotRound"
>在线聊</el-button
>
</div>
<div style="text-align: right">
<el-button