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
Administrator
bkunyun
Commits
5ae002f7
Commit
5ae002f7
authored
Jun 15, 2022
by
chenshouchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新增项目后 当前项目变为新增的项目, 切换项目后同时获取filetoken
parent
454f109e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
56 additions
and
4 deletions
+56
-4
useMyRouter.ts
src/components/MyRouter/useMyRouter.ts
+8
-1
currentProject.ts
src/store/modules/currentProject.ts
+1
-0
index.tsx
src/views/Project/ProjectData/index.tsx
+0
-0
index.tsx
src/views/Project/ProjectSetting/BaseInfo/index.tsx
+11
-1
index.tsx
src/views/Project/components/AddProject/index.tsx
+16
-0
index.tsx
src/views/Project/components/CurrentProject/index.tsx
+8
-1
project.ts
src/views/Project/project.ts
+12
-1
No files found.
src/components/MyRouter/useMyRouter.ts
View file @
5ae002f7
...
...
@@ -8,7 +8,10 @@ import NotFound from "@/views/404";
import
useMyRequest
from
"@/hooks/useMyRequest"
;
import
{
useEffect
}
from
"react"
;
import
{
menu
}
from
"@/api/routes_api"
;
import
{
setFileServerEndPointLocalStorage
}
from
"@/views/Project/project"
;
import
{
setFileServerEndPointLocalStorage
,
getFiletokenAccordingToId
,
}
from
"@/views/Project/project"
;
const
useMyRouter
=
()
=>
{
const
{
permissionStore
,
menuStore
,
currentProjectStore
}
=
useStores
();
...
...
@@ -53,6 +56,10 @@ const useMyRouter = () => {
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
]);
});
}
}
...
...
src/store/modules/currentProject.ts
View file @
5ae002f7
...
...
@@ -4,6 +4,7 @@ type projectInfo = {
name
?:
string
;
desc
?:
string
;
projectRole
?:
string
;
filetoken
?:
string
;
};
type
productInfo
=
{
...
...
src/views/Project/ProjectData/index.tsx
View file @
5ae002f7
This diff is collapsed.
Click to expand it.
src/views/Project/ProjectSetting/BaseInfo/index.tsx
View file @
5ae002f7
...
...
@@ -28,7 +28,10 @@ import Loading from "@/views/Loading";
import
MyDialog
from
"@/components/mui/MyDialog"
;
import
{
getProjectList
}
from
"../../project"
;
import
{
checkIsNumberLetterChinese
}
from
"@/utils/util"
;
import
{
setFileServerEndPointLocalStorage
}
from
"@/views/Project/project"
;
import
{
setFileServerEndPointLocalStorage
,
getFiletokenAccordingToId
,
}
from
"@/views/Project/project"
;
type
zoneIdOption
=
{
id
:
string
;
...
...
@@ -190,8 +193,15 @@ const BaseInfo = observer(() => {
localStorage
.
setItem
(
"fileServerEndPoint"
,
""
);
setProjectInfo
({});
}
else
{
projectList
[
0
].
filetoken
=
getFiletokenAccordingToId
(
projectList
[
0
].
id
);
currentProjectStore
.
changeProject
(
projectList
[
0
]);
setFileServerEndPointLocalStorage
(
projectList
[
0
].
zoneId
);
getFiletokenAccordingToId
(
projectList
[
0
].
id
).
then
((
res
)
=>
{
projectList
[
0
].
filetoken
=
res
;
currentProjectStore
.
changeProject
(
projectList
[
0
]);
});
setProjectInfo
(
projectList
[
0
]);
}
},
...
...
src/views/Project/components/AddProject/index.tsx
View file @
5ae002f7
...
...
@@ -8,6 +8,10 @@ import { useMessage } from "@/components/MySnackbar";
import
{
getProjectList
}
from
"../../project"
;
import
{
useStores
}
from
"@/store"
;
import
{
checkIsNumberLetterChinese
}
from
"@/utils/util"
;
import
{
setFileServerEndPointLocalStorage
,
getFiletokenAccordingToId
,
}
from
"@/views/Project/project"
;
type
zoneIdOption
=
{
id
:
string
;
...
...
@@ -45,6 +49,18 @@ const AddProject = (props: any) => {
message
.
success
(
"新建项目成功"
);
const
projectList
=
await
getProjectList
();
currentProjectStore
.
setProjectList
(
projectList
);
let
project
:
any
=
{};
projectList
.
forEach
((
item
:
any
)
=>
{
if
(
item
.
name
===
name
)
{
project
=
{
...
item
};
}
});
currentProjectStore
.
changeProject
(
project
);
setFileServerEndPointLocalStorage
(
project
.
zoneId
);
getFiletokenAccordingToId
(
project
.
id
).
then
((
res
)
=>
{
project
.
filetoken
=
res
;
currentProjectStore
.
changeProject
(
project
);
});
}
},
onError
:
()
=>
{
...
...
src/views/Project/components/CurrentProject/index.tsx
View file @
5ae002f7
...
...
@@ -7,7 +7,10 @@ import ProjectListPopper from "../ProjectListPopper";
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
{
observer
}
from
"mobx-react-lite"
;
import
AddProject
from
"../AddProject"
;
import
{
setFileServerEndPointLocalStorage
}
from
"@/views/Project/project"
;
import
{
setFileServerEndPointLocalStorage
,
getFiletokenAccordingToId
,
}
from
"@/views/Project/project"
;
const
CurrentProject
=
observer
(()
=>
{
const
{
currentProjectStore
}
=
useStores
();
...
...
@@ -33,6 +36,10 @@ const CurrentProject = observer(() => {
const
handleChangeCurrentProject
=
(
project
:
any
)
=>
{
currentProjectStore
.
changeProject
(
project
);
setFileServerEndPointLocalStorage
(
project
.
zoneId
);
getFiletokenAccordingToId
(
project
.
id
).
then
((
res
)
=>
{
project
.
filetoken
=
res
;
currentProjectStore
.
changeProject
(
project
);
});
setProjectListOpen
(
!
projectListOpen
);
};
...
...
src/views/Project/project.ts
View file @
5ae002f7
import
{
product
,
hpczone
}
from
"@/api/project_api"
;
import
{
product
,
hpczone
,
getDataFileToken
}
from
"@/api/project_api"
;
export
const
getProjectList
=
async
()
=>
{
const
res
=
await
product
({
product
:
"CADD"
});
...
...
@@ -18,3 +18,14 @@ export const setFileServerEndPointLocalStorage = async (zoneId: string) => {
localStorage
.
setItem
(
"fileServerEndPoint"
,
fileServerEndPoint
);
}
};
// 根据项目id获取文件token
export
const
getFiletokenAccordingToId
=
async
(
projectId
:
string
)
=>
{
const
res
=
await
getDataFileToken
({
id
:
projectId
});
console
.
log
(
res
,
"getFiletokenAccordingToId"
);
return
res
.
data
;
// if (res) {
// } else {
// return false;
// }
};
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