Skip to content

Commit 9bf9edf

Browse files
author
Kerwin
committed
fix: cannot chat without logging in (Closes #31)
1 parent f4910f3 commit 9bf9edf

File tree

6 files changed

+10
-6
lines changed

6 files changed

+10
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chatgpt-web",
3-
"version": "2.12.3",
3+
"version": "2.12.4",
44
"private": false,
55
"description": "ChatGPT Web",
66
"author": "ChenZhaoYu <chenzhaoyu1994@gmail.com>",

service/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ router.post('/session', async (req, res) => {
457457
const config = await getCacheConfig()
458458
const hasAuth = config.siteConfig.loginEnabled
459459
const allowRegister = (await getCacheConfig()).siteConfig.registerEnabled
460-
res.send({ status: 'Success', message: '', data: { auth: hasAuth, allowRegister, model: currentModel() } })
460+
res.send({ status: 'Success', message: '', data: { auth: hasAuth, allowRegister, model: currentModel(), title: config.siteConfig.siteTitle } })
461461
}
462462
catch (error) {
463463
res.send({ status: 'Fail', message: error.message, data: null })

src/components/common/UserAvatar/index.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ const userInfo = computed(() => userStore.userInfo)
4040
v-else tag="a" text
4141
@click="showPermission = true"
4242
>
43-
<span class="text-xl text-[#ff69b4] dark:text-white">
43+
<span v-if="!!authStore.session?.auth && !authStore.token" class="text-xl text-[#ff69b4] dark:text-white">
4444
{{ $t('common.notLoggedIn') }}
4545
</span>
46+
<span v-else class="text-xl text-[#ff69b4] dark:text-white">
47+
{{ authStore .session?.title }}
48+
</span>
4649
</NButton>
4750
</div>
4851
<Permission :visible="needPermission" />

src/store/modules/auth/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ interface SessionResponse {
99
auth: boolean
1010
model: 'ChatGPTAPI' | 'ChatGPTUnofficialProxyAPI'
1111
allowRegister: boolean
12+
title: string
1213
}
1314

1415
export interface AuthState {

src/views/chat/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ function handleStop() {
450450
451451
async function loadMoreMessage(event: any) {
452452
const chatIndex = chatStore.chat.findIndex(d => d.uuid === +uuid)
453-
if (chatIndex <= -1)
453+
if (chatIndex <= -1 || chatStore.chat[chatIndex].data.length <= 0)
454454
return
455455
456456
const scrollPosition = event.target.scrollHeight - event.target.scrollTop
@@ -623,7 +623,7 @@ onUnmounted(() => {
623623
<NInput
624624
ref="inputRef"
625625
v-model:value="prompt"
626-
:disabled="authStore.token === undefined"
626+
:disabled="!!authStore.session?.auth && !authStore.token"
627627
type="textarea"
628628
:placeholder="placeholder"
629629
:autosize="{ minRows: 1, maxRows: isMobile ? 4 : 8 }"

src/views/chat/layout/sider/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ watch(
7373
<div class="flex flex-col h-full" :style="mobileSafeArea">
7474
<main class="flex flex-col flex-1 min-h-0">
7575
<div class="p-4">
76-
<NButton dashed block :disabled="authStore.token === undefined" @click="handleAdd">
76+
<NButton dashed block :disabled="!!authStore.session?.auth && !authStore.token" @click="handleAdd">
7777
{{ $t('chat.newChatButton') }}
7878
</NButton>
7979
</div>

0 commit comments

Comments
 (0)