Files
Yi.Admin/Yi.Bbs.Vue3/src/views/home/Index.vue

439 lines
12 KiB
Vue
Raw Normal View History

2023-12-14 10:15:23 +08:00
<template>
2023-12-20 21:52:42 +08:00
<div class="home-box">
2023-12-14 10:15:23 +08:00
<el-row :gutter="20" class="top-div">
<el-col :span="17">
<div class="scrollbar">
<ScrollbarInfo />
</div>
<el-row class="left-div">
<el-col
:span="8"
v-for="i in plateList"
:key="i.id"
2023-12-14 10:15:23 +08:00
class="plate"
:style="{
'padding-left': i % 3 == 1 ? 0 : 0.2 + 'rem',
'padding-right': i % 3 == 0 ? 0 : 0.2 + 'rem',
}"
>
<PlateCard
:name="i.name"
:introduction="i.introduction"
:id="i.id"
2023-12-20 23:29:55 +08:00
:isPublish="i.isDisableCreateDiscuss"
2023-12-14 10:15:23 +08:00
/>
</el-col>
<template v-if="isDiscussFinished">
<el-col :span="24" v-for="i in discussList" :key="i.id">
<DisscussCard :discuss="i" />
</el-col>
</template>
<template v-else>
<Skeleton :isBorder="true" />
</template>
<template v-if="isAllDiscussFinished">
<el-col :span="24" v-for="i in allDiscussList" :key="i.id">
2023-12-26 23:18:27 +08:00
<DisscussCard :discuss="i" />
</el-col>
</template>
<template v-else>
<Skeleton :isBorder="true" />
</template>
2023-12-14 10:15:23 +08:00
</el-row>
</el-col>
<el-col :span="7">
<el-row class="right-div">
<el-col :span="24">
<el-carousel trigger="click" height="150px">
<el-carousel-item v-for="item in bannerList" :key="item.id">
2023-12-14 10:15:23 +08:00
<div class="carousel-font" :style="{ color: item.color }">
{{ item.name }}
</div>
<el-image
style="width: 100%; height: 100%"
:src="item.logo"
fit="cover"
/>
</el-carousel-item>
</el-carousel>
</el-col>
<div class="analyse">
<div class="item">
<div class="text">在线人数</div>
<div class="content">
<div class="name"></div>
<div class="content-box top">
2024-01-06 12:45:14 +08:00
<div class="count">{{ onlineNumber }}</div>
</div>
</div>
</div>
<div class="item">
<div class="text">注册人数</div>
<div class="content">
<div class="content-box top">
<div class="count">{{ userAnalyseInfo.registerNumber }}</div>
</div>
</div>
</div>
<div class="item">
<div class="text">昨日新增</div>
<div class="content">
<div class="content-box">
<div class="count">
{{ userAnalyseInfo.yesterdayNewUser }}
</div>
</div>
</div>
</div>
</div>
2024-01-11 23:51:09 +08:00
<!-- 签到 -->
<el-col :span="24">
2024-01-13 17:20:57 +08:00
<InfoCard header="每日签到">
2024-01-11 23:51:09 +08:00
<template #content>
<div class="signIn">
2024-01-13 17:20:57 +08:00
<div class="left">你好很高兴今天又遇到你</div>
2024-01-11 23:51:09 +08:00
<div class="right">
<div class="signIn-btn" @click="handleToSign">去签到</div>
</div>
</div>
</template>
</InfoCard>
</el-col>
2023-12-14 10:15:23 +08:00
<el-col :span="24">
<InfoCard header="访问统计" class="VisitsLineChart" text="详情">
<template #content>
<VisitsLineChart :option="statisOptions" class="statisChart" />
</template>
</InfoCard>
</el-col>
<el-col :span="24">
<InfoCard header="简介" text="详情">
<template #content>
<div class="introduce">
没有什么能够阻挡人类对代码<span style="color: #1890ff"
>优雅</span
>的追求
</div>
</template>
</InfoCard>
</el-col>
2023-12-14 10:15:23 +08:00
<el-col :span="24">
<template v-if="isPointFinished">
<InfoCard
:items="pointList"
2024-01-15 15:44:55 +08:00
header="财富排行榜"
text="关于钱钱"
height="400"
>
<template #item="temp">
<PointsRanking :pointsData="temp" />
</template>
</InfoCard>
</template>
<template v-else>
<InfoCard header="本月排行" text="更多">
<template #content> <Skeleton /></template>
</InfoCard>
</template>
2023-12-14 10:15:23 +08:00
</el-col>
<el-col :span="24">
<template v-if="isFriendFinished">
<InfoCard
:items="friendList"
header="推荐好友"
text="更多"
height="400"
>
<template #item="temp">
<RecommendFriend :friendData="temp" />
</template>
</InfoCard>
</template>
<template v-else>
<InfoCard header="推荐好友" text="更多">
<template #content> <Skeleton /></template>
</InfoCard>
</template>
2023-12-14 10:15:23 +08:00
</el-col>
2023-12-25 23:37:36 +08:00
<el-col :span="24">
<template v-if="isThemeFinished">
<InfoCard
:items="themeList"
header="推荐主题"
text="更多"
height="400"
>
<template #item="temp">
<ThemeData :themeData="temp" />
</template>
</InfoCard>
</template>
<template v-else>
<InfoCard header="推荐主题" text="更多">
<template #content> <Skeleton /></template>
</InfoCard>
</template>
2023-12-25 23:37:36 +08:00
</el-col>
2023-12-14 10:15:23 +08:00
<el-col :span="24" style="background: transparent">
<BottomInfo />
</el-col>
</el-row>
</el-col>
</el-row>
</div>
</template>
<script setup>
2024-01-04 21:37:35 +08:00
import { onMounted, ref, reactive, computed, nextTick, watch } from "vue";
2024-01-11 23:51:09 +08:00
import { useRouter } from "vue-router";
2023-12-14 10:15:23 +08:00
import DisscussCard from "@/components/DisscussCard.vue";
import InfoCard from "@/components/InfoCard.vue";
import PlateCard from "@/components/PlateCard.vue";
import ScrollbarInfo from "@/components/ScrollbarInfo.vue";
import BottomInfo from "@/components/BottomInfo.vue";
2023-12-25 22:27:15 +08:00
import VisitsLineChart from "./components/VisitsLineChart/index.vue";
2023-12-14 10:15:23 +08:00
import { access } from "@/apis/accessApi.js";
import { getList } from "@/apis/plateApi.js";
import { getList as bannerGetList } from "@/apis/bannerApi.js";
2023-12-20 21:14:55 +08:00
import { getHomeDiscuss } from "@/apis/discussApi.js";
2023-12-14 10:15:23 +08:00
import { getWeek } from "@/apis/accessApi.js";
2023-12-25 23:37:36 +08:00
import {
getRecommendedTopic,
getRecommendedFriend,
getRankingPoints,
getUserAnalyse,
2023-12-25 23:37:36 +08:00
} from "@/apis/analyseApi.js";
2023-12-26 23:18:27 +08:00
import { getList as getAllDiscussList } from "@/apis/discussApi.js";
2023-12-25 22:27:15 +08:00
import PointsRanking from "./components/PointsRanking/index.vue";
2023-12-25 22:50:04 +08:00
import RecommendFriend from "./components/RecommendFriend/index.vue";
2023-12-25 23:37:36 +08:00
import ThemeData from "./components/RecommendTheme/index.vue";
import Skeleton from "@/components/Skeleton/index.vue";
2024-01-06 12:45:14 +08:00
import useSocketStore from "@/stores/socket";
2024-01-15 00:25:25 +08:00
2024-01-04 21:37:35 +08:00
2024-01-11 23:51:09 +08:00
const router = useRouter();
2024-01-15 00:25:25 +08:00
2023-12-14 10:15:23 +08:00
2023-12-25 22:27:15 +08:00
const plateList = ref([]);
const discussList = ref([]);
const isDiscussFinished = ref(false);
2023-12-25 22:27:15 +08:00
const bannerList = ref([]);
2023-12-14 10:15:23 +08:00
const weekList = ref([]);
2023-12-25 22:27:15 +08:00
const pointList = ref([]);
const isPointFinished = ref(false);
2023-12-25 22:50:04 +08:00
const friendList = ref([]);
const isFriendFinished = ref(false);
2023-12-25 23:37:36 +08:00
const themeList = ref([]);
2024-01-09 21:46:09 +08:00
const isThemeFinished = ref(false);
2023-12-26 23:18:27 +08:00
const allDiscussList = ref([]);
const isAllDiscussFinished = ref(false);
const userAnalyseInfo = ref({});
2024-01-06 12:45:14 +08:00
const onlineNumber = ref(0);
2023-12-14 10:15:23 +08:00
//主题查询参数
const query = reactive({
skipCount: 1,
maxResultCount: 10,
isTop: true,
});
//初始化
onMounted(async () => {
access();
const { data: plateData } = await getList();
plateList.value = plateData.items;
const { data: discussData, config: discussConfig } = await getHomeDiscuss();
2023-12-20 21:14:55 +08:00
discussList.value = discussData;
isDiscussFinished.value = discussConfig.isFinish;
2023-12-14 10:15:23 +08:00
const { data: bannerData } = await bannerGetList();
bannerList.value = bannerData.items;
const { data: weekData } = await getWeek();
weekList.value = weekData;
const { data: pointData, config: pointConfig } = await getRankingPoints();
2023-12-25 22:27:15 +08:00
pointList.value = pointData;
isPointFinished.value = pointConfig.isFinish;
const { data: friendData, config: friendConfig } =
await getRecommendedFriend();
2023-12-25 22:50:04 +08:00
friendList.value = friendData;
isFriendFinished.value = friendConfig.isFinish;
const { data: themeData, config: themeConfig } = await getRecommendedTopic();
2023-12-25 23:37:36 +08:00
themeList.value = themeData;
isThemeFinished.value = themeConfig.isFinish;
const { data: allDiscussData, config: allDiscussConfig } =
await getAllDiscussList({
Type: 0,
skipCount: 1,
maxResultCount: 30,
});
isAllDiscussFinished.value = allDiscussConfig.isFinish;
2023-12-26 23:18:27 +08:00
allDiscussList.value = allDiscussData.items;
const { data: userAnalyseInfoData } = await getUserAnalyse();
2024-01-06 12:45:14 +08:00
onlineNumber.value = userAnalyseInfoData.onlineNumber;
userAnalyseInfo.value = userAnalyseInfoData;
2023-12-14 10:15:23 +08:00
});
2023-12-16 17:47:44 +08:00
const weekXAxis = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"];
2023-12-14 10:15:23 +08:00
// 访问统计
const statisOptions = computed(() => {
return {
xAxis: {
2023-12-16 17:47:44 +08:00
data: weekList.value.map((item, index) => {
return weekXAxis.filter((v, vIndex) => {
return vIndex === index;
})[0];
}),
2023-12-14 10:15:23 +08:00
},
series: {
data: weekList.value.map((item) => item.number),
},
};
});
2024-01-06 12:45:14 +08:00
2024-01-11 23:51:09 +08:00
const handleToSign = () => {
2024-01-25 20:32:01 +08:00
router.push("/activity/sign");
2024-01-11 23:51:09 +08:00
};
2024-01-06 12:45:14 +08:00
// 推送的实时人数获取
const currentOnlineNum = computed(() => useSocketStore().getOnlineNum());
watch(
() => currentOnlineNum.value,
(val) => {
onlineNumber.value = val;
},
{ deep: true }
2024-01-06 12:45:14 +08:00
);
2024-01-15 00:25:25 +08:00
2023-12-14 10:15:23 +08:00
</script>
2023-12-20 21:52:42 +08:00
<style scoped lang="scss">
.home-box {
2023-12-24 16:07:13 +08:00
width: 1300px;
2023-12-20 21:52:42 +08:00
height: 100%;
.introduce {
color: rgba(0, 0, 0, 0.45);
font-size: small;
}
.plate {
background: transparent !important;
}
.left-div .el-col {
background-color: #ffffff;
margin-bottom: 1rem;
}
.right-div .el-col {
background-color: #ffffff;
margin-bottom: 1rem;
}
.carousel-font {
position: absolute;
z-index: 1;
top: 10%;
left: 10%;
}
.top-div {
padding-top: 0.5rem;
}
.scrollbar {
display: block;
margin-bottom: 0.5rem;
}
.analyse {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
height: 100px;
margin-bottom: 10px;
.item {
width: 30%;
height: 100%;
position: relative;
background: url("@/assets/box/online_bg.svg") no-repeat;
background-color: #fff;
background-position: 0 30px;
background-size: 150% 100%;
border: 1px solid #409eff;
border-radius: 5px;
color: #409eff;
.content {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
&-box {
width: 100%;
display: flex;
align-items: center;
justify-content: flex-start;
justify-content: center;
margin-bottom: 10px;
.name {
font-size: 14px;
}
.count {
font-size: 20px;
font-weight: bold;
}
}
}
.text {
width: 60px;
position: absolute;
top: -10px;
left: 50%;
transform: translateX(-50%);
font-size: 12px;
text-align: center;
border: 1px solid #d9ecff;
border-radius: 5px;
color: #409eff;
background-color: #ecf5ff;
}
}
}
2024-01-11 23:51:09 +08:00
.signIn {
display: flex;
justify-content: space-between;
align-items: center;
color: #8a919f;
&-btn {
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
width: 74px;
height: 36px;
border-radius: 4px;
border: 1px solid rgba(30, 128, 255, 0.3);
background-color: rgba(30, 128, 255, 0.1);
color: #1e80ff;
}
}
2023-12-20 21:52:42 +08:00
.VisitsLineChart >>> .el-card__body {
padding: 0.5rem;
}
.statisChart {
width: 100%;
height: 300px;
}
2023-12-14 10:15:23 +08:00
}
</style>