导入 User 类而不是直接使用 User

将

var currentUser = Discourse.User.current();

更改为

var currentUser = api.getCurrentUser();