From faf08f6513a0936c4f523fd57930f41c1f8ca1e9 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Sat, 21 Feb 2026 23:20:26 +0800 Subject: [PATCH] chore: project --- packages/ui/certd-client/src/api/service.ts | 2 +- .../certd-client/src/layout/layout-basic.vue | 9 +++--- .../certd-client/src/store/project/index.ts | 30 +++++++++++++++++++ .../ui/certd-client/src/style/common.less | 1 + packages/ui/certd-client/src/style/dark.less | 14 ++++++--- packages/ui/certd-client/src/style/vben.less | 3 ++ .../src/vben/layouts/basic/layout.vue | 2 -- .../access/access-selector/access/crud.tsx | 4 +-- .../src/views/certd/access/crud.tsx | 4 ++- .../ui/certd-client/src/views/certd/dicts.ts | 26 ++++++++++++++-- .../src/views/certd/history/crud.tsx | 4 +-- .../src/views/certd/monitor/cert/crud.tsx | 4 +-- .../src/views/certd/monitor/site/crud.tsx | 4 +-- .../src/views/certd/notification/common.tsx | 4 +-- .../src/views/certd/open/openkey/crud.tsx | 12 +++++++- .../src/views/certd/pipeline/crud.tsx | 12 ++++++-- .../src/views/certd/pipeline/group/crud.tsx | 4 +-- .../views/certd/pipeline/template/crud.tsx | 4 +-- .../src/views/certd/project/api.ts | 7 +++++ .../src/views/sys/settings/tabs/mode.vue | 3 ++ .../sys/enterprise/service/project-service.ts | 8 ++--- 21 files changed, 125 insertions(+), 36 deletions(-) create mode 100644 packages/ui/certd-client/src/style/vben.less diff --git a/packages/ui/certd-client/src/api/service.ts b/packages/ui/certd-client/src/api/service.ts index 9a322f6d7..6a27fb9f3 100644 --- a/packages/ui/certd-client/src/api/service.ts +++ b/packages/ui/certd-client/src/api/service.ts @@ -146,7 +146,7 @@ function createRequestFunction(service: any) { }; const projectStore = useProjectStore(); - if (projectStore.isEnterprise && !config.url.startsWith("/sys")) { + if (projectStore.isEnterprise && !config.url.startsWith("/sys") && !config.url.startsWith("http")) { configDefault.headers["project-id"] = projectStore.currentProjectId; } diff --git a/packages/ui/certd-client/src/layout/layout-basic.vue b/packages/ui/certd-client/src/layout/layout-basic.vue index bbac875d1..944c7b41c 100644 --- a/packages/ui/certd-client/src/layout/layout-basic.vue +++ b/packages/ui/certd-client/src/layout/layout-basic.vue @@ -84,7 +84,11 @@ const projectStore = useProjectStore(); diff --git a/packages/ui/certd-client/src/views/certd/access/access-selector/access/crud.tsx b/packages/ui/certd-client/src/views/certd/access/access-selector/access/crud.tsx index e06d69f00..821514155 100644 --- a/packages/ui/certd-client/src/views/certd/access/access-selector/access/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/access/access-selector/access/crud.tsx @@ -4,7 +4,7 @@ import { getCommonColumnDefine } from "/@/views/certd/access/common"; import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud"; import { useI18n } from "/src/locales"; import { useProjectStore } from "/@/store/project"; -import { myProjectDict } from "../../../dicts"; +import { useDicts } from "../../../dicts"; export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet { const { t } = useI18n(); @@ -41,7 +41,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat selectedRowKey.value = changed; ctx.emit("update:modelValue", changed[0]); }; - + const { myProjectDict } = useDicts(); const typeRef = ref("aliyun"); context.typeRef = typeRef; const commonColumnsDefine = getCommonColumnDefine(crudExpose, typeRef, api); diff --git a/packages/ui/certd-client/src/views/certd/access/crud.tsx b/packages/ui/certd-client/src/views/certd/access/crud.tsx index 0dc6bad77..d15dd61a9 100644 --- a/packages/ui/certd-client/src/views/certd/access/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/access/crud.tsx @@ -1,7 +1,7 @@ // @ts-ignore import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud"; import { ref } from "vue"; -import { myProjectDict } from "../dicts"; +import { useDicts } from "../dicts"; import { useProjectStore } from "/@/store/project"; import { getCommonColumnDefine } from "/@/views/certd/access/common"; import { useI18n } from "/src/locales"; @@ -32,6 +32,8 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat const typeRef = ref(); const commonColumnsDefine = getCommonColumnDefine(crudExpose, typeRef, api); const projectStore = useProjectStore(); + + const { myProjectDict } = useDicts(); return { crudOptions: { request: { diff --git a/packages/ui/certd-client/src/views/certd/dicts.ts b/packages/ui/certd-client/src/views/certd/dicts.ts index afe870457..07cdf0d56 100644 --- a/packages/ui/certd-client/src/views/certd/dicts.ts +++ b/packages/ui/certd-client/src/views/certd/dicts.ts @@ -1,6 +1,7 @@ import { dict } from "@fast-crud/fast-crud"; +import { GetMyProjectList } from "./project/api"; -export const projectPermissionDict = dict({ +const projectPermissionDict = dict({ data: [ { label: "read", @@ -17,13 +18,24 @@ export const projectPermissionDict = dict({ ], }); -export const myProjectDict = dict({ +const myProjectDict = dict({ url: "/enterprise/project/list", + getData: async () => { + const res = await GetMyProjectList(); + return res; + }, value: "id", label: "name", + immediate: false, + onReady: ({ dict }) => { + for (const item of dict.data) { + item.label = item.name; + item.value = item.id; + } + }, }); -export const userDict = dict({ +const userDict = dict({ url: "/sys/authority/user/getSimpleUsers", value: "id", onReady: ({ dict }) => { @@ -32,3 +44,11 @@ export const userDict = dict({ } }, }); + +export function useDicts() { + return { + projectPermissionDict, + myProjectDict, + userDict, + }; +} diff --git a/packages/ui/certd-client/src/views/certd/history/crud.tsx b/packages/ui/certd-client/src/views/certd/history/crud.tsx index a49d805d7..dd64a1f98 100644 --- a/packages/ui/certd-client/src/views/certd/history/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/history/crud.tsx @@ -6,7 +6,7 @@ import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, Edi import { useUserStore } from "/@/store/user"; import { useSettingStore } from "/@/store/settings"; import { statusUtil } from "/@/views/certd/pipeline/pipeline/utils/util.status"; -import { myProjectDict } from "../dicts"; +import { useDicts } from "../dicts"; import { useProjectStore } from "/@/store/project"; export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet { @@ -33,7 +33,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat const settingStore = useSettingStore(); const selectedRowKeys: Ref = ref([]); context.selectedRowKeys = selectedRowKeys; - + const { myProjectDict } = useDicts(); const projectStore = useProjectStore(); return { diff --git a/packages/ui/certd-client/src/views/certd/monitor/cert/crud.tsx b/packages/ui/certd-client/src/views/certd/monitor/cert/crud.tsx index 59047a686..53bcf7738 100644 --- a/packages/ui/certd-client/src/views/certd/monitor/cert/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/monitor/cert/crud.tsx @@ -11,7 +11,7 @@ import CertView from "/@/views/certd/pipeline/cert-view.vue"; import { useCertUpload } from "/@/views/certd/pipeline/cert-upload/use"; import { useSettingStore } from "/@/store/settings"; import { useProjectStore } from "/@/store/project"; -import { myProjectDict } from "../../dicts"; +import { useDicts } from "../../dicts"; export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet { const { t } = useI18n(); @@ -36,7 +36,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat return res; }; const router = useRouter(); - + const { myProjectDict } = useDicts(); const settingStore = useSettingStore(); const projectStore = useProjectStore(); const model = useModal(); diff --git a/packages/ui/certd-client/src/views/certd/monitor/site/crud.tsx b/packages/ui/certd-client/src/views/certd/monitor/site/crud.tsx index 2e19d4a64..800f0b75d 100644 --- a/packages/ui/certd-client/src/views/certd/monitor/site/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/monitor/site/crud.tsx @@ -14,7 +14,7 @@ import { ref } from "vue"; import GroupSelector from "../../basic/group/group-selector.vue"; import { createGroupDictRef } from "../../basic/group/api"; import { useProjectStore } from "/@/store/project"; -import { myProjectDict } from "../../dicts"; +import { useDicts } from "../../dicts"; export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet { const { t } = useI18n(); const api = siteInfoApi; @@ -39,7 +39,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat const res = await api.AddObj(form); return res; }; - + const { myProjectDict } = useDicts(); const settingsStore = useSettingStore(); const checkStatusDict = dict({ diff --git a/packages/ui/certd-client/src/views/certd/notification/common.tsx b/packages/ui/certd-client/src/views/certd/notification/common.tsx index a54582397..91726d8ee 100644 --- a/packages/ui/certd-client/src/views/certd/notification/common.tsx +++ b/packages/ui/certd-client/src/views/certd/notification/common.tsx @@ -6,7 +6,7 @@ import { Modal } from "ant-design-vue"; import { mitter } from "/@/utils/util.mitt"; import { useI18n } from "/src/locales"; import { useProjectStore } from "/@/store/project"; -import { myProjectDict } from "../dicts"; +import { useDicts } from "../dicts"; export function notificationProvide(api: any) { provide("notificationApi", api); @@ -29,7 +29,7 @@ export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any) { }; const projectStore = useProjectStore(); - + const { myProjectDict } = useDicts(); provide("getCurrentPluginDefine", () => { return currentDefine; }); diff --git a/packages/ui/certd-client/src/views/certd/open/openkey/crud.tsx b/packages/ui/certd-client/src/views/certd/open/openkey/crud.tsx index d95075cbb..66a3a9128 100644 --- a/packages/ui/certd-client/src/views/certd/open/openkey/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/open/openkey/crud.tsx @@ -4,7 +4,8 @@ import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, Edi import { OPEN_API_DOC, openkeyApi } from "./api"; import { useModal } from "/@/use/use-modal"; import { useProjectStore } from "/@/store/project"; -import { myProjectDict } from "../../dicts"; +import { computed } from "vue"; +import { useDicts } from "../../dicts"; export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet { const { t } = useI18n(); @@ -28,6 +29,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat const res = await api.AddObj(form); return res; }; + const { myProjectDict } = useDicts(); const projectStore = useProjectStore(); const model = useModal(); return { @@ -176,6 +178,14 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat form: { show: false, }, + column: { + show: computed(() => { + return projectStore.isEnterprise; + }), + width: 120, + align: "center", + sorter: true, + }, }, createTime: { title: t("certd.fields.createTime"), diff --git a/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx b/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx index 9c7629277..7d60a94ea 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx @@ -14,7 +14,7 @@ import GroupSelector from "/@/views/certd/pipeline/group/group-selector.vue"; import { statusUtil } from "/@/views/certd/pipeline/pipeline/utils/util.status"; import { useCertViewer } from "/@/views/certd/pipeline/use"; import { useI18n } from "/src/locales"; -import { myProjectDict } from "../dicts"; +import { useDicts } from "../dicts"; import { useProjectStore } from "/@/store/project"; export default function ({ crudExpose, context: { selectedRowKeys, openCertApplyDialog } }: CreateCrudOptionsProps): CreateCrudOptionsRet { @@ -69,7 +69,7 @@ export default function ({ crudExpose, context: { selectedRowKeys, openCertApply const settingStore = useSettingStore(); const projectStore = useProjectStore(); - + const { myProjectDict } = useDicts(); const DEFAULT_WILL_EXPIRE_DAYS = settingStore.sysPublic.defaultWillExpireDays || settingStore.sysPublic.defaultCertRenewDays || 15; function onDialogOpen(opt: any) { @@ -656,6 +656,14 @@ export default function ({ crudExpose, context: { selectedRowKeys, openCertApply form: { show: false, }, + column: { + show: computed(() => { + return settingStore.isEnterprise; + }), + width: 120, + align: "center", + sorter: true, + }, }, updateTime: { title: t("certd.fields.updateTime"), diff --git a/packages/ui/certd-client/src/views/certd/pipeline/group/crud.tsx b/packages/ui/certd-client/src/views/certd/pipeline/group/crud.tsx index 2ada545a5..d83850f43 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/group/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/pipeline/group/crud.tsx @@ -2,7 +2,7 @@ import { useI18n } from "/src/locales"; import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud"; import { pipelineGroupApi } from "./api"; import { useProjectStore } from "/@/store/project"; -import { myProjectDict } from "../../dicts"; +import { useDicts } from "../../dicts"; export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet { const { t } = useI18n(); @@ -28,7 +28,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat }; const projectStore = useProjectStore(); - + const { myProjectDict } = useDicts(); return { crudOptions: { settings: { diff --git a/packages/ui/certd-client/src/views/certd/pipeline/template/crud.tsx b/packages/ui/certd-client/src/views/certd/pipeline/template/crud.tsx index be9c3c961..091e6688d 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/template/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/pipeline/template/crud.tsx @@ -7,7 +7,7 @@ import * as pipelineApi from "../api"; import { useTemplate } from "/@/views/certd/pipeline/template/use"; import { useI18n } from "/@/locales"; import { useProjectStore } from "/@/store/project"; -import { myProjectDict } from "../../dicts"; +import { useDicts } from "../../dicts"; export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet { const api = templateApi; const { t } = useI18n(); @@ -36,7 +36,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat const router = useRouter(); const model = useModal(); - + const { myProjectDict } = useDicts(); const { openCreateFromTemplateDialog } = useTemplate(); return { diff --git a/packages/ui/certd-client/src/views/certd/project/api.ts b/packages/ui/certd-client/src/views/certd/project/api.ts index cd637e065..b5eafb8e0 100644 --- a/packages/ui/certd-client/src/views/certd/project/api.ts +++ b/packages/ui/certd-client/src/views/certd/project/api.ts @@ -10,6 +10,13 @@ export async function GetList(query: any) { }); } +export async function GetMyProjectList() { + return await request({ + url: apiPrefix + "/list", + method: "post", + }); +} + export async function GetPage(query: any) { return await request({ url: apiPrefix + "/page", diff --git a/packages/ui/certd-client/src/views/sys/settings/tabs/mode.vue b/packages/ui/certd-client/src/views/sys/settings/tabs/mode.vue index 2089d144c..c23734319 100644 --- a/packages/ui/certd-client/src/views/sys/settings/tabs/mode.vue +++ b/packages/ui/certd-client/src/views/sys/settings/tabs/mode.vue @@ -21,6 +21,7 @@ import { useSettingStore } from "/@/store/settings"; import { notification } from "ant-design-vue"; import { useI18n } from "/src/locales"; import { dict } from "@fast-crud/fast-crud"; +import { useProjectStore } from "/@/store/project"; const { t } = useI18n(); defineOptions({ @@ -53,12 +54,14 @@ async function loadSysSettings() { const saveLoading = ref(false); loadSysSettings(); const settingsStore = useSettingStore(); +const projectStore = useProjectStore(); const onFinish = async (form: any) => { try { saveLoading.value = true; await api.SysSettingsSave(form); await settingsStore.loadSysSettings(); + await projectStore.reload(); notification.success({ message: t("certd.saveSuccess"), }); diff --git a/packages/ui/certd-server/src/modules/sys/enterprise/service/project-service.ts b/packages/ui/certd-server/src/modules/sys/enterprise/service/project-service.ts index 27d4e524c..c959f3c02 100644 --- a/packages/ui/certd-server/src/modules/sys/enterprise/service/project-service.ts +++ b/packages/ui/certd-server/src/modules/sys/enterprise/service/project-service.ts @@ -144,14 +144,14 @@ export class ProjectService extends BaseService { } const member = await this.projectMemberService.getMember(projectId, userId); if (!member) { - throw new Error('项目成员不存在'); + throw new Error(`用户${userId}不是该项目${projectId}成员`); } savedPermission = member.permission; } } projectCache.set(cacheKey, savedPermission,{ttl: 3 * 60 * 1000}); if (!savedPermission) { - throw new Error('权限不足'); + throw new Error(`权限不足,需要${permission}权限`); } if (permission === 'read') { @@ -161,11 +161,11 @@ export class ProjectService extends BaseService { if (savedPermission === 'admin' || savedPermission === 'write') { return true } else { - throw new Error('权限不足'); + throw new Error(`权限不足,需要${permission}权限`); } } if (savedPermission !== permission) { - throw new Error('权限不足'); + throw new Error(`权限不足,需要${permission}权限`); } return true }