feat: 添加访问统计模块
This commit is contained in:
17
Yi.BBS.Vue3/src/apis/accessApi.js
Normal file
17
Yi.BBS.Vue3/src/apis/accessApi.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import request from '@/utils/request'
|
||||
// 触发访问
|
||||
export function access() {
|
||||
return request({
|
||||
url: '/access-log',
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 获取本周数据
|
||||
export function getWeek() {
|
||||
return request({
|
||||
url: '/access-log/week',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
@@ -8,30 +8,34 @@ import { LineChart } from 'echarts/charts';
|
||||
import { UniversalTransition } from 'echarts/features';
|
||||
import { CanvasRenderer } from 'echarts/renderers';
|
||||
import { ref ,onMounted} from 'vue';
|
||||
|
||||
import { getWeek } from '@/apis/accessApi.js'
|
||||
echarts.use([GridComponent, LineChart, CanvasRenderer, UniversalTransition]);
|
||||
|
||||
const VisitsLineChart=ref(null);
|
||||
|
||||
onMounted(()=>{
|
||||
onMounted(async()=>{
|
||||
var myChart = echarts.init(VisitsLineChart.value, null, {
|
||||
width: 320,
|
||||
height: 230
|
||||
});
|
||||
var option;
|
||||
|
||||
const response=await getWeek();
|
||||
|
||||
var numberData=response.data.map(x=>x.number);
|
||||
|
||||
option = {
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
||||
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
series: [
|
||||
{
|
||||
data: [82, 93, 90, 93, 129, 133, 132],
|
||||
data: numberData,
|
||||
type: 'line',
|
||||
areaStyle: {}
|
||||
}
|
||||
|
||||
@@ -103,6 +103,7 @@ import AvatarInfo from '@/components/AvatarInfo.vue'
|
||||
import BottomInfo from '@/components/BottomInfo.vue'
|
||||
import VisitsLineChart from '@/components/echars/VisitsLineChart.vue'
|
||||
|
||||
import { access } from '@/apis/accessApi.js'
|
||||
import { getList } from '@/apis/plateApi.js'
|
||||
import { getList as bannerGetList } from '@/apis/bannerApi.js'
|
||||
import { getList as discussGetList } from '@/apis/discussApi.js'
|
||||
@@ -121,6 +122,7 @@ const query = reactive({
|
||||
|
||||
//初始化
|
||||
onMounted(async () => {
|
||||
await access();
|
||||
plateList.value = (await getList()).data.items;
|
||||
discussList.value = (await discussGetList(query)).data.items;
|
||||
bannerList.value = (await bannerGetList()).data.items
|
||||
|
||||
Reference in New Issue
Block a user