<template>
    <div class="loading">
        <div class="loading-wrap">
            <div class="loading-dots">
                <span class="dot dot-spin">
                    <i /><i /><i /><i />
                </span>
            </div>
            <div class="loading-title">系统加载中</div>
        </div>
    </div>
</template>

<script setup>
import { onMounted } from 'vue'
import { getTopUrl } from '~uti/tools'
import router from '~src/router/index'
import config from '~src/config/index'

//使用新登录页的域名和端口
let newDomain = []

//渲染完成
onMounted(() => {
    const domains = config.domains, port = config.ports
    const currentDomain = getTopUrl()
    //把http和https加进去
    newDomain = []
    for (let i = 0; i < domains.length; i++) {
        newDomain.push('http://' + domains[i])
        newDomain.push('https://' + domains[i])
    }
    //判断端口和域名
    try {
        const urls = currentDomain.split(':')
        if (urls.length >= 3 && port.indexOf(urls[2]) !== -1) {
            router.push({ name: 'new-login' })
        } else if (newDomain.indexOf(currentDomain) !== -1) {
            router.push({ name: 'new-login' })
        } else {
            router.push({ name: 'login' })
        }
    } catch (e) {
        router.push({ name: 'login' })
    }
})
</script>
