fixe page styles

This commit is contained in:
RockYang
2024-06-05 18:08:23 +08:00
parent d52dfbfef4
commit 2207830db9
17 changed files with 95 additions and 78 deletions

View File

@@ -222,10 +222,24 @@ export function processContent(content) {
return texts.join("\n")
}
export function escapeHTML(html) {
return html.replace(/&/g, "&")
export function processPrompt(prompt) {
prompt = prompt.replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;");
const linkRegex = /(https?:\/\/\S+)/g;
const links = prompt.match(linkRegex);
if (links) {
for (let link of links) {
if (isImage(link)) {
const index = prompt.indexOf(link)
if (prompt.substring(index - 1, 2) !== "]") {
prompt = prompt.replace(link, "\n![](" + link + ")\n")
}
}
}
}
return prompt
}
// 判断是否为 iphone 设备

View File

@@ -191,7 +191,15 @@ import ChatPrompt from "@/components/ChatPrompt.vue";
import ChatReply from "@/components/ChatReply.vue";
import {Delete, Edit, More, Plus, Promotion, Search, Share, VideoPause} from '@element-plus/icons-vue'
import 'highlight.js/styles/a11y-dark.css'
import {dateFormat, escapeHTML, isMobile, processContent, randString, removeArrayItem, UUID} from "@/utils/libs";
import {
dateFormat,
isMobile,
processContent,
processPrompt,
randString,
removeArrayItem,
UUID
} from "@/utils/libs";
import {ElMessage, ElMessageBox} from "element-plus";
import hl from "highlight.js";
import {getSessionId, getUserToken, removeUserToken} from "@/store/session";
@@ -697,8 +705,10 @@ const onInput = (e) => {
inputRef.value.scrollTo(0, inputRef.value.scrollHeight)
if (prompt.value.length < 10) {
row.value = 1
} else if (row.value <= 7) {
} else if (lines <= 7){
row.value = lines
} else {
row.value = 7
}
// 输入回车自动提交
@@ -738,7 +748,7 @@ const sendMessage = function () {
type: "prompt",
id: randString(32),
icon: loginUser.value.avatar,
content: md.render(escapeHTML(processContent(prompt.value))),
content: md.render(processPrompt(prompt.value)),
created_at: new Date().getTime() / 1000,
});

View File

@@ -167,11 +167,6 @@
<i class="iconfont icon-loading"></i>
<span>正在下载图片</span>
</div>
<div class="image-slot">
<el-icon>
<Picture/>
</el-icon>
</div>
</template>
</el-image>

View File

@@ -187,7 +187,7 @@ onMounted(() => {
httpGet("/api/menu/list").then(res => {
mainNavs.value = res.data
// 根据窗口的高度计算应该显示多少菜单
const rows = Math.floor((window.innerHeight - 90) / 60)
const rows = Math.floor((window.innerHeight - 100) / 90)
if (res.data.length > rows) {
mainNavs.value = res.data.slice(0, rows)
moreNavs.value = res.data.slice(rows)

View File

@@ -515,6 +515,13 @@
正在加载图片
</div>
</template>
<template #error>
<div class="image-slot">
<el-icon>
<Picture/>
</el-icon>
</div>
</template>
</el-image>
<el-image v-else>
<template #error>
@@ -522,11 +529,6 @@
<i class="iconfont icon-loading"></i>
<span>正在下载图片</span>
</div>
<div class="image-slot">
<el-icon>
<Picture/>
</el-icon>
</div>
</template>
</el-image>

View File

@@ -308,11 +308,7 @@
</template>
<template #error>
<div class="image-slot">
<el-icon>
<Picture/>
</el-icon>
</div>
<div class="image-slot"></div>
</template>
</el-image>