This commit is contained in:
xiaojunnuo
2024-09-30 18:00:51 +08:00
parent 8d42273665
commit 17a9beb514
12 changed files with 149 additions and 22 deletions
@@ -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;
};
@@ -4,6 +4,20 @@
# server:
# baseUrl: 'http://127.0.0.1:11007'
#flyway:
# scriptDir: './db/migration-pg'
#typeorm:
# dataSource:
# default:
# type: postgres
# host: localhost
# port: 5433
# username: postgres
# password: root
# database: postgres
plus:
server:
baseUrls: ['https://api.ai.handsfree.work', 'https://api.ai.docmirror.cn']
+1 -1
View File
@@ -16,7 +16,7 @@
"build": "mwtsc --cleanOutDir --skipLibCheck",
"build-on-docker": "node ./before-build.js && npm run build",
"up-mw-deps": "npx midway-version -u -w",
"heap": "clinic heapprofiler -- node ./bootstrap.js",
"heap": "clinic heapprofiler -- node ./bootstrap.js",
"flame": "clinic flame -- node ./bootstrap.js"
},
"dependencies": {
@@ -37,22 +37,19 @@ export class HandleController extends BaseController {
//@ts-ignore
const access = new accessCls();
let isNew = true;
let inputAccess = body.input.access;
if (body.input.id > 0) {
const oldEntity = await this.accessService.info(body.input.id);
if (!oldEntity) {
isNew = false;
const param = {
if (oldEntity) {
const param: any = {
type: body.typeName,
setting: JSON.stringify(body.input.access),
};
this.accessService.encryptSetting(param, oldEntity);
body.input.access = JSON.parse(param.setting);
inputAccess = this.accessService.decryptAccessEntity(param);
}
}
if (isNew) {
mergeUtils.merge(access, body.input.access);
}
mergeUtils.merge(access, inputAccess);
const ctx: AccessRequestHandleContext = {
http: http,
@@ -108,6 +108,14 @@ export class AccessService extends BaseService<AccessEntity> implements IAccessS
throw new Error(`该授权配置不存在,请确认是否已被删除:id=${id}`);
}
// const access = accessRegistry.get(entity.type);
const setting = this.decryptAccessEntity(entity);
return {
id: entity.id,
...setting,
};
}
decryptAccessEntity(entity: AccessEntity): any {
let setting = {};
if (entity.encryptSetting && entity.encryptSetting !== '{}') {
setting = JSON.parse(entity.encryptSetting);
@@ -123,10 +131,7 @@ export class AccessService extends BaseService<AccessEntity> implements IAccessS
} else if (entity.setting) {
setting = JSON.parse(entity.setting);
}
return {
id: entity.id,
...setting,
};
return setting;
}
getDefineList() {