perf: 通知渠道支持测试按钮

This commit is contained in:
xiaojunnuo
2024-11-25 11:35:16 +08:00
parent 3af6d96e6e
commit b54ae272eb
13 changed files with 126 additions and 24 deletions
@@ -11,12 +11,15 @@
</template>
<script setup lang="ts">
import { ComponentPropsType, doRequest } from "/@/components/plugins/lib";
import { ref } from "vue";
import { ref, inject } from "vue";
defineOptions({
name: "ApiTest"
});
const getScope: any = inject("get:scope");
const getPluginType: any = inject("get:plugin:type");
const props = defineProps<{} & ComponentPropsType>();
const emit = defineEmits<{
@@ -31,16 +34,20 @@ const doTest = async () => {
return;
}
const { form } = getScope();
const pluginType = getPluginType();
message.value = "";
hasError.value = false;
loading.value = true;
debugger;
try {
const res = await doRequest(
{
type: props.type,
typeName: props.typeName,
type: pluginType,
typeName: form.type,
action: props.action,
input: props.form
input: form
},
{
onError(err: any) {
@@ -50,9 +57,7 @@ const doTest = async () => {
showErrorNotify: false
}
);
if (res && res.length > 0) {
message.value = "测试请求成功";
}
message.value = "测试请求成功";
} finally {
loading.value = false;
}
@@ -42,6 +42,9 @@ const emit = defineEmits<{
const attrs = useAttrs();
const getCurrentPluginDefine: any = inject("getCurrentPluginDefine");
const getScope: any = inject("get:scope");
const getPluginType: any = inject("get:plugin:type");
const optionsRef = ref([]);
const message = ref("");
const hasError = ref(false);
@@ -75,13 +78,16 @@ const getOptions = async () => {
hasError.value = false;
loading.value = true;
optionsRef.value = [];
const { form } = getScope();
const pluginType = getPluginType();
try {
const res = await doRequest(
{
type: props.type,
typeName: props.typeName,
type: pluginType,
typeName: form.type,
action: props.action,
input: props.form
input: form
},
{
onError(err: any) {
@@ -1,9 +1,9 @@
import { request } from "/@/api/service";
export type ComponentPropsType = {
type: string;
typeName: string;
action?: string;
form: any;
type?: string;
typeName?: string;
action: string;
form?: any;
value?: any;
};
export type RequestHandleReq<T = any> = {
@@ -15,7 +15,7 @@ export type RequestHandleReq<T = any> = {
};
export async function doRequest(req: RequestHandleReq, opts: any = {}) {
const url = req.type === "access" ? "/pi/handle/access" : "/pi/handle/plugin";
const url = `/pi/handle/${req.type}`;
const { typeName, action, data, input } = req;
const res = await request({
url,
@@ -19,7 +19,6 @@ defineOptions({
});
const props = defineProps<ComponentPropsType>();
const emit = defineEmits<{
"update:value": any;
}>();
@@ -6,6 +6,9 @@ import SecretPlainGetter from "/@/views/certd/access/access-selector/access/secr
export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any) {
provide("accessApi", api);
provide("get:plugin:type", () => {
return "access";
});
const AccessTypeDictRef = dict({
url: "/pi/access/accessTypeDict"
});
@@ -1,10 +1,13 @@
import { ColumnCompositionProps, dict } from "@fast-crud/fast-crud";
import { ColumnCompositionProps, compute, dict } from "@fast-crud/fast-crud";
import { computed, provide, ref, toRef } from "vue";
import { useReference } from "/@/use/use-refrence";
import { forEach, get, merge, set } from "lodash-es";
export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any) {
provide("notificationApi", api);
provide("get:plugin:type", () => {
return "notification";
});
const notificationTypeDictRef = dict({
url: "/pi/notification/getTypeDict"
});
@@ -125,6 +128,26 @@ export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any) {
})
}
} as ColumnCompositionProps,
test: {
title: "测试",
form: {
component: {
name: "api-test",
type: "notification",
typeName: compute(({ form }) => {
return form.type;
}),
action: "TestRequest",
form: compute(({ form }) => {
return form;
})
},
order: 999
},
column: {
show: false
}
},
setting: {
column: { show: false },
form: {
@@ -222,6 +222,9 @@ export default {
provide("getCurrentPluginDefine", () => {
return currentPluginDefine;
});
provide("get:plugin:type", () => {
return "plugin";
});
function getContext() {
return {