diff --git a/dinky-web/src/components/RightContent/AvatarDropdown.tsx b/dinky-web/src/components/RightContent/AvatarDropdown.tsx index 89630490b0..4a33ee931a 100644 --- a/dinky-web/src/components/RightContent/AvatarDropdown.tsx +++ b/dinky-web/src/components/RightContent/AvatarDropdown.tsx @@ -18,12 +18,19 @@ */ import { chooseTenantSubmit, outLogin } from '@/services/BusinessCrud'; -import {getValueFromLocalStorage, setKeyToLocalStorage, setTenantStorageAndCookie} from '@/utils/function'; +import { ENABLE_MODEL_TIP } from '@/services/constants'; +import { + getValueFromLocalStorage, + setKeyToLocalStorage, + setTenantStorageAndCookie +} from '@/utils/function'; import { l } from '@/utils/intl'; -import {ErrorNotification, SuccessNotification, WarningNotification} from '@/utils/messages'; +import { ErrorNotification, SuccessNotification, WarningNotification } from '@/utils/messages'; import { BugOutlined, - ClearOutlined, CloseCircleOutlined, LogoutOutlined, + ClearOutlined, + CloseCircleOutlined, + LogoutOutlined, TeamOutlined, UserOutlined, UserSwitchOutlined @@ -35,9 +42,8 @@ import { Avatar, Modal, Spin } from 'antd'; import { stringify } from 'querystring'; import { ItemType } from 'rc-menu/es/interface'; import type { MenuInfo } from 'rc-menu/lib/interface'; -import {useCallback, useState} from 'react'; +import { useCallback, useState } from 'react'; import HeaderDropdown from '../HeaderDropdown'; -import {ENABLE_MODEL_TIP} from "@/services/constants"; export const loginOut = async () => { await outLogin(); @@ -121,7 +127,9 @@ const AvatarDropdown = () => { }); const { initialState, setInitialState } = useModel('@@initialState'); - const [enableModelTip, setEnableModelTip] = useState(Boolean(getValueFromLocalStorage(ENABLE_MODEL_TIP))); + const [enableModelTip, setEnableModelTip] = useState( + Boolean(getValueFromLocalStorage(ENABLE_MODEL_TIP)) + ); const loginOutHandler = useCallback( async (event: MenuInfo) => { @@ -191,16 +199,15 @@ const AvatarDropdown = () => { return chooseTenantList; }; - const handleClickEnableModelTip = () => { - setKeyToLocalStorage(ENABLE_MODEL_TIP,String(!enableModelTip)); + setKeyToLocalStorage(ENABLE_MODEL_TIP, String(!enableModelTip)); setEnableModelTip(!enableModelTip); - if(!enableModelTip) { + if (!enableModelTip) { SuccessNotification(l('menu.account.openGlobalMessageTip')); } else { WarningNotification(l('menu.account.closeGlobalMessageTip')); } - } + }; const menuItems = [ { @@ -243,7 +250,9 @@ const AvatarDropdown = () => { { key: 'enableModelTip', icon: enableModelTip ? : , - label: enableModelTip ? l('menu.account.closeGlobalMessage') : l('menu.account.openGlobalMessage'), + label: enableModelTip + ? l('menu.account.closeGlobalMessage') + : l('menu.account.openGlobalMessage'), onClick: () => handleClickEnableModelTip() }, { diff --git a/dinky-web/src/locales/en-US/menu.ts b/dinky-web/src/locales/en-US/menu.ts index 91e93b5cd6..ab64158e27 100644 --- a/dinky-web/src/locales/en-US/menu.ts +++ b/dinky-web/src/locales/en-US/menu.ts @@ -39,8 +39,10 @@ export default { 'menu.account.checkTenantConfirm': 'Are you sure to switch tenant [ {tenantCode} ] ?', 'menu.account.closeGlobalMessage': 'Close developer mode', 'menu.account.openGlobalMessage': 'Turn on developer mode', - 'menu.account.closeGlobalMessageTip': 'You have turned off the developer mode and will not receive all exception information returned by the background. You can only receive warning information.', - 'menu.account.openGlobalMessageTip': 'Developer mode is turned on. You can receive all exception/warning information returned by the background. If you do not want to receive the exception stack, please turn off this function.', + 'menu.account.closeGlobalMessageTip': + 'You have turned off the developer mode and will not receive all exception information returned by the background. You can only receive warning information.', + 'menu.account.openGlobalMessageTip': + 'Developer mode is turned on. You can receive all exception/warning information returned by the background. If you do not want to receive the exception stack, please turn off this function.', 'menu.datastudio': 'Data Studio', diff --git a/dinky-web/src/locales/zh-CN/menu.ts b/dinky-web/src/locales/zh-CN/menu.ts index 9e47539547..09afe4b85d 100644 --- a/dinky-web/src/locales/zh-CN/menu.ts +++ b/dinky-web/src/locales/zh-CN/menu.ts @@ -39,9 +39,10 @@ export default { 'menu.account.checkTenantConfirm': '你确定切换租户【{tenantCode}】吗?', 'menu.account.closeGlobalMessage': '关闭开发者模式', 'menu.account.openGlobalMessage': '开启开发者模式', - 'menu.account.closeGlobalMessageTip': '你已关闭开发者模式,将不会接收到后台返回的所有异常信息,只能收到警告信息.', - 'menu.account.openGlobalMessageTip': '已开启开发者模式,你可以接收到后台返回的所有异常/警告信息,如果你不想接收异常堆栈,请关闭此功能.', - + 'menu.account.closeGlobalMessageTip': + '你已关闭开发者模式,将不会接收到后台返回的所有异常信息,只能收到警告信息.', + 'menu.account.openGlobalMessageTip': + '已开启开发者模式,你可以接收到后台返回的所有异常/警告信息,如果你不想接收异常堆栈,请关闭此功能.', 'menu.datastudio': '数据开发', diff --git a/dinky-web/src/pages/Other/Login/function.tsx b/dinky-web/src/pages/Other/Login/function.tsx index e75ecfdc47..027478c41f 100644 --- a/dinky-web/src/pages/Other/Login/function.tsx +++ b/dinky-web/src/pages/Other/Login/function.tsx @@ -17,13 +17,13 @@ * */ -import { history } from '@@/core/history'; +import { ENABLE_MODEL_TIP } from '@/services/constants'; import { hasKeyofLocalStorage, setKeyToLocalStorage, setLocalThemeToStorage -} from "@/utils/function"; -import {ENABLE_MODEL_TIP} from "@/services/constants"; +} from '@/utils/function'; +import { history } from '@@/core/history'; /** 此方法会跳转到 redirect 参数所在的位置 */ export const gotoRedirectUrl = () => { @@ -39,7 +39,6 @@ export const redirectToLogin = () => { window.location.href = '/login'; }; - export const initSomeThing = () => { // 初始化设置主题 setLocalThemeToStorage(); @@ -47,4 +46,4 @@ export const initSomeThing = () => { if (hasKeyofLocalStorage(ENABLE_MODEL_TIP)) { setKeyToLocalStorage(ENABLE_MODEL_TIP, 'true'); } -} +}; diff --git a/dinky-web/src/pages/Other/Login/index.tsx b/dinky-web/src/pages/Other/Login/index.tsx index e861426140..15120773cc 100644 --- a/dinky-web/src/pages/Other/Login/index.tsx +++ b/dinky-web/src/pages/Other/Login/index.tsx @@ -19,13 +19,13 @@ import Footer from '@/components/Footer'; import ChooseModal from '@/pages/Other/Login/ChooseModal'; -import {gotoRedirectUrl, initSomeThing, redirectToLogin} from '@/pages/Other/Login/function'; +import { gotoRedirectUrl, initSomeThing, redirectToLogin } from '@/pages/Other/Login/function'; import LangSwitch from '@/pages/Other/Login/LangSwitch'; import { chooseTenantSubmit, login, queryDataByParams } from '@/services/BusinessCrud'; import { API } from '@/services/data'; import { API_CONSTANTS } from '@/services/endpoints'; import { UserBaseInfo } from '@/types/AuthCenter/data'; -import { setLocalThemeToStorage, setTenantStorageAndCookie } from '@/utils/function'; +import { setTenantStorageAndCookie } from '@/utils/function'; import { useLocalStorage } from '@/utils/hook/useLocalStorage'; import { l } from '@/utils/intl'; import { ErrorMessage, SuccessMessageAsync } from '@/utils/messages'; diff --git a/dinky-web/src/requestErrorConfig.ts b/dinky-web/src/requestErrorConfig.ts index 0dba5666db..4bc3520ae6 100644 --- a/dinky-web/src/requestErrorConfig.ts +++ b/dinky-web/src/requestErrorConfig.ts @@ -17,14 +17,14 @@ * */ +import { ENABLE_MODEL_TIP } from '@/services/constants'; import { API_CONSTANTS } from '@/services/endpoints'; +import { getValueFromLocalStorage } from '@/utils/function'; import { l } from '@/utils/intl'; import { ErrorNotification, WarningNotification } from '@/utils/messages'; import { history } from '@@/core/history'; import type { RequestOptions } from '@@/plugin-request/request'; import type { RequestConfig } from '@umijs/max'; -import {getValueFromLocalStorage} from "@/utils/function"; -import {ENABLE_MODEL_TIP} from "@/services/constants"; // 错误处理方案: 错误类型 enum ErrorCode { @@ -45,7 +45,7 @@ interface ResponseStructure { const handleBizError = (result: ResponseStructure) => { const { msg, code, data } = result; - console.log(JSON.stringify(msg)) + console.log(JSON.stringify(msg)); switch (code) { case ErrorCode.SUCCESS: @@ -89,7 +89,7 @@ export const errorConfig: RequestConfig = { }, // 错误接收及处理 errorHandler: (error: any, opts: any) => { - console.log(error) + console.log(error); if (opts?.skipErrorHandler) throw error; // 我们的 errorThrower 抛出的错误。