mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
perf: EAB授权支持绑定邮箱,支持公共EAB设置
This commit is contained in:
@@ -96,6 +96,20 @@ export const sysResources = [
|
||||
permission: "sys:settings:view"
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "证书插件配置",
|
||||
name: "SysPluginConfig",
|
||||
path: "/sys/plugin/config",
|
||||
component: "/sys/plugin/config.vue",
|
||||
meta: {
|
||||
show: () => {
|
||||
const settingStore = useSettingStore();
|
||||
return settingStore.isComm;
|
||||
},
|
||||
icon: "ion:extension-puzzle-outline",
|
||||
permission: "sys:settings:view"
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "账号绑定",
|
||||
name: "AccountBind",
|
||||
|
||||
@@ -222,3 +222,8 @@ h1, h2, h3, h4, h5, h6 {
|
||||
/* right: 0; */
|
||||
}
|
||||
}
|
||||
|
||||
.settings-form {
|
||||
width: 800px;
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// @ts-ignore
|
||||
import { ref } from "vue";
|
||||
import { getCommonColumnDefine } from "/@/views/certd/access/common";
|
||||
import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
|
||||
import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
|
||||
|
||||
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
||||
const { crudBinding } = crudExpose;
|
||||
const { props, ctx } = context;
|
||||
const { props, ctx, api } = context;
|
||||
const lastResRef = ref();
|
||||
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
|
||||
return await context.api.GetList(query);
|
||||
@@ -108,6 +108,33 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
width: 200
|
||||
}
|
||||
},
|
||||
from: {
|
||||
title: "级别",
|
||||
type: "dict-select",
|
||||
dict: dict({
|
||||
data: [
|
||||
{ label: "系统", value: "sys" },
|
||||
{ label: "用户", value: "user" }
|
||||
]
|
||||
}),
|
||||
search: {
|
||||
show: false
|
||||
},
|
||||
form: {
|
||||
show: false
|
||||
},
|
||||
column: {
|
||||
width: 100,
|
||||
align: "center",
|
||||
component: {
|
||||
color: "auto"
|
||||
},
|
||||
order: 10
|
||||
},
|
||||
valueBuilder: ({ row, key, value }) => {
|
||||
row[key] = row.userId > 0 ? "user" : "sys";
|
||||
}
|
||||
},
|
||||
...commonColumnsDefine
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export default defineComponent({
|
||||
},
|
||||
emits: ["update:modelValue"],
|
||||
setup(props, ctx) {
|
||||
const api = createAccessApi(props.from === "sys" ? "/sys/access" : "/pi/access");
|
||||
const api = createAccessApi(props.from);
|
||||
const context: any = { props, ctx, api };
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context });
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<a-form-item-rest v-if="chooseForm.show">
|
||||
<a-modal v-model:open="chooseForm.show" title="选择授权提供者" width="900px" @ok="chooseForm.ok">
|
||||
<div style="height: 400px; position: relative">
|
||||
<cert-access-modal v-model="selectedId" :type="type"></cert-access-modal>
|
||||
<cert-access-modal v-model="selectedId" :type="type" :from="from"></cert-access-modal>
|
||||
</div>
|
||||
</a-modal>
|
||||
</a-form-item-rest>
|
||||
@@ -48,7 +48,7 @@ export default defineComponent({
|
||||
},
|
||||
emits: ["update:modelValue"],
|
||||
setup(props, ctx) {
|
||||
const api = createAccessApi(props.from === "sys" ? "/sys/access" : "/pi/access");
|
||||
const api = createAccessApi(props.from);
|
||||
|
||||
const target = ref({});
|
||||
const selectedId = ref();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { request } from "/src/api/service";
|
||||
|
||||
export function createAccessApi(apiPrefix = "/pi/access") {
|
||||
export function createAccessApi(from = "user") {
|
||||
const apiPrefix = from === "sys" ? "/sys/access" : "/pi/access";
|
||||
return {
|
||||
async GetList(query: any) {
|
||||
return await request({
|
||||
|
||||
@@ -19,7 +19,7 @@ import { createAccessApi } from "/@/views/certd/access/api";
|
||||
export default defineComponent({
|
||||
name: "AccessManager",
|
||||
setup() {
|
||||
const api = createAccessApi("/pi/access");
|
||||
const api = createAccessApi("user");
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: { api } });
|
||||
|
||||
// 页面打开后获取列表数据
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { request } from "/src/api/service";
|
||||
import _ from "lodash-es";
|
||||
import { PluginConfigBean, PluginSysSetting } from "/@/views/sys/plugin/api";
|
||||
const apiPrefix = "/pi/plugin";
|
||||
|
||||
const defaultInputDefine = {
|
||||
@@ -54,3 +55,11 @@ export async function GetGroups(query: any) {
|
||||
initPlugins(plugins);
|
||||
return groups;
|
||||
}
|
||||
|
||||
export async function GetPluginConfig(req: { id?: number; name: string; type: string }): Promise<PluginConfigBean> {
|
||||
return await request({
|
||||
url: apiPrefix + "/config",
|
||||
method: "post",
|
||||
data: req
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { compute, CreateCrudOptionsRet, dict } from "@fast-crud/fast-crud";
|
||||
import { PluginGroup } from "@certd/pipeline";
|
||||
import { useReference } from "/@/use/use-refrence";
|
||||
import _ from "lodash-es";
|
||||
import _, { merge } from "lodash-es";
|
||||
import { useUserStore } from "/@/store/modules/user";
|
||||
import { useSettingStore } from "/@/store/modules/settings";
|
||||
|
||||
import * as api from "../api.plugin";
|
||||
export default function (certPluginGroup: PluginGroup, formWrapperRef: any): CreateCrudOptionsRet {
|
||||
const inputs: any = {};
|
||||
const userStore = useUserStore();
|
||||
@@ -46,7 +46,7 @@ export default function (certPluginGroup: PluginGroup, formWrapperRef: any): Cre
|
||||
crudOptions: {
|
||||
form: {
|
||||
wrapper: {
|
||||
width: "1150px",
|
||||
width: 1350,
|
||||
saveRemind: false,
|
||||
title: "创建证书申请流水线"
|
||||
}
|
||||
@@ -73,6 +73,19 @@ export default function (certPluginGroup: PluginGroup, formWrapperRef: any): Cre
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
},
|
||||
valueChange: {
|
||||
handle: async ({ form, value }) => {
|
||||
debugger;
|
||||
const config = await api.GetPluginConfig({
|
||||
name: value,
|
||||
type: "builtIn"
|
||||
});
|
||||
if (config.sysSetting?.input) {
|
||||
merge(form, config.sysSetting.input);
|
||||
}
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+12
-4
@@ -116,7 +116,7 @@ import { useUserStore } from "/@/store/modules/user";
|
||||
import { compute, useCompute } from "@fast-crud/fast-crud";
|
||||
import { useReference } from "/@/use/use-refrence";
|
||||
import { useSettingStore } from "/@/store/modules/settings";
|
||||
|
||||
import * as pluginApi from "../../../api.plugin";
|
||||
export default {
|
||||
name: "PiStepForm",
|
||||
// eslint-disable-next-line vue/no-unused-components
|
||||
@@ -163,7 +163,7 @@ export default {
|
||||
console.log("currentStepTypeChanged:", currentStep.value);
|
||||
};
|
||||
|
||||
const stepTypeSave = () => {
|
||||
const stepTypeSave = async () => {
|
||||
currentStep.value._isAdd = false;
|
||||
if (currentStep.value.type == null) {
|
||||
message.warn("请先选择类型");
|
||||
@@ -171,7 +171,7 @@ export default {
|
||||
}
|
||||
|
||||
// 给step的input设置默认值
|
||||
changeCurrentPlugin(currentStep.value);
|
||||
await changeCurrentPlugin(currentStep.value);
|
||||
|
||||
//合并默认值
|
||||
_.merge(currentStep.value, { input: {}, strategy: { runStrategy: 0 } }, currentPlugin.value.default, currentStep.value);
|
||||
@@ -229,7 +229,7 @@ export default {
|
||||
const currentPlugin = doComputed(() => {
|
||||
return currentPluginDefine.value;
|
||||
}, getContext);
|
||||
const changeCurrentPlugin = (step: any) => {
|
||||
const changeCurrentPlugin = async (step: any) => {
|
||||
const stepType = step.type;
|
||||
step.type = stepType;
|
||||
step._isAdd = false;
|
||||
@@ -255,6 +255,14 @@ export default {
|
||||
currentStep.value.input[key] = column.default ?? column.value;
|
||||
}
|
||||
}
|
||||
//设置系统初始值
|
||||
debugger;
|
||||
const pluginSysConfig = await pluginApi.GetPluginConfig({ name: pluginDefine.name, type: "builtIn" });
|
||||
if (pluginSysConfig.sysSetting?.input) {
|
||||
for (const key in pluginSysConfig.sysSetting?.input) {
|
||||
currentStep.value.input[key] = pluginSysConfig.sysSetting?.input[key];
|
||||
}
|
||||
}
|
||||
|
||||
console.log("currentStepTypeChanged:", currentStep.value);
|
||||
console.log("currentStepPlugin:", currentPlugin.value);
|
||||
|
||||
@@ -20,7 +20,7 @@ export type PluginGroup = {
|
||||
};
|
||||
|
||||
export type PluginDefine = {
|
||||
key: string;
|
||||
name: string;
|
||||
title: string;
|
||||
desc?: string;
|
||||
input: {
|
||||
|
||||
@@ -58,10 +58,43 @@ export async function DeleteBatch(ids: any[]) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function SetDisabled(bean: { id?: number; name?: string; type?: string; disabled: boolean }) {
|
||||
export async function SetDisabled(data: { id?: number; name?: string; type?: string; disabled: boolean }) {
|
||||
return await request({
|
||||
url: apiPrefix + "/setDisabled",
|
||||
method: "post",
|
||||
data: bean
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
export type PluginConfigBean = {
|
||||
name: string;
|
||||
disabled: boolean;
|
||||
sysSetting: {
|
||||
input?: Record<string, any>;
|
||||
};
|
||||
};
|
||||
|
||||
export type CertApplyPluginSysInput = {
|
||||
googleCommonEabAccessId: number;
|
||||
};
|
||||
export type PluginSysSetting<T> = {
|
||||
input?: T;
|
||||
};
|
||||
export type CommPluginConfig = {
|
||||
CertApply?: PluginSysSetting<CertApplyPluginSysInput>;
|
||||
};
|
||||
|
||||
export async function GetCommPluginConfigs(): Promise<CommPluginConfig> {
|
||||
return await request({
|
||||
url: apiPrefix + "/getCommPluginConfigs",
|
||||
method: "post"
|
||||
});
|
||||
}
|
||||
|
||||
export async function SaveCommPluginConfigs(data: CommPluginConfig): Promise<void> {
|
||||
return await request({
|
||||
url: apiPrefix + "/saveCommPluginConfigs",
|
||||
method: "post",
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<template>
|
||||
<fs-page class="page-plugin-config">
|
||||
<template #header>
|
||||
<div class="title">证书插件配置</div>
|
||||
</template>
|
||||
|
||||
<div class="sys-plugin-config settings-form">
|
||||
<a-form :model="formState" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" @finish="onFinish" @finish-failed="onFinishFailed">
|
||||
<a-form-item label="公共Google EAB授权" :name="['CertApply', 'input', 'googleCommonEabAccessId']">
|
||||
<access-selector v-model:model-value="formState.CertApply.input.googleCommonEabAccessId" type="eab" from="sys"></access-selector>
|
||||
<div class="helper">设置公共Google EAB授权给用户使用,避免用户自己去翻墙获取Google EAB授权</div>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item :wrapper-col="{ offset: 8, span: 16 }">
|
||||
<a-button :loading="saveLoading" type="primary" html-type="submit">保存</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
</fs-page>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import AccessSelector from "/@/views/certd/access/access-selector/index.vue";
|
||||
import { reactive, ref } from "vue";
|
||||
import { CommPluginConfig, GetCommPluginConfigs, SaveCommPluginConfigs } from "/@/views/sys/plugin/api";
|
||||
import { merge } from "lodash-es";
|
||||
import { notification } from "ant-design-vue";
|
||||
|
||||
defineOptions({
|
||||
name: "SysPluginConfig"
|
||||
});
|
||||
const formState = reactive<Partial<CommPluginConfig>>({
|
||||
CertApply: {
|
||||
input: {}
|
||||
}
|
||||
});
|
||||
|
||||
async function loadForm() {
|
||||
const res = await GetCommPluginConfigs();
|
||||
merge(formState, res);
|
||||
}
|
||||
|
||||
loadForm();
|
||||
|
||||
const saveLoading = ref(false);
|
||||
const onFinish = async (form: any) => {
|
||||
try {
|
||||
saveLoading.value = true;
|
||||
await SaveCommPluginConfigs(form);
|
||||
notification.success({
|
||||
message: "保存成功"
|
||||
});
|
||||
} finally {
|
||||
saveLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const onFinishFailed = (errorInfo: any) => {
|
||||
console.log("Failed:", errorInfo);
|
||||
};
|
||||
</script>
|
||||
<style lang="less"></style>
|
||||
@@ -3,7 +3,7 @@
|
||||
<template #header>
|
||||
<div class="title">系统设置</div>
|
||||
</template>
|
||||
<div class="sys-settings-form">
|
||||
<div class="sys-settings-form settings-form">
|
||||
<a-form
|
||||
:model="formState"
|
||||
name="basic"
|
||||
|
||||
Reference in New Issue
Block a user