From cd17434058e1ad5a1a985d3a0b1b137f31d3d849 Mon Sep 17 00:00:00 2001 From: "wu.jian2" Date: Fri, 1 Sep 2023 16:38:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=B7=91=E9=A9=AC?= =?UTF-8?q?=E7=81=AF=E7=BB=84=E4=BB=B6=E5=9C=A8=E9=A6=96=E6=AC=A1=E6=89=93?= =?UTF-8?q?=E5=BC=80=E9=85=8D=E7=BD=AE=E9=9D=A2=E6=9D=BF=EF=BC=8C=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E9=9F=B3=E9=A2=91=E5=92=8C=E6=96=87=E5=AD=97=E6=92=AD?= =?UTF-8?q?=E6=8A=A5=E5=90=8C=E6=97=B6=E5=87=BA=E7=8E=B0=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5=E5=92=8C=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=90=8E=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=87=BA=E7=8E=B0=E9=87=8D=E5=A4=8D=E4=B8=A4?= =?UTF-8?q?=E6=AC=A1=E6=96=87=E5=AD=97=E6=92=AD=E6=8A=A5=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BasicComponents/Marquee/index.vue | 31 ++++++++++++++----- data-room-ui/packages/Render/RenderCard.vue | 1 - 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/data-room-ui/packages/BasicComponents/Marquee/index.vue b/data-room-ui/packages/BasicComponents/Marquee/index.vue index 52fd18ea..c56879a9 100644 --- a/data-room-ui/packages/BasicComponents/Marquee/index.vue +++ b/data-room-ui/packages/BasicComponents/Marquee/index.vue @@ -112,6 +112,7 @@ import linkageMixins from 'data-room-ui/js/mixins/linkageMixins' import { settingToTheme } from 'data-room-ui/js/utils/themeFormatting' import cloneDeep from 'lodash/cloneDeep' import IconSvg from 'data-room-ui/SvgIcon' +import { get } from 'sortablejs' export default { name: 'Marquee', props: { @@ -127,6 +128,7 @@ export default { data () { return { showVoiceSwitch: false, + visibilityState: false, voiceSwitchValue: true, customClass: {}, attributeName: { @@ -159,6 +161,7 @@ export default { // 语音播报 speech: null, isInit: false, + firstSpeech: true, numberBroadcasts: 0 } }, @@ -167,16 +170,19 @@ export default { speechText () { return this.config.customize.title || '' }, - isPreview () { - return (this.$route.path === window?.BS_CONFIG?.routers?.previewUrl) || (this.$route.path === '/big-screen/preview') - }, - audioSrc () { - return this.config?.option?.data?.[this.config?.dataSource?.metricField] || '' + audioSrc: { + get () { + return this.config?.option?.data?.[this.config?.dataSource?.metricField] || '' + }, + set (val) { + this.config.option.data[this.config.dataSource.metricField] = val + } } }, watch: { speechText (val) { - if (!this.isPreview && this.config.customize.voiceBroadcast && !this.isInit) { + if (!this.isPreview && this.config.customize.voiceBroadcast && !this.isInit && !this.firstSpeech) { + console.log(4) this.speechBroadcast(val) } else { if (this.speech) { @@ -236,6 +242,7 @@ export default { this.audio.play() } else { this.speech = null + console.log(1) this.speechBroadcast(this.config.customize.title) this.isInit = false } @@ -271,7 +278,8 @@ export default { config.option.data = [] } // 清除上一个visibilitychange监听,重新开始监听 - if (this.voiceSwitchValue) { + if (this.voiceSwitchValue && !this.visibilityState && this.isInit) { + console.log(6) this.voiceBroadcast(config) } return config @@ -294,6 +302,7 @@ export default { } else if (config.customize.title) { // 页面初始化不执行 if (!this.isInit) { + console.log(2) this.speechBroadcast(config.customize.title) } } @@ -326,9 +335,13 @@ export default { }, changeStyle (config) { config = { ...this.config, ...config } - if (config.customize.voiceBroadcast && this.isInit && !this.audioSrc) { + if (config.customize.voiceBroadcast && this.isInit && !config?.option?.data?.[this.config?.dataSource?.metricField]) { this.isInit = false + console.log(3) this.speechBroadcast(config.customize.title) + this.$nextTick(() => { + this.firstSpeech = false + }) } // 样式改变时更新主题配置 config.theme = settingToTheme(cloneDeep(config), this.customTheme) @@ -340,6 +353,7 @@ export default { // 监听页面是否可见 handleVisibilityChange () { if (document.visibilityState === 'hidden') { + this.visibilityState = true if (this.audio) { this.audio.pause() } @@ -347,6 +361,7 @@ export default { this.speech = null } } else { + this.visibilityState = false if (this.audio) { this.audio.play() } diff --git a/data-room-ui/packages/Render/RenderCard.vue b/data-room-ui/packages/Render/RenderCard.vue index c10e9c31..dadd12b4 100644 --- a/data-room-ui/packages/Render/RenderCard.vue +++ b/data-room-ui/packages/Render/RenderCard.vue @@ -57,7 +57,6 @@ export default { }, computed: {}, mounted () { - console.log(this.$refs) // 调用初始化方法 dataInit(this) },