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
98a57965
authored
Jul 16, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ssr init
parent
877aab85
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
10 deletions
+51
-10
client/src/components/Layout/index.tsx
+3
-2
client/src/pages/_app.tsx
+17
-1
client/src/pages/_error.tsx
+9
-0
client/src/pages/chat/share.tsx
+6
-5
client/src/pages/kb/detail/components/Info.tsx
+6
-0
client/src/store/global.ts
+10
-2
No files found.
client/src/components/Layout/index.tsx
View file @
98a57965
...
...
@@ -63,7 +63,7 @@ const Layout = ({ children }: { children: JSX.Element }) => {
return
(
<>
<
Box
h=
{
'100%'
}
bg=
{
'myWhite.600'
}
>
{
isPc
?
(
{
isPc
===
true
&&
(
<>
{
pcUnShowLayoutRoute
[
router
.
pathname
]
?
(
<
Auth
>
{
children
}
</
Auth
>
...
...
@@ -78,7 +78,8 @@ const Layout = ({ children }: { children: JSX.Element }) => {
</>
)
}
</>
)
:
(
)
}
{
isPc
===
false
&&
(
<>
<
Box
h=
{
'100%'
}
display=
{
[
'block'
,
'none'
]
}
>
{
phoneUnShowLayoutRoute
[
router
.
pathname
]
||
isChatPage
?
(
...
...
client/src/pages/_app.tsx
View file @
98a57965
...
...
@@ -11,6 +11,9 @@ import Router from 'next/router';
import
'nprogress/nprogress.css'
;
import
'@/styles/reset.scss'
;
import
{
clientInitData
}
from
'@/store/static'
;
import
{
NextPageContext
}
from
'next'
;
import
{
useGlobalStore
}
from
'@/store/global'
;
import
{
GET
}
from
'@/service/api/axios'
;
//Binding events.
Router
.
events
.
on
(
'routeChangeStart'
,
()
=>
NProgress
.
start
());
...
...
@@ -28,9 +31,14 @@ const queryClient = new QueryClient({
}
});
function
App
({
Component
,
pageProps
}:
AppProps
)
{
function
App
({
Component
,
pageProps
,
isPc
}:
AppProps
&
{
isPc
?:
boolean
;
response
:
any
}
)
{
const
[
googleVerKey
,
setGoogleVerKey
]
=
useState
<
string
>
();
const
[
baiduTongji
,
setBaiduTongji
]
=
useState
<
string
>
();
const
{
initIsPc
}
=
useGlobalStore
();
if
(
isPc
!==
undefined
)
{
initIsPc
(
isPc
);
}
useEffect
(()
=>
{
(
async
()
=>
{
...
...
@@ -76,4 +84,12 @@ function App({ Component, pageProps }: AppProps) {
);
}
App
.
getInitialProps
=
async
({
ctx
}:
{
ctx
:
NextPageContext
})
=>
{
const
reg
=
/mobile/gi
;
const
isPc
=
!
reg
.
test
(
ctx
.
req
?.
headers
?.[
'user-agent'
]
||
''
);
return
{
isPc
};
};
export
default
App
;
client/src/pages/_error.tsx
View file @
98a57965
import
{
useEffect
}
from
'react'
;
import
{
useRouter
}
from
'next/router'
;
function
Error
()
{
const
router
=
useRouter
();
useEffect
(()
=>
{
setTimeout
(()
=>
{
router
.
replace
(
'/app/list'
);
},
2000
);
},
[]);
return
(
<
p
>
部分系统不兼容,导致页面崩溃。如果可以,请联系作者,反馈下具体操作和页面。大部分是 苹果 的
...
...
client/src/pages/chat/share.tsx
View file @
98a57965
...
...
@@ -90,7 +90,9 @@ const ShareChat = ({ shareId, historyId }: { shareId: string; historyId: string
const
loadAppInfo
=
useCallback
(
async
(
shareId
:
string
,
historyId
:
string
)
=>
{
if
(
!
shareId
||
!
historyId
)
return
null
;
console
.
log
(
shareId
,
historyId
);
if
(
!
shareId
)
return
null
;
const
history
=
shareChatHistory
.
find
((
item
)
=>
item
.
_id
===
historyId
)
||
defaultHistory
;
ChatBoxRef
.
current
?.
resetHistory
(
history
.
chats
);
...
...
@@ -129,9 +131,9 @@ const ShareChat = ({ shareId, historyId }: { shareId: string; historyId: string
[
delManyShareChatHistoryByShareId
,
setShareChatData
,
shareChatData
,
shareChatHistory
,
toast
]
);
use
Effect
(
()
=>
{
loadAppInfo
(
shareId
,
historyId
);
}
,
[
shareId
,
historyId
]
);
use
Query
([
'init'
,
shareId
,
historyId
],
()
=>
{
return
loadAppInfo
(
shareId
,
historyId
);
});
return
(
<
PageContainer
>
...
...
@@ -168,7 +170,6 @@ const ShareChat = ({ shareId, historyId }: { shareId: string; historyId: string
}
}
}
onDelHistory=
{
delOneShareHistoryByHistoryId
}
onCloseSlider=
{
onCloseSlider
}
/>
)
}
...
...
client/src/pages/kb/detail/components/Info.tsx
View file @
98a57965
...
...
@@ -147,6 +147,12 @@ const Info = (
<Flex p={5} flexDirection={'column'} alignItems={'center'}>
<Flex mt={5} w={'100%'} maxW={'350px'} alignItems={'center'}>
<Box flex={'0 0 90px'} w={0}>
知识库 ID
</Box>
<Box flex={1}>{kbDetail._id}</Box>
</Flex>
<Flex mt={5} w={'100%'} maxW={'350px'} alignItems={'center'}>
<Box flex={'0 0 90px'} w={0}>
知识库头像
</Box>
<Box flex={1}>
...
...
client/src/store/global.ts
View file @
98a57965
...
...
@@ -7,7 +7,8 @@ type State = {
setLoading
:
(
val
:
boolean
)
=>
null
;
screenWidth
:
number
;
setScreenWidth
:
(
val
:
number
)
=>
void
;
isPc
:
boolean
;
isPc
?:
boolean
;
initIsPc
(
val
:
boolean
):
void
;
};
export
const
useGlobalStore
=
create
<
State
>
()(
...
...
@@ -27,7 +28,14 @@ export const useGlobalStore = create<State>()(
state
.
isPc
=
val
<
900
?
false
:
true
;
});
},
isPc
:
false
isPc
:
undefined
,
initIsPc
(
val
:
boolean
)
{
if
(
get
().
isPc
!==
undefined
)
return
;
set
((
state
)
=>
{
state
.
isPc
=
val
;
});
}
}))
)
);
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