Skip to content

Commit e8b7de9

Browse files
author
Kerwin
committed
Merge remote-tracking branch 'github/main'
# Conflicts: # README.en.md # README.md # package.json
2 parents 3449032 + fb8ad37 commit e8b7de9

File tree

18 files changed

+83
-35
lines changed

18 files changed

+83
-35
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Glob API URL
22
VITE_GLOB_API_URL=/api
33

4-
VITE_APP_API_BASE_URL=http://localhost:3002/
4+
VITE_APP_API_BASE_URL=http://127.0.0.1:3002/
55

66
# Whether long replies are supported, which may result in higher API fees
77
VITE_GLOB_OPEN_LONG_REPLY=false

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1+
## v2.10.8
2+
3+
`2023-03-23`
4+
5+
如遇问题,请删除 `node_modules` 重新安装依赖。
6+
7+
## Feature
8+
- 显示回复消息原文的选项 [[yilozt](https://github.com/Chanzhaoyu/chatgpt-web/pull/672)]
9+
- 添加单 `IP` 每小时请求限制。环境变量: `MAX_REQUEST_PER_HOUR` [[zhuxindong ](https://github.com/Chanzhaoyu/chatgpt-web/pull/718)]
10+
- 前端添加角色设定,仅 `API` 方式可见 [[quzard](https://github.com/Chanzhaoyu/chatgpt-web/pull/768)]
11+
- `OPENAI_API_MODEL` 变量现在对 `ChatGPTUnofficialProxyAPI` 也生效,注意:`Token``API` 的模型命名不一致,不能直接填入 `gpt-3.5` 或者 `gpt-4` [[hncboy](https://github.com/Chanzhaoyu/chatgpt-web/pull/632)]
12+
- 添加繁体中文 `Prompts` [[PeterDaveHello](https://github.com/Chanzhaoyu/chatgpt-web/pull/796)]
13+
14+
## Enhancement
15+
- 重置回答时滚动定位至该回答 [[shunyue1320](https://github.com/Chanzhaoyu/chatgpt-web/pull/781)]
16+
-`API``gpt-4` 时增加可用的 `Max Tokens` [[simonwu53](https://github.com/Chanzhaoyu/chatgpt-web/pull/729)]
17+
- 判断和忽略回复字符 [[liut](https://github.com/Chanzhaoyu/chatgpt-web/pull/474)]
18+
- 切换会话时,自动聚焦输入框 [[JS-an](https://github.com/Chanzhaoyu/chatgpt-web/pull/735)]
19+
- 渲染的链接新窗口打开
20+
- 查询余额可选 `API_BASE_URL` 代理地址
21+
- `config` 接口添加验证防止被无限制调用
22+
- `PWA` 默认不开启,现在需手动修改 `.env` 文件 `VITE_GLOB_APP_PWA` 变量
23+
- 当网络连接时,刷新页面,`500` 错误页自动跳转到主页
24+
25+
## BugFix
26+
- `scrollToBottom` 调回 `scrollToBottomIfAtBottom` [[shunyue1320](https://github.com/Chanzhaoyu/chatgpt-web/pull/771)]
27+
- 重置异常的 `loading` 会话
28+
29+
## Common
30+
- 创建 `start.cmd``windows` 下也可以运行 [vulgatecnn](https://github.com/Chanzhaoyu/chatgpt-web/pull/656)]
31+
- 添加 `visual-studio-code` 中调试配置 [[ChandlerVer5](https://github.com/Chanzhaoyu/chatgpt-web/pull/296)]
32+
- 修复文档中 `docker` 端口为本地 [[kilvn](https://github.com/Chanzhaoyu/chatgpt-web/pull/802)]
33+
## Other
34+
- 依赖更新
35+
36+
137
## v2.10.7
238

339
`2023-03-17`

README.en.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ pnpm dev
194194
docker build -t chatgpt-web .
195195

196196
# foreground operation
197-
docker run --name chatgpt-web --rm -it -p 3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
197+
docker run --name chatgpt-web --rm -it -p 127.0.0.1:3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
198198

199199
# background operation
200-
docker run --name chatgpt-web -d -p 3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
200+
docker run --name chatgpt-web -d -p 127.0.0.1:3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
201201

202202
# running address
203203
http://localhost:3002/

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,10 @@ pnpm dev
200200
docker build -t chatgpt-web .
201201

202202
# 前台运行
203-
docker run --name chatgpt-web --rm -it -p 3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
203+
docker run --name chatgpt-web --rm -it -p 127.0.0.1:3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
204204

205205
# 后台运行
206-
docker run --name chatgpt-web -d -p 3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
206+
docker run --name chatgpt-web -d -p 127.0.0.1:3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
207207

208208
# 运行地址
209209
http://localhost:3002/

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.11.0",
3+
"version": "2.11.1",
44
"private": false,
55
"description": "ChatGPT Web",
66
"author": "ChenZhaoYu <chenzhaoyu1994@gmail.com>",

service/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"scripts": {
1717
"start": "esno ./src/index.ts",
1818
"dev": "esno watch ./src/index.ts",
19-
"prod": "esno ./build/index.js",
19+
"prod": "node ./build/index.mjs",
2020
"build": "pnpm clean && tsup",
2121
"clean": "rimraf build",
2222
"lint": "eslint .",

service/src/chatgpt/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'isomorphic-fetch'
33
import type { ChatGPTAPIOptions, ChatMessage, SendMessageOptions } from 'chatgpt'
44
import { ChatGPTAPI, ChatGPTUnofficialProxyAPI } from 'chatgpt'
55
import { SocksProxyAgent } from 'socks-proxy-agent'
6-
import { HttpsProxyAgent } from 'https-proxy-agent'
6+
import httpsProxyAgent from 'https-proxy-agent'
77
import fetch from 'node-fetch'
88
import axios from 'axios'
99
import { getCacheConfig, getOriginConfig } from '../storage/config'
@@ -12,6 +12,8 @@ import { isNotEmptyString } from '../utils/is'
1212
import type { ApiModel, ChatContext, ChatGPTUnofficialProxyAPIOptions, ModelConfig } from '../types'
1313
import type { RequestOptions } from './types'
1414

15+
const { HttpsProxyAgent } = httpsProxyAgent
16+
1517
dotenv.config()
1618

1719
const ErrorCodeMessage: Record<string, string> = {

service/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,5 +380,6 @@ router.post('/setting-mail', auth, async (req, res) => {
380380

381381
app.use('', router)
382382
app.use('/api', router)
383+
app.set('trust proxy', 1)
383384

384385
app.listen(3002, () => globalThis.console.log('Server is running on port 3002'))

service/tsup.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default defineConfig({
44
entry: ['src/index.ts'],
55
outDir: 'build',
66
target: 'es2020',
7-
format: ['cjs'],
7+
format: ['esm'],
88
splitting: false,
99
sourcemap: true,
1010
minify: false,

src/assets/recommend.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[
2-
{
3-
"key": "chatgpt-prompt-collection",
4-
"desc": "Nothing1024收集整理的prompts",
5-
"downloadUrl": "https://raw.githubusercontent.com/Nothing1024/chatgpt-prompt-collection/main/awesome-chatgpt-prompts-zh.json",
6-
"url": "https://github.com/Nothing1024/chatgpt-prompt-collection"
7-
},
82
{
93
"key": "awesome-chatgpt-prompts-zh",
104
"desc": "ChatGPT 中文调教指南",
115
"downloadUrl": "https://raw.githubusercontent.com/PlexPt/awesome-chatgpt-prompts-zh/main/prompts-zh.json",
126
"url": "https://github.com/PlexPt/awesome-chatgpt-prompts-zh"
7+
},
8+
{
9+
"key": "awesome-chatgpt-prompts-zh-TW",
10+
"desc": "ChatGPT 中文調教指南 (透過 OpenAI / OpenCC 協助,從簡體中文轉換為繁體中文的版本)",
11+
"downloadUrl": "https://raw.githubusercontent.com/PlexPt/awesome-chatgpt-prompts-zh/main/prompts-zh-TW.json",
12+
"url": "https://github.com/PlexPt/awesome-chatgpt-prompts-zh"
1313
}
1414
]

src/components/common/PromptStore/index.vue

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang='ts'>
22
import type { DataTableColumns } from 'naive-ui'
33
import { computed, h, ref, watch } from 'vue'
4-
import { NButton, NCard, NDataTable, NDivider, NInput, NLayoutContent, NList, NListItem, NModal, NPopconfirm, NSpace, NTabPane, NTabs, NThing, useMessage } from 'naive-ui'
4+
import { NButton, NCard, NDataTable, NDivider, NInput, NList, NListItem, NModal, NPopconfirm, NSpace, NTabPane, NTabs, NThing, useMessage } from 'naive-ui'
55
import PromptRecommend from '../../../assets/recommend.json'
66
import { SvgIcon } from '..'
77
import { usePromptStore } from '@/store'
@@ -408,17 +408,12 @@ const dataSource = computed(() => {
408408
</NButton>
409409
</div>
410410
<NDivider />
411-
<NLayoutContent
412-
style="height: 360px"
413-
content-style="background: none;"
414-
:native-scrollbar="false"
415-
>
411+
<div class="max-h-[360px] overflow-y-auto space-y-4">
416412
<NCard
417413
v-for="info in promptRecommendList"
418414
:key="info.key" :title="info.key"
419-
style="margin: 5px;"
420-
embedded
421415
:bordered="true"
416+
embedded
422417
>
423418
<p
424419
class="overflow-hidden text-ellipsis whitespace-nowrap"
@@ -442,7 +437,7 @@ const dataSource = computed(() => {
442437
</div>
443438
</template>
444439
</NCard>
445-
</NLayoutContent>
440+
</div>
446441
</NTabPane>
447442
</NTabs>
448443
</div>

src/store/modules/settings/helper.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ export function getLocalState(): SettingsState {
2121
export function setLocalState(setting: SettingsState): void {
2222
ss.set(LOCAL_NAME, setting)
2323
}
24+
25+
export function removeLocalState() {
26+
ss.remove(LOCAL_NAME)
27+
}

src/store/modules/settings/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineStore } from 'pinia'
22
import type { SettingsState } from './helper'
3-
import { defaultSetting, getLocalState, setLocalState } from './helper'
3+
import { defaultSetting, getLocalState, removeLocalState, setLocalState } from './helper'
44

55
export const useSettingStore = defineStore('setting-store', {
66
state: (): SettingsState => getLocalState(),
@@ -12,7 +12,7 @@ export const useSettingStore = defineStore('setting-store', {
1212

1313
resetSetting() {
1414
this.$state = defaultSetting()
15-
this.recordState()
15+
removeLocalState()
1616
},
1717

1818
recordState() {

src/views/chat/components/Message/index.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { SvgIcon } from '@/components/common'
77
import { copyText } from '@/utils/format'
88
import { useIconRender } from '@/hooks/useIconRender'
99
import { t } from '@/locales'
10+
import { useBasicLayout } from '@/hooks/useBasicLayout'
1011
1112
interface Props {
1213
dateTime?: string
@@ -25,6 +26,8 @@ const props = defineProps<Props>()
2526
2627
const emit = defineEmits<Emit>()
2728
29+
const { isMobile } = useBasicLayout()
30+
2831
const { iconRender } = useIconRender()
2932
3033
const textRef = ref<HTMLElement>()
@@ -113,7 +116,12 @@ function handleRegenerate() {
113116
>
114117
<SvgIcon icon="ri:restart-line" />
115118
</button>
116-
<NDropdown :placement="!inversion ? 'right' : 'left'" :options="options" @select="handleSelect">
119+
<NDropdown
120+
:trigger="isMobile ? 'click' : 'hover'"
121+
:placement="!inversion ? 'right' : 'left'"
122+
:options="options"
123+
@select="handleSelect"
124+
>
117125
<button class="transition text-neutral-300 hover:text-neutral-800 dark:hover:text-neutral-200">
118126
<SvgIcon icon="ri:more-2-fill" />
119127
</button>

src/views/chat/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ const footerClass = computed(() => {
462462
463463
onMounted(() => {
464464
scrollToBottom()
465-
if (inputRef.value)
465+
if (inputRef.value && !isMobile.value)
466466
inputRef.value?.focus()
467467
})
468468

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ function handleEdit({ uuid }: Chat.History, isEdit: boolean, event?: MouseEvent)
5050
function handleDelete(index: number, event?: MouseEvent | TouchEvent) {
5151
event?.stopPropagation()
5252
chatStore.deleteHistory(index)
53+
if (isMobile.value)
54+
appStore.setSiderCollapsed(true)
5355
}
5456
5557
function handleEnter({ uuid }: Chat.History, isEdit: boolean, event: KeyboardEvent) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const collapsed = computed(() => appStore.siderCollapsed)
1818
1919
function handleAdd() {
2020
chatStore.addHistory({ title: 'New Chat', uuid: Date.now(), isEdit: false })
21+
if (isMobile.value)
22+
appStore.setSiderCollapsed(true)
2123
}
2224
2325
function handleUpdateCollapsed() {

vite.config.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import vue from '@vitejs/plugin-vue'
55
import { VitePWA } from 'vite-plugin-pwa'
66

77
function setupPlugins(env: ImportMetaEnv): PluginOption[] {
8-
const plugins = [vue()]
9-
10-
if (env.VITE_GLOB_APP_PWA === 'true') {
11-
VitePWA({
8+
return [
9+
vue(),
10+
env.VITE_GLOB_APP_PWA === 'true' && VitePWA({
1211
injectRegister: 'auto',
1312
manifest: {
1413
name: 'chatGPT',
@@ -18,9 +17,8 @@ function setupPlugins(env: ImportMetaEnv): PluginOption[] {
1817
{ src: 'pwa-512x512.png', sizes: '512x512', type: 'image/png' },
1918
],
2019
},
21-
})
22-
}
23-
return plugins
20+
}),
21+
]
2422
}
2523

2624
export default defineConfig((env) => {

0 commit comments

Comments
 (0)