Skip to content

部分组件vhecklogin的时候顺序不当 #118

Description

@gushishang

页面组件挂载 → onActivated 触发 → checkLogin() 执行
但 checkLogin() 读的是 Pinia store 里的 userInfo
Pinia store 从 localStorage 恢复数据需要时间
如果 checkLogin() 跑在 Pinia store 恢复数据之前,那 userInfo.Nickname 就是 null
于是 showDialog 被调用 → overlay 出现 → 挡住了一切

让 checkLogin 别在数据没准备好时就弹框。

// 修改前
onActivated(checkLogin)

// 修改后
onActivated(async () => {
await nextTick() // 等 Vue 完成 DOM 更新和 store 初始化
if (userStore.userInfo?.Nickname) return // 数据有了,不用检查
checkLogin()
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions