Commit 196744fe authored by 沈翠玲's avatar 沈翠玲

改成希迈定制

parent f6558628
......@@ -9,14 +9,14 @@
export default {
dev: {
'/api/': {
target: 'http://localhost:20093',
target: 'http://192.168.222.60:8088',
changeOrigin: true,
pathRewrite: { '^/api': '' },
},
},
test: {
'/api/': {
target: 'https://proapi.azurewebsites.net',
target: 'http://192.168.222.60:8088',
changeOrigin: true,
pathRewrite: { '^': '' },
},
......
......@@ -91,24 +91,25 @@ export default [
],
},
{
key: 'def4',
path: '/kanban',
name: 'kanban',
icon: 'FundOutlined',
routes: [
{
path: 'productionProgressKanban',
name: 'productionProgressKanban',
target: '_blank',
layout: false,
component: './kanban/ProductionProgress',
},
{
path: 'productProgressKanban',
name: 'productProgressKanban',
target: '_blank',
layout: false,
component: './kanban/ProductProgress',
},
// {
// path: 'productionProgressKanban',
// name: 'productionProgressKanban',
// target: '_blank',
// layout: false,
// component: './kanban/ProductionProgress',
// },
// {
// path: 'productProgressKanban',
// name: 'productProgressKanban',
// target: '_blank',
// layout: false,
// component: './kanban/ProductProgress',
// },
{
path: 'productionComprehensKanban',
name: 'productionComprehensKanban',
......@@ -116,48 +117,48 @@ export default [
layout: false,
component: './kanban/productionComprehens',
},
{
path: 'materialSynthesisKanban',
name: 'materialSynthesisKanban',
target: '_blank',
layout: false,
component: './kanban/materialSynthesis',
},
{
path: 'weldingProcessKanban',
name: 'weldingProcessKanban',
target: '_blank',
layout: false,
component: './kanban/weldingProcessKanban',
},
{
path: 'evacuationProcessKanban',
name: 'evacuationProcessKanban',
target: '_blank',
layout: false,
component: './kanban/evacuationProcessKanban',
},
{
path: 'paintingProcessKanban',
name: 'paintingProcessKanban',
target: '_blank',
layout: false,
component: './kanban/paintingProcessKanban',
},
{
path: 'airBottleProcessKanban',
name: 'airBottleProcessKanban',
target: '_blank',
layout: false,
component: './kanban/airBottleProcessKanban',
},
{
path: 'qiPingComprehensKanban',
name: 'qiPingComprehensKanban',
target: '_blank',
layout: false,
component: './kanban/qipingComprehens',
},
// {
// path: 'materialSynthesisKanban',
// name: 'materialSynthesisKanban',
// target: '_blank',
// layout: false,
// component: './kanban/materialSynthesis',
// },
// {
// path: 'weldingProcessKanban',
// name: 'weldingProcessKanban',
// target: '_blank',
// layout: false,
// component: './kanban/weldingProcessKanban',
// },
// {
// path: 'evacuationProcessKanban',
// name: 'evacuationProcessKanban',
// target: '_blank',
// layout: false,
// component: './kanban/evacuationProcessKanban',
// },
// {
// path: 'paintingProcessKanban',
// name: 'paintingProcessKanban',
// target: '_blank',
// layout: false,
// component: './kanban/paintingProcessKanban',
// },
// {
// path: 'airBottleProcessKanban',
// name: 'airBottleProcessKanban',
// target: '_blank',
// layout: false,
// component: './kanban/airBottleProcessKanban',
// },
// {
// path: 'qiPingComprehensKanban',
// name: 'qiPingComprehensKanban',
// target: '_blank',
// layout: false,
// component: './kanban/qipingComprehens',
// },
// {
// path: 'jiejingProduction',
// name: 'jiejingProduction',
......@@ -518,7 +519,7 @@ export default [
],
},
{
key: 'personalSetting',
key: 'def3',
path: '/personalSetting',
name: 'personalSetting',
icon: 'user',
......
......@@ -7,15 +7,9 @@ export default function access(initialState: {
}) {
const { currentUser, permissions } = initialState || {};
return {
canAdmin: currentUser && currentUser.roles.split(',').some((r) => r === 'admin'),
canAdmin: currentUser && currentUser.roles.some((r) => r === 'admin'),
grantAccess: (accessCode: string) => {
return (
currentUser &&
(permissions?.findIndex((p: string) => p?.toUpperCase() === accessCode?.toUpperCase()) >=
0 ||
accessCode == '' ||
accessCode == undefined)
);
return true;
},
};
}
......@@ -7,7 +7,6 @@ import RightContent from '@/components/RightContent';
import Footer from '@/components/Footer';
import {
currentUser as queryCurrentUser,
getPermission,
token as getToken,
} from './services/mgr/api';
import {
......@@ -22,7 +21,6 @@ import {
UserOutlined,
} from '@ant-design/icons';
import { decodeToken } from 'react-jwt';
import { getMenu } from '@/services/mgr/api';
const isDev = process.env.NODE_ENV === 'development';
const loginPath = '/user/login';
......@@ -191,7 +189,7 @@ export async function getInitialState(): Promise<{
const fetchUserInfo = async () => {
try {
const msg = await queryCurrentUser();
return msg.data;
return msg;
} catch (error) {
history.push(loginPath);
}
......@@ -217,23 +215,17 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
return {
menu: {
params: {
loginName: initialState?.currentUser?.loginName,
loginName: initialState?.currentUser?.user?.nickName,
},
request: async (params, defaultMenuData) => {
if (params?.loginName) {
const defaultResult = defaultMenuData.filter((item: any) => {
return item.key?.substring(0, 3) == 'def';
});
const menuData = await getMenu(params.loginName);
menuData.forEach((item: any) => (item.icon = iconMapping[item.icon]));
const result = [...defaultResult, ...menuData];
extendMenuProp(menuData, defaultMenuData);
const result = defaultResult;
extendMenuProp([], defaultMenuData);
const menuPaths = extractMenuPath(result);
await setInitialState((s) => ({ ...s, menuPaths }));
const permissions = await getPermission(params.loginName);
await setInitialState((s) => ({ ...s, permissions }));
return result;
} else return [];
},
......@@ -244,15 +236,15 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
onPageChange: () => {
const { location } = history;
// 如果没有登录,重定向到 login
if (!initialState?.currentUser && location.pathname !== loginPath) {
history.push(loginPath);
}
// 用于处理直接修改浏览器地址,进入页面
if (initialState?.menuPaths) {
if (!matchPath(location.pathname, { path: initialState.menuPaths, exact: true })) {
history.push('/404');
}
}
// if (!initialState?.currentUser && location.pathname !== loginPath) {
// history.push(loginPath);
// }
// // 用于处理直接修改浏览器地址,进入页面
// if (initialState?.menuPaths) {
// if (!matchPath(location.pathname, { path: initialState.menuPaths, exact: true })) {
// history.push('/404');
// }
// }
},
links: isDev
? [
......
......@@ -53,7 +53,7 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
const { currentUser } = initialState;
if (!currentUser || !currentUser.name) {
if (!currentUser || !currentUser.user.nickName) {
return loading;
}
......@@ -83,7 +83,7 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
<HeaderDropdown overlay={menuHeaderDropdown}>
<span className={`${styles.action} ${styles.account}`}>
<Avatar size="small" className={styles.avatar} src="/avatars/simple.svg" alt="avatar" />
<span className={`${styles.name} anticon`}>{currentUser.name}</span>
<span className={`${styles.name} anticon`}>{currentUser.user.nickName}</span>
</span>
</HeaderDropdown>
);
......
......@@ -50,7 +50,7 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
name="username"
disabled={true}
label={'用户名'}
initialValue={initialState?.currentUser?.loginName}
initialValue={initialState?.currentUser?.user?.nickName}
fieldProps={{
size: 'large',
prefix: <UserOutlined className={styles.prefixIcon} />,
......
......@@ -5,7 +5,8 @@ import { MenuDataItem } from '@umijs/route-utils';
import { Modal } from 'antd';
export async function login(body: Api.LoginMgrParams, options?: { [key: string]: any }) {
const resData = request<Api.ServiceResult<Api.LoginResult>>('/api/login', {
localStorage.removeItem('token');
const resData = request<Api.LoginResult>('/api/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
......@@ -13,12 +14,12 @@ export async function login(body: Api.LoginMgrParams, options?: { [key: string]:
data: body,
...(options || {}),
});
localStorage.setItem('token', (await resData).data.token);
localStorage.setItem('token', (await resData).token);
return resData;
}
export async function logout(options?: { [key: string]: any }) {
const res = await request<Api.ServiceResult<null>>('/api/loginout', {
const res = await request<Api.ServiceResult<null>>('/api/logout', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
......@@ -30,8 +31,8 @@ export async function logout(options?: { [key: string]: any }) {
}
export async function currentUser(options?: { [key: string]: any }) {
return request<Api.ServiceResult<Api.CurrentUser>>('/api/currentuser', {
method: 'POST',
return request<Api.CurrentUser>('/api/getInfo', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
......@@ -263,7 +264,6 @@ export async function getMenu(userName: string, options?: { [key: string]: any }
},
);
return (await resData).data as MenuDataItem[];
return [] as MenuDataItem[];
}
export async function getPermission(userName: string, options?: { [key: string]: any }) {
......
......@@ -84,9 +84,8 @@ declare namespace Api {
} & IdDto;
type CurrentUser = {
loginName: string;
name: string;
roles: string;
user: any;
roles: any[];
};
type CurrentAccount = {
......
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