zmc
2023-08-30 b7b35d8bd8f0ff7fe4e1aa6c69a877551bed81a3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
 
<template>
  <div class="login-container">
    <el-card class="login-card">
    <h2>登陆</h2>
    <div class="box"><img src="../../assets/loginBg.png" class="imag"> </div>
    <el-form label-position="top">
      <el-form-item label="用户名">
        <el-input
          class="login-input"
          v-model="username"
          placeholder="请输入账号"
          size="large"
        ></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input
          class="login-input"
          v-model="password"
          placeholder="请输入密码"
          type="password"
          size="large"
        ></el-input>
      </el-form-item>
 
      <el-button color="#3d86d5" class="login-btn" @click="login" size="large">登录</el-button>
    </el-form>
    </el-card>
  </div>
</template>
 
<script lang="ts">
export default {
  data() {
    return {
      username: '',
      password: '',
    };
  },
  methods: {
    login() {
      // 登录逻辑
      if (this.username === 'admin' && this.password === 'admin123') {
         ElMessage.success('登录成功');
          // 登录成功,跳转到对应页面
          this.$router.push('/ndata') // 假设登录成功后跳转到 '/dashboard' 页面
        } else {
          // console.log('Login Failed!')
          ElMessage.error('账号或密码错误');
        }
    }
  }
};
</script>
 
<style scoped>
.login-container {
  background-image: url('../../assets/loginPageBg.png');
                      /*用于为一个元素设置一个或者多个背景图像。 */
  background-size: cover;         /* 将背景图像等比缩放到完全覆盖容器,背景图像有可能超出容器。*/
  background-position: center;  /* 为每一个背景图片设置初始位置。这个位置是相对于由 background-origin 定义的位置图层的 键字 center,用来居中背景图片。*/
 
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;  /*center:伸缩元素向每行中点排列 */
  align-items: center;   /*素在交叉轴居中。如果元素在交叉轴上的高度高于其容器,那么在两个方向上溢出距离相同 */
 
  position: relative;
}
.login-card {
  background-color: white;
  margin: 0 auto;
  padding: 20px;
  /* border-radius: 12px; */
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  border: 0;
 
  position: absolute;
  right: 10%;
  width: 20%;
  height: 50%;
 
}
.el-form-item {
  margin-bottom: 40px;
}
.box {
  width: 120px;
  height: 120px;
 
  position: absolute;
  top: 10px;
  right:10px;
}
.imag {
  max-width: 100%;
  max-height: 100%;
}
.el-card h2 {
  text-align: center;
  padding: 20px;
  margin-bottom: 20px;
}
 
 
.login-btn {
 
  position: absolute;
  width: calc(100% - 80px);
  font-size: 1.1em;
  letter-spacing: 0.3em;
  text-align: center;
  box-sizing: border-box;
  bottom: 80px;
 
}
 
 
</style>