-
Notifications
You must be signed in to change notification settings - Fork 67
/
App.vue
161 lines (150 loc) · 3.57 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<template>
<el-config-provider namespace="ep">
<el-container
style="min-height: 100vh; min-width: 100%"
v-show="!chatDocument"
>
<BaseSide
v-show="showSide"
:style="{ width: isMobile ? '100vw' : '300px' }"
/>
<div
:style="{ width: getMainWidth() }"
v-show="!isMobile || (isMobile && !showSide)"
>
<BaseHeader />
<el-main>
<!-- <HelloWorld msg="Hello Vue 3.0 + Element Plus + Vite" /> -->
<chat :conversationId="activeConversationId" />
</el-main>
</div>
</el-container>
<el-container
style="min-height: 100vh; min-width: 100%"
v-show="chatDocument"
>
<DocSide
v-show="showSide"
:style="{ width: isMobile ? '100vw' : '70%' }"
style="overflow-y: hidden; height: 100vh"
/>
<div
:style="{ width: getDocMainWidth() }"
v-show="!isMobile || (isMobile && !showSide)"
>
<DocHeader />
<el-main>
<!-- <HelloWorld msg="Hello Vue 3.0 + Element Plus + Vite" /> -->
<DocChat />
</el-main>
</div>
</el-container>
<Loading />
</el-config-provider>
</template>
<script lang="ts" setup>
import { ref, watch } from "vue";
import Chat from "~/components/Chat.vue";
import { useChatStore } from "~/store/chat";
import { useAppStore } from "~/store/app";
import { storeToRefs } from "pinia";
import { useDark, useToggle } from "@vueuse/core";
import { el } from "element-plus/es/locale";
const isDark = useDark();
let chatStore = useChatStore();
let appStore = useAppStore();
const { showSide, isMobile, chatDocument } = storeToRefs(appStore);
const { conversationList, messageList, activeConversationId } =
storeToRefs(chatStore);
const mdcolor = ref("balck");
watch(
() => isDark,
(value, oldValue) => {
if (value) {
mdcolor.value = "white";
} else {
mdcolor.value = "black";
}
},
{ immediate: true }
);
const getDocMainWidth = () => {
if (showSide.value) {
if (isMobile.value) {
return "0px";
} else {
return "30%";
}
} else {
if (isMobile.value) {
return "100vw";
} else {
return "100vw";
}
}
};
const getMainWidth = () => {
if (showSide.value) {
if (isMobile.value) {
return "0px";
} else {
return "calc(100% - 300px)";
}
} else {
if (isMobile.value) {
return "100vw";
} else {
return "100vw";
}
}
};
//部分store持久化
let l1 = localStorage.getItem("chatStore_001");
if (l1) {
chatStore.$patch(JSON.parse(l1));
}
//默认发送状态为空
chatStore.isSending = false;
chatStore.$subscribe((_, state) => {
localStorage.setItem("chatStore_001", JSON.stringify(state));
});
let l2 = localStorage.getItem("appStore_001");
if (l2) {
appStore.$patch(JSON.parse(l2));
}
//判断是否手机端
appStore.isMobile = window.innerWidth < 768;
//菜单自动收缩
if (appStore.isMobile) {
appStore.showSide = false;
} else {
appStore.showSide = true;
}
//重置文档对话状态
appStore.chatDocument = false;
//重置loading状态
appStore.loading = false;
appStore.$subscribe((_, state) => {
localStorage.setItem("appStore_001", JSON.stringify(state));
});
</script>
<style>
#app {
text-align: center;
color: var(--ep-text-color-primary);
}
.element-plus-logo {
width: 50%;
}
.vuepress-markdown-body {
background-color: transparent !important;
padding: 5px !important;
text-align: left;
font-size: 14px !important;
}
</style>
<style lang="scss">
.vuepress-markdown-body {
color: var(--mdcolor) !important;
}
</style>