更新小程序配置,重构页面结构,删除不再使用的地址管理和章节页面,优化项目结构以提升可维护性;调整全局样式,增强组件的可复用性和一致性。

This commit is contained in:
2026-02-03 11:35:38 +08:00
parent d74410cfb5
commit a7d781a25b
79 changed files with 10610 additions and 3518 deletions

View File

@@ -1,69 +0,0 @@
const app = getApp()
Page({
data: {
statusBarHeight: 44,
navBarHeight: 88,
query: '',
results: [],
keywords: [],
isLoading: false,
hotKeywords: ['私域', '流量', '赚钱', '电商', 'AI', '社群']
},
onLoad() {
const statusBarHeight = app.globalData.statusBarHeight || 44
const navBarHeight = app.globalData.navBarHeight || (statusBarHeight + 44)
this.setData({ statusBarHeight, navBarHeight })
},
onInput(e) {
const query = (e.detail && e.detail.value) || ''
this.setData({ query })
if (!query.trim()) {
this.setData({ results: [], keywords: [] })
return
}
this.debounceSearch(query)
},
_searchTimer: null,
debounceSearch(query) {
if (this._searchTimer) clearTimeout(this._searchTimer)
this._searchTimer = setTimeout(() => this.doSearch(query), 300)
},
doSearch(q) {
if (!q || !q.trim()) return
this.setData({ isLoading: true })
app.request('/api/search?q=' + encodeURIComponent(q.trim()) + '&type=all')
.then((res) => {
const results = (res && res.data && res.data.results) ? res.data.results : []
const keywords = (res && res.data && res.data.keywords) ? res.data.keywords : []
this.setData({ results, keywords, isLoading: false })
})
.catch(() => {
this.setData({ results: [], keywords: [], isLoading: false })
})
},
onKeywordTap(e) {
const keyword = e.currentTarget.dataset.keyword
this.setData({ query: keyword })
this.doSearch(keyword)
},
clearQuery() {
this.setData({ query: '', results: [], keywords: [] })
},
goToRead(e) {
const id = e.currentTarget.dataset.id
if (!id) return
wx.navigateTo({ url: '/pages/read/read?id=' + encodeURIComponent(id) })
},
goBack() {
wx.navigateBack({ fail: () => wx.switchTab({ url: '/pages/index/index' }) })
}
})

View File

@@ -1,4 +0,0 @@
{
"navigationBarTitleText": "搜索",
"usingComponents": {}
}

View File

@@ -1,67 +0,0 @@
<view class="page">
<view class="nav-bar" style="height: {{navBarHeight || (statusBarHeight + 44)}}px; padding-top: {{statusBarHeight || 44}}px; box-sizing: border-box;">
<view class="nav-inner safe-header-right">
<view class="nav-back" bindtap="goBack">← 返回</view>
<text class="nav-title">搜索</text>
</view>
</view>
<view class="search-box">
<view class="search-input-wrap">
<text class="search-icon">🔍</text>
<input class="search-input" placeholder="搜索章节标题或内容..." value="{{query}}" bindinput="onInput" focus="{{true}}" />
<view class="search-clear" wx:if="{{query}}" bindtap="clearQuery">×</view>
</view>
</view>
<scroll-view class="result-area" scroll-y>
<block wx:if="{{!query}}">
<view class="hot-section">
<text class="hot-label">热门搜索</text>
<view class="hot-tags">
<view class="hot-tag" wx:for="{{hotKeywords}}" wx:key="*this" data-keyword="{{item}}" bindtap="onKeywordTap">{{item}}</view>
</view>
</view>
</block>
<block wx:elif="{{isLoading}}">
<view class="loading-wrap">
<view class="loading-spinner"></view>
<text class="loading-text">搜索中...</text>
</view>
</block>
<block wx:elif="{{results.length > 0}}">
<view class="result-header">找到 {{results.length}} 个结果</view>
<view class="result-list">
<view class="result-item" wx:for="{{results}}" wx:key="id" data-id="{{item.id}}" bindtap="goToRead">
<view class="result-icon">📄</view>
<view class="result-body">
<view class="result-meta">
<text class="result-id">{{item.id}}</text>
<text class="tag-free" wx:if="{{item.isFree}}">免费</text>
<text class="tag-content" wx:if="{{item.matchType === 'content'}}">内容匹配</text>
</view>
<text class="result-title">{{item.title}}</text>
<text class="result-snippet" wx:if="{{item.snippet}}">{{item.snippet}}</text>
<text class="result-path" wx:if="{{item.partTitle}}">{{item.partTitle}} · {{item.chapterTitle}}</text>
</view>
<text class="result-arrow"></text>
</view>
</view>
<view class="keywords-section" wx:if="{{keywords.length > 0}}">
<text class="keywords-label">相关标签</text>
<view class="keywords-tags">
<view class="keyword-tag" wx:for="{{keywords}}" wx:for-item="kw" wx:key="*this" wx:if="{{kw}}" data-keyword="{{kw}}" bindtap="onKeywordTap">#{{kw}}</view>
</view>
</view>
</block>
<block wx:elif="{{query && !isLoading}}">
<view class="empty-wrap">
<text class="empty-icon">🔍</text>
<text class="empty-text">未找到相关内容</text>
<text class="empty-hint">试试其他关键词</text>
</view>
</block>
</scroll-view>
</view>

