|
|
@@ -7,15 +7,21 @@ import type { LoginData, TenantVO } from "@@/types/Account"
|
|
|
|
|
|
const userStore = appStore.authStore
|
|
|
const router = useRouter()
|
|
|
-const loginRef = ref<HTMLFormElement>()
|
|
|
+const loginFormRef = ref<HTMLFormElement>()
|
|
|
+const show = ref(false)
|
|
|
+const copyright = computed(() => {
|
|
|
+ return appStore.appConfigStore.getConfig().copyrightYear || "2020"
|
|
|
+})
|
|
|
+
|
|
|
const title = ref(import.meta.env.VITE_APP_TITLE || "后台管理系统")
|
|
|
+
|
|
|
const tenantOptions = ref<TenantVO[]>([])
|
|
|
const loginForm = ref<LoginData>({
|
|
|
tenantId: "000000",
|
|
|
username: "admin",
|
|
|
password: "123iwb",
|
|
|
rememberMe: false,
|
|
|
- code: "1",
|
|
|
+ code: "",
|
|
|
uuid: ""
|
|
|
})
|
|
|
|
|
|
@@ -29,16 +35,16 @@ const loginRules = {
|
|
|
const codeUrl = ref("")
|
|
|
const loading = ref(false)
|
|
|
// 租户开关
|
|
|
-const tenantEnabled = ref(true)
|
|
|
+const tenantEnabled = ref(false)
|
|
|
// 验证码开关
|
|
|
-const captchaEnabled = ref(true)
|
|
|
+const captchaEnabled = ref(false)
|
|
|
// 注册开关
|
|
|
const register = ref(false)
|
|
|
|
|
|
const redirect = ref(undefined)
|
|
|
|
|
|
function handleLogin() {
|
|
|
- loginRef.value?.validate((valid: boolean) => {
|
|
|
+ loginFormRef.value?.validate((valid: boolean) => {
|
|
|
if (valid) {
|
|
|
loading.value = true
|
|
|
//勾选了需要记住密码设置在 cookie 中设置记住用户名和密码
|
|
|
@@ -93,7 +99,6 @@ const doSocialLogin = (type: string) => {
|
|
|
|
|
|
function getCode() {
|
|
|
apis.loginApi.getCodeImg().then(({ data }) => {
|
|
|
- captchaEnabled.value = data.captchaEnabled === undefined ? true : data.captchaEnabled
|
|
|
if (captchaEnabled.value) {
|
|
|
codeUrl.value = "data:image/gif;base64," + data.img
|
|
|
loginForm.value.uuid = data.uuid
|
|
|
@@ -124,21 +129,32 @@ const initTenant = async () => {
|
|
|
appStore.tenantStore
|
|
|
.initTenant()
|
|
|
.then((res: any) => {
|
|
|
- tenantEnabled.value = true
|
|
|
tenantOptions.value = res
|
|
|
- if (tenantOptions.value != null && tenantOptions.value.length !== 0) {
|
|
|
- loginForm.value.tenantId = tenantOptions.value[0].tenantId
|
|
|
- }
|
|
|
})
|
|
|
.catch(() => {
|
|
|
tenantOptions.value = []
|
|
|
- tenantEnabled.value = false
|
|
|
})
|
|
|
}
|
|
|
function init() {
|
|
|
- getCode()
|
|
|
+ appStore.appConfigStore
|
|
|
+ .loadConfig()
|
|
|
+ .then(() => {
|
|
|
+ console.log("---", appStore.appConfigStore.getConfig())
|
|
|
+ title.value = appStore.appConfigStore.getConfig().name
|
|
|
+ register.value = appStore.appConfigStore.isRegister()
|
|
|
+ if (appStore.appConfigStore.isTenant()) {
|
|
|
+ tenantEnabled.value = true
|
|
|
+ initTenant()
|
|
|
+ }
|
|
|
+ if (appStore.appConfigStore.isCaptcha()) {
|
|
|
+ captchaEnabled.value = true
|
|
|
+ getCode()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ show.value = true
|
|
|
+ })
|
|
|
getCookie()
|
|
|
- initTenant()
|
|
|
}
|
|
|
|
|
|
onMounted(init)
|
|
|
@@ -153,7 +169,12 @@ watch(
|
|
|
|
|
|
<template>
|
|
|
<div class="login">
|
|
|
- <el-form ref="loginRef" :model="loginForm" :rules="loginRules" class="login-form">
|
|
|
+ <el-form
|
|
|
+ v-if="show"
|
|
|
+ ref="loginFormRef"
|
|
|
+ :model="loginForm"
|
|
|
+ :rules="loginRules"
|
|
|
+ class="login-form">
|
|
|
<h3 class="title">{{ title }}</h3>
|
|
|
<el-form-item prop="tenantId" v-if="tenantEnabled">
|
|
|
<el-select
|
|
|
@@ -249,7 +270,9 @@ watch(
|
|
|
</el-form>
|
|
|
<!-- 底部 -->
|
|
|
<div class="el-login-footer">
|
|
|
- <span>Copyright ©2018-{{ new Date().getFullYear() }} VAP All Rights Reserved.</span>
|
|
|
+ <span>
|
|
|
+ Copyright ©{{ copyright }}-{{ new Date().getFullYear() }} VAP All Rights Reserved.
|
|
|
+ </span>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|