|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <div class="login-container">
|
|
|
3
|
+ <div class="login-card">
|
|
|
4
|
+ <img src="@/assets/logo.png" alt="logo" class="login-logo"/>
|
|
|
5
|
+ <el-form ref="f" :model="form" label-position="top" class="login-form" :rules="rules">
|
|
|
6
|
+ <el-form-item :label="T('Username')" prop="username">
|
|
|
7
|
+ <el-input v-model="form.username" class="login-input"></el-input>
|
|
|
8
|
+ </el-form-item>
|
|
|
9
|
+
|
|
|
10
|
+ <el-form-item :label="T('Password')" prop="password">
|
|
|
11
|
+ <el-input v-model="form.password" type="password" show-password
|
|
|
12
|
+ class="login-input"></el-input>
|
|
|
13
|
+ </el-form-item>
|
|
|
14
|
+ <el-form-item :label="T('ConfirmPassword')" prop="confirm_password">
|
|
|
15
|
+ <el-input v-model="form.confirm_password" type="password" @keyup.enter.native="submit" show-password
|
|
|
16
|
+ class="login-input"></el-input>
|
|
|
17
|
+ </el-form-item>
|
|
|
18
|
+ <el-form-item label="">
|
|
|
19
|
+ <el-button @click="submit" class="login-button" type="success">{{ T('Submit') }}</el-button>
|
|
|
20
|
+ <el-button @click="toLogin" class="login-button">{{ T('ToLogin') }}</el-button>
|
|
|
21
|
+ </el-form-item>
|
|
|
22
|
+ </el-form>
|
|
|
23
|
+ </div>
|
|
|
24
|
+ </div>
|
|
|
25
|
+</template>
|
|
|
26
|
+
|
|
|
27
|
+<script setup>
|
|
|
28
|
+ import { reactive, ref } from 'vue'
|
|
|
29
|
+ import { ElMessage } from 'element-plus'
|
|
|
30
|
+ import { T } from '@/utils/i18n'
|
|
|
31
|
+ import { useRoute, useRouter } from 'vue-router'
|
|
|
32
|
+ import { register } from '@/api/user'
|
|
|
33
|
+ import { useUserStore } from '@/store/user'
|
|
|
34
|
+
|
|
|
35
|
+ const router = useRouter()
|
|
|
36
|
+ const userStore = useUserStore()
|
|
|
37
|
+ const form = reactive({
|
|
|
38
|
+ username: '',
|
|
|
39
|
+ password: '',
|
|
|
40
|
+ confirm_password: '',
|
|
|
41
|
+ })
|
|
|
42
|
+ const rules = {
|
|
|
43
|
+ username: [
|
|
|
44
|
+ { required: true, message: T('ParamRequired', { param: T('Username') }), trigger: 'blur' },
|
|
|
45
|
+ ],
|
|
|
46
|
+ password: [
|
|
|
47
|
+ { required: true, message: T('ParamRequired', { param: T('Password') }), trigger: 'blur' },
|
|
|
48
|
+ ],
|
|
|
49
|
+ confirm_password: [
|
|
|
50
|
+ { required: true, message: T('ParamRequired', { param: T('ConfirmPassword') }), trigger: 'blur' },
|
|
|
51
|
+ {
|
|
|
52
|
+ validator: (rule, value, callback) => {
|
|
|
53
|
+ if (value !== form.password) {
|
|
|
54
|
+ callback(new Error(T('PasswordNotMatchConfirmPassword')))
|
|
|
55
|
+ } else {
|
|
|
56
|
+ callback()
|
|
|
57
|
+ }
|
|
|
58
|
+ }, trigger: 'blur',
|
|
|
59
|
+ },
|
|
|
60
|
+ ],
|
|
|
61
|
+ }
|
|
|
62
|
+ const f = ref(null)
|
|
|
63
|
+ const submit = async () => {
|
|
|
64
|
+ const v = await f.value.validate().catch(_ => false)
|
|
|
65
|
+ if (!v) {
|
|
|
66
|
+ return
|
|
|
67
|
+ }
|
|
|
68
|
+ const res = await register(form).catch(_ => false)
|
|
|
69
|
+ if (!res) {
|
|
|
70
|
+ return
|
|
|
71
|
+ }
|
|
|
72
|
+ userStore.saveUserData(res.data)
|
|
|
73
|
+ ElMessage.success('Submit')
|
|
|
74
|
+ router.push('/')
|
|
|
75
|
+ }
|
|
|
76
|
+ const toLogin = () => {
|
|
|
77
|
+ router.push('/login')
|
|
|
78
|
+
|
|
|
79
|
+ }
|
|
|
80
|
+</script>
|
|
|
81
|
+
|
|
|
82
|
+<style scoped lang="scss">
|
|
|
83
|
+.login-container {
|
|
|
84
|
+ display: flex;
|
|
|
85
|
+ justify-content: center;
|
|
|
86
|
+ align-items: center;
|
|
|
87
|
+ height: 100vh;
|
|
|
88
|
+ background-color: #2d3a4b;
|
|
|
89
|
+ padding: 20px;
|
|
|
90
|
+ box-sizing: border-box;
|
|
|
91
|
+}
|
|
|
92
|
+
|
|
|
93
|
+.login-card {
|
|
|
94
|
+ width: 360px;
|
|
|
95
|
+ background-color: #283342;
|
|
|
96
|
+ padding: 40px;
|
|
|
97
|
+ border-radius: 8px;
|
|
|
98
|
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
|
|
99
|
+ text-align: center;
|
|
|
100
|
+}
|
|
|
101
|
+
|
|
|
102
|
+h1 {
|
|
|
103
|
+ margin-bottom: 20px;
|
|
|
104
|
+ font-size: 24px;
|
|
|
105
|
+ font-weight: bold;
|
|
|
106
|
+}
|
|
|
107
|
+
|
|
|
108
|
+.login-form {
|
|
|
109
|
+ margin-bottom: 20px;
|
|
|
110
|
+}
|
|
|
111
|
+
|
|
|
112
|
+.login-input {
|
|
|
113
|
+ width: 100%;
|
|
|
114
|
+}
|
|
|
115
|
+
|
|
|
116
|
+.login-button {
|
|
|
117
|
+ width: 100%;
|
|
|
118
|
+ height: 40px;
|
|
|
119
|
+ margin-bottom: 20px;
|
|
|
120
|
+ margin-top: 20px;
|
|
|
121
|
+ margin-left: 0;
|
|
|
122
|
+}
|
|
|
123
|
+
|
|
|
124
|
+.login-logo {
|
|
|
125
|
+ width: 80px;
|
|
|
126
|
+ height: 80px;
|
|
|
127
|
+ margin: 0 auto 20px;
|
|
|
128
|
+ display: block;
|
|
|
129
|
+}
|
|
|
130
|
+
|
|
|
131
|
+.el-form-item {
|
|
|
132
|
+ ::v-deep(.el-form-item__label) {
|
|
|
133
|
+ color: #fff;
|
|
|
134
|
+ }
|
|
|
135
|
+
|
|
|
136
|
+ .el-input {
|
|
|
137
|
+ ::v-deep(.el-input__wrapper) {
|
|
|
138
|
+ border: 1px solid rgba(255, 255, 255, 0.1);
|
|
|
139
|
+ background: transparent;
|
|
|
140
|
+ }
|
|
|
141
|
+
|
|
|
142
|
+ ::v-deep(input) {
|
|
|
143
|
+ color: #fff;
|
|
|
144
|
+ }
|
|
|
145
|
+ }
|
|
|
146
|
+}
|
|
|
147
|
+</style>
|