mirror of
https://github.com/certd/certd.git
synced 2026-04-23 11:37:23 +08:00
perf: 通知渠道支持测试按钮
This commit is contained in:
@@ -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;
|
||||
}>();
|
||||
|
||||
Reference in New Issue
Block a user