Sfoglia il codice sorgente

Merge branch 'master' of http://192.168.0.115:3000/tangning/SichuanDaily

rindy 9 mesi fa
parent
commit
c34435a8a6

+ 0 - 7
src/App.vue

@@ -36,13 +36,6 @@
         >
           <n-menu
             class="menu-class"
-            style="
-              --n-item-color-hover: rgb(243, 243, 245, 0.5);
-              --n-item-text-color: white;
-              --n-font-size: 14px;
-              --n-item-icon-color: #fff;
-              --n-item-icon-color-active: #316c72;
-            "
             v-model:value="activeKey"
             :options="menuOptions"
             @update:value="handleUpdateValue"

+ 7 - 1
src/api/module/tts.ts

@@ -29,10 +29,16 @@ export const saveTOTTS = (params: SaveTOTTSParams) => {
   })
 }
 
-export const saveTOSTT = (params: { id?: string; num: string; file: File }) => {
+export const saveTOSTT = (params: {
+  id?: string
+  num: string
+  file: File
+  name: string
+}) => {
   const forms = new FormData()
   forms.append('file', params.file)
   forms.append('num', params.num)
+  forms.append('name', params.name)
   params.id && forms.append('id', params.id)
   return Alova.Post(url.sttSave, forms)
 }

+ 7 - 2
src/store/main.ts

@@ -29,7 +29,8 @@ export const useMainStore = defineStore('main', {
         age: 18
       },
       sceneInfo: {
-        boxVideos: ''
+        boxVideos: '',
+        boxModels: ''
       },
       aiSetting: [],
       navigation: []
@@ -92,10 +93,14 @@ export const useMainStore = defineStore('main', {
       console.log('data', data)
       this.sceneInfo = data as any as {
         boxVideos: string
+        boxModels: string
       }
     },
     syncNavigation(navigation: any[]) {
-      this.navigation = navigation
+      this.navigation = navigation as any as []
+    },
+    syncAISetting(aiSetting: any[]) {
+      this.aiSetting = aiSetting as any as []
     }
   }
 })

+ 22 - 8
src/styles/theme.ts

@@ -6,20 +6,34 @@ export const themeOverrides: GlobalThemeOverrides = {
     primaryColor: '#0960bd',
     primaryColorHover: '#1478e3',
     primaryColorPressed: '#064282',
-    primaryColorSuppl: '#316C7263',
-    successColor: '#316C72FF',
-    successColorHover: '#316C72E3',
-    successColorPressed: '#2B4C59FF',
-    successColorSuppl: '#316C7263'
+    primaryColorSuppl: '#0960bd'
+    // successColor: '#0960bd',
+    // successColorHover: '#1478e3',
+    // successColorPressed: '#0960bd',
+    // successColorSuppl: '#0960bd'
   },
   Drawer: {
     color: 'rgb(24, 24, 28)'
   },
