Files
Message-Push-Nest/web/src/views/tabsTools/sendTasks/view/viewTaskAPIPopUp.vue
T

164 lines
4.3 KiB
Vue
Raw Normal View History

2023-12-30 17:40:20 +08:00
<template>
<el-dialog v-model="isShow" width="58%" :close-on-press-escape="false" :before-close="() => { }" :show-close="false">
<template #header="">
<el-text class="mx-1">查看接入API</el-text>
<el-tooltip placement="top">
<template #content>
一个任务可能关联多个不同渠道的实例
<br />
实例的内容类型大体上可以可以分为texthtmlmarkdown
<br />
2024-01-06 17:44:45 +08:00
发送的消息会优先现在相应的类型消息进行发送如果没有将使用传的text消息进行发送
2023-12-30 17:40:20 +08:00
<br />
2024-01-06 17:44:45 +08:00
** text节点必传指定mode=sync将同步发送默认异步发送
2023-12-30 17:40:20 +08:00
</template>
<el-icon>
<QuestionFilled />
</el-icon>
</el-tooltip>
</template>
2024-01-14 13:57:23 +08:00
<el-tabs v-model="activeName">
2024-01-14 13:43:17 +08:00
<el-tab-pane :label="item.label" :name="item.label" v-for="item in apiViewData">
<pre><code :class="item.class">{{ item.code }}</code></pre>
2023-12-30 17:40:20 +08:00
</el-tab-pane>
</el-tabs>
<template #footer>
<span class="dialog-footer">
<el-button @click="handleCancer()" size="small">取消</el-button>
</span>
</template>
</el-dialog>
</template>
<script>
import { defineComponent, onMounted, watch, reactive, toRefs, onUpdated } from 'vue';
import { _ } from 'lodash';
import { usePageState } from '@/store/page_sate.js';
import Prism from "prismjs";
import { QuestionFilled } from '@element-plus/icons-vue'
2024-01-06 17:44:45 +08:00
import { request } from '@/api/api'
2024-01-14 13:43:17 +08:00
import { CONSTANT } from '@/constant'
2023-12-30 17:40:20 +08:00
export default defineComponent({
components: {
QuestionFilled,
},
props: {
componentName: String,
},
setup(props) {
const pageState = usePageState();
const state = reactive({
isShow: false,
2024-01-14 13:43:17 +08:00
currOption: '',
2023-12-30 17:40:20 +08:00
activeName: 'curl',
2024-01-14 13:43:17 +08:00
apiViewData: CONSTANT.API_VIEW_DATA,
2023-12-30 17:40:20 +08:00
});
watch(pageState.ShowDialogData, (newValue, oldValue) => {
if (newValue[props.componentName]) {
state.isShow = pageState.ShowDialogData[props.componentName].isShow;
renderApiString();
}
});
const handleCancer = () => {
if (pageState.ShowDialogData[props.componentName]) {
pageState.ShowDialogData[props.componentName].isShow = false;
2024-01-14 14:34:14 +08:00
state.currOption = '';
2023-12-30 17:40:20 +08:00
}
}
2024-01-06 17:44:45 +08:00
// 获取接口查看格式
const getViewOptions = async (taskId) => {
let params = { id: taskId };
const rsp = await request.get('/sendtasks/ins/gettask', { params: params });
let insTableData = await rsp.data.data.ins_data;
let viewOptions = {}
insTableData.forEach(element => {
viewOptions[element.content_type] = 1;
});
return viewOptions
}
2024-01-14 13:43:17 +08:00
// 渲染api接口代码
2024-01-06 17:44:45 +08:00
const renderApiString = async () => {
2023-12-30 17:40:20 +08:00
let task_id = pageState.ShowDialogData[props.componentName].rowData.id;
2024-01-14 13:43:17 +08:00
if (!state.currOption) {
state.currOption = await getViewOptions(task_id);
2023-12-30 17:40:20 +08:00
}
2024-01-14 13:43:17 +08:00
state.apiViewData.forEach(element => {
2024-01-14 14:34:14 +08:00
// if (!element.code) {
element.code = element.func(task_id, state.currOption);
// }
2024-01-14 13:43:17 +08:00
});
2023-12-30 17:40:20 +08:00
setTimeout(() => {
Prism.highlightAll()
}, 100)
}
return {
...toRefs(state), handleCancer, renderApiString
};
},
});
</script>
<style scoped>
.language-javascript {
background-color: #f0f0f0;
}
/* pre {
overflow: hidden !important;
code{
display: inline-block;
padding-bottom: 20px;
position: relative;
top: 20px;
}
&::before {
content: "";
position: absolute;
background: red;
width: 10px;
height: 10px;
border-radius: 50%;
top: 10px;
left: 15px;
transform: translate(-50%);
}
&::after {
content: "";
position: absolute;
background: sandybrown;
width: 10px;
height: 10px;
border-radius: 50%;
top: 10px;
left: 30px;
transform: translate(-50%);
}
code:first-child{
&::after{
content: "";
position: absolute;
background: limegreen;
width: 10px;
height: 10px;
border-radius: 50%;
top: -24px;
left: -7px;
transform: translate(-50%);
}
}
} */
</style>