feat: 新增签到功能模块并优化详情页样式

- 添加签到功能相关HTML/CSS/JS文件
- 在详情页增加图片预览组件
- 调整详情页文本行高和标题样式
- 修复评论时间显示问题
- 优化本地开发环境授权处理
This commit is contained in:
DESKTOP-RQ919RC\Pc
2025-11-21 19:07:03 +08:00
parent 40d06c180f
commit f73a662141
11 changed files with 508 additions and 26 deletions

View File

@@ -89,8 +89,6 @@ const appSectionIndex = createApp({
const checkWConfig = () => {
const wConfig = JSON.parse(localStorage.getItem("wConfig")) || {};
console.log("wConfig", wConfig);
if (wConfig.time) {
const time = new Date(wConfig.time);
const now = new Date();
@@ -127,10 +125,11 @@ const appSectionIndex = createApp({
const data = res.data;
let targetInfo = data.info;
console.log("data", data);
if (!targetInfo.hidden) targetInfo.hidden = 0;
targetInfo.content = '如果你热爱古典文献,又希望在现代职场大展身手——这个项目可能就是你的“本命”!作为香港最正统的中国语言文学项目,它既传承经典,又为你打跨境传播等全新赛道!\n\n<b>🌟 项目核心亮点</b>权威认证:中国语言文学专业认证,考公考编无障碍\n古今结合深耕古典文献与理论同时对接AI内容创作等新兴领域\n语言友好全程中文授课普通话+粤语),无语言适应压力\n规模可观每年录取150+,机会相对较多\n\n点击前往 [港校项目库] 查看 \n<a href="https://program.gter.net/details/tf1yFYIBSda7Y5k7s9iHeLVSxDiuYTljNA~~" target="_blank" contenteditable="false">中国语言文学</a>\n手机扫码查看\n[attachimg]1008942[/attachimg]\n\n<b>🎯 谁最适合申请?</b>中文系、汉语言、古代文学等对口专业背景\n希望在教育、传媒、AI内容或国际中文教育领域发展\n看重学校声誉与专业正统性的同学\n<b>💼 毕业出路超多元</b>除了教师、公务员等传统路径,毕业生还活跃于:\n✔ 跨境文化传播\n✔ AI内容策划与生成\n✔ 国际中文教育\n✔ 出版与编辑行业\n<b>📌 申请指南</b>专业背景:严格限定中文相关专业,暂不接受跨专业申请\n成绩要求985/211同学建议86+\n语言成绩雅思7.0小分5.5)即可\n面试体验氛围轻松专业问题较少\n<b>💡 内部消息参考</b>前几轮拿到面试邀请的同学基本都能录取\n985背景优势明显建议尽早提交申请\n双非同学如背景特别匹配也可尝试\n<b>🤝 欢迎交流</b>你对中国文学在AI时代的发展有什么想法或者对哪个就业方向申请问题欢迎在评论区分享交流\n欢迎加入寄托香港群交流\n\n[attachimg]969489[/attachimg]';
// 替换换行
targetInfo.content = targetInfo.content?.replace(/\n/g, "<br>") || "";
@@ -177,6 +176,9 @@ const appSectionIndex = createApp({
let html = formattedText;
html = html.replaceAll('<b>', "[b]");
html = html.replaceAll('</b>', "[/b]");
// 1. 还原换行符为<br>标签
html = html.replace(/\n/g, "<br>");
@@ -190,6 +192,8 @@ const appSectionIndex = createApp({
// 4. 还原粗体标记为h2标签
html = html.replace(/\[b\]([\s\S]*?)\[\/b\]/gi, "<h2>$1</h2>");
console.log(html);
// 5. 统一在单次遍历中按出现顺序替换 attach/attachimg
const byAid = new Map();
imageList.forEach((e) => byAid.set(Number(e.aid), { type: "image", ...e }));
@@ -214,7 +218,7 @@ const appSectionIndex = createApp({
html = html.replace(/(<span class="blue">[^<]+<\/span>)\s+/gi, '$1 <span class="fill"></span> ');
// 7. 清理多余的<br>标签
html = html.replace(/<br><br>/g, "<br>");
// html = html.replace(/<br><br>/g, "<br>");
if (type != "comment") {
byAid.forEach((item, aid) => {
@@ -271,8 +275,6 @@ const appSectionIndex = createApp({
actions: ["like", "collection"],
})
.then((res) => {
console.log("res", res);
const data = res.data;
const like = data.like;
const collection = data.collection;
@@ -418,7 +420,6 @@ const appSectionIndex = createApp({
let commentTotalCount = ref(0);
const getComment = () => {
console.log("commentPage.value", commentPage.value);
if (commentPage.value == 0 || isgetCommentSate || !token) return;
isgetCommentSate = true;
ajaxGet(`/v2/api/forum/getCommentList?token=${token}&page=${commentPage.value}&limit=20`)
@@ -439,7 +440,7 @@ const appSectionIndex = createApp({
if (element.child.length > 0) {
element.child.forEach((el) => {
el["picture"] = [];
el.timestamp = strtimeago(element.created_at, 4);
el.timestamp = strtimeago(el.created_at, 4);
el["isReplyBoxShow"] = 0;
if (el["content"]) el["content"] = restoreHtml(el["content"], el.attachments, "comment");
@@ -518,16 +519,7 @@ const appSectionIndex = createApp({
const handleAnswerText = (e) => {
if (e.target.tagName === "IMG") {
var src = e.target.getAttribute("src");
const div = document.createElement("div");
div.innerHTML = `<div class="detail-image flexcenter"><img class="detail-img" src="${src}" /></div>`;
div.className = "detail-image-mask flexcenter";
div.addEventListener("click", () => {
document.body.style.overflow = "auto";
div.remove();
});
document.body.appendChild(div);
document.body.style.overflow = "hidden";
previewImage.initComponent(src);
}
};
@@ -775,8 +767,6 @@ const appSectionIndex = createApp({
images: image,
};
console.log("userInfoWin", userInfoWin.value);
ajax("/v2/api/forum/postComment", {
content,
token,
@@ -872,12 +862,10 @@ const appSectionIndex = createApp({
let target = {};
if (i != null) target = list[index]["child"][i];
else target = list[index];
console.log("target", target);
editToken.value = target.token || "";
editInput.value = target.content || "";
editPicture.value = target.attachments?.images || [];
console.log("editCommentState", editPicture.value);
editCommentState.value = true;
};

View File

@@ -9,6 +9,8 @@ const ajax = (url, data) => {
url = url.indexOf("https://") > -1 ? url : forumBaseURL + url;
return new Promise(function (resolve, reject) {
if (location.hostname == "127.0.0.1") axios.defaults.headers.common["Authorization"] = "n1pstcsmw6m6bcx49z705xhvduqviw29";
axios
.post(url, data, {
emulateJSON: true,
@@ -67,6 +69,8 @@ const ajaxGet = (url) => {
url = url.indexOf("https://") > -1 ? url : forumBaseURL + url;
return new Promise(function (resolve, reject) {
if (location.hostname == "127.0.0.1") axios.defaults.headers.common["Authorization"] = "n1pstcsmw6m6bcx49z705xhvduqviw29";
axios
.get(
url,

63
js/signIn.js Normal file
View File

@@ -0,0 +1,63 @@
const { createApp, ref, onMounted, nextTick, onUnmounted, computed, watch, provide } = Vue;
const appSectionIndex = createApp({
setup() {
onMounted(() => {
console.log("signIn");
getFirstDay();
});
let dayOfWeek = ref(0); // 当月第一天是星期几
let totalDaysInMonth = ref(0); // 当月第一共今天
let currentDay = ref(0); // 今天几号
let showList = ref([]); // 展示的 签到列表
const getFirstDay = () => {
const firstDayOfMonth = new Date();
firstDayOfMonth.setDate(1);
// 获取当月第一天是星期几0 表示星期日1 表示星期一,依此类推)
dayOfWeek.value = firstDayOfMonth.getDay();
const currentDate = new Date();
const currentMonth = currentDate.getMonth() + 1;
const currentYear = currentDate.getFullYear();
currentDay.value = currentDate.getDate();
// 获取当前月份的总天数
totalDaysInMonth.value = new Date(currentYear, currentMonth, 0).getDate();
init();
};
// 初始化
const init = () => {
ajaxGet("https://api.gter.net/v2/api/forum/getSignInfo").then((res) => {
if (res.code != 200) return;
console.log("res", res);
const data = res.data;
const list = data.list || {};
this.getDateList(list);
const issign = data.issign || 0;
if (issign == 1) wx.setStorageSync("signInState", util.getCurrentDate()); // 存储签到时间
this.setData({
tips: data.tips || [],
integral: Number(data.integral) || 0,
token: data.token || "",
signnum: data.signnum || 0,
signreward: data.signreward || 0,
issign,
});
console.log("integral", this.data.integral);
});
};
return { dayOfWeek };
},
});
appSectionIndex.mount("#signInBox");