1
1
<script lang="ts" setup>
2
- import {
3
- NEmpty ,
4
- NFlex ,
5
- NSkeleton ,
6
- NTimeline ,
7
- NTimelineItem ,
8
- NVirtualList ,
9
- } from ' naive-ui' ;
2
+ import { NTimeline , NVirtualList } from ' naive-ui' ;
10
3
11
4
import { onActivated , onMounted , ref , Transition , watch } from ' vue' ;
12
5
13
6
import type { VirtualListInst } from ' naive-ui' ;
14
-
15
7
import type { TraktHistory } from ' ~/models/trakt/trakt-history.model' ;
16
8
9
+ import HistoryEmpty from ' ~/components/views/history/HistoryEmpty.vue' ;
10
+ import HistoryItem from ' ~/components/views/history/HistoryItem.vue' ;
11
+
17
12
import { useHistoryStore , useHistoryStoreRefs } from ' ~/stores/data/history.store' ;
18
13
import { useUserSettingsStoreRefs } from ' ~/stores/settings/user.store' ;
19
14
@@ -95,54 +90,15 @@ const getTitle = (media: TraktHistory) => {
95
90
@vue:updated =" onUpdated"
96
91
>
97
92
<template #default =" { item , index } " >
98
- <template v-if =" item .id >= 0 " >
99
- <NTimelineItem
100
- :key =" item.id"
101
- class =" timeline-item"
102
- :data-key =" item.id"
103
- :data-index =" index"
104
- type =" success"
105
- :title =" getTitle(item)"
106
- :content =" item.show?.title"
107
- :time =" new Date(item.watched_at).toLocaleString()"
108
- />
109
- </template >
110
- <template v-else >
111
- <NTimelineItem
112
- :key =" item.id"
113
- class =" timeline-item"
114
- :data-key =" item.id"
115
- :data-index =" index"
116
- line-type =" dashed"
117
- >
118
- <template #default >
119
- <NFlex vertical >
120
- <NSkeleton text style =" width : 70% " />
121
- <NSkeleton text style =" width : 60% " />
122
- <NSkeleton text style =" width : 20% " />
123
- </NFlex >
124
- </template >
125
- </NTimelineItem >
126
- </template >
93
+ <HistoryItem :item =" item" :index =" index" />
127
94
</template >
128
95
</NVirtualList >
129
- <NEmpty v-else size =" large" :show-description =" false" >
130
- <template #extra >
131
- <span class =" empty" >No data found.</span >
132
- <div v-if =" pagination?.page && pagination?.pageCount" >
133
- <div class =" empty" >
134
- Pages searched <span class =" page" > {{ pagination?.page }} </span > out of
135
- <span class =" page" > {{ pagination?.pageCount }} </span >.
136
- </div >
137
- <template v-if =" pagination .page < pagination .pageCount " >
138
- <div class =" empty" >Increase the page size to search more.</div >
139
- <div class =" empty" >
140
- Current page size is <span class =" page" > {{ pageSize }} </span >.
141
- </div >
142
- </template >
143
- </div >
144
- </template >
145
- </NEmpty >
96
+ <HistoryEmpty
97
+ v-else
98
+ :page =" pagination?.page"
99
+ :page-count =" pagination?.pageCount"
100
+ :page-size =" pageSize"
101
+ />
146
102
</Transition >
147
103
</template >
148
104
@@ -155,21 +111,5 @@ const getTitle = (media: TraktHistory) => {
155
111
height : calc (100 dvh - 8px );
156
112
margin-top : - #{layout .$header-navbar-height } ;
157
113
margin-bottom : 8px ;
158
-
159
- .timeline-item {
160
- font-variant-numeric : tabular-nums ;
161
- margin : 0 1rem ;
162
- }
163
- }
164
-
165
- .empty {
166
- margin-top : 0.5rem ;
167
- color : var (--n-text-color );
168
- transition : color 0.3s var (--n-bezier );
169
-
170
- .page {
171
- color : var (--primary-color-disabled );
172
- font-weight : bold ;
173
- }
174
114
}
175
115
</style >
0 commit comments