Commit 8722d315 authored by GuanHua's avatar GuanHua

fix: 修改获取权限路由的方式

parent 5d804078
......@@ -28,11 +28,11 @@ const MenuSlider: React.FC<MenuSliderProps> = (props) => {
let menuItemsCache = null
const getMenuRouter = (routes: any, pathname: any) => {
let list = routes.filter((item: any) => pathname.indexOf(item.key) > -1)
const list = routes.filter((item: any) => pathname.indexOf(item.key) > -1)
return list[0]
}
const getMenus = (menuArray: any, hasChildren: boolean = false) => {
const getMenus = (menuArray: any, hasChildren = false) => {
if (!!menuArray && menuArray.length > 0) {
return menuArray.map((item: any) => {
// 不存在路由表内或者 需要隐藏
......@@ -83,8 +83,8 @@ const MenuSlider: React.FC<MenuSliderProps> = (props) => {
}
const clearHeightSearchParams = () => {
let currentState = JSON.parse(sessionStorage.getItem("currentState"))
let result = {...currentState, queryParams: {}, current: 1}
const currentState = JSON.parse(sessionStorage.getItem("currentState"))
const result = {...currentState, queryParams: {}, current: 1}
sessionStorage.setItem("currentState", JSON.stringify(result))
}
......
......@@ -19,7 +19,7 @@ export interface OuterSiderProps {
const OuterSider: React.FC<OuterSiderProps> = observer((props) => {
const { menuData, pathname = "/" } = props
const authRouters = getRouters()
let defaultSelectedKeys: string = ""
let defaultSelectedKeys = ""
const isAuthPath = (path) => {
if (isDev) {
......
......@@ -75,6 +75,7 @@ const Banner: React.FC<BannerPropsType> = (props) => {
const [productRowSelection, productRowCtl] = useRowSelectionTable({type: 'radio'})
useEffect(() => {
console.log(storeId, "storeId")
initDataList()
}, [dataList])
......
......@@ -40,7 +40,7 @@ interface BannerPropsType {
const RecommendCommodity: React.FC<BannerPropsType> = (props) => {
const { title, storeId, productIdList, dataList } = props
const { title, storeId, productIdList = [], dataList } = props
const [expandState, setExpandState] = useState<boolean>(true)
const [list, setList] = useState<DataItemType[]>([])
const [modalVisible, setModalVisible] = useState<boolean>(false)
......@@ -193,8 +193,10 @@ const RecommendCommodity: React.FC<BannerPropsType> = (props) => {
message.info("请选择")
return null
}
selectedRowKeys = [...productIdList, ...selectedRowKeys]
const commodityList = await fetchCategoryByCommodityId(selectedRowKeys)
changeProps({
props:Object.assign({ ...props }, {
productIdList: selectedRowKeys,
......
......@@ -192,9 +192,9 @@ const mobileShopTempleteEdit: React.FC<ShopPreviewPropsType> = (props) => {
mobileChannelHeaderNav[mobileChannelHeaderNav.key].props.styleTheme = appConfig?.topBO.style
mobileChannelHeaderNav[mobileChannelHeaderNav.key].props.dataList = appConfig?.topBO.topDetailsBOList
}
mobileBanner[mobileBanner.key].props.channelMemberId = channelInfo.memberId
if (appConfig?.advertBO) {
mobileBanner[mobileBanner.key].props.channelMemberId = channelInfo.memberId
mobileBanner[mobileBanner.key].props.dataList = appConfig?.advertBO.advertDetailsBOList
}
......
......@@ -161,9 +161,9 @@ const mobileShopTempleteEdit: React.FC<ShopPreviewPropsType> = (props) => {
if(appConfig?.backdropBO) {
mobileShopHeaderNav[mobileShopHeaderNav.key].props.backdrop = appConfig?.backdropBO.backdrop
}
mobileBanner[mobileBanner.key].props.storeId = shopInfo.id
if(appConfig?.advertBO) {
mobileBanner[mobileBanner.key].props.storeId = shopInfo.id
mobileBanner[mobileBanner.key].props.dataList = appConfig?.advertBO.advertDetailsBOList
}
......@@ -182,6 +182,7 @@ const mobileShopTempleteEdit: React.FC<ShopPreviewPropsType> = (props) => {
} else {
mobileShopCommodityList[mobileShopCommodityList.key].props.storeId = shopInfo.id
mobileShopCommodityList[mobileShopCommodityList.key].props.title = '热销商品'
mobileShopCommodityList[mobileShopCommodityList.key].props.productIdList = []
}
const config = {
......
import { isDev } from '@/constants'
export interface AuthInfo {
userId: number,
memberId: number,
name: string,
token: string
}
export const setAuth = (info: AuthInfo) => {
window.localStorage.setItem('auth', JSON.stringify(info))
}
export const getAuth = () => {
try {
const localAuth = window.localStorage.getItem('auth')
return localAuth ? JSON.parse(localAuth) : null
} catch (error) {
return {}
}
}
export const setRouters = (routers: any[]) => {
window.sessionStorage.setItem('rt', JSON.stringify(routers))
}
export const getRouters = (): string[] => {
try {
const sessionRt = window.sessionStorage.getItem('rt')
return sessionRt ? JSON.parse(sessionRt) : []
} catch (error) {
return []
}
}
export const removeRouters = () => {
window.sessionStorage.removeItem('rt')
}
export const removeAuth = () => {
window.localStorage.removeItem('auth')
}
export const asyncRouter = async (routeLists: string[], routes: any[]) => {
for (let i = 0; i < routes.length; i++) {
const item = routes[i]
if (item.routes) {
asyncRouter(routeLists, item.routes)
} else {
// 参与权限校验的页面
if (item.path && !routeLists.includes(item.path)) {
item.hideInMenu = true
item.noAuth = true
}
}
}
}
\ No newline at end of file
import { isDev } from '@/constants'
export interface AuthInfo {
userId: number,
memberId: number,
name: string,
token: string,
}
export const setAuth = (info: AuthInfo) => {
window.localStorage.setItem('auth', JSON.stringify(info))
}
export const getAuth = () => {
try {
const localAuth = window.localStorage.getItem('auth')
return localAuth ? JSON.parse(localAuth) : null
} catch (error) {
return {}
}
}
export const setRouters = (routers: any[]) => {
window.sessionStorage.setItem('rt', JSON.stringify(routers))
}
export const getRouters = (): string[] => {
try {
const localAuth = window.localStorage.getItem('auth')
if (localAuth) {
const userInfo = JSON.parse(localAuth)
return userInfo.urls ? userInfo.urls : []
}
return []
} catch (error) {
return []
}
}
export const removeRouters = () => {
window.sessionStorage.removeItem('rt')
}
export const removeAuth = () => {
window.localStorage.removeItem('auth')
}
export const asyncRouter = async (routeLists: string[], routes: any[]) => {
for (let i = 0; i < routes.length; i++) {
const item = routes[i]
if (item.routes) {
asyncRouter(routeLists, item.routes)
} else {
// 参与权限校验的页面
if (item.path && !routeLists.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