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