@fy-/fws-vue 2.1.28 → 2.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/ui/DefaultPaging.vue +48 -49
- package/package.json +1 -1
|
@@ -4,8 +4,8 @@ import type { RouteLocationRaw } from 'vue-router'
|
|
|
4
4
|
import type { APIPaging } from '../../composables/rest'
|
|
5
5
|
import { getURL, hasFW } from '@fy-/fws-js'
|
|
6
6
|
import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/vue/24/solid'
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { useHead } from '@unhead/vue'
|
|
8
|
+
import { ref, watch, watchEffect } from 'vue'
|
|
9
9
|
import { useRoute } from 'vue-router'
|
|
10
10
|
import { useEventBus } from '../../composables/event-bus'
|
|
11
11
|
import { useServerRouter } from '../../stores/serverRouter'
|
|
@@ -77,56 +77,55 @@ pageWatcher.value = watch(
|
|
|
77
77
|
},
|
|
78
78
|
)
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const nextQueryString = new URLSearchParams(nextQuery).toString()
|
|
102
|
-
next = `${baseURL}?${nextQueryString}${hashPart}`
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (page - 1 >= 1) {
|
|
106
|
-
const prevQuery = { ...currentQuery, page: (page - 1).toString() }
|
|
107
|
-
const prevQueryString = new URLSearchParams(prevQuery).toString()
|
|
108
|
-
prev = `${baseURL}?${prevQueryString}${hashPart}`
|
|
109
|
-
}
|
|
80
|
+
watchEffect(() => {
|
|
81
|
+
const page = props.items.page_no
|
|
82
|
+
const page_max = props.items.page_max
|
|
83
|
+
|
|
84
|
+
let next
|
|
85
|
+
let prev
|
|
86
|
+
|
|
87
|
+
if (hasFW()) {
|
|
88
|
+
const url = getURL()
|
|
89
|
+
if (url) {
|
|
90
|
+
const currentQuery = { ...route.query }
|
|
91
|
+
// Remove the existing 'page' parameter to avoid duplicates
|
|
92
|
+
delete currentQuery.page
|
|
93
|
+
|
|
94
|
+
const baseURL = `${url.Scheme}://${url.Host}${url.Path}`
|
|
95
|
+
const hashPart = props.hash !== '' ? `#${props.hash}` : ''
|
|
96
|
+
|
|
97
|
+
if (page + 1 <= page_max) {
|
|
98
|
+
const nextQuery = { ...currentQuery, page: (page + 1).toString() }
|
|
99
|
+
const nextQueryString = new URLSearchParams(nextQuery).toString()
|
|
100
|
+
next = `${baseURL}?${nextQueryString}${hashPart}`
|
|
110
101
|
}
|
|
111
|
-
}
|
|
112
102
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
})
|
|
119
|
-
}
|
|
120
|
-
if (prev) {
|
|
121
|
-
result.push({
|
|
122
|
-
href: prev,
|
|
123
|
-
rel: 'prev',
|
|
124
|
-
key: `paging-prev${props.id}`,
|
|
125
|
-
})
|
|
103
|
+
if (page - 1 >= 1) {
|
|
104
|
+
const prevQuery = { ...currentQuery, page: (page - 1).toString() }
|
|
105
|
+
const prevQueryString = new URLSearchParams(prevQuery).toString()
|
|
106
|
+
prev = `${baseURL}?${prevQueryString}${hashPart}`
|
|
107
|
+
}
|
|
126
108
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
109
|
+
}
|
|
110
|
+
const result: any = []
|
|
111
|
+
|
|
112
|
+
if (next) {
|
|
113
|
+
result.push({
|
|
114
|
+
href: next,
|
|
115
|
+
rel: 'next',
|
|
116
|
+
key: `paging-next${props.id}`,
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
if (prev) {
|
|
120
|
+
result.push({
|
|
121
|
+
href: prev,
|
|
122
|
+
rel: 'prev',
|
|
123
|
+
key: `paging-prev${props.id}`,
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
useHead({
|
|
127
|
+
link: result,
|
|
128
|
+
})
|
|
130
129
|
})
|
|
131
130
|
</script>
|
|
132
131
|
|