Merge branch 'v2-dev' of https://github.com/certd/certd into v2-dev

This commit is contained in:
xiaojunnuo
2026-03-12 18:11:09 +08:00
56 changed files with 587 additions and 151 deletions
@@ -1,7 +1,7 @@
<template>
<div class="remote-select">
<div class="flex flex-row">
<a-select class="remote-select-input" show-search :filter-option="filterOption" :options="optionsRef" :value="value" v-bind="attrs" @click="onClick" @update:value="emit('update:value', $event)">
<a-select class="remote-select-input" show-search mode="tags" :filter-option="filterOption" :options="optionsRef" :value="value" v-bind="attrs" @click="onClick" @update:value="updateValue($event)">
<template #dropdownRender="{ menuNode: menu }">
<template v-if="search">
<div class="flex w-full" style="padding: 4px 8px">
@@ -61,6 +61,7 @@ const props = defineProps<
watches?: string[];
search?: boolean;
pager?: boolean;
multi?: boolean;
} & ComponentPropsType
>();
@@ -68,6 +69,15 @@ const emit = defineEmits<{
"update:value": any;
}>();
function updateValue(value: any) {
if (props.multi) {
emit("update:value", value);
} else {
const last = value?.[value.length - 1];
emit("update:value", last);
}
}
const attrs = useAttrs();
const getCurrentPluginDefine: any = inject("getCurrentPluginDefine", () => {
@@ -80,6 +90,7 @@ const getPluginType: any = inject("get:plugin:type", () => {
return "plugin";
});
debugger;
const searchKeyRef = ref("");
const optionsRef = ref([]);
const message = ref("");
@@ -789,6 +789,8 @@ export default {
reverseProxyHelper: "Reverse proxy for ACME address, used when applying for certificate",
reverseProxyPlaceholder: "http://le.px.handfree.work",
reverseProxyEmpty: "No reverse proxy list configured",
environmentVars: "Environment Variables",
environmentVarsHelper: "configure the runtime environment variables, one per line, format: KEY=VALUE",
},
},
modal: {
@@ -800,6 +800,8 @@ export default {
reverseProxyHelper: "证书颁发机构ACME地址的反向代理,在申请证书时自动使用",
reverseProxyPlaceholder: "http://le.px.handfree.work",
reverseProxyEmpty: "未配置反向代理",
environmentVars: "环境变量",
environmentVarsHelper: "配置运行时环境变量,每行一个,格式:KEY=VALUE",
},
},
modal: {
@@ -127,6 +127,21 @@ export const certdResources = [
keepAlive: true,
},
},
{
title: "certd.sysResources.currentProject",
name: "ProjectMemberManager",
path: "/certd/project/detail",
component: "/certd/project/detail/index.vue",
meta: {
show: () => {
const projectStore = useProjectStore();
return projectStore.isEnterprise;
},
isMenu: true,
icon: "ion:apps",
auth: true,
},
},
{
title: "certd.settings",
name: "MineSetting",
@@ -263,21 +278,6 @@ export const certdResources = [
isMenu: true,
},
},
{
title: "certd.sysResources.projectMemberManager",
name: "ProjectMemberManager",
path: "/certd/project/detail",
component: "/certd/project/detail/index.vue",
meta: {
show: () => {
const projectStore = useProjectStore();
return projectStore.isEnterprise;
},
isMenu: true,
icon: "ion:apps",
auth: true,
},
},
],
},
{
@@ -101,6 +101,8 @@ export type SysPrivateSetting = {
commonCnameEnabled?: boolean;
// 同一个用户同时最大运行流水线数量
pipelineMaxRunningCount?: number;
// 环境变量
environmentVars?: string;
sms?: {
type?: string;
+14 -8
View File
@@ -1,4 +1,5 @@
import { useFormWrapper } from "@fast-crud/fast-crud";
import { merge } from "lodash-es";
export type FormOptionReq = {
title: string;
@@ -7,6 +8,7 @@ export type FormOptionReq = {
body?: any;
initialForm?: any;
zIndex?: number;
wrapper?: any;
};
export function useFormDialog() {
@@ -14,19 +16,23 @@ export function useFormDialog() {
async function openFormDialog(req: FormOptionReq) {
function createCrudOptions() {
const warpper = merge(
{
zIndex: req.zIndex,
title: req.title,
saveRemind: false,
slots: {
"form-body-top": req.body,
},
},
req.wrapper
);
return {
crudOptions: {
columns: req.columns,
form: {
initialForm: req.initialForm,
wrapper: {
zIndex: req.zIndex,
title: req.title,
saveRemind: false,
slots: {
"form-body-top": req.body,
},
},
wrapper: warpper,
async afterSubmit() {},
async doSubmit({ form }: any) {
if (req.onSubmit) {
@@ -1,5 +1,5 @@
import * as _ from "lodash-es";
import { asyncCompute, compute } from "@fast-crud/fast-crud";
import { merge } from "lodash-es";
import { computed } from "vue";
export type MergeScriptContext = {
@@ -18,7 +18,7 @@ export function useReference(formItem: any) {
const script = formItem.mergeScript;
const func = new Function("ctx", script);
const merged = func(ctx);
_.merge(formItem, merged);
merge(formItem, merged);
delete formItem.mergeScript;
}
@@ -6,7 +6,7 @@ import { useRouter } from "vue-router";
import { compute, CreateCrudOptionsRet, dict, useFormWrapper } from "@fast-crud/fast-crud";
import NotificationSelector from "/@/views/certd/notification/notification-selector/index.vue";
import { useReference } from "/@/use/use-refrence";
import { computed, ref } from "vue";
import { computed, provide, Ref, ref } from "vue";
import * as api from "../api";
import { PluginGroup, usePluginStore } from "/@/store/plugin";
import { createNotificationApi } from "/@/views/certd/notification/api";
@@ -89,9 +89,10 @@ export function useCertPipelineCreator() {
const inputs: any = {};
const moreParams = [];
const doSubmit = req.doSubmit;
for (const inputKey in req.certPlugin.input) {
const certPlugin = req.certPlugin;
for (const inputKey in certPlugin.input) {
// inputs[inputKey].form.show = true;
const inputDefine = cloneDeep(req.certPlugin.input[inputKey]);
const inputDefine = cloneDeep(certPlugin.input[inputKey]);
if (inputDefine.maybeNeed) {
moreParams.push(inputKey);
}
@@ -103,7 +104,6 @@ export function useCertPipelineCreator() {
},
};
}
const pluginStore = usePluginStore();
const randomHour = Math.floor(Math.random() * 6);
const randomMin = Math.floor(Math.random() * 60);
@@ -322,7 +322,7 @@ export function useCertPipelineCreator() {
return certPlugins;
}
async function openAddCertdPipelineDialog(req: { pluginName: string; defaultGroupId?: number; title?: string }) {
async function openAddCertdPipelineDialog(req: { pluginName: string; defaultGroupId?: number; title?: string; currentPluginRef: Ref<any> }) {
//检查是否流水线数量超出限制
await checkPipelineLimit();
@@ -393,6 +393,8 @@ export function useCertPipelineCreator() {
message.error("该证书申请插件不存在");
return;
}
req.currentPluginRef.value = certPlugin;
const { crudOptions } = createCrudOptions({
certPlugin,
doSubmit,
@@ -52,7 +52,7 @@
</template>
<script lang="ts" setup>
import { computed, onActivated, onMounted, ref } from "vue";
import { computed, onActivated, onMounted, provide, ref } from "vue";
import { dict, useFs } from "@fast-crud/fast-crud";
import createCrudOptions from "./crud";
import ChangeGroup from "./components/change-group.vue";
@@ -69,6 +69,7 @@ import { groupDictRef } from "./group/dicts";
import { useCertPipelineCreator } from "./certd-form/use";
import { useRouter } from "vue-router";
import { useCrudPermission } from "/@/plugin/permission";
import CertdForm from "./certd-form/certd-form.vue";
defineOptions({
name: "PipelineManager",
@@ -79,11 +80,17 @@ const context: any = {
selectedRowKeys,
};
const router = useRouter();
const { openAddCertdPipelineDialog } = useCertPipelineCreator();
function onActionbarMoreItemClick(req: { key: string; item: any }) {
openCertApplyDialog({ key: req.key, title: req.item?.title });
}
const certdFormRef = ref<typeof CertdForm>();
const currentPluginRef = ref();
provide("getCurrentPluginDefine", () => {
return currentPluginRef.value;
});
const addMorePipelineBtns = computed(() => {
return [
{ key: "CertApplyGetFormAliyun", title: t("certd.pipelinePage.aliyunSubscriptionPipeline"), icon: "svg:icon-aliyun" },
@@ -92,6 +99,7 @@ const addMorePipelineBtns = computed(() => {
{ key: "BatchAddPipeline", title: t("certd.pipelinePage.batchAddPipeline"), icon: "ion:duplicate" },
];
});
const { openAddCertdPipelineDialog } = useCertPipelineCreator();
function openCertApplyDialog(req: { key: string; title: string }) {
if (req.key === "AddPipeline") {
crudExpose.openAdd({});
@@ -104,7 +112,7 @@ function openCertApplyDialog(req: { key: string; title: string }) {
const searchForm = crudExpose.getSearchValidatedFormData();
const defaultGroupId = searchForm.groupId;
openAddCertdPipelineDialog({ pluginName: req.key, defaultGroupId, title: req.title });
openAddCertdPipelineDialog({ pluginName: req.key, defaultGroupId, title: req.title, currentPluginRef });
}
context.openCertApplyDialog = openCertApplyDialog;
context.permission = { isProjectPermission: true };
@@ -294,13 +294,9 @@ function useStepForm() {
currentStep.value.input[key] = pluginSysConfig.sysSetting?.input[key];
}
}
console.log("currentStepTypeChanged:", currentStep.value);
console.log("currentStepPlugin:", currentPlugin.value);
};
const stepSave = async (e: any) => {
console.log("currentStepSave", currentStep.value);
try {
await stepFormRef.value.validate();
} catch (e) {
@@ -73,3 +73,17 @@ export async function ApproveJoin(form: any) {
data: form,
});
}
export async function GetSelfResources() {
return await request({
url: "/enterprise/transfer/selfResources",
method: "post",
});
}
export async function TransferResources() {
return await request({
url: "/enterprise/transfer/doTransfer",
method: "post",
});
}
@@ -9,8 +9,12 @@
<fs-values-format :model-value="project.permission" :dict="projectPermissionDict"></fs-values-format>
<a-divider type="vertical"></a-divider>
<fs-values-format :model-value="project.status" :dict="projectMemberStatusDict"></fs-values-format> -->
<a-divider type="vertical"></a-divider>
<a-button class="mr-5" type="primary" @click="openTransferDialog">个人数据迁移</a-button>
<a-button v-if="userStore.isAdmin" type="primary" @click="goProjectManager">{{ t("certd.project.projectManage") }}</a-button>
</span>
</div>
<div class="more"></div>
</template>
<fs-crud ref="crudRef" v-bind="crudBinding">
<template #pagination-left>
@@ -29,11 +33,13 @@ import createCrudOptions from "./crud";
import { message, Modal } from "ant-design-vue";
import { DeleteBatch } from "./api";
import { useI18n } from "/src/locales";
import { useRoute } from "vue-router";
import { useRoute, useRouter } from "vue-router";
import { useProjectStore } from "/@/store/project";
import { request } from "/@/api/service";
import { useDicts } from "../../dicts";
import { useCrudPermission } from "/@/plugin/permission";
import { useUserStore } from "/@/store/user";
import { useTransfer } from "./use";
const { t } = useI18n();
@@ -49,6 +55,14 @@ if (!projectId) {
projectId = projectStore.currentProject?.id;
}
const router = useRouter();
const userStore = useUserStore();
function goProjectManager() {
router.push(`/sys/enterprise/project`);
}
const { openTransferDialog } = useTransfer();
const { projectPermissionDict, projectMemberStatusDict, userDict } = useDicts();
const project: Ref<any> = ref({});
@@ -1,46 +0,0 @@
import { dict } from "@fast-crud/fast-crud";
import { useDicts } from "../../dicts";
import { useFormDialog } from "/@/use/use-dialog";
export function useApprove() {
const { openFormDialog } = useFormDialog();
const { projectPermissionDict, projectMemberStatusDict, userDict } = useDicts();
function openApproveDialog({ id, permission, onSubmit }: { id: any; permission: any; onSubmit: any }) {
openFormDialog({
title: "审批加入申请",
columns: {
permission: {
title: "成员权限",
type: "dict-select",
dict: projectPermissionDict,
},
status: {
title: "审批结果",
type: "dict-radio",
dict: dict({
data: [
{
label: "通过",
value: "approved",
},
{
label: "拒绝",
value: "rejected",
},
],
}),
},
},
onSubmit: onSubmit,
initialForm: {
id: id,
permission: permission,
status: "approved",
},
});
}
return {
openApproveDialog,
};
}
@@ -0,0 +1,134 @@
import { dict } from "@fast-crud/fast-crud";
import { useDicts } from "../../dicts";
import { useFormDialog } from "/@/use/use-dialog";
import * as api from "./api";
import { useProjectStore } from "/@/store/project";
import { message, Modal } from "ant-design-vue";
import { Ref, ref } from "vue";
export function useApprove() {
const { openFormDialog } = useFormDialog();
const { projectPermissionDict, projectMemberStatusDict, userDict } = useDicts();
function openApproveDialog({ id, permission, onSubmit }: { id: any; permission: any; onSubmit: any }) {
openFormDialog({
title: "审批加入申请",
columns: {
permission: {
title: "成员权限",
type: "dict-select",
dict: projectPermissionDict,
},
status: {
title: "审批结果",
type: "dict-radio",
dict: dict({
data: [
{
label: "通过",
value: "approved",
},
{
label: "拒绝",
value: "rejected",
},
],
}),
},
},
onSubmit: onSubmit,
initialForm: {
id: id,
permission: permission,
status: "approved",
},
});
}
return {
openApproveDialog,
};
}
export function useTransfer() {
const { openFormDialog } = useFormDialog();
async function doTransfer() {
Modal.confirm({
title: "请确认",
content: () => (
<div>
<p></p>
<p class="text-red-500"></p>
</div>
),
okText: "确认",
okType: "primary",
onOk: async () => {
await api.TransferResources();
message.success("迁移成功");
await loadMyResources();
},
});
}
const selfResources: Ref = ref({});
const projectStore = useProjectStore();
async function loadMyResources() {
selfResources.value = await api.GetSelfResources();
}
async function openTransferDialog() {
await loadMyResources();
openFormDialog({
title: "迁移我的个人资源到当前企业项目",
wrapper: {
buttons: {
ok: {
show: false,
},
reset: {
show: false,
},
},
},
body() {
return (
<div class="p-8">
<div class="flex flex-row items-center justify-evenly w-full">
<div>
<h3 class="text-lg font-bold"></h3>
<div class="mt-4">
<p>线{selfResources.value.pipeline}</p>
<p>线{selfResources.value.history}</p>
<p>线{selfResources.value.historyLog}</p>
<p>线{selfResources.value.pipelineGroup}</p>
<p>{selfResources.value.storage}</p>
<p>{selfResources.value.certInfo}</p>
<p>{selfResources.value.access}</p>
<p>{selfResources.value.siteMonitor}</p>
<p>{selfResources.value.notification}</p>
<p>{selfResources.value.group}</p>
<p>线{selfResources.value.template}</p>
<p>{selfResources.value.domain}</p>
<p>{selfResources.value.subdomain}</p>
<p>cname记录{selfResources.value.cnameRecord}</p>
</div>
</div>
<div class="text-2xl font-bold"> </div>
<div>"{projectStore.currentProject?.name}"</div>
</div>
<div class="flex flex-row items-center justify-center w-full">
<a-button type="primary" onClick={doTransfer}>
</a-button>
</div>
</div>
);
},
});
}
return {
openTransferDialog,
};
}
@@ -7,6 +7,7 @@ import * as api from "./api";
import { useSettingStore } from "/@/store/settings";
import { useUserStore } from "/@/store/user";
import { useI18n } from "/src/locales";
import { useProjectStore } from "/@/store/project";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const router = useRouter();
@@ -29,6 +30,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
};
const userStore = useUserStore();
const projectStore = useProjectStore();
const settingStore = useSettingStore();
const selectedRowKeys: Ref<any[]> = ref([]);
context.selectedRowKeys = selectedRowKeys;
@@ -61,6 +63,12 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
minWidth: 200,
fixed: "right",
},
form: {
onSuccess: async () => {
await projectStore.reload();
crudExpose?.doRefresh();
},
},
columns: {
id: {
title: "ID",
@@ -14,6 +14,11 @@
<div class="helper">{{ t("certd.httpsProxyHelper") }}</div>
</a-form-item>
<a-form-item :label="t('certd.sys.setting.environmentVars')" :name="['private', 'environmentVars']">
<a-textarea v-model:value="formState.private.environmentVars" :placeholder="environmentVarsExample" rows="4" />
<div class="helper">{{ t("certd.sys.setting.environmentVarsHelper") }}</div>
</a-form-item>
<a-form-item :label="t('certd.dualStackNetwork')" :name="['private', 'dnsResultOrder']">
<a-select v-model:value="formState.private.dnsResultOrder">
<a-select-option value="verbatim">{{ t("certd.default") }}</a-select-option>
@@ -55,6 +60,11 @@ defineOptions({
name: "SettingNetwork",
});
const environmentVarsExample = ref(
`ALIYUN_CLIENT_CONNECT_TIMEOUT=16000 #连接超时,单位毫秒
ALIYUN_CLIENT_READ_TIMEOUT=16000 #读取数据超时,单位毫秒`
);
const formState = reactive<Partial<SysSettings>>({
public: {},
private: {},