Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 4ab9f70

Browse files
authored
v2.5.1 (#75)
* perf: 新增会话添加在列表前方 * fix: 路由模式改为 hash 保证兼容性 * perf: 增强移动端体验 * chore: version 2.5.1
1 parent cb90d81 commit 4ab9f70

File tree

9 files changed

+33
-17
lines changed

9 files changed

+33
-17
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## v2.5.1
2+
3+
`2023-02-21`
4+
### Enhancement
5+
- 调整路由模式为 `hash`
6+
- 调整新增会话添加到列表最前
7+
- 调整移动端样式
8+
19
## v2.5.0
210

311
`2023-02-20`

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chatgpt-web",
3-
"version": "2.5.0",
3+
"version": "2.5.1",
44
"private": false,
55
"description": "ChatGPT Web",
66
"author": "ChenZhaoYu <[email protected]>",

src/router/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { App } from 'vue'
22
import type { RouteRecordRaw } from 'vue-router'
3-
import { createRouter, createWebHistory } from 'vue-router'
3+
import { createRouter, createWebHashHistory } from 'vue-router'
44
import { ChatLayout } from '@/views/chat/layout'
55

66
const routes: RouteRecordRaw[] = [
@@ -20,7 +20,7 @@ const routes: RouteRecordRaw[] = [
2020
]
2121

2222
export const router = createRouter({
23-
history: createWebHistory(),
23+
history: createWebHashHistory(),
2424
routes,
2525
scrollBehavior: () => ({ left: 0, top: 0 }),
2626
})

src/store/modules/chat/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export const useChatStore = defineStore('chat-store', {
1717

1818
actions: {
1919
addHistory(history: Chat.History, chatData: Chat.Chat[] = []) {
20-
this.history.push(history)
21-
this.chat.push({ uuid: history.uuid, data: chatData })
20+
this.history.unshift(history)
21+
this.chat.unshift({ uuid: history.uuid, data: chatData })
2222
this.active = history.uuid
2323
this.reloadRoute(history.uuid)
2424
},
@@ -63,9 +63,9 @@ export const useChatStore = defineStore('chat-store', {
6363
}
6464
},
6565

66-
setActive(uuid: number) {
66+
async setActive(uuid: number) {
6767
this.active = uuid
68-
this.reloadRoute(uuid)
68+
return await this.reloadRoute(uuid)
6969
},
7070

7171
addChatByUuid(uuid: number, chat: Chat.Chat) {

src/views/chat/index.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ const buttonDisabled = computed(() => {
227227
const footerClass = computed(() => {
228228
let classes = ['p-4']
229229
if (isMobile.value)
230-
classes = [...classes, 'pl-2', 'pt-2', 'pb-2', 'fixed', 'bottom-0', 'left-0', 'right-0', 'z-30']
230+
classes = ['p-2', 'pr-4', 'fixed', 'bottom-4', 'left-0', 'right-0', 'z-30', 'h-14', 'overflow-hidden']
231231
return classes
232232
})
233233
@@ -242,7 +242,7 @@ onUnmounted(() => {
242242
</script>
243243

244244
<template>
245-
<div class="flex flex-col h-full">
245+
<div class="flex flex-col h-full pt-14 pb-14">
246246
<main class="flex-1 overflow-hidden">
247247
<div ref="scrollRef" class="h-full p-4 overflow-hidden overflow-y-auto" :class="[{ 'p-2': isMobile }]">
248248
<template v-if="!dataSources.length">

src/views/chat/layout/Layout.vue

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@ const getMobileClass = computed(() => {
2626
const getContainerClass = computed(() => {
2727
return [
2828
'h-full',
29-
{ 'pt-14': isMobile.value },
3029
{ 'pl-[260px]': !isMobile.value && !collapsed.value },
3130
]
3231
})
3332
</script>
3433

3534
<template>
36-
<div class="h-screen" :class="[isMobile ? 'p-0' : 'p-4']">
35+
<div class="h-full" :class="[isMobile ? 'p-0' : 'p-4']">
3736
<div class="h-full overflow-hidden" :class="getMobileClass">
3837
<NLayout class="z-40 transition" :class="getContainerClass" has-sider>
3938
<Sider />

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function handleUpdateCollapsed() {
1818
</script>
1919

2020
<template>
21-
<header class="fixed top-0 left-0 right-0 z-50 border-b bg-white/80 backdrop-blur">
21+
<header class="fixed top-0 left-0 right-0 z-30 border-b bg-white/80 backdrop-blur">
2222
<div class="relative flex items-center justify-between h-14">
2323
<button class="flex items-center justify-center w-11 h-11" @click="handleUpdateCollapsed">
2424
<SvgIcon v-if="collapsed" class="text-2xl" icon="ri:align-justify" />

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

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
import { computed } from 'vue'
33
import { NInput, NPopconfirm, NScrollbar } from 'naive-ui'
44
import { SvgIcon } from '@/components/common'
5-
import { useChatStore } from '@/store'
5+
import { useAppStore, useChatStore } from '@/store'
6+
import { useBasicLayout } from '@/hooks/useBasicLayout'
67
8+
const { isMobile } = useBasicLayout()
9+
10+
const appStore = useAppStore()
711
const chatStore = useChatStore()
812
913
const dataSources = computed(() => chatStore.history)
@@ -12,7 +16,10 @@ async function handleSelect({ uuid }: Chat.History) {
1216
if (isActive(uuid))
1317
return
1418
15-
chatStore.setActive(uuid)
19+
await chatStore.setActive(uuid)
20+
21+
if (isMobile.value)
22+
appStore.setSiderCollapsed(true)
1623
}
1724
1825
function handleEdit({ uuid }: Chat.History, isEdit: boolean, event?: MouseEvent) {

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,16 @@ watch(
5656
:style="getMobileClass"
5757
@update-collapsed="handleUpdateCollapsed"
5858
>
59-
<div class="flex flex-col h-full" :class="[{ 'pt-14': isMobile }]">
60-
<main class="flex-1 min-h-0 overflow-hidden">
59+
<div class="flex flex-col h-full">
60+
<main class="flex flex-col flex-1 min-h-0">
6161
<div class="p-4">
6262
<NButton dashed block @click="handleAdd">
6363
New chat
6464
</NButton>
6565
</div>
66-
<List />
66+
<div class="flex-1 min-h-0 pb-4 overflow-hidden">
67+
<List />
68+
</div>
6769
</main>
6870
<footer class="flex items-center justify-between min-w-0 p-4 overflow-hidden border-t">
6971
<UserAvatar />

0 commit comments

Comments
 (0)