Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shenshaokai
jinfa-platform
Commits
6c75af40
Commit
6c75af40
authored
Mar 10, 2022
by
Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修改首页没有菜单权限仍然显示数据bug
parent
d0e67dd8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
11 deletions
+24
-11
index.ts
src/constants/index.ts
+2
-2
ChannelMallCenter.tsx
src/pages/home/components/Centers/ChannelMallCenter.tsx
+1
-1
ShopCenter.tsx
src/pages/home/components/Centers/ShopCenter.tsx
+1
-1
useViewRequest.tsx
src/pages/home/hooks/useViewRequest.tsx
+20
-7
No files found.
src/constants/index.ts
View file @
6c75af40
...
...
@@ -152,8 +152,8 @@ export enum LAYOUT_TYPE {
// 本地环境跳过权限校验
export
const
isDev
=
process
.
env
.
NODE_ENV
===
"development"
//
export const isDev = process.env.NODE_ENV === "development"
export
const
isDev
=
false
...
...
src/pages/home/components/Centers/ChannelMallCenter.tsx
View file @
6c75af40
...
...
@@ -28,7 +28,7 @@ const BIND_MANAGER = '/memberCenter/channelAbility/memberList'
const
ChannelMallCenter
:
React
.
FC
<
Iprops
>
=
()
=>
{
const
intl
=
useIntl
();
const
{
userAuth
,
hasAbilityFunc
}
=
useGetAuth
();
const
{
loading
,
responseData
,
isError
,
ref
,
inViewPort
}
=
useViewRequest
<
GetTemplateWebMemberChannelWebFindCurrMemberChannelResponse
,
any
>
(
getTemplateWebMemberChannelWebFindCurrMemberChannel
,
{
memberId
:
userAuth
.
memberId
}
)
const
{
loading
,
responseData
,
isError
,
ref
,
inViewPort
}
=
useViewRequest
<
GetTemplateWebMemberChannelWebFindCurrMemberChannelResponse
,
any
>
(
getTemplateWebMemberChannelWebFindCurrMemberChannel
,
{
memberId
:
userAuth
.
memberId
}
,
{
isFilterList
:
false
});
const
hasAbility
=
hasAbilityFunc
(
'channelAbility'
);
const
bindAuth
=
useMemo
(()
=>
userAuth
.
urls
?.
includes
(
BIND_MANAGER
),
[
userAuth
]);
const
[
salerNum
,
setSalerNum
]
=
useState
(
0
);
...
...
src/pages/home/components/Centers/ShopCenter.tsx
View file @
6c75af40
...
...
@@ -22,7 +22,7 @@ const CREATE_SHOP = '/memberCenter/shopAbility/infoManage';
// 5、如果当前用户有创建店铺权限,但还未创建店铺,则显示:您还没有创建店铺,请先创建店铺,点击创建店铺,跳转能力中心-店铺能力-店铺管理-创建店铺页
const
ShopCenter
:
React
.
FC
<
Iprops
>
=
()
=>
{
const
{
loading
,
responseData
,
isError
,
ref
}
=
useViewRequest
<
GetTemplateWebMemberShopWebFindCurrMemberShopResponse
,
any
>
(
getTemplateWebMemberShopWebFindCurrMemberShop
,
{})
const
{
loading
,
responseData
,
isError
,
ref
}
=
useViewRequest
<
GetTemplateWebMemberShopWebFindCurrMemberShopResponse
,
any
>
(
getTemplateWebMemberShopWebFindCurrMemberShop
,
{}
,
{
isFilterList
:
false
}
)
const
intl
=
useIntl
();
const
userAuth
=
getAuth
();
const
hasShopAbility
=
userAuth
.
urls
?.
some
((
_item
)
=>
_item
.
includes
(
SHOP_ABILITY
));
...
...
src/pages/home/hooks/useViewRequest.tsx
View file @
6c75af40
import
{
IRequestSuccess
}
from
'@/index.d'
;
import
{
getAuth
}
from
'@/utils/auth'
;
import
{
useInViewport
}
from
'@umijs/hooks'
;
import
{
useCallback
,
useEffect
,
useMemo
,
useRef
,
useState
}
from
'react'
;
type
Options
=
{
/** 是否进行权限过滤处理 */
isFilterList
:
boolean
}
/***
* 当下拉滚动到可视区域时请求数据
*/
function
useViewRequest
<
T
,
P
>
(
fn
:
(
postData
:
P
)
=>
Promise
<
IRequestSuccess
<
T
>>
,
params
?:
P
)
{
function
useViewRequest
<
T
,
P
>
(
fn
:
(
postData
:
P
)
=>
Promise
<
IRequestSuccess
<
T
>>
,
params
?:
P
,
options
?:
Options
)
{
const
[
loading
,
setLoading
]
=
useState
<
boolean
>
(
false
);
const
[
isError
,
setIsError
]
=
useState
<
boolean
>
(
false
);
const
[
inViewPort
,
ref
]
=
useInViewport
<
HTMLDivElement
>
();
const
[
hasRequest
,
setHasRequest
]
=
useState
<
boolean
>
(
false
)
const
[
responseData
,
setResponseData
]
=
useState
<
T
|
null
>
(
null
);
const
userAuth
=
getAuth
();
const
cacheAuth
=
useMemo
(()
=>
userAuth
,
[
userAuth
]);
const
urls
=
useMemo
(()
=>
cacheAuth
?.
urls
||
[],
[
cacheAuth
])
const
{
isFilterList
=
true
}
=
options
||
{}
// const hasFetchingRef = useRef(false);
const
fetchData
=
useCallback
(
async
(
params
)
=>
{
setLoading
(()
=>
true
);
try
{
const
{
data
,
code
,
message
}
=
await
fn
(
params
);
setHasRequest
(
()
=>
true
)
setHasRequest
(
true
)
// throw new Error("123");
if
(
code
===
1000
)
{
setResponseData
(
data
as
T
)
}
}
catch
(
error
)
{
setIsError
(
()
=>
true
);
setIsError
(
true
);
}
finally
{
setHasRequest
(
()
=>
true
);
setLoading
(
()
=>
false
);
setHasRequest
(
true
);
setLoading
(
false
);
}
},
[
fn
])
...
...
@@ -46,7 +56,7 @@ function useViewRequest<T, P>(fn: (postData: P) => Promise<IRequestSuccess<T>>,
}
const filterEmptyList = useMemo(() =
>
{
if
(
!
responseData
)
{
if
(
!
responseData
||
!
isFilterList
)
{
return
responseData
}
...
...
@@ -57,11 +67,14 @@ function useViewRequest<T, P>(fn: (postData: P) => Promise<IRequestSuccess<T>>,
if
(
!
responseData
)
{
return
result
}
console
.
log
(
responseData
,
"responData"
);
Object
.
keys
(
responseData
).
forEach
((
_row
)
=>
{
if
(
responseData
[
_row
]
&&
responseData
[
_row
].
length
!==
0
)
{
result
[
_row
]
=
responseData
[
_row
];
result
[
_row
]
=
responseData
[
_row
]
?.
filter
((
_item
)
=>
urls
.
includes
(
_item
.
link
))
;
}
})
console
.
log
(
result
,
"result"
);
return
result
;
}
, [responseData])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment