样式调整
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@kangc/v-md-editor": "^2.3.15",
|
"@kangc/v-md-editor": "^2.3.15",
|
||||||
"element-plus": "^2.3.4",
|
"element-plus": "^2.3.4",
|
||||||
|
"highlight.js": "^11.8.0",
|
||||||
"nanoid": "^4.0.2",
|
"nanoid": "^4.0.2",
|
||||||
"node-forge": "^1.3.1",
|
"node-forge": "^1.3.1",
|
||||||
"query-string": "^8.1.0",
|
"query-string": "^8.1.0",
|
||||||
|
|||||||
24
src/App.vue
24
src/App.vue
@@ -1,10 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="app">
|
<chat class="fill" :config="setting" :showSettings="showSettings"
|
||||||
<el-row class="home">
|
@setting="showSettings=!showSettings"/>
|
||||||
<chat class="fill" :config="setting" @setting="showSettings=!showSettings"/>
|
<settings v-show="showSettings" v-model="setting"/>
|
||||||
<settings class="mar-l16" v-show="showSettings" v-model="setting"/>
|
|
||||||
</el-row>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -99,19 +96,10 @@ export default {
|
|||||||
#app {
|
#app {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
background-size: cover;
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
|
|
||||||
.home {
|
|
||||||
width: 100vw;
|
|
||||||
height: 100vh;
|
|
||||||
padding: 16px;
|
|
||||||
background-color: #272A37;
|
background-color: #272A37;
|
||||||
position: absolute;
|
padding: 16px;
|
||||||
left: 50%;
|
display: flex;
|
||||||
top: 50%;
|
box-sizing: border-box;
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.fill {
|
.fill {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<el-row justify="end" class="fill mar-l8 gap-8">
|
<el-row justify="end" class="fill mar-l8 gap-8">
|
||||||
<!--聊天操作栏-->
|
<!--聊天操作栏-->
|
||||||
<div class="optIcon clear"/>
|
<div class="optIcon clear"/>
|
||||||
<div class="optIcon setting" @click="$emit('setting')"/>
|
<div class="optIcon setting" :class="{active:$attrs.showSettings}" @click="$emit('setting')"/>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-row>
|
</el-row>
|
||||||
<thinking-bar v-show="loading"/>
|
<thinking-bar v-show="loading"/>
|
||||||
@@ -85,6 +85,8 @@ export default {
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
.optIcon {
|
.optIcon {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@@ -104,6 +106,10 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
opacity: .8;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.active {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<section class="chatContent" @scroll="onScroll">
|
<section class="chatContent" @scroll="onScroll">
|
||||||
|
<div class="chat-wrapper">
|
||||||
|
<div class="chat-friend">
|
||||||
|
<div class="chat-text">
|
||||||
|
<v-md-preview :text="demo"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="chat-wrapper" v-for="item in list" :key="item.id">
|
<div class="chat-wrapper" v-for="item in list" :key="item.id">
|
||||||
<div class="chat-friend" v-if="item.uid !== 'me'">
|
<div class="chat-friend" v-if="item.uid !== 'me'">
|
||||||
<div class="chat-text" v-if="item.chatType == 0">
|
<div class="chat-text" v-if="item.chatType == 0">
|
||||||
<icon-copy @click="copy(item.msg, '已复制')"/>
|
<icon-copy @click="copy(item.msg, '已复制')"/>
|
||||||
<v-md-preview-html :html="item.msg.trim()" preview-class="vuepress-markdown-body"/>
|
<v-md-preview :text="item.msg.trim()"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="chat-img" v-if="item.chatType == 1">
|
<div class="chat-img" v-if="item.chatType == 1">
|
||||||
<img :src="item.msg" alt="表情" v-if="item.extend.imgType == 1" style="width: 100px; height: 100px"/>
|
<img :src="item.msg" alt="表情" v-if="item.extend.imgType == 1" style="width: 100px; height: 100px"/>
|
||||||
@@ -41,6 +48,22 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
list: {default: () => []}
|
list: {default: () => []}
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
demo: "要针对一个CSS滚动到元素的最底部,可以使用以下JS代码:\n" +
|
||||||
|
"\n" +
|
||||||
|
"``` javascript\n" +
|
||||||
|
"var element = document.getElementById('yourElementId');\n" +
|
||||||
|
"scrollToBottom(element);\n" +
|
||||||
|
"\n" +
|
||||||
|
"function scrollToBottom(element) {\n" +
|
||||||
|
" element.scrollTop = element.scrollHeight - element.clientHeight;\n" +
|
||||||
|
"}\n" +
|
||||||
|
"```\n" +
|
||||||
|
"\n" +
|
||||||
|
"这个代码首先获取一个具有给定ID的元素,然后调用名为`scrollToBottom`的函数,该函数将元素滚动到底部。在`scrollToBottom`函数中,`scrollTop`属性设置为`element.scrollHeight - element.clientHeight`的结果,这将把元素滚动到它的最底部。"
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onScroll() {
|
onScroll() {
|
||||||
const scrollDom = this.$el;
|
const scrollDom = this.$el;
|
||||||
@@ -49,6 +72,7 @@ export default {
|
|||||||
const scrollHeight = scrollDom.scrollHeight;
|
const scrollHeight = scrollDom.scrollHeight;
|
||||||
// 当滚动到底部,设置 isAutoScroll 为 true
|
// 当滚动到底部,设置 isAutoScroll 为 true
|
||||||
this.isAutoScroll = scrollTop + offsetHeight === scrollHeight;
|
this.isAutoScroll = scrollTop + offsetHeight === scrollHeight;
|
||||||
|
scrollDom.scrollTop = scrollHeight - scrollDom.clientHeight
|
||||||
},
|
},
|
||||||
copy(msg) {
|
copy(msg) {
|
||||||
if (copyToClipboard(msg)) {
|
if (copyToClipboard(msg)) {
|
||||||
@@ -98,6 +122,7 @@ export default {
|
|||||||
max-width: max(650px, 90%);
|
max-width: max(650px, 90%);
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
|
color: initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-img {
|
.chat-img {
|
||||||
@@ -190,8 +215,12 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.vuepress-markdown-body) {
|
:deep(.github-markdown-body) {
|
||||||
padding: 2px 0 !important;
|
padding: 2px 0 !important;
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ export default {
|
|||||||
},
|
},
|
||||||
getModelAccount(c = 0) {
|
getModelAccount(c = 0) {
|
||||||
const ai = this.settings.model
|
const ai = this.settings.model
|
||||||
console.log(ai)
|
|
||||||
if (ai.apiKey) {
|
if (ai.apiKey) {
|
||||||
this.loadingAccount = true
|
this.loadingAccount = true
|
||||||
ai.getAccount().then(v => this.settings.account = v).finally(() => this.loadingAccount = false)
|
ai.getAccount().then(v => this.settings.account = v).finally(() => this.loadingAccount = false)
|
||||||
@@ -84,7 +83,8 @@ export default {
|
|||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.settings {
|
.settings {
|
||||||
min-width: 400px;
|
min-width: 375px;
|
||||||
|
margin-left: 16px;
|
||||||
|
|
||||||
:deep(.el-form) {
|
:deep(.el-form) {
|
||||||
.el-form-item__label {
|
.el-form-item__label {
|
||||||
@@ -116,4 +116,22 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//移动端布局
|
||||||
|
@media screen and (max-width: 1150px) {
|
||||||
|
.settings {
|
||||||
|
margin-left: 0;
|
||||||
|
z-index: 202305181433;
|
||||||
|
position: fixed;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 0 16px 16px;
|
||||||
|
width: 100vw;
|
||||||
|
top: 80px;
|
||||||
|
left: 0;
|
||||||
|
height: calc(100vh - 80px);
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
background-color: #272A37;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
11
src/main.js
11
src/main.js
@@ -1,14 +1,17 @@
|
|||||||
import VMdPreviewHtml from '@kangc/v-md-editor/lib/preview-html';
|
import VMdPreview from '@kangc/v-md-editor/lib/preview';
|
||||||
import '@kangc/v-md-editor/lib/style/preview-html.css';
|
import '@kangc/v-md-editor/lib/style/preview.css';
|
||||||
import '@kangc/v-md-editor/lib/theme/style/vuepress.css';
|
import githubTheme from '@kangc/v-md-editor/lib/theme/github.js';
|
||||||
|
import '@kangc/v-md-editor/lib/theme/style/github.css';
|
||||||
import ElementPlus from 'element-plus'
|
import ElementPlus from 'element-plus'
|
||||||
import 'element-plus/dist/index.css'
|
import 'element-plus/dist/index.css'
|
||||||
|
import Hljs from "highlight.js"
|
||||||
import {createApp} from 'vue'
|
import {createApp} from 'vue'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import axios from "./utils/axios";
|
import axios from "./utils/axios";
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
app.config.globalProperties.$http = axios
|
app.config.globalProperties.$http = axios
|
||||||
|
VMdPreview.use(githubTheme, {Hljs})
|
||||||
app.use(ElementPlus)
|
app.use(ElementPlus)
|
||||||
app.use(VMdPreviewHtml);
|
app.use(VMdPreview);
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|||||||
Reference in New Issue
Block a user