Compare commits
2 Commits
5cb1f3b24b
...
60c6f634ce
| Author | SHA1 | Date | |
|---|---|---|---|
| 60c6f634ce | |||
| d68ba1e987 |
@ -16,11 +16,28 @@ const isLoginPage = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 页面加载时刷新权限
|
// 页面加载时刷新权限
|
||||||
onMounted(() => {
|
onMounted(async () => {
|
||||||
if (userStore.token) {
|
if (userStore.token) {
|
||||||
|
// ★ 如果 access_token 可能已过期,先主动用 refresh_token 换新 token
|
||||||
|
// 避免后续 API 调用触发 401 → 刷新 → 重试的竞态导致权限空白
|
||||||
|
try {
|
||||||
|
const refreshTokenValue = localStorage.getItem('refresh_token')
|
||||||
|
if (refreshTokenValue) {
|
||||||
|
const res = await fetch('/api/v1/auth/refresh', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ refresh_token: refreshTokenValue })
|
||||||
|
})
|
||||||
|
if (res.ok) {
|
||||||
|
const data = await res.json()
|
||||||
|
if (data.access_token) {
|
||||||
|
userStore.setToken(data.access_token)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) { /* 静默,失败时走正常 401 刷新流程 */ }
|
||||||
userStore.refreshUserPermissions()
|
userStore.refreshUserPermissions()
|
||||||
}
|
}
|
||||||
// 当 Vue 根组件挂载完毕,确保 Dify 图标一定会被加载
|
|
||||||
if (typeof (window as any).initDifyChatbot === 'function') {
|
if (typeof (window as any).initDifyChatbot === 'function') {
|
||||||
(window as any).initDifyChatbot()
|
(window as any).initDifyChatbot()
|
||||||
}
|
}
|
||||||
@ -239,7 +256,7 @@ const handleLogout = () => {
|
|||||||
<footer v-if="!isLoginPage" class="app-footer">
|
<footer v-if="!isLoginPage" class="app-footer">
|
||||||
<span class="version-tag">
|
<span class="version-tag">
|
||||||
<el-icon style="vertical-align: middle; margin-right: 4px"><InfoFilled /></el-icon>
|
<el-icon style="vertical-align: middle; margin-right: 4px"><InfoFilled /></el-icon>
|
||||||
当前版本:V3.64
|
当前版本:V3.65
|
||||||
</span>
|
</span>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user