123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <template>
- <div class="login-container">
- <a-row>
- <a-col :xs="0" :md="0" :sm="12" :lg="14" :xl="16"></a-col>
- <a-col :xs="24" :sm="24" :md="12" :lg="10" :xl="6">
- <div class="login-container-form">
- <div class="login-container-hello">hello!</div>
- <div class="login-container-title">欢迎来到 {{ title }}</div>
- <a-form :model="form" @submit="handleSubmit" @submit.prevent>
- <a-form-item>
- <a-input v-model:value="form.username" placeholder="Username">
- <template v-slot:prefix>
- <UserOutlined style="color: rgba(0, 0, 0, 0.25)" />
- </template>
- </a-input>
- </a-form-item>
- <a-form-item>
- <a-input
- v-model:value="form.password"
- type="password"
- placeholder="Password"
- >
- <template v-slot:prefix>
- <LockOutlined style="color: rgba(0, 0, 0, 0.25)" />
- </template>
- </a-input>
- </a-form-item>
- <a-form-item>
- <a-button
- type="primary"
- html-type="submit"
- :disabled="form.username === '' || form.password === ''"
- >
- 登录
- </a-button>
- </a-form-item>
- </a-form>
- </div>
- </a-col>
- </a-row>
- <!-- <div class="login-container-tips">
- 基于vue{{ dependencies['vue'] }}
- + ant-design-vue
- {{ dependencies['ant-design-vue'] }}开发
- </div> -->
- </div>
- </template>
- <script>
- import { dependencies, devDependencies } from '*/package.json'
- import { mapActions, mapGetters } from 'vuex'
- import { useRouter } from 'vue-router'
- import { UserOutlined, LockOutlined } from '@ant-design/icons-vue'
- export default {
- name: 'Login',
- components: {
- UserOutlined,
- LockOutlined,
- },
- data() {
- return {
- form: {
- username: '',
- password: '',
- },
- redirect: undefined,
- dependencies: dependencies,
- devDependencies: devDependencies,
- }
- },
- computed: {
- ...mapGetters({
- logo: 'settings/logo',
- title: 'settings/title',
- }),
- },
- watch: {
- $route: {
- handler(route) {
- this.redirect = (route.query && route.query.redirect) || '/'
- },
- immediate: true,
- },
- },
- mounted() {
- this.form.username = 'admin'
- this.form.password = 'admin123'
- const router = useRouter()
- console.log(router)
- if (router.currentRoute.value.query.userName === 'admin') {
- this.handleSubmit()
- }
- // setTimeout(() => {
- // this.handleSubmit()
- // }, 3000)
- },
- methods: {
- ...mapActions({
- login: 'user/login',
- }),
- handleRoute() {
- return this.redirect === '/404' || this.redirect === '/403'
- ? '/'
- : this.redirect
- },
- async handleSubmit() {
- await this.login(this.form)
- await this.$router.push(this.handleRoute())
- },
- },
- }
- </script>
- <style lang="less">
- .login-container {
- width: 100%;
- height: 100vh;
- background: url('~@/assets/login_images/login_background.png');
- background-size: cover;
- &-form {
- width: calc(100% - 40px);
- height: 380px;
- padding: 4vh;
- margin-top: calc((100vh - 380px) / 2);
- margin-right: 20px;
- margin-left: 20px;
- background: url('~@/assets/login_images/login_form.png');
- background-size: 100% 100%;
- border-radius: 10px;
- box-shadow: 0 2px 8px 0 rgba(7, 17, 27, 0.06);
- }
- &-hello {
- font-size: 32px;
- color: #fff;
- }
- &-title {
- margin-bottom: 30px;
- font-size: 20px;
- color: #fff;
- }
- &-tips {
- position: fixed;
- bottom: @vab-margin;
- width: 100%;
- height: 40px;
- color: rgba(255, 255, 255, 0.856);
- text-align: center;
- }
- .ant-col {
- width: 100%;
- padding: 0 10px 0 10px;
- }
- .ant-input {
- height: 35px;
- }
- .ant-btn {
- width: 100%;
- height: 45px;
- border-radius: 99px;
- }
- }
- </style>
|