index.vue 2.43 KB
<script setup lang="ts">
  import { setToken } from '@/utils/auth';

  import PhoneContent from '@/views/login/components/phone-content.vue';
  import { Message } from '@arco-design/web-vue';
  import { useRouter } from 'vue-router';

  type LoginData = { access_token: string; refresh_token: string; nick_name: string };

  const router = useRouter();

  const onLogin = ({ access_token, refresh_token, nick_name }: LoginData) => {
    setToken(access_token, refresh_token);
    Message.success(`欢迎回来,管理员:${nick_name}`);
    const { path } = router.currentRoute.value.query;
    // router.replace((path as string) || '/dashboard');
    router.replace((path as string) || '/demos');
  };
</script>

<template>
  <div class="container">
    <div class="banner">
      <div class="banner-inner"></div>
    </div>
    <div class="content">
      <div class="content-inner">
        <div class="login-form-wrapper">
          <div class="login-form-title">泡泡留声</div>
          <div class="login-form-sub-title">个人管理后台</div>
          <a-card :bordered="true" :hoverable="true">
            <a-tabs size="small" :justify-="true" :animation="true" lazy-load>
              <a-tab-pane key="phone" title="手机号">
                <phone-content @login="onLogin" />
              </a-tab-pane>
            </a-tabs>
          </a-card>
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="less" scoped>
  .container {
    display: flex;
    height: 100vh;

    .banner {
      width: 550px;
    }

    .content {
      position: relative;
      display: flex;
      flex: 1;
      align-items: center;
      justify-content: center;
      padding-bottom: 40px;

      .login-form-wrapper {
        width: 380px;
      }

      .login-form-title {
        color: var(--color-text-1);
        font-weight: 500;
        font-size: 30px;
        line-height: 46px;
        text-align: center;
      }

      .login-form-sub-title {
        color: var(--color-text-3);
        font-size: 16px;
        line-height: 24px;
        text-align: center;
        margin-bottom: 16px;
      }
    }

    .footer {
      position: absolute;
      right: 0;
      bottom: 0;
      width: 100%;
    }
  }

  .banner {
    display: flex;
    align-items: center;
    justify-content: center;

    &-inner {
      flex: 1;
      height: 100%;
      background-image: url('assets/image/user-login-bg.jpg');
      background-size: cover;
    }
  }
</style>