View File

@@ -1,40 +0,0 @@
.page { min-height: 100vh; background: #000; display: flex; flex-direction: column; }
.nav-bar { background: #1c1c1e; border-bottom: 2rpx solid rgba(255,255,255,0.05); box-sizing: border-box; display: flex; flex-direction: column; justify-content: flex-end; }
.nav-inner { display: flex; align-items: center; padding: 0 24rpx; height: 88rpx; min-height: 44px; flex-shrink: 0; }
.nav-back { font-size: 32rpx; color: #00CED1; padding: 16rpx 0; }
.nav-title { flex: 1; text-align: center; font-size: 34rpx; color: #fff; }
.search-box { padding: 24rpx; border-bottom: 2rpx solid rgba(255,255,255,0.05); }
.search-input-wrap { display: flex; align-items: center; padding: 24rpx 32rpx; background: #2c2c2e; border-radius: 24rpx; border: 2rpx solid rgba(255,255,255,0.05); }
.search-icon { font-size: 32rpx; margin-right: 16rpx; opacity: 0.6; }
.search-input { flex: 1; font-size: 28rpx; color: #fff; }
.search-clear { font-size: 40rpx; color: rgba(255,255,255,0.5); padding: 0 16rpx; }
.result-area { flex: 1; height: 0; }
.hot-section { padding: 32rpx; }
.hot-label { font-size: 24rpx; color: rgba(255,255,255,0.4); display: block; margin-bottom: 24rpx; }
.hot-tags { display: flex; flex-wrap: wrap; gap: 16rpx; }
.hot-tag { padding: 16rpx 24rpx; font-size: 24rpx; color: rgba(255,255,255,0.8); background: #2c2c2e; border-radius: 32rpx; }
.loading-wrap { padding: 80rpx; text-align: center; }
.loading-spinner { width: 48rpx; height: 48rpx; border: 4rpx solid rgba(0,206,209,0.3); border-top-color: #00CED1; border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 24rpx; }
.loading-text { font-size: 28rpx; color: rgba(255,255,255,0.5); }
@keyframes spin { to { transform: rotate(360deg); } }
.result-header { padding: 24rpx 32rpx; font-size: 24rpx; color: rgba(255,255,255,0.4); border-bottom: 2rpx solid rgba(255,255,255,0.05); }
.result-list { }
.result-item { display: flex; align-items: flex-start; padding: 32rpx; border-bottom: 2rpx solid rgba(255,255,255,0.05); }
.result-icon { width: 64rpx; height: 64rpx; border-radius: 16rpx; background: rgba(0,206,209,0.1); display: flex; align-items: center; justify-content: center; font-size: 32rpx; margin-right: 24rpx; flex-shrink: 0; }
.result-body { flex: 1; min-width: 0; }
.result-meta { display: flex; align-items: center; gap: 16rpx; margin-bottom: 8rpx; }
.result-id { font-size: 24rpx; color: #00CED1; font-family: monospace; }
.tag-free { font-size: 20rpx; padding: 4rpx 12rpx; border-radius: 6rpx; background: rgba(0,206,209,0.1); color: #00CED1; }
.tag-content { font-size: 20rpx; padding: 4rpx 12rpx; border-radius: 6rpx; background: rgba(123,97,255,0.1); color: #7B61FF; }
.result-title { font-size: 28rpx; color: #fff; font-weight: 500; display: block; margin-bottom: 4rpx; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-snippet { font-size: 24rpx; color: rgba(255,255,255,0.5); display: block; margin-bottom: 4rpx; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.result-path { font-size: 22rpx; color: rgba(255,255,255,0.3); }
.result-arrow { font-size: 32rpx; color: rgba(255,255,255,0.3); margin-left: 16rpx; }
.keywords-section { padding: 32rpx; border-top: 2rpx solid rgba(255,255,255,0.05); }
.keywords-label { font-size: 24rpx; color: rgba(255,255,255,0.4); display: block; margin-bottom: 16rpx; }
.keywords-tags { display: flex; flex-wrap: wrap; gap: 16rpx; }
.keyword-tag { font-size: 24rpx; color: rgba(255,255,255,0.5); padding: 8rpx 16rpx; background: #2c2c2e; border-radius: 8rpx; }
.empty-wrap { padding: 80rpx; text-align: center; }
.empty-icon { font-size: 80rpx; display: block; margin-bottom: 24rpx; opacity: 0.5; }
.empty-text { font-size: 28rpx; color: rgba(255,255,255,0.5); display: block; }
.empty-hint { font-size: 24rpx; color: rgba(255,255,255,0.3); margin-top: 8rpx; display: block; }