+  Select: {
+    optionColorActive: '#ffffff'
+  },
+
   Menu: {
     itemTextColor: '#ffffff',
-    itemTextColorActive: '#ffffff',
-    pressedColor: '#ffffff',
-    itemColorHoverInverted: 'rgb(24, 24, 28)'
+    itemColorHover: 'rgba(255,255,255,0.1)',
+    // pressedColor: '#ffffff',
+    // // itemColorHoverInverted: 'rgb(24, 24, 28)',
+    // itemTextColorHover: '#ffffff',
+    itemTextColorActive: '#0960bd',
+    itemColorActiveCollapsed: '#0960bd'
+    // itemIconColor: '#ffffff',
+    // itemIconColorHover: '#ffffff',
+    // itemIconColorActive: '#ffffff',
+    // itemIconColorChildActive: '#ffffff',
+    // itemTextColorActiveHover: 'rgba(255,255,255,0.2)'
+    // itemTextColorActiveHover: '#ffffff',
+    // itemTextColorChildActive: '#ffffff'
   },
 
   Button: {

+ 70 - 25
src/views/digitalHuman/index.vue

@@ -15,22 +15,25 @@
       <n-drawer-content title="数字人播报">
         <div class="drawerContent m-5">
           <!-- <div class="text-lg my-2.5">数字人播报</div>-->
-
           <n-list
-            hoverable
-            clickable
+            v-if="list"
             style="--n-color-modal: none"
             :show-divider="false"
           >
-            <n-list-item v-for="(vi, index) in list" :key="index">
-              当前空间视频ID:
-              <n-space></n-space>
-              <!--              {{ vi.url}}-->
-              {{ vi.sid }}
+            <!--            {{list}}-->
+            <n-list-item
+              v-for="(vi, index) in list"
+              :key="index"
+              style="width: 100%"
+            >
+              <div class="mb-5">
+                {{ `当前空间${vi.media ? '视频' : '模型'}` }} ID: {{ vi.sid }}
+              </div>
 
               <n-select
-                v-model:value="bindAudioId"
+                v-model:value="vi.audioId"
                 :options="audioOptions"
+                @update:value="(val) => handleSelect(val, vi.sid)"
               ></n-select>
             </n-list-item>
           </n-list>
@@ -47,7 +50,8 @@ import {
   onMounted,
   // reactive,
   onUnmounted,
-  watchEffect
+  watchEffect,
+  watch
 } from 'vue'
 
 import { useMainStore } from '@/store'
@@ -59,40 +63,81 @@ const main = useMainStore()
 const active = ref(true)
 
 const boxVideos = computed(() => main.sceneInfo.boxVideos)
+const boxModels = computed(() => main.sceneInfo.boxModels)
+const aiData = computed(() => main.getEditorData.aiSetting)
 
-const list = ref<any[]>([])
-
-const bindAudioId = ref()
+const list = ref<{ sid: string; audioFilePath: string; audioId }[]>([])
+const audiolist = ref<any[]>([])
 const audioOptions = ref<any[]>([])
 
 onMounted(async () => {
   active.value = true
   const res = await fetchTtsList(main.sceneCode)
   if (res) {
-    const arr = Array.from(res as any as SaveTOTTSParams[])
-      .filter((i) => i.type === 'tts')
-      .map((item) => {
-        return {
-          label: item.document,
-          value: item.id
-        }
-      })
+    const result = Array.from(res as any as SaveTOTTSParams[]).filter(
+      (i) => i.type === 'tts'
+    )
+    audiolist.value = result
+    const arr = result.map((item) => {
+      return {
+        label: item.name,
+        value: item.id
+      }
+    })
     console.log('array', arr)
     audioOptions.value = arr
   }
 
   watchEffect(() => {
-    if (boxVideos.value?.length) {
+    if (boxVideos.value?.length || boxModels.value?.length) {
       // debugger
-      const data = JSON.parse(boxVideos.value)
-      console.log('boxVideos', data)
-      list.value = data
+      const videoData = JSON.parse(boxVideos.value)
+      const boxData = JSON.parse(boxModels.value)
+      console.log('boxVideos', videoData)
+      if (videoData && aiData.value.length === 0) {
+        list.value = list.value.concat(
+          videoData.map((item) => {
+            return {
+              ...item,
+              audioId: null,
+              audioFilePath: null
+            }
+          })
+        )
+      }
+      if (videoData && aiData.value.length === 0) {
+        list.value = list.value.concat(
+          boxData.map((item) => {
+            return {
+              ...item,
+              audioId: null,
+              audioFilePath: null
+            }
+          })
+        )
+      }
     }
   })
 })
+watchEffect(() => {
+  if (aiData.value.length > 0) {
+    list.value = aiData.value
+  }
+})
 onUnmounted(() => {
   // setWidthSceneRef(0)
 })
+const handleSelect = (audioId: any, vid: any) => {
+  const file = audiolist.value.find((i) => i.id === audioId)
+  const models = Array.from(list.value.flat() || []).find((i) => i.sid === vid)
+  const fileName = file.voicePath.substring(file.voicePath.lastIndexOf('/') + 1)
+  if (file.voicePath?.length && models) {
+    // debugger
+    models.audioFilePath = fileName
+    console.log('models', models)
+    main.syncAISetting(list.value)
+  }
+}
 </script>
 
 <style lang="sass" scoped>

+ 13 - 4
src/views/textToaudio/index.vue

@@ -24,7 +24,7 @@
       :is-editing="showTTSModel.isEditing"
       :data="showTTSModel.data"
       @close="showTTSModel.show = false"
-      @submit="(showTTSModel.show = false) && refresh()"
+      @submit="noticeTTsModelDone"
     ></TtsModel>
 
     <SttModel
@@ -32,7 +32,7 @@
       :is-editing="showSTTModel.isEditing"
       :data="showSTTModel.data"
       @close="showSTTModel.show = false"
-      @submit="(showSTTModel.show = false) && refresh()"
+      @submit="noticeSTTModelDone"
     ></SttModel>
   </div>
 </template>
@@ -80,7 +80,7 @@ const paginationReactive = reactive({
 onMounted(async () => {
   watchEffect(async () => {
     if (main.sceneCode) {
-     await refresh()
+      await refresh()
     }
   })
 })
@@ -225,6 +225,15 @@ const openEdit = (row) => {
     showSTTModel.value.data = row
   }
 }
+
+const noticeTTsModelDone = async () => {
+  await refresh()
+  showTTSModel.value.show = false
+}
+const noticeSTTModelDone = async () => {
+  await refresh()
+  showSTTModel.value.show = false
+}
 </script>
 
 <style lang="sass" scoped>
@@ -243,5 +252,5 @@ code
 
 .textToaudio
   min-height: 100%
-  //border-left: 1px solid
+//border-left: 1px solid
 </style>

+ 30 - 5
src/views/textToaudio/sttModel.vue

@@ -24,6 +24,21 @@
         </n-icon>
       </template>
 
+      <n-form
+        ref="formRef"
+        :model="form"
+        label-placement="left"
+        label-width="auto"
+        require-mark-placement="right-hanging"
+        :style="{
+          maxWidth: '100%'
+        }"
+      >
+        <n-form-item label="名称" path="inputValue">
+          <n-input v-model:value="form.name" />
+        </n-form-item>
+      </n-form>
+
       <n-flex>
         <n-upload
           accept=".mp3,.wmv"
@@ -56,7 +71,15 @@
 
 <script setup lang="ts">
 import { ref, reactive, watchEffect } from 'vue'
-import { NUpload, NUploadDragger, NP, NText, useMessage } from 'naive-ui'
+import {
+  NUpload,
+  NUploadDragger,
+  NP,
+  NText,
+  useMessage,
+  NForm,
+  NFormItem
+} from 'naive-ui'
 import { saveTOSTT } from '@/api'
 import { useMainStore } from '@/store'
 import { ArchiveOutline as ArchiveIcon } from '@vicons/ionicons5'
@@ -66,11 +89,12 @@ const main = useMainStore()
 const showModal = ref(false)
 const message = useMessage()
 
-const form = reactive<{ file: File | null }>({
-  file: null
+const form = reactive<{ file: File | null; name: string }>({
+  file: null,
+  name: ''
 })
 
-const emits = defineEmits(['close','submit'])
+const emits = defineEmits(['close', 'submit'])
 
 const props = defineProps({
   show: {
@@ -96,11 +120,12 @@ const handleSave = async () => {
   if (form.file) {
     const data = {
       file: form.file,
+      name: form.name,
       num: main.sceneCode
     }
     await saveTOSTT(data)
+    message.success('新增成功!')
     emits('submit')
-
   } else {
     message.error('请上传语音文件')
   }

+ 6 - 5
src/views/textToaudio/ttsModel.vue

@@ -39,7 +39,7 @@
         <n-flex style="flex: 1" vertical>
           <div>选择人物</div>
 
-          <n-flex class="card-select mb-5" justify="center" >
+          <n-flex class="card-select mb-5" justify="center">
             <template v-for="(card, index) in cardList" :key="index">
               <n-card
                 style="flex: 1 1 48%"
@@ -108,7 +108,7 @@
 
 <script setup lang="ts">
 import { ref, reactive, watchEffect, computed } from 'vue'
-import { NSlider, NForm, NFormItem, NAvatar } from 'naive-ui'
+import { NSlider, NForm, NFormItem, NAvatar, useMessage } from 'naive-ui'
 import { saveTOTTS, SaveTOTTSParams } from '@/api'
 import { useMainStore } from '@/store'
 
@@ -123,7 +123,7 @@ const form = reactive({
   speed: 1,
   volume: 5
 })
-
+const message = useMessage()
 const emits = defineEmits(['close', 'submit'])
 
 const props = defineProps({
@@ -182,8 +182,9 @@ const handleSave = async () => {
     ...form,
     num: main.sceneCode
   }
-  const res = await saveTOTTS(data)
-  console.log(res)
+  await saveTOTTS(data)
+  // console.log(res)
+  message.success('新增成功!')
   emits('submit')
 }
 

+ 7 - 4
src/views/topicNavigation/index.vue

@@ -123,7 +123,7 @@
 </template>
 
 <script setup lang="ts">
-import { computed, ref, watch } from 'vue'
+import { computed, ref, watch, watchEffect } from 'vue'
 import { sdk, clearScreen } from '@/sdk'
 import { onMounted, onUnmounted } from 'vue'
 import {
@@ -144,6 +144,7 @@ const main = useMainStore()
 const currentEditing = ref(NaN)
 const currentPanoEditing = ref()
 const isPanoEditing = ref(false)
+const naviData = computed(() => main.getEditorData.navigation)
 const dataList = ref<
   {
     title: string
@@ -169,7 +170,11 @@ const handleAdd = () => {
     // message.warning('请先保存数据!')
   }
 }
-
+watchEffect(() => {
+  if (naviData.value) {
+    dataList.value = naviData.value
+  }
+})
 onMounted(() => {
   sdk.then((sdk) => {
     sdk.Scene.whenLoaded(() => {
@@ -237,8 +242,6 @@ const handleItem = (index: number) => {
 
 const handleItemSubmit = () => {
   isPanoEditing.value = false
-
-  sdk.then((sdk) => {})
   main.syncNavigation(dataList.value)
 }
 const handlePanoDel = (index: number) => {