From 1390ddb36e704271f462e00b4b5f02f3174d0638 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Fri, 6 Jun 2025 16:32:03 +0800 Subject: [PATCH] paragraph --- ui/package.json | 1 + .../dynamics-form/items/slider/Slider.vue | 5 - ui/src/components/index.ts | 6 + ui/src/components/markdown/EchartsRander.vue | 119 ++++++++ ui/src/components/markdown/FormRander.vue | 92 +++++++ ui/src/components/markdown/HtmlRander.vue | 36 +++ ui/src/components/markdown/MdEditor.vue | 26 ++ .../components/markdown/MdEditorMagnify.vue | 68 +++++ ui/src/components/markdown/MdPreview.vue | 23 ++ ui/src/components/markdown/MdRenderer.vue | 256 ++++++++++++++++++ .../components/markdown/ReasoningRander.vue | 35 +++ .../markdown/assets/markdown-iconfont.js | 1 + ui/src/locales/lang/en-US/common.ts | 1 + ui/src/locales/lang/zh-CN/common.ts | 1 + ui/src/locales/lang/zh-CN/views/index.ts | 5 +- ui/src/locales/lang/zh-CN/views/knowledge.ts | 2 + ui/src/locales/lang/zh-CN/views/paragraph.ts | 32 +++ ui/src/locales/lang/zh-Hant/common.ts | 1 + ui/src/main.ts | 34 +++ ui/src/router/modules/paragraph.ts | 2 +- ui/src/styles/component.scss | 6 + ui/src/styles/element-plus.scss | 6 +- ui/src/styles/index.scss | 2 + ui/src/styles/md-editor.scss | 46 ++++ ui/src/views/document/index.vue | 19 +- ui/src/views/knowledge/KnowledgeSetting.vue | 123 ++++----- .../paragraph/component/ParagraphCard.vue | 85 ++++++ ui/src/views/paragraph/index.vue | 211 ++++----------- ui/src/views/tool/index.vue | 4 +- 29 files changed, 1009 insertions(+), 239 deletions(-) create mode 100644 ui/src/components/markdown/EchartsRander.vue create mode 100644 ui/src/components/markdown/FormRander.vue create mode 100644 ui/src/components/markdown/HtmlRander.vue create mode 100644 ui/src/components/markdown/MdEditor.vue create mode 100644 ui/src/components/markdown/MdEditorMagnify.vue create mode 100644 ui/src/components/markdown/MdPreview.vue create mode 100644 ui/src/components/markdown/MdRenderer.vue create mode 100644 ui/src/components/markdown/ReasoningRander.vue create mode 100644 ui/src/components/markdown/assets/markdown-iconfont.js create mode 100644 ui/src/locales/lang/zh-CN/views/paragraph.ts create mode 100644 ui/src/styles/md-editor.scss create mode 100644 ui/src/views/paragraph/component/ParagraphCard.vue diff --git a/ui/package.json b/ui/package.json index df3f14d24..d17f1fc23 100644 --- a/ui/package.json +++ b/ui/package.json @@ -20,6 +20,7 @@ "axios": "^1.8.4", "dingtalk-jsapi": "^3.1.0", "element-plus": "^2.9.10", + "md-editor-v3": "^5.6.1", "nprogress": "^0.2.0", "pinia": "^3.0.1", "use-element-plus-theme": "^0.0.5", diff --git a/ui/src/components/dynamics-form/items/slider/Slider.vue b/ui/src/components/dynamics-form/items/slider/Slider.vue index 3892f1563..000245a72 100644 --- a/ui/src/components/dynamics-form/items/slider/Slider.vue +++ b/ui/src/components/dynamics-form/items/slider/Slider.vue @@ -3,9 +3,4 @@ diff --git a/ui/src/components/index.ts b/ui/src/components/index.ts index 4fe7b5080..dbd79d8a8 100644 --- a/ui/src/components/index.ts +++ b/ui/src/components/index.ts @@ -16,6 +16,9 @@ import InfiniteScroll from './infinite-scroll/index.vue' import ModelSelect from './model-select/index.vue' import ReadWrite from './read-write/index.vue' import AutoTooltip from './auto-tooltip/index.vue' +import MdEditor from './markdown/MdEditor.vue' +import MdPreview from './markdown/MdPreview.vue' +import MdEditorMagnify from './markdown/MdEditorMagnify.vue' export default { install(app: App) { app.component('LogoFull', LogoFull) @@ -35,5 +38,8 @@ export default { app.component('ModelSelect', ModelSelect) app.component('ReadWrite', ReadWrite) app.component('AutoTooltip', AutoTooltip) + app.component('MdPreview', MdPreview) + app.component('MdEditor', MdEditor) + app.component('MdEditorMagnify', MdEditorMagnify) }, } diff --git a/ui/src/components/markdown/EchartsRander.vue b/ui/src/components/markdown/EchartsRander.vue new file mode 100644 index 000000000..f008cdaa0 --- /dev/null +++ b/ui/src/components/markdown/EchartsRander.vue @@ -0,0 +1,119 @@ + + + diff --git a/ui/src/components/markdown/FormRander.vue b/ui/src/components/markdown/FormRander.vue new file mode 100644 index 000000000..96c743809 --- /dev/null +++ b/ui/src/components/markdown/FormRander.vue @@ -0,0 +1,92 @@ + + + diff --git a/ui/src/components/markdown/HtmlRander.vue b/ui/src/components/markdown/HtmlRander.vue new file mode 100644 index 000000000..a8be05959 --- /dev/null +++ b/ui/src/components/markdown/HtmlRander.vue @@ -0,0 +1,36 @@ + + + diff --git a/ui/src/components/markdown/MdEditor.vue b/ui/src/components/markdown/MdEditor.vue new file mode 100644 index 000000000..6a621a04e --- /dev/null +++ b/ui/src/components/markdown/MdEditor.vue @@ -0,0 +1,26 @@ + + + diff --git a/ui/src/components/markdown/MdEditorMagnify.vue b/ui/src/components/markdown/MdEditorMagnify.vue new file mode 100644 index 000000000..e8555abe3 --- /dev/null +++ b/ui/src/components/markdown/MdEditorMagnify.vue @@ -0,0 +1,68 @@ + + + + + diff --git a/ui/src/components/markdown/MdPreview.vue b/ui/src/components/markdown/MdPreview.vue new file mode 100644 index 000000000..0d8c3ab15 --- /dev/null +++ b/ui/src/components/markdown/MdPreview.vue @@ -0,0 +1,23 @@ + + + diff --git a/ui/src/components/markdown/MdRenderer.vue b/ui/src/components/markdown/MdRenderer.vue new file mode 100644 index 000000000..e2fc4ee90 --- /dev/null +++ b/ui/src/components/markdown/MdRenderer.vue @@ -0,0 +1,256 @@ + + + diff --git a/ui/src/components/markdown/ReasoningRander.vue b/ui/src/components/markdown/ReasoningRander.vue new file mode 100644 index 000000000..b42ae7fed --- /dev/null +++ b/ui/src/components/markdown/ReasoningRander.vue @@ -0,0 +1,35 @@ + + + diff --git a/ui/src/components/markdown/assets/markdown-iconfont.js b/ui/src/components/markdown/assets/markdown-iconfont.js new file mode 100644 index 000000000..6b8505f21 --- /dev/null +++ b/ui/src/components/markdown/assets/markdown-iconfont.js @@ -0,0 +1 @@ +window._iconfont_svg_string_2605852='',function(l){var a=(a=document.getElementsByTagName("script"))[a.length-1],c=a.getAttribute("data-injectcss"),a=a.getAttribute("data-disable-injectsvg");if(!a){var o,t,i,e,h,d=function(a,c){c.parentNode.insertBefore(a,c)};if(c&&!l.__iconfont__svg__cssinject__){l.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(a){console&&console.log(a)}}o=function(){var a,c=document.createElement("div");c.innerHTML=l._iconfont_svg_string_2605852,(c=c.getElementsByTagName("svg")[0])&&(c.setAttribute("aria-hidden","true"),c.style.position="absolute",c.style.width=0,c.style.height=0,c.style.overflow="hidden",c=c,(a=document.body).firstChild?d(c,a.firstChild):a.appendChild(c))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(o,0):(t=function(){document.removeEventListener("DOMContentLoaded",t,!1),o()},document.addEventListener("DOMContentLoaded",t,!1)):document.attachEvent&&(i=o,e=l.document,h=!1,v(),e.onreadystatechange=function(){"complete"==e.readyState&&(e.onreadystatechange=null,m())})}function m(){h||(h=!0,i())}function v(){try{e.documentElement.doScroll("left")}catch(a){return void setTimeout(v,50)}m()}}(window); \ No newline at end of file diff --git a/ui/src/locales/lang/en-US/common.ts b/ui/src/locales/lang/en-US/common.ts index a91c1a7b5..afabb61fd 100644 --- a/ui/src/locales/lang/en-US/common.ts +++ b/ui/src/locales/lang/en-US/common.ts @@ -80,4 +80,5 @@ export default { uploadImagePrompt: 'Please upload an image', }, info: 'Base Information', + otherSetting: 'Other Settings', } diff --git a/ui/src/locales/lang/zh-CN/common.ts b/ui/src/locales/lang/zh-CN/common.ts index 1dc493640..c7fb3fd9e 100644 --- a/ui/src/locales/lang/zh-CN/common.ts +++ b/ui/src/locales/lang/zh-CN/common.ts @@ -84,4 +84,5 @@ export default { uploadImagePrompt: '请上传一张图片', }, info: '基本信息', + otherSetting: '其他设置', } diff --git a/ui/src/locales/lang/zh-CN/views/index.ts b/ui/src/locales/lang/zh-CN/views/index.ts index ac04f79ff..49e68cf92 100644 --- a/ui/src/locales/lang/zh-CN/views/index.ts +++ b/ui/src/locales/lang/zh-CN/views/index.ts @@ -10,10 +10,9 @@ import application from './application' import problem from './problem' import applicationOverview from './application-overview' import applicationWorkflow from './application-workflow' +import paragraph from './paragraph' // import notFound from './404' -// import paragraph from './paragraph' - // import log from './log' // import operateLog from './operate-log' @@ -30,8 +29,8 @@ export default { problem, applicationOverview, applicationWorkflow, + paragraph, // notFound, - // paragraph, // log, diff --git a/ui/src/locales/lang/zh-CN/views/knowledge.ts b/ui/src/locales/lang/zh-CN/views/knowledge.ts index 8f0e67fe4..f7c44f32d 100644 --- a/ui/src/locales/lang/zh-CN/views/knowledge.ts +++ b/ui/src/locales/lang/zh-CN/views/knowledge.ts @@ -64,6 +64,8 @@ export default { label: '选择器', placeholder: '默认为 body,可输入 .classname/#idname/tagname', }, + + }, ResultSuccess: { diff --git a/ui/src/locales/lang/zh-CN/views/paragraph.ts b/ui/src/locales/lang/zh-CN/views/paragraph.ts new file mode 100644 index 000000000..cf38b908f --- /dev/null +++ b/ui/src/locales/lang/zh-CN/views/paragraph.ts @@ -0,0 +1,32 @@ +export default { + title: '段落', + paragraph_count: '段落', + editParagraph: '编辑分段', + addParagraph: '添加分段', + paragraphDetail: '分段详情', + character_count: '个字符', + setting: { + batchSelected: '批量选择', + cancelSelected: '取消选择' + }, + delete: { + confirmTitle: '是否删除段落:', + confirmMessage: '删除后无法恢复,请谨慎操作。' + }, + relatedProblem: { + title: '关联问题', + placeholder: '请选择问题' + }, + form: { + paragraphTitle: { + label: '分段标题', + placeholder: '请输入分段标题' + }, + content: { + label: '分段内容', + placeholder: '请输入分段内容', + requiredMessage1: '请输入分段内容', + requiredMessage2: '内容最多不超过 100000 个字' + } + } +} diff --git a/ui/src/locales/lang/zh-Hant/common.ts b/ui/src/locales/lang/zh-Hant/common.ts index e6a99e91a..a89aabed5 100644 --- a/ui/src/locales/lang/zh-Hant/common.ts +++ b/ui/src/locales/lang/zh-Hant/common.ts @@ -80,4 +80,5 @@ export default { uploadImagePrompt: '請上傳一張圖片', }, info: '使用者資訊', + otherSetting: '其他設定', } diff --git a/ui/src/main.ts b/ui/src/main.ts index c8e6c0329..9180a5325 100644 --- a/ui/src/main.ts +++ b/ui/src/main.ts @@ -11,6 +11,40 @@ import router from '@/router' import i18n from '@/locales' import Components from '@/components' import directives from '@/directives' + +import { config } from 'md-editor-v3' +import screenfull from 'screenfull' + +import katex from 'katex' +import 'katex/dist/katex.min.css' + +import Cropper from 'cropperjs' +import 'cropperjs/dist/cropper.css' + +import mermaid from 'mermaid' + +import highlight from 'highlight.js' +import 'highlight.js/styles/atom-one-dark.css' + +config({ + editorExtensions: { + highlight: { + instance: highlight + }, + screenfull: { + instance: screenfull + }, + katex: { + instance: katex + }, + cropper: { + instance: Cropper + }, + mermaid: { + instance: mermaid + } + } +}) const app = createApp(App) app.use(createPinia()) for (const [key, component] of Object.entries(ElementPlusIcons)) { diff --git a/ui/src/router/modules/paragraph.ts b/ui/src/router/modules/paragraph.ts index db2f64b85..102822b45 100644 --- a/ui/src/router/modules/paragraph.ts +++ b/ui/src/router/modules/paragraph.ts @@ -7,7 +7,7 @@ const ParagraphRouter = { children: [ { path: '/paragraph/:id/:documentId', - name: 'Paragraph1', + name: 'ParagraphIndex', meta: { activeMenu: '/knowledge' }, component: () => import('@/views/paragraph/index.vue'), }, diff --git a/ui/src/styles/component.scss b/ui/src/styles/component.scss index 36cf3e79c..8366a4ed1 100644 --- a/ui/src/styles/component.scss +++ b/ui/src/styles/component.scss @@ -93,3 +93,9 @@ } } } + +.custom-slider { + .el-input-number.is-without-controls .el-input__wrapper { + padding: 0 !important; + } +} diff --git a/ui/src/styles/element-plus.scss b/ui/src/styles/element-plus.scss index 9323fb8fb..4daca04d5 100644 --- a/ui/src/styles/element-plus.scss +++ b/ui/src/styles/element-plus.scss @@ -23,9 +23,13 @@ // card .el-card { --el-card-padding: calc(var(--app-base-px) * 2); - --el-card-border-radius: 8px; + --el-card-border-radius: 6px; box-shadow: 0px 2px 4px 0px rgba(31, 35, 41, 0.12) !important; border: none; + &.is-never-shadow { + border: 1px solid var(--el-card-border-color); + box-shadow: none !important; + } } // tree diff --git a/ui/src/styles/index.scss b/ui/src/styles/index.scss index 7f452a1a3..0d5b82957 100644 --- a/ui/src/styles/index.scss +++ b/ui/src/styles/index.scss @@ -4,3 +4,5 @@ @use './app.scss'; @use './component.scss'; @import 'nprogress/nprogress.css'; +@import 'md-editor-v3/lib/style.css'; +@import './md-editor.scss'; diff --git a/ui/src/styles/md-editor.scss b/ui/src/styles/md-editor.scss new file mode 100644 index 000000000..c60f51f4e --- /dev/null +++ b/ui/src/styles/md-editor.scss @@ -0,0 +1,46 @@ +.md-editor { + font-weight: 400; +} + +.md-editor-preview { + padding: 0; + margin: 0; + font-size: inherit; + word-break: break-word; + table { + display: block; + } + p { + padding: 0 !important; + } + .md-editor-admonition { + margin: 0; + padding: 0; + } + img { + border: 0 !important; + max-width: 360px !important; + } +} + +@media only screen and (max-width: 768px) { + .md-editor-preview { + img { + max-width: 100% !important; + } + } +} + +.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; +} diff --git a/ui/src/views/document/index.vue b/ui/src/views/document/index.vue index b506b2df5..e1a21e380 100644 --- a/ui/src/views/document/index.vue +++ b/ui/src/views/document/index.vue @@ -502,12 +502,6 @@ - - - - - -
@@ -525,7 +519,14 @@ {{ $t('common.clear') }}
+ + + + + + + + diff --git a/ui/src/views/paragraph/index.vue b/ui/src/views/paragraph/index.vue index aa7b3d999..36539e459 100644 --- a/ui/src/views/paragraph/index.vue +++ b/ui/src/views/paragraph/index.vue @@ -1,39 +1,34 @@