Skip to content

Commit

Permalink
尝试 isAuthorized 为假时,导航到认证页面
Browse files Browse the repository at this point in the history
  • Loading branch information
gqye committed Jul 22, 2024
1 parent 6381675 commit f0d488f
Showing 1 changed file with 29 additions and 30 deletions.
59 changes: 29 additions & 30 deletions app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -591,11 +591,10 @@ export function ChatActions(props: {
<Selector
defaultSelectedValue={`${currentModel}@${currentProviderName}`}
items={models.map((m) => ({
title: `${m.displayName}${
m?.provider?.providerName
? "(" + m?.provider?.providerName + ")"
: ""
}`,
title: `${m.displayName}${m?.provider?.providerName
? "(" + m?.provider?.providerName + ")"
: ""
}`,
value: `${m.name}@${m?.provider?.providerName}`,
}))}
onClose={() => setShowModelSelector(false)}
Expand Down Expand Up @@ -711,9 +710,9 @@ function _Chat() {
const scrollRef = useRef<HTMLDivElement>(null);
const isScrolledToBottom = scrollRef?.current
? Math.abs(
scrollRef.current.scrollHeight -
(scrollRef.current.scrollTop + scrollRef.current.clientHeight),
) <= 1
scrollRef.current.scrollHeight -
(scrollRef.current.scrollTop + scrollRef.current.clientHeight),
) <= 1
: false;
const { setAutoScroll, scrollDomToBottom } = useScrollToBottom(
scrollRef,
Expand Down Expand Up @@ -983,6 +982,7 @@ function _Chat() {
const copiedHello = Object.assign({}, BOT_HELLO);
if (!accessStore.isAuthorized()) {
copiedHello.content = Locale.Error.Unauthorized;
navigate(Path.Auth)
}
context.push(copiedHello);
}
Expand All @@ -994,27 +994,27 @@ function _Chat() {
.concat(
isLoading
? [
{
...createMessage({
role: "assistant",
content: "……",
}),
preview: true,
},
]
{
...createMessage({
role: "assistant",
content: "……",
}),
preview: true,
},
]
: [],
)
.concat(
userInput.length > 0 && config.sendPreviewBubble
? [
{
...createMessage({
role: "user",
content: userInput,
}),
preview: true,
},
]
{
...createMessage({
role: "user",
content: userInput,
}),
preview: true,
},
]
: [],
);
}, [
Expand Down Expand Up @@ -1109,7 +1109,7 @@ function _Chat() {
if (payload.key || payload.url) {
showConfirm(
Locale.URLCommand.Settings +
`\n${JSON.stringify(payload, null, 4)}`,
`\n${JSON.stringify(payload, null, 4)}`,
).then((res) => {
if (!res) return;
if (payload.key) {
Expand Down Expand Up @@ -1523,11 +1523,10 @@ function _Chat() {
}}
/>
<label
className={`${styles["chat-input-panel-inner"]} ${
attachImages.length != 0
? styles["chat-input-panel-inner-attach"]
: ""
}`}
className={`${styles["chat-input-panel-inner"]} ${attachImages.length != 0
? styles["chat-input-panel-inner-attach"]
: ""
}`}
htmlFor="chat-input"
>
<textarea
Expand Down

0 comments on commit f0d488f

Please sign in to comment.