Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
bkunyun
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
sunyihao
bkunyun
Commits
6557c960
Commit
6557c960
authored
Jul 05, 2022
by
chenshouchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 修改获取产品信息时机,之前:进入页面获取,现在:在切换产品时获取产品信息
parent
84f25f7c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
37 deletions
+66
-37
project_api.ts
src/api/project_api.ts
+2
-2
useMyRouter.ts
src/components/MyRouter/useMyRouter.ts
+2
-27
index.tsx
src/views/ConsoleLayout/index.tsx
+42
-3
index.tsx
src/views/MenuLayout/index.tsx
+9
-1
index.tsx
src/views/Project/components/CurrentProject/index.tsx
+5
-2
project.ts
src/views/Project/project.ts
+6
-2
No files found.
src/api/project_api.ts
View file @
6557c960
...
@@ -21,7 +21,7 @@ type projectListParams = {
...
@@ -21,7 +21,7 @@ type projectListParams = {
};
};
// 查询当前用户可以看到的项目列表
// 查询当前用户可以看到的项目列表
const
produc
t
=
(
params
:
projectListParams
)
=>
{
const
getProjectLis
t
=
(
params
:
projectListParams
)
=>
{
return
request
({
return
request
({
url
:
Api
.
API_PROJECT_LIST
,
url
:
Api
.
API_PROJECT_LIST
,
method
:
"get"
,
method
:
"get"
,
...
@@ -246,7 +246,7 @@ const getworkFlowTaskInfo = (params: { jobId: string; taskId: string }) => {
...
@@ -246,7 +246,7 @@ const getworkFlowTaskInfo = (params: { jobId: string; taskId: string }) => {
export
{
export
{
current
,
current
,
menu
,
menu
,
produc
t
,
getProjectLis
t
,
hpczone
,
hpczone
,
addProject
,
addProject
,
getProject
,
getProject
,
...
...
src/components/MyRouter/useMyRouter.ts
View file @
6557c960
import
{
useStores
}
from
"@/store/index"
;
import
{
useStores
}
from
"@/store/index"
;
import
{
elements
}
from
"@/router"
;
import
{
elements
}
from
"@/router"
;
import
{
current
}
from
"@/api/demo_api"
;
import
{
current
}
from
"@/api/demo_api"
;
import
{
product
}
from
"@/api/project_api"
;
import
localStorageKey
from
"@/utils/localStorageKey"
;
import
localStorageKey
from
"@/utils/localStorageKey"
;
import
NotFound
from
"@/views/404"
;
import
NotFound
from
"@/views/404"
;
import
useMyRequest
from
"@/hooks/useMyRequest"
;
import
useMyRequest
from
"@/hooks/useMyRequest"
;
import
{
useEffect
}
from
"react"
;
import
{
useEffect
}
from
"react"
;
import
{
menu
}
from
"@/api/routes_api"
;
import
{
menu
}
from
"@/api/routes_api"
;
import
{
setFileServerEndPointLocalStorage
,
getFiletokenAccordingToId
,
}
from
"@/views/Project/project"
;
const
useMyRouter
=
()
=>
{
const
useMyRouter
=
()
=>
{
const
{
permissionStore
,
menuStore
,
currentProjectStore
}
=
useStores
();
const
{
permissionStore
,
menuStore
}
=
useStores
();
const
userInfo
=
useMyRequest
(
current
);
const
userInfo
=
useMyRequest
(
current
);
const
menuInfo
=
useMyRequest
(
menu
);
const
menuInfo
=
useMyRequest
(
menu
);
const
productInfo
=
useMyRequest
(
product
);
useEffect
(()
=>
{
useEffect
(()
=>
{
userInfo
.
run
();
userInfo
.
run
();
menuInfo
.
run
();
menuInfo
.
run
();
productInfo
.
run
({
product
:
"CADD"
,
});
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps
},
[]);
},
[]);
...
@@ -47,24 +38,8 @@ const useMyRouter = () => {
...
@@ -47,24 +38,8 @@ const useMyRouter = () => {
permissionStore
.
initAllRoutes
();
permissionStore
.
initAllRoutes
();
}
}
if
(
productInfo
.
res
)
{
let
list
=
productInfo
.
data
?.
data
;
if
(
list
.
length
===
0
)
{
currentProjectStore
.
setProjectList
([]);
currentProjectStore
.
changeProject
({});
}
else
{
currentProjectStore
.
setProjectList
(
list
);
currentProjectStore
.
changeProject
(
list
[
0
]);
setFileServerEndPointLocalStorage
(
list
[
0
].
zoneId
);
getFiletokenAccordingToId
(
list
[
0
].
id
).
then
((
res
)
=>
{
list
[
0
].
filetoken
=
res
;
currentProjectStore
.
changeProject
(
list
[
0
]);
});
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps
},
[
userInfo
.
data
,
menuInfo
.
data
,
productInfo
.
data
]);
},
[
userInfo
.
data
,
menuInfo
.
data
]);
return
permissionStore
.
allRoutes
;
return
permissionStore
.
allRoutes
;
};
};
...
...
src/views/ConsoleLayout/index.tsx
View file @
6557c960
import
React
,
{
useEffect
}
from
"react"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
{
Outlet
,
useLocation
,
useNavigate
}
from
"react-router-dom"
;
import
{
Outlet
,
useLocation
,
useNavigate
}
from
"react-router-dom"
;
import
cx
from
"classnames"
;
import
cx
from
"classnames"
;
import
{
observer
}
from
"mobx-react-lite"
;
import
{
observer
}
from
"mobx-react-lite"
;
...
@@ -14,7 +14,12 @@ import Button from "@/components/mui/Button";
...
@@ -14,7 +14,12 @@ import Button from "@/components/mui/Button";
import
logo
from
"@/assets/img/logo.svg"
;
import
logo
from
"@/assets/img/logo.svg"
;
import
MyPopover
from
"@/components/mui/MyPopover"
;
import
MyPopover
from
"@/components/mui/MyPopover"
;
import
TranSferList
from
"./components/TransferList"
;
import
TranSferList
from
"./components/TransferList"
;
import
{
getProjectList
}
from
"@/api/project_api"
;
import
useMyRequest
from
"@/hooks/useMyRequest"
;
import
{
setFileServerEndPointLocalStorage
,
getFiletokenAccordingToId
,
}
from
"@/views/Project/project"
;
import
style
from
"./index.module.css"
;
import
style
from
"./index.module.css"
;
const
ConsoleLayout
=
observer
(()
=>
{
const
ConsoleLayout
=
observer
(()
=>
{
...
@@ -28,6 +33,40 @@ const ConsoleLayout = observer(() => {
...
@@ -28,6 +33,40 @@ const ConsoleLayout = observer(() => {
handleClose
,
handleClose
,
}
=
useIndex
();
}
=
useIndex
();
const
[
currentProduct
,
setCurrentProduct
]
=
useState
<
{
path
:
string
;
name
:
string
;
}
>
();
const
{
currentProjectStore
}
=
useStores
();
const
{
run
:
runGetProjectList
}
=
useMyRequest
(
getProjectList
,
{
onSuccess
:
(
res
)
=>
{
let
list
=
res
.
data
;
if
(
list
.
length
===
0
)
{
currentProjectStore
.
setProjectList
([]);
currentProjectStore
.
changeProject
({});
navigate
(
currentProduct
?.
path
as
string
);
}
else
{
currentProjectStore
.
setProjectList
(
list
);
currentProjectStore
.
changeProject
(
list
[
0
]);
setFileServerEndPointLocalStorage
(
list
[
0
].
zoneId
);
getFiletokenAccordingToId
(
list
[
0
].
id
).
then
((
res
)
=>
{
list
[
0
].
filetoken
=
res
;
currentProjectStore
.
changeProject
(
list
[
0
]);
});
navigate
(
currentProduct
?.
path
as
string
);
}
},
});
// 切换产品
const
getProduct
=
(
item
:
any
)
=>
{
setCurrentProduct
(
item
);
runGetProjectList
({
product
:
item
.
name
,
});
};
const
navigate
=
useNavigate
();
const
navigate
=
useNavigate
();
const
location
=
useLocation
();
const
location
=
useLocation
();
const
{
permissionStore
,
menuStore
}
=
useStores
();
const
{
permissionStore
,
menuStore
}
=
useStores
();
...
@@ -86,7 +125,7 @@ const ConsoleLayout = observer(() => {
...
@@ -86,7 +125,7 @@ const ConsoleLayout = observer(() => {
root
:
style
.
menuItemRoot
,
root
:
style
.
menuItemRoot
,
}
}
}
}
onClick=
{
()
=>
{
onClick=
{
()
=>
{
navigate
(
item
.
path
);
getProduct
(
item
);
handleClose
();
handleClose
();
}
}
}
}
>
>
...
...
src/views/MenuLayout/index.tsx
View file @
6557c960
...
@@ -6,13 +6,21 @@ import style from "./index.module.css";
...
@@ -6,13 +6,21 @@ import style from "./index.module.css";
import
{
observer
}
from
"mobx-react-lite"
;
import
{
observer
}
from
"mobx-react-lite"
;
import
{
useStores
}
from
"@/store/index"
;
import
{
useStores
}
from
"@/store/index"
;
import
classnames
from
"classnames"
;
import
classnames
from
"classnames"
;
import
{
toJS
}
from
"mobx"
;
const
MenuLayout
=
observer
(()
=>
{
const
MenuLayout
=
observer
(()
=>
{
const
{
permissionStore
}
=
useStores
();
const
{
permissionStore
,
currentProjectStore
}
=
useStores
();
let
pathname
=
new
URL
(
window
.
location
.
href
).
pathname
;
let
pathname
=
new
URL
(
window
.
location
.
href
).
pathname
;
const
navigate
=
useNavigate
();
const
navigate
=
useNavigate
();
const
productInfo
=
toJS
(
currentProjectStore
.
currentProductInfo
);
// 未选择产品时 直接跳转home页面
if
(
!
productInfo
.
name
)
{
navigate
(
"/home"
);
}
return
(
return
(
<
Box
className=
{
style
.
container
}
>
<
Box
className=
{
style
.
container
}
>
<
Box
className=
{
style
.
aside
}
>
<
Box
className=
{
style
.
aside
}
>
...
...
src/views/Project/components/CurrentProject/index.tsx
View file @
6557c960
...
@@ -59,9 +59,12 @@ const CurrentProject = observer(() => {
...
@@ -59,9 +59,12 @@ const CurrentProject = observer(() => {
<
img
src=
{
logo
}
alt=
""
className=
{
style
.
logo
}
/>
<
img
src=
{
logo
}
alt=
""
className=
{
style
.
logo
}
/>
<
div
className=
{
style
.
info
}
>
<
div
className=
{
style
.
info
}
>
<
div
className=
{
style
.
productName
}
>
<
div
className=
{
style
.
productName
}
>
{
currentProjectStore
.
currentProductInfo
.
name
||
"CADD"
}
{
currentProjectStore
.
currentProductInfo
.
name
}
</
div
>
</
div
>
<
div
className=
{
style
.
projectName
}
title=
{
currentProjectStore
.
currentProjectInfo
.
name
}
>
<
div
className=
{
style
.
projectName
}
title=
{
currentProjectStore
.
currentProjectInfo
.
name
}
>
{
currentProjectStore
.
currentProjectInfo
.
name
||
"暂无项目"
}
{
currentProjectStore
.
currentProjectInfo
.
name
||
"暂无项目"
}
</
div
>
</
div
>
</
div
>
</
div
>
...
...
src/views/Project/project.ts
View file @
6557c960
...
@@ -6,10 +6,14 @@
...
@@ -6,10 +6,14 @@
* @FilePath: /bkunyun/src/views/Project/project.ts
* @FilePath: /bkunyun/src/views/Project/project.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
*/
import
{
product
,
hpczone
,
getDataFileToken
}
from
"@/api/project_api"
;
import
{
getProjectList
as
getProjectListApi
,
hpczone
,
getDataFileToken
,
}
from
"@/api/project_api"
;
export
const
getProjectList
=
async
()
=>
{
export
const
getProjectList
=
async
()
=>
{
const
res
=
await
product
({
product
:
"CADD"
});
const
res
=
await
getProjectListApi
({
product
:
"CADD"
});
return
res
.
data
;
return
res
.
data
;
};
};
...
...
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