feat: 体验优化——探索/趋势页下拉刷新、触感反馈工具函数
- pages.json: 探索/趋势页开启 enablePullDownRefresh - 新增 utils/haptics.js: 关键操作轻震动反馈(仅微信端) - 探索页接入 onPullDownRefresh 重新拉取趋势数据
This commit is contained in:
@@ -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()
|
||||
})
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user