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

改成希迈定制

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