@@ -248,9 +248,7 @@ const OutLink = (props: Props) => {
248248 < Flex
249249 h = { 'full' }
250250 gap = { 4 }
251- { ...( isEmbed
252- ? { p : '0 !important' , insertProps : { borderRadius : '0' , boxShadow : 'none' } }
253- : { p : [ 0 , 5 ] } ) }
251+ { ...( isEmbed ? { p : '0 !important' , borderRadius : '0' , boxShadow : 'none' } : { p : [ 0 , 5 ] } ) }
254252 >
255253 { ( ! quoteData || isPc ) && (
256254 < PageContainer flex = { '1 0 0' } w = { 0 } isLoading = { loading } p = { '0 !important' } >
@@ -316,12 +314,12 @@ const OutLink = (props: Props) => {
316314
317315const Render = ( props : Props ) => {
318316 const { shareId, authToken, customUid, appId } = props ;
319- const { localUId } = useShareChatStore ( ) ;
317+ const { localUId, setLocalUId , loaded } = useShareChatStore ( ) ;
320318 const { source, chatId, setSource, setAppId, setOutLinkAuthData } = useChatStore ( ) ;
321319 const { setUserDefaultLng } = useI18nLng ( ) ;
322320
323321 const chatHistoryProviderParams = useMemo ( ( ) => {
324- return { shareId, outLinkUid : authToken || customUid || localUId } ;
322+ return { shareId, outLinkUid : authToken || customUid || localUId || '' } ;
325323 } , [ authToken , customUid , localUId , shareId ] ) ;
326324 const chatRecordProviderParams = useMemo ( ( ) => {
327325 return {
@@ -338,20 +336,32 @@ const Render = (props: Props) => {
338336 setUserDefaultLng ( true ) ;
339337 } ) ;
340338
341- // Set outLinkAuthData
339+ // Set default localUId
342340 useEffect ( ( ) => {
343- setOutLinkAuthData ( {
344- shareId,
345- outLinkUid : chatHistoryProviderParams . outLinkUid
346- } ) ;
341+ if ( loaded ) {
342+ if ( ! localUId ) {
343+ setLocalUId ( `shareChat-${ Date . now ( ) } -${ getNanoid ( 24 ) } ` ) ;
344+ }
345+ }
346+ } , [ loaded , localUId , setLocalUId ] ) ;
347+
348+ // Init outLinkAuthData
349+ useEffect ( ( ) => {
350+ if ( chatHistoryProviderParams . outLinkUid ) {
351+ setOutLinkAuthData ( {
352+ shareId,
353+ outLinkUid : chatHistoryProviderParams . outLinkUid
354+ } ) ;
355+ }
347356 return ( ) => {
348357 setOutLinkAuthData ( { } ) ;
349358 } ;
350- } , [ chatHistoryProviderParams . outLinkUid , shareId ] ) ;
359+ } , [ chatHistoryProviderParams . outLinkUid , setOutLinkAuthData , shareId ] ) ;
360+
351361 // Watch appId
352362 useEffect ( ( ) => {
353363 setAppId ( appId ) ;
354- } , [ appId ] ) ;
364+ } , [ appId , setAppId ] ) ;
355365
356366 return source === ChatSourceEnum . share ? (
357367 < ChatContextProvider params = { chatHistoryProviderParams } >
0 commit comments