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

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

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