Browse Source

feat:解决页面刷新或关闭时移动端浏览器不触发保存聊天记录问题

master
dashan 2 years ago
parent
commit
6904546b7d
  1. 22
      README.md
  2. 2
      src/layouts/MainLayout.vue

22
README.md

@ -2,27 +2,27 @@
chatbot web chatbot web
## Install the dependencies ## 效果展示
### PC端效果展示
![](https://raw.githubusercontent.com/DaiShuaishuai/pic/main/picgo/pc1.jpg)
![](https://raw.githubusercontent.com/DaiShuaishuai/pic/main/picgo/pc2.jpg)
### 移动端效果展示
![](https://raw.githubusercontent.com/DaiShuaishuai/pic/main/picgo/yd1.jpg)
![](https://raw.githubusercontent.com/DaiShuaishuai/pic/main/picgo/yd2.jpg)
## 下载依赖
```bash ```bash
yarn yarn
# or # or
npm install npm install
``` ```
### Start the app in development mode (hot-code reloading, error reporting, etc.) ### 启动项目
```bash ```bash
quasar dev quasar dev
``` ```
### 打包
### Lint the files
```bash
yarn lint
# or
npm run lint
```
### Build the app for production
```bash ```bash
quasar build quasar build
``` ```

2
src/layouts/MainLayout.vue

@ -86,7 +86,7 @@ export default {
this.messages=JSON.parse(records) this.messages=JSON.parse(records)
localStorage.removeItem(bot_message_records) localStorage.removeItem(bot_message_records)
} }
window.addEventListener("beforeunload",()=>{ window.addEventListener("pagehide",()=>{
localStorage.setItem(bot_message_records,JSON.stringify(this.messages)) localStorage.setItem(bot_message_records,JSON.stringify(this.messages))
}) })
}, },

Loading…
Cancel
Save