fix(component): 修复组件名称错误和props类型定义
refactor(component): 重构组件模板结构,移除重复代码 feat(component): 添加可选props支持外部数据传入 style(css): 优化样式布局和响应式设计 fix(js): 修复URL路径处理逻辑和滚动加载问题 feat(search): 新增搜索页推荐内容和空状态处理 chore: 添加新图标资源文件
This commit is contained in:
26
js/public.js
26
js/public.js
@@ -401,11 +401,29 @@ let copyForumUid = (text) => {
|
||||
const updateUrlLastPath = (newLastPath, isReplace = false) => {
|
||||
const raw = typeof newLastPath === "string" ? newLastPath : String(newLastPath);
|
||||
const basePath = raw.split("?")[0];
|
||||
const newPathname = basePath.startsWith("/") ? basePath : "/" + basePath;
|
||||
|
||||
let finalPathname = "";
|
||||
if (basePath.startsWith("/")) {
|
||||
finalPathname = basePath;
|
||||
} else {
|
||||
const oldPathSegments = window.location.pathname.split("/").filter(Boolean);
|
||||
const newPathSegments = oldPathSegments.slice(0, -1); // 移除原最后一段
|
||||
if (basePath) {
|
||||
newPathSegments.push(basePath); // 添加新最后一段
|
||||
}
|
||||
finalPathname = "/" + newPathSegments.join("/");
|
||||
}
|
||||
|
||||
// 拼接完整URL
|
||||
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 newUrl = window.location.origin + finalPathname + newSearch;
|
||||
|
||||
// 管理历史栈 + 修改URL
|
||||
if (isReplace) {
|
||||
history.replaceState(null, document.title, newUrl);
|
||||
} else {
|
||||
history.pushState(null, document.title, newUrl);
|
||||
}
|
||||
};
|
||||
|
||||
const removeQueryQ = (isReplace = false) => {
|
||||
|
||||
Reference in New Issue
Block a user