fix(stage-ui): should exclude presets & file format handling

This commit is contained in:
Neko Ayaka
2025-08-25 00:04:20 +08:00
parent 21b3307e9e
commit 5917783670
3 changed files with 10 additions and 10 deletions
@@ -88,7 +88,7 @@ watch(vrmFiles, (newFiles) => {
</DropdownMenuTrigger>
<DropdownMenuPortal>
<DropdownMenuContent
class="will-change-[opacity,transform] z-10000 max-w-45 rounded-lg p-0.5 text-white shadow-md outline-none data-[side=bottom]:animate-slideUpAndFade data-[side=left]:animate-slideRightAndFade data-[side=right]:animate-slideLeftAndFade data-[side=top]:animate-slideDownAndFade dark:text-black"
class="will-change-[opacity,transform] z-10000 max-w-45 rounded-lg p-0.5 shadow-md outline-none data-[side=bottom]:animate-slideUpAndFade data-[side=left]:animate-slideRightAndFade data-[side=right]:animate-slideLeftAndFade data-[side=top]:animate-slideDownAndFade"
bg="neutral-700/50 dark:neutral-950/50"
transition="colors duration-200 ease-in-out"
backdrop-blur-sm
@@ -169,7 +169,7 @@ watch(vrmFiles, (newFiles) => {
px-1 py-2
>
<img v-if="model.previewImage" :src="model.previewImage" h-full w-full rounded-lg object-cover :class="[highlightDisplayModelCard && highlightDisplayModelCard === model.id ? 'ring-3 ring-primary-400' : 'ring-0 ring-transparent']" transition="all duration-200 ease-in-out">
<div v-else bg="neutral-100 dark:neutral-900" relative h-full w-full flex flex-col items-center justify-center gap-2 rounded-lg :class="[highlightDisplayModelCard && highlightDisplayModelCard === model.id ? 'ring-4 ring-primary-400' : 'ring-0 ring-transparent']" transition="all duration-200 ease-in-out">
<div v-else bg="neutral-100 dark:neutral-900" relative h-full w-full flex flex-col items-center justify-center gap-2 overflow-hidden rounded-lg :class="[highlightDisplayModelCard && highlightDisplayModelCard === model.id ? 'ring-3 ring-primary-400' : 'ring-0 ring-transparent']" transition="all duration-200 ease-in-out">
<div i-solar:question-square-bold-duotone text-4xl opacity-75 />
<div translate-y="100%" absolute top-0 flex flex-col translate-x--7 rotate-45 scale-250 gap-0 opacity-5>
<div text="sm sm:sm" translate-x-7 translate-y--2 text-nowrap>
@@ -151,7 +151,7 @@ async function loadModel() {
if (modelSrcRef.value.startsWith('blob:')) {
const res = await fetch(modelSrcRef.value)
const blob = await res.blob()
await Live2DFactory.setupLive2DModel(modelInstance, [blob], { autoInteract: false })
await Live2DFactory.setupLive2DModel(modelInstance, [new File([blob], 'model.zip')], { autoInteract: false })
}
else {
await Live2DFactory.setupLive2DModel(modelInstance, modelSrcRef.value, { autoInteract: false })
@@ -25,6 +25,7 @@ export interface DisplayModelFile {
file: File
name: string
previewImage?: string
importedAt: number
}
export interface DisplayModelURL {
@@ -34,13 +35,12 @@ export interface DisplayModelURL {
url: string
name: string
previewImage?: string
importedAt: number
}
const displayModelsPresets: DisplayModel[] = [
{ id: 'preset-live2d-1', format: DisplayModelFormat.Live2dZip, type: 'url', url: '/assets/live2d/models/hiyori_pro_zh.zip', name: 'Hiyori (Pro)', previewImage: '/assets/live2d/models/hiyori_free_zh/avatar.png' },
{ id: 'preset-live2d-2', format: DisplayModelFormat.Live2dZip, type: 'url', url: '/assets/live2d/models/hiyori_free_zh.zip', name: 'Hiyori (Free)', previewImage: '/assets/live2d/models/hiyori_free_zh/avatar.png' },
{ id: 'preset-live2d-3', format: DisplayModelFormat.Live2dZip, type: 'url', url: '/assets/live2d/models/hiyori_free_zh.zip', name: 'Hiyori (Free)' },
{ id: 'preset-live2d-4', format: DisplayModelFormat.Live2dZip, type: 'url', url: '/assets/live2d/models/hiyori_free_zh.zip', name: 'Hiyori (Free)', previewImage: '/assets/live2d/models/hiyori_free_zh/avatar.png' },
{ id: 'preset-live2d-1', format: DisplayModelFormat.Live2dZip, type: 'url', url: '/assets/live2d/models/hiyori_pro_zh.zip', name: 'Hiyori (Pro)', previewImage: '/assets/live2d/models/hiyori_free_zh/avatar.png', importedAt: 1733113886840 },
{ id: 'preset-live2d-2', format: DisplayModelFormat.Live2dZip, type: 'url', url: '/assets/live2d/models/hiyori_free_zh.zip', name: 'Hiyori (Free)', previewImage: '/assets/live2d/models/hiyori_free_zh/avatar.png', importedAt: 1733113886840 },
]
export const useDisplayModelsStore = defineStore('display-models', () => {
@@ -55,9 +55,9 @@ export const useDisplayModelsStore = defineStore('display-models', () => {
const models = [...displayModelsPresets]
try {
await localforage.iterate<{ format: DisplayModelFormat, file: File }, void>((val, key) => {
await localforage.iterate<{ format: DisplayModelFormat, file: File, importedAt: number, previewImage?: string }, void>((val, key) => {
if (key.startsWith('display-model-')) {
models.push({ id: key, format: val.format, type: 'file', file: val.file, name: val.file.name })
models.push({ id: key, format: val.format, type: 'file', file: val.file, name: val.file.name, importedAt: val.importedAt, previewImage: val.previewImage })
}
})
}
@@ -76,7 +76,7 @@ export const useDisplayModelsStore = defineStore('display-models', () => {
async function addDisplayModel(format: DisplayModelFormat, file: File) {
await until(displayModelsFromIndexedDBLoading).toBe(false)
const newDisplayModel: DisplayModelFile = { id: `display-model-${nanoid()}`, format, type: 'file', file, name: file.name }
const newDisplayModel: DisplayModelFile = { id: `display-model-${nanoid()}`, format, type: 'file', file, name: file.name, importedAt: Date.now() }
displayModels.value.push(newDisplayModel)
localforage.setItem<DisplayModelFile>(newDisplayModel.id, newDisplayModel)