no message

This commit is contained in:
A1300399510
2025-10-31 01:28:16 +08:00
parent d4244fc783
commit 91dab6d446
16 changed files with 639 additions and 218 deletions

View File

@@ -10,11 +10,51 @@ import { headTop } from "../component/head-top/head-top.js";
const appSectionIndex = createApp({
setup() {
onMounted(() => {
getUserInfoWin();
init();
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 isLogin = ref(true);
let realname = ref(1); // 是否已经实名
let userInfoWin = ref({
authority: ["comment.edit", "comment.delete", "offercollege.hide", "offersummary.hide", "mj.hide", "topic:manager", "topic:hide"],
avatar: "https://nas.gter.net:9008/avatar/97K4EWIMLrsbGTWXslC2WFVSEKWOikN42jDKLNjtax7HL4xtfMOJSdU9oWFhY2E~/middle?random=1761733169",
groupid: 3,
nickname: "肖荣豪",
realname: 1,
token: "01346a38444d71aaadb3adad52b52c39",
uid: 500144,
uin: 4238049,
});
let permissions = 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;
permissions.value = user?.authority || [];
};
document.addEventListener("getUser", checkUser);
};
const openAttest = () => {
const handleAttestClose = () => {
document.removeEventListener("closeAttest", handleAttestClose);
@@ -35,6 +75,7 @@ const appSectionIndex = createApp({
};
provide("isLogin", isLogin);
provide("userInfoWin", userInfoWin);
provide("realname", realname);
provide("openAttest", openAttest);
provide("goLogin", goLogin);
@@ -45,6 +86,7 @@ const appSectionIndex = createApp({
let medallist = ref([]);
let introduction = ref("");
let avatar = "";
const init = () => {
ajax(`/v2/api/forum/postUserDetail`)
.then((res) => {
@@ -63,12 +105,12 @@ const appSectionIndex = createApp({
info.value = data.info || {};
medallist.value = data.medal || [];
introduction.value = data?.urls?.introduction;
avatar = data?.info?.avatar || "";
getCount();
getList();
})
.catch(() => {});
getCollectList();
};
let createCount = ref(0);
@@ -189,30 +231,68 @@ const appSectionIndex = createApp({
let page = ref(1);
let total = ref(0);
const getCollectList = () => {
const limit = 10;
ajax("/v2/api/forum/postUserCollect", {
let loading = ref(false);
const getList = () => {
if (page.value == 0 || loading.value) return;
loading.value = true;
let url = `/v2/api/forum/postUserCollect`;
if (typeValue.value == "comment") url = `/v2/api/forum/postUserComment`;
if (typeValue.value == "like") url = `/v2/api/forum/postUserLike`;
if (typeValue.value == "footprint") url = `/v2/api/forum/postUserFootprint`;
ajax(url, {
page: page.value,
type: classify.value,
}).then((res) => {
if (res.code != 200) return;
const data = res.data || [];
console.log("data", data);
total.value = data.count;
list.value = [...list.value, ...data.data];
page.value = data.count > data.page * limit ? page.value + 1 : 0;
});
})
.then((res) => {
if (res.code != 200) return;
const data = res.data || [];
let targetList = data.data || [];
targetList.forEach((element) => element.comment_list?.forEach((ele) => (ele["avatar"] = avatar)));
total.value = data.count;
list.value = [...list.value, ...targetList];
page.value = list.value.length >= data.count ? 0 : page.value + 1;
})
.finally(() => (loading.value = false));
};
const cancelOperate = (token) => {
console.log("token", token);
// 取消操作后的删除
const cancelOperate = (type, token) => {
if (typeValue.value != type) return;
const index = list.value.findIndex((item) => item.token == token);
if (index == -1) return;
list.value.splice(index, 1);
total.value--;
};
provide("cancelOperate", cancelOperate);
const classifyChange = (type) => {
if (classify.value == type) return;
page.value = 1;
list.value = [];
total.value = 0;
classify.value = type;
getList();
};
const typeChange = (type) => {
if (typeValue.value == type) return;
typeValue.value = type;
page.value = 1;
list.value = [];
total.value = 0;
classify.value = "";
getList();
};
const copy = (text) => copyUid(text);
return { total, list, classifyList, classify, typeValue, typeList, creationType, gtercoin, info, medallist, schoolTags, introduction, copy };
return { typeChange, page, loading, classifyChange, total, list, classifyList, classify, typeValue, typeList, creationType, gtercoin, info, medallist, schoolTags, introduction, copy };
},
});

View File

@@ -25,6 +25,8 @@ const watchList = {
"../component/slideshow-box/slideshow-box.txt": "../component/slideshow-box/slideshow-box.js",
// 监听 head-top.txt同步到 head-top.js
"../component/head-top/head-top.txt": "../component/head-top/head-top.js",
// 监听 hot-tag.txt同步到 hot-tag.js
"../component/hot-tag/hot-tag.txt": "../component/hot-tag/hot-tag.js",
// 可添加更多文件(格式:'txt路径': 'js路径'
// './component/other/other.txt': './component/other/other.js',

View File

@@ -1,23 +1,71 @@
const { createApp, ref, onMounted, nextTick, onUnmounted, computed, watch, provide } = Vue;
import { itemForum } from "../component/item-forum/item-forum.js";
import { headTop } from "../component/head-top/head-top.js";
import { hotTag } from "../component/hot-tag/hot-tag.js";
const appSearch = createApp({
setup() {
onMounted(() => {
const params = getUrlParams();
const id = params.section || "";
if (id) {
section.value = id;
init();
}
section.value = id;
// init();
});
return {};
const classifyList = ref([
{
text: "全部",
type: "",
},
{
text: "帖子",
type: "thread",
},
{
text: "Offer",
type: "offer",
},
{
text: "总结",
type: "offer_summary",
},
{
text: "面经",
type: "interviewexperience",
},
{
text: "投票",
type: "vote",
},
{
text: "租房",
type: "tenement",
},
]);
let classify = ref("");
const classifyChange = (type) => {
if (classify.value == type) return;
classify.value = type;
};
let tabList = ref({
all: "全部",
thread: "论坛",
offer: "Offer",
offer_summary: "总结",
interviewexperience: "面经",
vote: "投票",
});
let tabValue = ref("all");
return { tabValue, tabList, classifyChange, classifyList, classify };
},
});
appSearch.component("item-forum", itemForum);
appSearch.mount("#sectionIndex");
appSearch.component("head-top", headTop);
appSearch.component("hot-tag", hotTag);
appSearch.mount("#search");