mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
chore:
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<script setup lang="ts">
|
||||
import { inject, ref, watch } from "vue";
|
||||
|
||||
const props = defineProps<{
|
||||
inputKey?: string;
|
||||
modelValue?: string[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
"update:modelValue": any;
|
||||
}>();
|
||||
|
||||
const pipeline: any = inject("pipeline");
|
||||
|
||||
function findStepFromPipeline(targetStepId: string) {
|
||||
for (const stage of pipeline.value.stages) {
|
||||
for (const task of stage.tasks) {
|
||||
for (const step of task.steps) {
|
||||
if (step.id === targetStepId) {
|
||||
return step;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const errorRef = ref("");
|
||||
function getDomainFromPipeline(inputKey: string) {
|
||||
if (!inputKey) {
|
||||
errorRef.value = "请先选择域名证书";
|
||||
return;
|
||||
}
|
||||
const targetStepId = inputKey.split(".")[1];
|
||||
const certStep = findStepFromPipeline(targetStepId);
|
||||
if (!certStep) {
|
||||
errorRef.value = "找不到目标步骤,请先选择域名证书";
|
||||
return;
|
||||
}
|
||||
const domain = certStep.input["domains"];
|
||||
emit("update:modelValue", domain);
|
||||
}
|
||||
|
||||
watch(
|
||||
() => {
|
||||
return props.inputKey;
|
||||
},
|
||||
(inputKey: string) => {
|
||||
getDomainFromPipeline(inputKey);
|
||||
},
|
||||
{
|
||||
immediate: true
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-select mode="tags" readonly :value="modelValue" />
|
||||
<div>{{ errorRef }}</div>
|
||||
</template>
|
||||
|
||||
<style lang="less"></style>
|
||||
@@ -22,6 +22,19 @@ const getOptions = async () => {
|
||||
});
|
||||
};
|
||||
|
||||
const filterOption = (input: string, option: any) => {
|
||||
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 || String(option.value).toLowerCase().indexOf(input.toLowerCase());
|
||||
};
|
||||
|
||||
let isFirst = true;
|
||||
async function onClick() {
|
||||
if (!isFirst) {
|
||||
return;
|
||||
}
|
||||
isFirst = false;
|
||||
optionsRef.value = await getOptions();
|
||||
}
|
||||
|
||||
watch(
|
||||
() => {
|
||||
const values = [];
|
||||
@@ -35,13 +48,20 @@ watch(
|
||||
},
|
||||
async () => {
|
||||
optionsRef.value = await getOptions();
|
||||
},
|
||||
{ immediate: true }
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-select class="remote-select" :options="optionsRef" :value="value" @update:value="emit('update:value', $event)" />
|
||||
<a-select
|
||||
class="remote-select"
|
||||
show-search
|
||||
:filter-option="filterOption"
|
||||
:options="optionsRef"
|
||||
:value="value"
|
||||
@click="onClick"
|
||||
@update:value="emit('update:value', $event)"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style lang="less"></style>
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import SynologyIdDeviceGetter from "./synology/device-id-getter.vue";
|
||||
import RemoteSelect from "./common/remote-select.vue";
|
||||
import CertDomainsGetter from "./common/cert-domains-getter.vue";
|
||||
export default {
|
||||
install(app: any) {
|
||||
app.component("SynologyDeviceIdGetter", SynologyIdDeviceGetter);
|
||||
app.component("RemoteSelect", RemoteSelect);
|
||||
app.component("CertDomainsGetter", CertDomainsGetter);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7,10 +7,10 @@ export type ComponentPropsType = {
|
||||
value?: any;
|
||||
};
|
||||
export type RequestHandleReq<T = any> = {
|
||||
type: strin;
|
||||
type: string;
|
||||
typeName: string;
|
||||
action: string;
|
||||
data: any;
|
||||
data?: any;
|
||||
input: T;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user