- 完成学生信息管理核心功能开发 - 新增学生信息采集批次管理功能 - 完成班干部管理模块开发 - 修复物业报修模块附件上传逻辑 - 完善数据库表结构和权限配置 - 更新API文档和变更记录 - 优化前端页面交互体验 详细变更记录见: - docs/变更管理/code-adjust-record-2025-01-13-wuzhen.md - docs/变更管理/code-adjust-record-2025-07-11-wuzilong.md - docs/变更管理/code-adjust-record-2025-07-12-wuzhen.md
407 lines
11 KiB
Vue
407 lines
11 KiB
Vue
<template>
|
|
<div class="login" :class="{ 'bg-loaded': backgroundLoaded }">
|
|
<div class="bg-placeholder" v-if="!backgroundLoaded"></div>
|
|
<div class="loading-indicator" v-if="!backgroundLoaded">
|
|
<el-progress :percentage="loadingProgress" :show-text="false" />
|
|
<span class="loading-text">背景加载中...</span>
|
|
</div>
|
|
<el-form ref="loginRef" :model="loginForm" :rules="loginRules" class="login-form">
|
|
<div class="title-box">
|
|
<h3 class="title">{{ title }}</h3>
|
|
<!-- <lang-select /> -->
|
|
</div>
|
|
<el-form-item v-if="tenantEnabled" prop="tenantId" class="el_select_coopr">
|
|
<el-select v-model="loginForm.tenantId" filterable :placeholder="proxy.$t('login.selectPlaceholder')" style="width: 100%">
|
|
<el-option v-for="item in tenantList" :key="item.tenantId" :label="item.companyName" :value="item.tenantId"></el-option>
|
|
<template #prefix><svg-icon icon-class="company" class="el-input__icon input-icon" /></template>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item prop="username">
|
|
<el-input v-model="loginForm.username" type="text" auto-complete="off" :placeholder="proxy.$t('login.username')">
|
|
<template #prefix><svg-icon icon-class="user" class="el-input__icon input-icon" /></template>
|
|
</el-input>
|
|
</el-form-item>
|
|
<el-form-item prop="password">
|
|
<el-input
|
|
v-model="loginForm.password"
|
|
type="password"
|
|
auto-complete="off"
|
|
:placeholder="proxy.$t('login.password')"
|
|
@keyup.enter="handleLogin"
|
|
>
|
|
<template #prefix><svg-icon icon-class="password" class="el-input__icon input-icon" /></template>
|
|
</el-input>
|
|
</el-form-item>
|
|
|
|
<!-- <el-checkbox v-model="loginForm.rememberMe" style="margin: 0 0 25px 0">{{ proxy.$t('login.rememberPassword') }}</el-checkbox> -->
|
|
<!-- <el-form-item style="float: right">
|
|
<el-button circle :title="proxy.$t('login.social.wechat')" @click="doSocialLogin('wechat')">
|
|
<svg-icon icon-class="wechat" />
|
|
</el-button>
|
|
<el-button circle :title="proxy.$t('login.social.maxkey')" @click="doSocialLogin('maxkey')">
|
|
<svg-icon icon-class="maxkey" />
|
|
</el-button>
|
|
<el-button circle :title="proxy.$t('login.social.topiam')" @click="doSocialLogin('topiam')">
|
|
<svg-icon icon-class="topiam" />
|
|
</el-button>
|
|
<el-button circle :title="proxy.$t('login.social.gitee')" @click="doSocialLogin('gitee')">
|
|
<svg-icon icon-class="gitee" />
|
|
</el-button>
|
|
<el-button circle :title="proxy.$t('login.social.github')" @click="doSocialLogin('github')">
|
|
<svg-icon icon-class="github" />
|
|
</el-button>
|
|
</el-form-item> -->
|
|
<el-form-item style="width: 100%">
|
|
<el-button
|
|
:loading="loading"
|
|
size="large"
|
|
style="width: 100%; background-color: rgb(var(--art-primary)) !important"
|
|
class="login-button"
|
|
@click.prevent="handleLogin"
|
|
>
|
|
<span v-if="!loading">{{ proxy.$t('login.login') }}</span>
|
|
<span v-else>{{ proxy.$t('login.logging') }}</span>
|
|
</el-button>
|
|
<div v-if="register" style="float: right">
|
|
<router-link class="link-type" :to="'/register'">{{ proxy.$t('login.switchRegisterPage') }}</router-link>
|
|
</div>
|
|
</el-form-item>
|
|
</el-form>
|
|
<!-- 底部 -->
|
|
<div class="el-login-footer">
|
|
<span>Copyright © 2025-{{ currentYear }} 杭州第一技师学院 All Rights Reserved.</span>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { getTenantList } from '@/api/login';
|
|
import { authBinding } from '@/api/system/social/auth';
|
|
import { useUserStore } from '@/store/modules/user';
|
|
import { LoginData, TenantVO } from '@/api/types';
|
|
import { to } from 'await-to-js';
|
|
import { HttpStatus } from '@/enums/RespEnum';
|
|
import { useI18n } from 'vue-i18n';
|
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
|
const title = import.meta.env.VITE_APP_TITLE;
|
|
const userStore = useUserStore();
|
|
const router = useRouter();
|
|
const { t } = useI18n();
|
|
|
|
// 获取当前年份
|
|
const currentYear = new Date().getFullYear();
|
|
|
|
// 背景图片加载状态
|
|
const backgroundLoaded = ref(false);
|
|
const loadingProgress = ref(0);
|
|
|
|
const loginForm = ref<LoginData>({
|
|
tenantId: '000000',
|
|
username: 'admin',
|
|
password: 'admin123',
|
|
clientId: 'e5cd7e4891bf95d1d19206ce24a7b32e',
|
|
grantType: 'password'
|
|
} as LoginData);
|
|
|
|
const loginRules: ElFormRules = {
|
|
tenantId: [{ required: true, trigger: 'blur', message: t('login.rule.tenantId.required') }],
|
|
username: [{ required: true, trigger: 'blur', message: t('login.rule.username.required') }],
|
|
password: [{ required: true, trigger: 'blur', message: t('login.rule.password.required') }]
|
|
};
|
|
|
|
const loading = ref(false);
|
|
// 租户开关
|
|
const tenantEnabled = ref(true);
|
|
|
|
// 注册开关
|
|
const register = ref(false);
|
|
const redirect = ref('/');
|
|
const loginRef = ref<ElFormInstance>();
|
|
// 租户列表
|
|
const tenantList = ref<TenantVO[]>([]);
|
|
|
|
/**
|
|
* 预加载背景图片
|
|
*/
|
|
const preloadBackgroundImage = () => {
|
|
const img = new Image();
|
|
const backgroundImageUrl = new URL('../assets/images/login-background.jpg', import.meta.url).href;
|
|
|
|
// 模拟加载进度
|
|
const progressInterval = setInterval(() => {
|
|
if (loadingProgress.value < 90) {
|
|
loadingProgress.value += Math.random() * 15;
|
|
}
|
|
}, 200);
|
|
|
|
img.onload = () => {
|
|
clearInterval(progressInterval);
|
|
loadingProgress.value = 100;
|
|
|
|
// 短暂延迟后显示完整背景图片
|
|
setTimeout(() => {
|
|
backgroundLoaded.value = true;
|
|
}, 300);
|
|
};
|
|
|
|
img.onerror = () => {
|
|
clearInterval(progressInterval);
|
|
console.warn('背景图片加载失败,使用占位图片');
|
|
backgroundLoaded.value = true; // 即使失败也显示占位背景
|
|
};
|
|
|
|
img.src = backgroundImageUrl;
|
|
};
|
|
|
|
watch(
|
|
() => router.currentRoute.value,
|
|
(newRoute: any) => {
|
|
redirect.value = newRoute.query && newRoute.query.redirect && decodeURIComponent(newRoute.query.redirect);
|
|
},
|
|
{ immediate: true }
|
|
);
|
|
|
|
const handleLogin = () => {
|
|
loginRef.value?.validate(async (valid: boolean, fields: any) => {
|
|
if (valid) {
|
|
loading.value = true;
|
|
|
|
// 调用action的登录方法
|
|
const [err] = await to(userStore.login(loginForm.value));
|
|
if (!err) {
|
|
const redirectUrl = redirect.value || '/';
|
|
await router.push(redirectUrl);
|
|
loading.value = false;
|
|
} else {
|
|
loading.value = false;
|
|
}
|
|
} else {
|
|
console.log('error submit!', fields);
|
|
}
|
|
});
|
|
};
|
|
|
|
const getLoginData = () => {
|
|
// 由于已去除记住密码功能,保持默认的登录数据
|
|
// 如需要其他初始化逻辑,可在此处添加
|
|
};
|
|
|
|
/**
|
|
* 获取租户列表
|
|
*/
|
|
const initTenantList = async () => {
|
|
const { data } = await getTenantList(false);
|
|
tenantEnabled.value = data.tenantEnabled === undefined ? true : data.tenantEnabled;
|
|
if (tenantEnabled.value) {
|
|
tenantList.value = data.voList;
|
|
if (tenantList.value != null && tenantList.value.length !== 0) {
|
|
loginForm.value.tenantId = tenantList.value[0].tenantId;
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* 第三方登录
|
|
* @param type
|
|
*/
|
|
const doSocialLogin = (type: string) => {
|
|
authBinding(type, loginForm.value.tenantId).then((res: any) => {
|
|
if (res.code === HttpStatus.SUCCESS) {
|
|
// 获取授权地址跳转
|
|
window.location.href = res.data;
|
|
} else {
|
|
ElMessage.error(res.msg);
|
|
}
|
|
});
|
|
};
|
|
|
|
onMounted(() => {
|
|
initTenantList();
|
|
getLoginData();
|
|
|
|
// 开始预加载背景图片
|
|
preloadBackgroundImage();
|
|
});
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.login {
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
align-items: center;
|
|
height: 100%;
|
|
padding-right: 200px;
|
|
position: relative;
|
|
|
|
// 默认显示占位背景(使用较小的图片或渐变)
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
|
|
// 占位背景图片(使用较小的图片)
|
|
.bg-placeholder {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
background-image: url('../assets/images/login-background-old.jpg');
|
|
background-size: cover;
|
|
background-position: center;
|
|
opacity: 0.7;
|
|
z-index: -2;
|
|
}
|
|
|
|
// 加载完成后显示完整背景图片
|
|
&.bg-loaded {
|
|
background-image: url('../assets/images/login-background.jpg');
|
|
background-size: cover;
|
|
background-position: center;
|
|
transition: all 1s ease-in-out;
|
|
|
|
.bg-placeholder {
|
|
opacity: 0;
|
|
transition: opacity 1s ease-in-out;
|
|
}
|
|
|
|
.loading-indicator {
|
|
opacity: 0;
|
|
transition: opacity 0.5s ease-in-out;
|
|
}
|
|
}
|
|
}
|
|
|
|
// 加载指示器样式
|
|
.loading-indicator {
|
|
position: fixed;
|
|
top: 20px;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
background: rgba(255, 255, 255, 0.9);
|
|
padding: 15px 25px;
|
|
border-radius: 25px;
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
z-index: 1000;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
gap: 8px;
|
|
backdrop-filter: blur(10px);
|
|
|
|
.el-progress {
|
|
width: 200px;
|
|
}
|
|
|
|
.loading-text {
|
|
font-size: 12px;
|
|
color: #606266;
|
|
margin-top: 5px;
|
|
}
|
|
}
|
|
|
|
.title-box {
|
|
display: flex;
|
|
|
|
.title {
|
|
margin: 0px auto 30px auto;
|
|
text-align: center;
|
|
color: #000000;
|
|
}
|
|
|
|
:deep(.lang-select--style) {
|
|
line-height: 0;
|
|
color: #7483a3;
|
|
}
|
|
}
|
|
|
|
.login-form {
|
|
border-radius: 6px;
|
|
background: rgba(255, 255, 255, 0.55);
|
|
backdrop-filter: blur(10px);
|
|
width: 400px;
|
|
padding: 25px 25px 5px 25px;
|
|
z-index: 1;
|
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
|
|
// 统一所有表单控件的高度为32px(与全局保持一致)
|
|
.el-input,
|
|
.el-select {
|
|
height: 32px !important;
|
|
min-height: 32px !important;
|
|
max-height: 32px !important;
|
|
|
|
.el-input__wrapper {
|
|
height: 32px !important;
|
|
min-height: 32px !important;
|
|
max-height: 32px !important;
|
|
box-sizing: border-box !important;
|
|
}
|
|
|
|
.el-input__inner,
|
|
input {
|
|
height: 32px !important;
|
|
min-height: 32px !important;
|
|
max-height: 32px !important;
|
|
line-height: 32px !important;
|
|
}
|
|
|
|
.el-input__prefix,
|
|
.el-input__suffix {
|
|
height: 32px !important;
|
|
line-height: 32px !important;
|
|
}
|
|
}
|
|
|
|
// 特别针对select组件的高度控制
|
|
.el-select {
|
|
.el-input {
|
|
height: 32px !important;
|
|
min-height: 32px !important;
|
|
max-height: 32px !important;
|
|
}
|
|
}
|
|
|
|
.input-icon {
|
|
height: 31px;
|
|
width: 14px;
|
|
margin-left: 0px;
|
|
}
|
|
}
|
|
|
|
.login-tip {
|
|
font-size: 13px;
|
|
text-align: center;
|
|
color: #bfbfbf;
|
|
}
|
|
|
|
.el-login-footer {
|
|
height: 40px;
|
|
line-height: 40px;
|
|
position: fixed;
|
|
bottom: 0;
|
|
width: 100%;
|
|
text-align: center;
|
|
color: #fff;
|
|
font-family: Arial, serif;
|
|
font-size: 12px;
|
|
letter-spacing: 1px;
|
|
}
|
|
|
|
// 针对公司选择下拉框的特殊样式
|
|
.el_select_coopr {
|
|
:deep(.el-select__wrapper) {
|
|
padding: 0px 12px !important;
|
|
border-radius: 8px;
|
|
}
|
|
|
|
:deep(.el-input__wrapper) {
|
|
padding: 0px 12px !important;
|
|
border-radius: 8px;
|
|
}
|
|
}
|
|
|
|
.login-button {
|
|
color: #ffffff;
|
|
}
|
|
</style>
|