diff --git a/web/src/views/ChatFree.vue b/web/src/views/ChatFree.vue
index 986ab28e..efca481f 100644
--- a/web/src/views/ChatFree.vue
+++ b/web/src/views/ChatFree.vue
@@ -6,14 +6,15 @@
-
+
响应式页面布局代码
@@ -87,8 +88,6 @@
-
-
import {defineComponent, nextTick} from "vue"
-import {ChatRound, Fold, Lock, Plus, RefreshRight, VideoPause} from "@element-plus/icons-vue";
+import {ChatRound, CloseBold, Fold, Lock, Plus, RefreshRight, VideoPause} from "@element-plus/icons-vue";
import {httpGet, httpPost} from "@/utils/http";
import hl from "highlight.js";
import ChatReply from "@/components/ChatReply.vue";
import ChatPrompt from "@/components/ChatPrompt.vue";
import {getSessionId, getUserInfo, setLoginUser} from "@/utils/storage";
import {ElMessage, ElMessageBox} from "element-plus";
-import {randString} from "@/utils/libs";
+import {isMobile, randString} from "@/utils/libs";
import Clipboard from "clipboard";
-import ConfigDialog from "@/components/ConfigDialog.vue";
// 免费版 ChatGPT
export default defineComponent({
name: 'ChatFree',
- components: {ConfigDialog, Lock, VideoPause, RefreshRight, ChatPrompt, ChatReply, ChatRound, Plus, Fold},
+ components: {CloseBold, Lock, VideoPause, RefreshRight, ChatPrompt, ChatReply, ChatRound, Plus, Fold},
data() {
return {
chatData: [],
inputValue: '', // 聊天内容
- showConfigDialog: false,
userInfo: {},
showLoginDialog: false,
role: 'gpt',
@@ -177,13 +174,19 @@ export default defineComponent({
})
nextTick(() => {
- this.inputBoxWidth = document.getElementById('sidebar') ?
- window.innerWidth - document.getElementById('sidebar').offsetWidth - 20 : window.innerWidth - 20;
+ if (isMobile()) {
+ this.inputBoxWidth = window.innerWidth - 20;
+ } else {
+ this.inputBoxWidth = window.innerWidth - document.getElementById('sidebar').offsetWidth - 20;
+ }
})
window.addEventListener("resize", () => {
- this.inputBoxWidth = document.getElementById('sidebar') ?
- window.innerWidth - document.getElementById('sidebar').offsetWidth - 20 : window.innerWidth - 20;
+ if (isMobile()) {
+ this.inputBoxWidth = window.innerWidth - 20;
+ } else {
+ this.inputBoxWidth = window.innerWidth - document.getElementById('sidebar').offsetWidth - 20;
+ }
});
this.connect();
@@ -446,7 +449,12 @@ export default defineComponent({
this.showStopGenerate = true;
this.showReGenerate = false;
this.socket.send('重新生成上述问题的答案:' + this.previousText);
- }
+ },
+
+ // 显示/关闭侧边栏
+ toggleSidebar: function () {
+ document.getElementById("sidebar").classList.toggle('show');
+ },
}
})
@@ -466,6 +474,7 @@ export default defineComponent({
nav {
margin 0
padding 0
+ width 100%
ul {
list-style-type: none
@@ -487,6 +496,7 @@ export default defineComponent({
a {
display flex
text-decoration: none;
+ position relative
.icon {
font-size 16px;
@@ -510,6 +520,13 @@ export default defineComponent({
li.new-chat {
border: 1px solid #4A4B4D;
+
+ .btn {
+ display none
+ position absolute
+ right -2px;
+ top -2px;
+ }
}
}
@@ -537,6 +554,7 @@ export default defineComponent({
.el-icon {
font-size 24px;
cursor pointer
+ padding-left 10px
}
.text {
@@ -669,7 +687,23 @@ export default defineComponent({
width: 90%;
position absolute;
z-index 9999;
- display none
+ top: 0;
+ left: -350px;
+ transition: transform 0.3s ease-in-out;
+
+ nav {
+ ul {
+ li.new-chat {
+ .btn {
+ display inline
+ }
+ }
+ }
+ }
+ }
+
+ .sidebar.show {
+ transform: translateX(350px);
}
.main-content {
@@ -680,7 +714,7 @@ export default defineComponent({
}
.chat-container {
- height: calc(100vh - 50px);
+ height: calc(100vh - 40px);
.chat-box {
height: calc(100vh - 120px);