From 7b5a00f2576ae5e2fd08ac6080f52c84c94a34a6 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Mon, 9 Sep 2024 12:47:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20=E9=92=89?= =?UTF-8?q?=E9=92=89=E5=86=85=E6=89=93=E5=BC=80=E5=88=86=E4=BA=AB=E9=93=BE?= =?UTF-8?q?=E6=8E=A5Title=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/store/modules/appearance.ts | 4 +++ core/core-frontend/src/utils/utils.ts | 30 +++++++++++++++++++ .../data-visualization/PreviewCanvas.vue | 3 ++ .../PreviewCanvasMobile.vue | 2 ++ 4 files changed, 39 insertions(+) diff --git a/core/core-frontend/src/store/modules/appearance.ts b/core/core-frontend/src/store/modules/appearance.ts index a7e1352caf..0ea98a58fc 100644 --- a/core/core-frontend/src/store/modules/appearance.ts +++ b/core/core-frontend/src/store/modules/appearance.ts @@ -5,6 +5,8 @@ import { uiLoadApi } from '@/api/login' import { useCache } from '@/hooks/web/useCache' import colorFunctions from 'less/lib/less/functions/color.js' import colorTree from 'less/lib/less/tree/color.js' +import { setTitle } from '@/utils/utils' + const basePath = import.meta.env.VITE_API_BASEPATH const baseUrl = basePath + '/appearance/image/' import { isBtnShow } from '@/utils/utils' @@ -312,8 +314,10 @@ export const useAppearanceStore = defineStore('appearanceStore', { if (isDataEaseBi) return if (this.name) { document.title = this.name + setTitle(this.name) } else { document.title = 'DataEase' + setTitle('DataEase') } const link = document.querySelector('link[rel="icon"]') if (link) { diff --git a/core/core-frontend/src/utils/utils.ts b/core/core-frontend/src/utils/utils.ts index c82bb08f12..9699452db5 100644 --- a/core/core-frontend/src/utils/utils.ts +++ b/core/core-frontend/src/utils/utils.ts @@ -1,5 +1,6 @@ import { BusiTreeNode } from '@/models/tree/TreeNode' import { useCache } from '@/hooks/web/useCache' +import { loadScript } from '@/utils/RemoteJs' const { wsCache } = useCache() export function deepCopy(target) { @@ -135,6 +136,35 @@ export function isMobile() { ) } +export const isDingTalk = window.navigator.userAgent.toLowerCase().includes('dingtalk') + +export const setTitle = (title?: string) => { + if (!isDingTalk) { + document.title = title || 'DataEase' + return + } + const jsUrl = 'https://g.alicdn.com/dingding/dingtalk-jsapi/3.0.25/dingtalk.open.js' + const jsId = 'fit2cloud-dataease-v2-platform-client-dingtalk' + if (window['dd'] && window['dd'].biz?.navigation?.setTitle) { + window['dd'].biz.navigation.setTitle({ + title: title + }) + return + } + const awaitMethod = loadScript(jsUrl, jsId) + awaitMethod + .then(() => { + window['dd'].ready(() => { + window['dd'].biz.navigation.setTitle({ + title: title + }) + }) + }) + .catch(() => { + document.title = title || 'DataEase' + }) +} + export function isTablet() { const userAgent = navigator.userAgent const tabletRegex = /iPad|Silk|Galaxy Tab|PlayBook|BlackBerry|(tablet|ipad|playbook)/i diff --git a/core/core-frontend/src/views/data-visualization/PreviewCanvas.vue b/core/core-frontend/src/views/data-visualization/PreviewCanvas.vue index c7114409af..8f80e52398 100644 --- a/core/core-frontend/src/views/data-visualization/PreviewCanvas.vue +++ b/core/core-frontend/src/views/data-visualization/PreviewCanvas.vue @@ -15,6 +15,8 @@ import { useI18n } from '@/hooks/web/useI18n' import { XpackComponent } from '@/components/plugin' import { propTypes } from '@/utils/propTypes' import { downloadCanvas2 } from '@/utils/imgUtils' +import { setTitle } from '@/utils/utils' + const dvMainStore = dvMainStoreWithOut() const { t } = useI18n() const embeddedStore = useEmbedded() @@ -116,6 +118,7 @@ const loadCanvasDataAsync = async (dvId, dvType) => { if (props.publicLinkStatus) { // 设置浏览器title为当前仪表板名称 document.title = dvInfo.name + setTitle(dvInfo.name) } } ) diff --git a/core/core-frontend/src/views/data-visualization/PreviewCanvasMobile.vue b/core/core-frontend/src/views/data-visualization/PreviewCanvasMobile.vue index 430277fe04..051f387f1c 100644 --- a/core/core-frontend/src/views/data-visualization/PreviewCanvasMobile.vue +++ b/core/core-frontend/src/views/data-visualization/PreviewCanvasMobile.vue @@ -12,6 +12,7 @@ import { useEmbedded } from '@/store/modules/embedded' import { useI18n } from '@/hooks/web/useI18n' import { XpackComponent } from '@/components/plugin' import { propTypes } from '@/utils/propTypes' +import { setTitle } from '@/utils/utils' const dvMainStore = dvMainStoreWithOut() const { t } = useI18n() @@ -115,6 +116,7 @@ const loadCanvasDataAsync = async (dvId, dvType) => { if (props.publicLinkStatus) { // 设置浏览器title为当前仪表板名称 document.title = dvInfo.name + setTitle(dvInfo.name) } } )