<template>
    <div v-if="settingsStore.websiteInfo.show" style="display: flex;flex-wrap: wrap;padding-top: 5px;background-color: #fff;" :style="{justifyContent: settingsStore.websiteInfo.justify }">
        <template v-for="(info, index) in settingsStore.websiteInfo.otherInfo">
            <span style="padding-top: 3px;">
                <el-divider v-if="index>0" direction="vertical" />
                <el-link :href=info.url target="_blank" type="info" :underline="false">{{ info.name }}</el-link>
            </span>
        </template>
        <span id="container_ideConac" style="margin-left: 10px;"></span>
    </div>
    
</template>

<script setup lang="ts">
import { useSettingsStore } from "@/framework/store/modules/settings";

const settingsStore = useSettingsStore();
/**加载党政机关事业单位网站标识 */
const loadConac = () => {
    let conacUrl=settingsStore.websiteInfo.conacUrl.url;
    if(!conacUrl){
        return;
    }
    const container = document.getElementById('container_ideConac')
    if(!container){
        return;
    }
    const span = document.createElement('span')
    span.id = '_ideConac'
    const script = document.createElement('script')
    script.src = conacUrl
    script.type = 'text/javascript'
    script.async = true
    container.appendChild(span)
    container.appendChild(script)
   
    let count=0;
    let imgConacTimer=setInterval(function() {
         const img = document.getElementById('imgConac')
         if(img){
            img.style.width = settingsStore.websiteInfo.conacUrl.size?settingsStore.websiteInfo.conacUrl.size+'px':'30px';
            clearInterval(imgConacTimer);
         }
         count++;
         if(count==30){
            clearInterval(imgConacTimer);
         }
    }, 200);
}

onMounted(() => {
    if(!settingsStore.websiteInfo.show)
        return;
    loadConac();
});
</script>

<style scoped lang="scss">
</style>