optimize the logic for showing chat history

This commit is contained in:
RockYang 2023-04-20 11:56:33 +08:00
parent efc1ea5d8b
commit 296d83c3a1
6 changed files with 603 additions and 597 deletions

View File

@ -86,7 +86,7 @@ func (s *Server) Run(webRoot embed.FS, path string, debug bool) {
engine.Use(AuthorizeMiddleware(s))
engine.Use(Recover)
engine.POST("test", s.TestHandle)
engine.POST("api/test", s.TestHandle)
engine.GET("api/session/get", s.GetSessionHandle)
engine.POST("api/login", s.LoginHandle)
engine.POST("api/logout", s.LogoutHandle)
@ -116,6 +116,9 @@ func (s *Server) Run(webRoot embed.FS, path string, debug bool) {
if c.Request.URL.Path == "/favicon.ico" {
c.Redirect(http.StatusMovedPermanently, "/chat/"+c.Request.URL.Path)
}
if c.Request.URL.Path == "/" {
c.Redirect(http.StatusMovedPermanently, "/chat")
}
})
// process front-end web static files

View File

@ -5,19 +5,8 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="favicon.ico">
<title>ChatGPT 助手</title>
<style>
* {
margin: 0;
padding: 0;
}
html, body {
height: 100%;
}
</style>
<link rel="icon" href="favicon.ico" type="image/x-icon">
<title>ChatGPT-Plus</title>
</head>
<body>
@ -25,7 +14,6 @@
<strong>请开启JavaScript支持</strong>
</noscript>
<div id="app"></div>
<script type="module" src="src/main.js"></script>
</body>
</html>

View File

@ -1,4 +1,4 @@
import {createRouter, createWebHistory} from 'vue-router'
import {createRouter, createWebHashHistory} from 'vue-router'
import {createApp} from 'vue'
import ElementPlus from "element-plus"
import "element-plus/dist/index.css"
@ -45,7 +45,7 @@ const routes = [
]
const router = createRouter({
history: createWebHistory(),
history: createWebHashHistory(),
routes: routes,
})

View File

@ -679,8 +679,16 @@ export default defineComponent({
.tip-text {
text-align left
padding 10px 20px;
line-height 1.5
padding 0 20px 10px 20px;
.el-alert {
padding 5px;
.el-alert__description {
font-size 14px;
}
}
}
}

View File

@ -126,6 +126,7 @@
v-model="showLoginDialog"
:show-close="false"
:close-on-click-modal="false"
top="5vh"
title="请输入口令继续访问"
>
<el-row>
@ -140,11 +141,15 @@
</el-row>
<div class="tip-text">
打开微信扫下面二维码免费领取口令, <strong>强烈建议你使用 PC 浏览器访问获得更好的聊天体验</strong>
<p>扫码加入群聊在群公告获取免费体验账号</p>
<el-alert type="warning" :closable="false">
<strong>特别声明</strong> 我们充分尊重用户隐私因此所有用户的聊天记录均只保存在本地设备所以请尽量用同一设备访问以便能查阅所有的聊天记录
</el-alert>
</div>
<el-row class="row-center">
<el-image src="images/wx.png" fit="cover"/>
<el-image src="https://img.r9it.com/chatgpt/wechat-group.jpeg" fit="cover"/>
</el-row>
</el-dialog>
@ -300,6 +305,11 @@ export default defineComponent({
reader.readAsText(event.data, "UTF-8");
reader.onload = () => {
const data = JSON.parse(String(reader.result));
//
if (data['is_hello_msg'] && this.chatData.length > 1) {
return
}
if (data.type === 'start') {
this.chatData.push({
type: "reply",

View File

@ -16,10 +16,7 @@ module.exports = defineConfig({
]
},
publicPath: process.env.NODE_ENV === 'production'
? '/chat'
: '/',
publicPath: process.env.NODE_ENV === 'production' ? '/chat' : '/',
outputDir: '../dist',
crossorigin: "anonymous",
devServer: {