mantou132 / nesbox

Online multiplayer games platform
https://nesbox.xianqiao.wang/
MIT License
387 stars 33 forks source link

登录按钮 loading 状态 #240

Closed hehehai closed 2 years ago

hehehai commented 2 years ago

身份认证页面,点击登录或注册按钮,没有 loading 状态。

试着调了下,😓 加载按钮有点大,css 覆盖样式搞不懂覆盖规则 😵

state: State = {
    username: '',
    password: '',
    loading: true,
};

#onSubmit = async () => {
    if (this.state.loading) return;
    this.setState({ loading: true });
    try {
      if (!(await this.formRef.element!.valid())) return;
      const { username, password } = this.state;
      if (this.register) {
        await register({ username, password });
      } else {
        await login({ username, password });
      }
    } finally {
      this.setState({ loading: false });
    }
    gotoRedirectUri();
};
<dy-button data-cy="submit" @click=${this.#onSubmit}>
      ${loading ? html`<dy-loading></dy-loading>` : this.register ? i18n.get('register') : i18n.get('login')}
</dy-button>
image
mantou132 commented 2 years ago

<dy-button .icon=${icons.loading}></dy-button> 应该可以

mantou132 commented 2 years ago

PR 里面有几行代码似乎的多余的。

还有以前那个添加官网链接的 PR,需要解决下冲突,另外也有几个建议你看下。

hehehai commented 2 years ago

PR 里面有几行代码似乎的多余的。

还有以前那个添加官网链接的 PR,需要解决下冲突,另外也有几个建议你看下。

ok