mirror of https://github.com/certd/certd
perf: 授权加密支持解密查看
parent
6dabad76ba
commit
5575c83970
|
@ -0,0 +1,32 @@
|
||||||
|
<template>
|
||||||
|
<a-button class="cd-secret-plain-getter ml-5">
|
||||||
|
<fs-icon class="pointer" :icon="computedIcon" @click="showPlain" />
|
||||||
|
</a-button>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, inject, ref } from "vue";
|
||||||
|
defineOptions({
|
||||||
|
name: "SecretPlainGetter"
|
||||||
|
});
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
modelValue?: string;
|
||||||
|
accessId?: number;
|
||||||
|
inputKey: string;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits(["update:modelValue"]);
|
||||||
|
const showRef = ref(false);
|
||||||
|
const computedIcon = computed(() => {
|
||||||
|
return showRef.value ? "ion:eye-outline" : "ion:eye-off-outline";
|
||||||
|
});
|
||||||
|
const accessApi: any = inject("accessApi");
|
||||||
|
async function showPlain() {
|
||||||
|
showRef.value = true;
|
||||||
|
if (props.accessId) {
|
||||||
|
const plain = await accessApi.GetSecretPlain(props.accessId, props.inputKey);
|
||||||
|
emit("update:modelValue", plain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style lang="less"></style>
|
|
@ -43,6 +43,14 @@ export function createAccessApi(from = "user") {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async GetSecretPlain(id: number, key: string) {
|
||||||
|
return await request({
|
||||||
|
url: apiPrefix + "/getSecretPlain",
|
||||||
|
method: "post",
|
||||||
|
data: { id, key }
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
async GetProviderDefine(type: string) {
|
async GetProviderDefine(type: string) {
|
||||||
return await request({
|
return await request({
|
||||||
url: apiPrefix + "/define",
|
url: apiPrefix + "/define",
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import { ColumnCompositionProps, dict } from "@fast-crud/fast-crud";
|
import { ColumnCompositionProps, dict } from "@fast-crud/fast-crud";
|
||||||
import { computed, ref, toRef } from "vue";
|
import { computed, provide, ref, toRef } from "vue";
|
||||||
import { useReference } from "/@/use/use-refrence";
|
import { useReference } from "/@/use/use-refrence";
|
||||||
import { forEach, get, merge, set } from "lodash-es";
|
import { forEach, get, merge, set } from "lodash-es";
|
||||||
|
import SecretPlainGetter from "/@/views/certd/access/access-selector/access/secret-plain-getter.vue";
|
||||||
|
|
||||||
export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any) {
|
export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any) {
|
||||||
|
provide("accessApi", api);
|
||||||
const AccessTypeDictRef = dict({
|
const AccessTypeDictRef = dict({
|
||||||
url: "/pi/access/accessTypeDict"
|
url: "/pi/access/accessTypeDict"
|
||||||
});
|
});
|
||||||
|
@ -32,6 +34,13 @@ export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any) {
|
||||||
};
|
};
|
||||||
const column = merge({ title: key }, defaultPluginConfig, field);
|
const column = merge({ title: key }, defaultPluginConfig, field);
|
||||||
|
|
||||||
|
if (value.encrypt === true) {
|
||||||
|
column.suffixRender = (scope: { form: any; key: string }) => {
|
||||||
|
const { form, key } = scope;
|
||||||
|
const inputKey = scope.key.replace("access.", "");
|
||||||
|
return <SecretPlainGetter accessId={form.id} inputKey={inputKey} v-model={form[key]} />;
|
||||||
|
};
|
||||||
|
}
|
||||||
//eval
|
//eval
|
||||||
useReference(column);
|
useReference(column);
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,12 @@ export class AccessController extends CrudController<AccessService> {
|
||||||
return this.ok(access);
|
return this.ok(access);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post('/getSecretPlain', { summary: Constants.per.authOnly })
|
||||||
|
async getSecretPlain(@Body(ALL) body: { id: number; key: string }) {
|
||||||
|
const value = await this.service.getById(body.id, this.getUserId());
|
||||||
|
return this.ok(value[body.key]);
|
||||||
|
}
|
||||||
|
|
||||||
@Post('/accessTypeDict', { summary: Constants.per.authOnly })
|
@Post('/accessTypeDict', { summary: Constants.per.authOnly })
|
||||||
async getAccessTypeDict() {
|
async getAccessTypeDict() {
|
||||||
const list = this.service.getDefineList();
|
const list = this.service.getDefineList();
|
||||||
|
|
Loading…
Reference in New Issue