useContentModel
useContentExpandModel
::: warning 该业务模型未集成 API 接口请求,需要自己请求接口,处理数据后,使用提供的 transformModel 初始化模型。 :::
// 接口
import {
ajaxGetArticlePreAgentInfo,
ajaxGetContentInfo,
ajaxGetContentOtherInfo
} from '@/api/modules/detail'
// 页面模型
import useContentModel from '@jy/data-models/modules/article/model/content'
import useContentExpandModel from '@jy/data-models/modules/article/model/expand'
<script setup>
import { reactive, ref } from 'vue'
const AgentInfo = ref({
token: '',
baseToken: ''
})
const Content = reactive(useContentModel())
const ContentExpands = reactive(useContentExpandModel())
async function useContentStore() {
await ajaxGetArticlePreAgentInfo().then((res) => {
if (res?.error_code === 0 && res?.data) {
AgentInfo.value.token = res.data?.token
}
})
await ajaxGetContentInfo({ token: AgentInfo.value.token })
.then((res) => {
if (res.error_code === 0) {
AgentInfo.value.baseToken = res.data?.token
return res.data
}
})
.then(Content.transformModel)
await ajaxGetContentOtherInfo({ token: AgentInfo.value.baseToken })
.then((res) => {
ContentPageExpandsLoading.value = false
if (res.error_code === 0) {
return res.data
}
})
.then(ContentExpands.transformModel)
return {
useContentStore
}
}
<script>