fix(bi): 添加投币数量必须大于0的校验

feat(item-bottom): 实现二维码弹窗自适应右侧边界
添加判断逻辑使二维码弹窗在靠近右侧边界时向左弹出

refactor(public.js): 优化ajax请求配置和登录跳转逻辑
统一设置axios默认配置,提取登录跳转函数

style(public.css): 调整QRcode-box.right的定位
修复二维码弹窗靠近右侧时的显示问题

fix(details.js): 修复粗体标记正则匹配多行内容
使用[\s\S]*?匹配可能的多行内容

refactor(index.js): 优化列表加载和滚动逻辑
移除模拟数据,添加加载状态,调整滚动加载阈值

chore: 更新html模板中的唯一标识和广告类名
This commit is contained in:
DESKTOP-RQ919RC\Pc
2025-11-19 19:27:43 +08:00
parent f49d937f19
commit c9e229a5cd
12 changed files with 211 additions and 217 deletions

View File

@@ -1,9 +1,11 @@
const forumBaseURL = "https://api.gter.net";
axios.defaults.withCredentials = true;
axios.defaults.emulateJSON = true;
// 导出ajax函数
const ajax = (url, data) => {
if (location.hostname == "127.0.0.1") axios.defaults.headers.common["Authorization"] = "erhvky91rk23vx7xiutj34db82kjb1vc";
axios.defaults.withCredentials = true;
axios.defaults.emulateJSON = true;
url = url.indexOf("https://") > -1 ? url : forumBaseURL + url;
return new Promise(function (resolve, reject) {
@@ -17,26 +19,51 @@ const ajax = (url, data) => {
if (data.code == 401) {
// 需要登录
showWindow("login", "https://passport.gter.net/login/ajax", "get", -1, {
cover: true,
});
go_ajax_Login();
reject();
}
resolve(data);
})
.catch((err) => {
reject();
if (err.response?.status == 401)
showWindow("login", "https://passport.gter.net/login/ajax", "get", -1, {
cover: true,
});
reject();
if (err.response?.status == 401) go_ajax_Login();
});
});
};
const ajaxdelete = (url, data) => {
axios.defaults.withCredentials = true;
axios.defaults.emulateJSON = true;
url = url.indexOf("https://") > -1 ? url : forumBaseURL + url;
return new Promise(function (resolve, reject) {
axios
.delete(url, {
emulateJSON: true,
withCredentials: true,
data,
})
.then(function (res) {
var data = typeof res.data == "string" ? JSON.parse(res.data) : res.data;
if (data.code == 401) {
// 需要登录
go_ajax_Login();
reject();
}
resolve(data);
})
.catch((err) => {
reject();
if (err.response?.status == 401) go_ajax_Login();
});
});
};
// 导出ajaxGet函数
const ajaxGet = (url) => {
if (location.hostname == "127.0.0.1") axios.defaults.headers.common["Authorization"] = "erhvky91rk23vx7xiutj34db82kjb1vc";
axios.defaults.withCredentials = true;
axios.defaults.emulateJSON = true;
url = url.indexOf("https://") > -1 ? url : forumBaseURL + url;
return new Promise(function (resolve, reject) {
@@ -53,9 +80,7 @@ const ajaxGet = (url) => {
var data = typeof res.data == "string" ? JSON.parse(res.data) : res.data;
if (data.code == 401) {
// 需要登录
showWindow("login", "https://passport.gter.net/login/ajax", "get", -1, {
cover: true,
});
go_ajax_Login();
reject();
}
resolve(data);
@@ -153,61 +178,6 @@ const timeago = (dateTimeStamp, type = 1) => {
return result;
};
const creationAlertBox = (type = "success", text) => {
if (!text) return;
const pathObj = {
success: `<path fill="currentColor" d="M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm-55.808 536.384-99.52-99.584a38.4 38.4 0 1 0-54.336 54.336l126.72 126.72a38.272 38.272 0 0 0 54.336 0l262.4-262.464a38.4 38.4 0 1 0-54.272-54.336L456.192 600.384z"></path>`,
error: `<path fill="currentColor" d="M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 393.664L407.936 353.6a38.4 38.4 0 1 0-54.336 54.336L457.664 512 353.6 616.064a38.4 38.4 0 1 0 54.336 54.336L512 566.336 616.064 670.4a38.4 38.4 0 1 0 54.336-54.336L566.336 512 670.4 407.936a38.4 38.4 0 1 0-54.336-54.336L512 457.664z"></path>`,
};
const colorObj = {
success: {
border: "#e1f3d8",
color: "#67c23a",
background: "#f0f9eb",
},
error: {
border: "#fde2e2",
color: "#f56c6c",
background: "#fef0f0",
},
};
if (!pathObj[type]) type = "success"; // 判断存不存在 给个默认值
const box = document.createElement("div");
box.style.position = "fixed";
box.style.zIndex = "10003";
box.style.top = "-51px";
box.style.left = "50%";
box.style.border = `${colorObj[type].border} 1px solid`;
box.style.color = colorObj[type].color;
box.style.background = colorObj[type].background;
box.style.display = "flex";
box.style.alignItems = "center";
box.style.fontSize = "14px";
box.style.padding = "15px 19px";
box.style.borderRadius = "4px";
box.style.transition = "0.5s";
box.style.transform = "translateX(-50%)";
const svg = `<svg style="width: 16px;height: 16px;margin-right: 10px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">${pathObj[type]}</svg>`;
box.innerHTML = `${svg}${text || "默认提示文本"}`;
document.body.appendChild(box);
setTimeout(() => {
box.style.top = 20 + "px";
setTimeout(() => {
box.style.top = -51 + "px";
setTimeout(() => {
box.remove();
}, 2000);
}, 2000);
}, 1);
};
const managerHide = (token, state, type = "offer") => {
return new Promise((resolve, reject) => {
const obj = {
@@ -277,6 +247,24 @@ const managerEssence = (token, state) => {
});
};
// 删除
const managerDelete = (token) => {
return new Promise((resolve, reject) => {
const post = () => {
ajaxdelete(`/v2/api/forum/deleteTopic`, {
token,
}).then((res) => {
creationAlertBox("success", res.message || "");
resolve();
});
};
const isConfirmed = confirm(`确定要删除吗?`);
if (!isConfirmed) reject();
else post();
});
};
const getUrlParams = () => {
const params = {};
const queryString = window.location.search.slice(1);
@@ -317,25 +305,27 @@ const updateUrlParams = (params, replace = false) => {
};
// 跳转 url
const redirectToExternalWebsite = (url) => {
const redirectToExternalWebsite = (url, target = "_blank") => {
const link = document.createElement("a");
link.href = url;
link.target = "_blank";
link.target = target;
link.click();
};
// 点击ta的主页
const goHomePage = (uin) => {
redirectToExternalWebsite(`https://bbs.gter.net/home.php?mod=space&uid=${uin}`);
const goHomePage = (token) => {
if (!token) return;
redirectToExternalWebsite(`/u/${token}`);
};
// 点击发送信息
const goSendMessage = (uin) => {
if (uin && typeof messagePrivateItem == "function") {
messagePrivateItem({ uin: uin });
const goSendMessage = (token) => {
if (typeof messagePrivateItem == "function") {
messagePrivateItem({ token });
return;
}
redirectToExternalWebsite(`https://bbs.gter.net/home.php?mod=space&showmsg=1&uid=${uin}`);
goHomePage(token);
};
const lang = {
@@ -363,14 +353,14 @@ const lang = {
rentalduration: { 1: "1个月", 2: "2个月", 3: "3个月", 4: "4个月", 5: "5个月", 6: "6个月", 7: "7个月", 8: "8个月", 9: "9个月", 10: "10个月", 11: "11个月", 12: "1年", 13: "1年1个月", 14: "1年2个月", 15: "1年3个月", 16: "1年4个月", 17: "1年5个月", 18: "1年6个月", 24: "2年", 36: "3年" },
};
let copyUid = (text) => {
let copyForumUid = (text) => {
if (navigator.clipboard)
copyUid = () => {
copyForumUid = () => {
navigator.clipboard.writeText(text);
creationAlertBox("success", "复制成功");
};
else {
copyUid = () => {
copyForumUid = () => {
var tempInput = document.createElement("input");
tempInput.value = text;
document.body.appendChild(tempInput);
@@ -380,5 +370,33 @@ let copyUid = (text) => {
creationAlertBox("success", "复制成功");
};
}
copyUid();
copyForumUid();
};
const updateUrlLastPath = (newLastPath, isReplace = false) => {
const raw = typeof newLastPath === "string" ? newLastPath : String(newLastPath);
const basePath = raw.split("?")[0];
const newPathname = basePath.startsWith("/") ? basePath : "/" + basePath;
const newSearch = window.location.search;
const newUrl = window.location.origin + newPathname + newSearch;
if (isReplace) history.replaceState(null, document.title, newUrl);
else history.pushState(null, document.title, newUrl);
};
const removeQueryQ = (isReplace = false) => {
const params = new URLSearchParams(window.location.search);
if (!params.has("q")) return;
params.delete("q");
const qs = params.toString();
const newUrl = window.location.origin + window.location.pathname + (qs ? "?" + qs : "") + window.location.hash;
if (isReplace) history.replaceState(null, document.title, newUrl);
else history.pushState(null, document.title, newUrl);
};
// 跳转登录
const go_ajax_Login = () => {
console.log("go_ajax_Login");
if (typeof ajax_login === "function") ajax_login();
else window.open("https://passport.gter.net/?referer=" + escape(location.href), "_self");
};