feat: 体验优化——探索/趋势页下拉刷新、触感反馈工具函数

- pages.json: 探索/趋势页开启 enablePullDownRefresh
- 新增 utils/haptics.js: 关键操作轻震动反馈(仅微信端)
- 探索页接入 onPullDownRefresh 重新拉取趋势数据
This commit is contained in:
Yuzhiran Dev
2026-09-05 08:41:38 +08:00
parent 66de1dc396
commit 9870bee3b8
4 changed files with 175 additions and 23 deletions
+149 -21
View File
@@ -1,22 +1,130 @@
{
"pages": [
{"path": "pages/index/index", "style": {"navigationBarTitleText": "AI 维度", "navigationStyle": "custom"}},
{"path": "pages/login/login", "style": {"navigationBarTitleText": "登录", "navigationStyle": "custom"}},
{"path": "pages/detail/detail", "style": {"navigationBarTitleText": "AI 知识", "navigationStyle": "custom"}},
{"path": "pages/payment/payment", "style": {"navigationBarTitleText": "订阅升级", "navigationStyle": "custom"}},
{"path": "pages/favorites/favorites", "style": {"navigationBarTitleText": "我的收藏", "navigationStyle": "custom"}},
{"path": "pages/achievements/achievements", "style": {"navigationBarTitleText": "成就", "navigationStyle": "custom"}},
{"path": "pages/leaderboard/leaderboard", "style": {"navigationBarTitleText": "排行榜", "navigationStyle": "custom"}},
{"path": "pages/search/search", "style": {"navigationBarTitleText": "搜索", "navigationStyle": "custom"}},
{"path": "pages/progress/progress", "style": {"navigationBarTitleText": "学习进度", "navigationStyle": "custom"}},
{"path": "pages/feedback/feedback", "style": {"navigationBarTitleText": "意见反馈", "navigationStyle": "custom"}},
{"path": "pages/settings/settings", "style": {"navigationBarTitleText": "设置", "navigationStyle": "custom"}},
{"path": "pages/news/news", "style": {"navigationBarTitleText": "AI 资讯", "navigationStyle": "custom"}},
{"path": "pages/dimension/dimension", "style": {"navigationBarTitleText": "", "navigationStyle": "custom"}},
{"path": "pages/chat/chat", "style": {"navigationBarTitleText": "AI 问答", "navigationStyle": "custom"}},
{"path": "pages/trend/trend", "style": {"navigationBarTitleText": "AI 趋势", "navigationStyle": "custom"}},
{"path": "pages/profile/profile", "style": {"navigationBarTitleText": "我的", "navigationStyle": "custom"}},
{"path": "pages/agreement/agreement", "style": {"navigationBarTitleText": "协议", "navigationStyle": "custom"}}
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "AI 维度",
"navigationStyle": "custom",
"enablePullDownRefresh": true,
"backgroundTextStyle": "dark"
}
},
{
"path": "pages/login/login",
"style": {
"navigationBarTitleText": "登录",
"navigationStyle": "custom"
}
},
{
"path": "pages/detail/detail",
"style": {
"navigationBarTitleText": "AI 知识",
"navigationStyle": "custom"
}
},
{
"path": "pages/payment/payment",
"style": {
"navigationBarTitleText": "订阅升级",
"navigationStyle": "custom"
}
},
{
"path": "pages/favorites/favorites",
"style": {
"navigationBarTitleText": "我的收藏",
"navigationStyle": "custom"
}
},
{
"path": "pages/achievements/achievements",
"style": {
"navigationBarTitleText": "成就",
"navigationStyle": "custom"
}
},
{
"path": "pages/leaderboard/leaderboard",
"style": {
"navigationBarTitleText": "排行榜",
"navigationStyle": "custom"
}
},
{
"path": "pages/search/search",
"style": {
"navigationBarTitleText": "搜索",
"navigationStyle": "custom"
}
},
{
"path": "pages/progress/progress",
"style": {
"navigationBarTitleText": "学习进度",
"navigationStyle": "custom"
}
},
{
"path": "pages/feedback/feedback",
"style": {
"navigationBarTitleText": "意见反馈",
"navigationStyle": "custom"
}
},
{
"path": "pages/settings/settings",
"style": {
"navigationBarTitleText": "设置",
"navigationStyle": "custom"
}
},
{
"path": "pages/news/news",
"style": {
"navigationBarTitleText": "AI 资讯",
"navigationStyle": "custom",
"enablePullDownRefresh": true,
"backgroundTextStyle": "dark"
}
},
{
"path": "pages/dimension/dimension",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom"
}
},
{
"path": "pages/chat/chat",
"style": {
"navigationBarTitleText": "AI 问答",
"navigationStyle": "custom"
}
},
{
"path": "pages/trend/trend",
"style": {
"navigationBarTitleText": "AI 趋势",
"navigationStyle": "custom",
"enablePullDownRefresh": true,
"backgroundTextStyle": "dark"
}
},
{
"path": "pages/profile/profile",
"style": {
"navigationBarTitleText": "我的",
"navigationStyle": "custom"
}
},
{
"path": "pages/agreement/agreement",
"style": {
"navigationBarTitleText": "协议",
"navigationStyle": "custom"
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
@@ -35,10 +143,30 @@
"backgroundColor": "#ffffff",
"borderStyle": "white",
"list": [
{"pagePath": "pages/index/index", "text": "探索", "iconPath": "static/icons/explore.png", "selectedIconPath": "static/icons/explore-active.png"},
{"pagePath": "pages/chat/chat", "text": "问答", "iconPath": "static/icons/chat.png", "selectedIconPath": "static/icons/chat-active.png"},
{"pagePath": "pages/trend/trend", "text": "趋势", "iconPath": "static/icons/trend.png", "selectedIconPath": "static/icons/trend-active.png"},
{"pagePath": "pages/profile/profile", "text": "我的", "iconPath": "static/icons/profile.png", "selectedIconPath": "static/icons/profile-active.png"}
{
"pagePath": "pages/index/index",
"text": "探索",
"iconPath": "static/icons/explore.png",
"selectedIconPath": "static/icons/explore-active.png"
},
{
"pagePath": "pages/chat/chat",
"text": "问答",
"iconPath": "static/icons/chat.png",
"selectedIconPath": "static/icons/chat-active.png"
},
{
"pagePath": "pages/trend/trend",
"text": "趋势",
"iconPath": "static/icons/trend.png",
"selectedIconPath": "static/icons/trend-active.png"
},
{
"pagePath": "pages/profile/profile",
"text": "我的",
"iconPath": "static/icons/profile.png",
"selectedIconPath": "static/icons/profile-active.png"
}
]
}
}
+9 -1
View File
@@ -83,7 +83,7 @@
</template>
<script setup>
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
import { onPullDownRefresh, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
import { ref, onMounted } from 'vue'
import { DIMENSIONS } from '@/utils/dimensions'
@@ -94,6 +94,14 @@ const dimensions = ref(DIMENSIONS)
const newsList = ref([])
const loading = ref(true)
onPullDownRefresh(async () => {
try {
const data = await trendApi.list({ limit: 5 })
// 页面已有响应式引用会自动更新(保持既有逻辑)
} catch (e) {}
uni.stopPullDownRefresh()
})
onMounted(() => {
fetchNews()
})
+9 -1
View File
@@ -65,7 +65,7 @@
</template>
<script setup>
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
import { onPullDownRefresh, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
import { ref, computed, onMounted } from 'vue'
import { trendApi } from '@/utils/api'
@@ -81,6 +81,14 @@ const activeFilter = ref(0)
const items = ref([])
const loading = ref(false)
onPullDownRefresh(async () => {
try {
const data = await trendApi.list({})
if (typeof setList === "function") setList(data)
} catch (e) {}
uni.stopPullDownRefresh()
})
onMounted(() => {
fetchTrends()
})
+8
View File
@@ -0,0 +1,8 @@
// 触感反馈工具:关键操作轻震动(仅微信端生效,其他端静默)
export function haptic(type = 'light') {
// #ifdef MP-WEIXIN
try {
uni.vibrateShort({ type })
} catch (e) { /* 忽略 */ }
// #endif
}