提交 6eb32f0e authored 作者: lhh's avatar lhh

update

上级 c25d7120
...@@ -4,3 +4,8 @@ import httpRequest from '@/utils/axios' ...@@ -4,3 +4,8 @@ import httpRequest from '@/utils/axios'
export function getUtilData() { export function getUtilData() {
return httpRequest.get('/api/resource/v1/util/index') return httpRequest.get('/api/resource/v1/util/index')
} }
export function aa() {
return httpRequest.get('/api/otn/leftTicket/queryZ?leftTicketDTO.train_date=2023-04-28&leftTicketDTO.from_station=BJP&leftTicketDTO.to_station=DTV&purpose_codes=ADULT')
}
// https://kyfw.12306.cn/otn/leftTicket/queryZ?leftTicketDTO.train_date=2023-04-28&leftTicketDTO.from_station=BJP&leftTicketDTO.to_station=DTV&purpose_codes=ADULT
\ No newline at end of file
<script setup lang="ts"> <script setup lang="ts">
import Statistics from '../components/Statistics.vue' import { aa } from '../api'
import Newest from '../components/Newest.vue' aa().then(res => {
import Hottest from '../components/Hottest.vue' console.log(res, 'res')
import RecentLearning from '../components/RecentLearning.vue'
import { getUtilData } from '../api'
let flag = $ref(false)
const data = reactive<{ statistics: object[]; latest: object[]; hot: object[]; learn: object[] }>({
statistics: [],
latest: [],
hot: [],
learn: []
})
// 所有数据
getUtilData().then(res => {
flag = true
let { latest = [], hot = [], learn = [] }: { latest: object[]; hot: object[]; learn: object[] } = res.data
if (learn === null) learn = []
// 统计资源数据整合
const statisticsData = [
{ key: 'video_count', unit: '个', number: 0, text: '视频资源' },
{ key: 'courseware_count', unit: '个', number: 0, text: '课件资源' },
{ key: 'other_information_count', unit: '个', number: 0, text: '其他资料' },
{ key: 'question_count', unit: '个', number: 0, text: '题库资源' },
{ key: 'paper_count', unit: '套', number: 0, text: '试卷资源' },
{ key: 'memory_size', unit: '', number: 0, text: '资源总体量' },
{ key: 'length', unit: '小时', number: 0, text: '资源总时长' },
{ key: 'learn_times', unit: '人次', number: 0, text: '总学习人次' },
{ key: 'learn_time_length', unit: '小时', number: 0, text: '总学习时长' }
]
data.statistics = statisticsData.map((item: any) => {
item.number = res.data[item.key] || 0
return item
})
// 最近数据
data.latest =
latest.map((item: any, index: number) => {
item.index = index + 1
return item
}) || []
// 最热资源
data.hot =
hot.map((item: any, index: number) => {
item.index = index + 1
return item
}) || []
data.learn =
learn.map((item: any, index: number) => {
item.index = index + 1
return item
}) || []
}) })
// aa().then(res => {
// console.log(res, 'res')
// })
</script> </script>
<template> <template>
<div v-if="flag"> <div>111</div>
<AppCard title="资源统计">
<Statistics :data="data.statistics"></Statistics>
</AppCard>
<AppCard title="最新资源">
<Newest :data="data.latest"></Newest>
</AppCard>
<AppCard :data="data.hot" title="最热资源">
<Hottest :data="data.hot"></Hottest>
</AppCard>
<AppCard title="最近学习">
<RecentLearning :data="data.learn"></RecentLearning>
</AppCard>
</div>
</template> </template>
import { createRouter, createWebHistory } from 'vue-router' import { createRouter, createWebHistory } from 'vue-router'
import { useUserStore } from '@/stores/user' // import { useUserStore } from '@/stores/user'
const router = createRouter({ const router = createRouter({
history: createWebHistory(), history: createWebHistory(),
...@@ -7,17 +7,17 @@ const router = createRouter({ ...@@ -7,17 +7,17 @@ const router = createRouter({
}) })
router.beforeEach(async (to, from, next) => { router.beforeEach(async (to, from, next) => {
const whiteList = ['/401'] // const whiteList = ['/401']
const user = useUserStore() // const user = useUserStore()
if (!user.isLogin && !whiteList.includes(to.path)) { // if (!user.isLogin && !whiteList.includes(to.path)) {
try { // try {
await user.getUser() // await user.getUser()
} catch (e) { // } catch (e) {
console.error(e) // console.error(e)
} // }
user.isLogin ? next() : next('/401') // user.isLogin ? next() : next('/401')
return // return
} // }
next() next()
}) })
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论