chore: 流水线有效期优化

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

View File

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

View File

@ -466,7 +466,7 @@ export default function ({ crudExpose, context: { groupDictRef, selectedRowKeys
},
column: {
sorter: true,
width: 80,
width: 100,
align: "center",
component: {
name: "fs-dict-switch",
@ -513,7 +513,7 @@ export default function ({ crudExpose, context: { groupDictRef, selectedRowKeys
{ value: "cert", label: t("certd.types.certApply") },
{ value: "cert_upload", label: t("certd.types.certUpload") },
{ value: "custom", label: t("certd.types.custom") },
{ value: "template", label: "模版" },
{ value: "template", label: t("certd.types.template") },
],
}),
form: {
@ -522,7 +522,7 @@ export default function ({ crudExpose, context: { groupDictRef, selectedRowKeys
},
column: {
sorter: true,
width: 90,
width: 110,
align: "center",
show: true,
component: {
@ -560,7 +560,7 @@ export default function ({ crudExpose, context: { groupDictRef, selectedRowKeys
type: "date",
form: {
show: computed(() => {
return settingStore.isPlus && settingStore.sysPublic.pipelineValidTimeEnabled;
return settingStore.isPlus && settingStore.sysPublic.pipelineValidTimeEnabled && userStore.isAdmin;
}),
helper: t("certd.pi.validTimeHelper"),
valueResolve({ form, key, value }) {
@ -573,6 +573,18 @@ export default function ({ crudExpose, context: { groupDictRef, selectedRowKeys
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: {
show: computed(() => {

View File

@ -26,7 +26,6 @@
import { onActivated, onMounted, ref } from "vue";
import { dict, useFs } from "@fast-crud/fast-crud";
import createCrudOptions from "./crud";
import PiCertdForm from "./certd-form/index.vue";
import ChangeGroup from "./components/change-group.vue";
import ChangeTrigger from "./components/change-trigger.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')">
<SettingCaptcha v-if="activeKey === 'captcha'" />
</a-tab-pane>
<a-tab-pane key="cert" :tab="t('certd.sys.setting.certSetting')">
<SettingCert v-if="activeKey === 'cert'" />
<a-tab-pane key="pipeline" :tab="t('certd.sys.setting.pipelineSetting')">
<SettingPipeline v-if="activeKey === 'pipeline'" />
</a-tab-pane>
</a-tabs>
</div>
@ -34,7 +34,7 @@ import SettingRegister from "/@/views/sys/settings/tabs/register.vue";
import SettingPayment from "/@/views/sys/settings/tabs/payment.vue";
import SettingSafe from "/@/views/sys/settings/tabs/safe.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 { ref } from "vue";
import { useSettingStore } from "/@/store/settings";

View File

@ -1,6 +1,13 @@
<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-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']">
<div class="flex items-center">
<a-switch v-model:checked="formState.public.pipelineValidTimeEnabled" :disabled="!settingsStore.isPlus" />
@ -35,7 +42,7 @@ import { useI18n } from "/src/locales";
const { t } = useI18n();
defineOptions({
name: "SettingCert",
name: "SettingPipeline",
});
const formState = reactive<Partial<SysSettings>>({
@ -65,7 +72,4 @@ const onFinish = async (form: any) => {
}
};
</script>
<style lang="less">
.sys-settings-cert {
}
</style>
<style lang="less"></style>

View File

@ -1,13 +1,6 @@
<template>
<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-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-switch v-model:checked="formState.public.registerEnabled" />
</a-form-item>

View File

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

View File

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