Skip to content

Commit 9f9a1fd

Browse files
committed
feat(home): 默认显示主页内容并初始化搜索
- 移除主页初始隐藏样式 - 页面加载时自动显示主页内容 - 初始化时对主页执行自动搜索 - 隐藏除主页外的其他标签页内容 - 添加主页标签的自动搜索功能入口
1 parent 32714ad commit 9f9a1fd

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

file_classification_webapi/static/js/main.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,21 @@ function initTabs() {
7979
// 存储已打开的标签页
8080
const openedTabs = new Set();
8181

82+
// 页面加载时只显示首页内容
83+
const homeTab = document.getElementById('home');
84+
if (homeTab) {
85+
homeTab.style.display = 'block';
86+
// 主页也需要执行一次搜索以显示默认数据
87+
autoSearch('home');
88+
}
89+
90+
// 隐藏除主页外的所有标签页内容
91+
tabContents.forEach(content => {
92+
if (content.id !== 'home') {
93+
content.style.display = 'none';
94+
}
95+
});
96+
8297
navLinks.forEach(link => {
8398
link.addEventListener('click', function (e) {
8499
e.preventDefault();
@@ -123,6 +138,9 @@ function initTabs() {
123138
// 根据当前tab自动执行搜索
124139
function autoSearch(tabName) {
125140
switch (tabName) {
141+
case 'home':
142+
// 主页可能需要执行某些初始化操作
143+
break;
126144
case 'files':
127145
if (typeof listFilesByFilter === 'function') {
128146
listFilesByFilter();

file_classification_webapi/static/partials/home.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- 系统主页 -->
2-
<section class="tab-content" id="home" style="display: none;">
2+
<section class="tab-content" id="home">
33
<h2>文件分类系统说明</h2>
44

55
<div class="documentation">

0 commit comments

Comments
 (0)