@core-pilot/client-vue 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client-vue.css +1 -1
- package/dist/cjs/components/bubble-list/index.js +1 -1
- package/dist/cjs/components/bubble-list/index.js.map +1 -1
- package/dist/cjs/components/core-card/index.js +2 -0
- package/dist/cjs/components/core-card/index.js.map +1 -0
- package/dist/cjs/components/editor-sender/index.js +1 -1
- package/dist/cjs/components/editor-sender/index.js.map +1 -1
- package/dist/cjs/components/index.js +1 -1
- package/dist/cjs/components/x-markdown/index.js +1 -1
- package/dist/cjs/components/x-markdown/index.js.map +1 -1
- package/dist/cjs/components/x-markdown/utils/parseCorePilotSchema.js +1 -1
- package/dist/cjs/components/x-markdown/utils/parseCorePilotSchema.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/client-vue.css +1 -1
- package/dist/es/components/bubble-list/index.js +1 -0
- package/dist/es/components/bubble-list/index.js.map +1 -1
- package/dist/es/components/core-card/index.js +76 -0
- package/dist/es/components/core-card/index.js.map +1 -0
- package/dist/es/components/editor-sender/index.js +29 -2
- package/dist/es/components/editor-sender/index.js.map +1 -1
- package/dist/es/components/index.js +2 -0
- package/dist/es/components/index.js.map +1 -1
- package/dist/es/components/x-markdown/index.js +107 -21
- package/dist/es/components/x-markdown/index.js.map +1 -1
- package/dist/es/components/x-markdown/utils/parseCorePilotSchema.js +7 -1
- package/dist/es/components/x-markdown/utils/parseCorePilotSchema.js.map +1 -1
- package/dist/es/index.js +2 -0
- package/dist/es/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const e=require("vue"),t=require("vue-element-plus-x");;/* empty css */const i=require("./actionBar.js"),o=require("../x-markdown/index.js"),
|
|
1
|
+
"use strict";const e=require("vue"),t=require("vue-element-plus-x");;/* empty css */const i=require("./actionBar.js"),o=require("../x-markdown/index.js"),s=e.defineComponent({props:{list:{type:Array,default:()=>[]},btnLoading:{type:Boolean,default:!0},maxHeight:{type:String,default:"500px"},autoHideThinking:{type:Boolean,default:!0},speed:{type:Number,default:200},disLikeFeedbackList:{type:Array,default:()=>{}},likeFeedbackList:{type:Array,default:()=>{}}},expose:["showLastActionGroup","scrollToBottom","hideLastActionGroup"],emits:["hoverActiveRefTrigger","clickActiveRefTrigger","like","dislike","regenerate","copy","refConfigUpdate","questionClick","downloadFile","coreSubmit"],setup(t,{emit:o}){const s=e.useTemplateRef("bubbleList"),n=e.useTemplateRef("bubbleListContainer"),l=e.ref(!1),r=e.ref(null),a=e.ref(()=>{});e.watch(()=>r.value,(e,t)=>{var i;if(null===e)return;if(t===e)return;const s=null==(i=r.value)?void 0:i.querySelector("div[hidden]"),n=JSON.parse((null==s?void 0:s.textContent)||"[]");o("refConfigUpdate",n)}),e.watch(()=>t.list.length,()=>{console.log("props.list.length",t.list.length),e.nextTick(()=>{a.value(),a.value=g()})});const c=(e,t,i,s)=>{o(e,{content:t,message:s,cancel:i})},u=e=>{o("questionClick",e)},d=e=>t.list[t.list.length-1]===e,g=()=>{const e=n.value.querySelectorAll(".el-bubble-start"),t=new IntersectionObserver(e=>{e.forEach(e=>{if(e.isIntersecting){const t=e.boundingClientRect.bottom,i=e.target.clientHeight,o=n.value.getBoundingClientRect().bottom;Math.abs(t-o)<i&&(r.value=e.target)}})},{root:n.value,threshold:[.1,.9]});return e.forEach(e=>{t.observe(e)}),()=>{t.disconnect()}};return e.onMounted(()=>{a.value=g()}),{hoverActiveRefTrigger:e=>{o("hoverActiveRefTrigger",e)},showLastActionGroup:()=>{l.value=!0},hideLastActionGroup:()=>{l.value=!1},showLastBubbleFooter:l,clickActiveRefTrigger:e=>{o("clickActiveRefTrigger",e)},clickAction:c,scrollToBottom:()=>{var e;null==(e=s.value)||e.scrollToBottom()},lastRefConfigUpdate:(e,i)=>{t.list[t.list.length-1]===i&&o("refConfigUpdate",e)},getQuestions:t=>t.questions&&t.questions.length>0?e.createVNode("div",{class:"question-list"},[t.questions.map((t,i)=>e.createVNode("span",{class:"question-item",key:i,onClick:()=>u(t)},[t,e.createVNode("span",{class:"icon"},null)]))]):null,questionClick:u,isLastItem:d,getActionBar:o=>{if("boolean"==typeof o.showActions&&!o.showActions)return null;const s=d(o);return s&&l.value?e.createVNode(i,{isLast:s,content:o.content,message:o,disLikeFeedbackList:t.disLikeFeedbackList,likeFeedbackList:t.likeFeedbackList,onClick:(e,t,i)=>c(e,t,i,o)},null):s?void 0:e.createVNode(i,{isLast:s,content:o.content,message:o,disLikeFeedbackList:t.disLikeFeedbackList,likeFeedbackList:t.likeFeedbackList,onClick:(e,t,i)=>c(e,t,i,o)},null)},onDownloadFile:e=>{o("downloadFile",e)},coreSubmit:(e,t)=>{o("coreSubmit",e,t)}}},render(){return e.createVNode("div",{ref:"bubbleListContainer",class:"bubble-list"},[e.createVNode(t.BubbleList,{ref:"bubbleList",list:this.list,btnLoading:this.btnLoading,maxHeight:this.maxHeight},{header:({item:i})=>{var o;return(null==(o=i.files)?void 0:o.length)?e.createVNode("div",{class:"bubble-item-header"},[i.files.map(i=>e.createVNode(t.FilesCard,{name:i.name,status:"done"},null))]):null},content:({item:t})=>e.createVNode(o,{key:t.id,typing:t.typing,speed:this.speed,text:t.content,historyInputs:t.historyInputs,isHistoryMessage:t.isHistoryMessage,autoHideThinking:this.autoHideThinking,onHoverActiveRefTrigger:this.hoverActiveRefTrigger,onClickActiveRefTrigger:this.clickActiveRefTrigger,onRefConfigUpdate:e=>this.lastRefConfigUpdate(e,t),onDownloadFile:this.onDownloadFile,onCoreSubmit:e=>this.coreSubmit(e,t)},null),footer:({item:t})=>"ai"===t.role?e.createVNode("div",null,[this.getActionBar(t),this.getQuestions(t)]):null})])}});module.exports=s;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/bubble-list/index.tsx"],"sourcesContent":["import { defineComponent, nextTick, onMounted, ref, useTemplateRef, watch } from 'vue';\nimport { BubbleList, FilesCard } from 'vue-element-plus-x';\nimport type { BubbleListItemProps } from 'vue-element-plus-x/types/BubbleList';\nimport './style/index.less';\nimport ActionBar, { BtnItemConfig } from './actionBar';\nimport XMarkdown from '../x-markdown';\n\nexport interface FeedbackItem {\n title: string;\n content: string;\n checked: boolean;\n // showInput?: boolean; // 是否显示输入框\n}\n\nexport interface MessageItem extends BubbleListItemProps {\n role: 'user' | 'ai';\n questions?: Array<string>;\n speed?: number;\n id: string;\n showActions?: boolean;\n feedback?: 'like' | 'dislike';\n files?: Array<{\n id: string,\n extension: string,\n name: string,\n }>;\n isHistoryMessage?: boolean;\n}\n\nexport default defineComponent({\n props: {\n list: {\n type: Array as () => Array<MessageItem>,\n default: () => [],\n },\n btnLoading: {\n type: Boolean,\n default: true,\n },\n maxHeight: {\n type: String,\n default: '500px',\n },\n autoHideThinking: {\n type: Boolean,\n default: true,\n },\n speed: {\n type: Number,\n default: 200,\n },\n disLikeFeedbackList: {\n type: Array as () => Array<FeedbackItem>,\n default: () => undefined,\n },\n likeFeedbackList: {\n type: Array as () => Array<FeedbackItem>,\n default: () => undefined,\n },\n },\n expose: ['showLastActionGroup', 'scrollToBottom', 'hideLastActionGroup'],\n emits: [\n 'hoverActiveRefTrigger',\n 'clickActiveRefTrigger',\n 'like',\n 'dislike',\n 'regenerate',\n 'copy',\n 'refConfigUpdate',\n 'questionClick',\n 'downloadFile',\n 'coreSubmit',\n ],\n setup(props, { emit }) {\n const bubbleList = useTemplateRef<typeof BubbleList>('bubbleList');\n const bubbleListContainer = useTemplateRef<Element>('bubbleListContainer');\n const showLastBubbleFooter = ref(false);\n const curActiveItem = ref<Element | null>(null);\n const destoryObserver = ref<Function>(() => {});\n\n watch(() => curActiveItem.value, (newVal, oldVal) => {\n if (newVal === null) {\n return;\n }\n if (oldVal === newVal) {\n return;\n }\n const refContainer = (curActiveItem.value as HTMLElement)?.querySelector('div[hidden]');\n const curRefList = JSON.parse(refContainer?.textContent || '[]');\n emit('refConfigUpdate', curRefList);\n })\n\n watch(() => props.list.length, () => {\n console.log('props.list.length', props.list.length);\n nextTick(() => {\n destoryObserver.value();\n destoryObserver.value = scrollTrigger();\n })\n })\n\n const hoverActiveRefTrigger = (item) => {\n emit('hoverActiveRefTrigger', item);\n }\n\n const clickActiveRefTrigger = (item) => {\n emit('clickActiveRefTrigger', item);\n }\n\n const showLastActionGroup = () => {\n showLastBubbleFooter.value = true;\n }\n\n const hideLastActionGroup = () => {\n showLastBubbleFooter.value = false;\n }\n\n const clickAction = (type: BtnItemConfig['type'], content, cancel, item) => {\n emit(type, { content, message: item, cancel })\n }\n\n const scrollToBottom = () => {\n (bubbleList.value as any)?.scrollToBottom();\n }\n\n const lastRefConfigUpdate = (refList, item) => {\n // 更新最后一条消息的引用列表\n if (props.list[props.list.length - 1] === item) {\n emit('refConfigUpdate', refList);\n }\n }\n\n const getQuestions = (item) => {\n if (item.questions && item.questions.length > 0) {\n return (\n <div class='question-list'>\n {\n item.questions.map((question, index) => {\n return (\n <span\n class='question-item'\n key={index}\n onClick={() => questionClick(question)}\n >\n {question}\n <span class='icon'></span>\n </span>\n )\n })\n }\n </div>\n )\n }\n return null;\n }\n\n const questionClick = (q) => {\n emit('questionClick', q)\n }\n\n const isLastItem = (item: MessageItem) => {\n return props.list[props.list.length - 1] === item;\n }\n\n const getActionBar = (item: MessageItem) => {\n // 如果当前项中明确指定不显示actionbar,则不显示\n if (typeof item.showActions === 'boolean' && !item.showActions) {\n return null;\n }\n const isLast = isLastItem(item);\n if (isLast && showLastBubbleFooter.value) {\n return (\n <ActionBar\n isLast={isLast}\n content={item.content}\n message={item}\n disLikeFeedbackList={props.disLikeFeedbackList}\n likeFeedbackList={props.likeFeedbackList}\n onClick={(type, content, cancel) => clickAction(type, content, cancel, item)}\n />\n )\n }\n if (!isLast) {\n return (\n <ActionBar\n isLast={isLast}\n content={item.content}\n message={item}\n disLikeFeedbackList={props.disLikeFeedbackList}\n likeFeedbackList={props.likeFeedbackList}\n onClick={(type, content, cancel) => clickAction(type, content, cancel, item)}\n />\n );\n }\n }\n\n const onDownloadFile = (payload) => {\n emit('downloadFile', payload);\n }\n\n const scrollTrigger = () => {\n const messageItems = bubbleListContainer.value!.querySelectorAll('.el-bubble-start');\n\n const observer = new IntersectionObserver((entries) => {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n const itemBottom = entry.boundingClientRect.bottom;\n const height = entry.target.clientHeight;\n const listBottom = bubbleListContainer.value!.getBoundingClientRect().bottom;\n \n if (Math.abs(itemBottom - listBottom) < height) {\n curActiveItem.value = entry.target;\n }\n }\n });\n }, {\n root: bubbleListContainer.value!,\n threshold: [0.1, 0.9]\n });\n\n // 3. 为所有消息项添加监听\n messageItems.forEach(item => {\n observer.observe(item);\n });\n\n return () => {\n observer.disconnect();\n }\n }\n\n const coreSubmit = (payload, item) => {\n emit('coreSubmit', payload, item);\n }\n\n onMounted(() => {\n destoryObserver.value = scrollTrigger();\n })\n\n return {\n hoverActiveRefTrigger,\n showLastActionGroup,\n hideLastActionGroup,\n showLastBubbleFooter,\n clickActiveRefTrigger,\n clickAction,\n scrollToBottom,\n lastRefConfigUpdate,\n getQuestions,\n questionClick,\n isLastItem,\n getActionBar,\n onDownloadFile,\n coreSubmit,\n };\n },\n\n render() {\n return (\n <div\n ref=\"bubbleListContainer\"\n class=\"bubble-list\"\n >\n <BubbleList\n ref=\"bubbleList\"\n list={this.list}\n btnLoading={this.btnLoading}\n maxHeight={this.maxHeight}\n >\n {{\n header: ({ item }: { item: MessageItem }) => {\n if (!item.files?.length) {\n return null;\n }\n return (\n <div class=\"bubble-item-header\">\n {\n item.files.map((item) => (\n <FilesCard\n name={item.name}\n status=\"done\"\n />\n ))\n }\n </div>\n )\n },\n content: ({ item }: { item: MessageItem }) => (\n <XMarkdown\n key={item.id}\n typing={item.typing as boolean}\n speed={this.speed}\n text={item.content}\n isHistoryMessage={item.isHistoryMessage}\n autoHideThinking={this.autoHideThinking}\n onHoverActiveRefTrigger={this.hoverActiveRefTrigger}\n onClickActiveRefTrigger={this.clickActiveRefTrigger}\n onRefConfigUpdate={(refList) => this.lastRefConfigUpdate(refList, item)}\n onDownloadFile={this.onDownloadFile}\n onCoreSubmit={(payload) => this.coreSubmit(payload, item)}\n />\n ),\n footer: ({ item }: { item: MessageItem }) => {\n if (item.role === 'ai') {\n return (\n <div>\n {\n this.getActionBar(item)\n }\n {\n this.getQuestions(item)\n }\n </div>\n )\n }\n return null;\n }\n }}\n </BubbleList>\n </div>\n );\n }\n});"],"names":["index","props","list","type","Array","default","btnLoading","Boolean","maxHeight","String","autoHideThinking","speed","Number","disLikeFeedbackList","likeFeedbackList","expose","emits","setup","emit","bubbleList","useTemplateRef","bubbleListContainer","showLastBubbleFooter","ref","curActiveItem","destoryObserver","watch","value","newVal","oldVal","refContainer","querySelector","curRefList","JSON","parse","textContent","length","console","log","nextTick","scrollTrigger","clickAction","content","cancel","item","message","questionClick","q","isLastItem","messageItems","querySelectorAll","observer","IntersectionObserver","entries","forEach","entry","isIntersecting","itemBottom","boundingClientRect","bottom","height","target","clientHeight","listBottom","getBoundingClientRect","Math","abs","root","threshold","observe","disconnect","onMounted","hoverActiveRefTrigger","showLastActionGroup","hideLastActionGroup","clickActiveRefTrigger","scrollToBottom","lastRefConfigUpdate","refList","getQuestions","questions","_createVNode","class","map","question","key","onClick","getActionBar","showActions","isLast","ActionBar","onDownloadFile","payload","coreSubmit","render","BubbleList","this","header","files","FilesCard","name","status","XMarkdown","id","typing","text","isHistoryMessage","onHoverActiveRefTrigger","onClickActiveRefTrigger","onRefConfigUpdate","onCoreSubmit","footer","role"],"mappings":"2KA6BAA,oBAA+B,CAC7BC,MAAO,CACLC,KAAM,CACJC,KAAMC,MACNC,QAASA,IAAM,IAEjBC,WAAY,CACVH,KAAMI,QACNF,SAAS,GAEXG,UAAW,CACTL,KAAMM,OACNJ,QAAS,SAEXK,iBA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xB,sBAAqBoC,wBAC1BZ,KAAKrB,sBAAqBkC,kBAC/B/B,GAAYkB,KAAKnB,oBAAoBC,EAASlC,GAAK+C,eACvDK,KAAKL,eAAcmB,aACpBlB,GAAYI,KAAKH,WAAWD,EAAShD,IAAK,MAG7DmE,OAAQA,EAAGnE,UACS,OAAdA,EAAKoE,KACP/B,cAAA,MAAA,KAAA,CAGMe,KAAKT,aAAa3C,GAGlBoD,KAAKjB,aAAanC,KAKnB,QAMnB"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/bubble-list/index.tsx"],"sourcesContent":["import { defineComponent, nextTick, onMounted, ref, useTemplateRef, watch } from 'vue';\nimport { BubbleList, FilesCard } from 'vue-element-plus-x';\nimport type { BubbleListItemProps } from 'vue-element-plus-x/types/BubbleList';\nimport './style/index.less';\nimport ActionBar, { BtnItemConfig } from './actionBar';\nimport XMarkdown from '../x-markdown';\n\nexport interface FeedbackItem {\n title: string;\n content: string;\n checked: boolean;\n // showInput?: boolean; // 是否显示输入框\n}\n\nexport interface MessageItem extends BubbleListItemProps {\n role: 'user' | 'ai';\n questions?: Array<string>;\n speed?: number;\n id: string;\n showActions?: boolean;\n feedback?: 'like' | 'dislike';\n files?: Array<{\n id: string,\n extension: string,\n name: string,\n }>;\n isHistoryMessage?: boolean;\n historyInputs?: Record<string, any>;\n}\n\nexport default defineComponent({\n props: {\n list: {\n type: Array as () => Array<MessageItem>,\n default: () => [],\n },\n btnLoading: {\n type: Boolean,\n default: true,\n },\n maxHeight: {\n type: String,\n default: '500px',\n },\n autoHideThinking: {\n type: Boolean,\n default: true,\n },\n speed: {\n type: Number,\n default: 200,\n },\n disLikeFeedbackList: {\n type: Array as () => Array<FeedbackItem>,\n default: () => undefined,\n },\n likeFeedbackList: {\n type: Array as () => Array<FeedbackItem>,\n default: () => undefined,\n },\n },\n expose: ['showLastActionGroup', 'scrollToBottom', 'hideLastActionGroup'],\n emits: [\n 'hoverActiveRefTrigger',\n 'clickActiveRefTrigger',\n 'like',\n 'dislike',\n 'regenerate',\n 'copy',\n 'refConfigUpdate',\n 'questionClick',\n 'downloadFile',\n 'coreSubmit',\n ],\n setup(props, { emit }) {\n const bubbleList = useTemplateRef<typeof BubbleList>('bubbleList');\n const bubbleListContainer = useTemplateRef<Element>('bubbleListContainer');\n const showLastBubbleFooter = ref(false);\n const curActiveItem = ref<Element | null>(null);\n const destoryObserver = ref<Function>(() => {});\n\n watch(() => curActiveItem.value, (newVal, oldVal) => {\n if (newVal === null) {\n return;\n }\n if (oldVal === newVal) {\n return;\n }\n const refContainer = (curActiveItem.value as HTMLElement)?.querySelector('div[hidden]');\n const curRefList = JSON.parse(refContainer?.textContent || '[]');\n emit('refConfigUpdate', curRefList);\n })\n\n watch(() => props.list.length, () => {\n console.log('props.list.length', props.list.length);\n nextTick(() => {\n destoryObserver.value();\n destoryObserver.value = scrollTrigger();\n })\n })\n\n const hoverActiveRefTrigger = (item) => {\n emit('hoverActiveRefTrigger', item);\n }\n\n const clickActiveRefTrigger = (item) => {\n emit('clickActiveRefTrigger', item);\n }\n\n const showLastActionGroup = () => {\n showLastBubbleFooter.value = true;\n }\n\n const hideLastActionGroup = () => {\n showLastBubbleFooter.value = false;\n }\n\n const clickAction = (type: BtnItemConfig['type'], content, cancel, item) => {\n emit(type, { content, message: item, cancel })\n }\n\n const scrollToBottom = () => {\n (bubbleList.value as any)?.scrollToBottom();\n }\n\n const lastRefConfigUpdate = (refList, item) => {\n // 更新最后一条消息的引用列表\n if (props.list[props.list.length - 1] === item) {\n emit('refConfigUpdate', refList);\n }\n }\n\n const getQuestions = (item) => {\n if (item.questions && item.questions.length > 0) {\n return (\n <div class='question-list'>\n {\n item.questions.map((question, index) => {\n return (\n <span\n class='question-item'\n key={index}\n onClick={() => questionClick(question)}\n >\n {question}\n <span class='icon'></span>\n </span>\n )\n })\n }\n </div>\n )\n }\n return null;\n }\n\n const questionClick = (q) => {\n emit('questionClick', q)\n }\n\n const isLastItem = (item: MessageItem) => {\n return props.list[props.list.length - 1] === item;\n }\n\n const getActionBar = (item: MessageItem) => {\n // 如果当前项中明确指定不显示actionbar,则不显示\n if (typeof item.showActions === 'boolean' && !item.showActions) {\n return null;\n }\n const isLast = isLastItem(item);\n if (isLast && showLastBubbleFooter.value) {\n return (\n <ActionBar\n isLast={isLast}\n content={item.content}\n message={item}\n disLikeFeedbackList={props.disLikeFeedbackList}\n likeFeedbackList={props.likeFeedbackList}\n onClick={(type, content, cancel) => clickAction(type, content, cancel, item)}\n />\n )\n }\n if (!isLast) {\n return (\n <ActionBar\n isLast={isLast}\n content={item.content}\n message={item}\n disLikeFeedbackList={props.disLikeFeedbackList}\n likeFeedbackList={props.likeFeedbackList}\n onClick={(type, content, cancel) => clickAction(type, content, cancel, item)}\n />\n );\n }\n }\n\n const onDownloadFile = (payload) => {\n emit('downloadFile', payload);\n }\n\n const scrollTrigger = () => {\n const messageItems = bubbleListContainer.value!.querySelectorAll('.el-bubble-start');\n\n const observer = new IntersectionObserver((entries) => {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n const itemBottom = entry.boundingClientRect.bottom;\n const height = entry.target.clientHeight;\n const listBottom = bubbleListContainer.value!.getBoundingClientRect().bottom;\n \n if (Math.abs(itemBottom - listBottom) < height) {\n curActiveItem.value = entry.target;\n }\n }\n });\n }, {\n root: bubbleListContainer.value!,\n threshold: [0.1, 0.9]\n });\n\n // 3. 为所有消息项添加监听\n messageItems.forEach(item => {\n observer.observe(item);\n });\n\n return () => {\n observer.disconnect();\n }\n }\n\n const coreSubmit = (payload, item) => {\n emit('coreSubmit', payload, item);\n }\n\n onMounted(() => {\n destoryObserver.value = scrollTrigger();\n })\n\n return {\n hoverActiveRefTrigger,\n showLastActionGroup,\n hideLastActionGroup,\n showLastBubbleFooter,\n clickActiveRefTrigger,\n clickAction,\n scrollToBottom,\n lastRefConfigUpdate,\n getQuestions,\n questionClick,\n isLastItem,\n getActionBar,\n onDownloadFile,\n coreSubmit,\n };\n },\n\n render() {\n return (\n <div\n ref=\"bubbleListContainer\"\n class=\"bubble-list\"\n >\n <BubbleList\n ref=\"bubbleList\"\n list={this.list}\n btnLoading={this.btnLoading}\n maxHeight={this.maxHeight}\n >\n {{\n header: ({ item }: { item: MessageItem }) => {\n if (!item.files?.length) {\n return null;\n }\n return (\n <div class=\"bubble-item-header\">\n {\n item.files.map((item) => (\n <FilesCard\n name={item.name}\n status=\"done\"\n />\n ))\n }\n </div>\n )\n },\n content: ({ item }: { item: MessageItem }) => (\n <XMarkdown\n key={item.id}\n typing={item.typing as boolean}\n speed={this.speed}\n text={item.content}\n historyInputs={item.historyInputs}\n isHistoryMessage={item.isHistoryMessage}\n autoHideThinking={this.autoHideThinking}\n onHoverActiveRefTrigger={this.hoverActiveRefTrigger}\n onClickActiveRefTrigger={this.clickActiveRefTrigger}\n onRefConfigUpdate={(refList) => this.lastRefConfigUpdate(refList, item)}\n onDownloadFile={this.onDownloadFile}\n onCoreSubmit={(payload) => this.coreSubmit(payload, item)}\n />\n ),\n footer: ({ item }: { item: MessageItem }) => {\n if (item.role === 'ai') {\n return (\n <div>\n {\n this.getActionBar(item)\n }\n {\n this.getQuestions(item)\n }\n </div>\n )\n }\n return null;\n }\n }}\n </BubbleList>\n </div>\n );\n }\n});"],"names":["index","props","list","type","Array","default","btnLoading","Boolean","maxHeight","String","autoHideThinking","speed","Number","disLikeFeedbackList","likeFeedbackList","expose","emits","setup","emit","bubbleList","useTemplateRef","bubbleListContainer","showLastBubbleFooter","ref","curActiveItem","destoryObserver","watch","value","newVal","oldVal","refContainer","querySelector","curRefList","JSON","parse","textContent","length","console","log","nextTick","scrollTrigger","clickAction","content","cancel","item","message","questionClick","q","isLastItem","messageItems","querySelectorAll","observer","IntersectionObserver","entries","forEach","entry","isIntersecting","itemBottom","boundingClientRect","bottom","height","target","clientHeight","listBottom","getBoundingClientRect","Math","abs","root","threshold","observe","disconnect","onMounted","hoverActiveRefTrigger","showLastActionGroup","hideLastActionGroup","clickActiveRefTrigger","scrollToBottom","lastRefConfigUpdate","refList","getQuestions","questions","_createVNode","class","map","question","key","onClick","getActionBar","showActions","isLast","ActionBar","onDownloadFile","payload","coreSubmit","render","BubbleList","this","header","files","FilesCard","name","status","XMarkdown","id","typing","text","historyInputs","isHistoryMessage","onHoverActiveRefTrigger","onClickActiveRefTrigger","onRefConfigUpdate","onCoreSubmit","footer","role"],"mappings":"2KA8BAA,oBAA+B,CAC7BC,MAAO,CACLC,KAAM,CACJC,KAAMC,MACNC,QAASA,IAAM,IAEjBC,WAAY,CACVH,KAAMI,QACNF,SAAS,GAEXG,UAAW,CACTL,KAAMM,OACNJ,QAAS,SAEXK,iBAAkB,CAChBP,KAAMI,QACNF,SAAS,GAEXM,MAAO,CACLR,KAAMS,OACNP,QAAS,KAEXQ,oBAAqB,CACnBV,KAAMC,MACNC,QAASA,QAEXS,iBAAkB,CAChBX,KAAMC,MACNC,QAASA,SAGbU,OAAQ,CAAC,sBAAuB,iBAAkB,uBAClDC,MAAO,CACL,wBACA,wBACA,OACA,UACA,aACA,OACA,kBACA,gBACA,eACA,cAEFC,KAAAA,CAAMhB,GAAOiB,KAAEA,IACb,MAAMC,EAAaC,EAAAA,eAAkC,cAC/CC,EAAsBD,EAAAA,eAAwB,uBAC9CE,EAAuBC,EAAAA,KAAI,GAC3BC,EAAgBD,EAAAA,IAAoB,MACpCE,EAAkBF,EAAAA,IAAc,QAEtCG,EAAAA,MAAM,IAAMF,EAAcG,MAAO,CAACC,EAAQC,WACxC,GAAe,OAAXD,EACF,OAEF,GAAIC,IAAWD,EACb,OAEF,MAAME,EAAgBN,OAAAA,EAAAA,EAAcG,YAAdH,EAAAA,EAAqCO,cAAc,eACnEC,EAAaC,KAAKC,OAAMJ,MAAAA,OAAAA,EAAAA,EAAcK,cAAe,MAC3DjB,EAAK,kBAAmBc,KAG1BN,EAAAA,MAAM,IAAMzB,EAAMC,KAAKkC,OAAQ,KAC7BC,QAAQC,IAAI,oBAAqBrC,EAAMC,KAAKkC,QAC5CG,EA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A,EAAYR,QAGjB6C,EAAAA,YAAA,MAAA,CAAAC,MAAA,sBAAA,CAGMtC,EAAKsD,MAAMf,IAAKvC,GAAIqC,EAAAA,YAAAkB,YAAA,CAAAC,KAEVxD,EAAKwD,KAAIC,OAAA,QAAA,SAPhB,MAeX3D,QAASA,EAAGE,UAA6BqC,EAAAA,YAAAqB,EAAA,CAAAjB,IAEhCzC,EAAK2D,GAAEC,OACJ5D,EAAK4D,OAAM7F,MACZqF,KAAKrF,MAAK8F,KACX7D,EAAKF,QAAOgE,cACH9D,EAAK8D,cAAaC,iBACf/D,EAAK+D,iBAAgBjG,iBACrBsF,KAAKtF,iBAAgBkG,wBACdZ,KAAKxB,sBAAqBqC,wBAC1Bb,KAAKrB,sBAAqBmC,kBAC/BhC,GAAYkB,KAAKnB,oBAAoBC,EAASlC,GAAK+C,eACvDK,KAAKL,eAAcoB,aACpBnB,GAAYI,KAAKH,WAAWD,EAAShD,IAAK,MAG7DoE,OAAQA,EAAGpE,UACS,OAAdA,EAAKqE,KACPhC,cAAA,MAAA,KAAA,CAGMe,KAAKT,aAAa3C,GAGlBoD,KAAKjB,aAAanC,KAKnB,QAMnB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const e=require("vue"),s=require("element-plus");/* empty css *//* empty css */;/* empty css */const l=e.defineComponent({name:"CoreCard",props:{header:{type:String,default:""},shadow:{type:String,default:"always"},collapsible:{type:Boolean,default:!0},defaultCollapsed:{type:Boolean,default:!1}},setup(s,{slots:l}){const a=e.ref(s.defaultCollapsed),o=e.computed(()=>a.value?"core-card__collapse-icon--collapsed":"core-card__collapse-icon--expanded");return{isCollapsed:a,toggleCollapse:()=>{s.collapsible&&(a.value=!a.value)},collapseIconClass:o}},render(){const l=this.header||this.$slots.header;return e.createVNode(s.ElCard,{class:"core-card",shadow:this.shadow},{header:l?()=>e.createVNode("div",{class:"core-card__header",onClick:this.toggleCollapse,style:this.collapsible?{cursor:"pointer"}:{}},[e.createVNode("span",{class:"core-card__header-text"},[this.$slots.header?this.$slots.header():this.header]),this.collapsible&&e.createVNode("i",{class:`core-card__collapse-icon ${this.collapseIconClass}`},null)]):void 0,default:()=>{var s,l;return e.createVNode("div",{class:{"core-card__body":!0,"core-card__body--collapsed":this.isCollapsed}},[null==(l=(s=this.$slots).default)?void 0:l.call(s)])}})}});module.exports=l;
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/core-card/index.tsx"],"sourcesContent":["import { defineComponent, ref, PropType, computed } from 'vue';\nimport { ElCard } from 'element-plus';\nimport './style.less';\n\nexport default defineComponent({\n name: 'CoreCard',\n props: {\n header: {\n type: String,\n default: '',\n },\n shadow: {\n type: String as PropType<'always' | 'never' | 'hover'>,\n default: 'always',\n },\n collapsible: {\n type: Boolean,\n default: true,\n },\n defaultCollapsed: {\n type: Boolean,\n default: false,\n },\n },\n setup(props, { slots }) {\n const isCollapsed = ref(props.defaultCollapsed);\n\n const toggleCollapse = () => {\n if (props.collapsible) {\n isCollapsed.value = !isCollapsed.value;\n }\n };\n\n const collapseIconClass = computed(() => {\n return isCollapsed.value ? 'core-card__collapse-icon--collapsed' : 'core-card__collapse-icon--expanded';\n });\n\n return {\n isCollapsed,\n toggleCollapse,\n collapseIconClass,\n };\n },\n render() {\n const hasHeader = this.header || this.$slots.header;\n \n return (\n <ElCard\n class=\"core-card\"\n shadow={this.shadow}\n >\n {{\n header: hasHeader ? () => (\n <div \n class=\"core-card__header\" \n onClick={this.toggleCollapse}\n style={this.collapsible ? { cursor: 'pointer' } : {}}\n >\n <span class=\"core-card__header-text\">\n {this.$slots.header ? this.$slots.header() : this.header}\n </span>\n {this.collapsible && (\n <i class={`core-card__collapse-icon ${this.collapseIconClass}`}></i>\n )}\n </div>\n ) : undefined,\n default: () => (\n <div\n class={{\n 'core-card__body': true,\n 'core-card__body--collapsed': this.isCollapsed,\n }}\n >\n {this.$slots.default?.()}\n </div>\n ),\n }}\n </ElCard>\n );\n },\n});\n\n"],"names":["CoreCard","name","props","header","type","String","default","shadow","collapsible","Boolean","defaultCollapsed","setup","slots","isCollapsed","ref","collapseIconClass","computed","value","toggleCollapse","render","hasHeader","this","$slots","_createVNode","ElCard","class","onClick","style","cursor","undefined","_b","_a"],"mappings":"iXAIA,MAAAA,oBAA+B,CAC7BC,KAAM,WACNC,MAAO,CACLC,OAAQ,CACNC,KAAMC,OACNC,QAAS,IAEXC,OAAQ,CACNH,KAAMC,OACNC,QAAS,UAEXE,YAAa,CACXJ,KAAMK,QACNH,SAAS,GAEXI,iBAAkB,CAChBN,KAAMK,QACNH,SAAS,IAGbK,KAAAA,CAAMT,GAAOU,MAAEA,IACb,MAAMC,EAAcC,EAAAA,IAAIZ,EAAMQ,kBAQxBK,EAAoBC,EAAAA,SAAS,IAC1BH,EAAYI,MAAQ,sCAAwC,sCAGrE,MAAO,CACLJ,cACAK,eAZqBA,KACjBhB,EAAMM,cACRK,EAAYI,OAASJ,EAAYI,QAWnCF,oBAEJ,EACAI,MAAAA,GACE,MAAMC,EAAYC,KAAKlB,QAAUkB,KAAKC,OAAOnB,OAE7C,OAAAoB,EAAAA,YAAAC,EAAAA,OAAA,CAAAC,MAAA,YAAAlB,OAGYc,KAAKd,QAAM,CAGjBJ,OAAQiB,EAAY,IAAAG,EAAAA,YAAA,MAAA,CAAAE,MAAA,oBAAAC,QAGPL,KAAKH,eAAcS,MACrBN,KAAKb,YAAc,CAAEoB,OAAQ,WAAc,CAAA,GAAE,CAAAL,EAAAA,YAAA,OAAA,CAAAE,MAAA,0BAAA,CAGjDJ,KAAKC,OAAOnB,OAASkB,KAAKC,OAAOnB,SAAWkB,KAAKlB,SAEnDkB,KAAKb,aAAWe,EAAAA,YAAA,IAAA,CAAAE,MACL,4BAA4BJ,KAAKN,qBAAmB,aAGhEc,EACJvB,QAASA,aAAAiB,OAAAA,EAAAA,YAAA,MAAA,CAAAE,MAEE,CACL,mBAAmB,EACnB,6BAA8BJ,KAAKR,cACpC,CAEA,OAAAiB,GAAAC,EAAAV,KAAKC,QAAOhB,8BAMzB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const e=require("vue"),t=require("vue-element-plus-x"),a=require("./source/index.vue.js"),l=require("../../node_modules/.pnpm/@element-plus_icons-vue@2.3.2_vue@3.5.24_typescript@5.6.3_/node_modules/@element-plus/icons-vue/dist/index.js"),n=require("element-plus");/* empty css *//* empty css *//* empty css */;/* empty css */const i=require("./LoadingButton/index.vue.js");;/* empty css */const s=e.defineComponent({props:{loading:{type:Boolean,default:!1},actionUrl:{type:String,default:"/openapi/v1/app/files/upload"},extendData:{type:Object,default:()=>({user:"abc-123"})},acceptFileType:{type:String,default:".txt,.md,.mdx,.markdown,.pdf,.html,.xlsx,.xls,.doc,.docx,.csv,.eml,.msg,.pptx,.ppt,.xml,.epub,.jpg,.jpeg,.png,.gif,.webp,.svg"},headers:{type:Object,default:()=>({Authorization:"Bearer ApiSecretKey_mEKsrCMvxNLzzUUKeQmpzaUZqwZxFyJf",appId:"9a673565-d4f6-4382-bc67-f1beb07df435"})},agentName:{type:String,default:"知识问答智能体"},limit:{type:Number,default:5},customStyle:{type:Object,default:()=>({maxHeight:"75px"})},inputData:{type:String,default:""},placeholder:{type:String,default:"请尝试输入任务、问题或想法,我会帮你搞定"},tagList:{type:Array,default:()=>[{id:"1",name:"问产品"},{id:"2",name:"问品类"},{id:"3",name:"问品牌"},{id:"4",name:"找物料"},{id:"5",name:"问知识"},{id:"6",name:"遇客诉"}]},sceneList:{type:Array,default:()=>[{id:"ANC",name:"ANC"},{id:"BNC",name:"BNC"}]}},emits:["cancel","submit","sceneChange"],setup(a,{emit:s}){const
|
|
1
|
+
"use strict";const e=require("vue"),t=require("vue-element-plus-x"),a=require("./source/index.vue.js"),l=require("../../node_modules/.pnpm/@element-plus_icons-vue@2.3.2_vue@3.5.24_typescript@5.6.3_/node_modules/@element-plus/icons-vue/dist/index.js"),n=require("element-plus");/* empty css *//* empty css *//* empty css */;/* empty css */const i=require("./LoadingButton/index.vue.js");;/* empty css */const s=e.defineComponent({props:{loading:{type:Boolean,default:!1},actionUrl:{type:String,default:"/openapi/v1/app/files/upload"},extendData:{type:Object,default:()=>({user:"abc-123"})},acceptFileType:{type:String,default:".txt,.md,.mdx,.markdown,.pdf,.html,.xlsx,.xls,.doc,.docx,.csv,.eml,.msg,.pptx,.ppt,.xml,.epub,.jpg,.jpeg,.png,.gif,.webp,.svg"},headers:{type:Object,default:()=>({Authorization:"Bearer ApiSecretKey_mEKsrCMvxNLzzUUKeQmpzaUZqwZxFyJf",appId:"9a673565-d4f6-4382-bc67-f1beb07df435"})},agentName:{type:String,default:"知识问答智能体"},limit:{type:Number,default:5},customStyle:{type:Object,default:()=>({maxHeight:"75px"})},inputData:{type:String,default:""},placeholder:{type:String,default:"请尝试输入任务、问题或想法,我会帮你搞定"},tagList:{type:Array,default:()=>[{id:"1",name:"问产品"},{id:"2",name:"问品类"},{id:"3",name:"问品牌"},{id:"4",name:"找物料"},{id:"5",name:"问知识"},{id:"6",name:"遇客诉"}]},sceneList:{type:Array,default:()=>[{id:"ANC",name:"ANC"},{id:"BNC",name:"BNC"}]},scene:{type:String,default:void 0}},emits:["cancel","submit","sceneChange","update:scene"],setup(a,{emit:s}){const r=e.useTemplateRef("editorSender"),o=e.useTemplateRef("editorSenderWrapper"),d=e.useTemplateRef("fileUpload"),c=e.ref((()=>{if(a.scene){const e=a.sceneList.find(e=>e.id===a.scene);if(e)return e}return a.sceneList[0]})()),p=e.ref(!0),u=e.ref([]),m=e.ref(a.tagList[0]);e.watch(()=>a.agentName,t=>{e.nextTick(()=>{var e;const a=null==(e=o.value)?void 0:e.querySelector(".el-editor-sender-chat-room");null==a||a.setAttribute("datatype",t)})},{immediate:!0}),e.watch(()=>a.inputData,t=>{e.nextTick(()=>{var e,a;null==(e=r.value)||e.clear(),null==(a=r.value)||a.setText(t)})}),e.watch(()=>a.scene,e=>{if(e){const t=a.sceneList.find(t=>t.id===e);t&&(c.value=t)}}),e.watch(()=>a.sceneList,e=>{if(e.length>0){if(a.scene){const t=e.find(e=>e.id===a.scene);if(t)return void(c.value=t)}c.value=e[0]}},{immediate:!0});const v=()=>{s("cancel")},f=e=>{if(p.value||a.loading)return;const t={text:e.text,file:u.value.map(e=>e.response)};var l,n;s("submit",t),null==(l=r.value)||l.clear(),u.value=[],null==(n=d.value)||n.clearFiles()},g=()=>{n.ElNotification({title:"",message:"上传文件失败",type:"error"})},h=(e,t,a)=>{u.value=a},y=e=>{if(t=e.type,!new Set(["text/plain","text/markdown","application/pdf","text/html","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/csv","message/rfc822","application/vnd.ms-outlook","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.ms-powerpoint","application/xml","text/xml","application/epub+zip","image/jpeg","image/png","image/gif","image/webp","image/svg+xml"]).has(null==t?void 0:t.trim().toLowerCase()))return n.ElNotification({title:"",message:"无法解析上传",type:"warning"}),!1;var t;const a=e.type.includes("image"),l=!a,i=e.size/1024/1024<15,s=e.size/1024/1024<10;return l&&!i?(n.ElNotification({title:"",message:"上传文档大小不能超过 15MB!",type:"warning"}),!1):!(a&&!s)||(n.ElNotification({title:"",message:"上传图片大小不能超过 10MB!",type:"warning"}),!1)},x=()=>{n.ElNotification({title:"",message:"最多上传5个文件",type:"warning"})},N=({name:e})=>{var t;const a=u.value.find(t=>t.name===e);a&&(null==(t=d.value)||t.handleRemove(a))},_=(e,t)=>{u.value=t},b=()=>{var e;const t=null==(e=r.value)?void 0:e.getCurrentValue();f(t)};return{isEmpty:p,fileList:u,activeTag:m,cancelHandler:v,submitHandler:f,changeHandler:()=>{var e,t;p.value=null==(t=null==(e=r.value)?void 0:e.chatState)?void 0:t.isEmpty},handleUploadError:g,handleUploadSuccess:h,handleUploadBefore:y,handleUploadExceed:x,removeFile:N,handleUploadRemove:_,submitBtnClick:b,getSlots:()=>{const r={"action-list":()=>e.createVNode("div",{class:"sender-action-wrapper"},[e.createVNode("div",{class:"sender-action-left"},[e.createVNode(n.ElUpload,{ref:"fileUpload",disabled:u.value.length>5,action:a.actionUrl,"show-file-list":!1,multiple:!0,limit:a.limit-u.value.length,data:a.extendData,beforeUpload:y,headers:a.headers,onError:g,onSuccess:h,onExceed:x,onRemove:_,accept:a.acceptFileType},{default:()=>[e.createVNode(n.ElIcon,{class:"sender-file-icon"},{default:()=>[e.createVNode(l.Paperclip,null,null)]})]}),a.sceneList.length>0?e.createVNode(e.Fragment,null,[e.createVNode("div",{class:"split-line"},null),e.createVNode("div",{class:"scene-list"},[a.sceneList.map(t=>e.createVNode("span",{class:c.value.id===t.id?"scene-item active":"scene-item",onClick:()=>{return e=t,c.value=e,s("sceneChange",e),void s("update:scene",e.id);var e}},[t.name]))])]):null]),a.loading?e.createVNode(i,{class:"sender-cancel",onCancel:v},null):e.createVNode("div",{class:{"sender-btn":!0,active:!p.value},onClick:b},null)])};return(u.value.length>0||a.tagList.length>0)&&(r.header=()=>e.createVNode("div",{class:"sender-header-wrapper"},[e.createVNode("div",{class:"sender-file-list"},[u.value.map(a=>e.createVNode(t.FilesCard,{name:a.name,"show-del-icon":!0,status:"done",onDelete:N},null))]),e.createVNode("div",{class:"tag-list-wrapper"},[a.tagList.map(t=>e.createVNode("span",{class:m.value.id===t.id?"tag-item active":"tag-item",onClick:()=>{m.value=t}},[t.name]))])])),r}}},render(){let t;return e.createVNode("div",{class:"editor-sender-wrapper",ref:"editorSenderWrapper"},[e.createVNode(a,{ref:"editorSender",variant:"updown",loading:this.loading,placeholder:this.placeholder,activeTag:this.activeTag,onSubmit:this.submitHandler,onCancel:this.cancelHandler,onChange:this.changeHandler,"custom-style":this.customStyle},(l=t=this.getSlots(),"function"==typeof l||"[object Object]"===Object.prototype.toString.call(l)&&!e.isVNode(l)?t:{default:()=>[t]}))]);var l}});module.exports=s;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/editor-sender/index.tsx"],"sourcesContent":["import { defineComponent, ref, computed, useTemplateRef, watch, nextTick } from 'vue';\nimport { FilesCard } from 'vue-element-plus-x';\nimport EditorSender from './source/index.vue';\nimport { Paperclip } from '@element-plus/icons-vue'\nimport { ElIcon, ElUpload, ElNotification, UploadFiles, ElButton, ElTag } from 'element-plus'\nimport LoadingBtn from './LoadingButton/index.vue'\n\nimport './style/index.less'\nimport { SubmitResult, TagInfo } from 'vue-element-plus-x/types/EditorSender';\nimport { FilesCardProps } from 'vue-element-plus-x/types/FilesCard';\n\nexport default defineComponent({\n props: {\n loading: {\n type: Boolean,\n default: false,\n },\n actionUrl: {\n type: String,\n default: '/openapi/v1/app/files/upload',\n },\n extendData: {\n type: Object,\n default: () => ({\n \"user\": \"abc-123\",\n }),\n },\n acceptFileType: {\n type: String,\n default: '.txt,.md,.mdx,.markdown,.pdf,.html,.xlsx,.xls,.doc,.docx,.csv,.eml,.msg,.pptx,.ppt,.xml,.epub,.jpg,.jpeg,.png,.gif,.webp,.svg'\n },\n headers: {\n type: Object,\n default: () => ({\n Authorization: 'Bearer ApiSecretKey_mEKsrCMvxNLzzUUKeQmpzaUZqwZxFyJf',\n appId: '9a673565-d4f6-4382-bc67-f1beb07df435'\n }),\n },\n agentName: {\n type: String,\n default: '知识问答智能体',\n },\n limit: {\n type: Number,\n default: 5,\n },\n customStyle: {\n type: Object,\n default: () => ({\n maxHeight: '75px'\n }),\n },\n inputData: {\n type: String,\n default: '',\n },\n placeholder: {\n type: String,\n default: '请尝试输入任务、问题或想法,我会帮你搞定',\n },\n tagList: {\n type: Array<TagInfo>,\n default: () => ([\n {\n id: '1',\n name: '问产品',\n },\n {\n id: '2',\n name: '问品类',\n },\n {\n id: '3',\n name: '问品牌',\n },\n {\n id: '4',\n name: '找物料',\n },\n {\n id: '5',\n name: '问知识',\n },\n {\n id: '6',\n name: '遇客诉',\n }\n ])\n },\n sceneList: {\n type: Array<{\n id: string,\n name: string,\n }>,\n default: () => ([\n {\n id: 'ANC',\n name: 'ANC',\n },\n {\n id: 'BNC',\n name: 'BNC',\n },\n ])\n },\n },\n emits: ['cancel', 'submit', 'sceneChange'],\n setup(props, { emit }) {\n const editorSender = useTemplateRef<typeof EditorSender>('editorSender');\n const editorSenderWrapper = useTemplateRef<HTMLElement>('editorSenderWrapper');\n const fileUpload = useTemplateRef<typeof ElUpload>('fileUpload');\n const activeScene = ref(props.sceneList[0]);\n\n const isEmpty = ref(true);\n const fileList = ref<UploadFiles>([]);\n const activeTag = ref(props.tagList[0]);\n\n watch(() => props.agentName, (val) => {\n nextTick(() => {\n const target = editorSenderWrapper.value?.querySelector('.el-editor-sender-chat-room');\n target?.setAttribute('datatype', val)\n })\n }, {\n immediate: true\n });\n\n watch(() => props.inputData, (val) => {\n nextTick(() => {\n editorSender.value?.clear() as SubmitResult;\n editorSender.value?.setText(val)\n })\n })\n\n watch(() => props.sceneList, (val) => {\n if (val.length > 0) {\n activeScene.value = val[0];\n }\n }, {\n immediate: true\n });\n\n const cancelHandler = () => {\n emit('cancel')\n }\n\n const initSender = () => {\n editorSender.value?.clear() as SubmitResult;\n fileList.value = [];\n fileUpload.value?.clearFiles();\n }\n\n const submitHandler = (val: SubmitResult) => {\n if (isEmpty.value || props.loading) return;\n const res = {\n text: val.text,\n file: fileList.value.map((item) => item.response)\n }\n emit('submit', res)\n initSender()\n }\n\n const changeHandler = () => {\n isEmpty.value = editorSender.value?.chatState?.isEmpty;\n }\n\n const handleUploadError = () => {\n ElNotification({\n title: '',\n message: '上传文件失败',\n type: 'error',\n })\n }\n\n const handleUploadSuccess = (response, file, list: UploadFiles) => {\n fileList.value = list;\n }\n\n const isValidMimeType = (mimeType: string) => {\n // 包含所有有效MIME类型的集合\n const validTypes = new Set([\n 'text/plain',\n 'text/markdown', // 非标准但常见的markdown类型\n 'application/pdf',\n 'text/html',\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'application/vnd.ms-excel',\n 'application/msword',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'text/csv',\n 'message/rfc822',\n 'application/vnd.ms-outlook',\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n 'application/vnd.ms-powerpoint',\n 'application/xml',\n 'text/xml',\n 'application/epub+zip',\n 'image/jpeg',\n 'image/png',\n 'image/gif',\n 'image/webp',\n 'image/svg+xml'\n ]);\n\n // 去除可能的空格并转为小写后检查\n return validTypes.has(mimeType?.trim().toLowerCase());\n }\n\n const handleUploadBefore = (file: File) => {\n if (!isValidMimeType(file.type)) {\n ElNotification({\n title: '',\n message: '无法解析上传',\n type: 'warning',\n })\n return false;\n }\n const isImg = file.type.includes('image');\n const isDoc = !isImg;\n const isLt15M = file.size / 1024 / 1024 < 15;\n const isLt10M = file.size / 1024 / 1024 < 10;\n if (isDoc && !isLt15M) {\n ElNotification({\n title: '',\n message: '上传文档大小不能超过 15MB!',\n type: 'warning',\n })\n return false;\n }\n if (isImg && !isLt10M) {\n ElNotification({\n title: '',\n message: '上传图片大小不能超过 10MB!',\n type: 'warning',\n })\n return false;\n }\n return true;\n }\n\n const handleUploadExceed = () => {\n ElNotification({\n title: '',\n message: `最多上传5个文件`,\n type: 'warning',\n })\n }\n\n // 删除文件\n const removeFile = ({ name }: FilesCardProps) => {\n const target = fileList.value.find((item) => item.name === name);\n if (target) {\n fileUpload.value?.handleRemove(target);\n }\n }\n\n const handleUploadRemove = (file, files) => {\n fileList.value = files;\n }\n\n const submitBtnClick = () => {\n const context = editorSender.value?.getCurrentValue() as SubmitResult;\n submitHandler(context);\n }\n\n const triggerSceneChange = (scene: {\n id: string,\n name: string,\n }) => {\n activeScene.value = scene;\n emit('sceneChange', scene);\n }\n\n const getSlots = () => {\n const slots = {\n 'action-list': () => (\n <div class=\"sender-action-wrapper\">\n <div class=\"sender-action-left\">\n <ElUpload\n ref=\"fileUpload\"\n disabled={fileList.value.length > 5}\n action={props.actionUrl}\n show-file-list={false}\n multiple\n limit={props.limit - fileList.value.length}\n data={props.extendData}\n beforeUpload={handleUploadBefore}\n headers={props.headers}\n onError={handleUploadError}\n onSuccess={handleUploadSuccess}\n onExceed={handleUploadExceed}\n onRemove={handleUploadRemove}\n accept={props.acceptFileType}\n >\n <ElIcon\n class=\"sender-file-icon\"\n >\n <Paperclip />\n </ElIcon>\n </ElUpload>\n {\n props.sceneList.length > 0 ? (\n <>\n <div class=\"split-line\"></div>\n <div class=\"scene-list\">\n {\n props.sceneList.map((item) => (\n <span \n class={activeScene.value.id === item.id ? 'scene-item active' : 'scene-item'}\n onClick={() => triggerSceneChange(item)}\n >\n {item.name}\n </span>\n ))\n }\n </div>\n </>\n ) : null\n }\n </div>\n {\n props.loading ?\n <LoadingBtn\n class='sender-cancel'\n onCancel={cancelHandler}\n /> :\n <div\n class={{ 'sender-btn': true, 'active': !isEmpty.value }}\n onClick={submitBtnClick}\n >\n </div>\n }\n </div>\n ),\n }\n if (fileList.value.length > 0 || props.tagList.length > 0) {\n slots['header'] = () => {\n return (\n <div class=\"sender-header-wrapper\">\n <div\n class=\"sender-file-list\"\n >\n {\n fileList.value.map((item) => (\n <FilesCard\n name={item.name}\n show-del-icon\n status=\"done\"\n onDelete={removeFile}\n />\n ))\n }\n </div>\n <div class=\"tag-list-wrapper\">\n {\n props.tagList.map((item) => (\n <span\n class={activeTag.value.id === item.id ? 'tag-item active' : 'tag-item'}\n onClick={() => {\n activeTag.value = item;\n }}\n >\n {item.name}\n </span>\n ))\n }\n </div>\n </div>\n )\n }\n }\n\n return slots;\n }\n\n return {\n isEmpty,\n fileList,\n activeTag,\n cancelHandler,\n submitHandler,\n changeHandler,\n handleUploadError,\n handleUploadSuccess,\n handleUploadBefore,\n handleUploadExceed,\n removeFile,\n handleUploadRemove,\n submitBtnClick,\n getSlots,\n };\n },\n\n render() {\n return (\n <div\n class=\"editor-sender-wrapper\"\n ref=\"editorSenderWrapper\"\n >\n <EditorSender\n ref=\"editorSender\"\n variant=\"updown\"\n loading={this.loading}\n placeholder={this.placeholder}\n activeTag={this.activeTag}\n onSubmit={this.submitHandler}\n onCancel={this.cancelHandler}\n onChange={this.changeHandler}\n custom-style={this.customStyle}\n >\n {\n this.getSlots()\n }\n\n </EditorSender>\n </div>\n );\n }\n});\n"],"names":["index","props","loading","type","Boolean","default","actionUrl","String","extendData","Object","user","acceptFileType","headers","Authorization","appId","agentName","limit","Number","customStyle","maxHeight","inputData","placeholder","tagList","Array","id","name","sceneList","emits","setup","emit","editorSender","useTemplateRef","editorSenderWrapper","fileUpload","activeScene","ref","isEmpty","fileList","activeTag","watch","val","nextTick","target","value","querySelector","setAttribute","immediate","clear","setText","length","cancelHandler","submitHandler","res","text","file","map","item","response","initSender","clearFiles","handleUploadError","ElNotification","title","message","handleUploadSuccess","list","handleUploadBefore","mimeType","Set","has","trim","toLowerCase","isImg","includes","isDoc","isLt15M","size","isLt10M","handleUploadExceed","removeFile","find","handleRemove","handleUploadRemove","files","submitBtnClick","context","getCurrentValue","changeHandler","chatState","getSlots","slots","action-list","_createVNode","class","ElUpload","disabled","action","multiple","data","beforeUpload","onError","onSuccess","onExceed","onRemove","accept","ElIcon","Paperclip","_Fragment","onClick","triggerSceneChange","scene","LoadingBtn","onCancel","active","FilesCard","status","onDelete","render","_slot","EditorSender","variant","this","onSubmit","onChange","s","prototype","toString","call","_isVNode"],"mappings":"o6BAWA,MAAAA,oBAA+B,CAC7BC,MAAO,CACLC,QAAS,CACPC,KAAMC,QACNC,SAAS,GAEXC,UAAW,CACTH,KAAMI,OACNF,QAAS,gCAEXG,WAAY,CACVL,KAAMM,OACNJ,QAASA,KAAAA,CACPK,KAAQ,aAGZC,eAAgB,CACdR,KAAMI,OACNF,QAAS,iIAEXO,QAAS,CACPT,KAAMM,OACNJ,QAASA,KAAAA,CACPQ,cAAe,uDACfC,MAAO,0CAGXC,UAAW,CACTZ,KAAMI,OACNF,QAAS,WAEX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pG,YAAWiB,UAClBmF,KAAKnF,UAASoF,SACfD,KAAKtE,cAAa6D,SAClBS,KAAKvE,cAAayE,SAClBF,KAAKlC,cAAa,eACdkC,KAAKvG,cAhZF0G,EAgZaN,EAG5BG,KAAKhC,WAnZU,mBAAAmC,GAAA,oBAAAnH,OAAAoH,UAAAC,SAAAC,KAAAH,KAAAI,EAAAA,QAAAJ,GAmZAN,EAAA,CAAAjH,QAAAA,IAAA,CAAAiH,QAnZA,IAAAM,CAyZzB"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/editor-sender/index.tsx"],"sourcesContent":["import { defineComponent, ref, computed, useTemplateRef, watch, nextTick } from 'vue';\nimport { FilesCard } from 'vue-element-plus-x';\nimport EditorSender from './source/index.vue';\nimport { Paperclip } from '@element-plus/icons-vue'\nimport { ElIcon, ElUpload, ElNotification, UploadFiles, ElButton, ElTag } from 'element-plus'\nimport LoadingBtn from './LoadingButton/index.vue'\n\nimport './style/index.less'\nimport { SubmitResult, TagInfo } from 'vue-element-plus-x/types/EditorSender';\nimport { FilesCardProps } from 'vue-element-plus-x/types/FilesCard';\n\nexport default defineComponent({\n props: {\n loading: {\n type: Boolean,\n default: false,\n },\n actionUrl: {\n type: String,\n default: '/openapi/v1/app/files/upload',\n },\n extendData: {\n type: Object,\n default: () => ({\n \"user\": \"abc-123\",\n }),\n },\n acceptFileType: {\n type: String,\n default: '.txt,.md,.mdx,.markdown,.pdf,.html,.xlsx,.xls,.doc,.docx,.csv,.eml,.msg,.pptx,.ppt,.xml,.epub,.jpg,.jpeg,.png,.gif,.webp,.svg'\n },\n headers: {\n type: Object,\n default: () => ({\n Authorization: 'Bearer ApiSecretKey_mEKsrCMvxNLzzUUKeQmpzaUZqwZxFyJf',\n appId: '9a673565-d4f6-4382-bc67-f1beb07df435'\n }),\n },\n agentName: {\n type: String,\n default: '知识问答智能体',\n },\n limit: {\n type: Number,\n default: 5,\n },\n customStyle: {\n type: Object,\n default: () => ({\n maxHeight: '75px'\n }),\n },\n inputData: {\n type: String,\n default: '',\n },\n placeholder: {\n type: String,\n default: '请尝试输入任务、问题或想法,我会帮你搞定',\n },\n tagList: {\n type: Array<TagInfo>,\n default: () => ([\n {\n id: '1',\n name: '问产品',\n },\n {\n id: '2',\n name: '问品类',\n },\n {\n id: '3',\n name: '问品牌',\n },\n {\n id: '4',\n name: '找物料',\n },\n {\n id: '5',\n name: '问知识',\n },\n {\n id: '6',\n name: '遇客诉',\n }\n ])\n },\n sceneList: {\n type: Array<{\n id: string,\n name: string,\n }>,\n default: () => ([\n {\n id: 'ANC',\n name: 'ANC',\n },\n {\n id: 'BNC',\n name: 'BNC',\n },\n ])\n },\n scene: {\n type: String,\n default: undefined,\n },\n },\n emits: ['cancel', 'submit', 'sceneChange', 'update:scene'],\n setup(props, { emit }) {\n const editorSender = useTemplateRef<typeof EditorSender>('editorSender');\n const editorSenderWrapper = useTemplateRef<HTMLElement>('editorSenderWrapper');\n const fileUpload = useTemplateRef<typeof ElUpload>('fileUpload');\n \n // 初始化 activeScene:优先使用传入的 scene prop,否则使用 sceneList 的第一个\n const getInitialScene = () => {\n if (props.scene) {\n const found = props.sceneList.find(item => item.id === props.scene);\n if (found) return found;\n }\n return props.sceneList[0];\n };\n const activeScene = ref(getInitialScene());\n\n const isEmpty = ref(true);\n const fileList = ref<UploadFiles>([]);\n const activeTag = ref(props.tagList[0]);\n\n watch(() => props.agentName, (val) => {\n nextTick(() => {\n const target = editorSenderWrapper.value?.querySelector('.el-editor-sender-chat-room');\n target?.setAttribute('datatype', val)\n })\n }, {\n immediate: true\n });\n\n watch(() => props.inputData, (val) => {\n nextTick(() => {\n editorSender.value?.clear() as SubmitResult;\n editorSender.value?.setText(val)\n })\n })\n\n // 监听外部传入的 scene prop 变化\n watch(() => props.scene, (val) => {\n if (val) {\n const found = props.sceneList.find(item => item.id === val);\n if (found) {\n activeScene.value = found;\n }\n }\n });\n\n watch(() => props.sceneList, (val) => {\n if (val.length > 0) {\n // 如果当前 scene prop 存在,优先使用它;否则使用第一个\n if (props.scene) {\n const found = val.find(item => item.id === props.scene);\n if (found) {\n activeScene.value = found;\n return;\n }\n }\n activeScene.value = val[0];\n }\n }, {\n immediate: true\n });\n\n const cancelHandler = () => {\n emit('cancel')\n }\n\n const initSender = () => {\n editorSender.value?.clear() as SubmitResult;\n fileList.value = [];\n fileUpload.value?.clearFiles();\n }\n\n const submitHandler = (val: SubmitResult) => {\n if (isEmpty.value || props.loading) return;\n const res = {\n text: val.text,\n file: fileList.value.map((item) => item.response)\n }\n emit('submit', res)\n initSender()\n }\n\n const changeHandler = () => {\n isEmpty.value = editorSender.value?.chatState?.isEmpty;\n }\n\n const handleUploadError = () => {\n ElNotification({\n title: '',\n message: '上传文件失败',\n type: 'error',\n })\n }\n\n const handleUploadSuccess = (response, file, list: UploadFiles) => {\n fileList.value = list;\n }\n\n const isValidMimeType = (mimeType: string) => {\n // 包含所有有效MIME类型的集合\n const validTypes = new Set([\n 'text/plain',\n 'text/markdown', // 非标准但常见的markdown类型\n 'application/pdf',\n 'text/html',\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'application/vnd.ms-excel',\n 'application/msword',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'text/csv',\n 'message/rfc822',\n 'application/vnd.ms-outlook',\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n 'application/vnd.ms-powerpoint',\n 'application/xml',\n 'text/xml',\n 'application/epub+zip',\n 'image/jpeg',\n 'image/png',\n 'image/gif',\n 'image/webp',\n 'image/svg+xml'\n ]);\n\n // 去除可能的空格并转为小写后检查\n return validTypes.has(mimeType?.trim().toLowerCase());\n }\n\n const handleUploadBefore = (file: File) => {\n if (!isValidMimeType(file.type)) {\n ElNotification({\n title: '',\n message: '无法解析上传',\n type: 'warning',\n })\n return false;\n }\n const isImg = file.type.includes('image');\n const isDoc = !isImg;\n const isLt15M = file.size / 1024 / 1024 < 15;\n const isLt10M = file.size / 1024 / 1024 < 10;\n if (isDoc && !isLt15M) {\n ElNotification({\n title: '',\n message: '上传文档大小不能超过 15MB!',\n type: 'warning',\n })\n return false;\n }\n if (isImg && !isLt10M) {\n ElNotification({\n title: '',\n message: '上传图片大小不能超过 10MB!',\n type: 'warning',\n })\n return false;\n }\n return true;\n }\n\n const handleUploadExceed = () => {\n ElNotification({\n title: '',\n message: `最多上传5个文件`,\n type: 'warning',\n })\n }\n\n // 删除文件\n const removeFile = ({ name }: FilesCardProps) => {\n const target = fileList.value.find((item) => item.name === name);\n if (target) {\n fileUpload.value?.handleRemove(target);\n }\n }\n\n const handleUploadRemove = (file, files) => {\n fileList.value = files;\n }\n\n const submitBtnClick = () => {\n const context = editorSender.value?.getCurrentValue() as SubmitResult;\n submitHandler(context);\n }\n\n const triggerSceneChange = (scene: {\n id: string,\n name: string,\n }) => {\n activeScene.value = scene;\n emit('sceneChange', scene);\n emit('update:scene', scene.id);\n }\n\n const getSlots = () => {\n const slots = {\n 'action-list': () => (\n <div class=\"sender-action-wrapper\">\n <div class=\"sender-action-left\">\n <ElUpload\n ref=\"fileUpload\"\n disabled={fileList.value.length > 5}\n action={props.actionUrl}\n show-file-list={false}\n multiple\n limit={props.limit - fileList.value.length}\n data={props.extendData}\n beforeUpload={handleUploadBefore}\n headers={props.headers}\n onError={handleUploadError}\n onSuccess={handleUploadSuccess}\n onExceed={handleUploadExceed}\n onRemove={handleUploadRemove}\n accept={props.acceptFileType}\n >\n <ElIcon\n class=\"sender-file-icon\"\n >\n <Paperclip />\n </ElIcon>\n </ElUpload>\n {\n props.sceneList.length > 0 ? (\n <>\n <div class=\"split-line\"></div>\n <div class=\"scene-list\">\n {\n props.sceneList.map((item) => (\n <span \n class={activeScene.value.id === item.id ? 'scene-item active' : 'scene-item'}\n onClick={() => triggerSceneChange(item)}\n >\n {item.name}\n </span>\n ))\n }\n </div>\n </>\n ) : null\n }\n </div>\n {\n props.loading ?\n <LoadingBtn\n class='sender-cancel'\n onCancel={cancelHandler}\n /> :\n <div\n class={{ 'sender-btn': true, 'active': !isEmpty.value }}\n onClick={submitBtnClick}\n >\n </div>\n }\n </div>\n ),\n }\n if (fileList.value.length > 0 || props.tagList.length > 0) {\n slots['header'] = () => {\n return (\n <div class=\"sender-header-wrapper\">\n <div\n class=\"sender-file-list\"\n >\n {\n fileList.value.map((item) => (\n <FilesCard\n name={item.name}\n show-del-icon\n status=\"done\"\n onDelete={removeFile}\n />\n ))\n }\n </div>\n <div class=\"tag-list-wrapper\">\n {\n props.tagList.map((item) => (\n <span\n class={activeTag.value.id === item.id ? 'tag-item active' : 'tag-item'}\n onClick={() => {\n activeTag.value = item;\n }}\n >\n {item.name}\n </span>\n ))\n }\n </div>\n </div>\n )\n }\n }\n\n return slots;\n }\n\n return {\n isEmpty,\n fileList,\n activeTag,\n cancelHandler,\n submitHandler,\n changeHandler,\n handleUploadError,\n handleUploadSuccess,\n handleUploadBefore,\n handleUploadExceed,\n removeFile,\n handleUploadRemove,\n submitBtnClick,\n getSlots,\n };\n },\n\n render() {\n return (\n <div\n class=\"editor-sender-wrapper\"\n ref=\"editorSenderWrapper\"\n >\n <EditorSender\n ref=\"editorSender\"\n variant=\"updown\"\n loading={this.loading}\n placeholder={this.placeholder}\n activeTag={this.activeTag}\n onSubmit={this.submitHandler}\n onCancel={this.cancelHandler}\n onChange={this.changeHandler}\n custom-style={this.customStyle}\n >\n {\n this.getSlots()\n }\n\n </EditorSender>\n </div>\n );\n }\n});\n"],"names":["index","props","loading","type","Boolean","default","actionUrl","String","extendData","Object","user","acceptFileType","headers","Authorization","appId","agentName","limit","Number","customStyle","maxHeight","inputData","placeholder","tagList","Array","id","name","sceneList","scene","undefined","emits","setup","emit","editorSender","useTemplateRef","editorSenderWrapper","fileUpload","activeScene","ref","getInitialScene","found","find","item","isEmpty","fileList","activeTag","watch","val","nextTick","target","value","querySelector","setAttribute","immediate","clear","setText","length","cancelHandler","submitHandler","res","text","file","map","response","initSender","clearFiles","handleUploadError","ElNotification","title","message","handleUploadSuccess","list","handleUploadBefore","mimeType","Set","has","trim","toLowerCase","isImg","includes","isDoc","isLt15M","size","isLt10M","handleUploadExceed","removeFile","handleRemove","handleUploadRemove","files","submitBtnClick","context","getCurrentValue","changeHandler","chatState","getSlots","slots","action-list","_createVNode","class","ElUpload","disabled","action","multiple","data","beforeUpload","onError","onSuccess","onExceed","onRemove","accept","ElIcon","Paperclip","_Fragment","onClick","triggerSceneChange","LoadingBtn","onCancel","active","FilesCard","status","onDelete","render","_slot","EditorSender","variant","this","onSubmit","onChange","s","prototype","toString","call","_isVNode"],"mappings":"o6BAWA,MAAAA,oBAA+B,CAC7BC,MAAO,CACLC,QAAS,CACPC,KAAMC,QACNC,SAAS,GAEXC,UAAW,CACTH,KAAMI,OACNF,QAAS,gCAEXG,WAAY,CACVL,KAAMM,OACNJ,QAASA,KAAAA,CACPK,KAAQ,aAGZC,eAAgB,CACdR,KAAMI,OACNF,QAAS,iIAEXO,QAAS,CACPT,KAAMM,OACNJ,QAASA,KAAAA,CACPQ,cAAe,uDACfC,MAAO,0CAGXC,UAAW,CACTZ,KAAMI,OACNF,QAAS,WAEXW,MAAO,CACLb,KAAMc,OACNZ,QAAS,GAEXa,YAAa,CACXf,KAAMM,OACNJ,QAASA,KAAAA,CACPc,UAAW,UAGfC,UAAW,CACTjB,KAAMI,OACNF,QAAS,IAEXgB,YAAa,CACXlB,KAAMI,OACNF,QAAS,wBAEXiB,QAAS,CACPnB,KAAMoB,MACNlB,QAASA,IAAO,CACd,CACEmB,GAAI,IACJC,KAAM,OAER,CACED,GAAI,IACJC,KAAM,OAER,CACED,GAAI,IACJC,KAAM,OAER,CACED,GAAI,IACJC,KAAM,OAER,CACED,GAAI,IACJC,KAAM,OAER,CACED,GAAI,IACJC,KAAM,SAIZC,UAAW,CACTvB,KAAMoB,MAINlB,QAASA,IAAO,CACd,CACEmB,GAAI,MACJC,KAAM,OAER,CACED,GAAI,MACJC,KAAM,SAIZE,MAAO,CACLxB,KAAMI,OACNF,aAASuB,IAG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YACRuG,KAAKvG,YAAWuB,UAClBgF,KAAKhF,UAASiF,SACfD,KAAKnE,cAAa0D,SAClBS,KAAKpE,cAAasE,SAClBF,KAAKjC,cAAa,eACdiC,KAAK1G,cAhbF6G,EAgbaN,EAG5BG,KAAK/B,WAnbU,mBAAAkC,GAAA,oBAAAtH,OAAAuH,UAAAC,SAAAC,KAAAH,KAAAI,EAAAA,QAAAJ,GAmbAN,EAAA,CAAApH,QAAAA,IAAA,CAAAoH,QAnbA,IAAAM,CAybzB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./bubble-list/index.js"),r=require("./x-markdown/index.js"),i=require("./file-preview/index.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./bubble-list/index.js"),r=require("./x-markdown/index.js"),i=require("./file-preview/index.js"),o=require("./editor-sender/index.js"),s=require("./file-card/index.js"),t=require("./core-text/index.js"),x=require("./core-tips/index.js"),d=require("./core-result/index.js"),n=require("./core-table/index.js"),u=require("./core-chart/index.js"),p=require("./core-card/index.js");exports.BubbleList=e,exports.XMarkdown=r,exports.FilePreview=i,exports.EditorSender=o,exports.FileCard=s,exports.CoreText=t,exports.CoreTips=x,exports.CoreResult=d,exports.CoreTable=n,exports.CoreChart=u,exports.CoreCard=p;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const e=require("vue"),r=require("../../_virtual/debounce.js"),t=require("../../node_modules/.pnpm/@vueuse_core@14.0.0_vue@3.5.24_typescript@5.6.3_/node_modules/@vueuse/core/dist/index.js"),l=require("element-plus");/* empty css *//* empty css *//* empty css *//* empty css */require("../../node_modules/.pnpm/element-plus@2.11.8_vue@3.5.24_typescript@5.6.3_/node_modules/element-plus/theme-chalk/src/form-item.scss.js"),/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */require("../../node_modules/.pnpm/element-plus@2.11.8_vue@3.5.24_typescript@5.6.3_/node_modules/element-plus/theme-chalk/src/date-picker.scss.js"),/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */require("../../node_modules/.pnpm/element-plus@2.11.8_vue@3.5.24_typescript@5.6.3_/node_modules/element-plus/theme-chalk/src/config-provider.scss.js"),/* empty css */;/* empty css */const s=require("./utils/mockStream.js"),n=require("./utils/parseCorePilotSchema.js"),o=require("./utils/animation.js"),i=require("../core-text/index.js"),a=require("../core-tips/index.js"),u=require("../core-result/index.js"),d=require("../core-table/index.js"),p=require("../core-chart/index.js");;/* empty css */const m=require("../../node_modules/.pnpm/element-plus@2.11.8_vue@3.5.24_typescript@5.6.3_/node_modules/element-plus/es/locale/lang/zh-cn.js"),c=require("../../node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.js"),v=require("../../node_modules/.pnpm/remark-parse@11.0.0/node_modules/remark-parse/lib/index.js"),h=require("../../node_modules/.pnpm/remark-breaks@4.0.0/node_modules/remark-breaks/lib/index.js"),_=require("../../node_modules/.pnpm/remark-gfm@4.0.1/node_modules/remark-gfm/lib/index.js"),f=require("../../node_modules/.pnpm/remark-math@6.0.0/node_modules/remark-math/lib/index.js"),g=require("../../node_modules/.pnpm/remark-gemoji@8.0.0/node_modules/remark-gemoji/lib/index.js"),y=require("../../node_modules/.pnpm/remark-rehype@11.1.2/node_modules/remark-rehype/lib/index.js"),k=require("../../node_modules/.pnpm/rehype-raw@7.0.0/node_modules/rehype-raw/lib/index.js"),b=require("../../node_modules/.pnpm/rehype-katex@7.0.1/node_modules/rehype-katex/lib/index.js"),x=require("../../node_modules/.pnpm/rehype-stringify@10.0.1/node_modules/rehype-stringify/lib/index.js"),q=e.defineComponent({name:"XMarkdown",props:{text:{type:String,default:""},autoHideThinking:{type:Boolean,default:!0},typing:{type:Boolean,default:!1},speed:{type:Number,default:200},isHistoryMessage:{type:Boolean,default:!1}},expose:["getContentText"],emits:["hoverActiveRefTrigger","clickActiveRefTrigger","refConfigUpdate","downloadFile","coreSubmit"],setup(q,{emit:j}){const E=e.useTemplateRef("x-markdown-container"),N=e.ref(Date.now()),w=e.ref(-1/0),A=e.ref(""),C=new Set,S=e.ref(!1),T=e.ref(!1),P=e.ref([]),L=t.useTemplateRefsList(),R=e.ref(0);let F=0;const V=e.ref(null),$=e.ref(s.createStreamGenerator(e=>{A.value=A.value+e},q.speed)),D=e.computed(()=>{if(!q.autoHideThinking)return A.value;let e=A.value;if(e=(e=>{let r=!0;return e.replace(/(<summary[^>]*>[\s\S]*?<\/summary>)\s*(<div>[\s\S]*?)(<\/div>|$)/g,(e,t,l,s)=>{const n="</div>"===s;return`${t.replace(/(<summary)/g,e=>r?(r=!1,e):`<summary class="${n?"loaded":"loading"}"`)}\n${l}${s}`})})(e),e=e.replace(/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g," "),e.includes("</details>")){w.value===-1/0&&(w.value=Date.now());const r=(e=>{const r=/<div hidden>([\s\S]*?)<\/div>/g.exec(e);if(!r)return[];const t=r[1];try{return JSON.parse(t)}catch(l){return[]}})(e);return e.replace(/<details open>([\s\S]*?)<\/details>/g,(e,t)=>`<details>${t=(t=t.replace(/<summary>([\s\S]*?)<\/summary>/,(e,t)=>{const l=((w.value-N.value)/1e3).toFixed(0);return`<summary style="color: #8D90A0;font-weight: 300; font-size: 16px;">\n 已完成思考 ${l>"0"?l+"s":""} ${r.length?`<span style="display: inline-block;margin: 0 8px;border-left: 1px solid #CDCFD7;width: 1px;height: 16px;"></span> 引用文档:${null==r?void 0:r.length} 个`:""}\n </summary>`})).replace(/<summary>完成<\/summary>/,'<summary class="loaded">完成</summary>')}</details>`)}return e}),H=e.computed(()=>q.isHistoryMessage);e.watch(()=>[q.text,q.typing],(e,r)=>{var t,l,s,n;const[o,i]=e,[a]=r||[];if(o.startsWith(a)||(null==(t=$.value)||t.reset(),A.value=""),o){if(null==(l=$.value)||l.update(o),!i)return void(null==(s=$.value)||s.stop());const e=/<summary>资料整合<\/summary>\r?\n(.|\s)+?/;if(!T.value&&e.test(o))return T.value=!0,void(null==(n=$.value)||n.setSpeed(500))}},{immediate:!0});const U=e.ref([]),B=r(()=>{(()=>{var e;const r=null==(e=E.value)?void 0:e.querySelector("div[hidden]");U.value=JSON.parse((null==r?void 0:r.textContent)||"[]"),j("refConfigUpdate",U.value)})()},100),M=e.ref(null);e.watch(()=>A.value,B,{immediate:!0}),e.watch(M,(e,r)=>{if(e!==r)if(e){const r=e.getAttribute("dataherf"),t=U.value.find(e=>e.link===r);j("hoverActiveRefTrigger",t)}else j("hoverActiveRefTrigger","")});const W=e=>{const r=e.target;if("SPAN"===r.tagName){const e=r.classList.contains("x-markdown-split"),t=r.classList.contains("x-markdown-sub");if(e||t)return t?r:r.parentElement}},I=e=>{const r=W(e);M.value=r||null},J=e=>{if("A"===e.target.tagName)return void(async e=>{e.stopPropagation(),e.preventDefault();const r=e.target,t=r.getAttribute("href"),s=r.getAttribute("data-id")||r.getAttribute("dataid"),n=r.getAttribute("data-name")||r.getAttribute("dataname");if(!t)return;const o=t.split(".").pop();s?(l.ElMessage("文件下载中..."),j("downloadFile",{title:n,id:s,ext:o,href:t})):window.open(t,"_blank")})(e);const r=W(e);if(r){const e=r.getAttribute("dataherf"),t=JSON.parse(r.getAttribute("datahighlight")||"[]"),l=Number(r.getAttribute("datanumber")),s=r.getAttribute("id"),n={...U.value.find(r=>r.link===e),highlight:t,page:l,id:s};j("clickActiveRefTrigger",n)}};e.onMounted(()=>{E.value.addEventListener("mouseover",I),E.value.addEventListener("click",J)}),e.onBeforeUnmount(()=>{E.value.removeEventListener("mouseover",I),E.value.addEventListener("click",J)});const O=()=>{if(!E.value)return;E.value.querySelectorAll("img:not([data-processed='true'])").forEach(e=>{C.has(e)||(C.add(e),G(e),e.complete?z(e):(e.addEventListener("load",()=>z(e)),e.addEventListener("error",()=>X(e))))})},G=e=>{const r=e.parentElement.offsetWidth;if(e.naturalWidth>r&&(e.style.maxWidth="100%"),e.naturalWidth&&e.naturalHeight){const t=e.naturalHeight/e.naturalWidth;e.style.maxHeight=`${Math.min(500,r*t)}px`}},z=e=>{C.delete(e),e.setAttribute("data-processed","true"),e.classList.add("loaded"),e.style.opacity="1",e.removeEventListener("load",z),e.removeEventListener("error",X)},X=e=>{C.delete(e),e.setAttribute("data-processed","true"),e.classList.add("load-error"),e.style.maxHeight="200px",e.removeEventListener("load",z),e.removeEventListener("error",X)},K=c.unified().use(v).use(h).use(_,{singleTilde:!1}).use(f).use(g).use(y,{allowDangerousHtml:!0}).use(k).use(b).use(x),Q=(e,r)=>{var t;if(e&&"object"==typeof e){if("form"===e.type){const l=(null==(t=e.properties)?void 0:t.data)||{};return void r.push(l)}Array.isArray(e.children)&&e.children.forEach(e=>{Q(e,r)})}};e.watch(()=>D.value,async r=>{F=0;const t=await K.run(K.parse(r)),l=(e=>{const r=[],t=[],l=e=>{e&&("pre"===e.tagName&&t.push(e),Array.isArray(e.children)&&e.children.forEach(l))};return Array.isArray(e.children)&&e.children.forEach(l),t.forEach(e=>{var t,l,s,n,o;const i=null==(t=e.children)?void 0:t.find(e=>"code"===e.tagName);if(null==(s=null==(l=null==i?void 0:i.properties)?void 0:l.className)?void 0:s.includes("language-CorePilot"))try{const e=(null==(o=null==(n=i.children)?void 0:n[0])?void 0:o.value)||"";if(e){const t=JSON.parse(e);Q(t,r)}}catch(a){console.error("Failed to parse CorePilot schema:",a)}}),r})(t);P.value=l,await e.nextTick(),V.value=t,e.nextTick(O),e.nextTick(()=>{var e;const r=null==(e=E.value)?void 0:e.querySelector("details");(null==r?void 0:r.querySelector("summary"))&&!S.value&&(S.value=!0,new o.Accordion(r))})},{immediate:!0});const Y=(r,t,s)=>{var o,c,v,h,_,f,g,y,k,b,x,q,E,N,w,A,C,S,T,V,$;if(!r)return null;let D=[];switch(["sub","pre","text","ElForm"].includes(r.tagName)||(D=(null==(c=null==(o=r.children)?void 0:o.map)?void 0:c.call(o,e=>Y(e,t)))||[]),r.type){case"root":return e.h("div",{class:"markdown-body"},e.h(l.ElConfigProvider,{locale:m},D));case"element":if("sub"===r.tagName){const l=[{type:"element",tagName:"span",properties:{class:"x-markdown-split"}},...r.children],s=null==l?void 0:l.map(e=>Y(e,t));return e.h("span",{...r.properties,class:"x-markdown-sub"},s)}if("span"===r.tagName)return e.h("span",{...r.properties},D);if("img"===r.tagName)return e.h("img",{...r.properties,class:"markdown-image","data-processed":"false"});if("a"===r.tagName){const t=(null==(v=r.properties)?void 0:v.href)||"",l=t?t.split(".").pop():null;return e.h("a",{...r.properties,class:"file-link","data-file-type":l},D)}if("ElTimeline"===r.tagName)return e.h(l.ElTimeline,{...r.properties},D);if("table"===r.tagName)return e.h("div",{class:"custom-table-container"},[e.h("table",D)]);if("view"===r.tagName)return e.h("div",{class:"custom-view-container"},[D[R.value]]);if("ElRow"===r.tagName)return e.h(l.ElRow,{...r.properties},D);if("ElCol"===r.tagName)return e.h(l.ElCol,{...r.properties},D);if("ElCard"===r.tagName)return e.h(l.ElCard,{...r.properties},D);if("ElForm"===r.tagName){const s=null==(h=r.children)?void 0:h.map(e=>Y(e,F));return F++,e.h(l.ElForm,{ref:L.value.set,model:P.value[t],...r.properties,disabled:(null==(_=r.properties)?void 0:_.disabled)||H.value},s)}if("ElFormItem"===r.tagName)return e.h(l.ElFormItem,{...r.properties},D);if("ElButton"===r.tagName){let n=null==(f=r.properties)?void 0:f.payload;return"table"===r.parentScope&&(n=s),e.h(l.ElButton,{...r.properties,disabled:(null==(g=r.properties)?void 0:g.disabled)||H.value,onClick:()=>{var e;(async(e,r,t,l)=>{var s;if("inner_next"===r)return void(R.value+=1);if("inner_prev"===r)return void(R.value-=1);let n={action:r,payload:{}};t&&"form"!==l?n={action:r,payload:t}:(await(null==(s=L.value[e])?void 0:s.validate()),n={action:r,payload:{...P.value[e],...t}}),j("coreSubmit",n)})(t,null==(e=r.properties)?void 0:e.action,n,r.parentScope)}},D)}if("ElSelect"===r.tagName)return e.h(l.ElSelect,{...r.properties,disabled:(null==(y=r.properties)?void 0:y.disabled)||H.value,modelValue:P.value[t][null==(k=r.properties)?void 0:k.formProp],"onUpdate:modelValue":e=>{var l;P.value[t][null==(l=r.properties)?void 0:l.formProp]=e}},D);if("ElDatePicker"===r.tagName)return e.h(l.ElDatePicker,{...r.properties,disabled:(null==(b=r.properties)?void 0:b.disabled)||H.value,modelValue:P.value[t][null==(x=r.properties)?void 0:x.formProp],"onUpdate:modelValue":e=>{var l;P.value[t][null==(l=r.properties)?void 0:l.formProp]=e}},D);if("ElInput"===r.tagName)return e.h(l.ElInput,{...r.properties,disabled:(null==(q=r.properties)?void 0:q.disabled)||H.value,modelValue:P.value[t][null==(E=r.properties)?void 0:E.formProp],"onUpdate:modelValue":e=>{var l;P.value[t][null==(l=r.properties)?void 0:l.formProp]=e}},D);if("ElRadioGroup"===r.tagName)return e.h(l.ElRadioGroup,{...r.properties,disabled:(null==(N=r.properties)?void 0:N.disabled)||H.value,modelValue:P.value[t][null==(w=r.properties)?void 0:w.formProp],"onUpdate:modelValue":e=>{var l;P.value[t][null==(l=r.properties)?void 0:l.formProp]=e}},D);if("ElRadio"===r.tagName)return e.h(l.ElRadio,{...r.properties,disabled:(null==(A=r.properties)?void 0:A.disabled)||H.value},D);if("ElTable"===r.tagName)return e.h(d,{...r.properties},D);if("ElTableColumn"===r.tagName)return e.h(l.ElTableColumn,{...r.properties},{default:e=>{var t,l;const s=null==(t=r.children)?void 0:t.map(r=>Y(r,F,e.row)),n=null==(l=r.children)?void 0:l.findIndex(t=>{var l;return t.value===e.row[null==(l=r.properties)?void 0:l.prop]});return-1===n?s:null==s?void 0:s[n]}});if("CoreText"===r.tagName)return e.h(i,{...r.properties});if("CoreTips"===r.tagName)return e.h(a,{...r.properties});if("CoreResult"===r.tagName)return e.h(u,{...r.properties});if("CoreChart"===r.tagName)return e.h(p,{...r.properties});if("pre"===r.tagName){const t=null==(C=r.children)?void 0:C.find(e=>"code"===e.tagName);if(t&&(null==(T=null==(S=t.properties)?void 0:S.className)?void 0:T.includes("language-CorePilot"))){const r=(null==($=null==(V=t.children)?void 0:V[0])?void 0:$.value)||"";try{const t=JSON.parse(r),l=n.parseCorePilot(t),s=Y(l,F);return e.h("div",{class:"hitl-wrapper"},[s])}catch(U){return null}}}return e.h(r.tagName,r.properties,D);case"text":return r.value.trim();default:return null}};return e.onUpdated(()=>{F=0}),{hastToVNode:Y,ast:V,container:E,renderComplete:B,getContentText:()=>{var e;return null==(e=E.value)?void 0:e.innerText}}},render(){return e.createVNode("div",{ref:"x-markdown-container",class:"x-markdown"},[this.hastToVNode(this.ast)])}});module.exports=q;
|
|
1
|
+
"use strict";const e=require("vue"),r=require("../../_virtual/debounce.js"),t=require("../../node_modules/.pnpm/@vueuse_core@14.0.0_vue@3.5.24_typescript@5.6.3_/node_modules/@vueuse/core/dist/index.js"),s=require("element-plus");/* empty css *//* empty css *//* empty css *//* empty css */require("../../node_modules/.pnpm/element-plus@2.11.8_vue@3.5.24_typescript@5.6.3_/node_modules/element-plus/theme-chalk/src/form-item.scss.js"),/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */require("../../node_modules/.pnpm/element-plus@2.11.8_vue@3.5.24_typescript@5.6.3_/node_modules/element-plus/theme-chalk/src/date-picker.scss.js"),/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */require("../../node_modules/.pnpm/element-plus@2.11.8_vue@3.5.24_typescript@5.6.3_/node_modules/element-plus/theme-chalk/src/config-provider.scss.js"),/* empty css */;/* empty css */const l=require("./utils/mockStream.js"),n=require("./utils/parseCorePilotSchema.js"),o=require("./utils/animation.js"),i=require("../core-text/index.js"),a=require("../core-tips/index.js"),u=require("../core-result/index.js"),d=require("../core-table/index.js"),p=require("../core-chart/index.js"),m=require("../core-card/index.js");;/* empty css */const c=require("../../node_modules/.pnpm/element-plus@2.11.8_vue@3.5.24_typescript@5.6.3_/node_modules/element-plus/es/locale/lang/zh-cn.js"),v=require("../../node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.js"),h=require("../../node_modules/.pnpm/remark-parse@11.0.0/node_modules/remark-parse/lib/index.js"),_=require("../../node_modules/.pnpm/remark-breaks@4.0.0/node_modules/remark-breaks/lib/index.js"),f=require("../../node_modules/.pnpm/remark-gfm@4.0.1/node_modules/remark-gfm/lib/index.js"),g=require("../../node_modules/.pnpm/remark-math@6.0.0/node_modules/remark-math/lib/index.js"),y=require("../../node_modules/.pnpm/remark-gemoji@8.0.0/node_modules/remark-gemoji/lib/index.js"),k=require("../../node_modules/.pnpm/remark-rehype@11.1.2/node_modules/remark-rehype/lib/index.js"),b=require("../../node_modules/.pnpm/rehype-raw@7.0.0/node_modules/rehype-raw/lib/index.js"),x=require("../../node_modules/.pnpm/rehype-katex@7.0.1/node_modules/rehype-katex/lib/index.js"),q=require("../../node_modules/.pnpm/rehype-stringify@10.0.1/node_modules/rehype-stringify/lib/index.js"),j=e.defineComponent({name:"XMarkdown",props:{text:{type:String,default:""},autoHideThinking:{type:Boolean,default:!0},typing:{type:Boolean,default:!1},speed:{type:Number,default:200},isHistoryMessage:{type:Boolean,default:!1},historyInputs:{type:Object,default:()=>({})}},expose:["getContentText"],emits:["hoverActiveRefTrigger","clickActiveRefTrigger","refConfigUpdate","downloadFile","coreSubmit"],setup(j,{emit:N}){const E=e.useTemplateRef("x-markdown-container"),w=e.ref(Date.now()),A=e.ref(-1/0),C=e.ref(""),S=new Set,T=e.ref(!1),P=e.ref(!1),R=e.ref([]),L=t.useTemplateRefsList(),F=e.ref(0);let V=0;const $=e.ref(null),D=e.ref(!1),H=e.ref(l.createStreamGenerator(e=>{C.value=C.value+e},j.speed)),U=e.computed(()=>{if(!j.autoHideThinking)return C.value;let e=C.value;if(e=(e=>{let r=!0;return e.replace(/(<summary[^>]*>[\s\S]*?<\/summary>)\s*(<div>[\s\S]*?)(<\/div>|$)/g,(e,t,s,l)=>{const n="</div>"===l;return`${t.replace(/(<summary)/g,e=>r?(r=!1,e):`<summary class="${n?"loaded":"loading"}"`)}\n${s}${l}`})})(e),e=e.replace(/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g," "),e.includes("</details>")){A.value===-1/0&&(A.value=Date.now());const r=(e=>{const r=/<div hidden>([\s\S]*?)<\/div>/g.exec(e);if(!r)return[];const t=r[1];try{return JSON.parse(t)}catch(s){return[]}})(e);return e.replace(/<details open>([\s\S]*?)<\/details>/g,(e,t)=>`<details>${t=(t=t.replace(/<summary>([\s\S]*?)<\/summary>/,(e,t)=>{const s=((A.value-w.value)/1e3).toFixed(0);return`<summary style="color: #8D90A0;font-weight: 300; font-size: 16px;">\n 已完成思考 ${s>"0"?s+"s":""} ${r.length?`<span style="display: inline-block;margin: 0 8px;border-left: 1px solid #CDCFD7;width: 1px;height: 16px;"></span> 引用文档:${null==r?void 0:r.length} 个`:""}\n </summary>`})).replace(/<summary>完成<\/summary>/,'<summary class="loaded">完成</summary>')}</details>`)}return e}),I=e=>{const{properties:r={},parentScope:t}=e,{disabled:s}=r;return!!s||"form"===t&&(j.isHistoryMessage&&!D.value)};e.watch(()=>[j.text,j.typing],(e,r)=>{var t,s,l,n;const[o,i]=e,[a]=r||[];if(o.startsWith(a)||(null==(t=H.value)||t.reset(),C.value=""),o){if(null==(s=H.value)||s.update(o),!i)return void(null==(l=H.value)||l.stop());const e=/<summary>资料整合<\/summary>\r?\n(.|\s)+?/;if(!P.value&&e.test(o))return P.value=!0,void(null==(n=H.value)||n.setSpeed(500))}},{immediate:!0});const O=e.ref([]),W=r(()=>{(()=>{var e;const r=null==(e=E.value)?void 0:e.querySelector("div[hidden]");O.value=JSON.parse((null==r?void 0:r.textContent)||"[]"),N("refConfigUpdate",O.value)})()},100),B=e.ref(null);e.watch(()=>C.value,W,{immediate:!0}),e.watch(B,(e,r)=>{if(e!==r)if(e){const r=e.getAttribute("dataherf"),t=O.value.find(e=>e.link===r);N("hoverActiveRefTrigger",t)}else N("hoverActiveRefTrigger","")});const J=e=>{const r=e.target;if("SPAN"===r.tagName){const e=r.classList.contains("x-markdown-split"),t=r.classList.contains("x-markdown-sub");if(e||t)return t?r:r.parentElement}},M=e=>{const r=J(e);B.value=r||null},G=e=>{if("A"===e.target.tagName)return void(async e=>{e.stopPropagation(),e.preventDefault();const r=e.target,t=r.getAttribute("href"),l=r.getAttribute("data-id")||r.getAttribute("dataid"),n=r.getAttribute("data-name")||r.getAttribute("dataname");if(!t)return;const o=t.split(".").pop();l?(s.ElMessage("文件下载中..."),N("downloadFile",{title:n,id:l,ext:o,href:t})):window.open(t,"_blank")})(e);const r=J(e);if(r){const e=r.getAttribute("dataherf"),t=JSON.parse(r.getAttribute("datahighlight")||"[]"),s=Number(r.getAttribute("datanumber")),l=r.getAttribute("id"),n={...O.value.find(r=>r.link===e),highlight:t,page:s,id:l};N("clickActiveRefTrigger",n)}};e.onMounted(()=>{E.value.addEventListener("mouseover",M),E.value.addEventListener("click",G)}),e.onBeforeUnmount(()=>{E.value.removeEventListener("mouseover",M),E.value.addEventListener("click",G)});const z=()=>{if(!E.value)return;E.value.querySelectorAll("img:not([data-processed='true'])").forEach(e=>{S.has(e)||(S.add(e),X(e),e.complete?K(e):(e.addEventListener("load",()=>K(e)),e.addEventListener("error",()=>Q(e))))})},X=e=>{const r=e.parentElement.offsetWidth;if(e.naturalWidth>r&&(e.style.maxWidth="100%"),e.naturalWidth&&e.naturalHeight){const t=e.naturalHeight/e.naturalWidth;e.style.maxHeight=`${Math.min(500,r*t)}px`}},K=e=>{S.delete(e),e.setAttribute("data-processed","true"),e.classList.add("loaded"),e.style.opacity="1",e.removeEventListener("load",K),e.removeEventListener("error",Q)},Q=e=>{S.delete(e),e.setAttribute("data-processed","true"),e.classList.add("load-error"),e.style.maxHeight="200px",e.removeEventListener("load",K),e.removeEventListener("error",Q)},Y=v.unified().use(h).use(_).use(f,{singleTilde:!1}).use(g).use(y).use(k,{allowDangerousHtml:!0}).use(b).use(x).use(q),Z=(e,r)=>{var t;if(e&&"object"==typeof e){if("form"===e.type){const s={...(null==(t=e.properties)?void 0:t.data)||{},...j.historyInputs||{}};return void r.push(s)}Array.isArray(e.children)&&e.children.forEach(e=>{Z(e,r)})}};e.watch(()=>U.value,async r=>{V=0;const t=await Y.run(Y.parse(r)),s=(e=>{const r=[],t=[],s=e=>{e&&("pre"===e.tagName&&t.push(e),Array.isArray(e.children)&&e.children.forEach(s))};return Array.isArray(e.children)&&e.children.forEach(s),t.forEach(e=>{var t,s,l,n,o;const i=null==(t=e.children)?void 0:t.find(e=>"code"===e.tagName);if(null==(l=null==(s=null==i?void 0:i.properties)?void 0:s.className)?void 0:l.includes("language-CorePilot"))try{const e=(null==(o=null==(n=i.children)?void 0:n[0])?void 0:o.value)||"";if(e){const t=JSON.parse(e);Z(t,r)}}catch(a){console.error("Failed to parse CorePilot schema:",a)}}),r})(t);R.value=s,await e.nextTick(),$.value=t,e.nextTick(z),e.nextTick(()=>{var e;const r=null==(e=E.value)?void 0:e.querySelector("details");(null==r?void 0:r.querySelector("summary"))&&!T.value&&(T.value=!0,new o.Accordion(r))})},{immediate:!0});const ee=()=>e.h("div",{class:"hitl-skeleton"},[e.h("div",{class:"skeleton-header"},[e.h("div",{class:"skeleton-avatar"}),e.h("div",{class:"skeleton-title"})]),e.h("div",{class:"skeleton-item skeleton-item-long"}),e.h("div",{class:"skeleton-item skeleton-item-medium"}),e.h("div",{class:"skeleton-item skeleton-item-short"}),e.h("div",{class:"skeleton-item skeleton-item-long"}),e.h("div",{class:"skeleton-item skeleton-item-medium"})]),re=(r,t,l)=>{var o,v,h,_,f,g,y,k,b,x,q,j,E,w;if(!r)return null;let A=[];switch(["sub","pre","text","ElForm"].includes(r.tagName)||(A=(null==(v=null==(o=r.children)?void 0:o.map)?void 0:v.call(o,e=>re(e,t)))||[]),r.type){case"root":return e.h("div",{class:"markdown-body"},e.h(s.ElConfigProvider,{locale:c},A));case"element":if("sub"===r.tagName){const s=[{type:"element",tagName:"span",properties:{class:"x-markdown-split"}},...r.children],l=null==s?void 0:s.map(e=>re(e,t));return e.h("span",{...r.properties,class:"x-markdown-sub"},l)}if("span"===r.tagName)return e.h("span",{...r.properties},A);if("img"===r.tagName)return e.h("img",{...r.properties,class:"markdown-image","data-processed":"false"});if("a"===r.tagName){const t=(null==(h=r.properties)?void 0:h.href)||"",s=t?t.split(".").pop():null;return e.h("a",{...r.properties,class:"file-link","data-file-type":s},A)}if("ElTimeline"===r.tagName)return e.h(s.ElTimeline,{...r.properties},A);if("table"===r.tagName)return e.h("div",{class:"custom-table-container"},[e.h("table",A)]);if("view"===r.tagName)return e.h("div",{class:"custom-view-container"},[A[F.value]]);if("ElRow"===r.tagName)return e.h(s.ElRow,{...r.properties},A);if("ElCol"===r.tagName)return e.h(s.ElCol,{...r.properties},A);if("ElCard"===r.tagName)return e.h(s.ElCard,{...r.properties},A);if("CoreCard"===r.tagName)return e.h(m,{...r.properties},A);if("ElForm"===r.tagName){const l=null==(_=r.children)?void 0:_.map(e=>re(e,V));return V++,e.h(s.ElForm,{ref:L.value.set,model:R.value[t],...r.properties,disabled:I(r)},l)}if("ElFormItem"===r.tagName)return e.h(s.ElFormItem,{...r.properties},A);if("ElButton"===r.tagName){let n=null==(f=r.properties)?void 0:f.payload;return"table"===r.parentScope&&(n=l),e.h(s.ElButton,{...r.properties,disabled:I(r),onClick:()=>{var e;(async(e,r,t,s)=>{var l;if("inner_next"===r)return void(F.value+=1);if("inner_prev"===r)return void(F.value-=1);if("inner_rewrite"===r)return D.value=!0,void console.log("isRewrite",D.value);let n={action:r,payload:{}};t&&"form"!==s?n={action:r,payload:t}:(await(null==(l=L.value[e])?void 0:l.validate()),n={action:r,payload:{...R.value[e],...t}}),D.value&&r.startsWith("core_")&&(D.value=!1),N("coreSubmit",n)})(t,null==(e=r.properties)?void 0:e.action,n,r.parentScope)}},A)}if("ElSelect"===r.tagName)return e.h(s.ElSelect,{...r.properties,disabled:I(r),modelValue:R.value[t][null==(g=r.properties)?void 0:g.formProp],"onUpdate:modelValue":e=>{var s;R.value[t][null==(s=r.properties)?void 0:s.formProp]=e}},A);if("ElDatePicker"===r.tagName)return e.h(s.ElDatePicker,{...r.properties,disabled:I(r),modelValue:R.value[t][null==(y=r.properties)?void 0:y.formProp],"onUpdate:modelValue":e=>{var s;R.value[t][null==(s=r.properties)?void 0:s.formProp]=e}},A);if("ElInput"===r.tagName)return e.h(s.ElInput,{...r.properties,disabled:I(r),modelValue:R.value[t][null==(k=r.properties)?void 0:k.formProp],"onUpdate:modelValue":e=>{var s;R.value[t][null==(s=r.properties)?void 0:s.formProp]=e}},A);if("ElRadioGroup"===r.tagName)return e.h(s.ElRadioGroup,{...r.properties,disabled:I(r),modelValue:R.value[t][null==(b=r.properties)?void 0:b.formProp],"onUpdate:modelValue":e=>{var s;R.value[t][null==(s=r.properties)?void 0:s.formProp]=e}},A);if("ElRadio"===r.tagName)return e.h(s.ElRadio,{...r.properties,disabled:I(r)},A);if("ElTable"===r.tagName)return e.h(d,{...r.properties},A);if("ElTableColumn"===r.tagName)return e.h(s.ElTableColumn,{...r.properties},{default:e=>{var t,s;const l=null==(t=r.children)?void 0:t.map(r=>re(r,V,e.row)),n=null==(s=r.children)?void 0:s.findIndex(t=>{var s;return t.value===e.row[null==(s=r.properties)?void 0:s.prop]});return-1===n?l:null==l?void 0:l[n]}});if("CoreText"===r.tagName)return e.h(i,{...r.properties});if("CoreTips"===r.tagName)return e.h(a,{...r.properties});if("CoreResult"===r.tagName)return e.h(u,{...r.properties});if("CoreChart"===r.tagName)return e.h(p,{...r.properties});if("pre"===r.tagName){const t=null==(x=r.children)?void 0:x.find(e=>"code"===e.tagName);if(t&&(null==(j=null==(q=t.properties)?void 0:q.className)?void 0:j.includes("language-CorePilot"))){const r=(null==(w=null==(E=t.children)?void 0:E[0])?void 0:w.value)||"";if(!(e=>{if(!e||0===e.trim().length)return!1;const r=e.trim(),t=r[0];if("{"!==t&&"["!==t)return!1;try{return JSON.parse(r),!0}catch(s){return!1}})(r))return ee();try{const t=JSON.parse(r),s=n.parseCorePilot(t),l=re(s,V);return e.h("div",{class:"hitl-wrapper"},[l])}catch(C){return ee()}}}return e.h(r.tagName,r.properties,A);case"text":return r.value.trim();default:return null}};return e.onUpdated(()=>{V=0}),{hastToVNode:re,ast:$,container:E,renderComplete:W,isRewrite:D,getContentText:()=>{var e;return null==(e=E.value)?void 0:e.innerText}}},render(){return e.createVNode("div",{ref:"x-markdown-container",class:"x-markdown"},[this.hastToVNode(this.ast)])}});module.exports=j;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|