123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <template>
- <LeftPano>
- <List
- title="数据列表"
- key="id"
- :data="modelList"
- >
- <template #action v-if="custom.modelsChangeStore">
- <ui-input
- type="file"
- width="20px"
- placeholder="上传模型"
- othPlaceholder="支持ZIP压缩包格式"
- accept=".zip"
- :disable="true"
- :multiple="false"
- @update:modelValue="addHandler"
- >
- <template v-slot:replace>
- <ui-icon type="add" ctrl/>
- </template>
- </ui-input>
- </template>
- <template #atom="{ item }">
- <ModelSign
- :model="item.raw"
- @delete="modelDelete(item.raw)"
- @click="modelChangeSelect(item.raw)"
- />
- </template>
- </List>
- </LeftPano>
- </template>
- <script lang="ts" setup>
- import { computed, watchEffect } from 'vue'
- import { LeftPano } from '@/layout'
- import { models, getModelShowVariable, addModel } from '@/store'
- import { custom } from '@/env'
- import { getSceneModel } from '@/sdk'
- import List from '@/components/list/index.vue'
- import ModelSign from './sign.vue'
- import type { Model } from '@/store'
- const modelList = computed(() =>
- models.value.map(model => ({
- raw: model,
- select: custom.currentModel === model
- }))
- )
- const addHandler = async (file: File) => {
- await addModel(file)
- modelList.value.forEach(model => {
- if (!custom.showModelsMap.has(model.raw)) {
- custom.showModelsMap.set(model.raw, model.raw.show)
- }
- })
- }
- const modelChangeSelect = (model: Model) => {
- if (getModelShowVariable(model).value) {
- if (custom.currentModel !== model) {
- getSceneModel(model)?.changeSelect(true)
- custom.currentModel = model
- } else {
- getSceneModel(custom.currentModel)?.changeSelect(false)
- custom.currentModel = null
- }
- }
- }
- watchEffect(() => {
- if (custom.currentModel && !getModelShowVariable(custom.currentModel).value) {
- custom.currentModel = null
- }
- })
- const modelDelete = (model: Model) => {
- const index = models.value.indexOf(model)
- if (~index) {
- models.value.splice(index, 1)
- }
- }
- </script>
|