# Widget 用户认知

**URL:** https://meta.discourse.org/t/widgets-user-awareness/146275
**Category:** Development
**Created:** [2020年三月31日 14:02 UTC](https://meta.discourse.org/t/widgets-user-awareness/146275 "2020-03-31T14:02:51Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![zcuric](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zcuric/32/292837_2.png) [@zcuric](https://meta.discourse.org/u/zcuric)
#### Post date: [2020年三月31日 16:35 UTC](https://meta.discourse.org/t/widgets-user-awareness/146275/2 "2020-03-31T16:35:21Z")

</div>

您可以使用：

```plaintext
const user = api.getCurrentUser()

if(user) {
  return user.username;
}

```

更多信息请参见：

> [@Developing Discourse Themes & Theme Components](https://meta.discourse.org/t/developer-s-guide-to-discourse-themes/93648#heading--4-c-2):
>
> Discourse Themes and Theme Components can be used to customize the look, feel and functionality of Discourse’s frontend. This section of the developer guides aims to provide all the reference materials you need to develop simple themes for a single site, right up to complex open-source theme components. This introduction aims to provide a map of all the tools and APIs for theme development. If you prefer a step-by-step tutorial for theme development, jump straight to: Themes vs. Theme Compon…

---

_[View the full topic](https://meta.discourse.org/t/widgets-user-awareness/146275)._
