<script lang="ts" setup>
|
import type { CSSProperties } from 'vue';
|
|
import { computed, ref, watch } from 'vue';
|
|
import { useGlobSetting } from '@jnpf/hooks';
|
|
import SystemBrandImage from '#/components/SystemBrandImage/index.vue';
|
import { useBaseStore } from '#/store';
|
import { resolveBrandAssetUrl } from '#/utils/systemBrand';
|
|
import LoginForm from './LoginForm.vue';
|
// import LoginFormTitle from './LoginFormTitle.vue';
|
|
const baseStore = useBaseStore();
|
const globSetting = useGlobSetting();
|
const loading = ref<boolean>(false);
|
const loadedBackgroundUrl = ref('');
|
|
const getSysConfig = computed(() => baseStore.getSysConfig);
|
const configuredBackgroundUrl = computed(() => resolveBrandAssetUrl(getSysConfig.value.loginBackground, globSetting.apiURL));
|
const loginBackgroundStyle = computed<CSSProperties | undefined>(() =>
|
loadedBackgroundUrl.value ? { backgroundImage: `url(${JSON.stringify(loadedBackgroundUrl.value)})` } : undefined,
|
);
|
|
watch(
|
configuredBackgroundUrl,
|
(url, _oldUrl, onCleanup) => {
|
loadedBackgroundUrl.value = '';
|
if (!url) return;
|
|
const image = new Image();
|
let active = true;
|
image.addEventListener('load', () => active && (loadedBackgroundUrl.value = url), { once: true });
|
image.addEventListener('error', () => active && (loadedBackgroundUrl.value = ''), { once: true });
|
image.src = url;
|
onCleanup(() => (active = false));
|
},
|
{ immediate: true },
|
);
|
|
function changeLoading(boo = false) {
|
loading.value = !!boo;
|
}
|
</script>
|
<template>
|
<div class="jnpf-login-container" v-loading="loading" :style="loginBackgroundStyle">
|
<!-- <div class="login-version" v-if="getSysConfig && getSysConfig.sysVersion">
|
<p class="login-version-text">{{ getSysConfig.sysVersion }}</p>
|
</div> -->
|
<div class="login-header">
|
<SystemBrandImage class="login-company-logo-img -enter-x" type="login" />
|
</div>
|
<div class="login-content-wrapper">
|
<div class="login-content">
|
<!-- <div class="login-left hidden xl:block">
|
<LoginFormTitle class="-enter-x" />
|
<img class="login-banner -enter-x" :src="banner" />
|
</div> -->
|
<div class="jnpf-login-container-form enter-x h-[620px] xl:h-full">
|
<!-- <LoginFormTitle class="-enter-x xl:hidden" /> -->
|
<LoginForm @change-loading="changeLoading" />
|
</div>
|
</div>
|
<div class="copyright">{{ getSysConfig.copyright }}</div>
|
</div>
|
</div>
|
</template>
|
<style lang="scss">
|
@use './index.scss' as *;
|
</style>
|