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) } } )