Merge branch 'main' of github.com:maxkb-dev/maxkb

# Conflicts:
#	ui/src/components/markdown-renderer/MdRenderer.vue
This commit is contained in:
shaohuzhang1 2024-03-14 19:27:17 +08:00
commit f286158f54
7 changed files with 78 additions and 20 deletions

View File

@ -4,6 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base target=_blank>
<title>%VITE_APP_TITLE%</title>
</head>
<body>

View File

@ -26,7 +26,7 @@
"markdown-it-sup": "^1.0.0",
"markdown-it-task-lists": "^2.1.1",
"markdown-it-toc-done-right": "^4.2.0",
"md-editor-v3": "^4.9.0",
"md-editor-v3": "^4.12.1",
"medium-zoom": "^1.1.0",
"mitt": "^3.0.0",
"npm": "^10.2.4",

View File

@ -1,14 +1,12 @@
<template>
<div class="top-bar-container border-b flex-between">
<div class="flex-center h-full">
<a href="/">
<div class="app-title-container flex-center">
<div class="app-title-icon"></div>
<div class="app-title-text app-logo-font ml-4">
{{ defaultTitle }}
</div>
<div class="app-title-container flex-center cursor" @click="router.push('/')">
<div class="app-title-icon"></div>
<div class="app-title-text app-logo-font ml-4">
{{ defaultTitle }}
</div>
</a>
</div>
<TopMenu></TopMenu>
</div>
<div class="avatar">
@ -19,6 +17,8 @@
<script setup lang="ts">
import TopMenu from './top-menu/index.vue'
import Avatar from './avatar/index.vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const defaultTitle = import.meta.env.VITE_APP_TITLE
</script>
<style lang="scss">

View File

@ -518,11 +518,3 @@ h4 {
}
}
}
// markdown
.ͼ1 .cm-placeholder {
color: var(--app-input-color-placeholder);
font-size: 14px;
font-weight: 400;
}

View File

@ -17,3 +17,13 @@
.md-editor-preview-wrapper {
padding: 0;
}
.md-editor-footer {
height: auto !important;
}
.ͼ1 .cm-placeholder {
color: var(--app-input-color-placeholder);
font-size: 14px;
font-weight: 400;
}

View File

@ -333,7 +333,7 @@ const {
const defaultPrompt = `已知信息:
{data}
回答要求
- 简洁和专业的来回答用户的问题
- 使用简洁且专业的语言来回答用户的问题
- 如果你不知道答案请回答没有在知识库中查找到相关信息建议咨询相关技术支持或参考官方文档进行操作
- 避免提及你是从已知信息中获得的知识
- 请保证答案与已知信息中描述的一致

View File

@ -28,15 +28,22 @@
placeholder="请输入分段内容"
:maxLength="4096"
:preview="false"
style="height: 300px;"
:toolbars="toolbars"
style="height: 300px"
/>
<MdPreview
v-else
ref="editorRef"
editorId="preview-only"
:modelValue="form.content"
class="maxkb-md"
/>
<MdPreview v-else ref="editorRef" editorId="preview-only" :modelValue="form.content" />
<!-- <span v-else class="break-all lighter">{{ form.content }}</span> -->
</el-form-item>
</el-form>
</template>
<script setup lang="ts">
import { ref, reactive, onUnmounted, watch } from 'vue'
import { ref, reactive, onUnmounted, watch, nextTick } from 'vue'
import type { FormInstance, FormRules } from 'element-plus'
import { MdEditor, MdPreview } from 'md-editor-v3'
const props = defineProps({
@ -47,6 +54,39 @@ const props = defineProps({
isEdit: Boolean
})
const toolbars = [
'bold',
'underline',
'italic',
'-',
'title',
'strikeThrough',
'sub',
'sup',
'quote',
'unorderedList',
'orderedList',
'task',
'-',
'codeRow',
'code',
'link',
'image',
'table',
'mermaid',
'katex',
'-',
'revoke',
'next',
'=',
'pageFullscreen',
'preview',
'htmlPreview',
'catalog'
] as any[]
const editorRef = ref()
const form = ref<any>({
title: '',
content: ''
@ -95,6 +135,21 @@ function validate() {
})
}
// const onHtmlChanged = () => {
// appendTarget()
// }
// const appendTarget = () => {
// nextTick(() => {
// var item = document.getElementsByClassName('maxkb-md')
// for (var j = 0; j < item.length; j++) {
// var aTags = item[j].getElementsByTagName('a')
// for (var i = 0; i < aTags.length; i++) {
// aTags[i].setAttribute('target', '_blank')
// }
// }
// })
// }
onUnmounted(() => {
form.value = {
title: '',