Skip to content

Commit

Permalink
Spotless Apply
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzm0809 authored and github-actions[bot] committed Dec 19, 2023
1 parent 76b7320 commit 963b59d
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 27 deletions.
31 changes: 20 additions & 11 deletions dinky-web/src/components/RightContent/AvatarDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down Expand Up @@ -121,7 +127,9 @@ const AvatarDropdown = () => {
});
const { initialState, setInitialState } = useModel('@@initialState');

const [enableModelTip, setEnableModelTip] = useState<boolean>(Boolean(getValueFromLocalStorage(ENABLE_MODEL_TIP)));
const [enableModelTip, setEnableModelTip] = useState<boolean>(
Boolean(getValueFromLocalStorage(ENABLE_MODEL_TIP))
);

const loginOutHandler = useCallback(
async (event: MenuInfo) => {
Expand Down Expand Up @@ -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 = [
{
Expand Down Expand Up @@ -243,7 +250,9 @@ const AvatarDropdown = () => {
{
key: 'enableModelTip',
icon: enableModelTip ? <CloseCircleOutlined /> : <BugOutlined />,
label: enableModelTip ? l('menu.account.closeGlobalMessage') : l('menu.account.openGlobalMessage'),
label: enableModelTip
? l('menu.account.closeGlobalMessage')
: l('menu.account.openGlobalMessage'),
onClick: () => handleClickEnableModelTip()
},
{
Expand Down
6 changes: 4 additions & 2 deletions dinky-web/src/locales/en-US/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',

Expand Down
7 changes: 4 additions & 3 deletions dinky-web/src/locales/zh-CN/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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': '数据开发',

Expand Down
9 changes: 4 additions & 5 deletions dinky-web/src/pages/Other/Login/function.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -39,12 +39,11 @@ export const redirectToLogin = () => {
window.location.href = '/login';
};


export const initSomeThing = () => {
// 初始化设置主题
setLocalThemeToStorage();
// 取出本地存储是否有启用消息提示的 key , 没有的话设置一下
if (hasKeyofLocalStorage(ENABLE_MODEL_TIP)) {
setKeyToLocalStorage(ENABLE_MODEL_TIP, 'true');
}
}
};
4 changes: 2 additions & 2 deletions dinky-web/src/pages/Other/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
8 changes: 4 additions & 4 deletions dinky-web/src/requestErrorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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:
Expand Down Expand Up @@ -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 抛出的错误。
Expand Down

0 comments on commit 963b59d

Please sign in to comment.