Skip to content

Commit c78d2f1

Browse files
author
Kerwin
committed
Merge remote-tracking branch 'github/main'
# Conflicts: # src/views/chat/layout/sider/List.vue
2 parents 3c566ae + 76cef65 commit c78d2f1

File tree

10 files changed

+45
-11
lines changed

10 files changed

+45
-11
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ node_modules
44
Dockerfile
55
.*
66
*/.*
7+
!.env

README.en.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ Q: Why doesn't the frontend have a typewriter effect?
358358

359359
A: One possible reason is that after Nginx reverse proxying, buffering is turned on, and Nginx will try to buffer a certain amount of data from the backend before sending it to the browser. Please try adding `proxy_buffering off;` after the reverse proxy parameter and then reloading Nginx. Other web server configurations are similar.
360360

361+
Q: The content returned is incomplete?
362+
363+
A: There is a length limit for the content returned by the API each time. You can modify the `VITE_GLOB_OPEN_LONG_REPLY` field in the `.env` file under the root directory, set it to `true`, and rebuild the front-end to enable the long reply feature, which can return the full content. It should be noted that using this feature may bring more API usage fees.
364+
361365
## Contributing
362366

363367
Please read the [Contributing Guidelines](./CONTRIBUTING.en.md) before contributing.

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
1. 你应该首先使用 `API` 方式
6464
2. 使用 `API` 时,如果网络不通,那是国内被墙了,你需要自建代理,绝对不要使用别人的公开代理,那是危险的。
6565
3. 使用 `accessToken` 方式时反向代理将向第三方暴露您的访问令牌,这样做应该不会产生任何不良影响,但在使用这种方法之前请考虑风险。
66-
4. 使用 `accessToken` 时,不管你是国内还是国外的机器,都会使用代理。默认代理为 [acheong08](https://github.com/acheong08) 大佬的 `https://bypass.duti.tech/api/conversation`,这不是后门也不是监听,除非你有能力自己翻过 `CF` 验证,用前请知悉。[社区代理](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy)(注意:只有这两个是推荐,其他第三方来源,请自行甄别)
66+
4. 使用 `accessToken` 时,不管你是国内还是国外的机器,都会使用代理。默认代理为 [acheong08](https://github.com/acheong08) 大佬的 `https://bypass.churchless.tech/api/conversation`,这不是后门也不是监听,除非你有能力自己翻过 `CF` 验证,用前请知悉。[社区代理](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy)(注意:只有这两个是推荐,其他第三方来源,请自行甄别)
6767
5. 把项目发布到公共网络时,你应该设置 `AUTH_SECRET_KEY` 变量添加你的密码访问权限,你也应该修改 `index.html` 中的 `title`,防止被关键词搜索到。
6868

6969
切换方式:
@@ -174,7 +174,7 @@ pnpm dev
174174
`ACCESS_TOKEN` 可用:
175175

176176
- `OPENAI_ACCESS_TOKEN``OPENAI_API_KEY` 二选一,同时存在时,`OPENAI_API_KEY` 优先
177-
- `API_REVERSE_PROXY` 设置反向代理,可选,默认:`https://bypass.duti.tech/api/conversation`[社区](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy)(注意:只有这两个是推荐,其他第三方来源,请自行甄别)
177+
- `API_REVERSE_PROXY` 设置反向代理,可选,默认:`https://bypass.churchless.tech/api/conversation`[社区](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy)(注意:只有这两个是推荐,其他第三方来源,请自行甄别)
178178

179179
通用:
180180

@@ -233,7 +233,8 @@ services:
233233
OPENAI_ACCESS_TOKEN: xxx
234234
# API接口地址,可选,设置 OPENAI_API_KEY 时可用
235235
OPENAI_API_BASE_URL: xxx
236-
# API模型,可选,设置 OPENAI_API_KEY 时可用
236+
# API模型,可选,设置 OPENAI_API_KEY 时可用,https://platform.openai.com/docs/models
237+
# gpt-4, gpt-4-0314, gpt-4-32k, gpt-4-32k-0314, gpt-3.5-turbo, gpt-3.5-turbo-0301, text-davinci-003, text-davinci-002, code-davinci-002
237238
OPENAI_API_MODEL: xxx
238239
# 反向代理,可选
239240
API_REVERSE_PROXY: xxx

src/components/common/PromptStore/index.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const clearPromptTemplate = () => {
147147
message.success(t('common.clearSuccess'))
148148
}
149149
150-
const importPromptTemplate = () => {
150+
const importPromptTemplate = (from = 'online') => {
151151
try {
152152
const jsonData = JSON.parse(tempPromptValue.value)
153153
let key = ''
@@ -168,7 +168,7 @@ const importPromptTemplate = () => {
168168
}
169169
170170
for (const i of jsonData) {
171-
if (!('key' in i) || !('value' in i))
171+
if (!(key in i) || !(value in i))
172172
throw new Error(t('store.importError'))
173173
let safe = true
174174
for (const j of promptList.value) {
@@ -191,6 +191,8 @@ const importPromptTemplate = () => {
191191
catch {
192192
message.error('JSON 格式错误,请检查 JSON 格式')
193193
}
194+
if (from === 'local')
195+
showModal.value = !showModal.value
194196
}
195197
196198
// 模板导出
@@ -469,7 +471,7 @@ const dataSource = computed(() => {
469471
block
470472
type="primary"
471473
:disabled="inputStatus"
472-
@click="() => { importPromptTemplate() }"
474+
@click="() => { importPromptTemplate('local') }"
473475
>
474476
{{ t('common.import') }}
475477
</NButton>

src/locales/en-US.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default {
3535
passwordConfirm: 'Confirm Password',
3636
},
3737
chat: {
38+
newChatButton: 'New Chat',
3839
placeholder: 'Ask me anything...(Shift + Enter = line break)',
3940
placeholderMobile: 'Ask me anything...',
4041
copy: 'Copy',
@@ -94,6 +95,7 @@ export default {
9495
loginSaltTip: 'Changes will invalidate all logged in',
9596
},
9697
store: {
98+
siderButton: 'Prompt Store',
9799
local: 'Local',
98100
online: 'Online',
99101
title: 'Title',

src/locales/zh-CN.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default {
3535
passwordConfirm: '确认密码',
3636
},
3737
chat: {
38+
newChatButton: '新建聊天',
3839
placeholder: '来说点什么吧...(Shift + Enter = 换行)',
3940
placeholderMobile: '来说点什么...',
4041
copy: '复制',
@@ -94,6 +95,7 @@ export default {
9495
loginSaltTip: '变更会导致所有已登录失效',
9596
},
9697
store: {
98+
siderButton: '提示词商店',
9799
local: '本地',
98100
online: '在线',
99101
title: '标题',

src/locales/zh-TW.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default {
3535
passwordConfirm: '確認密碼',
3636
},
3737
chat: {
38+
newChatButton: '新建對話',
3839
placeholder: '來說點什麼...(Shift + Enter = 換行)',
3940
placeholderMobile: '來說點什麼...',
4041
copy: '複製',
@@ -94,6 +95,7 @@ export default {
9495
loginSaltTip: '变更会导致所有已登录失效',
9596
},
9697
store: {
98+
siderButton: '提示詞商店',
9799
local: '本機',
98100
online: '線上',
99101
title: '標題',

src/utils/functions/debounce.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
type CallbackFunc<T extends unknown[]> = (...args: T) => void
2+
3+
export function debounce<T extends unknown[]>(
4+
func: CallbackFunc<T>,
5+
wait: number,
6+
): (...args: T) => void {
7+
let timeoutId: ReturnType<typeof setTimeout> | undefined
8+
9+
return (...args: T) => {
10+
const later = () => {
11+
clearTimeout(timeoutId)
12+
func(...args)
13+
}
14+
15+
clearTimeout(timeoutId)
16+
timeoutId = setTimeout(later, wait)
17+
}
18+
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { SvgIcon } from '@/components/common'
55
import { useAppStore, useChatStore } from '@/store'
66
import { useBasicLayout } from '@/hooks/useBasicLayout'
77
import { useAuthStoreWithout } from '@/store/modules/auth'
8+
import { debounce } from '@/utils/functions/debounce'
89
910
const { isMobile } = useBasicLayout()
1011
@@ -59,6 +60,8 @@ function handleDelete(index: number, event?: MouseEvent | TouchEvent) {
5960
appStore.setSiderCollapsed(true)
6061
}
6162
63+
const handleDeleteDebounce = debounce(handleDelete, 600)
64+
6265
function handleEnter({ uuid }: Chat.History, isEdit: boolean, event: KeyboardEvent) {
6366
event?.stopPropagation()
6467
if (event.key === 'Enter')
@@ -92,8 +95,7 @@ function isActive(uuid: number) {
9295
<div class="relative flex-1 overflow-hidden break-all text-ellipsis whitespace-nowrap">
9396
<NInput
9497
v-if="item.isEdit"
95-
v-model:value="item.title"
96-
size="tiny"
98+
v-model:value="item.title" size="tiny"
9799
@keypress="handleEnter(item, false, $event)"
98100
/>
99101
<span v-else>{{ item.title }}</span>
@@ -108,7 +110,7 @@ function isActive(uuid: number) {
108110
<button class="p-1">
109111
<SvgIcon icon="ri:edit-line" @click="handleEdit(item, true, $event)" />
110112
</button>
111-
<NPopconfirm placement="bottom" @positive-click="handleDelete(index, $event)">
113+
<NPopconfirm placement="bottom" @positive-click="handleDeleteDebounce(index, $event)">
112114
<template #trigger>
113115
<button class="p-1">
114116
<SvgIcon icon="ri:delete-bin-line" />

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ watch(
7373
<main class="flex flex-col flex-1 min-h-0">
7474
<div class="p-4">
7575
<NButton dashed block @click="handleAdd">
76-
New chat
76+
{{ $t('chat.newChatButton') }}
7777
</NButton>
7878
</div>
7979
<div class="flex-1 min-h-0 pb-4 overflow-hidden">
8080
<List />
8181
</div>
8282
<div class="p-4">
8383
<NButton block @click="show = true">
84-
Prompt Store
84+
{{ $t('store.siderButton') }}
8585
</NButton>
8686
</div>
8787
</main>

0 commit comments

Comments
 (0)