This commit is contained in:
1 parent
ede28e0062
commit
64f2f85607
4 files changed
+49
-43
No files matched your search
@@ -3,7 +3,10 @@ import { HeartIcon, SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, useVIntl } from '@modrinth/ui'
|
||||
import { onMounted, ref } from 'vue'
|
||||
|
||||
import { type SkinSiteDonationSummary, skinSiteDonationSummary } from '@/helpers/skin-site-api'
|
||||
import {
|
||||
type SkinSitePublicDonationSummary,
|
||||
skinSitePublicDonationSummary,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
|
||||
@@ -18,13 +21,13 @@ const messages = defineMessages({
|
||||
loading: { id: 'app.skin-site.home.donation.loading', defaultMessage: 'Loading…' },
|
||||
})
|
||||
|
||||
const summary = ref<SkinSiteDonationSummary | null>(null)
|
||||
const summary = ref<SkinSitePublicDonationSummary | null>(null)
|
||||
const loading = ref(true)
|
||||
const failed = ref(false)
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const result = await skinSiteDonationSummary()
|
||||
const result = await skinSitePublicDonationSummary()
|
||||
if (result.success) summary.value = result.payload
|
||||
else failed.value = true
|
||||
} catch {
|
||||
|
||||
@@ -4,11 +4,11 @@ import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/u
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
|
||||
import {
|
||||
skinSiteDownloadCategories,
|
||||
type SkinSiteDownloadCategory,
|
||||
type SkinSiteDownloadItem,
|
||||
skinSiteDownloadList,
|
||||
type SkinSiteDownloadStatus,
|
||||
skinSitePublicDownloadCategories,
|
||||
type SkinSitePublicDownloadCategory,
|
||||
type SkinSitePublicDownloadItem,
|
||||
skinSitePublicDownloadList,
|
||||
type SkinSitePublicDownloadStatus,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
@@ -36,8 +36,8 @@ const messages = defineMessages({
|
||||
|
||||
const emit = defineEmits<{ (e: 'back'): void }>()
|
||||
|
||||
const items = ref<SkinSiteDownloadItem[]>([])
|
||||
const categories = ref<SkinSiteDownloadCategory[]>([])
|
||||
const items = ref<SkinSitePublicDownloadItem[]>([])
|
||||
const categories = ref<SkinSitePublicDownloadCategory[]>([])
|
||||
const selectedCategory = ref<string | null>(null)
|
||||
const loading = ref(true)
|
||||
const failed = ref(false)
|
||||
@@ -48,7 +48,7 @@ const filtered = computed(() =>
|
||||
: items.value,
|
||||
)
|
||||
|
||||
function statusLabel(status: SkinSiteDownloadStatus): string {
|
||||
function statusLabel(status: SkinSitePublicDownloadStatus): string {
|
||||
switch (status) {
|
||||
case 'NEW':
|
||||
return formatMessage(messages.statusNew)
|
||||
@@ -68,7 +68,7 @@ async function openUrl(url: string) {
|
||||
await open(url)
|
||||
}
|
||||
|
||||
function download(item: SkinSiteDownloadItem) {
|
||||
function download(item: SkinSitePublicDownloadItem) {
|
||||
const route = item.routes?.[0]
|
||||
void openUrl(route?.url ?? item.url)
|
||||
}
|
||||
@@ -78,8 +78,8 @@ async function load() {
|
||||
failed.value = false
|
||||
try {
|
||||
const [listResult, categoryResult] = await Promise.all([
|
||||
skinSiteDownloadList(),
|
||||
skinSiteDownloadCategories(),
|
||||
skinSitePublicDownloadList(),
|
||||
skinSitePublicDownloadCategories(),
|
||||
])
|
||||
if (!listResult.success) throw new Error(listResult.errorMessage)
|
||||
items.value = listResult.payload ?? []
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ExternalIcon, SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
|
||||
import { type SkinSiteMapServer, skinSiteMapServers } from '@/helpers/skin-site-api'
|
||||
import { type SkinSitePublicMapServer, skinSitePublicMapServers } from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError } = injectNotificationManager()
|
||||
@@ -23,7 +23,7 @@ const messages = defineMessages({
|
||||
|
||||
const emit = defineEmits<{ (e: 'back'): void }>()
|
||||
|
||||
const servers = ref<SkinSiteMapServer[]>([])
|
||||
const servers = ref<SkinSitePublicMapServer[]>([])
|
||||
const internal = ref(false)
|
||||
const serverIndex = ref(0)
|
||||
const mapIndex = ref(0)
|
||||
@@ -52,7 +52,7 @@ async function load() {
|
||||
loading.value = true
|
||||
failed.value = false
|
||||
try {
|
||||
const result = await skinSiteMapServers()
|
||||
const result = await skinSitePublicMapServers()
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
servers.value = result.payload ?? []
|
||||
if (!servers.value.some((s) => !s.internal)) internal.value = true
|
||||
|
||||
@@ -389,12 +389,12 @@ export function skinSitePasswordReset(payload: {
|
||||
// Donations & announcements
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export interface SkinSiteDonationSummary {
|
||||
export interface SkinSitePublicDonationSummary {
|
||||
totalAmount: string
|
||||
donorCount: number
|
||||
}
|
||||
|
||||
export interface SkinSiteDonationEntry {
|
||||
export interface SkinSitePublicDonationEntry {
|
||||
id: number
|
||||
rank: number
|
||||
username: string
|
||||
@@ -402,14 +402,16 @@ export interface SkinSiteDonationEntry {
|
||||
amount: string
|
||||
}
|
||||
|
||||
export interface SkinSiteDonationPage {
|
||||
items: SkinSiteDonationEntry[]
|
||||
summary: SkinSiteDonationSummary
|
||||
export interface SkinSitePublicDonationPage {
|
||||
items: SkinSitePublicDonationEntry[]
|
||||
summary: SkinSitePublicDonationSummary
|
||||
hasMore: boolean
|
||||
}
|
||||
|
||||
export function skinSiteDonationSummary(): Promise<SkinSiteResponse<SkinSiteDonationSummary>> {
|
||||
return skinSiteRequest<SkinSiteDonationSummary>('donation/summary', { auth: false })
|
||||
export function skinSitePublicDonationSummary(): Promise<
|
||||
SkinSiteResponse<SkinSitePublicDonationSummary>
|
||||
> {
|
||||
return skinSiteRequest<SkinSitePublicDonationSummary>('donation/summary', { auth: false })
|
||||
}
|
||||
|
||||
export function skinSiteDonationList(offset = 0): Promise<SkinSiteResponse<SkinSiteDonationPage>> {
|
||||
@@ -487,71 +489,73 @@ export async function skinSiteUploadAvatar(blob: Blob): Promise<SkinSiteResponse
|
||||
// Downloads
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export type SkinSiteDownloadStatus = 'OK' | 'NEW' | 'LEGACY' | 'OUTDATED' | 'REMOVAL'
|
||||
export type SkinSitePublicDownloadStatus = 'OK' | 'NEW' | 'LEGACY' | 'OUTDATED' | 'REMOVAL'
|
||||
|
||||
export interface SkinSiteDownloadRoute {
|
||||
export interface SkinSitePublicDownloadRoute {
|
||||
name?: string | null
|
||||
url: string
|
||||
}
|
||||
|
||||
export interface SkinSiteDownloadItem {
|
||||
export interface SkinSitePublicDownloadItem {
|
||||
id: number
|
||||
uploader: string
|
||||
url: string
|
||||
routes: SkinSiteDownloadRoute[]
|
||||
routes: SkinSitePublicDownloadRoute[]
|
||||
filename: string
|
||||
description: string
|
||||
status: SkinSiteDownloadStatus[]
|
||||
status: SkinSitePublicDownloadStatus[]
|
||||
category: string[]
|
||||
}
|
||||
|
||||
export interface SkinSiteDownloadCategory {
|
||||
export interface SkinSitePublicDownloadCategory {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
|
||||
export function skinSiteDownloadList(options?: {
|
||||
export function skinSitePublicDownloadList(options?: {
|
||||
limit?: number
|
||||
offset?: number
|
||||
category?: string
|
||||
}): Promise<SkinSiteResponse<SkinSiteDownloadItem[]>> {
|
||||
}): Promise<SkinSiteResponse<SkinSitePublicDownloadItem[]>> {
|
||||
const query = new URLSearchParams({
|
||||
limit: String(options?.limit ?? 200),
|
||||
offset: String(options?.offset ?? 0),
|
||||
})
|
||||
if (options?.category) query.set('category', options.category)
|
||||
return skinSiteRequest<SkinSiteDownloadItem[]>(`download/list?${query.toString()}`, {
|
||||
return skinSiteRequest<SkinSitePublicDownloadItem[]>(`download/list?${query.toString()}`, {
|
||||
auth: false,
|
||||
})
|
||||
}
|
||||
|
||||
export function skinSiteDownloadCount(category?: string): Promise<SkinSiteResponse<number>> {
|
||||
export function skinSitePublicDownloadCount(category?: string): Promise<SkinSiteResponse<number>> {
|
||||
const suffix = category ? `?category=${encodeURIComponent(category)}` : ''
|
||||
return skinSiteRequest<number>(`download/count${suffix}`, { auth: false })
|
||||
}
|
||||
|
||||
export function skinSiteDownloadCategories(): Promise<
|
||||
SkinSiteResponse<SkinSiteDownloadCategory[]>
|
||||
export function skinSitePublicDownloadCategories(): Promise<
|
||||
SkinSiteResponse<SkinSitePublicDownloadCategory[]>
|
||||
> {
|
||||
return skinSiteRequest<SkinSiteDownloadCategory[]>('download/category/list', { auth: false })
|
||||
return skinSiteRequest<SkinSitePublicDownloadCategory[]>('download/category/list', {
|
||||
auth: false,
|
||||
})
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
// Maps
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export interface SkinSiteMapEntry {
|
||||
export interface SkinSitePublicMapEntry {
|
||||
name: string
|
||||
url: string
|
||||
}
|
||||
|
||||
export interface SkinSiteMapServer {
|
||||
export interface SkinSitePublicMapServer {
|
||||
name: string
|
||||
internal: boolean
|
||||
maps: SkinSiteMapEntry[]
|
||||
maps: SkinSitePublicMapEntry[]
|
||||
}
|
||||
|
||||
export function skinSiteMapServers(): Promise<SkinSiteResponse<SkinSiteMapServer[]>> {
|
||||
return skinSiteRequest<SkinSiteMapServer[]>('maps', { auth: false })
|
||||
export function skinSitePublicMapServers(): Promise<SkinSiteResponse<SkinSitePublicMapServer[]>> {
|
||||
return skinSiteRequest<SkinSitePublicMapServer[]>('maps', { auth: false })
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
// Player review (public side)
|
||||
@@ -1033,7 +1037,6 @@ export function skinSiteAdminUserFrequencyLimit(
|
||||
)
|
||||
}
|
||||
|
||||
export type SkinSiteReviewResult = 'PENDING' | 'PASSED' | 'REJECTED'
|
||||
export type SkinSiteReviewMode = 'AUTO' | 'MANUAL'
|
||||
|
||||
export interface SkinSiteReviewAnswer {
|
||||
|
||||
Reference in new issue
Block a user