Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
763b41b3
authored
Nov 21, 2024
by
heheer
Committed by
GitHub
Nov 21, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simple app snapshot init (#3207)
* simple init * change old past position
parent
019bf67e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
17 deletions
+11
-17
projects/app/src/pages/app/detail/components/SimpleApp/Edit.tsx
+11
-3
projects/app/src/pages/app/detail/components/SimpleApp/useSnapshots.tsx
+0
-14
No files found.
projects/app/src/pages/app/detail/components/SimpleApp/Edit.tsx
View file @
763b41b3
import
React
from
'react'
;
import
React
from
'react'
;
import
{
Box
}
from
'@chakra-ui/react'
;
import
{
Box
}
from
'@chakra-ui/react'
;
import
{
useMount
}
from
'ahooks'
;
import
{
use
LocalStorageState
,
use
Mount
}
from
'ahooks'
;
import
{
useDatasetStore
}
from
'@/web/core/dataset/store/dataset'
;
import
{
useDatasetStore
}
from
'@/web/core/dataset/store/dataset'
;
import
{
appWorkflow2Form
}
from
'@fastgpt/global/core/app/utils'
;
import
{
appWorkflow2Form
}
from
'@fastgpt/global/core/app/utils'
;
...
@@ -62,6 +62,12 @@ const Edit = ({
...
@@ -62,6 +62,12 @@ const Edit = ({
const
{
appDetail
}
=
useContextSelector
(
AppContext
,
(
v
)
=>
v
);
const
{
appDetail
}
=
useContextSelector
(
AppContext
,
(
v
)
=>
v
);
const
{
t
}
=
useTranslation
();
const
{
t
}
=
useTranslation
();
// 旧的编辑记录,直接重置到新的变量中
const
[
oldPast
,
setOldPast
]
=
useLocalStorageState
<
SimpleAppSnapshotType
[]
>
(
`
${
appDetail
.
_id
}
-past-simple`
,
{}
);
// Init app form
// Init app form
useMount
(()
=>
{
useMount
(()
=>
{
// show selected dataset
// show selected dataset
...
@@ -81,11 +87,13 @@ const Edit = ({
...
@@ -81,11 +87,13 @@ const Edit = ({
const
pastState
=
getAppConfigByDiff
(
past
[
past
.
length
-
1
].
state
,
past
[
0
].
diff
);
const
pastState
=
getAppConfigByDiff
(
past
[
past
.
length
-
1
].
state
,
past
[
0
].
diff
);
return
setAppForm
(
pastState
);
return
setAppForm
(
pastState
);
}
else
if
(
past
&&
past
.
length
>
0
&&
p
ast
?.
every
((
item
)
=>
item
.
appForm
))
{
}
else
if
(
oldPast
&&
oldPast
.
length
>
0
&&
oldP
ast
?.
every
((
item
)
=>
item
.
appForm
))
{
// 格式化成 diff
// 格式化成 diff
const
newPast
=
convertOldFormatHistory
(
p
ast
);
const
newPast
=
convertOldFormatHistory
(
oldP
ast
);
setPast
(
newPast
);
setPast
(
newPast
);
setOldPast
&&
setOldPast
([]);
return
setAppForm
(
getAppConfigByDiff
(
newPast
[
newPast
.
length
-
1
].
state
,
newPast
[
0
].
diff
));
return
setAppForm
(
getAppConfigByDiff
(
newPast
[
newPast
.
length
-
1
].
state
,
newPast
[
0
].
diff
));
}
}
...
...
projects/app/src/pages/app/detail/components/SimpleApp/useSnapshots.tsx
View file @
763b41b3
...
@@ -120,20 +120,6 @@ export const useSimpleAppSnapshots = (appId: string) => {
...
@@ -120,20 +120,6 @@ export const useSimpleAppSnapshots = (appId: string) => {
});
});
},
[
appId
]);
},
[
appId
]);
// 旧的编辑记录,直接重置到新的变量中
const
[
oldPast
,
setOldPast
]
=
useLocalStorageState
<
SimpleAppSnapshotType
[]
>
(
`
${
appId
}
-past-simple`
,
{}
);
useEffect
(()
=>
{
if
(
oldPast
&&
oldPast
.
length
>
0
)
{
setPast
(
past
);
setOldPast
([]);
// refresh page
window
.
location
.
reload
();
}
},
[
oldPast
]);
return
{
forbiddenSaveSnapshot
,
past
,
setPast
,
saveSnapshot
};
return
{
forbiddenSaveSnapshot
,
past
,
setPast
,
saveSnapshot
};
};
};
...
...
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