同步代码

This commit is contained in:
zengqiao
2022-08-23 19:01:53 +08:00
parent e90c5003ae
commit e1514c901b
76 changed files with 796 additions and 577 deletions

View File

@@ -3,9 +3,10 @@
import { notification, Utils } from 'knowdesign';
const goLogin = () => {
// notification.error({ message: '当前未登录,将自动跳转到登录页' });
window.history.replaceState({}, '', `/login?redirect=${window.location.href.slice(window.location.origin.length)}`);
export const goLogin = () => {
if (!window.location.pathname.toLowerCase().startsWith('/login')) {
window.history.replaceState({}, '', `/login?redirect=${window.location.href.slice(window.location.origin.length)}`);
}
};
const serviceInstance = Utils.service;
@@ -18,7 +19,7 @@ serviceInstance.interceptors.request.use(
(config: any) => {
const user = Utils.getCookie('X-SSO-USER');
const id = Utils.getCookie('X-SSO-USER-ID');
if ((!user || !id) && !window.location.pathname.toLowerCase().startsWith('/login')) {
if (!user || !id) {
goLogin();
} else {
config.headers['X-SSO-USER'] = user; // 请求携带token

View File

@@ -1,5 +1,6 @@
import React, { useLayoutEffect } from 'react';
import { Utils, AppContainer } from 'knowdesign';
import { goLogin } from 'constants/axiosConfig';
// 权限对应表
export enum ConfigPermissionMap {
@@ -33,12 +34,7 @@ const CommonConfig = (): JSX.Element => {
const [global, setGlobal] = AppContainer.useGlobalValue();
// 获取权限树
const getPermissionTree = () => {
// 如果未登录,直接退出
const userInfo = localStorage.getItem('userInfo');
if (!userInfo) return false;
const userId = JSON.parse(userInfo).id;
const getPermissionTree = (userId: number) => {
const getUserInfo = Utils.request(`/logi-security/api/v1/user/${userId}`);
const getPermissionTree = Utils.request('/logi-security/api/v1/permission/tree');
@@ -58,7 +54,19 @@ const CommonConfig = (): JSX.Element => {
};
useLayoutEffect(() => {
getPermissionTree();
// 如果未登录,直接跳转到登录页
const userInfo = localStorage.getItem('userInfo');
let userId: number;
try {
userId = JSON.parse(userInfo).id;
if (!userId) throw 'err';
} catch (_) {
goLogin();
return;
}
getPermissionTree(userId);
}, []);
return <></>;

View File

@@ -433,13 +433,13 @@ export default () => {
<div className="operate-bar">
<Form form={form} layout="inline" onFinish={() => getConfigList({ page: 1 })}>
<Form.Item name="valueGroup">
<Select placeholder="请选择模块" options={configGroupList} allowClear />
<Select style={{ width: 180 }} placeholder="请选择模块" options={configGroupList} />
</Form.Item>
<Form.Item name="valueName">
<Input placeholder="请输入配置键" />
<Input style={{ width: 180 }} placeholder="请输入配置键" />
</Form.Item>
<Form.Item name="memo">
<Input placeholder="请输入描述" />
<Input style={{ width: 180 }} placeholder="请输入描述" />
</Form.Item>
<Form.Item>
<Button type="primary" ghost htmlType="submit">

View File

@@ -114,7 +114,7 @@ export default () => {
<div className="operate-bar">
<Form form={form} layout="inline" onFinish={() => getData({ page: 1 })}>
<Form.Item name="targetType">
<Select placeholder="请选择模块" options={configGroupList} style={{ width: 160 }} allowClear />
<Select placeholder="请选择模块" options={configGroupList} style={{ width: 160 }} />
</Form.Item>
<Form.Item name="target">
<Input placeholder="请输入操作对象" />

View File

@@ -46,13 +46,13 @@ const EditUserDrawer = forwardRef((props, ref) => {
const requestPromise =
type === UserOperate.Add
? request(api.addUser, {
method: 'PUT',
data: formData,
})
method: 'PUT',
data: formData,
})
: request(api.editUser, {
method: 'POST',
data: { ...formData },
});
method: 'POST',
data: { ...formData },
});
requestPromise.then(
(res) => {
callback.current();
@@ -300,7 +300,7 @@ export default (props: { curTabKey: string }) => {
return (
<>
{global.hasPermission &&
(global.hasPermission(ConfigPermissionMap.USER_EDIT) || global.hasPermission(ConfigPermissionMap.USER_CHANGE_PASS)) ? (
(global.hasPermission(ConfigPermissionMap.USER_EDIT) || global.hasPermission(ConfigPermissionMap.USER_CHANGE_PASS)) ? (
<Button
type="link"
size="small"
@@ -349,7 +349,7 @@ export default (props: { curTabKey: string }) => {
<Input placeholder="请输入用户实名" />
</Form.Item>
<Form.Item name="roleId">
<Select style={{ width: 190 }} placeholder="选择平台已创建的角色名" allowClear options={simpleRoleList} />
<Select style={{ width: 190 }} placeholder="选择平台已创建的角色名" options={simpleRoleList} />
</Form.Item>
<Form.Item>
<Button type="primary" ghost htmlType="submit">