|
64 | 64 | // only one page text
|
65 | 65 | export let onePageText = paginationLang.defaultOnlyOnePage;
|
66 | 66 |
|
| 67 | + // 连续模式 |
| 68 | + // continuous mode |
| 69 | + export let continuous = false; |
| 70 | +
|
67 | 71 | // 总页数
|
68 | 72 | // totalPage
|
69 | 73 | $: totalPage = Math.ceil(total / pageSize);
|
|
235 | 239 | <div class="flex-1 py-2 border border-transparent">{onePageText}</div>
|
236 | 240 | {:else if totalPage > 1 && totalPage <= maxShowPage}
|
237 | 241 | {#each new Array(totalPage) as item, index}
|
238 |
| - <Page active={current === index + 1} {type} {radius} on:click={() => clickItemFunc(index + 1)}> |
| 242 | + <Page active={current === index + 1} {type} {radius} on:click={() => !continuous && clickItemFunc(index + 1)}> |
239 | 243 | {index + 1}
|
240 | 244 | </Page>
|
241 | 245 | {/each}
|
242 | 246 | {:else}
|
243 |
| - <Page active={current === 1} {type} {radius} on:click={() => clickItemFunc(1)}>1</Page> |
| 247 | + <Page active={current === 1} {type} {radius} on:click={() => !continuous && clickItemFunc(1)}>1</Page> |
244 | 248 | {#if showPreEllipsis}
|
245 | 249 | <!-- svelte-ignore a11y-click-events-have-key-events -->
|
246 | 250 | <div
|
247 | 251 | class="flex-1 py-2 border {showPreOmitPage
|
248 | 252 | ? typeClass[type] || typeClass.border
|
249 | 253 | : 'border-transparent' + (type === 'bold' ? ' opacity-50' : '')} {radiusClass[radius] || radiusClass.base}"
|
250 |
| - on:click={clickPreEllipsisFunc} |
| 254 | + on:click={!continuous && clickPreEllipsisFunc} |
251 | 255 | >
|
252 | 256 | {#if type === 'bold' && showPreOmitPage}
|
253 | 257 | <Icon name="ri-more-fill" size={18} />
|
|
258 | 262 | {/if}
|
259 | 263 | {#if !showPreEllipsis && current <= maxShowPage - 1}
|
260 | 264 | {#each new Array(maxShowPage - 3) as item, index}
|
261 |
| - <Page active={current === index + 2} {type} {radius} on:click={() => clickItemFunc(index + 2)}> |
| 265 | + <Page active={current === index + 2} {type} {radius} on:click={() => !continuous && clickItemFunc(index + 2)}> |
262 | 266 | {index + 2}
|
263 | 267 | </Page>
|
264 | 268 | {/each}
|
265 | 269 | {/if}
|
266 | 270 | {#if middleShowPage.length > 0}
|
267 | 271 | {#each middleShowPage as item, index}
|
268 |
| - <Page active={index === (middleShowPage.length - 1) / 2} {type} {radius} on:click={() => clickItemFunc(item)}> |
| 272 | + <Page active={index === (middleShowPage.length - 1) / 2} {type} {radius} on:click={() => !continuous && clickItemFunc(item)}> |
269 | 273 | {item}
|
270 | 274 | </Page>
|
271 | 275 | {/each}
|
|
276 | 280 | active={current === totalPage + index + 3 - maxShowPage}
|
277 | 281 | {type}
|
278 | 282 | {radius}
|
279 |
| - on:click={() => clickItemFunc(totalPage + index + 3 - maxShowPage)} |
| 283 | + on:click={() => !continuous && clickItemFunc(totalPage + index + 3 - maxShowPage)} |
280 | 284 | >
|
281 | 285 | {totalPage + index + 3 - maxShowPage}
|
282 | 286 | </Page>
|
|
288 | 292 | class="flex-1 py-2 border {showNextOmitPage
|
289 | 293 | ? typeClass[type] || typeClass.border
|
290 | 294 | : 'border-transparent' + (type === 'bold' ? ' opacity-50' : '')} {radiusClass[radius] || radiusClass.base}"
|
291 |
| - on:click={clickNextEllipsisFunc} |
| 295 | + on:click={!continuous && clickNextEllipsisFunc} |
292 | 296 | >
|
293 | 297 | {#if type === 'bold' && showNextOmitPage}
|
294 | 298 | <Icon name="ri-more-fill" size={18} />
|
|
297 | 301 | {/if}
|
298 | 302 | </div>
|
299 | 303 | {/if}
|
300 |
| - <Page active={current === totalPage} {type} {radius} on:click={() => clickItemFunc(totalPage)}>{totalPage}</Page> |
| 304 | + <Page active={current === totalPage} {type} {radius} on:click={() => !continuous && clickItemFunc(totalPage)}>{totalPage}</Page> |
301 | 305 | {/if}
|
302 | 306 | <!-- svelte-ignore a11y-click-events-have-key-events -->
|
303 | 307 | <div
|
|
0 commit comments