Commit 622e50b1 authored by 郭铭瑶's avatar 郭铭瑶 🤘

10/21第2~6点改动测试

parent 3498feca
......@@ -14,7 +14,7 @@ import store from '@/store'
export default async function useInitMap(
el: HTMLElement,
camera: any,
showArea: any,
showCommittee: any,
showBuilding: any,
) {
const config = api.MAP_CONFIG
......@@ -300,13 +300,14 @@ export default async function useInitMap(
data?.['管辖范围']?.map(
(item: any) => item?.['范围名称'],
) || []
areas.forEach((area) => showArea(area))
areas.forEach((area) => showCommittee(area))
// TODO 待测试
} else if (data?.['类别']?.includes('两新')) {
const buildings =
data?.['管辖楼宇']?.map((item: any) => item?.OBJECTID) ||
[]
buildings.forEach((building) => showBuilding(building))
// window.modelHighlight = buildings.map((building) => building && layerView.highlight(building))
// TODO 待测试
}
} else if (data?.isList) {
......
import IatRecorder from '@/util/iat-recorder'
import { onBeforeUnmount, ref } from 'vue'
type Status = 'init' | 'ing' | 'end'
type Status = 'init' | 'ing' | 'stop' | 'end'
export default function useVoiceRecorder() {
const iatRecorder: any = new IatRecorder()
const result = ref('')
const status = ref<Status>('init')
const timer: any = null
iatRecorder.onTextChange = function (txt: string) {
result.value = txt
}
iatRecorder.onWillStatusChange = function (_, curStatus: Status) {
status.value = curStatus
// let seconds = 0
// if (curStatus === 'ing') {
// timer = setInterval(() => {
// seconds += 1
// if (seconds >= 60) {
// iatRecorder.stop()
// clearInterval(timer)
// }
// }, 1000)
// }
}
onBeforeUnmount(() => {
iatRecorder.stop()
timer && clearInterval(timer)
resetRecorder()
})
function toggleRecorder() {
......@@ -37,12 +25,12 @@ export default function useVoiceRecorder() {
}
}
function reset() {
function resetRecorder() {
iatRecorder.stop()
iatRecorder.status === 'init'
status.value = 'init'
result.value = ''
}
return { result, toggleRecorder, status, reset }
return { result, toggleRecorder, status, resetRecorder }
}
......@@ -87,10 +87,10 @@ export default class IatRecorder {
this.result(e.data)
}
iatWS.onerror = (e) => {
this.recorderStop()
this.recorderStop('end')
}
iatWS.onclose = (e) => {
this.recorderStop()
this.recorderStop('end')
}
})
}
......@@ -197,7 +197,7 @@ export default class IatRecorder {
}
}
// 暂停录音
recorderStop() {
recorderStop(status) {
// safari下suspend后再次resume录音内容将是空白,设置safari下不做suspend
if (
!(
......@@ -206,7 +206,7 @@ export default class IatRecorder {
) {
this.audioContext && this.audioContext.suspend()
}
this.setStatus('end')
this.setStatus(status)
}
// 处理音频数据
// transAudioData(audioData) {
......@@ -237,8 +237,9 @@ export default class IatRecorder {
language: this.language, //小语种可在控制台--语音听写(流式)--方言/语种处添加试用
domain: 'iat',
accent: this.accent, //中文方言可在控制台--语音听写(流式)--方言/语种处添加试用
vad_eos: 5000,
vad_eos: 2000,
dwa: 'wpgs', //为使该功能生效,需到控制台开通动态修正功能(该功能免费)
ptt: 1,
},
data: {
status: 0,
......@@ -329,6 +330,6 @@ export default class IatRecorder {
this.setResultText({ resultText: '', resultTextTemp: '' })
}
stop() {
this.recorderStop()
this.recorderStop('stop')
}
}
......@@ -25,7 +25,7 @@ onMounted(async () => {
await nextTick()
if (mapRef.value) {
// eslint-disable-next-line
await useInitMap(mapRef.value, camera, showArea, showBuilding)
await useInitMap(mapRef.value, camera, showCommittee, showBuilding)
}
})
......
......@@ -266,6 +266,7 @@
v-model:value="detailData.attachment"
placeholder="请输入活动内容描述(800字以内)"
type="textarea"
:on-input="onInput"
/>
</n-form-item-gi>
<n-form-item-gi
......@@ -339,18 +340,24 @@ import useAliOss from '@/hooks/useAliOss'
import useExportDocx from '@/hooks/useExportDocx'
import useVoiceRecorder from '@/hooks/useVoiceRecorder'
const { result, toggleRecorder, status } = useVoiceRecorder()
watch(
() => result.value,
(txt) => {
console.log('txt', txt)
if (!detailData.value.attachment) {
detailData.value.attachment = txt
} else {
detailData.value.attachment += txt
}
},
)
const { result, toggleRecorder, status, resetRecorder } = useVoiceRecorder()
const activityDescribtion = ref('')
watch([() => result.value, () => status.value], ([txt, sta]) => {
if (!txt) return
if (activityDescribtion.value) {
detailData.value.attachment = activityDescribtion.value + txt
} else {
detailData.value.attachment = txt
}
if (sta === 'end') {
activityDescribtion.value = detailData.value.attachment
}
})
function onInput(val) {
if (!val) {
resetRecorder()
}
}
const message = useMessage()
const props = defineProps({
data: {
......@@ -391,6 +398,7 @@ watch(
const show = computed(() => store.state.showNewActivityDrawer)
const closeDrawer = () => {
store.commit('SET_NEW_ACTIVITY_DRAWER', false)
resetRecorder()
basicData.value = {}
memberData.value = {}
detailData.value = {}
......@@ -422,6 +430,14 @@ const basicData = ref<any>({})
const memberData = ref<any>({})
const detailData = ref<any>({})
watch(
() => detailData.value,
(data) => {
if (data?.describeType !== 'text') {
resetRecorder()
}
},
)
watch(
() => props.data,
(data) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment