fix(types): use auto-generated schema for NodeInfo (About pages; store instance init)

This commit is contained in:
upsiflu 2025-02-13 11:55:57 +01:00
parent 2960b939d9
commit 910a6ab157
4 changed files with 15 additions and 12 deletions

View File

@ -5,9 +5,10 @@ import { get } from 'lodash-es'
import { humanSize } from '~/utils/filters'
import { computed } from 'vue'
import type { components } from '~/generated/types.ts'
import SignupForm from '~/components/auth/SignupForm.vue'
import LogoText from '~/components/LogoText.vue'
import type { NodeInfo } from '~/store/instance'
import useMarkdown from '~/composables/useMarkdown'
import Link from '~/components/ui/Link.vue'
@ -36,15 +37,15 @@ const stats = computed(() => {
return null
}
const info = nodeinfo.value ?? {} as NodeInfo
const info = nodeinfo.value ?? {} as components['schemas']['NodeInfo20']
const data = {
users: get(info, 'usage.users.activeMonth', null),
hours: get(info, 'metadata.content.local.hoursOfContent', null),
artists: get(info, 'metadata.content.local.artists.total', null),
albums: get(info, 'metadata.content.local.albums.total', null),
tracks: get(info, 'metadata.content.local.tracks.total', null),
listenings: get(info, 'metadata.usage.listenings.total', null)
users: info.usage.users.activeMonth || null,
hours: info.metadata.library.music.hours || null,
artists: info.metadata.library.artists.total || null,
albums: info.metadata.library.albums.total || null,
tracks: info.metadata.library.tracks.total || null,
listenings: info.metadata.usage?.listenings.total || null
}
return { users, hours, data }

View File

@ -4,8 +4,9 @@ import { useStore } from '~/store'
import { get } from 'lodash-es'
import { computed } from 'vue'
import type { components } from '~/generated/types.ts'
import useMarkdown from '~/composables/useMarkdown'
import type { NodeInfo } from '~/store/instance'
import { useI18n } from 'vue-i18n'
const store = useStore()
@ -40,7 +41,7 @@ const federationEnabled = computed(() => {
const onDesktop = computed(() => window.innerWidth > 800)
const stats = computed(() => {
const info = nodeinfo.value ?? {} as NodeInfo
const info = nodeinfo.value ?? {} as components['schemas']['NodeInfo20']
const data = {
users: get(info, 'usage.users.activeMonth', null),

View File

@ -1,4 +1,5 @@
import type { NodeInfo } from '~/store/instance'
import type { schemas } from '~/generated/types'
import type { InitModule } from '~/types'
import { whenever } from '@vueuse/core'
@ -15,7 +16,7 @@ export const install: InitModule = async ({ store, router }) => {
const fetchNodeInfo = async () => {
try {
const [{ data }] = await Promise.all([
axios.get<NodeInfo>('instance/nodeinfo/2.1/'),
axios.get<schemas['NodeInfo20']>('instance/nodeinfo/2.1/'),
store.dispatch('instance/fetchSettings')
])

View File

@ -66,7 +66,7 @@ export type Usage = components['schemas']['Usage']
export type LibraryScan = components['schemas']['LibraryScan']
export type LibraryFollow = components["schemas"]["LibraryFollow"]
export type Cover = components["schemas"]["CoverField"]
export type RateLimitStatus = components["schemas"]["RateLimit"]
export type RateLimitStatus = components["schemas"]["RateLimit"]['scopes'][number]
export type PaginatedAlbumList = components["schemas"]["PaginatedAlbumList"]
export type SimpleArtist = components["schemas"]["SimpleArtist"]