nankai-cms-website-gov/utils/sitemap.js

31 lines
714 B
JavaScript
Raw Permalink Normal View History

2025-03-13 09:52:18 +08:00
import axios from 'axios'
export default {
// 缓存时间为一天
cacheMaxAgeSeconds: 60 * 60 * 24,
// 自动检测最后更新时间
autoLastmod: true,
// 排除的链接
exclude: [],
// 发起请求获取链接
urls: async () => {
return await axios.post(`${import.meta.env.VITE_API_URL}/search`, {
page: 1,
capacity: 100,
model: ''
})
.then(res => {
if (res.data.code !== 200) {
throw new Error(res.data.message)
}
// 循环构建地址
return res.data.data.articlePage.records.map(article => {
return `/article/${article.uid}`
})
})
.catch(e => {
console.error(e)
})
}
}