ui布局自适应

This commit is contained in:
tianmo committed 2026-11-09 10:08:29 +08:00
1 parent 98f44890f8
commit 3587129b90
40 files changed
+929 -142

No files matched your search

+28 -6
View File
@@ -2,7 +2,9 @@ import type { ParticleSystem } from '../store/particleStore'
import type { SpineExportVersion } from './spineExportSettings'
import { translate } from '../i18n'
const CONNECTOR_URL = 'http://127.0.0.1:27843'
const CONNECTOR_HTTP_URL = 'http://127.0.0.1:27843'
const CONNECTOR_HTTPS_URL = 'https://127.0.0.1:27844'
let connectorUrl = CONNECTOR_HTTP_URL
export interface SpineConnectorHealth {
available: boolean
@@ -10,6 +12,8 @@ export interface SpineConnectorHealth {
connectorVersion?: string
spineFound?: boolean
spinePath?: string
secureAvailable?: boolean
pairUrl?: string
platform?: string
error?: string
}
@@ -109,12 +113,28 @@ export async function collectSpineExportImages(systems: ParticleSystem[], onProg
}
export async function checkSpineConnector(): Promise<SpineConnectorHealth> {
const isSafari = typeof navigator !== 'undefined'
&& /Safari\//.test(navigator.userAgent)
&& !/(?:Chrome|Chromium|CriOS|Edg|EdgiOS|OPR|Firefox|FxiOS)\//.test(navigator.userAgent)
const candidates = typeof window !== 'undefined' && window.location.protocol === 'https:'
? isSafari ? [CONNECTOR_HTTPS_URL, CONNECTOR_HTTP_URL] : [CONNECTOR_HTTP_URL, CONNECTOR_HTTPS_URL]
: [CONNECTOR_HTTP_URL]
try {
const response = await fetch(`${CONNECTOR_URL}/v1/health`, { cache: 'no-store' })
if (!response.ok) throw new Error(`HTTP ${response.status}`)
const body = await response.json()
return { available: true, ...body }
let lastError: unknown
for (const candidate of candidates) {
try {
const response = await fetch(`${candidate}/v1/health`, { cache: 'no-store' })
if (!response.ok) throw new Error(`HTTP ${response.status}`)
const body = await response.json()
connectorUrl = candidate
return { available: true, ...body }
} catch (error) {
lastError = error
}
}
throw lastError
} catch (error) {
connectorUrl = ''
return { available: false, authorized: false, error: error instanceof Error ? error.message : String(error) }
}
}
@@ -125,6 +145,8 @@ export async function convertWithSpineConnector(input: {
skeletonJson: string
systems: ParticleSystem[]
}, onProgress?: (progress: SpineConnectorProgress) => void) {
if (!connectorUrl) await checkSpineConnector()
if (!connectorUrl) throw new SpineConnectorError(translate('errors.connectorOffline'), 'CONNECTOR_OFFLINE')
const images = await collectSpineExportImages(input.systems, (completed, total) => {
onProgress?.({ phase: 'images', progress: total ? completed / total : 1 })
})
@@ -138,7 +160,7 @@ export async function convertWithSpineConnector(input: {
return new Promise<{ blob: Blob; fileName: string; spineEditorVersion: string; imageCount: number }>((resolve, reject) => {
const request = new XMLHttpRequest()
request.open('POST', `${CONNECTOR_URL}/v1/convert`)
request.open('POST', `${connectorUrl}/v1/convert`)
request.responseType = 'blob'
request.setRequestHeader('Content-Type', 'application/json')
request.upload.onprogress = (event) => {