SourceTermAnalysisSystem_vue/src/views/system/loginmini/MiniLogin.vue

369 lines
11 KiB
Vue
Raw Normal View History

2025-07-16 11:41:36 +08:00
<template>
<div :class="prefixCls" class="login-background-img">
2025-08-13 11:13:51 +08:00
<!-- <AppLocalePicker class="absolute top-4 right-4 enter-x xl:text-gray-600" :showText="false" /> -->
<!-- <AppDarkModeToggle class="absolute top-3 right-7 enter-x" /> -->
<div class="aui-content">
<div class="aui-container">
<div class="aui-form">
<div class="aui-formBox">
2025-08-13 12:56:12 +08:00
<div class="aui-formWell">
<div
style="display: flex; width: 410px; margin-bottom: 25px; margin-left: 96px; justify-content: center;">
<img :src="logoImg" />
2025-07-16 11:41:36 +08:00
</div>
2025-08-13 12:56:12 +08:00
<div class="aui-flex aui-form-nav investment_title" style="margin-left: 78px;">
2025-08-13 11:13:51 +08:00
<div class="logoTitle">放射性源项分析系统</div>
</div>
<div class="aui-form-box" style="height: 252px">
<a-form ref="loginRef" :model="formData" @keyup.enter.native="loginHandleClick">
<div class="aui-account">
<div class="aui-inputClear">
<div class="aui-inputLabel">用户名</div>
<div class="aui-inputContent">
<i class="icon icon-user"></i>
2025-07-16 11:41:36 +08:00
<a-form-item>
2025-08-13 11:13:51 +08:00
<a-input class="fix-auto-fill" v-model:value="formData.username" />
2025-07-16 11:41:36 +08:00
</a-form-item>
</div>
2025-08-13 11:13:51 +08:00
</div>
<div class="aui-inputClear">
<div class="aui-inputLabel" style="text-align: right;">密码</div>
<div class="aui-inputContent">
2025-07-16 11:41:36 +08:00
<i class="icon icon-password"></i>
<a-form-item>
2025-08-13 11:13:51 +08:00
<a-input class="fix-auto-fill" type="password" v-model:value="formData.password" />
2025-07-16 11:41:36 +08:00
</a-form-item>
</div>
2025-08-13 11:13:51 +08:00
</div>
<div class="aui-inputClear">
<div class="aui-inputLabel">验证码</div>
<div class="aui-codeContent">
2025-07-16 11:41:36 +08:00
<i class="icon icon-code"></i>
<a-form-item>
2025-08-13 11:13:51 +08:00
<a-input class="fix-auto-fill code-input" type="text" v-model:value="formData.inputCode" />
2025-07-16 11:41:36 +08:00
</a-form-item>
</div>
2025-08-13 11:13:51 +08:00
<div class="aui-code">
<img v-if="randCodeData.requestCodeSuccess" :src="randCodeData.randCodeImage"
class="aui-code-img" @click="handleChangeCheckCode" />
<img v-else style="margin-top: 2px; max-width: initial" :src="codeImg" class="aui-code-img"
@click="handleChangeCheckCode" />
2025-07-16 11:41:36 +08:00
</div>
</div>
2025-08-13 11:13:51 +08:00
<div class="aui-flex">
<div class="aui-flex-box">
<div class="aui-choice">
<a-input class="fix-auto-fill" type="checkbox" v-model:value="rememberMe" />
<span style="margin-left: 5px">{{ t('sys.login.rememberMe') }}</span>
2025-07-16 11:41:36 +08:00
</div>
2025-08-13 12:56:12 +08:00
</div>
2025-07-16 11:41:36 +08:00
</div>
</div>
2025-08-13 11:13:51 +08:00
</a-form>
</div>
<div class="aui-formButton">
<a-button :loading="loginLoading" class="aui-link-login" type="primary" @click="loginHandleClick">
{{ t('sys.login.loginButton') }}</a-button>
2025-07-16 11:41:36 +08:00
</div>
</div>
</div>
</div>
</div>
</div>
2025-08-13 11:13:51 +08:00
<!-- <div v-show="type === 'forgot'" :class="`${prefixCls}-form`">
2025-07-16 11:41:36 +08:00
<MiniForgotpad ref="forgotRef" @go-back="goBack" @success="handleSuccess" />
</div>
<div v-show="type === 'register'" :class="`${prefixCls}-form`">
<MiniRegister ref="registerRef" @go-back="goBack" @success="handleSuccess" />
</div>
<div v-show="type === 'codeLogin'" :class="`${prefixCls}-form`">
<MiniCodelogin ref="codeRef" @go-back="goBack" @success="handleSuccess" />
</div>
<!-- 第三方登录相关弹框 -->
2025-08-13 11:13:51 +08:00
<ThirdModal ref="thirdModalRef"></ThirdModal> -->
2025-07-16 11:41:36 +08:00
<!-- 图片验证码弹窗 -->
<CaptchaModal @register="captchaRegisterModal" @ok="getLoginCode" />
</div>
</template>
<script lang="ts" setup name="login-mini">
2025-08-13 12:56:12 +08:00
import { getCodeInfo } from '/@/api/sys/user';
import { onMounted, reactive, ref, toRaw } from 'vue';
2025-08-13 11:13:51 +08:00
import codeImg from '/@/assets/images/checkcode.png';
import { useUserStore } from '/@/store/modules/user';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import ThirdModal from '/@/views/sys/login/ThirdModal.vue';
import logoImg from '/@/assets/loginmini/icon/logo.png';
import { useLocaleStore } from '/@/store/modules/locale';
import { useDesign } from "/@/hooks/web/useDesign";
import CaptchaModal from '@/components/jeecg/captcha/CaptchaModal.vue';
import { useModal } from "@/components/Modal";
const { prefixCls } = useDesign('mini-login');
const { notification, createMessage } = useMessage();
const userStore = useUserStore();
const { t } = useI18n();
const randCodeData = reactive<any>({
randCodeImage: '',
requestCodeSuccess: false,
checkKey: null,
});
const rememberMe = ref<string>('0');
//账号登录表单字段
const formData = reactive<any>({
inputCode: '',
username: 'admin',
password: '123456',
});
const loginRef = ref();
//第三方登录弹窗
const thirdModalRef = ref();
const loginLoading = ref<boolean>(false);
const [captchaRegisterModal, { openModal: openCaptchaModal }] = useModal();
defineProps({
sessionTimeout: {
type: Boolean,
},
});
/**
* 获取验证码
*/
function handleChangeCheckCode() {
formData.inputCode = '';
//update-begin---author:chenrui ---date:2025/1/7 for[QQYUN-10775]验证码可以复用 #7674------------
randCodeData.checkKey = new Date().getTime() + Math.random().toString(36).slice(-4); // 1629428467008;
//update-end---author:chenrui ---date:2025/1/7 for[QQYUN-10775]验证码可以复用 #7674------------
getCodeInfo(randCodeData.checkKey).then((res) => {
randCodeData.randCodeImage = res;
randCodeData.requestCodeSuccess = true;
2025-07-16 11:41:36 +08:00
});
2025-08-13 11:13:51 +08:00
}
2025-07-16 11:41:36 +08:00
2025-08-13 11:13:51 +08:00
/**
* 账号或者手机登录
*/
async function loginHandleClick() {
2025-08-13 12:56:12 +08:00
accountLogin();
2025-08-13 11:13:51 +08:00
}
2025-07-16 11:41:36 +08:00
2025-08-13 11:13:51 +08:00
async function accountLogin() {
if (!formData.username) {
createMessage.warn(t('sys.login.accountPlaceholder'));
return;
2025-07-16 11:41:36 +08:00
}
2025-08-13 11:13:51 +08:00
if (!formData.password) {
createMessage.warn(t('sys.login.passwordPlaceholder'));
return;
}
try {
loginLoading.value = true;
const { userInfo } = await userStore.login(
toRaw({
password: formData.password,
username: formData.username,
captcha: formData.inputCode,
checkKey: randCodeData.checkKey,
mode: 'none', //不要默认的错误提示
})
);
if (userInfo) {
notification.success({
message: t('sys.login.loginSuccessTitle'),
description: `${t('sys.login.loginSuccessDesc')}: ${userInfo.realname}`,
2025-07-16 11:41:36 +08:00
duration: 3,
});
}
2025-08-13 11:13:51 +08:00
} catch (error) {
notification.error({
message: t('sys.api.errorTip'),
description: error.message || t('sys.login.networkExceptionMsg'),
duration: 3,
});
handleChangeCheckCode();
} finally {
loginLoading.value = false;
2025-07-16 11:41:36 +08:00
}
2025-08-13 11:13:51 +08:00
}
2025-07-16 11:41:36 +08:00
2025-08-13 11:13:51 +08:00
onMounted(() => {
//加载验证码
handleChangeCheckCode();
});
2025-07-16 11:41:36 +08:00
</script>
<style lang="less" scoped>
2025-08-13 11:13:51 +08:00
@import '/@/assets/loginmini/style/home.less';
@import '/@/assets/loginmini/style/base.less';
2025-07-16 11:41:36 +08:00
2025-08-13 11:13:51 +08:00
:deep(.ant-input:focus) {
box-shadow: none;
}
2025-07-16 11:41:36 +08:00
2025-08-13 11:13:51 +08:00
.aui-get-code {
float: right;
position: relative;
z-index: 3;
background: #ffffff;
color: #1573e9;
border-radius: 100px;
padding: 5px 16px;
margin: 7px;
border: 1px solid #1573e9;
top: 12px;
}
2025-07-16 11:41:36 +08:00
2025-08-13 11:13:51 +08:00
.aui-get-code:hover {
color: #1573e9;
}
2025-07-16 11:41:36 +08:00
2025-08-13 11:13:51 +08:00
.code-shape {
border-color: #dadada !important;
color: #aaa !important;
}
:deep(.jeecg-dark-switch) {
position: absolute;
margin-right: 10px;
}
.aui-link-login {
width: 100%;
height: 60px;
margin-top: 36px;
font-family: MicrosoftYaHei;
font-size: 30px;
font-weight: bold;
font-stretch: normal;
line-height: 3px;
letter-spacing: 3px;
color: #ffffff !important;
background-color: transparent;
background-image: url(../../../assets/loginmini/icon/login-btn.png);
background-size: 100% 100%;
background-repeat: no-repeat;
}
2025-08-13 12:56:12 +08:00
.aui-link-login:hover {
2025-08-13 11:13:51 +08:00
color: #ffffff !important;
background-color: transparent;
box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.61);
background-image: url(../../../assets/loginmini/icon/login-btnHover.png);
background-size: 100% 100%;
background-repeat: no-repeat;
}
.aui-phone-logo {
position: absolute;
margin-left: 10px;
width: 60px;
top: 2px;
z-index: 4;
}
.top-3 {
top: 0.45rem;
}
2025-07-16 11:41:36 +08:00
</style>
<style lang="less">
@prefix-cls: ~'@{namespace}-mini-login';
@dark-bg: #293146;
html[data-theme='dark'] {
.@{prefix-cls} {
background-color: @dark-bg !important;
background-image: none;
&::before {
background-image: url(/@/assets/svg/login-bg-dark.svg);
}
2025-08-13 11:13:51 +08:00
.aui-inputClear {
2025-07-16 11:41:36 +08:00
background-color: #232a3b !important;
}
2025-08-13 11:13:51 +08:00
2025-07-16 11:41:36 +08:00
.ant-input,
.ant-input-password {
background-color: #232a3b !important;
}
.ant-btn:not(.ant-btn-link):not(.ant-btn-primary) {
border: 1px solid #4a5569 !important;
}
&-form {
background: @dark-bg !important;
}
.app-iconify {
color: #fff !important;
}
2025-08-13 11:13:51 +08:00
.aui-inputClear input,
.aui-input-line input,
.aui-choice {
2025-07-16 11:41:36 +08:00
color: #c9d1d9 !important;
}
2025-08-13 11:13:51 +08:00
.aui-formBox {
2025-07-16 11:41:36 +08:00
background-color: @dark-bg !important;
}
2025-08-13 11:13:51 +08:00
.aui-third-text span {
2025-07-16 11:41:36 +08:00
background-color: @dark-bg !important;
}
2025-08-13 11:13:51 +08:00
.aui-form-nav .aui-flex-box {
2025-07-16 11:41:36 +08:00
color: #c9d1d9 !important;
}
2025-08-13 11:13:51 +08:00
.aui-formButton .aui-linek-code {
background: @dark-bg !important;
2025-07-16 11:41:36 +08:00
color: white !important;
}
2025-08-13 11:13:51 +08:00
.aui-code-line {
2025-07-16 11:41:36 +08:00
border-left: none !important;
}
2025-08-13 11:13:51 +08:00
.ant-checkbox-inner,
.aui-success h3 {
2025-07-16 11:41:36 +08:00
border-color: #c9d1d9;
}
2025-08-13 11:13:51 +08:00
2025-07-16 11:41:36 +08:00
//update-begin---author:wangshuai ---date:20230828 for【QQYUN-6363】这个样式代码有问题不在里面导致表达式有问题------------
&-sign-in-way {
.anticon {
font-size: 22px !important;
color: #888 !important;
cursor: pointer !important;
&:hover {
color: @primary-color !important;
}
}
}
2025-08-13 11:13:51 +08:00
2025-07-16 11:41:36 +08:00
//update-end---author:wangshuai ---date:20230828 for【QQYUN-6363】这个样式代码有问题不在里面导致表达式有问题------------
}
input.fix-auto-fill,
.fix-auto-fill input {
-webkit-text-fill-color: #c9d1d9 !important;
box-shadow: inherit !important;
}
2025-08-13 11:13:51 +08:00
2025-07-16 11:41:36 +08:00
.ant-divider-inner-text {
font-size: 12px !important;
color: @text-color-secondary !important;
}
2025-08-13 11:13:51 +08:00
.aui-third-login a {
2025-07-16 11:41:36 +08:00
background: transparent;
}
}
</style>