Unverified Commit efe23a16 authored by kevin zhang's avatar kevin zhang Committed by GitHub

refactor:refactor login (#1627)

* add login * update dev api config * update login type * update dlink-web api config
parent 9fc51d87
......@@ -28,16 +28,17 @@
*/
export default {
// 如果需要自定义本地开发服务器 请取消注释按需调整
// dev: {
// // localhost:8000/api/** -> https://preview.pro.ant.design/api/**
// '/api/': {
// // 要代理的地址
// target: 'https://preview.pro.ant.design',
// // 配置了这个可以从 http 代理到 https
// // 依赖 origin 的功能可能需要这个,比如 cookie
// changeOrigin: true,
// },
// },
dev: {
// localhost:8000/api/** -> https://preview.pro.ant.design/api/**
'/api/': {
// 要代理的地址
// target: 'http://127.0.0.1:8888/',
// target: 'https://preview.pro.ant.design',
// 配置了这个可以从 http 代理到 https
// 依赖 origin 的功能可能需要这个,比如 cookie
changeOrigin: true,
},
},
/**
* @name 详细的代理配置
......
......@@ -35,9 +35,15 @@
},
"lint-staged": {
"**/*.{js,jsx,ts,tsx}": "npm run lint-staged:js",
"**/*.{js,jsx,tsx,ts,less,md,json}": ["prettier --write"]
"**/*.{js,jsx,tsx,ts,less,md,json}": [
"prettier --write"
]
},
"browserslist": ["> 1%", "last 2 versions", "not ie <= 10"],
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 10"
],
"dependencies": {
"@ant-design/icons": "^5.0.1",
"@ant-design/pro-components": "^2.3.52",
......@@ -45,6 +51,7 @@
"@umijs/route-utils": "^4.0.1",
"antd": "^5.0.0",
"classnames": "^2.3.2",
"js-cookie": "^3.0.1",
"lodash": "^4.17.21",
"moment": "^2.29.4",
"omit.js": "^2.0.2",
......@@ -83,5 +90,7 @@
"typescript": "^4.8.4",
"umi-presets-pro": "^2.0.0"
},
"engines": { "node": ">=12.0.0" }
"engines": {
"node": ">=12.0.0"
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="UTF-8"?>
<svg width="48px" height="48px" viewBox="0 0 48 48" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>位图</title>
<g id="页面" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="案例二" transform="translate(-315.000000, -84.000000)">
<g id="编组-2" transform="translate(229.000000, 68.000000)">
<g id="编组" transform="translate(70.000000, 0.000000)">
<g id="编组-3" transform="translate(16.000000, 16.000000)">
<image id="位图" x="0" y="0" width="48" height="48" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAMRWlDQ1BJQ0MgUHJvZmlsZQAASImVlwdYU9cewM8dmSSsQARkhL0EGbJlhLAiCMgUXIQkkDBiSAgibkupgnWLCKgVrYpYtA5A6sQ9iuDeD6WoVGpx4ELlnQyotd9773uH79z7u//zP//FuTfnAKBTy5NK81BdAPIlhbKEyFDW5LR0FqkbIPAPAGPA4vHlUnZ8fAx8AsP3v7c3N1S64KqL0tY/x/9r0xMI5XwAkHjImQI5Px/yAQDwUr5UVggA0RfKrWcVSpU8FbKBDAYIWarkbDWXKjlTzVUqnaQEDuTdAJBpPJ4sGwDtFihnFfGzoR3tW5DdJAKxBAAdMuQgvogngBwFeUx+/kwlQz3gkPmFney/2cwcscnjZY+wOhdVI4eJ5dI83uz/sxz/u+XnKYZ92MFOE8miEpQ5w7rdyp0ZrWQa5D5JZmwcZH3I78QClT5klCpSRCWr9VFTvpwDawaYkN0EvLBoyKaQIyR5sTEaeWaWOIILGa4QtFhcyE3SzF0ilIcnamzWymYmxA1zlozD1sxt5MlUfpX6pxS5yWyN/VsiIXfY/usSUVKqOmaMWiROiYWsDZkpz02MVutgNiUiTuywjkyRoIzfBrK/UBIZqraPTc+SRSRo9GX58uF8sSUiMTdWw9WFoqQojZ3dfJ4qfiPILUIJO3nYjlA+OWY4F4EwLFydO9YhlCRr8sW6pIWhCZq5L6V58Rp9nCrMi1TKrSCbyosSNXPxoEK4INX28VhpYXySOk48M4c3IV4dD14MYgAHhAEWUMCeCWaCHCBu72vug0/qkQjAAzKQDYTARSMZ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yEqTRbirgTVoMK6mmTDBEJ9lMq916ZjSfDNXz8q+T8BeRkq/vA7sMdbV0DBHZvnRDaPD5924jQ3JtnzsxLmvXrN7ATOl+WGNymWl/XFtsm/XBnuWJRW9nM2nhPIl4woEKh2vTAcSFcQUnXtQGYkcIcPhVmC6+y93qxO83Rf1HkP4dWgacuWLnxNXKhM64UWJ2lzWNVx17CvZgTDjNUtd3mhKL0ciNPNGRG0uK2+FnWvntcDWvFipfGZtg+2UjsixGjvMN0fEJXvlRmBvy1ZHLkM5umEEVqFVg3uwRfy758XebHz1WlZ0a5Dzg6OLeqYllSlzbK9x5ai4yB1EaX8/HThGI089nVQhh/Xv/z2lCUMj7YK2NZXKNeRbvLQDoQRNlqu+Vfr4/XVg+i5H3DHfxYoyFV1eSEIe181RXhzIwnLN/ijtEkudP8zme2Wnchk2dgQqL5HSv98ODPfRVl0TMOVG58XARrfbUB/zTgjGl5PSMFzRBvuiN9iq4C4DnflyJ0o3Ri/Aq9OB+M2g6nJtXkQ37y7Mtkdja1hd0DhNDS3NIMmjywKzLRdW89pFbWv4Rs8b7ApCJthj03YPNETC4v0/QXpn3DZlYjIAAAAASUVORK5CYII="></image>
</g>
</g>
</g>
</g>
</g>
</svg>
\ No newline at end of file
......@@ -17,14 +17,14 @@
import Footer from '@/components/Footer';
import RightContent from '@/components/RightContent';
import {LinkOutlined} from '@ant-design/icons';
import type {Settings as LayoutSettings} from '@ant-design/pro-components';
import {SettingDrawer} from '@ant-design/pro-components';
import type {RunTimeLayoutConfig} from '@umijs/max';
import {history, Link} from '@umijs/max';
import { LinkOutlined } from '@ant-design/icons';
import type { Settings as LayoutSettings } from '@ant-design/pro-components';
import { SettingDrawer } from '@ant-design/pro-components';
import type { RunTimeLayoutConfig } from '@umijs/max';
import { history, Link } from '@umijs/max';
import defaultSettings from '../config/defaultSettings';
import {errorConfig} from './requestErrorConfig';
import {currentUser as queryCurrentUser} from './services/api';
import { errorConfig } from './requestErrorConfig';
import { currentUser as queryCurrentUser } from './services/api';
import React from 'react';
const isDev = process.env.NODE_ENV === 'development';
......@@ -41,17 +41,32 @@ export async function getInitialState(): Promise<{
}> {
const fetchUserInfo = async () => {
try {
const msg = await queryCurrentUser({
skipErrorHandler: true,
});
return msg.data;
const result = await queryCurrentUser();
const currentUser: API.CurrentUser = {
id: result.datas.user.id,
username: result.datas.user.username,
password: result.datas.user.password,
nickname: result.datas.user.nickname,
worknum: result.datas.user.worknum,
avatar: result.datas.user.avatar ? result.datas.user.avatar : '/icons/user_avatar.png',
mobile: result.datas.user.mobile,
enabled: result.datas.user.enabled,
isDelete: result.datas.user.isDelete,
createTime: result.datas.user.createTime,
updateTime: result.datas.user.updateTime,
isAdmin: result.datas.user.isAdmin,
roleList: result.datas.roleList,
tenantList: result.datas.tenantList,
currentTenant: result.datas.currentTenant,
};
return currentUser;
} catch (error) {
// history.push(loginPath);
history.push(loginPath);
}
return undefined;
};
// 如果不是登录页面,执行
const { location } = history;
const {location} = history;
if (location.pathname !== loginPath) {
const currentUser = await fetchUserInfo();
return {
......@@ -67,18 +82,15 @@ export async function getInitialState(): Promise<{
}
// ProLayout 支持的api https://procomponents.ant.design/components/layout
export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => {
export const layout: RunTimeLayoutConfig = ({initialState, setInitialState}) => {
return {
rightContentRender: () => <RightContent />,
waterMarkProps: {
content: initialState?.currentUser?.name,
},
footerRender: () => <Footer />,
onPageChange: () => {
const { location } = history;
const {location} = history;
// 如果没有登录,重定向到 login
if (!initialState?.currentUser && location.pathname !== loginPath) {
// history.push(loginPath);
history.push(loginPath);
}
},
layoutBgImgList: [
......@@ -103,11 +115,11 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
],
links: isDev
? [
<Link key="openapi" to="/umi/plugin/openapi" target="_blank">
<LinkOutlined />
<span>OpenAPI 文档</span>
</Link>,
]
<Link key="openapi" to="/umi/plugin/openapi" target="_blank">
<LinkOutlined />
<span>OpenAPI 文档</span>
</Link>,
]
: [],
menuHeaderRender: undefined,
// 自定义 403 页面
......
......@@ -15,10 +15,10 @@
* limitations under the License.
*/
import {Dropdown} from 'antd';
import type {DropDownProps} from 'antd/es/dropdown';
import { Dropdown } from 'antd';
import type { DropDownProps } from 'antd/es/dropdown';
import React from 'react';
import {useEmotionCss} from '@ant-design/use-emotion-css';
import { useEmotionCss } from '@ant-design/use-emotion-css';
import classNames from 'classnames';
export type HeaderDropdownProps = {
......@@ -26,8 +26,8 @@ export type HeaderDropdownProps = {
placement?: 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topCenter' | 'topRight' | 'bottomCenter';
} & Omit<DropDownProps, 'overlay'>;
const HeaderDropdown: React.FC<HeaderDropdownProps> = ({ overlayClassName: cls, ...restProps }) => {
const className = useEmotionCss(({ token }) => {
const HeaderDropdown: React.FC<HeaderDropdownProps> = ({overlayClassName: cls, ...restProps}) => {
const className = useEmotionCss(({token}) => {
return {
[`@media screen and (max-width: ${token.screenXS})`]: {
width: '100%',
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import React, { useState } from 'react';
import { Button, Form, Input, Modal } from 'antd';
import { l } from "@/utils/intl";
import { PasswordItem } from '@/types/User/data';
export type PasswordFormProps = {
onCancel: (flag?: boolean) => void;
onSubmit: (values: Partial<PasswordItem>) => void;
modalVisible: boolean;
values: Partial<PasswordItem>;
};
const formLayout = {
labelCol: { span: 7 },
wrapperCol: { span: 13 },
};
const PasswordForm: React.FC<PasswordFormProps> = (props) => {
const [form] = Form.useForm();
const [formVals, setFormVals] = useState<Partial<PasswordItem>>({
username: props.values.username,
});
const {
onSubmit: handleSubmit,
onCancel: handleModalVisible,
modalVisible,
} = props;
const submitForm = async () => {
const fieldsValue = await form.validateFields();
setFormVals({ ...formVals, ...fieldsValue });
handleSubmit({ ...formVals, ...fieldsValue });
};
const renderContent = () => {
return (
<>
<Form.Item
name="password"
label={l('pages.user.UserOldPassword')}
hasFeedback
rules={[{ required: true, message: l('pages.user.UserEnterOldPassword') }]}>
<Input.Password placeholder={l('pages.user.UserEnterOldPassword')} />
</Form.Item>
<Form.Item
name="newPassword"
label={l('pages.user.UserNewPassword')}
hasFeedback
rules={[{ required: true, message: l('pages.user.UserEnterNewPassword') }]}>
<Input.Password placeholder={l('pages.user.UserEnterNewPassword')} />
</Form.Item>
<Form.Item
name="newPasswordCheck"
label={l('pages.user.UserRepeatNewPassword')}
hasFeedback
dependencies={['newPassword']}
rules={[
{
required: true,
message: l('pages.user.UserNewPasswordNotMatch'),
},
({ getFieldValue }) => ({
validator(_, value) {
if (!value || getFieldValue('newPassword') === value) {
return Promise.resolve();
}
return Promise.reject(new Error(l('pages.user.UserNewPasswordNotMatch')));
},
}),
]}>
<Input.Password placeholder={l('pages.user.UserEnterRepeatNewPassword')} />
</Form.Item>
</>
);
};
const renderFooter = () => {
return (
<>
<Button onClick={() => handleModalVisible(false)}> {l('button.cancel')}</Button>
<Button type="primary" onClick={() => submitForm()}>
{l('button.finish')}
</Button>
</>
);
};
return (
<Modal
width={"40%"}
bodyStyle={{ padding: '32px 40px 48px' }}
destroyOnClose
title={l('button.changePassword')}
visible={modalVisible}
footer={renderFooter()}
onCancel={() => handleModalVisible()}
>
<Form
{...formLayout}
form={form}
initialValues={formVals}
>
{renderContent()}
</Form>
</Modal>
);
};
export default PasswordForm;
......@@ -49,7 +49,7 @@ const Name = () => {
};
});
return <span className={`${nameClassName} anticon`}>{currentUser?.name}</span>;
return <span className={`${nameClassName} anticon`}>{currentUser?.username}</span>;
};
const AvatarLogo = () => {
......@@ -100,6 +100,7 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
alignItems: 'center',
padding: '0 8px',
cursor: 'pointer',
color:'white',
borderRadius: token.borderRadius,
'&:hover': {
backgroundColor: token.colorBgTextHover,
......@@ -138,10 +139,8 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
if (!initialState) {
return loading;
}
const { currentUser } = initialState;
if (!currentUser || !currentUser.name) {
if (!currentUser || !currentUser?.username) {
return loading;
}
......
......@@ -56,15 +56,17 @@ const GlobalHeaderRight: React.FC = () => {
const { initialState } = useModel('@@initialState');
console.log(initialState)
if (!initialState || !initialState.settings) {
return null;
}
return (
<div className={className}>
<Avatar />
<Avatar menu={true}/>
<SelectLang icon={<GlobalOutlined/>} className={actionClassName} />
<Space className={actionClassName}>{l('menu.version','',{version: VERSION})}</Space>
{/*<Space className={actionClassName}>{l('menu.version','',{version: VERSION})}</Space>*/}
</div>
);
};
......
......@@ -18,6 +18,7 @@
import menu from './en-US/menu';
import pages from './en-US/pages';
import pwa from './en-US/pwa';
import globalHeader from './en-US/global';
export default {
'navBar.lang': 'Languages',
......@@ -25,6 +26,7 @@ export default {
'layout.user.link.privacy': 'Privacy',
'layout.user.link.terms': 'Terms',
'app.copyright.produced': 'Produced by Dinky Community',
...globalHeader,
...menu,
...pwa,
...pages,
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
export default {
'button.create': 'Create',
'button.close': 'Close',
'button.confirm': 'Confirm',
'button.cancel': 'Cancel',
'button.finish': 'Finish',
'button.back': 'Back',
'button.save': 'Save',
'button.delete': 'Delete',
'button.batchDelete': 'Batch Delete',
'button.batchEnable': 'Batch Enable',
'button.batchDisable': 'Batch Disable',
'button.more': 'More',
'button.config': 'Config',
'button.edit': 'Edit',
'button.start': 'Start',
'button.stop': 'Stop',
'button.assignUser': 'Assign Users',
'button.assignRole': 'Assign Role',
'button.changePassword': 'Change Password',
'button.enable': 'Enable',
'button.disable': 'Disable',
'button.reset': 'Reset',
'button.search': 'Search',
'button.upload': 'Upload',
'button.import': 'Import',
'button.export': 'Export',
'button.submit': 'Submit',
'button.createDir': 'Create Directory',
'button.heartbeat': 'Heartbeat',
'button.recycle': 'Recycle',
'button.refresh': 'Refresh',
'button.test': 'Test',
'button.refreshData': 'Refresh Data',
'button.collapseDir': 'Collapse Directory',
'button.asc': 'ASC',
'button.desc': 'DESC',
'button.query': 'Query',
'button.exit': 'Exit',
'right.menu.open': 'Open',
'right.menu.submit': 'Sync Submit',
'right.menu.exportJson': 'Export JSON',
'right.menu.importJson': 'Import JSON',
'right.menu.rename': 'Rename',
'right.menu.copy': 'Copy',
'right.menu.cut': 'Cut',
'right.menu.paste': 'Paste',
'right.menu.delete': 'Delete',
'right.menu.createCatalogue': 'Create Directory',
'right.menu.createRootCatalogue': 'Create Root Directory',
'right.menu.uploadZipToCreate': 'Upload Zip To Create',
'right.menu.createTask': 'Create Task',
'right.menu.closeAll': 'Close All',
'right.menu.closeOther': 'Close Others',
'tips.selected': 'Selected {total} Item',
'tips.notSelected': 'Not Select',
'tips.enter': 'Please Enter',
'tips.confirm.logout.session': 'Confirm logout session [{sessionName}] ?',
'tips.confirm.delete.table': ' Are you sure you want to delete table [{tableName}]?',
'tips.create.session.success': 'Create Session [{session}] success!',
'status.enabled': 'Enabled',
'status.disabled': 'Disabled',
'global.time.second': 'S ',
'global.time.minute': 'M ',
'global.time.hour': 'H ',
'global.time.day': 'D ',
'global.time.millisecond': 'ms ',
'global.stay.tuned': 'Stay tuned',
'global.table.operate': 'Operation',
'global.table.config': 'Config',
'global.table.edit': 'Edit',
'global.table.delete': 'Delete',
'global.table.more': 'More',
'global.table.updateTime': 'Update Time',
'global.table.lastUpdateTime': 'Last Update Time',
'global.table.createTime': 'Create Time',
'global.table.startTime': 'Start Time',
'global.table.startUpTime': 'StartUp Time',
'global.table.endTime': 'End Time',
'global.table.finishTime': 'Finished Time',
'global.table.useTime': 'Duration',
'global.table.registType': 'Regist Type',
'global.table.registType.manual': 'Manual',
'global.table.registType.automatic': 'Automatic',
'global.table.isEnable': 'Is Enable',
'global.table.note': 'Note',
'global.table.status': 'Status',
'global.table.notePlaceholder': 'please input Note',
'global.table.status.normal': 'Normal',
'global.table.status.abnormal': 'Abnormal',
'global.table.jobname': 'Job Name',
'global.table.jobid': 'Job Id',
'global.table.lifecycle': 'Life Cycle',
'global.table.lifecycle.all': 'All',
'global.table.lifecycle.dev': 'Develop',
'global.table.lifecycle.publish': 'Publish',
'global.table.lifecycle.online': 'Online',
'global.table.lifecycle.unknown': 'Unknown',
'global.table.execmode': 'Execution mode',
'global.table.runmode': 'Run Mode',
'global.table.runmode.local': 'Local',
'global.table.runmode.remote': 'Remote',
'global.savepoint.strategy.disabled': 'Disabled',
'global.savepoint.strategy.latest': 'Latest',
'global.savepoint.strategy.earliest': 'Earliest',
'global.savepoint.strategy.custom': 'Custom',
};
......@@ -23,22 +23,30 @@ export default {
'pages.login.success': 'Login successful!',
'pages.login.username.placeholder': 'Username',
'pages.login.username.required': 'Please input your username!',
'pages.login.chooseTenant': 'Please Choose Tenant',
'pages.login.password.placeholder': 'Password',
'pages.login.password.required': 'Please input your password!',
'pages.login.rememberMe': 'Remember me',
'pages.about.alertMessage': 'The real-time computing platform Dinky will be released soon, and it is currently a trial version with version number {version}.',
'pages.about.Community' : 'Welcome to join the Dinky Official Community, Build a win-win situation',
'pages.about.alertMessage':
'The real-time computing platform Dinky will be released soon, and it is currently a trial version with version number {version}.',
'pages.about.Community':
'Welcome to join the Dinky Official Community, Build a win-win situation',
'pages.about.QQcode': 'QQ Official Community Group',
'pages.about.wechatCode': 'Wechat Official Account',
'pages.about.dingTalkCode': 'DingTalk Official Community Group',
'pages.about.wechatApply': 'WeChat user community group: recommendation, add wechat wenmo_ai to invite into the group (application notes Dinky + company name + position, no approval will not be written)`',
'pages.about.wechatApply':
'WeChat user community group: recommendation, add wechat wenmo_ai to invite into the group (application notes Dinky + company name + position, no approval will not be written)`',
'pages.about.precautions': 'Precautions',
'pages.about.usingHelp': 'Using Help',
'pages.about.communityRules': 'Community Rules',
'pages.about.communityRules.1': 'It is forbidden to publish or discuss content that is irrelevant or inappropriate to the subject of this group, once found it will be kicked immediately. ',
'pages.about.communityRules.2': 'For bug feedback and feature improvements or suggestions, please use issue, please read the issue document requirements. ',
'pages.about.communityRules.3': 'Please read the Readme, official account articles, official website documents, and Bilibili videos carefully before deployment and use. ',
'pages.about.communityRules.4': 'Please be polite and explain [version, execution mode, operation description, screenshot] when asking questions in the group. ',
'pages.about.communityRules.5': ' Register who is using Dinky, and can enter the enterprise user group to provide technical support. ',
'pages.about.communityRules.1':
'It is forbidden to publish or discuss content that is irrelevant or inappropriate to the subject of this group, once found it will be kicked immediately. ',
'pages.about.communityRules.2':
'For bug feedback and feature improvements or suggestions, please use issue, please read the issue document requirements. ',
'pages.about.communityRules.3':
'Please read the Readme, official account articles, official website documents, and Bilibili videos carefully before deployment and use. ',
'pages.about.communityRules.4':
'Please be polite and explain [version, execution mode, operation description, screenshot] when asking questions in the group. ',
'pages.about.communityRules.5':
' Register who is using Dinky, and can enter the enterprise user group to provide technical support. ',
};
......@@ -18,13 +18,14 @@
import menu from './zh-CN/menu';
import pages from './zh-CN/pages';
import pwa from './zh-CN/pwa';
import globalHeader from './zh-CN/global';
export default {
'navBar.lang': '语言',
'layout.user.link.help': '帮助',
'layout.user.link.privacy': '隐私',
'layout.user.link.terms': '条款',
'app.copyright.produced': 'Produced by Dinky Community',
...globalHeader,
...pages,
...menu,
...pwa,
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
export default {
'button.create': '新建',
'button.close': '关闭',
'button.confirm': '确定',
'button.cancel': '取消',
'button.finish': '完成',
'button.back': '返回',
'button.save': '保存',
'button.delete': '删除',
'button.batchDelete': '批量删除',
'button.batchEnable': '批量启用',
'button.batchDisable': '批量禁用',
'button.more': '更多',
'button.config': '配置',
'button.edit': '编辑',
'button.start': '启动',
'button.stop': '停止',
'button.assignUser': '分配用户',
'button.assignRole': '分配角色',
'button.changePassword': '修改密码',
'button.enable': '启用',
'button.disable': '禁用',
'button.reset': '重置',
'button.search': '搜索',
'button.upload': '上传',
'button.import': '导入',
'button.export': '导出',
'button.submit': '提交',
'button.createDir': '创建目录',
'button.heartbeat': '心跳',
'button.recycle': '回收',
'button.refresh': '刷新',
'button.test': '测试',
'button.refreshData': '刷新数据',
'button.collapseDir': '折叠目录',
'button.asc': '升序',
'button.desc': '倒序',
'button.query': '查询',
'button.exit': '退出',
'right.menu.open': '打开',
'right.menu.submit': '异步提交',
'right.menu.exportJson': '导出 JSON',
'right.menu.importJson': '导入 JSON',
'right.menu.rename': '重命名',
'right.menu.copy': '复制',
'right.menu.cut': '剪切',
'right.menu.paste': '粘贴',
'right.menu.delete': '删除',
'right.menu.createCatalogue': '创建目录',
'right.menu.createRootCatalogue': '创建根目录',
'right.menu.uploadZipToCreate': '上传zip包创建工程',
'right.menu.createTask': '创建作业',
'right.menu.closeAll': '关闭所有',
'right.menu.closeOther': '关闭其他',
'tips.selected': '已选择 {total} 项',
'tips.notSelected': '未选',
'tips.enter': '请输入',
'tips.confirm.logout.session': '确认注销会话【{sessionName}】 吗?',
'tips.confirm.delete.table': '确定删除表【{tableName}】吗?',
'tips.create.session.success': '创建会话【{session}】成功!',
'status.enabled': '已启用',
'status.disabled': '已禁用',
'global.time.second': '秒 ',
'global.time.minute': '分 ',
'global.time.hour': '小时 ',
'global.time.day': '天 ',
'global.time.millisecond': '毫秒 ',
'global.stay.tuned': '敬请期待',
'global.table.operate': '操作',
'global.table.updateTime': '更新时间',
'global.table.lastUpdateTime': '最近更新时间',
'global.table.createTime': '创建时间',
'global.table.startTime': '开始时间',
'global.table.startUpTime': '启动时间',
'global.table.endTime': '结束时间',
'global.table.finishTime': '完成时间',
'global.table.useTime': '耗时',
'global.table.registType': '注册方式',
'global.table.registType.manual': '手动',
'global.table.registType.automatic': '自动',
'global.table.isEnable': '是否启用',
'global.table.note': '备注',
'global.table.notePlaceholder': '请输入描述/备注!',
'global.table.status': '状态',
'global.table.status.normal': '正常',
'global.table.status.abnormal': '异常',
'global.table.jobname': '任务名称',
'global.table.jobid': '作业ID',
'global.table.lifecycle': '生命周期',
'global.table.lifecycle.all': '全部',
'global.table.lifecycle.dev': '开发中',
'global.table.lifecycle.publish': '已发布',
'global.table.lifecycle.online': '已上线',
'global.table.lifecycle.unknown': '未知',
'global.table.execmode': '执行模式',
'global.table.runmode': '运行模式',
'global.table.runmode.local': '本地',
'global.table.runmode.remote': '远程',
'global.savepoint.strategy.disabled': '禁用',
'global.savepoint.strategy.latest': '最近一次',
'global.savepoint.strategy.earliest': '最早一次',
'global.savepoint.strategy.custom': '指定一次',
};
......@@ -22,24 +22,26 @@ export default {
'pages.login.success': '登录成功!',
'pages.login.username.placeholder': '用户名',
'pages.login.username.required': '用户名是必填项!',
'pages.login.chooseTenant': '请选择租户',
'pages.login.password.placeholder': '密码',
'pages.login.password.required': '密码是必填项!',
'pages.login.rememberMe': '自动登录',
'pages.admin.subPage.title': ' 这个页面只有 admin 权限才能查看',
'pages.about.alertMessage': '实时计算平台 Dinky 即将发布,目前为体验版,版本号为 {version}。',
'pages.about.Community' : '欢迎加入 Dinky 官方社区,共建共赢',
'pages.about.Community': '欢迎加入 Dinky 官方社区,共建共赢',
'pages.about.QQcode': 'QQ官方社区群',
'pages.about.wechatCode': '微信公众号',
'pages.about.dingTalkCode': '钉钉官方社区群',
'pages.about.wechatApply': '微信用户社区群:推荐,添加微信号 wenmo_ai 邀请进群 (申请备注 Dinky + 企业名 + 职位,不写不批)',
'pages.about.wechatApply':
'微信用户社区群:推荐,添加微信号 wenmo_ai 邀请进群 (申请备注 Dinky + 企业名 + 职位,不写不批)',
'pages.about.precautions': '注意事项',
'pages.about.usingHelp': '使用帮助',
'pages.about.communityRules': '社区守则',
'pages.about.communityRules.1': '禁止发布或讨论与本群主旨无关或不良的内容,一经发现立马被踢。',
'pages.about.communityRules.2': '关于 Bug 反馈与功能改进或提议请通过 issue 进行,请阅读 issue 文档要求。',
'pages.about.communityRules.3': '部署和使用前请先仔细阅读 Readme、公众号文章、官网文档、B站视频。',
'pages.about.communityRules.2':
'关于 Bug 反馈与功能改进或提议请通过 issue 进行,请阅读 issue 文档要求。',
'pages.about.communityRules.3':
'部署和使用前请先仔细阅读 Readme、公众号文章、官网文档、B站视频。',
'pages.about.communityRules.4': '群提问题请礼貌并且说明【版本、执行模式、操作描述、截图】。',
'pages.about.communityRules.5': ' 登记谁在使用 Dinky,可进入企业用户群提供技术支持。',
};
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
/**
* @Author: kevin
* @Title: index.tsx
* @Date: 2023-02-10 16:45:06
* @Description:
*/
import Footer from '@/components/Footer';
import {LockOutlined, UserOutlined,} from '@ant-design/icons';
import {LoginForm, ProFormCheckbox, ProFormText,} from '@ant-design/pro-components';
import {useEmotionCss} from '@ant-design/use-emotion-css';
import {Helmet, history, SelectLang, useModel} from '@umijs/max';
import {Alert, message} from 'antd';
import { LockOutlined, UserOutlined } from '@ant-design/icons';
import { CheckCard, LoginForm, ProFormCheckbox, ProFormText } from '@ant-design/pro-components';
import { useEmotionCss } from '@ant-design/use-emotion-css';
import { Helmet, history, SelectLang, useModel } from '@umijs/max';
import { Alert, Button, message, Modal } from 'antd';
import Settings from '../../../../config/defaultSettings';
import React, {useState} from 'react';
import {flushSync} from 'react-dom';
import {login} from "@/services/api";
import {l} from '@/utils/intl';
import React, { useEffect, useState } from 'react';
import { flushSync } from 'react-dom';
import { login, getTenants } from '@/services/api';
import { l } from '@/utils/intl';
import cookies from 'js-cookie';
const Lang = () => {
const langClassName = useEmotionCss(({ token }) => {
......@@ -50,24 +41,13 @@ const Lang = () => {
);
};
const LoginMessage: React.FC<{
content: string;
}> = ({ content }) => {
return (
<Alert
style={{
marginBottom: 24,
}}
message={content}
type="error"
showIcon
/>
);
};
const Login: React.FC = () => {
const [submitting, setSubmitting] = useState(false);
const [userLoginState, setUserLoginState] = useState<API.LoginResult>({});
const { initialState, setInitialState } = useModel('@@initialState');
const [chooseTenant, setChooseTenant] = useState<boolean>(false);
const [checkDisabled, setCheckDisabled] = useState<boolean>(true);
const [tenant, setTenant] = useState<API.TenantListItem[]>([]);
const containerClassName = useEmotionCss(() => {
return {
......@@ -93,32 +73,113 @@ const Login: React.FC = () => {
}
};
/**
* 获取租户
*
*/
const getTenant = async () => {
const res = await getTenants({ username: 'admin' });
console.log('res', res?.datas);
if ((res?.datas?.length || 0) > 1) {
setTenant(res.datas || []);
setChooseTenant(true);
}
};
const handleSubmit = async (values: API.LoginParams) => {
try {
// 登录
const msg = await login({ ...values });
if (msg.status === 'ok') {
message.success(l('pages.login.success'));
const msg = await login({ ...values, type: 'password', tenantId: 1 });
if (msg.code === 0) {
// message.success(l('pages.login.success'));
// 选择租户
await fetchUserInfo();
const urlParams = new URL(window.location.href).searchParams;
history.push(urlParams.get('redirect') || '/');
await getTenant();
return;
}
console.log(msg);
// 如果失败去设置用户错误信息
setUserLoginState(msg);
} catch (error) {
message.error(l('pages.login.failure'));
}
};
const { status, type: loginType } = userLoginState;
const setTenantCookie = (tenantId: number) => {
localStorage.setItem('dlink-tenantId', tenantId.toString()); // 放入本地存储中 request2请求时会放入header
cookies.set('tenantId', tenantId.toString(), { path: '/' }); // 放入cookie中
};
const handleShowTenant = () => {
return (
<>
<Modal
title={l('pages.login.chooseTenant')}
open={chooseTenant}
destroyOnClose={true}
width={'60%'}
onCancel={() => {
setChooseTenant(false);
}}
footer={[
<Button
key="back"
onClick={() => {
setChooseTenant(false);
}}
>
{l('button.close')}
</Button>,
<Button
disabled={checkDisabled}
type="primary"
key="submit"
loading={submitting}
onClick={async () => {
// await handleSubmit(userParamsState);
setChooseTenant(false);
const urlParams = new URL(window.location.href).searchParams;
history.push(urlParams.get('redirect') || '/');
}}
>
{l('button.confirm')}
</Button>,
]}
>
<CheckCard.Group
multiple={false}
onChange={(value) => {
if (value) {
setCheckDisabled(false); // 如果没选择租户 ·确认按钮· 则禁用
// userParamsState.tenantId = value as number; // 将租户id给后端入参
setTenantCookie(value as number);
} else {
setCheckDisabled(true);
}
}}
>
{tenant?.map((item: any) => {
return (
<CheckCard
size={'default'}
key={item?.id}
avatar="/icons/tenant_default.svg"
title={item?.tenantCode}
value={item?.id}
description={item?.note}
/>
);
})}
</CheckCard.Group>
</Modal>
</>
);
};
return (
<div className={containerClassName}>
<Helmet>
<title>
{l('menu.login')}
- {Settings.title}
{l('menu.login')}- {Settings.title}
</title>
</Helmet>
<Lang />
......@@ -135,7 +196,7 @@ const Login: React.FC = () => {
}}
logo={<img alt="logo" src={Settings.logo} />}
title="Dinky"
subTitle={l('pages.layouts.userLayout.title' )}
subTitle={l('pages.layouts.userLayout.title')}
initialValues={{
autoLogin: true,
}}
......@@ -143,41 +204,36 @@ const Login: React.FC = () => {
await handleSubmit(values as API.LoginParams);
}}
>
<LoginMessage
content={l( 'pages.login.accountLogin.errorMessage')}
<>
<ProFormText
name="username"
fieldProps={{
size: 'large',
prefix: <UserOutlined />,
}}
placeholder={l('pages.login.username.placeholder')}
rules={[
{
required: true,
message: l('pages.login.username.required'),
},
]}
/>
<ProFormText.Password
name="password"
fieldProps={{
size: 'large',
prefix: <LockOutlined />,
}}
placeholder={l('pages.login.password.placeholder')}
rules={[
{
required: true,
message: l('pages.login.password.required'),
},
]}
/>
)
<>
<ProFormText
name="username"
fieldProps={{
size: 'large',
prefix: <UserOutlined />,
}}
placeholder={l('pages.login.username.placeholder')}
rules={[
{
required: true,
message: l('pages.login.username.required')
},
]}
/>
<ProFormText.Password
name="password"
fieldProps={{
size: 'large',
prefix: <LockOutlined />,
}}
placeholder={ l('pages.login.password.placeholder')}
rules={[
{
required: true,
message: l('pages.login.password.required')
},
]}
/>
</>
</>
<div
style={{
marginBottom: 24,
......@@ -190,6 +246,7 @@ const Login: React.FC = () => {
</LoginForm>
</div>
<Footer />
{handleShowTenant()}
</div>
);
};
......
......@@ -17,21 +17,19 @@
// @ts-ignore
/* eslint-disable */
import {request} from '@umijs/max';
import { request } from '@umijs/max';
/** 获取当前的用户 GET /api/currentUser */
export async function currentUser(options?: { [key: string]: any }) {
return request<{
data: API.CurrentUser;
}>('/api/currentUser', {
return request<API.Result>('/api/current', {
method: 'GET',
...(options || {}),
});
}
/** 退出登录接口 POST /api/login/outLogin */
/** 退出登录接口 POST /api/outLogin */
export async function outLogin(options?: { [key: string]: any }) {
return request<Record<string, any>>('/api/login/outLogin', {
return request<Record<string, any>>('/api/outLogin', {
method: 'POST',
...(options || {}),
});
......@@ -39,7 +37,7 @@ export async function outLogin(options?: { [key: string]: any }) {
/** 登录接口 POST /api/login/account */
export async function login(body: API.LoginParams, options?: { [key: string]: any }) {
return request<API.LoginResult>('/api/login/account', {
return request<API.LoginResult>('/api/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
......@@ -100,3 +98,13 @@ export async function removeRule(options?: { [key: string]: any }) {
...(options || {}),
});
}
/**获取租户 */
export async function getTenants(params: API.TenantRequest) {
return request<API.TenantResult>('/api/geTenants', {
method: 'GET',
params: {
...params,
},
});
}
......@@ -19,29 +19,42 @@
/* eslint-disable */
declare namespace API {
type Result = {
code: number;
datas: any;
msg: string;
};
type CurrentUser = {
name?: string;
id?: number;
username?: string;
password?: string;
nickname?: string;
worknum?: string;
avatar?: string;
userid?: string;
email?: string;
signature?: string;
title?: string;
group?: string;
tags?: { key?: string; label?: string }[];
notifyCount?: number;
unreadCount?: number;
country?: string;
access?: string;
geographic?: {
province?: { label?: string; key?: string };
city?: { label?: string; key?: string };
};
address?: string;
phone?: string;
mobile?: string;
enabled?: boolean;
isDelete?: boolean;
isAdmin?: boolean;
createTime?: Date;
updateTime?: Date;
roleList?: Role[];
tenantList?: Tenant[];
currentTenant?: Tenant;
};
type tenantListItem = {
id?: number,
tenantCode?: string,
note?: string,
isDelete?: boolean,
createTime?: string,
updateTime?: string;
};
type LoginResult = {
status?: string;
code?: number;
type?: string;
currentAuthority?: string;
};
......@@ -83,6 +96,7 @@ declare namespace API {
password?: string;
autoLogin?: boolean;
type?: string;
tenantId?: number;
};
type ErrorResponse = {
......@@ -115,4 +129,23 @@ declare namespace API {
description?: string;
type?: NoticeIconItemType;
};
type TenantRequest = {
username?: string;
};
type TenantListItem = {
id?: number;
createTime?: string;
updateTime?: string;
isDelete?: boolean;
note?: string;
tenantCode?: string;
};
type TenantResult = {
code?: number;
msg?: string;
datas?: TenantListItem[];
};
}
export type UserTableListItem = {
id?: number;
enabled?: boolean;
isDelete?: string;
createTime?: Date;
updateTime?: Date;
username?: string;
nickname?: string;
password?: string;
avatar?: string;
worknum?: string;
mobile?: string;
};
export type PasswordItem = {
username: string;
password?: string;
newPassword?: string;
newPasswordCheck?: string;
};
export type TenantTableListItem = {
id?: number;
tenantCode?: string;
isDelete?: boolean;
note?: string;
createTime?: Date;
updateTime?: Date;
};
export type RoleTableListItem = {
id?: number;
tenantId?: number;
tenant: TenantTableListItem;
roleCode?: string;
roleName?: string;
namespaceIds?: string;
namespaces?: NameSpaceTableListItem[];
isDelete?: boolean;
note?: string;
createTime?: Date;
updateTime?: Date;
};
export type NameSpaceTableListItem = {
id?: number;
tenantId?: number;
tenant: TenantTableListItem;
namespaceCode?: string;
enabled?: boolean;
note?: string;
createTime?: Date;
updateTime?: Date;
};
......@@ -17,7 +17,6 @@
*
*/
/**
* 在生产环境 代理是无法生效的,所以这里没有生产环境的配置
* The agent cannot take effect in the production environment
......@@ -28,7 +27,7 @@
export default {
dev: {
'/api': {
target: 'http://127.0.0.1:8888',
// target: 'http://127.0.0.1:8888',
changeOrigin: true,
pathRewrite: { '^': '' },
},
......
......@@ -17,28 +17,27 @@
*
*/
import {LockOutlined, UserOutlined,} from '@ant-design/icons';
import {Button, message, Modal} from 'antd';
import React, {useEffect, useState} from 'react';
import ProForm, {ProFormCheckbox, ProFormText} from '@ant-design/pro-form';
import {history, Link, SelectLang, useModel} from 'umi';
import { LockOutlined, UserOutlined } from '@ant-design/icons';
import { Button, message, Modal } from 'antd';
import React, { useEffect, useState } from 'react';
import ProForm, { ProFormCheckbox, ProFormText } from '@ant-design/pro-form';
import { history, Link, SelectLang, useModel } from 'umi';
import Footer from '@/components/Footer';
import {login} from '@/services/ant-design-pro/api';
import {CheckCard} from '@ant-design/pro-components';
import { login } from '@/services/ant-design-pro/api';
import { CheckCard } from '@ant-design/pro-components';
import styles from './index.less';
import {getData} from "@/components/Common/crud";
import {TenantTableListItem} from "@/pages/AuthenticationCenter/data.d";
import {l} from "@/utils/intl";
import cookies from "js-cookie";
import {setLocale} from "@@/plugin-locale/localeExports";
import { getData } from '@/components/Common/crud';
import type { TenantTableListItem } from '@/pages/AuthenticationCenter/data.d';
import { l } from '@/utils/intl';
import cookies from 'js-cookie';
import { setLocale } from '@@/plugin-locale/localeExports';
/** 此方法会跳转到 redirect 参数所在的位置 */
const goto = () => {
if (!history) return;
setTimeout(() => {
const {query} = history.location;
const {redirect} = query as { redirect: string };
const { query } = history.location;
const { redirect } = query as { redirect: string };
history.push(redirect || '/');
}, 10);
};
......@@ -48,14 +47,13 @@ const Login: React.FC = () => {
const [userLoginState, setUserLoginState] = useState<API.LoginResult>({});
const [userParamsState, setUserParamsState] = useState<API.LoginParams>({});
const [type, setType] = useState<string>('password');
const {initialState, setInitialState} = useModel('@@initialState');
const { initialState, setInitialState } = useModel('@@initialState');
const [isLogin, setIsLogin] = useState<boolean>(true);
const [chooseTenant, setChooseTenant] = useState<boolean>(false);
const [tenant, setTenant] = useState<TenantTableListItem[]>([]);
const [checkDisabled, setCheckDisabled] = useState<boolean>(true);
const fetchUserInfo = async () => {
const userInfo = await initialState?.fetchUserInfo?.();
if (userInfo) {
......@@ -66,25 +64,22 @@ const Login: React.FC = () => {
}
};
useEffect(() => {
// 调用接口
const {username} = userParamsState
const { username } = userParamsState;
if (!username) {
return
return;
}
getData("/api/geTenants", {username}).then(result => {
getData('/api/geTenants', { username }).then((result) => {
console.log('result', result);
setTenant(result?.datas);
})
}, [
userParamsState?.username
])
});
}, [userParamsState?.username]);
const setTenantCookie = (tenantId :number) => {
localStorage.setItem("dlink-tenantId", tenantId.toString()); // 放入本地存储中 request2请求时会放入header
cookies.set('tenantId', tenantId.toString(), {path: '/'}) // 放入cookie中
}
const setTenantCookie = (tenantId: number) => {
localStorage.setItem('dlink-tenantId', tenantId.toString()); // 放入本地存储中 request2请求时会放入header
cookies.set('tenantId', tenantId.toString(), { path: '/' }); // 放入cookie中
};
const handleSubmit = async (values: API.LoginParams) => {
if (!isLogin) {
......@@ -92,12 +87,12 @@ const Login: React.FC = () => {
}
setIsLogin(false);
setTimeout(() => {
setIsLogin(true)
setIsLogin(true);
}, 200);
setSubmitting(true);
try {
// 登录
const msg = await login({...values, type});
const msg = await login({ ...values, type });
if (msg.code === 0 && msg.datas != undefined) {
message.success(l('pages.login.success'));
await fetchUserInfo();
......@@ -115,78 +110,96 @@ const Login: React.FC = () => {
};
//const {code } = userLoginState;
const handleShowTenant = () => {
return <>
<Modal title={l('pages.login.chooseTenant')} visible={chooseTenant} destroyOnClose={true}
width={"60%"}
onCancel={() => {
setChooseTenant(false);
}}
footer={[
<Button key="back" onClick={() => {
setChooseTenant(false);
}}>
{l('button.close')}
</Button>,
<Button disabled={checkDisabled} type="primary" key="submit" loading={submitting}
onClick={async () => {
await handleSubmit(userParamsState);
}}>
{l('button.confirm')}
</Button>
]}>
<CheckCard.Group
multiple={false}
onChange={(value) => {
if (value) {
setCheckDisabled(false) // 如果没选择租户 ·确认按钮· 则禁用
userParamsState.tenantId = value as number; // 将租户id给后端入参
setTenantCookie(value as number)
} else {
setCheckDisabled(true)
}
return (
<>
<Modal
title={l('pages.login.chooseTenant')}
visible={chooseTenant}
destroyOnClose={true}
width={'60%'}
onCancel={() => {
setChooseTenant(false);
}}
footer={[
<Button
key="back"
onClick={() => {
setChooseTenant(false);
}}
>
{l('button.close')}
</Button>,
<Button
disabled={checkDisabled}
type="primary"
key="submit"
loading={submitting}
onClick={async () => {
await handleSubmit(userParamsState);
}}
>
{l('button.confirm')}
</Button>,
]}
>
{tenant?.map((item: any) => {
return <>
<CheckCard
size={"default"}
key={item?.id}
avatar="/icons/tenant_default.svg"
title={item?.tenantCode}
value={item?.id}
description={item?.note}
/>
</>
})}
</CheckCard.Group>
</Modal>
</>
}
<CheckCard.Group
multiple={false}
onChange={(value) => {
if (value) {
setCheckDisabled(false); // 如果没选择租户 ·确认按钮· 则禁用
userParamsState.tenantId = value as number; // 将租户id给后端入参
setTenantCookie(value as number);
} else {
setCheckDisabled(true);
}
}}
>
{tenant?.map((item: any) => {
return (
<>
<CheckCard
size={'default'}
key={item?.id}
avatar="/icons/tenant_default.svg"
title={item?.tenantCode}
value={item?.id}
description={item?.note}
/>
</>
);
})}
</CheckCard.Group>
</Modal>
</>
);
};
return (
<div className={styles.container}>
<div className={styles.lang}>{SelectLang && <SelectLang onItemClick={(e) => {
let language = e.key.toString()
if (language === undefined || language === "") {
language = localStorage.getItem("umi_locale")
}
cookies.set('language', language, {path: '/'})
setLocale(language)
}}/>}</div>
<div className={styles.lang}>
{SelectLang && (
<SelectLang
onItemClick={(e) => {
let language = e.key.toString();
if (language === undefined || language === '') {
language = localStorage.getItem('umi_locale');
}
cookies.set('language', language, { path: '/' });
setLocale(language);
}}
/>
)}
</div>
<div className={styles.content}>
<div className={styles.top}>
<div className={styles.header}>
<Link to="/">
<img alt="logo" className={styles.logo} src="/dinky.svg"/>
<img alt="logo" className={styles.logo} src="/dinky.svg" />
<span className={styles.title}>Dinky</span>
</Link>
</div>
<div className={styles.desc}>
{l('pages.layouts.userLayout.title')}
</div>
<div className={styles.desc}>{l('pages.layouts.userLayout.title')}</div>
</div>
<div className={styles.main}>
......@@ -209,24 +222,26 @@ const Login: React.FC = () => {
},
}}
onFinish={async (values: API.LoginParams) => {
setType("password")
let res: TenantTableListItem[] = await getData("/api/geTenants", {username: values.username}).then(result => {
if(!result?.datas){
setType('password');
const res: TenantTableListItem[] = await getData('/api/geTenants', {
username: values.username,
}).then((result) => {
if (!result?.datas) {
message.error(result?.msg);
return;
}
setTenant(result?.datas);
return result?.datas
})
return result?.datas;
});
if (res.length === 1) {
let tenantValue = res.pop().id // 进入此处说明 只有一个租户 直接pop() 拿到单个对象获取租户id
const tenantValue = res.pop().id; // 进入此处说明 只有一个租户 直接pop() 拿到单个对象获取租户id
values.tenantId = tenantValue; // 将租户id给后端入参
setTenantCookie(tenantValue as number)
setTenantCookie(tenantValue as number);
setUserParamsState(values);
await handleSubmit(values);
} else {
setUserParamsState(values);
setChooseTenant(true)
setChooseTenant(true);
}
}}
>
......@@ -236,7 +251,7 @@ const Login: React.FC = () => {
name="username"
fieldProps={{
size: 'large',
prefix: <UserOutlined className={styles.prefixIcon}/>,
prefix: <UserOutlined className={styles.prefixIcon} />,
}}
placeholder={l('pages.login.username.placeholder')}
rules={[
......@@ -250,7 +265,7 @@ const Login: React.FC = () => {
name="password"
fieldProps={{
size: 'large',
prefix: <LockOutlined className={styles.prefixIcon}/>,
prefix: <LockOutlined className={styles.prefixIcon} />,
}}
placeholder={l('pages.login.password.placeholder')}
rules={[
......@@ -263,7 +278,6 @@ const Login: React.FC = () => {
</>
)}
<div
style={{
marginBottom: 24,
......@@ -283,10 +297,9 @@ const Login: React.FC = () => {
</ProForm>
</div>
</div>
<Footer/>
<Footer />
{handleShowTenant()}
</div>
);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment