@fy-/fws-vue 2.1.28 → 2.1.29
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 +51 -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 { computed, ref, watch } from 'vue'
|
|
7
|
+
import { useHead } from '@unhead/vue'
|
|
8
|
+
import { computed, 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,58 @@ pageWatcher.value = watch(
|
|
|
77
77
|
},
|
|
78
78
|
)
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
80
|
+
watchEffect(() => {
|
|
81
|
+
useHead({
|
|
82
|
+
link: computed(() => {
|
|
83
|
+
const result: any = []
|
|
84
|
+
const page = props.items.page_no
|
|
85
|
+
const page_max = props.items.page_max
|
|
86
|
+
|
|
87
|
+
let next
|
|
88
|
+
let prev
|
|
89
|
+
|
|
90
|
+
if (hasFW()) {
|
|
91
|
+
const url = getURL()
|
|
92
|
+
if (url) {
|
|
93
|
+
const currentQuery = { ...route.query }
|
|
94
|
+
// Remove the existing 'page' parameter to avoid duplicates
|
|
95
|
+
delete currentQuery.page
|
|
96
|
+
|
|
97
|
+
const baseURL = `${url.Scheme}://${url.Host}${url.Path}`
|
|
98
|
+
const hashPart = props.hash !== '' ? `#${props.hash}` : ''
|
|
99
|
+
|
|
100
|
+
if (page + 1 <= page_max) {
|
|
101
|
+
const nextQuery = { ...currentQuery, page: (page + 1).toString() }
|
|
102
|
+
const nextQueryString = new URLSearchParams(nextQuery).toString()
|
|
103
|
+
next = `${baseURL}?${nextQueryString}${hashPart}`
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (page - 1 >= 1) {
|
|
107
|
+
const prevQuery = { ...currentQuery, page: (page - 1).toString() }
|
|
108
|
+
const prevQueryString = new URLSearchParams(prevQuery).toString()
|
|
109
|
+
prev = `${baseURL}?${prevQueryString}${hashPart}`
|
|
110
|
+
}
|
|
103
111
|
}
|
|
112
|
+
}
|
|
104
113
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
114
|
+
if (next) {
|
|
115
|
+
result.push({
|
|
116
|
+
href: next,
|
|
117
|
+
rel: 'next',
|
|
118
|
+
key: `paging-next${props.id}`,
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
if (prev) {
|
|
122
|
+
result.push({
|
|
123
|
+
href: prev,
|
|
124
|
+
rel: 'prev',
|
|
125
|
+
key: `paging-prev${props.id}`,
|
|
126
|
+
})
|
|
110
127
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
href: next,
|
|
116
|
-
rel: 'next',
|
|
117
|
-
key: `paging-next${props.id}`,
|
|
118
|
-
})
|
|
119
|
-
}
|
|
120
|
-
if (prev) {
|
|
121
|
-
result.push({
|
|
122
|
-
href: prev,
|
|
123
|
-
rel: 'prev',
|
|
124
|
-
key: `paging-prev${props.id}`,
|
|
125
|
-
})
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return result
|
|
129
|
-
}),
|
|
128
|
+
|
|
129
|
+
return result
|
|
130
|
+
}),
|
|
131
|
+
})
|
|
130
132
|
})
|
|
131
133
|
</script>
|
|
132
134
|
|