刘光辉
2 小时以前 cf11e63b659afcc9792ab3e395f1b45d844431a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<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>