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
45239ce4
Commit
45239ce4
authored
Jul 05, 2022
by
chenshouchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 选中的产品和项目用sessionstorage做持久化
parent
6557c960
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
10 deletions
+26
-10
currentProject.ts
src/store/modules/currentProject.ts
+20
-3
index.tsx
src/views/ConsoleLayout/index.tsx
+1
-0
index.tsx
src/views/Project/components/AddProject/index.tsx
+5
-6
index.tsx
src/views/Project/components/CurrentProject/index.tsx
+0
-1
No files found.
src/store/modules/currentProject.ts
View file @
45239ce4
...
@@ -11,22 +11,39 @@ type productInfo = {
...
@@ -11,22 +11,39 @@ type productInfo = {
id
?:
string
;
id
?:
string
;
name
?:
string
;
name
?:
string
;
};
};
const
sessionStorageCurrentProjectInfo
=
JSON
.
parse
(
sessionStorage
.
getItem
(
"currentProjectInfo"
)
||
"{}"
);
const
sessionStorageCurrentProductInfo
=
JSON
.
parse
(
sessionStorage
.
getItem
(
"currentProductInfo"
)
||
"{}"
);
const
sessionStorageProjectList
=
JSON
.
parse
(
sessionStorage
.
getItem
(
"projectList"
)
||
"[]"
);
class
currentProject
{
class
currentProject
{
constructor
()
{
constructor
()
{
makeAutoObservable
(
this
);
makeAutoObservable
(
this
);
}
}
// 选中的项目
// 选中的项目
currentProjectInfo
:
projectInfo
=
{}
;
currentProjectInfo
:
projectInfo
=
sessionStorageCurrentProjectInfo
;
// 选中的产品下的项目列表
// 选中的产品下的项目列表
projectList
:
Array
<
projectInfo
>
=
[]
;
projectList
:
Array
<
projectInfo
>
=
sessionStorageProjectList
;
// 选中的产品
// 选中的产品
currentProductInfo
:
productInfo
=
{}
;
currentProductInfo
:
productInfo
=
sessionStorageCurrentProductInfo
;
setProjectList
=
(
list
:
Array
<
projectInfo
>
)
=>
{
setProjectList
=
(
list
:
Array
<
projectInfo
>
)
=>
{
this
.
projectList
=
list
;
this
.
projectList
=
list
;
sessionStorage
.
setItem
(
"projectList"
,
JSON
.
stringify
(
list
));
};
};
changeProject
=
(
project
:
projectInfo
)
=>
{
changeProject
=
(
project
:
projectInfo
)
=>
{
this
.
currentProjectInfo
=
project
;
this
.
currentProjectInfo
=
project
;
sessionStorage
.
setItem
(
"currentProjectInfo"
,
JSON
.
stringify
(
project
));
};
changeProductInfo
=
(
productInfo
:
productInfo
)
=>
{
this
.
currentProductInfo
=
productInfo
;
sessionStorage
.
setItem
(
"currentProductInfo"
,
JSON
.
stringify
(
productInfo
));
};
};
}
}
...
...
src/views/ConsoleLayout/index.tsx
View file @
45239ce4
...
@@ -61,6 +61,7 @@ const ConsoleLayout = observer(() => {
...
@@ -61,6 +61,7 @@ const ConsoleLayout = observer(() => {
// 切换产品
// 切换产品
const
getProduct
=
(
item
:
any
)
=>
{
const
getProduct
=
(
item
:
any
)
=>
{
currentProjectStore
.
changeProductInfo
({
id
:
item
.
name
,
name
:
item
.
name
});
setCurrentProduct
(
item
);
setCurrentProduct
(
item
);
runGetProjectList
({
runGetProjectList
({
product
:
item
.
name
,
product
:
item
.
name
,
...
...
src/views/Project/components/AddProject/index.tsx
View file @
45239ce4
...
@@ -84,17 +84,16 @@ const AddProject = (props: any) => {
...
@@ -84,17 +84,16 @@ const AddProject = (props: any) => {
const
handleClickOpen
=
()
=>
{
const
handleClickOpen
=
()
=>
{
DialogRef
.
current
.
handleClickOpen
();
DialogRef
.
current
.
handleClickOpen
();
initData
()
initData
()
;
};
};
const
initData
=
()
=>
{
const
initData
=
()
=>
{
setName
(
''
)
setName
(
""
);
setDesc
(
''
)
setDesc
(
""
);
if
(
zoneIdOptions
.
length
>
0
)
{
if
(
zoneIdOptions
.
length
>
0
)
{
setZoneId
(
zoneIdOptions
[
0
].
id
)
setZoneId
(
zoneIdOptions
[
0
].
id
)
;
}
}
}
};
const
checkName
=
(
name
:
string
)
=>
{
const
checkName
=
(
name
:
string
)
=>
{
if
(
name
)
{
if
(
name
)
{
...
...
src/views/Project/components/CurrentProject/index.tsx
View file @
45239ce4
...
@@ -45,7 +45,6 @@ const CurrentProject = observer(() => {
...
@@ -45,7 +45,6 @@ const CurrentProject = observer(() => {
const
openAddProject
=
()
=>
{
const
openAddProject
=
()
=>
{
addProjectRef
.
current
.
handleClickOpen
();
addProjectRef
.
current
.
handleClickOpen
();
// setAddProjectOpen(true);
setProjectListOpen
(
false
);
setProjectListOpen
(
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