feat: 新增图片资源及组件功能优化

style: 调整CSS样式及修复链接样式问题

refactor: 重构item-head和item-bottom组件逻辑

fix: 修复section-index页面导航链接问题

perf: 优化滚动加载及URL参数处理

docs: 更新组件文档及注释

test: 添加组件测试用例

build: 更新依赖配置

chore: 清理无用代码及资源
This commit is contained in:
DESKTOP-RQ919RC\Pc
2025-10-29 19:01:33 +08:00
parent 7d81e02d3d
commit c9c34feaf2
35 changed files with 4456 additions and 130 deletions

View File

@@ -1,20 +1,35 @@
const { createApp, ref, onMounted, nextTick, onUnmounted, computed, watch } = Vue;
const { createApp, ref, onMounted, nextTick, onUnmounted, computed, watch, provide } = Vue;
import { itemForum } from "../component/item-forum/item-forum.js";
const appSectionIndex = createApp({
setup() {
let signInAlreadyState = ref(false);
onMounted(() => {
const params = getUrlParams();
section.value = params.section || "";
getSectionList();
init();
handpick();
getTags();
getList();
window.addEventListener("scroll", handleScroll);
});
const handleScroll = () => {
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
const scrollHeight = document.documentElement.scrollHeight;
const clientHeight = document.documentElement.clientHeight;
// 列表下 滑动到底部 获取新数据
if (scrollTop + clientHeight >= scrollHeight - 40) getList();
};
let sectionList = ref([]);
let section = ref("Lz9aimSLXeim");
let section = ref("");
const getSectionList = () => {
ajaxget("/v2/api/forum/getSectionList").then((res) => {
@@ -101,7 +116,6 @@ const appSectionIndex = createApp({
count.value = data.count;
loading = false;
console.log(list.value[0]);
})
.catch((err) => {
console.log("err", err);
@@ -112,7 +126,68 @@ const appSectionIndex = createApp({
});
};
return { signInAlreadyState, sectionList, section, info, handpickList, tagsList, list };
onMounted(() => getUserInfoWin());
let isLogin = ref(true);
let realname = ref(1); // 是否已经实名
let userInfoWin = ref({});
const getUserInfoWin = () => {
const checkUser = () => {
const user = window.userInfoWin;
if (!user) return;
document.removeEventListener("getUser", checkUser);
realname.value = user.realname;
userInfoWin.value = user;
if (user?.uin > 0 || user?.uid > 0) isLogin.value = true;
};
document.addEventListener("getUser", checkUser);
};
const openAttest = () => {
const handleAttestClose = () => {
document.removeEventListener("closeAttest", handleAttestClose);
realname.value = window.userInfoWin?.realname || 0;
};
// 启动认证流程时添加监听
document.addEventListener("closeAttest", handleAttestClose);
loadAttest(2);
};
// 跳转登录
const goLogin = () => {
if (typeof window === "undefined") return;
if (window["userInfoWin"] && Object.keys(window["userInfoWin"]).length !== 0) {
if (window["userInfoWin"]["uid"]) isNeedLogin.value = false;
else ajax_login();
} else ajax_login();
};
provide("isLogin", isLogin);
provide("userInfoWin", userInfoWin);
provide("realname", realname);
provide("openAttest", openAttest);
provide("goLogin", goLogin);
const changeSection = (uniqid) => {
section.value = uniqid;
handpickList.value = [];
info.value = {};
tagsList.value = [];
count.value = 0;
page.value = 1;
list.value = [];
init();
handpick();
getTags();
getList();
updateUrlParams({ section: uniqid });
};
return { changeSection, signInAlreadyState, sectionList, section, info, handpickList, tagsList, list, count };
},
});
appSectionIndex.component("item-forum", itemForum);