<template>
    <z-paging ref="paging" v-model="list" @query="handleQuery">
        <question-preview-list :list="list" hidden-delete/>
    </z-paging>
</template>

<script setup>
import {ref} from 'vue'
import QuestionPreviewList from "@/pages/topic-center/topic-collection/components/question-preview-list.vue";
import {favQuestions} from "@/api/webApi/webQue";
import {createPropDefine} from "@/utils";
import {useQuestionTranslate} from "@/components/mx-question/useQuestionTranslate";

const props = defineProps({
    subjectId: createPropDefine(0, [Number, String])
})

const list = ref([])
const paging = ref(null)

const handleQuery = function (pageNum, pageSize) {
    const params = {pageNum, pageSize, type: 'question', subjectId: props.subjectId}
    favQuestions(params)
        .then(res => {
            // 转成标准格式，以供mx-question-content/parse使用，以共享MathJax特性
            const rows = res.rows.map(useQuestionTranslate)
            paging.value.completeByTotal(rows, res.total)
        })
        .catch(e => paging.value.complete(false))
}
</script>

<style scoped>

</style>