@vesperjs/nuxt 0.7.1 → 0.8.0
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/app/composables/backend/api/use-http-headers.ts +1 -1
- package/app/composables/backend/api/use-query-api.ts +1 -1
- package/app/composables/backend/use-api-error.ts +1 -1
- package/app/composables/use-datetime-local.ts +1 -1
- package/app/composables/use-more-page.ts +114 -0
- package/app/composables/use-time-zone.ts +5 -3
- package/package.json +5 -4
- package/app/composables/use-more-scroll.ts +0 -79
|
@@ -2,7 +2,7 @@ import { useAsyncData, useNuxtApp, type NuxtError } from 'nuxt/app'
|
|
|
2
2
|
|
|
3
3
|
import type { FetchContext, FetchError, FetchOptions, FetchResponse } from 'ofetch'
|
|
4
4
|
|
|
5
|
-
import { ref } from '
|
|
5
|
+
import { ref } from 'vue'
|
|
6
6
|
|
|
7
7
|
import { useHttpHeaders } from './use-http-headers'
|
|
8
8
|
import { useApiConstants } from './use-api-constants'
|
|
@@ -33,7 +33,7 @@ export const useDatetimeLocal = function (fmtDT = 'YYYY/MM/DD HH:mm'): {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
const formatHTML = (datetime: string | null, fmt: string): string => {
|
|
36
|
-
return datetime ? format(
|
|
36
|
+
return datetime ? format(parseDT(datetime, fmtDT), fmt, locale.value) : ''
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
return { upDTL, downDTL, toISO8601, formatHTML }
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { useState } from 'nuxt/app'
|
|
2
|
+
|
|
3
|
+
interface MorePage {
|
|
4
|
+
first: number
|
|
5
|
+
pages: number
|
|
6
|
+
current: number
|
|
7
|
+
prev: boolean
|
|
8
|
+
next: boolean
|
|
9
|
+
min: number
|
|
10
|
+
max: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const useMorePage = function (options?: { key?: string | null }): {
|
|
14
|
+
firstPage: WritableComputedRef<number>
|
|
15
|
+
pages: WritableComputedRef<number>
|
|
16
|
+
currentPage: ComputedRef<number>
|
|
17
|
+
prev: ComputedRef<boolean>
|
|
18
|
+
next: ComputedRef<boolean>
|
|
19
|
+
minPage: ComputedRef<number>
|
|
20
|
+
maxPage: ComputedRef<number>
|
|
21
|
+
decrement: () => void
|
|
22
|
+
increment: () => void
|
|
23
|
+
} {
|
|
24
|
+
const key = options?.key
|
|
25
|
+
|
|
26
|
+
const toFirstUpper = (str: string): string => {
|
|
27
|
+
return str.charAt(0).toUpperCase() + str.slice(1)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const morePage = useState<MorePage>(key ? `morePageFor${toFirstUpper(key)}` : 'morePage', () => {
|
|
31
|
+
return {
|
|
32
|
+
first: 1,
|
|
33
|
+
pages: 1,
|
|
34
|
+
current: 1,
|
|
35
|
+
prev: false,
|
|
36
|
+
next: false,
|
|
37
|
+
min: 1,
|
|
38
|
+
max: 1,
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
const firstPage = computed<number>({
|
|
43
|
+
get() {
|
|
44
|
+
return morePage.value.first
|
|
45
|
+
},
|
|
46
|
+
set(value: number) {
|
|
47
|
+
morePage.value.first = value
|
|
48
|
+
morePage.value.current = value
|
|
49
|
+
|
|
50
|
+
morePage.value.prev = false
|
|
51
|
+
morePage.value.next = false
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const pages = computed<number>({
|
|
56
|
+
get() {
|
|
57
|
+
return morePage.value.pages
|
|
58
|
+
},
|
|
59
|
+
set(value: number) {
|
|
60
|
+
morePage.value.pages = value
|
|
61
|
+
|
|
62
|
+
minMaxPage()
|
|
63
|
+
prevNext()
|
|
64
|
+
},
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
const currentPage = computed<number>(() => morePage.value.current)
|
|
68
|
+
|
|
69
|
+
const prev = computed<boolean>(() => morePage.value.prev)
|
|
70
|
+
const next = computed<boolean>(() => morePage.value.next)
|
|
71
|
+
|
|
72
|
+
const minPage = computed<number>(() => morePage.value.min)
|
|
73
|
+
const maxPage = computed<number>(() => morePage.value.max)
|
|
74
|
+
|
|
75
|
+
const minMaxPage = () => {
|
|
76
|
+
morePage.value.min =
|
|
77
|
+
morePage.value.current < morePage.value.first ? morePage.value.current : morePage.value.first
|
|
78
|
+
morePage.value.max =
|
|
79
|
+
morePage.value.current > morePage.value.first ? morePage.value.current : morePage.value.first
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const prevNext = () => {
|
|
83
|
+
morePage.value.prev = morePage.value.min === 1 ? false : true
|
|
84
|
+
morePage.value.next = morePage.value.max === morePage.value.pages ? false : true
|
|
85
|
+
// console.log(`page prev: ${prev.value}`)
|
|
86
|
+
// console.log(`page next: ${next.value}`)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const decrement = () => {
|
|
90
|
+
morePage.value.current = morePage.value.min - 1
|
|
91
|
+
minMaxPage()
|
|
92
|
+
prevNext()
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const increment = () => {
|
|
96
|
+
morePage.value.current = morePage.value.max + 1
|
|
97
|
+
minMaxPage()
|
|
98
|
+
prevNext()
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
firstPage,
|
|
103
|
+
pages,
|
|
104
|
+
currentPage,
|
|
105
|
+
prev,
|
|
106
|
+
next,
|
|
107
|
+
minPage,
|
|
108
|
+
maxPage,
|
|
109
|
+
decrement,
|
|
110
|
+
increment,
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export const useMoreScroll = useMorePage
|
|
@@ -28,11 +28,13 @@ export const useTimeZone = function (fmtDT = 'YYYY/MM/DD HH:mm'): {
|
|
|
28
28
|
const { locale } = useLocale()
|
|
29
29
|
const { toISO8601, formatHTML } = useDatetimeLocal(fmtDT)
|
|
30
30
|
|
|
31
|
-
const
|
|
31
|
+
const serverTZ = runtimeConfig.public.timeZone as string
|
|
32
|
+
|
|
33
|
+
const clientTZ = computed<string>(() => Intl.DateTimeFormat().resolvedOptions().timeZone)
|
|
32
34
|
|
|
33
35
|
const timeZone = computed<TimeZone>(() => ({
|
|
34
|
-
client:
|
|
35
|
-
server:
|
|
36
|
+
client: clientTZ.value,
|
|
37
|
+
server: serverTZ ? serverTZ : clientTZ.value,
|
|
36
38
|
}))
|
|
37
39
|
|
|
38
40
|
const tzOptions = computed<TZOptions[]>(() =>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesperjs/nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"nuxt",
|
|
6
6
|
"vue.js"
|
|
@@ -24,16 +24,17 @@
|
|
|
24
24
|
"@nuxt/eslint": "1.15.2",
|
|
25
25
|
"@nuxtjs/i18n": "^10.3.0",
|
|
26
26
|
"@types/node": "^24.12.3",
|
|
27
|
-
"@vesperjs/shared": "0.
|
|
27
|
+
"@vesperjs/shared": "0.8.0",
|
|
28
28
|
"eslint": "^10.3.0",
|
|
29
29
|
"eslint-typegen": "2.3.1",
|
|
30
30
|
"nuxt": "^4.3.1",
|
|
31
31
|
"ofetch": "^1.5.1",
|
|
32
|
-
"oxfmt": "^0.
|
|
32
|
+
"oxfmt": "^0.50.0",
|
|
33
33
|
"typescript": "^6.0.3"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"typescript-eslint": "^8.59.
|
|
36
|
+
"@typescript-eslint/typescript-estree": "^8.59.3",
|
|
37
|
+
"typescript-eslint": "^8.59.3",
|
|
37
38
|
"vue": "^3.5.34 || ^3.6.0-beta.11"
|
|
38
39
|
},
|
|
39
40
|
"scripts": {
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { useState } from 'nuxt/app'
|
|
2
|
-
|
|
3
|
-
export const useMoreScroll = function ({
|
|
4
|
-
key = null,
|
|
5
|
-
page = 1,
|
|
6
|
-
pages,
|
|
7
|
-
}: {
|
|
8
|
-
key?: string | null
|
|
9
|
-
page: number
|
|
10
|
-
pages: number
|
|
11
|
-
}): {
|
|
12
|
-
currentPage: Ref<number>
|
|
13
|
-
pagePrev: Ref<boolean>
|
|
14
|
-
pageNext: Ref<boolean>
|
|
15
|
-
minPage: Ref<number>
|
|
16
|
-
maxPage: Ref<number>
|
|
17
|
-
init: () => void
|
|
18
|
-
decrement: () => void
|
|
19
|
-
increment: () => void
|
|
20
|
-
} {
|
|
21
|
-
const toFirstUpper = (str: string): string => {
|
|
22
|
-
return str.charAt(0).toUpperCase() + str.slice(1)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const currentPage = useState<number>(
|
|
26
|
-
key ? `currentPageFor${toFirstUpper(key)}` : 'currentPage',
|
|
27
|
-
() => {
|
|
28
|
-
return 1
|
|
29
|
-
},
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
const pagePrev = useState<boolean>(key ? `pagePrevFor${toFirstUpper(key)}` : 'pagePrev', () => {
|
|
33
|
-
return false
|
|
34
|
-
})
|
|
35
|
-
const pageNext = useState<boolean>(key ? `pageNextFor${toFirstUpper(key)}` : 'pageNext', () => {
|
|
36
|
-
return false
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
const minPage = useState<number>(key ? `minPageFor${toFirstUpper(key)}` : 'minPage', () => {
|
|
40
|
-
return 1
|
|
41
|
-
})
|
|
42
|
-
const maxPage = useState<number>(key ? `maxPageFor${toFirstUpper(key)}` : 'maxPage', () => {
|
|
43
|
-
return 1
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
const minMaxPage = () => {
|
|
47
|
-
minPage.value = currentPage.value < page ? currentPage.value : page
|
|
48
|
-
maxPage.value = currentPage.value > page ? currentPage.value : page
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const pagePrevNext = () => {
|
|
52
|
-
if (currentPage.value === 1) pagePrev.value = false
|
|
53
|
-
if (currentPage.value === pages) pageNext.value = false
|
|
54
|
-
// console.log(`page prev: ${pagePrev.value}`)
|
|
55
|
-
// console.log(`page next: ${pageNext.value}`)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const init = () => {
|
|
59
|
-
currentPage.value = page
|
|
60
|
-
pagePrev.value = true
|
|
61
|
-
pageNext.value = true
|
|
62
|
-
minMaxPage()
|
|
63
|
-
pagePrevNext()
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const decrement = () => {
|
|
67
|
-
currentPage.value = minPage.value - 1
|
|
68
|
-
minMaxPage()
|
|
69
|
-
pagePrevNext()
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const increment = () => {
|
|
73
|
-
currentPage.value = maxPage.value + 1
|
|
74
|
-
minMaxPage()
|
|
75
|
-
pagePrevNext()
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return { currentPage, pagePrev, pageNext, minPage, maxPage, init, decrement, increment }
|
|
79
|
-
}
|