-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathpaginationStore.js
More file actions
33 lines (32 loc) · 1.16 KB
/
paginationStore.js
File metadata and controls
33 lines (32 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { defineStore } from 'pinia';
export const usePaginationStore = defineStore('pagination', {
state: () => ({
statsText: '', // 翻页统计文本
isVisible: false, // 是否显示统计信息
currentRoute: '', // 当前路由,用于判断是否显示
}),
actions: {
// 更新翻页统计信息
updateStats(text) {
this.statsText = text;
this.isVisible = !!text; // 有文本时显示,无文本时隐藏
},
// 清除翻页统计信息
clearStats() {
this.statsText = '';
this.isVisible = false;
},
// 设置当前路由
setCurrentRoute(route) {
this.currentRoute = route;
// 如果不是点播页面或搜索页面,清除统计信息
if (route !== '/video' && route !== '/search') {
this.clearStats();
}
}
},
getters: {
// 是否应该显示统计信息(在点播页面或搜索页面且有统计文本)
shouldShow: (state) => state.isVisible && (state.currentRoute === '/video' || state.currentRoute === '/search')
}
});