Commit 7dc76ea7 authored by 前端-彭佳文's avatar 前端-彭佳文

Merge branch 'v2-0418-xxx' into 'v2-220418'

菜单调整 See merge request linkseeks-design/pro-platform!192
parents 69ffb7aa 0c2e1a76
......@@ -51,6 +51,7 @@ const loginWhiteList = [
'/memberCenter/home',
'/memberCenter/editMySelf'
]
/**
* @description 配置函数,对已配置的路由做修改, 一般与render函数一起结合可根据接口动态配置路由, 直接修改routes即可
* @author xjm
......@@ -74,7 +75,7 @@ export function patchRoutes({ routes }: IRoutes) {
getMemberLoginReget({}, { useCache: true, ttl: 1000 }).then(res => {
const { data, code } = res
if (code === 1000) {
asyncRouter(data.urls, routes)
asyncRouter(data.auth, routes)
}
})
}
......@@ -100,7 +101,7 @@ export function render(oldRender: Function) {
const { data, code } = res
if (code === 1000) {
setAuth(data as any)
setRouters(data.urls)
setRouters(data.auth)
} else {
removeAuth()
removeRouters()
......@@ -111,7 +112,7 @@ export function render(oldRender: Function) {
}).catch(() => {
oldRender()
})
getManagePaasSiteEnableMultiTenancy({siteId: GlobalConfig.global.siteInfo.id.toString()}).then(res => {
getManagePaasSiteEnableMultiTenancy({ siteId: GlobalConfig.global.siteInfo.id.toString() }).then(res => {
if (res.code !== 1000) {
return
}
......@@ -159,9 +160,9 @@ export function onRouteChange({ routes, matchedRoutes, location, action }) {
let routeAuthUrls = getRouters()
if (!routeAuthUrls || routeAuthUrls.length === 0) {
const { urls } = authInfo
const { urls, auth } = authInfo
routeAuthUrls = urls
setRouters(urls)
setRouters(urls, auth)
}
const { pathname } = location
console.log(pathname, 'pathname')
......
......@@ -36,7 +36,7 @@ const Roles: React.FC = () => {
}
const msg = message.loading({
content: intl.formatMessage({id: 'common.zhengzaiqiehuanjuese'}),
content: intl.formatMessage({ id: 'common.zhengzaiqiehuanjuese' }),
duration: 0,
});
......@@ -47,7 +47,7 @@ const Roles: React.FC = () => {
return;
}
setAuth(res.data);
setRouters(res.data.urls);
setRouters(res.data.auth);
setTimeout(() => {
window.location.replace('/memberCenter/home');
}, 800);
......
......@@ -40,7 +40,7 @@ const InquirySearch = () => {
return;
}
setAuth(res.data);
setRouters(res.data.urls);
setRouters(res.data.auth);
setTimeout(() => {
window.location.replace(`/memberCenter/tranactionAbility/productInquiry/waitAddInquiry/two?id=${id}`);
}, 800);
......
......@@ -25,8 +25,8 @@ const LoginWrap: React.FC = () => {
const { data, code } = res
if (code === 1000) {
message.destroy()
message.success(intl.formatMessage({id: 'user.dengluchenggong'}))
setRouters(data.urls)
message.success(intl.formatMessage({ id: 'user.dengluchenggong' }))
setRouters(data.auth)
// 设置同域名cookie缓存
setAuth(data)
// 此处需使用href跳转, 否则无法触发app.ts中的路由初始化校验
......@@ -45,7 +45,7 @@ const LoginWrap: React.FC = () => {
return (
<>
<p>{validFrame ? `${intl.formatMessage({id: 'user.dangqianshoujihaoma'})}:xxxxxxxxx` : intl.formatMessage({id: 'user.qingshiyongpingtaizhanghaodeng'})}</p>
<p>{validFrame ? `${intl.formatMessage({ id: 'user.dangqianshoujihaoma' })}:xxxxxxxxx` : intl.formatMessage({ id: 'user.qingshiyongpingtaizhanghaodeng' })}</p>
{
validFrame ?
<>
......@@ -54,12 +54,12 @@ const LoginWrap: React.FC = () => {
<Input size='large' />
</Col>
<Col offset={1} span={7}>
<Button type='default' size='large'>{intl.formatMessage({id: 'user.huoquyanzhengma'})}</Button>
<Button type='default' size='large'>{intl.formatMessage({ id: 'user.huoquyanzhengma' })}</Button>
</Col>
</Row>
<Row>
<Col span={24}>
<Button type='primary' size='large' htmlType='submit' block>{intl.formatMessage({id: 'user.dianjidenglu'})}</Button>
<Button type='primary' size='large' htmlType='submit' block>{intl.formatMessage({ id: 'user.dianjidenglu' })}</Button>
</Col>
</Row>
</>
......@@ -73,12 +73,12 @@ const LoginWrap: React.FC = () => {
[
{
required: true,
message: <><ExclamationCircleFilled style={{ marginRight: 6 }} /><span>{intl.formatMessage({id: 'user.qingshuruzhengquedeyonghu'})}</span></>
message: <><ExclamationCircleFilled style={{ marginRight: 6 }} /><span>{intl.formatMessage({ id: 'user.qingshuruzhengquedeyonghu' })}</span></>
}
]
}
>
<Input prefix={<UserOutlined />} placeholder={intl.formatMessage({id: 'user.yonghumingshoujihao'})} size='large' />
<Input prefix={<UserOutlined />} placeholder={intl.formatMessage({ id: 'user.yonghumingshoujihao' })} size='large' />
</Form.Item>
<Form.Item
name='password'
......@@ -86,21 +86,21 @@ const LoginWrap: React.FC = () => {
[
{
required: true,
message: <><ExclamationCircleFilled style={{ marginRight: 6 }} /><span>{intl.formatMessage({id: 'user.qingshuruzhengquedemima'})}</span></>
message: <><ExclamationCircleFilled style={{ marginRight: 6 }} /><span>{intl.formatMessage({ id: 'user.qingshuruzhengquedemima' })}</span></>
}
]
}
>
<Input.Password prefix={<LockOutlined />} placeholder={intl.formatMessage({id: 'user.qingshurumima'})} size='large' />
<Input.Password prefix={<LockOutlined />} placeholder={intl.formatMessage({ id: 'user.qingshurumima' })} size='large' />
</Form.Item>
{validButton && (<Form.Item
className={'loginVerBtn'}
>
<Button ghost type='primary' block size='large'>{intl.formatMessage({id: 'user.dianjijinhangyanzheng'})}</Button>
<Button ghost type='primary' block size='large'>{intl.formatMessage({ id: 'user.dianjijinhangyanzheng' })}</Button>
</Form.Item>)
}
<Form.Item>
<Button type='primary' loading={loginLoading} size='large' htmlType='submit' block>{intl.formatMessage({id: 'user.denglu'})}</Button>
<Button type='primary' loading={loginLoading} size='large' htmlType='submit' block>{intl.formatMessage({ id: 'user.denglu' })}</Button>
</Form.Item>
</Form>
}
......
......@@ -63,9 +63,9 @@ const ScanLoginWrap: React.FC = () => {
const { data, code } = res
if (code === 1000) {
message.destroy()
message.success(intl.formatMessage({id: 'user.dengluchenggong'}))
message.success(intl.formatMessage({ id: 'user.dengluchenggong' }))
setAuth(data)
setRouters(data.urls)
setRouters(data.auth)
// 此处需使用href跳转, 否则无法触发app.ts中的路由初始化校验
if (redirect) {
window.location.replace(decodeURIComponent(atob(redirect)))
......@@ -89,7 +89,7 @@ const ScanLoginWrap: React.FC = () => {
}, [])
return (
<div className={'scanLoginWrap'}>
<h2>{intl.formatMessage({id: 'user.saomadenglu'})}</h2>
<h2>{intl.formatMessage({ id: 'user.saomadenglu' })}</h2>
<div className={'qrCodeImage'}>
{
qrCode && <img src={qrCode} alt="" />
......
......@@ -40,7 +40,7 @@ export const setAuth = (info: AuthInfo) => {
setCookie(AUTH_KEY, JSON.stringify(auth), { domain: TOP_DOMAIN_NO_PORT})
setCookie(AUTH_ROLES_KEY, JSON.stringify(info.roles), { domain: TOP_DOMAIN_NO_PORT })
setLocalAuth(info)
setRouters(info.urls)
setRouters(info.auth)
}
/**
......@@ -78,7 +78,7 @@ export const getAuth = (): AuthInfo => {
}
}
export const setRouters = (routers: any[]) => {
export const setRouters = (routers: any) => {
window.sessionStorage.setItem('rt', JSON.stringify(routers))
}
......@@ -134,7 +134,8 @@ const HOME_URL = [
'/memberCenter/home'
]
export const asyncRouter = async (routeLists: string[], routes: any[]) => {
export const asyncRouter = async (routeLists: {b: string[], u: string}[], routes: any[]) => {
const pathList = routeLists.map((item) => item.u)
for (let i = 0; i < routes.length; i++) {
const item = routes[i]
if (item.routes) {
......@@ -142,7 +143,7 @@ export const asyncRouter = async (routeLists: string[], routes: any[]) => {
} else {
// 参与权限校验的页面
// fix: 修复左侧菜单首页无法显示
if (item.path && !routeLists.includes(item.path) && !HOME_URL.includes(item.path)) {
if (item.path && !pathList.includes(item.path) && !HOME_URL.includes(item.path)) {
item.hideInMenu = true
item.noAuth = true
}
......
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