Skip to content

Commit

Permalink
fix: 页面标题无法替换
Browse files Browse the repository at this point in the history
fix: 退出之后未清除本地记录
  • Loading branch information
Kerwin committed Mar 19, 2023
1 parent e84e7a4 commit 0271bba
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# build front-end
FROM node:lts-alpine AS frontend

ARG SITE_TITLE="ChatGpt Web"

RUN npm install pnpm -g

WORKDIR /app
Expand All @@ -15,8 +13,7 @@ RUN pnpm install

COPY . /app

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

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

COPY /service /app

COPY --from=frontend /app/replace-title.sh /app

RUN chmod +x /app/replace-title.sh

COPY --from=frontend /app/dist /app/public

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

EXPOSE 3002

CMD ["pnpm", "run", "prod"]
CMD ["sh", "-c", "./replace-title.sh && pnpm run prod"]
5 changes: 5 additions & 0 deletions replace-title.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

SITE_TITLE=${SITE_TITLE:-ChatGPT Web}

sed -i -E "s/<title>([^<]*)<\/title>/<title>${SITE_TITLE}<\/title>/g" /app/public/index.html
4 changes: 3 additions & 1 deletion src/store/modules/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineStore } from 'pinia'
import jwt_decode from 'jwt-decode'
import type { UserInfo } from '../user/helper'
import { getToken, removeToken, setToken } from './helper'
import { store, useUserStore } from '@/store'
import { store, useChatStore, useUserStore } from '@/store'
import { fetchSession } from '@/api'

interface SessionResponse {
Expand Down Expand Up @@ -57,6 +57,8 @@ export const useAuthStore = defineStore('auth-store', {
this.token = undefined
const userStore = useUserStore()
userStore.resetUserInfo()
const chatStore = useChatStore()
chatStore.clearLocalChat()
removeToken()
},
},
Expand Down
7 changes: 7 additions & 0 deletions src/store/modules/chat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@ export const useChatStore = defineStore('chat-store', {
}
},

clearLocalChat() {
this.chat = []
this.history = []
this.active = null
this.recordState()
},

async reloadRoute(uuid?: number) {
this.recordState()
await router.push({ name: 'Chat', params: { uuid } })
Expand Down

1 comment on commit 0271bba

@LuckyWang6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

大佬,chatgpt-web-2.10.7.4\vite.config.ts 中的PWA标题也可以用这种方法替换吗,我是直接改了文字

Please sign in to comment.