From 4f3e6ac8b090b085329f3d05f2da64ae730d4700 Mon Sep 17 00:00:00 2001 From: Feynman Date: Tue, 12 May 2026 17:41:18 +0800 Subject: [PATCH 1/2] refactor: streamline initialization process in main.ts and update settings handling in Login.vue --- apps/daas/src/main.ts | 57 ++++++++++++----------------- apps/daas/src/views/login/Login.vue | 15 +++++--- 2 files changed, 33 insertions(+), 39 deletions(-) diff --git a/apps/daas/src/main.ts b/apps/daas/src/main.ts index 4e27e5b79..a12870802 100644 --- a/apps/daas/src/main.ts +++ b/apps/daas/src/main.ts @@ -119,38 +119,36 @@ const init = () => { const loading = ElLoading.service({ fullscreen: true }) -fetchSettings() - .then(async (data) => { - const initData = data || [] - setSettings(initData) - - if (initData.length) { - localStorage.setItem('TAPDATA_SETTINGS', JSON.stringify(initData)) - store.commit('setAppearanceBySetting', data) - } - if (token) { - //无权限,说明是首次进入页面,重新请求后台获取 - const user = await getUserInfoByToken().catch(() => { - init() - return null - }) +const bootstrap = async () => { + if (token) { + //无权限,说明是首次进入页面,重新请求后台获取 + const user = await getUserInfoByToken().catch(() => { + init() + return null + }) - if (!user) { - return - } + if (user) { + configUser(user) await store.dispatch('feature/getFeatures') + const settings = await fetchSettings() + setSettings(settings) - //权限存在则存入缓存并继续向下走 - configUser(user) + if (settings.length) { + localStorage.setItem('TAPDATA_SETTINGS', JSON.stringify(settings)) + store.commit('setAppearanceBySetting', settings) + } } + } - init() - // 设置服务器时间 - fetchTimestamp().then((t) => { - Time.setTime(t) - }) + init() + // 设置服务器时间 + fetchTimestamp().then((t) => { + Time.setTime(t) }) +} + +bootstrap() .catch((error) => { // eslint-disable-next-line console.log(i18n.global.t('daas_src_main_qingqiuquanjupei') + error) @@ -158,15 +156,6 @@ fetchSettings() .finally(() => { loading.close() }) -//获取全局项目设置(OEM信息) - -//解决浏览器tab切换时,element ui 组件tooltip气泡不消失的问题 #7752 -document.addEventListener('visibilitychange', () => { - setTimeout(() => { - const ele = document.querySelector(':focus') - ele && ele.blur() - }, 50) -}) // community add jira issue collector if (import.meta.env.VUE_APP_MODE === 'community') { diff --git a/apps/daas/src/views/login/Login.vue b/apps/daas/src/views/login/Login.vue index 9bcd4b34b..f3f3a4822 100644 --- a/apps/daas/src/views/login/Login.vue +++ b/apps/daas/src/views/login/Login.vue @@ -1,4 +1,5 @@