style: 更新主题2.2
This commit is contained in:
@@ -28,7 +28,7 @@ onMounted(async () => {
|
|||||||
|
|
||||||
//如果登录了,再连接消息通知
|
//如果登录了,再连接消息通知
|
||||||
bbsNoticeSignalR();
|
bbsNoticeSignalR();
|
||||||
noticeSignalR();
|
noticeSignalR();
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,41 +4,41 @@ import useAuths from "@/hooks/useAuths";
|
|||||||
|
|
||||||
const { getToken } = useAuths();
|
const { getToken } = useAuths();
|
||||||
export default {
|
export default {
|
||||||
SR: {},
|
SR: {},
|
||||||
start(url,callFunc) {
|
start(url, callFunc) {
|
||||||
const connection = new signalR.HubConnectionBuilder()
|
const connection = new signalR.HubConnectionBuilder()
|
||||||
.withUrl(`${import.meta.env.VITE_APP_BASE_WS}/` + url, {
|
.withUrl(`${import.meta.env.VITE_APP_BASE_WS}/` + url, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${getToken()}`,
|
Authorization: `Bearer ${getToken()}`,
|
||||||
},
|
},
|
||||||
accessTokenFactory: () => {
|
accessTokenFactory: () => {
|
||||||
// 返回授权 token
|
// 返回授权 token
|
||||||
return `${getToken()}`;
|
return `${getToken()}`;
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
.withAutomaticReconnect(new ForeverRetryPolicy()) //自动重新连接
|
.withAutomaticReconnect(new ForeverRetryPolicy()) //自动重新连接
|
||||||
.configureLogging(signalR.LogLevel.Error)
|
.configureLogging(signalR.LogLevel.Error)
|
||||||
.build();
|
.build();
|
||||||
this.SR = connection;
|
this.SR = connection;
|
||||||
// 断线重连
|
// 断线重连
|
||||||
connection.onclose(() => {
|
connection.onclose(() => {
|
||||||
console.log("hub断开");
|
console.log("hub断开");
|
||||||
});
|
});
|
||||||
|
|
||||||
connection.onreconnected(() => {
|
connection.onreconnected(() => {
|
||||||
console.log("hub重新连接成功");
|
console.log("hub重新连接成功");
|
||||||
});
|
});
|
||||||
callFunc(connection);
|
callFunc(connection);
|
||||||
// 启动
|
// 启动
|
||||||
|
|
||||||
this.SR.start();
|
this.SR.start();
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
class ForeverRetryPolicy {
|
class ForeverRetryPolicy {
|
||||||
nextRetryDelayInMilliseconds(retryContext) {
|
nextRetryDelayInMilliseconds(retryContext) {
|
||||||
return 1000*3;
|
return 1000 * 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ margin: 10px auto;">
|
|||||||
:isPublish="i.isDisableCreateDiscuss"/>
|
:isPublish="i.isDisableCreateDiscuss"/>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<div ref="scrollableDiv" class="scrollable-div" v-infinite-scroll="loadDiscuss" style="height: 2500px;width: 100%;" infinite-scroll-distance="10">
|
<div ref="scrollableDiv" class="scrollable-div" style="width: 100%;">
|
||||||
|
|
||||||
<el-col v-if="isDiscussFinished" :span="24" v-for="i in discussList" :key="i.id">
|
<el-col v-if="isDiscussFinished" :span="24" v-for="i in discussList" :key="i.id">
|
||||||
<img v-if="isIcp" src="@/assets/login.png" style="height: 150px;width: 100%" alt=""/>
|
<img v-if="isIcp" src="@/assets/login.png" style="height: 150px;width: 100%" alt=""/>
|
||||||
@@ -106,7 +106,7 @@ margin: 10px auto;">
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 签到 -->
|
<!-- 签到 -->
|
||||||
<el-col v-if="!isIcp" :span="24">
|
<el-col v-if="!isIcp" :span="24" id="activeMenu">
|
||||||
<InfoCard header="活动">
|
<InfoCard header="活动">
|
||||||
<template #content>
|
<template #content>
|
||||||
<div class="top">与AI同行,创造无限可能</div>
|
<div class="top">与AI同行,创造无限可能</div>
|
||||||
@@ -196,7 +196,7 @@ margin: 10px auto;">
|
|||||||
</InfoCard>
|
</InfoCard>
|
||||||
</template>
|
</template>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col v-if="!isIcp" :span="24">
|
<el-col v-if="!isIcp" :span="24" id="themeMenu">
|
||||||
<template v-if="isThemeFinished">
|
<template v-if="isThemeFinished">
|
||||||
<InfoCard :isPadding="false" :items="themeList" header="推荐主题" text="更多" height="400"
|
<InfoCard :isPadding="false" :items="themeList" header="推荐主题" text="更多" height="400"
|
||||||
style="padding:0 20px"
|
style="padding:0 20px"
|
||||||
@@ -250,7 +250,7 @@ margin: 10px auto;">
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {onMounted, ref, reactive, computed, nextTick, watch} from "vue";
|
import {onMounted, onUnmounted, ref, reactive, computed, nextTick, watch} from "vue";
|
||||||
import {useRouter} from "vue-router";
|
import {useRouter} from "vue-router";
|
||||||
import DisscussCard from "@/components/DisscussCard.vue";
|
import DisscussCard from "@/components/DisscussCard.vue";
|
||||||
import InfoCard from "@/components/InfoCard.vue";
|
import InfoCard from "@/components/InfoCard.vue";
|
||||||
@@ -376,6 +376,12 @@ const init = async () => {
|
|||||||
//初始化
|
//初始化
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await init();
|
await init();
|
||||||
|
window.addEventListener('scroll', debouncedScrollHandler);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 组件卸载时移除事件监听器
|
||||||
|
onUnmounted(() => {
|
||||||
|
window.removeEventListener('scroll', debouncedScrollHandler);
|
||||||
});
|
});
|
||||||
|
|
||||||
const weekXAxis = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"];
|
const weekXAxis = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"];
|
||||||
@@ -477,16 +483,28 @@ const onClickAccessLog = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let loadingDiscuss = false;
|
let loadingDiscuss = false;
|
||||||
|
|
||||||
|
// 防抖函数
|
||||||
|
const debounce = (func, delay) => {
|
||||||
|
let timeoutId;
|
||||||
|
return (...args) => {
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
timeoutId = setTimeout(() => func.apply(this, args), delay);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
//加载滚动文章
|
//加载滚动文章
|
||||||
const loadDiscuss = async () => {
|
const loadDiscuss = async () => {
|
||||||
|
if (loadingDiscuss === false) {
|
||||||
if (loadingDiscuss === false) {
|
// if (loadingDiscuss === false && !isAllDiscussFinished.value) {
|
||||||
loadingDiscuss = true;
|
loadingDiscuss = true;
|
||||||
|
|
||||||
|
|
||||||
currentDiscussPageIndex.value += 1;
|
currentDiscussPageIndex.value += 1;
|
||||||
|
|
||||||
isAllDiscussFinished.value = false;
|
isAllDiscussFinished.value = false;
|
||||||
|
|
||||||
|
console.log("ccc");
|
||||||
|
|
||||||
const {data: allDiscussData, config: allDiscussConfig} =
|
const {data: allDiscussData, config: allDiscussConfig} =
|
||||||
await getAllDiscussList({Type: 0, skipCount: currentDiscussPageIndex.value, maxResultCount: 10});
|
await getAllDiscussList({Type: 0, skipCount: currentDiscussPageIndex.value, maxResultCount: 10});
|
||||||
isAllDiscussFinished.value = allDiscussConfig.isFinish;
|
isAllDiscussFinished.value = allDiscussConfig.isFinish;
|
||||||
@@ -494,12 +512,28 @@ const loadDiscuss = async () => {
|
|||||||
//在列表后新增
|
//在列表后新增
|
||||||
allDiscussList.value.push(...allDiscussData.items);
|
allDiscussList.value.push(...allDiscussData.items);
|
||||||
|
|
||||||
|
|
||||||
loadingDiscuss = false;
|
loadingDiscuss = false;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 检查是否滚动到底部
|
||||||
|
const checkScrollToBottom = () => {
|
||||||
|
const scrollTop = Math.ceil(window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop);
|
||||||
|
const clientHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
|
||||||
|
const scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
|
||||||
|
|
||||||
}
|
// 有滚动条的情况下,检查是否滚动到底部
|
||||||
|
// console.log(scrollTop,"scrollTop");
|
||||||
|
// console.log(clientHeight,"clientHeight");
|
||||||
|
// console.log(scrollHeight,"scrollHeight");
|
||||||
|
if (scrollTop + clientHeight >= scrollHeight -1 ) {
|
||||||
|
// console.log('触发加载更多');
|
||||||
|
loadDiscuss();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 防抖处理的滚动事件
|
||||||
|
const debouncedScrollHandler = debounce(checkScrollToBottom, 200);
|
||||||
const wechatDialogVisible = ref(false)
|
const wechatDialogVisible = ref(false)
|
||||||
//切换统计开关
|
//切换统计开关
|
||||||
const onClickWeekSwitch = async () => {
|
const onClickWeekSwitch = async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user