Skip to content

Commit 0271bba

Browse files
author
Kerwin
committed
fix: 页面标题无法替换
fix: 退出之后未清除本地记录
1 parent e84e7a4 commit 0271bba

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# build front-end
22
FROM node:lts-alpine AS frontend
33

4-
ARG SITE_TITLE="ChatGpt Web"
5-
64
RUN npm install pnpm -g
75

86
WORKDIR /app
@@ -15,8 +13,7 @@ RUN pnpm install
1513

1614
COPY . /app
1715

18-
RUN sed -i "s/\${TITLE}/${SITE_TITLE}/g" /app/public/index.html && \
19-
pnpm run build
16+
RUN pnpm run build
2017

2118
# build backend
2219
FROM node:lts-alpine as backend
@@ -50,10 +47,14 @@ RUN pnpm install --production && rm -rf /root/.npm /root/.pnpm-store /usr/local/
5047

5148
COPY /service /app
5249

50+
COPY --from=frontend /app/replace-title.sh /app
51+
52+
RUN chmod +x /app/replace-title.sh
53+
5354
COPY --from=frontend /app/dist /app/public
5455

5556
COPY --from=backend /app/build /app/build
5657

5758
EXPOSE 3002
5859

59-
CMD ["pnpm", "run", "prod"]
60+
CMD ["sh", "-c", "./replace-title.sh && pnpm run prod"]

replace-title.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
SITE_TITLE=${SITE_TITLE:-ChatGPT Web}
4+
5+
sed -i -E "s/<title>([^<]*)<\/title>/<title>${SITE_TITLE}<\/title>/g" /app/public/index.html

src/store/modules/auth/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { defineStore } from 'pinia'
22
import jwt_decode from 'jwt-decode'
33
import type { UserInfo } from '../user/helper'
44
import { getToken, removeToken, setToken } from './helper'
5-
import { store, useUserStore } from '@/store'
5+
import { store, useChatStore, useUserStore } from '@/store'
66
import { fetchSession } from '@/api'
77

88
interface SessionResponse {
@@ -57,6 +57,8 @@ export const useAuthStore = defineStore('auth-store', {
5757
this.token = undefined
5858
const userStore = useUserStore()
5959
userStore.resetUserInfo()
60+
const chatStore = useChatStore()
61+
chatStore.clearLocalChat()
6062
removeToken()
6163
},
6264
},

src/store/modules/chat/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,13 @@ export const useChatStore = defineStore('chat-store', {
229229
}
230230
},
231231

232+
clearLocalChat() {
233+
this.chat = []
234+
this.history = []
235+
this.active = null
236+
this.recordState()
237+
},
238+
232239
async reloadRoute(uuid?: number) {
233240
this.recordState()
234241
await router.push({ name: 'Chat', params: { uuid } })

0 commit comments

Comments
 (0)