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
9a1fff74
authored
Mar 20, 2025
by
Archer
Committed by
GitHub
Mar 20, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: nextjs 14.2.24 cannot auto create local storage (#4249) (#4250)
parent
de87639f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
19 deletions
+28
-19
projects/app/src/pages/chat/share.tsx
+22
-12
projects/app/src/web/core/chat/storeShareChat.ts
+6
-7
No files found.
projects/app/src/pages/chat/share.tsx
View file @
9a1fff74
...
@@ -248,9 +248,7 @@ const OutLink = (props: Props) => {
...
@@ -248,9 +248,7 @@ const OutLink = (props: Props) => {
<
Flex
<
Flex
h=
{
'full'
}
h=
{
'full'
}
gap=
{
4
}
gap=
{
4
}
{
...
(
isEmbed
{
...
(
isEmbed
?
{
p
:
'0
!
important
',
borderRadius
:
'0',
boxShadow
:
'
none
'
}
:
{
p
:
[0,
5]
})}
?
{
p
:
'0
!
important
',
insertProps
:
{
borderRadius
:
'0',
boxShadow
:
'
none
'
}
}
:
{
p
:
[0,
5]
})}
>
>
{
(
!
quoteData
||
isPc
)
&&
(
{
(
!
quoteData
||
isPc
)
&&
(
<
PageContainer
flex=
{
'1 0 0'
}
w=
{
0
}
isLoading=
{
loading
}
p=
{
'0 !important'
}
>
<
PageContainer
flex=
{
'1 0 0'
}
w=
{
0
}
isLoading=
{
loading
}
p=
{
'0 !important'
}
>
...
@@ -316,12 +314,12 @@ const OutLink = (props: Props) => {
...
@@ -316,12 +314,12 @@ const OutLink = (props: Props) => {
const
Render
=
(
props
:
Props
)
=>
{
const
Render
=
(
props
:
Props
)
=>
{
const
{
shareId
,
authToken
,
customUid
,
appId
}
=
props
;
const
{
shareId
,
authToken
,
customUid
,
appId
}
=
props
;
const
{
localUId
}
=
useShareChatStore
();
const
{
localUId
,
setLocalUId
,
loaded
}
=
useShareChatStore
();
const
{
source
,
chatId
,
setSource
,
setAppId
,
setOutLinkAuthData
}
=
useChatStore
();
const
{
source
,
chatId
,
setSource
,
setAppId
,
setOutLinkAuthData
}
=
useChatStore
();
const
{
setUserDefaultLng
}
=
useI18nLng
();
const
{
setUserDefaultLng
}
=
useI18nLng
();
const
chatHistoryProviderParams
=
useMemo
(()
=>
{
const
chatHistoryProviderParams
=
useMemo
(()
=>
{
return
{
shareId
,
outLinkUid
:
authToken
||
customUid
||
localUId
};
return
{
shareId
,
outLinkUid
:
authToken
||
customUid
||
localUId
||
''
};
},
[
authToken
,
customUid
,
localUId
,
shareId
]);
},
[
authToken
,
customUid
,
localUId
,
shareId
]);
const
chatRecordProviderParams
=
useMemo
(()
=>
{
const
chatRecordProviderParams
=
useMemo
(()
=>
{
return
{
return
{
...
@@ -338,20 +336,32 @@ const Render = (props: Props) => {
...
@@ -338,20 +336,32 @@ const Render = (props: Props) => {
setUserDefaultLng
(
true
);
setUserDefaultLng
(
true
);
});
});
// Set
outLinkAuthData
// Set
default localUId
useEffect
(()
=>
{
useEffect
(()
=>
{
setOutLinkAuthData
({
if
(
loaded
)
{
shareId
,
if
(
!
localUId
)
{
outLinkUid
:
chatHistoryProviderParams
.
outLinkUid
setLocalUId
(
`shareChat-
${
Date
.
now
()}
-
${
getNanoid
(
24
)}
`
);
});
}
}
},
[
loaded
,
localUId
,
setLocalUId
]);
// Init outLinkAuthData
useEffect
(()
=>
{
if
(
chatHistoryProviderParams
.
outLinkUid
)
{
setOutLinkAuthData
({
shareId
,
outLinkUid
:
chatHistoryProviderParams
.
outLinkUid
});
}
return
()
=>
{
return
()
=>
{
setOutLinkAuthData
({});
setOutLinkAuthData
({});
};
};
},
[
chatHistoryProviderParams
.
outLinkUid
,
shareId
]);
},
[
chatHistoryProviderParams
.
outLinkUid
,
setOutLinkAuthData
,
shareId
]);
// Watch appId
// Watch appId
useEffect
(()
=>
{
useEffect
(()
=>
{
setAppId
(
appId
);
setAppId
(
appId
);
},
[
appId
]);
},
[
appId
,
setAppId
]);
return
source
===
ChatSourceEnum
.
share
?
(
return
source
===
ChatSourceEnum
.
share
?
(
<
ChatContextProvider
params=
{
chatHistoryProviderParams
}
>
<
ChatContextProvider
params=
{
chatHistoryProviderParams
}
>
...
...
projects/app/src/web/core/chat/storeShareChat.ts
View file @
9a1fff74
import
{
create
}
from
'zustand'
;
import
{
create
}
from
'zustand'
;
import
{
devtools
,
persist
}
from
'zustand/middleware'
;
import
{
devtools
,
persist
}
from
'zustand/middleware'
;
import
{
immer
}
from
'zustand/middleware/immer'
;
import
{
immer
}
from
'zustand/middleware/immer'
;
import
{
customAlphabet
}
from
'nanoid'
;
const
nanoid
=
customAlphabet
(
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWSYZ1234567890_'
,
24
);
type
State
=
{
type
State
=
{
localUId
:
string
;
localUId
?:
string
;
setLocalUId
:
(
localUId
:
string
)
=>
void
;
loaded
:
boolean
;
loaded
:
boolean
;
};
};
...
@@ -16,7 +12,10 @@ export const useShareChatStore = create<State>()(
...
@@ -16,7 +12,10 @@ export const useShareChatStore = create<State>()(
devtools
(
devtools
(
persist
(
persist
(
immer
((
set
,
get
)
=>
({
immer
((
set
,
get
)
=>
({
localUId
:
`shareChat-
${
Date
.
now
()}
-
${
nanoid
()}
`
,
localUId
:
undefined
,
setLocalUId
(
localUId
:
string
)
{
set
({
localUId
});
},
loaded
:
false
loaded
:
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