2023-09-15 09:40:35 +00:00
|
|
|
<template>
|
2023-10-12 08:36:16 +00:00
|
|
|
<login-layout v-loading="loading">
|
2023-12-14 08:24:10 +00:00
|
|
|
<LoginContainer subTitle="欢迎使用 MaxKB 智能知识库">
|
2024-07-11 06:44:18 +00:00
|
|
|
<h2 class="mb-24">{{ loginMode || '普通登录' }}</h2>
|
2023-12-14 08:24:10 +00:00
|
|
|
<el-form
|
|
|
|
|
class="login-form"
|
|
|
|
|
:rules="rules"
|
|
|
|
|
:model="loginForm"
|
|
|
|
|
ref="loginFormRef"
|
|
|
|
|
@keyup.enter="login"
|
|
|
|
|
>
|
2024-02-23 03:37:37 +00:00
|
|
|
<div class="mb-24">
|
|
|
|
|
<el-form-item prop="username">
|
|
|
|
|
<el-input
|
|
|
|
|
size="large"
|
|
|
|
|
class="input-item"
|
|
|
|
|
v-model="loginForm.username"
|
|
|
|
|
placeholder="请输入用户名"
|
|
|
|
|
>
|
|
|
|
|
</el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mb-24">
|
|
|
|
|
<el-form-item prop="password">
|
|
|
|
|
<el-input
|
|
|
|
|
type="password"
|
|
|
|
|
size="large"
|
|
|
|
|
class="input-item"
|
|
|
|
|
v-model="loginForm.password"
|
|
|
|
|
placeholder="请输入密码"
|
|
|
|
|
show-password
|
|
|
|
|
>
|
|
|
|
|
</el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</div>
|
2023-10-12 08:36:16 +00:00
|
|
|
</el-form>
|
2024-02-23 03:37:37 +00:00
|
|
|
<el-button size="large" type="primary" class="w-full" @click="login">登录</el-button>
|
2023-12-12 03:32:45 +00:00
|
|
|
<div class="operate-container flex-between mt-12">
|
2024-03-21 06:19:01 +00:00
|
|
|
<!-- <el-button class="register" @click="router.push('/register')" link type="primary">
|
2023-10-12 08:36:16 +00:00
|
|
|
注册
|
2024-03-21 06:19:01 +00:00
|
|
|
</el-button> -->
|
2023-10-12 08:36:16 +00:00
|
|
|
<el-button
|
|
|
|
|
class="forgot-password"
|
|
|
|
|
@click="router.push('/forgot_password')"
|
|
|
|
|
link
|
|
|
|
|
type="primary"
|
|
|
|
|
>
|
2024-02-23 03:37:37 +00:00
|
|
|
忘记密码?
|
2023-10-12 08:36:16 +00:00
|
|
|
</el-button>
|
|
|
|
|
</div>
|
2024-07-11 06:44:18 +00:00
|
|
|
|
|
|
|
|
<!-- <div class="login-gradient-divider lighter mt-24">
|
|
|
|
|
<span>更多登录方式</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="text-center mt-16">
|
|
|
|
|
<el-button
|
|
|
|
|
v-if="loginMode !== 'LDAP'"
|
|
|
|
|
circle
|
|
|
|
|
class="login-button-circle color-secondary"
|
|
|
|
|
@click="changeMode('LDAP')"
|
|
|
|
|
>LDAP</el-button
|
|
|
|
|
>
|
|
|
|
|
<el-button
|
|
|
|
|
v-if="loginMode !== ''"
|
|
|
|
|
circle
|
|
|
|
|
class="login-button-circle color-secondary"
|
|
|
|
|
style="font-size: 24px"
|
|
|
|
|
icon="UserFilled"
|
|
|
|
|
@click="changeMode('')"
|
|
|
|
|
/>
|
|
|
|
|
</div> -->
|
2023-10-12 08:36:16 +00:00
|
|
|
</LoginContainer>
|
|
|
|
|
</login-layout>
|
2023-09-15 09:40:35 +00:00
|
|
|
</template>
|
|
|
|
|
<script setup lang="ts">
|
2023-10-12 08:36:16 +00:00
|
|
|
import { ref } from 'vue'
|
2023-10-20 03:26:14 +00:00
|
|
|
import type { LoginRequest } from '@/api/type/user'
|
2023-10-12 08:36:16 +00:00
|
|
|
import { useRouter } from 'vue-router'
|
2023-09-15 09:40:35 +00:00
|
|
|
import type { FormInstance, FormRules } from 'element-plus'
|
2023-10-19 10:18:45 +00:00
|
|
|
import useStore from '@/stores'
|
2023-09-15 09:40:35 +00:00
|
|
|
|
2023-10-12 08:36:16 +00:00
|
|
|
const loading = ref<boolean>(false)
|
2023-10-19 10:18:45 +00:00
|
|
|
const { user } = useStore()
|
2023-09-15 09:40:35 +00:00
|
|
|
const router = useRouter()
|
|
|
|
|
const loginForm = ref<LoginRequest>({
|
2023-10-12 08:36:16 +00:00
|
|
|
username: '',
|
|
|
|
|
password: ''
|
|
|
|
|
})
|
2023-09-15 09:40:35 +00:00
|
|
|
|
|
|
|
|
const rules = ref<FormRules<LoginRequest>>({
|
2023-10-12 08:36:16 +00:00
|
|
|
username: [
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: '请输入用户名',
|
|
|
|
|
trigger: 'blur'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
password: [
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: '请输入密码',
|
|
|
|
|
trigger: 'blur'
|
2024-03-21 06:19:01 +00:00
|
|
|
}
|
2023-10-12 08:36:16 +00:00
|
|
|
]
|
2023-09-15 09:40:35 +00:00
|
|
|
})
|
|
|
|
|
const loginFormRef = ref<FormInstance>()
|
|
|
|
|
|
2024-07-11 06:44:18 +00:00
|
|
|
const loginMode = ref('')
|
|
|
|
|
|
|
|
|
|
function changeMode(val: string) {
|
|
|
|
|
loginMode.value = val || ''
|
|
|
|
|
loginForm.value = {
|
|
|
|
|
username: '',
|
|
|
|
|
password: ''
|
|
|
|
|
}
|
|
|
|
|
loginFormRef.value?.clearValidate()
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-15 09:40:35 +00:00
|
|
|
const login = () => {
|
2023-10-12 08:36:16 +00:00
|
|
|
loginFormRef.value?.validate().then(() => {
|
|
|
|
|
loading.value = true
|
2023-10-19 10:18:45 +00:00
|
|
|
user
|
2023-10-12 08:36:16 +00:00
|
|
|
.login(loginForm.value.username, loginForm.value.password)
|
|
|
|
|
.then(() => {
|
|
|
|
|
router.push({ name: 'home' })
|
|
|
|
|
})
|
|
|
|
|
.finally(() => (loading.value = false))
|
|
|
|
|
})
|
2023-09-15 09:40:35 +00:00
|
|
|
}
|
|
|
|
|
</script>
|
2024-07-11 06:44:18 +00:00
|
|
|
<style lang="scss" scope>
|
|
|
|
|
.login-gradient-divider {
|
|
|
|
|
position: relative;
|
|
|
|
|
text-align: center;
|
|
|
|
|
color: var(--el-color-info);
|
|
|
|
|
|
|
|
|
|
::before {
|
|
|
|
|
content: '';
|
|
|
|
|
width: 25%;
|
|
|
|
|
height: 1px;
|
|
|
|
|
background: linear-gradient(90deg, rgba(222, 224, 227, 0) 0%, #dee0e3 100%);
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: 16px;
|
|
|
|
|
top: 50%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::after {
|
|
|
|
|
content: '';
|
|
|
|
|
width: 25%;
|
|
|
|
|
height: 1px;
|
|
|
|
|
background: linear-gradient(90deg, #dee0e3 0%, rgba(222, 224, 227, 0) 100%);
|
|
|
|
|
position: absolute;
|
|
|
|
|
right: 16px;
|
|
|
|
|
top: 50%;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.login-button-circle {
|
|
|
|
|
padding: 25px !important;
|
|
|
|
|
}
|
|
|
|
|
</style>
|