未滑动到底部 bug;多次点开对话测试 bug;数据对接SQL为选项之一
| | |
| | | <template><div class="my-amis-scope">å è½½ä¸...</div></template> |
| | | <template><div ref="amisRootRef" class="my-amis-scope">å è½½ä¸...</div></template> |
| | | |
| | | <script lang="ts"> |
| | | import { accessSessionKey, handleNoAuth } from '/@/utils/request'; |
| | | <script setup lang="ts"> |
| | | import { MAIN_URL } from '/@/constants'; |
| | | import router from '/@/router/index'; |
| | | |
| | | import { Local } from '/@/utils/storage'; |
| | | |
| | | import { accessSessionKey, handleNoAuth } from '/@/utils/request'; |
| | | // å¯ä»¥ä¸å¼ç¨, å¦æä½ ä¸æ³è¦ä»»ä½è¾
å©ç±»æ ·å¼çè¯ (æ¯å¦ `m-t-xs` è¿ç§) |
| | | // https://aisuda.bce.baidu.com/amis/zh-CN/style/index |
| | | // import 'amis/sdk/helper.css'; |
| | | import qs from 'qs'; |
| | | import { onMounted, onUnmounted, reactive, ref, shallowRef, watch } from 'vue'; |
| | | const amisRootRef = ref<HTMLDivElement>(null); |
| | | import { Local } from '/@/utils/storage'; |
| | | |
| | | const props = defineProps({ |
| | | schema: { |
| | | type: Object, |
| | | default: () => ({ |
| | | type: 'page', |
| | | body: 'Hello World!', |
| | | }), |
| | | }, |
| | | locals: { |
| | | type: Object, |
| | | default: () => ({}), |
| | | }, |
| | | props: { |
| | | type: Object, |
| | | default: () => ({}), |
| | | }, |
| | | env: { |
| | | type: Object, |
| | | default: () => ({}), |
| | | }, |
| | | }); |
| | | |
| | | const emit = defineEmits(['ready']); |
| | | |
| | | function loadScript(callback) { |
| | | window.eventList.amisSdkJsPromise |
| | |
| | | .catch((error) => { |
| | | callback(error); |
| | | }); |
| | | } |
| | | |
| | | function loadStyles(styles) { |
| | | for (const path of styles) { |
| | | const style = document.createElement('link'); |
| | | style.setAttribute('rel', 'stylesheet'); |
| | | style.setAttribute('type', 'text/css'); |
| | | style.setAttribute('href', path); |
| | | document.head.appendChild(style); |
| | | } |
| | | } |
| | | |
| | | function loadSDK() { |
| | |
| | | }); |
| | | } |
| | | |
| | | export default { |
| | | name: 'AMISRenderer', |
| | | components: {}, |
| | | props: { |
| | | schema: { |
| | | type: Object, |
| | | default: () => ({ |
| | | type: 'page', |
| | | body: 'Hello World!', |
| | | }), |
| | | }, |
| | | locals: { |
| | | type: Object, |
| | | default: () => ({}), |
| | | }, |
| | | props: { |
| | | type: Object, |
| | | default: () => ({}), |
| | | }, |
| | | env: { |
| | | type: Object, |
| | | default: () => ({}), |
| | | }, |
| | | }, |
| | | data() { |
| | | return { |
| | | // è¿éé¢çæ°æ®ææ amis 页é¢é½å¯ä»¥è·åå° |
| | | // å¯ä»¥ç¨æ¥æ¾ä¸ä¸å
Œ
±æ°æ®ï¼æ¯å¦ç¨æ·ä¿¡æ¯ç |
| | | // ä¸è¦æ¾åæ§æ°æ®ï¼åæ§æ°æ®åºè¯¥éè¿ data ä¸å |
| | | context: { |
| | | siteName: 'AMIS DEMO', |
| | | }, |
| | | get location() { |
| | | const current = router.currentRoute.value; |
| | | return { |
| | | pathname: current?.path, |
| | | hash: current?.hash, |
| | | query: current?.query, |
| | | search: `?${qs.stringify(current.query)}`, |
| | | }; |
| | | // return 'localtion' |
| | | }, |
| | | loading: false, |
| | | amisInstance: null, |
| | | unmounted: false, |
| | | }; |
| | | }, |
| | | const context = reactive({ |
| | | siteName: 'AMIS DEMO', |
| | | }); |
| | | const current = router.currentRoute.value; |
| | | |
| | | watch: { |
| | | locals: function () { |
| | | this.updateProps(); |
| | | }, |
| | | props: function () { |
| | | this.updateProps(); |
| | | }, |
| | | $route: function () { |
| | | this.updateProps(); |
| | | }, |
| | | }, |
| | | async mounted() { |
| | | try { |
| | | this.loading = true; |
| | | await loadSDK(); |
| | | } finally { |
| | | this.loading = false; |
| | | } |
| | | if (this.unmounted) { |
| | | return; |
| | | } |
| | | |
| | | const scoped = amisRequire('amis/embed'); |
| | | const { normalizeLink } = amisRequire('amis'); |
| | | const instance = scoped.embed( |
| | | this.$el, |
| | | this.schema, |
| | | { |
| | | data: { |
| | | ...this.locals, |
| | | }, |
| | | context: this.context, |
| | | location: this.location, |
| | | |
| | | // todo ä¸å location 对象 |
| | | ...this.props, |
| | | }, |
| | | { |
| | | requestAdaptor(api) { |
| | | const accessSession = Local.get(accessSessionKey); |
| | | if (accessSession) { |
| | | // å° token æ·»å å°è¯·æ±æ¥æå¤´ä¸ |
| | | api.headers['hswatersession'] = accessSession; |
| | | } else { |
| | | handleNoAuth(); |
| | | } |
| | | api.url = `${MAIN_URL}${api.url}`; |
| | | return api; |
| | | }, |
| | | // å
¨å± api éé
å¨ã |
| | | // å¦å¤å¨ amis é
置项ä¸ç api ä¹å¯ä»¥é
ç½®éé
å¨ï¼é对æä¸ªç¹å®æ¥å£åç¬å¤çã |
| | | responseAdaptor(api, payload, query, request, response) { |
| | | // { |
| | | // "json_ok": true, |
| | | // "sections": [ |
| | | // { |
| | | // "section_id": "knowledge_base", |
| | | // "section_name": "æ°´å¡ç¥è¯åº", |
| | | // "section_title": "æ¥ææ°´å¡è¡ä¸ç¸å
³çéç¨ç¥è¯ï¼å
æ¬ï¼æ³å¾æ³è§ã设计è§èãç»ææ°´ç¸å
³ç¥è¯çç" |
| | | // }, |
| | | // { |
| | | // "section_id": "office_assistant", |
| | | // "section_name": "åå
¬å©æ", |
| | | // "section_title": "åå
¬å©æè½å¤è¾
å©åä¼è®®éç¥ãè¯·åæ¡ã工使»ç»ãPPTçå·¥ä½ã" |
| | | // }, |
| | | // { |
| | | // "section_id": "customer_service", |
| | | // "section_name": "å®¢æ·æå¡", |
| | | // "section_title": "é对水å¡ä¼ä¸å¯¹å¤å®¢æ·æå¡ç¸å
³çå
容ï¼å
æ¬ï¼æè¡¨ãå¼è´¦ãæ¶è´¹ï¼ä»¥åç线ç¸å
³" |
| | | // }, |
| | | // { |
| | | // "section_id": "network_operation", |
| | | // "section_name": "管ç½è¿è¡", |
| | | // "section_title": "é对水å¡ä¼ä¸ç®¡ç½è¿è¡ä¸ç»´æ¤ç®¡çãæ°´è´¨ç®¡ççç¸å
³" |
| | | // }, |
| | | // { |
| | | // "section_id": "waterworks_operation", |
| | | // "section_name": "æ°´åè¿è¡", |
| | | // "section_title": "é对水å¡ä¼ä¸æ°´åè¿æ¥å¸¸è¿è¥ç®¡çæå¡ï¼å
æ¬ï¼æ°´åå·¥èºæµç¨ãæ°´æ³µè¿è¡è°åº¦" |
| | | // } |
| | | // ] |
| | | // } |
| | | return payload; |
| | | }, |
| | | // è¦ç amis env |
| | | // åè https://aisuda.bce.baidu.com/amis/zh-CN/docs/start/getting-started#sdk |
| | | jumpTo: (to, action) => { |
| | | return; |
| | | if (to === 'goBack') { |
| | | return router.go(-1); |
| | | } |
| | | |
| | | to = normalizeLink(to, this.location); |
| | | |
| | | if (action?.actionType === 'url') { |
| | | action.blank === false ? router.push(to) : window.open(to); |
| | | return; |
| | | } |
| | | |
| | | // ä¸»è¦æ¯æ¯æ nav ä¸ç跳转 |
| | | if (action && to && action.target) { |
| | | window.open(to, action.target); |
| | | return; |
| | | } |
| | | |
| | | if (/^https?:\/\//.test(to)) { |
| | | window.location.replace(to); |
| | | } else { |
| | | router.push(to); |
| | | } |
| | | }, |
| | | |
| | | updateLocation: (location, replace) => { |
| | | // ç¦æ¢è·³è½¬ |
| | | return; |
| | | if (location === 'goBack') { |
| | | return router.go(-1); |
| | | } |
| | | |
| | | location = normalizeLink(location, this.location); |
| | | replace ? router.replace(location) : router.replace(location); |
| | | }, |
| | | |
| | | ...this.env, |
| | | }, |
| | | () => { |
| | | this.$emit('ready', { |
| | | instance, |
| | | }); |
| | | } |
| | | ); |
| | | |
| | | this.amisInstance = instance; |
| | | }, |
| | | |
| | | methods: { |
| | | updateProps() { |
| | | this.amisInstance?.updateProps({ |
| | | data: { |
| | | ...this.locals, |
| | | }, |
| | | context: this.context, |
| | | ...this.props, |
| | | }); |
| | | }, |
| | | }, |
| | | |
| | | unmounted() { |
| | | this.unmounted = true; |
| | | this.amisInstance?.unmount(); |
| | | }, |
| | | const location = { |
| | | pathname: current?.path, |
| | | hash: current?.hash, |
| | | query: current?.query, |
| | | search: `?${qs.stringify(current.query)}`, |
| | | }; |
| | | |
| | | const loading = ref(false); |
| | | const amisInstance = shallowRef(null); |
| | | const unmounted = ref(false); |
| | | |
| | | const updateProps = () => { |
| | | amisInstance.value?.updateProps({ |
| | | data: { |
| | | ...props.locals, |
| | | }, |
| | | context: context, |
| | | ...props.props, |
| | | }); |
| | | }; |
| | | watch( |
| | | () => props.locals, |
| | | (val) => { |
| | | updateProps(); |
| | | } |
| | | ); |
| | | watch( |
| | | () => props.props, |
| | | (val) => { |
| | | updateProps(); |
| | | } |
| | | ); |
| | | |
| | | // watch(() => router.value, (val) => { |
| | | |
| | | // }) |
| | | |
| | | onMounted(async () => { |
| | | try { |
| | | loading.value = true; |
| | | await loadSDK(); |
| | | } finally { |
| | | loading.value = false; |
| | | } |
| | | if (unmounted.value) { |
| | | return; |
| | | } |
| | | |
| | | const scoped = amisRequire('amis/embed'); |
| | | const { normalizeLink } = amisRequire('amis'); |
| | | const instance = scoped.embed( |
| | | amisRootRef.value, |
| | | props.schema, |
| | | { |
| | | data: { |
| | | ...props.locals, |
| | | }, |
| | | context: context, |
| | | location: location, |
| | | |
| | | // todo ä¸å location 对象 |
| | | ...props.props, |
| | | }, |
| | | { |
| | | requestAdaptor(api) { |
| | | const accessSession = Local.get(accessSessionKey); |
| | | if (accessSession) { |
| | | // å° token æ·»å å°è¯·æ±æ¥æå¤´ä¸ |
| | | api.headers['hswatersession'] = accessSession; |
| | | } else { |
| | | handleNoAuth(); |
| | | } |
| | | api.url = `${MAIN_URL}${api.url}`; |
| | | return api; |
| | | }, |
| | | // å
¨å± api éé
å¨ã |
| | | // å¦å¤å¨ amis é
置项ä¸ç api ä¹å¯ä»¥é
ç½®éé
å¨ï¼é对æä¸ªç¹å®æ¥å£åç¬å¤çã |
| | | responseAdaptor(api, payload, query, request, response) { |
| | | // { |
| | | // "json_ok": true, |
| | | // "sections": [ |
| | | // { |
| | | // "section_id": "knowledge_base", |
| | | // "section_name": "æ°´å¡ç¥è¯åº", |
| | | // "section_title": "æ¥ææ°´å¡è¡ä¸ç¸å
³çéç¨ç¥è¯ï¼å
æ¬ï¼æ³å¾æ³è§ã设计è§èãç»ææ°´ç¸å
³ç¥è¯çç" |
| | | // }, |
| | | // { |
| | | // "section_id": "office_assistant", |
| | | // "section_name": "åå
¬å©æ", |
| | | // "section_title": "åå
¬å©æè½å¤è¾
å©åä¼è®®éç¥ãè¯·åæ¡ã工使»ç»ãPPTçå·¥ä½ã" |
| | | // }, |
| | | // { |
| | | // "section_id": "customer_service", |
| | | // "section_name": "å®¢æ·æå¡", |
| | | // "section_title": "é对水å¡ä¼ä¸å¯¹å¤å®¢æ·æå¡ç¸å
³çå
容ï¼å
æ¬ï¼æè¡¨ãå¼è´¦ãæ¶è´¹ï¼ä»¥åç线ç¸å
³" |
| | | // }, |
| | | // { |
| | | // "section_id": "network_operation", |
| | | // "section_name": "管ç½è¿è¡", |
| | | // "section_title": "é对水å¡ä¼ä¸ç®¡ç½è¿è¡ä¸ç»´æ¤ç®¡çãæ°´è´¨ç®¡ççç¸å
³" |
| | | // }, |
| | | // { |
| | | // "section_id": "waterworks_operation", |
| | | // "section_name": "æ°´åè¿è¡", |
| | | // "section_title": "é对水å¡ä¼ä¸æ°´åè¿æ¥å¸¸è¿è¥ç®¡çæå¡ï¼å
æ¬ï¼æ°´åå·¥èºæµç¨ãæ°´æ³µè¿è¡è°åº¦" |
| | | // } |
| | | // ] |
| | | // } |
| | | return payload; |
| | | }, |
| | | // è¦ç amis env |
| | | // åè https://aisuda.bce.baidu.com/amis/zh-CN/docs/start/getting-started#sdk |
| | | jumpTo: (to, action) => { |
| | | return; |
| | | if (to === 'goBack') { |
| | | return router.go(-1); |
| | | } |
| | | |
| | | to = normalizeLink(to, this.location); |
| | | |
| | | if (action?.actionType === 'url') { |
| | | action.blank === false ? router.push(to) : window.open(to); |
| | | return; |
| | | } |
| | | |
| | | // ä¸»è¦æ¯æ¯æ nav ä¸ç跳转 |
| | | if (action && to && action.target) { |
| | | window.open(to, action.target); |
| | | return; |
| | | } |
| | | |
| | | if (/^https?:\/\//.test(to)) { |
| | | window.location.replace(to); |
| | | } else { |
| | | router.push(to); |
| | | } |
| | | }, |
| | | |
| | | updateLocation: (location, replace) => { |
| | | // ç¦æ¢è·³è½¬ |
| | | return; |
| | | if (location === 'goBack') { |
| | | return router.go(-1); |
| | | } |
| | | |
| | | location = normalizeLink(location, this.location); |
| | | replace ? router.replace(location) : router.replace(location); |
| | | }, |
| | | |
| | | ...props.env, |
| | | }, |
| | | () => { |
| | | emit('ready', { |
| | | instance, |
| | | }); |
| | | } |
| | | ); |
| | | amisInstance.value = instance; |
| | | }); |
| | | |
| | | onUnmounted(() => { |
| | | unmounted.value = true; |
| | | |
| | | amisInstance.value?.unmount(); |
| | | }); |
| | | </script> |
| | |
| | | </div> |
| | | </div> |
| | | |
| | | <Loading v-if="isTalking && index === messageList.length - 1" class="w-fit" /> |
| | | <Loading v-if="isTalking && index === messageList.length - 1" class="w-fit my-auto" /> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="sticky bottom-0 w-full pb-3 flex justify-center"> |
| | | <div class="sticky bottom-0 w-full py-6 flex justify-center"> |
| | | <PlayBar |
| | | v-model:voicePageIsShow="voicePageIsShow" |
| | | :isTalking="isTalking" |
| | |
| | | import { GetHistoryAnswer, extCallQuery } from '/@/api/ai/chat'; |
| | | import PlayBar from '/@/components/chat/components/playBar/PlayBar.vue'; |
| | | import { ErrorCode } from '/@/utils/request'; |
| | | |
| | | |
| | | import { CancelTokenSource } from 'axios'; |
| | | |
| | | const props = defineProps({ |
| | | questionApi: Function as PropType<(...params: any[]) => any>, |
| | | questionApi: Function as PropType<(text: string, sourceObj: { source: CancelTokenSource }) => any>, |
| | | }); |
| | | |
| | | const chatWidth = '100%'; |
| | |
| | | type: AnswerType.Text, |
| | | values: 'è§£æå¤±è´¥ï¼', |
| | | }; |
| | | |
| | | switch (res.answer_type) { |
| | | case AnswerType.RecordSet: |
| | | content = { |
| | |
| | | }; |
| | | |
| | | let questionRes = null; |
| | | // ä½ä¸ºåæ°ä¼ è¿å»ï¼æºå¸¦åæ°åºæ¥ |
| | | let lastSourceObj: { source: CancelTokenSource } = { |
| | | source:null |
| | | }; |
| | | |
| | | const questionAi = async (text) => { |
| | | const res = await props.questionApi(text); |
| | | const res = await props.questionApi(text, lastSourceObj); |
| | | questionRes = res?.values; |
| | | const content = parseContent(res?.values); |
| | | return content; |
| | |
| | | history_id: historyId, |
| | | }); |
| | | }; |
| | | |
| | | const sendChatMessage = async (content: ChatContent = messageContent.value, cb?: any, isCallExtParams?: any) => { |
| | | if (!content?.values || isTalking.value) return; |
| | | const isNewChat = messageList.value.length === 0; |
| | |
| | | }; |
| | | |
| | | const clearContent = () => { |
| | | lastSourceObj.source?.cancel(); |
| | | messageList.value = []; |
| | | // æ¸
空è¾å
¥æ¡ |
| | | clearMessageContent(); |
| | |
| | | |
| | | defineExpose({ |
| | | autoSend, |
| | | clear:clearContent |
| | | clear: clearContent, |
| | | }); |
| | | |
| | | //#region ====================== å
³èæ¥è¯¢ ====================== |
| | |
| | | <template> |
| | | <div> |
| | | <span v-if="data?.title" class="text-base font-bold flex-center">{{ data?.title }}</span> |
| | | <AMISRenderer :schema="data?.amis_json" :locals="data?.amis_data" /> |
| | | <AMISRenderer :schema="data?.amis_json" :locals="data?.amis_data" @ready="amisReady"/> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | import type { PropType } from 'vue'; |
| | | import AMISRenderer from '/@/components/amis/AMISRenderer.vue'; |
| | | import emitter from '/@/utils/mitt'; |
| | | |
| | | // import å¨ç¤¾ä¼å鿝 from './testData/å¨ç¤¾ä¼å鿝.json' |
| | | // import å®¢æ·æ
åµ from './testData/å®¢æ·æ
åµ.json' |
| | |
| | | }, |
| | | }); |
| | | |
| | | const amisReady = (val) => { |
| | | emitter.emit('amis.page.ready',val); |
| | | }; |
| | | |
| | | |
| | | </script> |
| | | <style scoped lang="scss"></style> |
| | |
| | | import type { ComputedRef, Ref } from 'vue'; |
| | | import { nextTick, onActivated, ref, watch } from 'vue'; |
| | | import { nextTick, onActivated, onUnmounted, ref, watch } from 'vue'; |
| | | import type { ChatMessage } from '../model/types'; |
| | | import emitter from '/@/utils/mitt'; |
| | | |
| | | export type UseScrollToBottomOption = { |
| | | chatListDom: Ref<HTMLDivElement>; |
| | |
| | | |
| | | const scrollToBottom = () => { |
| | | if (!chatListDom.value) return; |
| | | chatListDom.value.lastElementChild?.scrollIntoView(); |
| | | const parent = chatListDom.value.parentElement; |
| | | if(!parent)return; |
| | | if(parent.scrollHeight>parent.clientHeight){ |
| | | parent.scrollTop = parent.scrollHeight - parent.clientHeight; |
| | | } |
| | | }; |
| | | |
| | | emitter.on('amis.page.ready',({instance})=>{ |
| | | nextTick(()=>{ |
| | | scrollToBottom(); |
| | | }) |
| | | }) |
| | | const forbidScroll = ref(false); |
| | | watch( |
| | | displayMessageList, |
| | |
| | | deep: true, |
| | | } |
| | | ); |
| | | onUnmounted(()=>{ |
| | | emitter.off('amis.page.ready'); |
| | | }) |
| | | |
| | | onActivated(() => { |
| | | if (forbidScroll.value) return; |
| | |
| | | }; |
| | | |
| | | //#endregion |
| | | |
| | | 'amis.page.ready':{ |
| | | instance |
| | | } |
| | | }; |
| | | |
| | | // mitt åæ°ç±»åå®ä¹ |
| | |
| | | // https://www.npmjs.com/package/mitt |
| | | import type { Emitter } from 'mitt'; |
| | | import mitt from 'mitt'; |
| | | import { MittType } from '../types/mitt'; |
| | | |
| | | // ç±»å |
| | | const emitter: Emitter<MittType> = mitt<MittType>(); |
| | |
| | | import type { AxiosInstance, AxiosRequestConfig } from 'axios'; |
| | | import type { AxiosInstance, AxiosRequestConfig, CancelToken } from 'axios'; |
| | | import axios from 'axios'; |
| | | import { ElLoadingService, ElMessage } from 'element-plus'; |
| | | import router from '../router'; |
| | |
| | | loading?: boolean; |
| | | noAuth?: boolean; |
| | | handleFail?: boolean; |
| | | cancelToken?: CancelToken | undefined; |
| | | }; |
| | | export const checkAuth = () => { |
| | | const session = Local.get(accessSessionKey); |
| | |
| | | import { useCompRef } from '/@/utils/types'; |
| | | import { SupervisorPublished, supervisorPublishedMap } from '/@/views/project/yw/lowCode/sqlAmis/types'; |
| | | import knowledgeLeft from '/static/images/knowledge/data_type_1.png'; |
| | | import axios, { CancelTokenSource } from 'axios'; |
| | | const router = useRouter(); |
| | | //#region ====================== è·åç¥è¯åºsheetå表 ====================== |
| | | const knowledgeBaseList = ref([]); |
| | |
| | | chatTestIsShow.value = true; |
| | | nextTick(() => { |
| | | chatRef.value.clear(); |
| | | chatRef.value.autoSend(row.prompt); |
| | | setTimeout(() => { |
| | | chatRef.value.autoSend(row.prompt); |
| | | }, 30); |
| | | }); |
| | | }; |
| | | |
| | |
| | | }, |
| | | }); |
| | | |
| | | const questionAi = async (text) => { |
| | | const questionAi = async (text, sourceObj: { source: CancelTokenSource }) => { |
| | | const currentSource = axios.CancelToken.source(); |
| | | sourceObj.source = currentSource; |
| | | const res = await check_docvector_validate( |
| | | { |
| | | knowlg_id: chatTestMapRow.value.id, |
| | |
| | | }, |
| | | { |
| | | loading: false, |
| | | cancelToken: currentSource.token, |
| | | } |
| | | ); |
| | | return res; |
| | |
| | | import { useCompRef } from '/@/utils/types'; |
| | | import { convertListToTree } from '/@/utils/util'; |
| | | |
| | | import axios, { CancelTokenSource } from 'axios'; |
| | | import * as supervisorGroupApi from '/@/api/supervisorAdmin/supervisorGroup'; |
| | | import LeftTreeByMgr from '/@/components/tree/leftTreeByMgr.vue'; |
| | | import AHMContainer from '/@/components/layout/AHMContainer.vue'; |
| | | import LeftTreeByMgr from '/@/components/tree/leftTreeByMgr.vue'; |
| | | import { useUpdateData } from '/@/hooks/useUpdateData'; |
| | | |
| | | //#region ====================== å·¦ä¾§æ æ°æ®ï¼tree init ====================== |
| | |
| | | |
| | | nextTick(() => { |
| | | chatRef.value.clear(); |
| | | chatRef.value.autoSend(row.prompt); |
| | | setTimeout(() => { |
| | | chatRef.value.autoSend(row.prompt); |
| | | }, 30); |
| | | }); |
| | | }; |
| | | |
| | |
| | | }, |
| | | }); |
| | | |
| | | const questionAi = async (text) => { |
| | | const questionAi = async (text, sourceObj: { source: CancelTokenSource }) => { |
| | | const currentSource = axios.CancelToken.source(); |
| | | sourceObj.source = currentSource; |
| | | const res = await checkSupervisorValidate( |
| | | { |
| | | id: chatTestMapRow.value.id, |
| | |
| | | }, |
| | | { |
| | | loading: false, |
| | | cancelToken: currentSource.token, |
| | | } |
| | | ); |
| | | return res; |
| | |
| | | </Pane> |
| | | <Pane :size="65"> |
| | | <div class=" h-full"> |
| | | <template v-if="currentSql"> |
| | | <template v-if="currentDockConfig"> |
| | | <div class=" flex justify-between items-center my-1 ml-1 h-[36px]"> |
| | | <span class="font-bold">SQL</span> |
| | | |
| | | <el-select class="w-52 font-bold" v-model="currentDockConfig.type"> |
| | | <el-option v-for="item in Object.keys(amisDockTypeMap)" :key="item" :value="(item)" :label="amisDockTypeMap[item]"></el-option> |
| | | </el-select> |
| | | |
| | | <el-select class="w-40" v-model="currentSql.database" @change="databaseSelectChange"> |
| | | <el-select class="w-40" v-model="currentDockConfig.database" @change="databaseSelectChange"> |
| | | <el-option v-for="item in databaseList" :key="item.id" :value="item.id" :label="item.title"></el-option> |
| | | </el-select> |
| | | </div> |
| | | <codemirror |
| | | class="overflow-auto" |
| | | style="height: calc(100% - 36px);" |
| | | v-model="currentSql.sql" |
| | | v-model="currentDockConfig.sql" |
| | | :autofocus="true" |
| | | :indent-with-tab="true" |
| | | :tab-size="2" |
| | |
| | | import { sql } from '@codemirror/lang-sql'; |
| | | import { xml } from '@codemirror/lang-xml'; |
| | | import { vscodeDark } from '@uiw/codemirror-theme-vscode'; |
| | | import _, { debounce } from 'lodash'; |
| | | import { onMounted, ref } from 'vue'; |
| | | import { Codemirror } from 'vue-codemirror'; |
| | | import * as codeExample from './testData'; |
| | | import titleBox from '/@/components/titleBox.vue'; |
| | | import { Pane, Splitpanes } from 'splitpanes'; |
| | | import 'splitpanes/dist/splitpanes.css'; |
| | | import type { TableInstance } from 'element-plus'; |
| | | import { ElMessage } from 'element-plus'; |
| | | import _, { debounce } from 'lodash'; |
| | | import { Pane, Splitpanes } from 'splitpanes'; |
| | | import 'splitpanes/dist/splitpanes.css'; |
| | | import { v4 as uuid } from 'uuid'; |
| | | import { onMounted, ref } from 'vue'; |
| | | import { Codemirror } from 'vue-codemirror'; |
| | | import { SupervisorPublished } from '../types'; |
| | | import * as codeExample from './testData'; |
| | | import * as supervisorApi from '/@/api/supervisorAdmin'; |
| | | import { updateSqlApi } from '/@/api/supervisorAdmin'; |
| | | import titleBox from '/@/components/titleBox.vue'; |
| | | import { useCompRef } from '/@/utils/types'; |
| | | import { SupervisorPublished } from '../types'; |
| | | import { amisDockTypeMap } from './types'; |
| | | |
| | | const props = defineProps(['supervisor']); |
| | | const emit = defineEmits(['backLastPage', 'updatePublished']); |
| | |
| | | let defaultSelectDatabase = null; |
| | | const databaseSelectChange = (val) => { |
| | | defaultSelectDatabase = val; |
| | | if(currentSql.value){ |
| | | currentSql.value.database = val; |
| | | if(currentDockConfig.value){ |
| | | currentDockConfig.value.database = val; |
| | | } |
| | | updateSqlAndRs(currentSql.value.id,currentSql.value) |
| | | updateSqlAndRs(currentDockConfig.value.id,currentDockConfig.value) |
| | | }; |
| | | const backLastPage = () => { |
| | | // setTimeout(() => { |
| | |
| | | const currentRs = ref<AmisDockConfig>(null); |
| | | const dockRowChange = (row) => { |
| | | currentRs.value = row; |
| | | currentSql.value = dockConfigList.value.find((item) => item.id === currentRs.value.recordId) ?? { |
| | | currentDockConfig.value = dockConfigList.value.find((item) => item.id === currentRs.value.recordId) ?? { |
| | | id: row.recordId, |
| | | type: AmisDockType.Sql, |
| | | sql: '', |
| | | database: defaultSelectDatabase ?? databaseList.value[0]?.id ?? null, |
| | | }; |
| | | }; |
| | | const currentSql = ref(null); |
| | | const currentDockConfig = ref(null); |
| | | /** @description è·¯å¾åé符 */ |
| | | const PATH_SEPARATOR = '/'; |
| | | /** @description 1 éåºææå¾ªç¯ -1éåºå½æ¬¡å¾ªç¯ 0æå
¶ä»å¼ç»§ç» */ |
| | |
| | | |
| | | const sqlCodeChange = debounce((val) => { |
| | | if (!currentRs.value.recordId) return; |
| | | if (currentSql.value) { |
| | | if (!currentSql.value.database) { |
| | | if (currentDockConfig.value) { |
| | | if (!currentDockConfig.value.database) { |
| | | ElMessage.warning('请å
éæ©æ°æ®åº'); |
| | | return; |
| | | } |
| | | } |
| | | updateSqlAndRs(currentSql.value.id, currentSql.value); |
| | | updateSqlAndRs(currentDockConfig.value.id, currentDockConfig.value); |
| | | }, 1000); |
| | | const dockConfigList = ref([]); |
| | | const rsTableRef = ref<TableInstance>(null); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | export const enum AmisDockType { |
| | | Sql = 'SQL', |
| | | } |
| | | |
| | | export const amisDockTypeMap = { |
| | | [AmisDockType.Sql]: 'SQL', |
| | | }; |