<?php
namespace core_next;
global $core_next_set;
if ($core_next_set['home_post_list_cache']) {
    $forced_update = Theme::getCanUpdateCache('home_post_list_cache');
    $post_list = Theme::Cache('home_post_list_query', function () {
        return WordPress::getPostList();
    }, $forced_update);
} else {
    $post_list = WordPress::getPostList();
}
$post_list = Theme::handleRandomThumbnail($post_list);
$arr['plane_name'] = 'div';
$arr['plane_class_name'] = 'post-list';
$cat_list = WordPress::getCatInfoList($core_next_set['home_post_list_id']);

?>
<div class="post-list-warp">
    <div class="box-title-warp post-list-tab-warp">
        <div class="cat-list">
            <div class="cat-item" :class="{'tab-active':tab_index===0}" @click="changeTab(0)">
                最新文章
            </div>
            <?php
            foreach ($cat_list as $index => $item) {
                ?>
                <div class="cat-item" :class="{'tab-active':tab_index===<?php echo $index + 1; ?>}"
                     @click="changeTab(<?php echo $index + 1; ?>)"
                >
                    <?php echo $item['name'] ?>
                </div>
                <?php
            }
            ?>
        </div>
    </div>

    <div class="cat-plane" v-show="tab_index===0">
        <?php Template::echoListTemplateHtmlByDOMDocument('post-item', $post_list, $arr, 'home_post_list_0'); ?>
    </div>
    <?php
    foreach ($cat_list as $index => $item) {
        ?>
        <div class="cat-plane" v-show="tab_index===<?php echo $index + 1; ?>">
            <div class="post-list" ref="home_post_list_<?php echo $index + 1; ?>">
            </div>
        </div>
        <?php
    }
    ?>
    <div class="list-footer">
        <button class="cp-btn load-more" @click="loadMorePost" ref="load_more_btn"><i class="el-icon-refresh-right"
                                                                                      :class="{'loading':loading.load_more_post}"></i>
            加载更多
        </button>
    </div>
</div>