<template>
    <div class="topNews">
        <div class="newsTitle">今日头条</div>
        <div class="newsContent">
            <div class="newsScrollWrapper">
                <div class="newsItem">
                    <a href="#">十四届全国人大常委会第十九次会议举行第二次全体会议 审议执法检查报告、专项工作报告等 赵乐际出席会议</a>
                </div>
                <div class="newsItem">
                    <a href="#">最高检调研组在四川调研</a>
                </div>
                <div class="newsItem">
                    <a href="#">辽宁高院深入学习贯彻中央经济工作会议精神</a>
                </div>
                <div class="newsItem">
                    <a href="#">省检察院召开党组（扩大）会议 传达学习中央经济工作会议精神</a>
                </div>
                <!-- 重复一遍，实现无缝滚动 -->
                <div class="newsItem">
                    <a href="#">十四届全国人大常委会第十九次会议举行第二次全体会议 审议执法检查报告、专项工作报告等 赵乐际出席会议</a>
                </div>
                <div class="newsItem">
                    <a href="#">最高检调研组在四川调研</a>
                </div>
                <div class="newsItem">
                    <a href="#">辽宁高院深入学习贯彻中央经济工作会议精神</a>
                </div>
                <div class="newsItem">
                    <a href="#">省检察院召开党组（扩大）会议 传达学习中央经济工作会议精神</a>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
//0.加载必备依赖 start ---------------------------------------->
import { ref, onMounted } from "vue"
const nuxtApp = useNuxtApp();
const axios = nuxtApp.$axios;

const getLinkPathDetail = (item) => {
    if (item.islink == 1) {
        return `${item.linkurl}`;
    } else {
        return `/${item.pinyin}/${item.id}.html`;
    }
}
//0.加载必备依赖 end ---------------------------------------->

//1.获得板块数据 start ---------------------------------------->
//大标题
const headlinelist = ref([])
//大标题下面的二级内容
const headlinelist1 = ref([])

async function getModelData1() {
    const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
        method: 'GET',
        query: {
            'imgnum': 0,
            'textnum': 3,
            'level': 1,
            'placeid': 0,
            'id': ''
        },
    });
    if (mkdata.code == 200) {
        for (let index in mkdata.data.text) {
            if (index < 1) {
                headlinelist.value.push(mkdata.data.text[index])
            } else {
                headlinelist1.value.push(mkdata.data.text[index])
            }
        }

    } else {
        console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
        console.log("错误位置：设置大标题")
        console.log("后端错误反馈：", mkdata.message)
        console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
    }
}
getModelData1()

const hotNewsList = ref("")
async function getModelData3() {
    const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
        method: 'GET',
        query: {
            'imgnum': 0,
            'textnum': 8,
            'level': 6,
            'placeid': 0,
            'id': ''
        },
    });
    if (mkdata.code == 200) {
        hotNewsList.value = mkdata.data.text;
    } else {
        // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
        // console.log("错误位置：获取首页今日热点")
        // console.log("后端错误反馈：", mkdata.message)
        // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
    }
}
getModelData3()
//1.获得板块数据 end ---------------------------------------->
</script>

<style lang="less" scoped>
// >1400px
@media screen and (min-width: 1401px) {
    .topNews {
        width: 1400PX;
        height: 40PX;
        overflow: hidden;
        border: dashed 1PX #eed0d0;
        margin: 20PX auto;
        position: relative;
        padding-top: 4PX;
        box-sizing: border-box;


        .newsTitle {
            position: absolute;
            top: 5PX;
            left: -2PX;
            width: 91PX;
            height: 29PX;
            line-height: 29PX;
            background: url("../../public/index/titleIcon.jpg") no-repeat center center;
            color: #fff;
            font-size: 16PX;
            padding-left: 13PX;
            box-sizing: border-box;
        }

        .newsContent {
            width: 1250PX;
            height: 32PX;
            line-height: 32PX;
            box-sizing: border-box;
            font-size: 15PX;
            color: #000;
            position: relative;
            overflow: hidden;
            margin-left: 120PX;

            .newsScrollWrapper {
                position: absolute;
                display: flex;
                /* 让新闻条目横向排列 */
                white-space: nowrap;
                animation: scroll 60s linear infinite;
                left: 0;
                top: 0;

                .newsItem {
                    text-align: center;
                    white-space: nowrap;
                    /* 单条新闻不换行 */
                    margin-right: 20PX;
                    /* 新闻之间的间距，可调整 */
                    flex-shrink: 0;
                    /* 关键：防止新闻条目被挤压变形 */

                    a {
                        display: inline-block;
                        color: #333;
                        padding: 0 10PX;
                        box-sizing: border-box;
                    }

                    a:hover {
                        color: #f00;
                        /* 可选：鼠标悬停变色 */
                    }
                }
            }

            @keyframes scroll {
                0% {
                    transform: translateX(0);
                    /* 初始位置 */
                }

                100% {
                    transform: translateX(-50%);
                    /* 滚动到第二份列表的起始位置，刚好衔接 */
                }
            }
        }

        .newsContent:hover .newsScrollWrapper {
            animation-play-state: paused;
        }
    }
}

// 801px-1400px
@media screen and (min-width: 801px) and (max-width: 1400px) {
    .topNews {
        width: 100%;
        height: 40PX;
        overflow: hidden;
        border: dashed 1PX #eed0d0;
        margin: 20PX auto;
        position: relative;
        padding-top: 4PX;
        box-sizing: border-box;


        .newsTitle {
            position: absolute;
            top: 5PX;
            left: -2PX;
            width: 91PX;
            height: 29PX;
            line-height: 29PX;
            background: url("../../public/index/titleIcon.jpg") no-repeat center center;
            color: #fff;
            font-size: 16PX;
            padding-left: 13PX;
            box-sizing: border-box;
        }

        .newsContent {
            width: 88%;
            height: 32PX;
            line-height: 32PX;
            box-sizing: border-box;
            font-size: 15PX;
            color: #000;
            position: relative;
            overflow: hidden;
            margin-left: 120PX;

            .newsScrollWrapper {
                position: absolute;
                display: flex;
                /* 让新闻条目横向排列 */
                white-space: nowrap;
                animation: scroll 60s linear infinite;
                left: 0;
                top: 0;

                .newsItem {
                    text-align: center;
                    white-space: nowrap;
                    /* 单条新闻不换行 */
                    margin-right: 20PX;
                    /* 新闻之间的间距，可调整 */
                    flex-shrink: 0;
                    /* 关键：防止新闻条目被挤压变形 */

                    a {
                        display: inline-block;
                        color: #333;
                        padding: 0 10PX;
                        box-sizing: border-box;
                    }

                    a:hover {
                        color: #f00;
                        /* 可选：鼠标悬停变色 */
                    }
                }
            }

            @keyframes scroll {
                0% {
                    transform: translateX(0);
                    /* 初始位置 */
                }

                100% {
                    transform: translateX(-50%);
                    /* 滚动到第二份列表的起始位置，刚好衔接 */
                }
            }
        }

        .newsContent:hover .newsScrollWrapper {
            animation-play-state: paused;
        }
    }
}

//  <=800px
@media screen and (max-width: 800px) {
    .topNews {
        display: none;
    }
}
</style>