|
@@ -35,23 +35,6 @@
|
|
|
show-password
|
|
show-password
|
|
|
/>
|
|
/>
|
|
|
</ElFormItem>
|
|
</ElFormItem>
|
|
|
- <ElFormItem prop="code">
|
|
|
|
|
- <ElInput
|
|
|
|
|
- class="custom-height"
|
|
|
|
|
- :placeholder="$t('login.placeholder.code')"
|
|
|
|
|
- v-model.trim="formData.code"
|
|
|
|
|
- type="text"
|
|
|
|
|
- autocomplete="off"
|
|
|
|
|
- >
|
|
|
|
|
- <template #append>
|
|
|
|
|
- <img
|
|
|
|
|
- :src="captcha"
|
|
|
|
|
- style="height: 36px; cursor: pointer"
|
|
|
|
|
- @click="refreshCaptcha"
|
|
|
|
|
- />
|
|
|
|
|
- </template>
|
|
|
|
|
- </ElInput>
|
|
|
|
|
- </ElFormItem>
|
|
|
|
|
|
|
|
|
|
<div class="flex-cb mt-2 text-sm">
|
|
<div class="flex-cb mt-2 text-sm">
|
|
|
<ElCheckbox v-model="formData.rememberPassword">{{
|
|
<ElCheckbox v-model="formData.rememberPassword">{{
|
|
@@ -92,7 +75,7 @@
|
|
|
import { useUserStore } from '@/store/modules/user'
|
|
import { useUserStore } from '@/store/modules/user'
|
|
|
import { useI18n } from 'vue-i18n'
|
|
import { useI18n } from 'vue-i18n'
|
|
|
import { HttpError } from '@/utils/http/error'
|
|
import { HttpError } from '@/utils/http/error'
|
|
|
- import { fetchCaptcha, fetchLogin, fetchGetUserInfo } from '@/api/auth'
|
|
|
|
|
|
|
+ import { fetchLogin, fetchGetUserInfo } from '@/api/auth'
|
|
|
import { ElNotification, type FormInstance, type FormRules } from 'element-plus'
|
|
import { ElNotification, type FormInstance, type FormRules } from 'element-plus'
|
|
|
|
|
|
|
|
defineOptions({ name: 'Login' })
|
|
defineOptions({ name: 'Login' })
|
|
@@ -108,33 +91,22 @@
|
|
|
const userStore = useUserStore()
|
|
const userStore = useUserStore()
|
|
|
const router = useRouter()
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
- const captcha = ref(
|
|
|
|
|
- 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
const systemName = AppConfig.systemInfo.name
|
|
const systemName = AppConfig.systemInfo.name
|
|
|
const formRef = ref<FormInstance>()
|
|
const formRef = ref<FormInstance>()
|
|
|
|
|
|
|
|
const formData = reactive({
|
|
const formData = reactive({
|
|
|
username: '',
|
|
username: '',
|
|
|
password: '',
|
|
password: '',
|
|
|
- code: '',
|
|
|
|
|
- uuid: '',
|
|
|
|
|
rememberPassword: true
|
|
rememberPassword: true
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
const rules = computed<FormRules>(() => ({
|
|
const rules = computed<FormRules>(() => ({
|
|
|
username: [{ required: true, message: t('login.placeholder.username'), trigger: 'blur' }],
|
|
username: [{ required: true, message: t('login.placeholder.username'), trigger: 'blur' }],
|
|
|
- password: [{ required: true, message: t('login.placeholder.password'), trigger: 'blur' }],
|
|
|
|
|
- code: [{ required: true, message: t('login.placeholder.code'), trigger: 'blur' }]
|
|
|
|
|
|
|
+ password: [{ required: true, message: t('login.placeholder.password'), trigger: 'blur' }]
|
|
|
}))
|
|
}))
|
|
|
|
|
|
|
|
const loading = ref(false)
|
|
const loading = ref(false)
|
|
|
|
|
|
|
|
- onMounted(() => {
|
|
|
|
|
- refreshCaptcha()
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
// 登录
|
|
// 登录
|
|
|
const handleSubmit = async () => {
|
|
const handleSubmit = async () => {
|
|
|
if (!formRef.value) return
|
|
if (!formRef.value) return
|
|
@@ -149,9 +121,7 @@
|
|
|
// 登录请求
|
|
// 登录请求
|
|
|
const { access_token, refresh_token } = await fetchLogin({
|
|
const { access_token, refresh_token } = await fetchLogin({
|
|
|
username: formData.username,
|
|
username: formData.username,
|
|
|
- password: formData.password,
|
|
|
|
|
- code: formData.code,
|
|
|
|
|
- uuid: formData.uuid
|
|
|
|
|
|
|
+ password: formData.password
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// 验证token
|
|
// 验证token
|
|
@@ -176,22 +146,10 @@
|
|
|
console.error('[Login] Unexpected error:', error)
|
|
console.error('[Login] Unexpected error:', error)
|
|
|
}
|
|
}
|
|
|
} finally {
|
|
} finally {
|
|
|
- refreshCaptcha()
|
|
|
|
|
loading.value = false
|
|
loading.value = false
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 获取验证码
|
|
|
|
|
- const refreshCaptcha = async () => {
|
|
|
|
|
- try {
|
|
|
|
|
- const res = await fetchCaptcha()
|
|
|
|
|
- formData.uuid = res.uuid
|
|
|
|
|
- captcha.value = res.image
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- console.error('[Login] Failed to load captcha:', error)
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
// 登录成功提示
|
|
// 登录成功提示
|
|
|
const showLoginSuccessNotice = () => {
|
|
const showLoginSuccessNotice = () => {
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|