chore: 流水线有效期优化

pull/569/head
xiaojunnuo 2025-10-24 23:48:32 +08:00
parent fea808ca5f
commit 6531002d61
10 changed files with 58 additions and 27 deletions

View File

@ -47,4 +47,12 @@ export abstract class BaseController {
} }
return user; return user;
} }
isAdmin() {
const roleIds: number[] = this.ctx?.user?.roles;
if (roleIds?.includes(1)) {
return true;
}
}
} }

View File

@ -143,9 +143,10 @@ export default {
validTimeHelper: "Not filled in means permanent validity", validTimeHelper: "Not filled in means permanent validity",
}, },
types: { types: {
certApply: "Certificate Application", certApply: "Cert Apply",
certUpload: "Certificate Upload", certUpload: "Cert Upload",
custom: "Custom", custom: "Custom",
template: "Template",
}, },
myPipelines: "My Pipelines", myPipelines: "My Pipelines",
selectedCount: "Selected {count} items", selectedCount: "Selected {count} items",
@ -730,6 +731,10 @@ export default {
addonName: "Name", addonName: "Name",
addonNameHelper: "Fill freely, helps to distinguish when multiple same type exist", addonNameHelper: "Fill freely, helps to distinguish when multiple same type exist",
addonTypeSelect: "Select type", addonTypeSelect: "Select type",
dates: {
years: "{count} years",
months: "{count} months",
},
sys: { sys: {
setting: { setting: {
baseSetting: "Base Settings", baseSetting: "Base Settings",
@ -737,8 +742,7 @@ export default {
safeSetting: "Safe Settings", safeSetting: "Safe Settings",
paymentSetting: "Payment Settings", paymentSetting: "Payment Settings",
captchaSetting: "Captcha Setting", captchaSetting: "Captcha Setting",
certSetting: "Certificate Apply Settings", pipelineSetting: "Pipeline Settings",
showRunStrategy: "Show RunStrategy", showRunStrategy: "Show RunStrategy",
showRunStrategyHelper: "Allow modify the run strategy of the task", showRunStrategyHelper: "Allow modify the run strategy of the task",

View File

@ -151,6 +151,7 @@ export default {
certApply: "证书申请", certApply: "证书申请",
certUpload: "证书上传", certUpload: "证书上传",
custom: "自定义", custom: "自定义",
template: "模版",
}, },
myPipelines: "我的流水线", myPipelines: "我的流水线",
selectedCount: "已选择 {count} 项", selectedCount: "已选择 {count} 项",
@ -730,6 +731,10 @@ export default {
copyPipelineConfig: "复制该流水线配置作为模板来源", copyPipelineConfig: "复制该流水线配置作为模板来源",
pipeline: "流水线", pipeline: "流水线",
}, },
dates: {
years: "{count}年",
months: "{count}月",
},
sys: { sys: {
setting: { setting: {
baseSetting: "基本设置", baseSetting: "基本设置",
@ -737,7 +742,7 @@ export default {
safeSetting: "安全设置", safeSetting: "安全设置",
paymentSetting: "支付设置", paymentSetting: "支付设置",
captchaSetting: "验证码设置", captchaSetting: "验证码设置",
certSetting: "证书申请设置", pipelineSetting: "流水线设置",
showRunStrategy: "显示运行策略选择", showRunStrategy: "显示运行策略选择",
showRunStrategyHelper: "任务设置中是否允许选择运行策略", showRunStrategyHelper: "任务设置中是否允许选择运行策略",

View File

@ -466,7 +466,7 @@ export default function ({ crudExpose, context: { groupDictRef, selectedRowKeys
}, },
column: { column: {
sorter: true, sorter: true,
width: 80, width: 100,
align: "center", align: "center",
component: { component: {
name: "fs-dict-switch", name: "fs-dict-switch",
@ -513,7 +513,7 @@ export default function ({ crudExpose, context: { groupDictRef, selectedRowKeys
{ value: "cert", label: t("certd.types.certApply") }, { value: "cert", label: t("certd.types.certApply") },
{ value: "cert_upload", label: t("certd.types.certUpload") }, { value: "cert_upload", label: t("certd.types.certUpload") },
{ value: "custom", label: t("certd.types.custom") }, { value: "custom", label: t("certd.types.custom") },
{ value: "template", label: "模版" }, { value: "template", label: t("certd.types.template") },
], ],
}), }),
form: { form: {
@ -522,7 +522,7 @@ export default function ({ crudExpose, context: { groupDictRef, selectedRowKeys
}, },
column: { column: {
sorter: true, sorter: true,
width: 90, width: 110,
align: "center", align: "center",
show: true, show: true,
component: { component: {
@ -560,7 +560,7 @@ export default function ({ crudExpose, context: { groupDictRef, selectedRowKeys
type: "date", type: "date",
form: { form: {
show: computed(() => { show: computed(() => {
return settingStore.isPlus && settingStore.sysPublic.pipelineValidTimeEnabled; return settingStore.isPlus && settingStore.sysPublic.pipelineValidTimeEnabled && userStore.isAdmin;
}), }),
helper: t("certd.pi.validTimeHelper"), helper: t("certd.pi.validTimeHelper"),
valueResolve({ form, key, value }) { valueResolve({ form, key, value }) {
@ -573,6 +573,18 @@ export default function ({ crudExpose, context: { groupDictRef, selectedRowKeys
form[key] = dayjs(value); form[key] = dayjs(value);
} }
}, },
component: {
presets: [
{ label: t("certd.dates.months", { count: 3 }), value: dayjs().add(3, "month") },
{ label: t("certd.dates.months", { count: 6 }), value: dayjs().add(6, "month") },
{ label: t("certd.dates.years", { count: 1 }), value: dayjs().add(1, "year") },
{ label: t("certd.dates.years", { count: 2 }), value: dayjs().add(2, "year") },
{ label: t("certd.dates.years", { count: 3 }), value: dayjs().add(3, "year") },
{ label: t("certd.dates.years", { count: 4 }), value: dayjs().add(4, "year") },
{ label: t("certd.dates.years", { count: 5 }), value: dayjs().add(5, "year") },
{ label: t("certd.dates.years", { count: 6 }), value: dayjs().add(6, "year") },
],
},
}, },
column: { column: {
show: computed(() => { show: computed(() => {

View File

@ -26,7 +26,6 @@
import { onActivated, onMounted, ref } from "vue"; import { onActivated, onMounted, ref } from "vue";
import { dict, useFs } from "@fast-crud/fast-crud"; import { dict, useFs } from "@fast-crud/fast-crud";
import createCrudOptions from "./crud"; import createCrudOptions from "./crud";
import PiCertdForm from "./certd-form/index.vue";
import ChangeGroup from "./components/change-group.vue"; import ChangeGroup from "./components/change-group.vue";
import ChangeTrigger from "./components/change-trigger.vue"; import ChangeTrigger from "./components/change-trigger.vue";
import { Modal, notification } from "ant-design-vue"; import { Modal, notification } from "ant-design-vue";

View File

@ -20,8 +20,8 @@
<a-tab-pane key="captcha" :tab="t('certd.sys.setting.captchaSetting')"> <a-tab-pane key="captcha" :tab="t('certd.sys.setting.captchaSetting')">
<SettingCaptcha v-if="activeKey === 'captcha'" /> <SettingCaptcha v-if="activeKey === 'captcha'" />
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="cert" :tab="t('certd.sys.setting.certSetting')"> <a-tab-pane key="pipeline" :tab="t('certd.sys.setting.pipelineSetting')">
<SettingCert v-if="activeKey === 'cert'" /> <SettingPipeline v-if="activeKey === 'pipeline'" />
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
</div> </div>
@ -34,7 +34,7 @@ import SettingRegister from "/@/views/sys/settings/tabs/register.vue";
import SettingPayment from "/@/views/sys/settings/tabs/payment.vue"; import SettingPayment from "/@/views/sys/settings/tabs/payment.vue";
import SettingSafe from "/@/views/sys/settings/tabs/safe.vue"; import SettingSafe from "/@/views/sys/settings/tabs/safe.vue";
import SettingCaptcha from "/@/views/sys/settings/tabs/captcha.vue"; import SettingCaptcha from "/@/views/sys/settings/tabs/captcha.vue";
import SettingCert from "/@/views/sys/settings/tabs/cert.vue"; import SettingPipeline from "/@/views/sys/settings/tabs/pipeline.vue";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
import { ref } from "vue"; import { ref } from "vue";
import { useSettingStore } from "/@/store/settings"; import { useSettingStore } from "/@/store/settings";

View File

@ -1,6 +1,13 @@
<template> <template>
<div class="sys-settings-form sys-settings-cert"> <div class="sys-settings-form sys-settings-pipeline">
<a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" @finish="onFinish"> <a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" @finish="onFinish">
<a-form-item :label="t('certd.manageOtherUserPipeline')" :name="['public', 'managerOtherUserPipeline']">
<a-switch v-model:checked="formState.public.managerOtherUserPipeline" />
</a-form-item>
<a-form-item :label="t('certd.limitUserPipelineCount')" :name="['public', 'limitUserPipelineCount']">
<a-input-number v-model:value="formState.public.limitUserPipelineCount" />
<div class="helper">{{ t("certd.limitUserPipelineCountHelper") }}</div>
</a-form-item>
<a-form-item :label="t('certd.sys.setting.pipelineValidTimeEnabled')" :name="['public', 'pipelineValidTimeEnabled']"> <a-form-item :label="t('certd.sys.setting.pipelineValidTimeEnabled')" :name="['public', 'pipelineValidTimeEnabled']">
<div class="flex items-center"> <div class="flex items-center">
<a-switch v-model:checked="formState.public.pipelineValidTimeEnabled" :disabled="!settingsStore.isPlus" /> <a-switch v-model:checked="formState.public.pipelineValidTimeEnabled" :disabled="!settingsStore.isPlus" />
@ -35,7 +42,7 @@ import { useI18n } from "/src/locales";
const { t } = useI18n(); const { t } = useI18n();
defineOptions({ defineOptions({
name: "SettingCert", name: "SettingPipeline",
}); });
const formState = reactive<Partial<SysSettings>>({ const formState = reactive<Partial<SysSettings>>({
@ -65,7 +72,4 @@ const onFinish = async (form: any) => {
} }
}; };
</script> </script>
<style lang="less"> <style lang="less"></style>
.sys-settings-cert {
}
</style>

View File

@ -1,13 +1,6 @@
<template> <template>
<div class="sys-settings-form sys-settings-register"> <div class="sys-settings-form sys-settings-register">
<a-form :model="formState" name="register" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" @finish="onFinish"> <a-form :model="formState" name="register" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" @finish="onFinish">
<a-form-item :label="t('certd.manageOtherUserPipeline')" :name="['public', 'managerOtherUserPipeline']">
<a-switch v-model:checked="formState.public.managerOtherUserPipeline" />
</a-form-item>
<a-form-item :label="t('certd.limitUserPipelineCount')" :name="['public', 'limitUserPipelineCount']">
<a-input-number v-model:value="formState.public.limitUserPipelineCount" />
<div class="helper">{{ t("certd.limitUserPipelineCountHelper") }}</div>
</a-form-item>
<a-form-item :label="t('certd.enableSelfRegistration')" :name="['public', 'registerEnabled']"> <a-form-item :label="t('certd.enableSelfRegistration')" :name="['public', 'registerEnabled']">
<a-switch v-model:checked="formState.public.registerEnabled" /> <a-switch v-model:checked="formState.public.registerEnabled" />
</a-form-item> </a-form-item>

View File

@ -85,6 +85,12 @@ export class PipelineController extends CrudController<PipelineService> {
} else { } else {
bean.userId = this.getUserId(); bean.userId = this.getUserId();
} }
if(!this.isAdmin()){
// 非管理员用户 不允许设置流水线有效期
delete bean.validTime
}
await this.service.save(bean); await this.service.save(bean);
//是否增加证书监控 //是否增加证书监控
if (bean.addToMonitorEnabled && bean.addToMonitorDomains) { if (bean.addToMonitorEnabled && bean.addToMonitorDomains) {

View File

@ -20,7 +20,7 @@ export class AuthService {
return true; return true;
} }
async isAdmin(ctx: any) { isAdmin(ctx: any) {
const roleIds: number[] = ctx.user.roles; const roleIds: number[] = ctx.user.roles;
if (roleIds.includes(1)) { if (roleIds.includes(1)) {
return true; return true;