You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.6 KiB

2 years ago
<script lang="ts" setup>
import { computed, reactive, ref, unref } from 'vue'
1 year ago
import { Form, Input } from 'ant-design-vue'
import { useAsyncState } from '@vueuse/core'
import CryptoJS from 'crypto-js'
import { LoadingOutlined } from '@ant-design/icons-vue'
2 years ago
import LoginFormTitle from './LoginFormTitle.vue'
import { LoginStateEnum, useFormRules, useFormValid, useLoginState } from './useLogin'
2 years ago
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
import { useUserStore } from '@/store/modules/user'
import { useDesign } from '@/hooks/web/useDesign'
import { getLoginCaptcha } from '@/api/base/user'
import type { LoginParams } from '@/api/base/user/types'
2 years ago
2 years ago
const FormItem = Form.Item
const InputPassword = Input.Password
2 years ago
2 years ago
const { t } = useI18n()
const { notification, createErrorModal } = useMessage()
const { prefixCls } = useDesign('login')
const userStore = useUserStore()
2 years ago
1 year ago
const { getLoginState } = useLoginState()
2 years ago
const { getFormRules } = useFormRules()
const formRef = ref()
const loading = ref(false)
2 years ago
const formData = reactive<LoginParams>({
feat: 系统管理 commit c6577279b8b1c94c9737d32a9ca1ba3437c5979b Author: K <1175047471@qq.com> Date: Fri Apr 12 09:40:22 2024 +0800 chore: 取消 token 刷新 commit 349b8176f28e294fbde7dd8a4c50f064785fdf9d Author: K <1175047471@qq.com> Date: Thu Apr 11 21:20:39 2024 +0800 chore: cleanup commit 309887ade9b8a8bb4efd35f09983ddcd3afb76df Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 21:15:02 2024 +0800 fix: 岗位查看 commit 0f4f83dd51c2ed454fc1ee3561f315bc7e35dc6a Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 21:13:47 2024 +0800 feat: 租户管理 commit 04e5d8d685616a601fd1d3b82ab18c4442536de8 Author: K <1175047471@qq.com> Date: Thu Apr 11 21:09:50 2024 +0800 chore: fix useinfo 未更新 commit 75ed18056c878c445ede439f27a1df2af41498dd Author: K <1175047471@qq.com> Date: Thu Apr 11 20:58:47 2024 +0800 chore: 修改首页地址 commit ef93ffc03d6f06f21b996f873b2b36e625c58a89 Author: K <1175047471@qq.com> Date: Thu Apr 11 20:52:27 2024 +0800 feat: 个人中心 commit 476a436f8654b8cd72fefd2105df2ecca7d517f7 Author: K <1175047471@qq.com> Date: Thu Apr 11 19:53:41 2024 +0800 wip: 个人中心 commit e5704dc3ad9dea20af45457dedc72ba65eb9d732 Author: K <1175047471@qq.com> Date: Thu Apr 11 19:36:55 2024 +0800 feat: 用户管理 commit e22200135c29ddbb17cbaae2d857c46478a9d9f7 Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 17:42:25 2024 +0800 fix: 部门删除接口将ids改为id commit bbf42e206fad8a91a23edbbd68a3e2ce2d5ed59f Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 17:40:20 2024 +0800 feat: 角色管理; commit c7e7e89bfe9100641811823846d1a0f48cd5f584 Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 14:11:35 2024 +0800 feat: 岗位管理 commit 355d77d3cfc286664bd78bffbaca2766597e11c1 Author: K <1175047471@qq.com> Date: Thu Apr 11 11:12:33 2024 +0800 chore: 调整行政区划操作按钮位置 commit 9f7927b94625f7b1ffe74a3b396849631cea5bea Author: K <1175047471@qq.com> Date: Thu Apr 11 10:45:24 2024 +0800 wip: 用户管理 commit 87b423b14f5bf795b4f99d120feac6a06f3ac332 Author: K <1175047471@qq.com> Date: Thu Apr 11 09:16:25 2024 +0800 feat: 菜单管理 - 新增子项 commit f2fa565d939802896539e1e07cdf1bd3bfa1bb0e Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:12:04 2024 +0800 chore: 菜单路由处理动态参数 commit 3a2c15b69ecd8243f6ca9237b1ff19dbb6d374fe Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:08:23 2024 +0800 Revert "chore: 菜单路由处理动态参数" This reverts commit 3018cb399cd58e8e80285b83fc53ff9bdbd10e14. commit 9724ddc926c5efedc8f72ced29d31d61995b12a5 Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:05:52 2024 +0800 chore: 菜单路由处理动态参数 commit 5bca711522df26d884669edd50eb53ce35c7ebd5 Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 20:40:12 2024 +0800 fix: 删掉测试路由 commit 753306a1e4b7fdf17ac6337ca029a6f411baec1c Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 20:11:03 2024 +0800 feat: 业务字典 commit 0f551cf23dc20f2750b823ff49864cfa1c55910e Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 18:29:17 2024 +0800 fix: 系统字典-字典配置修改 commit 040923dd0eb3eb3846ddcf17efee9aa9fb2ca2da Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 18:23:51 2024 +0800 feat: 系统字典 commit 1dfe6a3b221863fa792b8fc7432707c5fe009da2 Author: K <1175047471@qq.com> Date: Wed Apr 10 21:06:30 2024 +0800 fix: 菜单类型显示错误 commit c16cbdf807d7b8d44e2b0ff1b1310109c24c2d5d Author: K <1175047471@qq.com> Date: Wed Apr 10 20:57:36 2024 +0800 fix: 菜单无法跳转 commit f95c62d7faac99aa0700f14d46291fa34eafa0e2 Author: K <1175047471@qq.com> Date: Wed Apr 10 20:26:34 2024 +0800 feat: ImportModal 增加提示 commit 1e0af86b01d54e5ee8b89a5b48c8f2fb5276386f Author: K <1175047471@qq.com> Date: Wed Apr 10 20:21:37 2024 +0800 fix: 批量删除错误 commit 47a807a76e6cb006fb12ef8bf8e6a065f9e293b8 Author: K <1175047471@qq.com> Date: Wed Apr 10 20:19:00 2024 +0800 fix: 批量删除错误 commit 82248511dcb058a6885e64472a47df10bd43218d Author: K <1175047471@qq.com> Date: Wed Apr 10 20:07:28 2024 +0800 chore: cleanup commit fae351c1d131151738e42f82fbd0e98dd21f79bd Author: K <1175047471@qq.com> Date: Wed Apr 10 20:06:58 2024 +0800 feat: 行政区划 commit 9d370465faff6adac276f96e099a42ea015c4e4a Author: K <1175047471@qq.com> Date: Wed Apr 10 11:18:16 2024 +0800 fix: 菜单 icon 不应该是必选项 commit 68734b32e416ff6db4fe0e2748148e6867cd236a Author: K <1175047471@qq.com> Date: Wed Apr 10 10:59:32 2024 +0800 feat: 参数管理 - 批量删除 commit ff3a985a70f97db5ff169b64b2bfe997ce60360d Author: K <1175047471@qq.com> Date: Wed Apr 10 10:51:09 2024 +0800 feat: 参数管理 commit 6b1ec43e7a598a0140452eaae47223302cb6b345 Author: K <1175047471@qq.com> Date: Wed Apr 10 10:24:59 2024 +0800 wip: 菜单管理 commit 19ad299806d14f780ab52fc6d890224b63796750 Author: K <1175047471@qq.com> Date: Tue Apr 9 18:31:16 2024 +0800 wip: 系统管理 commit 8a02a8a64b90206a109d14ebdfc082b0ba1fcbdc Author: K <1175047471@qq.com> Date: Tue Apr 9 18:03:13 2024 +0800 wip: 系统管理
1 year ago
tenantId: '000000',
2 years ago
username: 'admin',
feat: 系统管理 commit c6577279b8b1c94c9737d32a9ca1ba3437c5979b Author: K <1175047471@qq.com> Date: Fri Apr 12 09:40:22 2024 +0800 chore: 取消 token 刷新 commit 349b8176f28e294fbde7dd8a4c50f064785fdf9d Author: K <1175047471@qq.com> Date: Thu Apr 11 21:20:39 2024 +0800 chore: cleanup commit 309887ade9b8a8bb4efd35f09983ddcd3afb76df Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 21:15:02 2024 +0800 fix: 岗位查看 commit 0f4f83dd51c2ed454fc1ee3561f315bc7e35dc6a Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 21:13:47 2024 +0800 feat: 租户管理 commit 04e5d8d685616a601fd1d3b82ab18c4442536de8 Author: K <1175047471@qq.com> Date: Thu Apr 11 21:09:50 2024 +0800 chore: fix useinfo 未更新 commit 75ed18056c878c445ede439f27a1df2af41498dd Author: K <1175047471@qq.com> Date: Thu Apr 11 20:58:47 2024 +0800 chore: 修改首页地址 commit ef93ffc03d6f06f21b996f873b2b36e625c58a89 Author: K <1175047471@qq.com> Date: Thu Apr 11 20:52:27 2024 +0800 feat: 个人中心 commit 476a436f8654b8cd72fefd2105df2ecca7d517f7 Author: K <1175047471@qq.com> Date: Thu Apr 11 19:53:41 2024 +0800 wip: 个人中心 commit e5704dc3ad9dea20af45457dedc72ba65eb9d732 Author: K <1175047471@qq.com> Date: Thu Apr 11 19:36:55 2024 +0800 feat: 用户管理 commit e22200135c29ddbb17cbaae2d857c46478a9d9f7 Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 17:42:25 2024 +0800 fix: 部门删除接口将ids改为id commit bbf42e206fad8a91a23edbbd68a3e2ce2d5ed59f Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 17:40:20 2024 +0800 feat: 角色管理; commit c7e7e89bfe9100641811823846d1a0f48cd5f584 Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 14:11:35 2024 +0800 feat: 岗位管理 commit 355d77d3cfc286664bd78bffbaca2766597e11c1 Author: K <1175047471@qq.com> Date: Thu Apr 11 11:12:33 2024 +0800 chore: 调整行政区划操作按钮位置 commit 9f7927b94625f7b1ffe74a3b396849631cea5bea Author: K <1175047471@qq.com> Date: Thu Apr 11 10:45:24 2024 +0800 wip: 用户管理 commit 87b423b14f5bf795b4f99d120feac6a06f3ac332 Author: K <1175047471@qq.com> Date: Thu Apr 11 09:16:25 2024 +0800 feat: 菜单管理 - 新增子项 commit f2fa565d939802896539e1e07cdf1bd3bfa1bb0e Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:12:04 2024 +0800 chore: 菜单路由处理动态参数 commit 3a2c15b69ecd8243f6ca9237b1ff19dbb6d374fe Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:08:23 2024 +0800 Revert "chore: 菜单路由处理动态参数" This reverts commit 3018cb399cd58e8e80285b83fc53ff9bdbd10e14. commit 9724ddc926c5efedc8f72ced29d31d61995b12a5 Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:05:52 2024 +0800 chore: 菜单路由处理动态参数 commit 5bca711522df26d884669edd50eb53ce35c7ebd5 Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 20:40:12 2024 +0800 fix: 删掉测试路由 commit 753306a1e4b7fdf17ac6337ca029a6f411baec1c Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 20:11:03 2024 +0800 feat: 业务字典 commit 0f551cf23dc20f2750b823ff49864cfa1c55910e Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 18:29:17 2024 +0800 fix: 系统字典-字典配置修改 commit 040923dd0eb3eb3846ddcf17efee9aa9fb2ca2da Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 18:23:51 2024 +0800 feat: 系统字典 commit 1dfe6a3b221863fa792b8fc7432707c5fe009da2 Author: K <1175047471@qq.com> Date: Wed Apr 10 21:06:30 2024 +0800 fix: 菜单类型显示错误 commit c16cbdf807d7b8d44e2b0ff1b1310109c24c2d5d Author: K <1175047471@qq.com> Date: Wed Apr 10 20:57:36 2024 +0800 fix: 菜单无法跳转 commit f95c62d7faac99aa0700f14d46291fa34eafa0e2 Author: K <1175047471@qq.com> Date: Wed Apr 10 20:26:34 2024 +0800 feat: ImportModal 增加提示 commit 1e0af86b01d54e5ee8b89a5b48c8f2fb5276386f Author: K <1175047471@qq.com> Date: Wed Apr 10 20:21:37 2024 +0800 fix: 批量删除错误 commit 47a807a76e6cb006fb12ef8bf8e6a065f9e293b8 Author: K <1175047471@qq.com> Date: Wed Apr 10 20:19:00 2024 +0800 fix: 批量删除错误 commit 82248511dcb058a6885e64472a47df10bd43218d Author: K <1175047471@qq.com> Date: Wed Apr 10 20:07:28 2024 +0800 chore: cleanup commit fae351c1d131151738e42f82fbd0e98dd21f79bd Author: K <1175047471@qq.com> Date: Wed Apr 10 20:06:58 2024 +0800 feat: 行政区划 commit 9d370465faff6adac276f96e099a42ea015c4e4a Author: K <1175047471@qq.com> Date: Wed Apr 10 11:18:16 2024 +0800 fix: 菜单 icon 不应该是必选项 commit 68734b32e416ff6db4fe0e2748148e6867cd236a Author: K <1175047471@qq.com> Date: Wed Apr 10 10:59:32 2024 +0800 feat: 参数管理 - 批量删除 commit ff3a985a70f97db5ff169b64b2bfe997ce60360d Author: K <1175047471@qq.com> Date: Wed Apr 10 10:51:09 2024 +0800 feat: 参数管理 commit 6b1ec43e7a598a0140452eaae47223302cb6b345 Author: K <1175047471@qq.com> Date: Wed Apr 10 10:24:59 2024 +0800 wip: 菜单管理 commit 19ad299806d14f780ab52fc6d890224b63796750 Author: K <1175047471@qq.com> Date: Tue Apr 9 18:31:16 2024 +0800 wip: 系统管理 commit 8a02a8a64b90206a109d14ebdfc082b0ba1fcbdc Author: K <1175047471@qq.com> Date: Tue Apr 9 18:03:13 2024 +0800 wip: 系统管理
1 year ago
password: '123456',
captchaKey: '',
captchaCode: '',
2 years ago
})
const { validForm } = useFormValid(formRef)
const getShow = computed(() => unref(getLoginState) === LoginStateEnum.LOGIN)
async function handleLogin() {
2 years ago
const data = await validForm()
if (!data)
return
2 years ago
try {
loading.value = true
const userInfo = await userStore.login({
...formData,
captchaKey: captcha.value!.key,
password: CryptoJS.MD5(formData.password).toString(),
mode: 'none',
2 years ago
})
if (userInfo) {
notification.success({
message: t('sys.login.loginSuccessTitle'),
description: `${t('sys.login.loginSuccessDesc')}: ${userInfo.user.real_name}`,
duration: 3,
2 years ago
})
}
}
catch (error) {
refreshCaptcha()
2 years ago
createErrorModal({
title: t('sys.api.errorTip'),
content: (error as unknown as Error).message || t('sys.api.networkExceptionMsg'),
getContainer: () => document.body.querySelector(`.${prefixCls}`) || document.body,
2 years ago
})
}
finally {
2 years ago
loading.value = false
}
}
const { state: captcha, execute: refreshCaptcha, isLoading: isLoadingCaptcha } = useAsyncState(getLoginCaptcha, undefined)
2 years ago
</script>
<template>
<LoginFormTitle v-show="getShow" class="enter-x" />
<Form
v-show="getShow" ref="formRef" class="enter-x p-4" :model="formData" :rules="getFormRules"
@keypress.enter="handleLogin"
>
<FormItem name="username" class="enter-x">
<Input
v-model:value="formData.username" size="large" :placeholder="t('sys.login.userName')"
class="fix-auto-fill"
/>
</FormItem>
<FormItem name="password" class="enter-x">
<InputPassword
v-model:value="formData.password"
size="large"
visibility-toggle
:placeholder="t('sys.login.password')"
class="fix-auto-fill"
/>
</FormItem>
<FormItem>
<div flex="~ justify-between items-center gap-12px">
<Input v-model:value="formData.captchaCode" size="large" placeholder="验证码" class="fix-auto-fill w-0 flex-1 min-w-auto!" />
<div w="100px" text="center">
<LoadingOutlined v-if="isLoadingCaptcha" />
<img v-else w-full :src="captcha?.image" @click="refreshCaptcha()">
</div>
</div>
</FormItem>
<FormItem class="enter-x">
<a-button type="primary" size="large" block :loading="loading" @click="handleLogin">
{{ t('sys.login.loginButton') }}
</a-button>
</FormItem>
</Form>
</template>