|
|
|
@ -12,9 +12,9 @@
|
|
|
|
class="login-form"
|
|
|
|
class="login-form"
|
|
|
|
size="large"
|
|
|
|
size="large"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<el-form-item prop="account">
|
|
|
|
<el-form-item prop="username">
|
|
|
|
<el-input
|
|
|
|
<el-input
|
|
|
|
v-model="loginForm.account"
|
|
|
|
v-model="loginForm.username"
|
|
|
|
placeholder="请输入用户名"
|
|
|
|
placeholder="请输入用户名"
|
|
|
|
:prefix-icon="User"
|
|
|
|
:prefix-icon="User"
|
|
|
|
:disabled="loading"
|
|
|
|
:disabled="loading"
|
|
|
|
@ -44,6 +44,11 @@
|
|
|
|
{{ loading ? '登录中...' : '登录' }}
|
|
|
|
{{ loading ? '登录中...' : '登录' }}
|
|
|
|
</el-button>
|
|
|
|
</el-button>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
<el-form-item>
|
|
|
|
|
|
|
|
<div class="register-link">
|
|
|
|
|
|
|
|
没有账号?<router-link to="/register">立即注册</router-link>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
</el-form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
@ -65,12 +70,12 @@ const loading = ref(false)
|
|
|
|
const rememberPassword = ref(true)
|
|
|
|
const rememberPassword = ref(true)
|
|
|
|
|
|
|
|
|
|
|
|
const loginForm = reactive({
|
|
|
|
const loginForm = reactive({
|
|
|
|
account: '',
|
|
|
|
username: '',
|
|
|
|
password: ''
|
|
|
|
password: ''
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const loginRules: FormRules = {
|
|
|
|
const loginRules: FormRules = {
|
|
|
|
account: [
|
|
|
|
username: [
|
|
|
|
{required: true, message: '请输入用户名', trigger: 'blur'},
|
|
|
|
{required: true, message: '请输入用户名', trigger: 'blur'},
|
|
|
|
{min: 1, max: 50, message: '用户名长度不超过50字符', trigger: 'blur'}
|
|
|
|
{min: 1, max: 50, message: '用户名长度不超过50字符', trigger: 'blur'}
|
|
|
|
],
|
|
|
|
],
|
|
|
|
@ -84,8 +89,8 @@ onMounted(() => {
|
|
|
|
const savedCredentials = localStorage.getItem('login-credentials')
|
|
|
|
const savedCredentials = localStorage.getItem('login-credentials')
|
|
|
|
if (savedCredentials) {
|
|
|
|
if (savedCredentials) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const {account, password} = JSON.parse(atob(savedCredentials))
|
|
|
|
const {username, password} = JSON.parse(atob(savedCredentials))
|
|
|
|
loginForm.account = account || ''
|
|
|
|
loginForm.username = username || ''
|
|
|
|
loginForm.password = password || ''
|
|
|
|
loginForm.password = password || ''
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
console.error('Failed to parse saved credentials')
|
|
|
|
console.error('Failed to parse saved credentials')
|
|
|
|
@ -101,19 +106,16 @@ const handleLogin = async () => {
|
|
|
|
|
|
|
|
|
|
|
|
loading.value = true
|
|
|
|
loading.value = true
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// await userStore.login({
|
|
|
|
await userStore.login({
|
|
|
|
// account: loginForm.account,
|
|
|
|
username: loginForm.username,
|
|
|
|
// password: loginForm.password
|
|
|
|
password: loginForm.password
|
|
|
|
// })
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 临时设置 token
|
|
|
|
|
|
|
|
localStorage.setItem('Access-Token', 'eyJraWQiOiJmMGQ4YjkyZC0yZjIzLTQzNmUtOGIzMS1hZWQzOGEwZmY5MDYiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJhZG1pbnVzZXJkZXB0aWQiLCJhdWQiOiJvYXV0aDJzZXJ2ZXIiLCJuYmYiOjE3NTYwODM3MjUsImNsaWVudElkIjoibGxtYWlwIiwidXNlcl9uYW1lIjoiYWRtaW4iLCJzY29wZSI6WyJyZWFkIiwid3JpdGUiXSwiaXNzIjoiaHR0cDpcL1wvYXV0aC1zZXJ2ZXI6ODA4NiIsImV4cCI6MTc1NjA4NzMyNSwibG9jYWxlIjoiemgtY24iLCJpYXQiOjE3NTYwODM3MjUsInVzZXJkZXB0SWQiOiJhZG1pbnVzZXJkZXB0aWQifQ.IGB4FZ1uYErluF0q7Owutw7GGqxVGCknSQNcOlgo1tmU-lLF0YVQ3eONX-iNQo4C4Um-q7FVkk5UZtuz190HJRIE7RenaFzYa4UjAGrGfgN7ZjjlXTHGy2T2Z_tKzrQlsF4i56SegXhKZGfHXGmBDTc9i3bhu9Frs-pWCahpP2Ehg7tP9q4pnzePr0wqIkMhgdFsq2sLBSwYzWwXHVVexgbySLbWCJlI0c-IdH0dYBHowMT_tVfUqqpg5IQysUokLspRjM_mxlIahMNRkiwvx8X4LjASGJMzWj0VsQJf-IBJKi13O-_f9gaR8Sq4eAar6i-e7X9BFoV9lRXNXp_2DA')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 记住密码
|
|
|
|
// 记住密码
|
|
|
|
if (rememberPassword.value) {
|
|
|
|
if (rememberPassword.value) {
|
|
|
|
localStorage.setItem(
|
|
|
|
localStorage.setItem(
|
|
|
|
'login-credentials',
|
|
|
|
'login-credentials',
|
|
|
|
btoa(JSON.stringify({account: loginForm.account, password: loginForm.password}))
|
|
|
|
btoa(JSON.stringify({username: loginForm.username, password: loginForm.password}))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
localStorage.removeItem('login-credentials')
|
|
|
|
localStorage.removeItem('login-credentials')
|
|
|
|
@ -136,7 +138,7 @@ const handleLogin = async () => {
|
|
|
|
.login-container {
|
|
|
|
.login-container {
|
|
|
|
width: 100vw;
|
|
|
|
width: 100vw;
|
|
|
|
height: 100vh;
|
|
|
|
height: 100vh;
|
|
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
|
|
background: linear-gradient(135deg, #1e3a5f 0%, #0d2137 100%);
|
|
|
|
display: flex;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
justify-content: center;
|
|
|
|
@ -166,7 +168,7 @@ const handleLogin = async () => {
|
|
|
|
color: #333;
|
|
|
|
color: #333;
|
|
|
|
margin: 0;
|
|
|
|
margin: 0;
|
|
|
|
padding-bottom: 10px;
|
|
|
|
padding-bottom: 10px;
|
|
|
|
border-bottom: 3px solid #667eea;
|
|
|
|
border-bottom: 3px solid #1e3a5f;
|
|
|
|
display: inline-block;
|
|
|
|
display: inline-block;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -182,4 +184,20 @@ const handleLogin = async () => {
|
|
|
|
font-size: 16px;
|
|
|
|
font-size: 16px;
|
|
|
|
border-radius: 8px;
|
|
|
|
border-radius: 8px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.register-link {
|
|
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
|
|
color: #666;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
a {
|
|
|
|
|
|
|
|
color: #1e3a5f;
|
|
|
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
|
|
|
text-decoration: underline;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</style>
|
|
|
|
|