mirror of https://github.com/certd/certd
Other translations
parent
cdac12bb2f
commit
daaef316e9
|
@ -1,120 +1,132 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="cron-editor">
|
<div class="cron-editor">
|
||||||
<div class="flex-o">
|
<div class="flex-o">
|
||||||
<cron-light :disabled="disabled" :readonly="readonly" :period="period" class="flex-o cron-ant" locale="zh-CN" format="quartz" :model-value="modelValue" @update:model-value="onUpdate" @error="onError" />
|
<cron-light :disabled="disabled" :readonly="readonly" :period="period" class="flex-o cron-ant"
|
||||||
</div>
|
locale="zh-CN" format="quartz" :model-value="modelValue" @update:model-value="onUpdate"
|
||||||
<div class="mt-5 flex">
|
@error="onError" />
|
||||||
<a-input :disabled="true" :readonly="readonly" :value="modelValue" @change="onChange"></a-input>
|
</div>
|
||||||
<fs-icon icon="ion:close-circle" class="pointer fs-16 ml-5 color-gray" title="清除选择" @click="onClear"></fs-icon>
|
<div class="mt-5 flex">
|
||||||
</div>
|
<a-input :disabled="true" :readonly="readonly" :value="modelValue" @change="onChange"></a-input>
|
||||||
<div class="helper">下次触发时间:{{ nextTime }}</div>
|
<fs-icon icon="ion:close-circle" class="pointer fs-16 ml-5 color-gray" :title="t('certd.cron.clearTip')"
|
||||||
<div class="fs-helper">{{ errorMessage }}</div>
|
@click="onClear"></fs-icon>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="helper">{{ t('certd.cron.nextTrigger') }}:{{ nextTime }}</div>
|
||||||
|
<div class="fs-helper">{{ errorMessage }}</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import parser from "cron-parser";
|
import parser from "cron-parser";
|
||||||
import { computed, ref } from "vue";
|
import { computed, ref } from "vue";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
import { useI18n } from "vue-i18n";
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
import { getCronNextTimes } from "/@/components/cron-editor/utils";
|
import { getCronNextTimes } from "/@/components/cron-editor/utils";
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "CronEditor",
|
name: "CronEditor",
|
||||||
});
|
});
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
modelValue?: string;
|
modelValue?: string;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
readonly?: boolean;
|
readonly?: boolean;
|
||||||
allowEveryMin?: boolean;
|
allowEveryMin?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const period = ref<string>("");
|
const period = ref<string>("");
|
||||||
if (props.modelValue == null || props.modelValue.endsWith("* * *")) {
|
if (props.modelValue == null || props.modelValue.endsWith("* * *")) {
|
||||||
period.value = "day";
|
period.value = "day";
|
||||||
} else if (props.modelValue.endsWith("* *")) {
|
} else if (props.modelValue.endsWith("* *")) {
|
||||||
period.value = "month";
|
period.value = "month";
|
||||||
} else if (props.modelValue.endsWith("*")) {
|
} else if (props.modelValue.endsWith("*")) {
|
||||||
period.value = "year";
|
period.value = "year";
|
||||||
}
|
}
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
"update:modelValue": any;
|
"update:modelValue": any;
|
||||||
change: any;
|
change: any;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const errorMessage = ref<string | null>(null);
|
const errorMessage = ref<string | null>(null);
|
||||||
|
|
||||||
const onUpdate = (value: string) => {
|
const onUpdate = (value: string) => {
|
||||||
if (value === props.modelValue) {
|
if (value === props.modelValue) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const arr: string[] = value.split(" ");
|
const arr: string[] = value.split(" ");
|
||||||
if (arr[0] === "*") {
|
if (arr[0] === "*") {
|
||||||
arr[0] = "0";
|
arr[0] = "0";
|
||||||
}
|
}
|
||||||
if (!props.allowEveryMin) {
|
if (!props.allowEveryMin) {
|
||||||
if (arr[1] === "*") {
|
if (arr[1] === "*") {
|
||||||
arr[1] = "0";
|
arr[1] = "0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
value = arr.join(" ");
|
value = arr.join(" ");
|
||||||
|
|
||||||
emit("update:modelValue", value);
|
emit("update:modelValue", value);
|
||||||
errorMessage.value = undefined;
|
errorMessage.value = undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onPeriod = (value: string) => {
|
const onPeriod = (value: string) => {
|
||||||
period.value = value;
|
period.value = value;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onChange = (e: any) => {
|
const onChange = (e: any) => {
|
||||||
const value = e.target.value;
|
const value = e.target.value;
|
||||||
onUpdate(value);
|
onUpdate(value);
|
||||||
};
|
};
|
||||||
const onError = (error: any) => {
|
const onError = (error: any) => {
|
||||||
errorMessage.value = error;
|
errorMessage.value = error;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClear = () => {
|
const onClear = () => {
|
||||||
if (props.disabled) {
|
if (props.disabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
onUpdate("");
|
onUpdate("");
|
||||||
};
|
};
|
||||||
|
|
||||||
const nextTime = computed(() => {
|
const nextTime = computed(() => {
|
||||||
if (props.modelValue == null) {
|
if (props.modelValue == null) {
|
||||||
return "请先设置正确的cron表达式";
|
return t("certd.cron.tip");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const nextTimes = getCronNextTimes(props.modelValue, 2);
|
const nextTimes = getCronNextTimes(props.modelValue, 2);
|
||||||
return nextTimes.join(",");
|
return nextTimes.join(",");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
return "请先设置正确的cron表达式";
|
return t("certd.cron.tip");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
.cron-editor {
|
.cron-editor {
|
||||||
.cron-ant {
|
.cron-ant {
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
&* > {
|
|
||||||
margin-bottom: 2px;
|
&*> {
|
||||||
display: flex;
|
margin-bottom: 2px;
|
||||||
align-items: center;
|
display: flex;
|
||||||
}
|
align-items: center;
|
||||||
.vcron-select-list {
|
}
|
||||||
min-width: 56px;
|
|
||||||
}
|
.vcron-select-list {
|
||||||
.vcron-select-input {
|
min-width: 56px;
|
||||||
min-height: 22px;
|
}
|
||||||
background-color: #fff;
|
|
||||||
}
|
.vcron-select-input {
|
||||||
.vcron-select-container {
|
min-height: 22px;
|
||||||
display: flex;
|
background-color: #fff;
|
||||||
align-items: center;
|
}
|
||||||
}
|
|
||||||
}
|
.vcron-select-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -185,4 +185,93 @@ export default {
|
||||||
download: {
|
download: {
|
||||||
title: "Download Certificate"
|
title: "Download Certificate"
|
||||||
},
|
},
|
||||||
|
source: "Source Code",
|
||||||
|
github: "GitHub",
|
||||||
|
gitee: "Gitee",
|
||||||
|
cron: {
|
||||||
|
clearTip: "Clear Selection",
|
||||||
|
nextTrigger: "Next Trigger Time",
|
||||||
|
tip: "Please set a valid cron expression first"
|
||||||
|
},
|
||||||
|
cronForm: {
|
||||||
|
title: "Scheduled Script",
|
||||||
|
helper: "Click the button above to select the time for daily execution.\nIt is recommended to run once a day. Tasks will be skipped if the certificate is not expiring.",
|
||||||
|
required: "This field is required"
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
title: "Recipient Email",
|
||||||
|
helper: "Enter your recipient email addresses. Multiple addresses are supported.",
|
||||||
|
required: "This field is required"
|
||||||
|
},
|
||||||
|
plugin: {
|
||||||
|
selectTitle: "Certificate Apply Plugin",
|
||||||
|
jsAcme: "JS-ACME: Easy to use, powerful features [Recommended]",
|
||||||
|
legoAcme: "Lego-ACME: Based on Lego, supports a wide range of DNS providers, suitable for users familiar with Lego"
|
||||||
|
},
|
||||||
|
pipelineForm: {
|
||||||
|
createTitle: "Create Certificate Pipeline",
|
||||||
|
moreParams: "More Parameters",
|
||||||
|
triggerCronTitle: "Scheduled Trigger",
|
||||||
|
triggerCronHelper:
|
||||||
|
"Click the button above to choose a daily execution time.\nIt is recommended to trigger once per day. The task will be skipped if the certificate has not expired and will not be executed repeatedly.",
|
||||||
|
notificationTitle: "Failure Notification",
|
||||||
|
notificationHelper: "Get real-time alerts when the task fails",
|
||||||
|
groupIdTitle: "Pipeline Group"
|
||||||
|
},
|
||||||
|
notificationDefault: "Use Default Notification",
|
||||||
|
monitor: {
|
||||||
|
title: "Site Certificate Monitoring",
|
||||||
|
description: "Check website certificates' expiration at 0:00 daily; reminders sent 10 days before expiration (using default notification channel);",
|
||||||
|
settingLink: "Site Monitoring Settings",
|
||||||
|
limitInfo: "Basic edition limited to 1, professional and above unlimited, current",
|
||||||
|
checkAll: "Check All",
|
||||||
|
confirmTitle: "Confirm",
|
||||||
|
confirmContent: "Confirm to trigger check for all site certificates?",
|
||||||
|
checkSubmitted: "Check task submitted",
|
||||||
|
pleaseRefresh: "Please refresh the page later to see the results",
|
||||||
|
siteName: "Site Name",
|
||||||
|
enterSiteName: "Please enter the site name",
|
||||||
|
domain: "Domain",
|
||||||
|
enterDomain: "Please enter the domain",
|
||||||
|
enterValidDomain: "Please enter a valid domain",
|
||||||
|
httpsPort: "HTTPS Port",
|
||||||
|
enterPort: "Please enter the port",
|
||||||
|
certInfo: "Certificate Info",
|
||||||
|
issuer: "Issuer",
|
||||||
|
certDomains: "Certificate Domains",
|
||||||
|
certProvider: "Issuer",
|
||||||
|
certStatus: "Certificate Status",
|
||||||
|
status: {
|
||||||
|
ok: "Valid",
|
||||||
|
expired: "Expired",
|
||||||
|
},
|
||||||
|
certExpiresTime: "Certificate Expiration",
|
||||||
|
expired: "expired",
|
||||||
|
days: "days",
|
||||||
|
lastCheckTime: "Last Check Time",
|
||||||
|
disabled: "Enable/Disable",
|
||||||
|
ipCheck: "Enable IP Check",
|
||||||
|
selectRequired: "Please select",
|
||||||
|
ipCheckConfirm: "Are you sure to {status} IP check?",
|
||||||
|
ipCount: "IP Count",
|
||||||
|
checkStatus: "Check Status",
|
||||||
|
pipelineId: "Linked Pipeline ID",
|
||||||
|
certInfoId: "Certificate ID",
|
||||||
|
checkSubmittedRefresh: "Check task submitted. Please refresh later to view the result.",
|
||||||
|
ipManagement: "IP Management",
|
||||||
|
bulkImport: "Bulk Import",
|
||||||
|
basicLimitError: "Basic version allows only one monitoring site. Please upgrade to the Pro version.",
|
||||||
|
limitExceeded: "Sorry, you can only create up to {max} monitoring records. Please purchase or upgrade your plan.",
|
||||||
|
},
|
||||||
|
checkStatus: {
|
||||||
|
success: "Success",
|
||||||
|
checking: "Checking",
|
||||||
|
error: "Error",
|
||||||
|
},
|
||||||
|
domainList: {
|
||||||
|
title: "Domain List",
|
||||||
|
helper: "Format: domain:port:name, one per line. Port and name are optional.\nExamples:\nwww.baidu.com:443:Baidu\nwww.taobao.com::Taobao\nwww.google.com",
|
||||||
|
required: "Please enter domains to import",
|
||||||
|
placeholder: "www.baidu.com:443:Baidu\nwww.taobao.com::Taobao\nwww.google.com\n",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
{
|
|
||||||
"back": "Back",
|
|
||||||
"backToHome": "Back To Home",
|
|
||||||
"login": "Login",
|
|
||||||
"logout": "Logout",
|
|
||||||
"prompt": "Prompt",
|
|
||||||
"cancel": "Cancel",
|
|
||||||
"confirm": "Confirm",
|
|
||||||
"reset": "Reset",
|
|
||||||
"noData": "No Data",
|
|
||||||
"refresh": "Refresh",
|
|
||||||
"loadingMenu": "Loading Menu",
|
|
||||||
"query": "Search",
|
|
||||||
"search": "Search",
|
|
||||||
"enabled": "Enabled",
|
|
||||||
"disabled": "Disabled",
|
|
||||||
"edit": "Edit",
|
|
||||||
"delete": "Delete",
|
|
||||||
"create": "Create",
|
|
||||||
"yes": "Yes",
|
|
||||||
"no": "No"
|
|
||||||
}
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
export default {
|
||||||
|
"back": "Back",
|
||||||
|
"backToHome": "Back To Home",
|
||||||
|
"login": "Login",
|
||||||
|
"logout": "Logout",
|
||||||
|
"prompt": "Prompt",
|
||||||
|
"cancel": "Cancel",
|
||||||
|
"confirm": "Confirm",
|
||||||
|
"reset": "Reset",
|
||||||
|
"noData": "No Data",
|
||||||
|
"refresh": "Refresh",
|
||||||
|
"loadingMenu": "Loading Menu",
|
||||||
|
"query": "Search",
|
||||||
|
"search": "Search",
|
||||||
|
"enabled": "Enabled",
|
||||||
|
"disabled": "Disabled",
|
||||||
|
"edit": "Edit",
|
||||||
|
"delete": "Delete",
|
||||||
|
"create": "Create",
|
||||||
|
"yes": "Yes",
|
||||||
|
"no": "No"
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import tutorial from './tutorial';
|
||||||
import preferences from './preferences';
|
import preferences from './preferences';
|
||||||
import ui from './ui';
|
import ui from './ui';
|
||||||
import guide from './guide';
|
import guide from './guide';
|
||||||
|
import common from './common';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
certd,
|
certd,
|
||||||
|
@ -13,5 +14,6 @@ export default {
|
||||||
ui,
|
ui,
|
||||||
tutorial,
|
tutorial,
|
||||||
preferences,
|
preferences,
|
||||||
guide
|
guide,
|
||||||
|
common
|
||||||
};
|
};
|
|
@ -191,4 +191,93 @@ export default {
|
||||||
download: {
|
download: {
|
||||||
title: "下载证书"
|
title: "下载证书"
|
||||||
},
|
},
|
||||||
|
source: "源码",
|
||||||
|
github: "github",
|
||||||
|
gitee: "gitee",
|
||||||
|
cron: {
|
||||||
|
clearTip: "清除选择",
|
||||||
|
nextTrigger: "下次触发时间",
|
||||||
|
tip: "请先设置正确的cron表达式"
|
||||||
|
},
|
||||||
|
cronForm: {
|
||||||
|
title: "定时脚本",
|
||||||
|
helper: "点击上面的按钮,选择每天几点定时执行。\n建议设置为每天触发一次,证书未到期之前任务会跳过,不会重复执行",
|
||||||
|
required: "此项必填"
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
title: "收件邮箱",
|
||||||
|
helper: "输入你的收件邮箱地址,支持多个邮箱",
|
||||||
|
required: "此项必填"
|
||||||
|
},
|
||||||
|
plugin: {
|
||||||
|
selectTitle: "证书申请插件",
|
||||||
|
jsAcme: "JS-ACME:使用简单方便,功能强大【推荐】",
|
||||||
|
legoAcme: "Lego-ACME:基于Lego实现,支持海量DNS提供商,熟悉LEGO的用户可以使用"
|
||||||
|
},
|
||||||
|
pipelineForm: {
|
||||||
|
createTitle: "创建证书流水线",
|
||||||
|
moreParams: "更多参数",
|
||||||
|
triggerCronTitle: "定时触发",
|
||||||
|
triggerCronHelper:
|
||||||
|
"点击上面的按钮,选择每天几点定时执行。\n建议设置为每天触发一次,证书未到期之前任务会跳过,不会重复执行",
|
||||||
|
notificationTitle: "失败通知",
|
||||||
|
notificationHelper: "任务执行失败实时提醒",
|
||||||
|
groupIdTitle: "流水线分组"
|
||||||
|
},
|
||||||
|
notificationDefault: "使用默认通知",
|
||||||
|
monitor: {
|
||||||
|
title: "站点证书监控",
|
||||||
|
description: "每天0点,检查网站证书的过期时间,到期前10天时将发出提醒(使用默认通知渠道);",
|
||||||
|
settingLink: "站点监控设置",
|
||||||
|
limitInfo: "基础版限制1条,专业版以上无限制,当前",
|
||||||
|
checkAll: "检查全部",
|
||||||
|
confirmTitle: "确认",
|
||||||
|
confirmContent: "确认触发检查全部站点证书吗?",
|
||||||
|
checkSubmitted: "检查任务已提交",
|
||||||
|
pleaseRefresh: "请稍后刷新页面查看结果",
|
||||||
|
siteName: "站点名称",
|
||||||
|
enterSiteName: "请输入站点名称",
|
||||||
|
domain: "网站域名",
|
||||||
|
enterDomain: "请输入域名",
|
||||||
|
enterValidDomain: "请输入正确的域名",
|
||||||
|
httpsPort: "HTTPS端口",
|
||||||
|
enterPort: "请输入端口",
|
||||||
|
certInfo: "证书信息",
|
||||||
|
issuer: "证书颁发机构",
|
||||||
|
certDomains: "证书域名",
|
||||||
|
certProvider: "颁发机构",
|
||||||
|
certStatus: "证书状态",
|
||||||
|
status: {
|
||||||
|
ok: "正常",
|
||||||
|
expired: "过期",
|
||||||
|
},
|
||||||
|
certExpiresTime: "证书到期时间",
|
||||||
|
expired: "过期",
|
||||||
|
days: "天",
|
||||||
|
lastCheckTime: "上次检查时间",
|
||||||
|
disabled: "禁用启用",
|
||||||
|
ipCheck: "开启IP检查",
|
||||||
|
selectRequired: "请选择",
|
||||||
|
ipCheckConfirm: "确定{status}IP检查?",
|
||||||
|
ipCount: "IP数量",
|
||||||
|
checkStatus: "检查状态",
|
||||||
|
pipelineId: "关联流水线ID",
|
||||||
|
certInfoId: "证书ID",
|
||||||
|
checkSubmittedRefresh: "检查任务已提交,请稍后刷新查看结果",
|
||||||
|
ipManagement: "IP管理",
|
||||||
|
bulkImport: "批量导入",
|
||||||
|
basicLimitError: "基础版只能添加一个监控站点,请赞助升级专业版",
|
||||||
|
limitExceeded: "对不起,您最多只能创建条{max}监控记录,请购买或升级套餐",
|
||||||
|
},
|
||||||
|
checkStatus: {
|
||||||
|
success: "成功",
|
||||||
|
checking: "检查中",
|
||||||
|
error: "异常",
|
||||||
|
},
|
||||||
|
domainList: {
|
||||||
|
title: "域名列表",
|
||||||
|
helper: "格式【域名:端口:名称】,一行一个,其中端口、名称可以省略\n比如:\nwww.baidu.com:443:百度\nwww.taobao.com::淘宝\nwww.google.com",
|
||||||
|
required: "请输入要导入的域名",
|
||||||
|
placeholder: "www.baidu.com:443:百度\nwww.taobao.com::淘宝\nwww.google.com\n",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
{
|
|
||||||
"back": "返回",
|
|
||||||
"backToHome": "返回首页",
|
|
||||||
"login": "登录",
|
|
||||||
"logout": "退出登录",
|
|
||||||
"prompt": "提示",
|
|
||||||
"cancel": "取消",
|
|
||||||
"confirm": "确认",
|
|
||||||
"reset": "重置",
|
|
||||||
"noData": "暂无数据",
|
|
||||||
"refresh": "刷新",
|
|
||||||
"loadingMenu": "加载菜单中",
|
|
||||||
"query": "查询",
|
|
||||||
"search": "搜索",
|
|
||||||
"enabled": "已启用",
|
|
||||||
"disabled": "已禁用",
|
|
||||||
"edit": "修改",
|
|
||||||
"delete": "删除",
|
|
||||||
"create": "新增",
|
|
||||||
"yes": "是",
|
|
||||||
"no": "否"
|
|
||||||
}
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
export default {
|
||||||
|
"back": "返回",
|
||||||
|
"backToHome": "返回首页",
|
||||||
|
"login": "登录",
|
||||||
|
"logout": "退出登录",
|
||||||
|
"prompt": "提示",
|
||||||
|
"cancel": "取消",
|
||||||
|
"confirm": "确认",
|
||||||
|
"reset": "重置",
|
||||||
|
"noData": "暂无数据",
|
||||||
|
"refresh": "刷新",
|
||||||
|
"loadingMenu": "加载菜单中",
|
||||||
|
"query": "查询",
|
||||||
|
"search": "搜索",
|
||||||
|
"enabled": "已启用",
|
||||||
|
"disabled": "已禁用",
|
||||||
|
"edit": "修改",
|
||||||
|
"delete": "删除",
|
||||||
|
"create": "新增",
|
||||||
|
"yes": "是",
|
||||||
|
"no": "否"
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import tutorial from './tutorial';
|
||||||
import preferences from './preferences';
|
import preferences from './preferences';
|
||||||
import ui from './ui';
|
import ui from './ui';
|
||||||
import guide from './guide';
|
import guide from './guide';
|
||||||
|
import common from './common';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
certd,
|
certd,
|
||||||
|
@ -13,5 +14,6 @@ export default {
|
||||||
ui,
|
ui,
|
||||||
tutorial,
|
tutorial,
|
||||||
preferences,
|
preferences,
|
||||||
guide
|
guide,
|
||||||
|
common
|
||||||
};
|
};
|
|
@ -1,33 +1,36 @@
|
||||||
|
import i18n from '/@/locales/i18n';
|
||||||
|
|
||||||
export const headerResource = [
|
export const headerResource = [
|
||||||
{
|
{
|
||||||
title: "文档",
|
title: i18n.global.t("certd.helpDoc"),
|
||||||
path: "https://certd.docmirror.cn",
|
path: "https://certd.docmirror.cn",
|
||||||
meta: {
|
meta: {
|
||||||
icon: "ion:document-text-outline"
|
icon: "ion:document-text-outline"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "源码",
|
title: i18n.global.t("certd.source"),
|
||||||
name: "source",
|
name: "source",
|
||||||
key: "source",
|
key: "source",
|
||||||
meta: {
|
meta: {
|
||||||
icon: "ion:git-branch-outline"
|
icon: "ion:git-branch-outline"
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
title: "github",
|
title: i18n.global.t("certd.github"),
|
||||||
path: "https://github.com/certd/certd",
|
path: "https://github.com/certd/certd",
|
||||||
meta: {
|
meta: {
|
||||||
icon: "ion:logo-github"
|
icon: "ion:logo-github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "gitee",
|
title: i18n.global.t("certd.gitee"),
|
||||||
path: "https://gitee.com/certd/certd",
|
path: "https://gitee.com/certd/certd",
|
||||||
meta: {
|
meta: {
|
||||||
icon: "ion:logo-octocat"
|
icon: "ion:logo-octocat"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -2,23 +2,25 @@ import { IFrameView } from "/@/vben/layouts";
|
||||||
import { useSettingStore } from "/@/store/settings";
|
import { useSettingStore } from "/@/store/settings";
|
||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
import TutorialButton from "/@/components/tutorial/index.vue";
|
import TutorialButton from "/@/components/tutorial/index.vue";
|
||||||
|
import i18n from '/@/locales/i18n';
|
||||||
|
|
||||||
export const aboutResource = [
|
export const aboutResource = [
|
||||||
{
|
{
|
||||||
title: "文档",
|
title: i18n.global.t("certd.dashboard.helpDoc"),
|
||||||
name: "document",
|
name: "document",
|
||||||
path: "/about/doc",
|
path: "/about/doc",
|
||||||
component: IFrameView,
|
component: IFrameView,
|
||||||
meta: {
|
meta: {
|
||||||
icon: "lucide:book-open-text",
|
icon: "lucide:book-open-text",
|
||||||
link: "https://certd.docmirror.cn",
|
link: "https://certd.docmirror.cn",
|
||||||
title: "文档",
|
title: i18n.global.t("certd.dashboard.helpDoc"),
|
||||||
order: 9999,
|
order: 9999,
|
||||||
show: () => {
|
show: () => {
|
||||||
const settingStore = useSettingStore();
|
const settingStore = useSettingStore();
|
||||||
return !settingStore.isComm;
|
return !settingStore.isComm;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default aboutResource;
|
export default aboutResource;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,53 +1,61 @@
|
||||||
<template>
|
<template>
|
||||||
<fs-page>
|
<fs-page>
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="title flex items-center">
|
<div class="title flex items-center">
|
||||||
站点证书监控
|
{{ t("certd.monitor.title") }}
|
||||||
<div class="sub flex-1">
|
<div class="sub flex-1">
|
||||||
<div>
|
<div>
|
||||||
每天0点,检查网站证书的过期时间,到期前10天时将发出提醒(使用默认通知渠道);
|
{{ t("certd.monitor.description") }}
|
||||||
<router-link to="/certd/monitor/setting">站点监控设置</router-link>
|
<router-link to="/certd/monitor/setting">{{ t("certd.monitor.settingLink") }}</router-link>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center">基础版限制1条,专业版以上无限制,当前<vip-button class="ml-5" mode="nav"></vip-button></div>
|
<div class="flex items-center">
|
||||||
</div>
|
{{ t("certd.monitor.limitInfo") }}
|
||||||
</div>
|
<vip-button class="ml-5" mode="nav"></vip-button>
|
||||||
<div class="more">
|
</div>
|
||||||
<a-button type="primary" @click="checkAll">检查全部</a-button>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
<div class="more">
|
||||||
<fs-crud ref="crudRef" v-bind="crudBinding"> </fs-crud>
|
<a-button type="primary" @click="checkAll">{{ t("certd.monitor.checkAll") }}</a-button>
|
||||||
</fs-page>
|
</div>
|
||||||
|
</template>
|
||||||
|
<fs-crud ref="crudRef" v-bind="crudBinding"> </fs-crud>
|
||||||
|
</fs-page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onActivated, onMounted } from "vue";
|
import { onActivated, onMounted } from "vue";
|
||||||
import { useFs } from "@fast-crud/fast-crud";
|
import { useFs } from "@fast-crud/fast-crud";
|
||||||
import createCrudOptions from "./crud";
|
import createCrudOptions from "./crud";
|
||||||
import { siteInfoApi } from "./api";
|
import { siteInfoApi } from "./api";
|
||||||
import { Modal, notification } from "ant-design-vue";
|
import { Modal, notification } from "ant-design-vue";
|
||||||
|
import { useI18n } from "vue-i18n";
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "SiteCertMonitor",
|
name: "SiteCertMonitor",
|
||||||
});
|
});
|
||||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: {} });
|
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: {} });
|
||||||
function checkAll() {
|
function checkAll() {
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: "确认",
|
title: t("certd.monitor.confirmTitle"), // "确认"
|
||||||
content: "确认触发检查全部站点证书吗?",
|
content: t("certd.monitor.confirmContent"), // "确认触发检查全部站点证书吗?"
|
||||||
onOk: async () => {
|
onOk: async () => {
|
||||||
await siteInfoApi.CheckAll();
|
await siteInfoApi.CheckAll();
|
||||||
notification.success({
|
notification.success({
|
||||||
message: "检查任务已提交",
|
message: t("certd.monitor.checkSubmitted"), // "检查任务已提交"
|
||||||
description: "请稍后刷新页面查看结果",
|
description: t("certd.monitor.pleaseRefresh"), // "请稍后刷新页面查看结果"
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 页面打开后获取列表数据
|
// 页面打开后获取列表数据
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
crudExpose.doRefresh();
|
crudExpose.doRefresh();
|
||||||
});
|
});
|
||||||
onActivated(() => {
|
onActivated(() => {
|
||||||
crudExpose.doRefresh();
|
crudExpose.doRefresh();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,41 +1,44 @@
|
||||||
import { useFormWrapper } from "@fast-crud/fast-crud";
|
import { useFormWrapper } from "@fast-crud/fast-crud";
|
||||||
import { siteInfoApi } from "./api";
|
import { siteInfoApi } from "./api";
|
||||||
|
import { useI18n } from "vue-i18n";
|
||||||
|
|
||||||
export function useSiteImport() {
|
export function useSiteImport() {
|
||||||
const { openCrudFormDialog } = useFormWrapper();
|
const { t } = useI18n();
|
||||||
|
const { openCrudFormDialog } = useFormWrapper();
|
||||||
|
|
||||||
async function openSiteImportDialog(opts: { afterSubmit: any }) {
|
async function openSiteImportDialog(opts: { afterSubmit: any }) {
|
||||||
const { afterSubmit } = opts;
|
const { afterSubmit } = opts;
|
||||||
await openCrudFormDialog<any>({
|
await openCrudFormDialog<any>({
|
||||||
crudOptions: {
|
crudOptions: {
|
||||||
columns: {
|
columns: {
|
||||||
text: {
|
text: {
|
||||||
type: "textarea",
|
type: "textarea",
|
||||||
title: "域名列表",
|
title: t("certd.domainList.title"), // 域名列表
|
||||||
form: {
|
form: {
|
||||||
helper: "格式【域名:端口:名称】,一行一个,其中端口、名称可以省略\n比如:\nwww.baidu.com:443:百度\nwww.taobao.com::淘宝\nwww.google.com",
|
helper: t("certd.domainList.helper"),
|
||||||
rules: [{ required: true, message: "请输入要导入的域名" }],
|
rules: [{ required: true, message: t("certd.domainList.required") }],
|
||||||
component: {
|
component: {
|
||||||
placeholder: "www.baidu.com:443:百度\nwww.taobao.com::淘宝\nwww.google.com\n",
|
placeholder: t("certd.domainList.placeholder"),
|
||||||
rows: 8,
|
rows: 8,
|
||||||
},
|
},
|
||||||
col: {
|
col: {
|
||||||
span: 24,
|
span: 24,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
form: {
|
|
||||||
async doSubmit({ form }) {
|
|
||||||
return siteInfoApi.Import(form);
|
|
||||||
},
|
|
||||||
afterSubmit,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
form: {
|
||||||
openSiteImportDialog,
|
async doSubmit({ form }) {
|
||||||
};
|
return siteInfoApi.Import(form);
|
||||||
|
},
|
||||||
|
afterSubmit,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
openSiteImportDialog,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,26 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="notification-selector">
|
<div class="notification-selector">
|
||||||
<div class="flex-o w-100">
|
<div class="flex-o w-100">
|
||||||
<fs-dict-select class="flex-1" :value="modelValue" :dict="optionsDictRef" :disabled="disabled" :render-label="renderLabel" :slots="selectSlots" :allow-clear="true" v-bind="select" @update:value="onChange" />
|
<fs-dict-select class="flex-1" :value="modelValue" :dict="optionsDictRef" :disabled="disabled"
|
||||||
<fs-table-select
|
:render-label="renderLabel" :slots="selectSlots" :allow-clear="true" v-bind="select"
|
||||||
ref="tableSelectRef"
|
@update:value="onChange" />
|
||||||
class="flex-0"
|
<fs-table-select ref="tableSelectRef" class="flex-0" :model-value="modelValue" :dict="optionsDictRef"
|
||||||
:model-value="modelValue"
|
:create-crud-options="createCrudOptions" :crud-options-override="{
|
||||||
:dict="optionsDictRef"
|
search: { show: false },
|
||||||
:create-crud-options="createCrudOptions"
|
table: {
|
||||||
:crud-options-override="{
|
scroll: {
|
||||||
search: { show: false },
|
x: 540,
|
||||||
table: {
|
},
|
||||||
scroll: {
|
},
|
||||||
x: 540,
|
}" :show-current="false" :show-select="false" :dialog="{ width: 960 }" :destroy-on-close="false" height="400px"
|
||||||
},
|
v-bind="tableSelect" @update:model-value="onChange" @dialog-closed="doRefresh">
|
||||||
},
|
<template #default="scope">
|
||||||
}"
|
<fs-button class="ml-5" :disabled="disabled" :size="size" type="primary"
|
||||||
:show-current="false"
|
icon="ant-design:edit-outlined" @click="scope.open"></fs-button>
|
||||||
:show-select="false"
|
</template>
|
||||||
:dialog="{ width: 960 }"
|
</fs-table-select>
|
||||||
:destroy-on-close="false"
|
</div>
|
||||||
height="400px"
|
</div>
|
||||||
v-bind="tableSelect"
|
|
||||||
@update:model-value="onChange"
|
|
||||||
@dialog-closed="doRefresh"
|
|
||||||
>
|
|
||||||
<template #default="scope">
|
|
||||||
<fs-button class="ml-5" :disabled="disabled" :size="size" type="primary" icon="ant-design:edit-outlined" @click="scope.open"></fs-button>
|
|
||||||
</template>
|
|
||||||
</fs-table-select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="tsx" setup>
|
<script lang="tsx" setup>
|
||||||
|
@ -41,23 +31,26 @@ import { dict } from "@fast-crud/fast-crud";
|
||||||
import createCrudOptions from "../crud";
|
import createCrudOptions from "../crud";
|
||||||
import { notificationProvide } from "/@/views/certd/notification/common";
|
import { notificationProvide } from "/@/views/certd/notification/common";
|
||||||
import { useUserStore } from "/@/store/user";
|
import { useUserStore } from "/@/store/user";
|
||||||
|
import { useI18n } from "vue-i18n";
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "NotificationSelector",
|
name: "NotificationSelector",
|
||||||
});
|
});
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
modelValue?: number | string | number[] | string[];
|
modelValue?: number | string | number[] | string[];
|
||||||
type?: string;
|
type?: string;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
size?: string;
|
size?: string;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
select?: any;
|
select?: any;
|
||||||
tableSelect?: any;
|
tableSelect?: any;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const onChange = async (value: number) => {
|
const onChange = async (value: number) => {
|
||||||
await emitValue(value);
|
await emitValue(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const emit = defineEmits(["update:modelValue", "selectedChange", "change"]);
|
const emit = defineEmits(["update:modelValue", "selectedChange", "change"]);
|
||||||
|
@ -76,89 +69,90 @@ notificationProvide(api);
|
||||||
// loadNotificationTypes();
|
// loadNotificationTypes();
|
||||||
const tableSelectRef = ref();
|
const tableSelectRef = ref();
|
||||||
const optionsDictRef = dict({
|
const optionsDictRef = dict({
|
||||||
url: "/pi/notification/options",
|
url: "/pi/notification/options",
|
||||||
value: "id",
|
value: "id",
|
||||||
label: "name",
|
label: "name",
|
||||||
onReady: ({ dict }) => {
|
onReady: ({ dict }) => {
|
||||||
const data = [
|
const data = [
|
||||||
{
|
{
|
||||||
id: 0,
|
id: 0,
|
||||||
name: "使用默认通知",
|
name: t("certd.notificationDefault"),
|
||||||
icon: "ion:notifications",
|
icon: "ion:notifications",
|
||||||
},
|
},
|
||||||
...dict.data,
|
...dict.data,
|
||||||
];
|
];
|
||||||
dict.setData(data);
|
dict.setData(data);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const renderLabel = (option: any) => {
|
const renderLabel = (option: any) => {
|
||||||
return <span>{option.name}</span>;
|
return <span>{option.name}</span>;
|
||||||
};
|
};
|
||||||
|
|
||||||
async function openTableSelectDialog() {
|
async function openTableSelectDialog() {
|
||||||
selectOpened.value = false;
|
selectOpened.value = false;
|
||||||
await tableSelectRef.value.open({});
|
await tableSelectRef.value.open({});
|
||||||
await tableSelectRef.value.crudExpose.openAdd({});
|
await tableSelectRef.value.crudExpose.openAdd({});
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectOpened = ref(false);
|
const selectOpened = ref(false);
|
||||||
const selectSlots = ref({
|
const selectSlots = ref({
|
||||||
dropdownRender({ menuNode, props }: any) {
|
dropdownRender({ menuNode, props }: any) {
|
||||||
const res = [];
|
const res = [];
|
||||||
res.push(menuNode);
|
res.push(menuNode);
|
||||||
// res.push(<a-divider style="margin: 4px 0" />);
|
// res.push(<a-divider style="margin: 4px 0" />);
|
||||||
// res.push(<a-space style="padding: 4px 8px" />);
|
// res.push(<a-space style="padding: 4px 8px" />);
|
||||||
// res.push(<fs-button class="w-100" type="text" icon="plus-outlined" text="新建通知渠道" onClick={openTableSelectDialog}></fs-button>);
|
// res.push(<fs-button class="w-100" type="text" icon="plus-outlined" text="新建通知渠道" onClick={openTableSelectDialog}></fs-button>);
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const target: Ref<any> = ref({});
|
const target: Ref<any> = ref({});
|
||||||
|
|
||||||
function clear() {
|
function clear() {
|
||||||
if (props.disabled) {
|
if (props.disabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
emitValue(null);
|
emitValue(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
async function emitValue(value: any) {
|
async function emitValue(value: any) {
|
||||||
// target.value = optionsDictRef.dataMap[value];
|
// target.value = optionsDictRef.dataMap[value];
|
||||||
const userId = userStore.userInfo.id;
|
const userId = userStore.userInfo.id;
|
||||||
if (pipeline?.value && pipeline.value.userId !== userId) {
|
if (pipeline?.value && pipeline.value.userId !== userId) {
|
||||||
message.error("对不起,您不能修改他人流水线的通知");
|
message.error("对不起,您不能修改他人流水线的通知");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
emit("change", value);
|
emit("change", value);
|
||||||
emit("update:modelValue", value);
|
emit("update:modelValue", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => {
|
() => {
|
||||||
return props.modelValue;
|
return props.modelValue;
|
||||||
},
|
},
|
||||||
async value => {
|
async value => {
|
||||||
await optionsDictRef.loadDict();
|
await optionsDictRef.loadDict();
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
target.value = optionsDictRef.dataMap[value];
|
target.value = optionsDictRef.dataMap[value];
|
||||||
emit("selectedChange", target.value);
|
emit("selectedChange", target.value);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
//当不在pipeline中编辑时,可能为空
|
//当不在pipeline中编辑时,可能为空
|
||||||
const pipeline = inject("pipeline", null);
|
const pipeline = inject("pipeline", null);
|
||||||
|
|
||||||
async function doRefresh() {
|
async function doRefresh() {
|
||||||
await optionsDictRef.reloadDict();
|
await optionsDictRef.reloadDict();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
.notification-selector {
|
.notification-selector {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -11,323 +11,328 @@ import * as api from "../api";
|
||||||
import { PluginGroup, usePluginStore } from "/@/store/plugin";
|
import { PluginGroup, usePluginStore } from "/@/store/plugin";
|
||||||
import { createNotificationApi } from "/@/views/certd/notification/api";
|
import { createNotificationApi } from "/@/views/certd/notification/api";
|
||||||
import GroupSelector from "../group/group-selector.vue";
|
import GroupSelector from "../group/group-selector.vue";
|
||||||
|
import { useI18n } from "vue-i18n";
|
||||||
|
|
||||||
|
|
||||||
export function setRunnableIds(pipeline: any) {
|
export function setRunnableIds(pipeline: any) {
|
||||||
const idMap: any = {};
|
const { t } = useI18n();
|
||||||
function createId(oldId: any) {
|
const idMap: any = {};
|
||||||
if (oldId == null) {
|
function createId(oldId: any) {
|
||||||
return nanoid();
|
if (oldId == null) {
|
||||||
}
|
return nanoid();
|
||||||
const newId = nanoid();
|
}
|
||||||
idMap[oldId] = newId;
|
const newId = nanoid();
|
||||||
return newId;
|
idMap[oldId] = newId;
|
||||||
}
|
return newId;
|
||||||
if (pipeline.stages) {
|
}
|
||||||
for (const stage of pipeline.stages) {
|
if (pipeline.stages) {
|
||||||
stage.id = createId(stage.id);
|
for (const stage of pipeline.stages) {
|
||||||
if (stage.tasks) {
|
stage.id = createId(stage.id);
|
||||||
for (const task of stage.tasks) {
|
if (stage.tasks) {
|
||||||
task.id = createId(task.id);
|
for (const task of stage.tasks) {
|
||||||
if (task.steps) {
|
task.id = createId(task.id);
|
||||||
for (const step of task.steps) {
|
if (task.steps) {
|
||||||
step.id = createId(step.id);
|
for (const step of task.steps) {
|
||||||
}
|
step.id = createId(step.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const trigger of pipeline.triggers) {
|
for (const trigger of pipeline.triggers) {
|
||||||
trigger.id = nanoid();
|
trigger.id = nanoid();
|
||||||
}
|
}
|
||||||
for (const notification of pipeline.notifications) {
|
for (const notification of pipeline.notifications) {
|
||||||
notification.id = nanoid();
|
notification.id = nanoid();
|
||||||
}
|
}
|
||||||
|
|
||||||
let content = JSON.stringify(pipeline);
|
let content = JSON.stringify(pipeline);
|
||||||
for (const key in idMap) {
|
for (const key in idMap) {
|
||||||
content = content.replaceAll(key, idMap[key]);
|
content = content.replaceAll(key, idMap[key]);
|
||||||
}
|
}
|
||||||
return JSON.parse(content);
|
return JSON.parse(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useCertPipelineCreator() {
|
export function useCertPipelineCreator() {
|
||||||
const { openCrudFormDialog } = useFormWrapper();
|
const { t } = useI18n();
|
||||||
|
const { openCrudFormDialog } = useFormWrapper();
|
||||||
|
|
||||||
const pluginStore = usePluginStore();
|
const pluginStore = usePluginStore();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
function createCrudOptions(certPlugins: any[], getFormData: any, doSubmit: any): CreateCrudOptionsRet {
|
function createCrudOptions(certPlugins: any[], getFormData: any, doSubmit: any): CreateCrudOptionsRet {
|
||||||
const inputs: any = {};
|
const inputs: any = {};
|
||||||
const moreParams = [];
|
const moreParams = [];
|
||||||
for (const plugin of certPlugins) {
|
for (const plugin of certPlugins) {
|
||||||
for (const inputKey in plugin.input) {
|
for (const inputKey in plugin.input) {
|
||||||
if (inputs[inputKey]) {
|
if (inputs[inputKey]) {
|
||||||
//如果两个插件有的字段,直接显示
|
//如果两个插件有的字段,直接显示
|
||||||
inputs[inputKey].form.show = true;
|
inputs[inputKey].form.show = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const inputDefine = cloneDeep(plugin.input[inputKey]);
|
const inputDefine = cloneDeep(plugin.input[inputKey]);
|
||||||
if (!inputDefine.required && !inputDefine.maybeNeed) {
|
if (!inputDefine.required && !inputDefine.maybeNeed) {
|
||||||
moreParams.push(inputKey);
|
moreParams.push(inputKey);
|
||||||
// continue;
|
// continue;
|
||||||
}
|
}
|
||||||
useReference(inputDefine);
|
useReference(inputDefine);
|
||||||
inputs[inputKey] = {
|
inputs[inputKey] = {
|
||||||
title: inputDefine.title,
|
title: inputDefine.title,
|
||||||
form: {
|
form: {
|
||||||
...inputDefine,
|
...inputDefine,
|
||||||
show: compute(ctx => {
|
show: compute(ctx => {
|
||||||
const form = getFormData();
|
const form = getFormData();
|
||||||
if (!form) {
|
if (!form) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let inputDefineShow = true;
|
let inputDefineShow = true;
|
||||||
if (inputDefine.show != null) {
|
if (inputDefine.show != null) {
|
||||||
const computeShow = inputDefine.show as any;
|
const computeShow = inputDefine.show as any;
|
||||||
if (computeShow === false) {
|
if (computeShow === false) {
|
||||||
inputDefineShow = false;
|
inputDefineShow = false;
|
||||||
} else if (computeShow && computeShow.computeFn) {
|
} else if (computeShow && computeShow.computeFn) {
|
||||||
inputDefineShow = computeShow.computeFn({ form });
|
inputDefineShow = computeShow.computeFn({ form });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return form?.certApplyPlugin === plugin.name && inputDefineShow;
|
return form?.certApplyPlugin === plugin.name && inputDefineShow;
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const pluginStore = usePluginStore();
|
const pluginStore = usePluginStore();
|
||||||
const randomHour = Math.floor(Math.random() * 6);
|
const randomHour = Math.floor(Math.random() * 6);
|
||||||
const randomMin = Math.floor(Math.random() * 60);
|
const randomMin = Math.floor(Math.random() * 60);
|
||||||
|
|
||||||
const groupDictRef = dict({
|
const groupDictRef = dict({
|
||||||
url: "/pi/pipeline/group/all",
|
url: "/pi/pipeline/group/all",
|
||||||
value: "id",
|
value: "id",
|
||||||
label: "name",
|
label: "name",
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
crudOptions: {
|
crudOptions: {
|
||||||
form: {
|
form: {
|
||||||
doSubmit,
|
doSubmit,
|
||||||
wrapper: {
|
wrapper: {
|
||||||
width: 1350,
|
width: 1350,
|
||||||
saveRemind: false,
|
saveRemind: false,
|
||||||
title: "创建证书流水线",
|
title: t("certd.pipelineForm.createTitle"),
|
||||||
},
|
},
|
||||||
group: {
|
group: {
|
||||||
groups: {
|
groups: {
|
||||||
more: {
|
more: {
|
||||||
header: "更多参数",
|
header: t("certd.pipelineForm.moreParams"),
|
||||||
columns: moreParams,
|
columns: moreParams,
|
||||||
collapsed: true,
|
collapsed: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
columns: {
|
columns: {
|
||||||
certApplyPlugin: {
|
certApplyPlugin: {
|
||||||
title: "证书申请插件",
|
title: t("certd.plugin.selectTitle"),
|
||||||
type: "dict-select",
|
type: "dict-select",
|
||||||
dict: dict({
|
dict: dict({
|
||||||
data: [
|
data: [
|
||||||
{ value: "CertApply", label: "JS-ACME" },
|
{ value: "CertApply", label: "JS-ACME" },
|
||||||
{ value: "CertApplyLego", label: "Lego-ACME" },
|
{ value: "CertApplyLego", label: "Lego-ACME" },
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
form: {
|
form: {
|
||||||
order: 0,
|
order: 0,
|
||||||
value: "CertApply",
|
value: "CertApply",
|
||||||
helper: {
|
helper: {
|
||||||
render: () => {
|
render: () => {
|
||||||
return (
|
return (
|
||||||
<ul>
|
<ul>
|
||||||
<li>JS-ACME:使用简单方便,功能强大【推荐】</li>
|
<li>{t("certd.plugin.jsAcme")}</li>
|
||||||
<li>Lego-ACME:基于Lego实现,支持海量DNS提供商,熟悉LEGO的用户可以使用</li>
|
<li>{t("certd.plugin.legoAcme")}</li>
|
||||||
</ul>
|
</ul>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
valueChange: {
|
valueChange: {
|
||||||
handle: async ({ form, value }) => {
|
handle: async ({ form, value }) => {
|
||||||
const config = await pluginStore.getPluginConfig({
|
const config = await pluginStore.getPluginConfig({
|
||||||
name: value,
|
name: value,
|
||||||
type: "builtIn",
|
type: "builtIn",
|
||||||
});
|
});
|
||||||
if (config.sysSetting?.input) {
|
if (config.sysSetting?.input) {
|
||||||
merge(form, config.sysSetting.input);
|
merge(form, config.sysSetting.input);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
immediate: true,
|
immediate: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
...inputs,
|
...inputs,
|
||||||
triggerCron: {
|
triggerCron: {
|
||||||
title: "定时触发",
|
title: t("certd.pipelineForm.triggerCronTitle"),
|
||||||
type: "text",
|
type: "text",
|
||||||
form: {
|
form: {
|
||||||
value: `0 ${randomMin} ${randomHour} * * *`,
|
value: `0 ${randomMin} ${randomHour} * * *`,
|
||||||
component: {
|
component: {
|
||||||
name: "cron-editor",
|
name: "cron-editor",
|
||||||
vModel: "modelValue",
|
vModel: "modelValue",
|
||||||
placeholder: "0 0 4 * * *",
|
placeholder: "0 0 4 * * *",
|
||||||
},
|
},
|
||||||
helper: "点击上面的按钮,选择每天几点定时执行。\n建议设置为每天触发一次,证书未到期之前任务会跳过,不会重复执行",
|
helper: t("certd.pipelineForm.triggerCronHelper"),
|
||||||
order: 100,
|
order: 100,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
notification: {
|
notification: {
|
||||||
title: "失败通知",
|
title: t("certd.pipelineForm.notificationTitle"),
|
||||||
type: "text",
|
type: "text",
|
||||||
form: {
|
form: {
|
||||||
value: 0,
|
value: 0,
|
||||||
component: {
|
component: {
|
||||||
name: NotificationSelector,
|
name: NotificationSelector,
|
||||||
vModel: "modelValue",
|
vModel: "modelValue",
|
||||||
on: {
|
on: {
|
||||||
selectedChange({ $event, form }) {
|
selectedChange({ $event, form }) {
|
||||||
form.notificationTarget = $event;
|
form.notificationTarget = $event;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
order: 101,
|
order: 101,
|
||||||
helper: "任务执行失败实时提醒",
|
helper: t("certd.pipelineForm.notificationHelper"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
groupId: {
|
groupId: {
|
||||||
title: "流水线分组",
|
title: t("certd.pipelineForm.groupIdTitle"),
|
||||||
type: "dict-select",
|
type: "dict-select",
|
||||||
dict: groupDictRef,
|
dict: groupDictRef,
|
||||||
form: {
|
form: {
|
||||||
component: {
|
component: {
|
||||||
name: GroupSelector,
|
name: GroupSelector,
|
||||||
vModel: "modelValue",
|
vModel: "modelValue",
|
||||||
},
|
},
|
||||||
order: 9999,
|
order: 9999,
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getCertPlugins() {
|
},
|
||||||
const pluginGroup = await pluginStore.getGroups();
|
},
|
||||||
const pluginGroups: { [key: string]: PluginGroup } = pluginGroup.groups;
|
};
|
||||||
const certPluginGroup = pluginGroups.cert;
|
}
|
||||||
|
|
||||||
const certPlugins = [];
|
async function getCertPlugins() {
|
||||||
for (const plugin of certPluginGroup.plugins) {
|
const pluginGroup = await pluginStore.getGroups();
|
||||||
const detail: any = await pluginStore.getPluginDefine(plugin.name);
|
const pluginGroups: { [key: string]: PluginGroup } = pluginGroup.groups;
|
||||||
certPlugins.push(detail);
|
const certPluginGroup = pluginGroups.cert;
|
||||||
}
|
|
||||||
return certPlugins;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function openAddCertdPipelineDialog(req: { defaultGroupId?: number }) {
|
const certPlugins = [];
|
||||||
//检查是否流水线数量超出限制
|
for (const plugin of certPluginGroup.plugins) {
|
||||||
await checkPipelineLimit();
|
const detail: any = await pluginStore.getPluginDefine(plugin.name);
|
||||||
|
certPlugins.push(detail);
|
||||||
|
}
|
||||||
|
return certPlugins;
|
||||||
|
}
|
||||||
|
|
||||||
const wrapperRef = ref();
|
async function openAddCertdPipelineDialog(req: { defaultGroupId?: number }) {
|
||||||
function getFormData() {
|
//检查是否流水线数量超出限制
|
||||||
if (!wrapperRef.value) {
|
await checkPipelineLimit();
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return wrapperRef.value.getFormData();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function doSubmit({ form }: any) {
|
const wrapperRef = ref();
|
||||||
// const certDetail = readCertDetail(form.cert.crt);
|
function getFormData() {
|
||||||
// 添加certd pipeline
|
if (!wrapperRef.value) {
|
||||||
const triggers = [];
|
return null;
|
||||||
if (form.triggerCron) {
|
}
|
||||||
triggers.push({ title: "定时触发", type: "timer", props: { cron: form.triggerCron } });
|
return wrapperRef.value.getFormData();
|
||||||
}
|
}
|
||||||
const notifications = [];
|
|
||||||
if (form.notification != null) {
|
|
||||||
notifications.push({
|
|
||||||
type: "custom",
|
|
||||||
when: ["error", "turnToSuccess", "success"],
|
|
||||||
notificationId: form.notification,
|
|
||||||
title: form.notificationTarget?.name || "自定义通知",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const pluginInput = omit(form, ["triggerCron", "notification", "notificationTarget", "certApplyPlugin", "groupId"]);
|
|
||||||
let pipeline = {
|
|
||||||
title: form.domains[0] + "证书自动化",
|
|
||||||
runnableType: "pipeline",
|
|
||||||
stages: [
|
|
||||||
{
|
|
||||||
title: "证书申请阶段",
|
|
||||||
maxTaskCount: 1,
|
|
||||||
runnableType: "stage",
|
|
||||||
tasks: [
|
|
||||||
{
|
|
||||||
title: "证书申请任务",
|
|
||||||
runnableType: "task",
|
|
||||||
steps: [
|
|
||||||
{
|
|
||||||
title: "申请证书",
|
|
||||||
runnableType: "step",
|
|
||||||
input: {
|
|
||||||
renewDays: 35,
|
|
||||||
...pluginInput,
|
|
||||||
},
|
|
||||||
strategy: {
|
|
||||||
runStrategy: 0, // 正常执行
|
|
||||||
},
|
|
||||||
type: form.certApplyPlugin,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
triggers,
|
|
||||||
notifications,
|
|
||||||
};
|
|
||||||
pipeline = setRunnableIds(pipeline);
|
|
||||||
|
|
||||||
/**
|
async function doSubmit({ form }: any) {
|
||||||
* // cert: 证书; backup: 备份; custom:自定义;
|
// const certDetail = readCertDetail(form.cert.crt);
|
||||||
* type: string;
|
// 添加certd pipeline
|
||||||
* // custom: 自定义; monitor: 监控;
|
const triggers = [];
|
||||||
* from: string;
|
if (form.triggerCron) {
|
||||||
*/
|
triggers.push({ title: "定时触发", type: "timer", props: { cron: form.triggerCron } });
|
||||||
const groupId = form.groupId;
|
}
|
||||||
const id = await api.Save({
|
const notifications = [];
|
||||||
title: pipeline.title,
|
if (form.notification != null) {
|
||||||
content: JSON.stringify(pipeline),
|
notifications.push({
|
||||||
keepHistoryCount: 30,
|
type: "custom",
|
||||||
type: "cert",
|
when: ["error", "turnToSuccess", "success"],
|
||||||
groupId,
|
notificationId: form.notification,
|
||||||
});
|
title: form.notificationTarget?.name || "自定义通知",
|
||||||
if (form.email) {
|
});
|
||||||
try {
|
}
|
||||||
//创建一个默认的邮件通知
|
const pluginInput = omit(form, ["triggerCron", "notification", "notificationTarget", "certApplyPlugin", "groupId"]);
|
||||||
const notificationApi = createNotificationApi();
|
let pipeline = {
|
||||||
await notificationApi.GetOrCreateDefault({ email: form.email });
|
title: form.domains[0] + "证书自动化",
|
||||||
} catch (e) {
|
runnableType: "pipeline",
|
||||||
console.error(e);
|
stages: [
|
||||||
}
|
{
|
||||||
}
|
title: "证书申请阶段",
|
||||||
message.success("创建成功,请添加证书部署任务");
|
maxTaskCount: 1,
|
||||||
router.push({ path: "/certd/pipeline/detail", query: { id, editMode: "true" } });
|
runnableType: "stage",
|
||||||
}
|
tasks: [
|
||||||
const certPlugins = await getCertPlugins();
|
{
|
||||||
const { crudOptions } = createCrudOptions(certPlugins, getFormData, doSubmit);
|
title: "证书申请任务",
|
||||||
//@ts-ignore
|
runnableType: "task",
|
||||||
crudOptions.columns.groupId.form.value = req.defaultGroupId || undefined;
|
steps: [
|
||||||
const wrapper = await openCrudFormDialog({ crudOptions });
|
{
|
||||||
wrapperRef.value = wrapper;
|
title: "申请证书",
|
||||||
}
|
runnableType: "step",
|
||||||
|
input: {
|
||||||
|
renewDays: 35,
|
||||||
|
...pluginInput,
|
||||||
|
},
|
||||||
|
strategy: {
|
||||||
|
runStrategy: 0, // 正常执行
|
||||||
|
},
|
||||||
|
type: form.certApplyPlugin,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
triggers,
|
||||||
|
notifications,
|
||||||
|
};
|
||||||
|
pipeline = setRunnableIds(pipeline);
|
||||||
|
|
||||||
return {
|
/**
|
||||||
openAddCertdPipelineDialog,
|
* // cert: 证书; backup: 备份; custom:自定义;
|
||||||
};
|
* type: string;
|
||||||
|
* // custom: 自定义; monitor: 监控;
|
||||||
|
* from: string;
|
||||||
|
*/
|
||||||
|
const groupId = form.groupId;
|
||||||
|
const id = await api.Save({
|
||||||
|
title: pipeline.title,
|
||||||
|
content: JSON.stringify(pipeline),
|
||||||
|
keepHistoryCount: 30,
|
||||||
|
type: "cert",
|
||||||
|
groupId,
|
||||||
|
});
|
||||||
|
if (form.email) {
|
||||||
|
try {
|
||||||
|
//创建一个默认的邮件通知
|
||||||
|
const notificationApi = createNotificationApi();
|
||||||
|
await notificationApi.GetOrCreateDefault({ email: form.email });
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
message.success("创建成功,请添加证书部署任务");
|
||||||
|
router.push({ path: "/certd/pipeline/detail", query: { id, editMode: "true" } });
|
||||||
|
}
|
||||||
|
const certPlugins = await getCertPlugins();
|
||||||
|
const { crudOptions } = createCrudOptions(certPlugins, getFormData, doSubmit);
|
||||||
|
//@ts-ignore
|
||||||
|
crudOptions.columns.groupId.form.value = req.defaultGroupId || undefined;
|
||||||
|
const wrapper = await openCrudFormDialog({ crudOptions });
|
||||||
|
wrapperRef.value = wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
openAddCertdPipelineDialog,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,37 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<fs-form-item
|
<fs-form-item v-model="optionsFormState.receivers" :item="{
|
||||||
v-model="optionsFormState.receivers"
|
title: t('certd.email.title'),
|
||||||
:item="{
|
key: 'type',
|
||||||
title: '收件邮箱',
|
component: {
|
||||||
key: 'type',
|
name: 'a-select',
|
||||||
component: {
|
vModel: 'value',
|
||||||
name: 'a-select',
|
mode: 'tags',
|
||||||
vModel: 'value',
|
open: false
|
||||||
mode: 'tags',
|
},
|
||||||
open: false
|
helper: t('certd.email.helper'),
|
||||||
},
|
rules: [{ required: true, message: t('certd.email.required') }]
|
||||||
helper: '输入你的收件邮箱地址,支持多个邮箱',
|
}" />
|
||||||
rules: [{ required: true, message: '此项必填' }]
|
|
||||||
}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<a-alert v-if="!settingStore.isPlus" class="m-1" type="info">
|
<a-alert v-if="!settingStore.isPlus" class="m-1" type="info">
|
||||||
<template #message> 还没有配置邮件服务器?<router-link :to="{ path: '/sys/settings/email' }">现在就去</router-link> </template>
|
<template #message> 还没有配置邮件服务器?<router-link :to="{ path: '/sys/settings/email' }">现在就去</router-link>
|
||||||
</a-alert>
|
</template>
|
||||||
</div>
|
</a-alert>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Ref, ref, watch } from "vue";
|
import { Ref, ref, watch } from "vue";
|
||||||
import { useUserStore } from "/@/store/user";
|
import { useUserStore } from "/@/store/user";
|
||||||
import { useSettingStore } from "/@/store/settings";
|
import { useSettingStore } from "/@/store/settings";
|
||||||
|
import { useI18n } from "vue-i18n";
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
options: {
|
options: {
|
||||||
type: Object as PropType<any>,
|
type: Object as PropType<any>,
|
||||||
default: () => {}
|
default: () => { }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const settingStore = useSettingStore();
|
const settingStore = useSettingStore();
|
||||||
|
@ -38,30 +39,30 @@ const settingStore = useSettingStore();
|
||||||
const optionsFormState: Ref<any> = ref({});
|
const optionsFormState: Ref<any> = ref({});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => {
|
() => {
|
||||||
return props.options;
|
return props.options;
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
optionsFormState.value = {
|
optionsFormState.value = {
|
||||||
...props.options
|
...props.options
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true
|
immediate: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const emit = defineEmits(["change"]);
|
const emit = defineEmits(["change"]);
|
||||||
function doEmit() {
|
function doEmit() {
|
||||||
emit("change", { ...optionsFormState.value });
|
emit("change", { ...optionsFormState.value });
|
||||||
}
|
}
|
||||||
|
|
||||||
function getValue() {
|
function getValue() {
|
||||||
return { ...optionsFormState.value };
|
return { ...optionsFormState.value };
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
doEmit,
|
doEmit,
|
||||||
getValue
|
getValue
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,70 +1,65 @@
|
||||||
<template>
|
<template>
|
||||||
<a-drawer v-model:open="triggerDrawerVisible" placement="right" :closable="true" width="650px" class="pi-trigger-form" @after-open-change="triggerDrawerOnAfterVisibleChange">
|
<a-drawer v-model:open="triggerDrawerVisible" placement="right" :closable="true" width="650px"
|
||||||
<template #title>
|
class="pi-trigger-form" @after-open-change="triggerDrawerOnAfterVisibleChange">
|
||||||
<div>
|
<template #title>
|
||||||
编辑触发器
|
<div>
|
||||||
<a-button v-if="mode === 'edit'" @click="triggerDelete()">
|
编辑触发器
|
||||||
<template #icon><DeleteOutlined /></template>
|
<a-button v-if="mode === 'edit'" @click="triggerDelete()">
|
||||||
</a-button>
|
<template #icon>
|
||||||
</div>
|
<DeleteOutlined />
|
||||||
</template>
|
</template>
|
||||||
<template v-if="currentTrigger">
|
</a-button>
|
||||||
<pi-container>
|
</div>
|
||||||
<a-form ref="triggerFormRef" class="trigger-form" :model="currentTrigger" :label-col="labelCol" :wrapper-col="wrapperCol">
|
</template>
|
||||||
<fs-form-item
|
<template v-if="currentTrigger">
|
||||||
v-model="currentTrigger.title"
|
<pi-container>
|
||||||
:item="{
|
<a-form ref="triggerFormRef" class="trigger-form" :model="currentTrigger" :label-col="labelCol"
|
||||||
title: '触发器名称',
|
:wrapper-col="wrapperCol">
|
||||||
key: 'title',
|
<fs-form-item v-model="currentTrigger.title" :item="{
|
||||||
component: {
|
title: '触发器名称',
|
||||||
name: 'a-input',
|
key: 'title',
|
||||||
vModel: 'value',
|
component: {
|
||||||
disabled: !editMode,
|
name: 'a-input',
|
||||||
},
|
vModel: 'value',
|
||||||
rules: [{ required: true, message: '此项必填' }],
|
disabled: !editMode,
|
||||||
}"
|
},
|
||||||
/>
|
rules: [{ required: true, message: '此项必填' }],
|
||||||
|
}" />
|
||||||
|
|
||||||
<fs-form-item
|
<fs-form-item v-model="currentTrigger.type" :item="{
|
||||||
v-model="currentTrigger.type"
|
title: '类型',
|
||||||
:item="{
|
key: 'type',
|
||||||
title: '类型',
|
value: 'timer',
|
||||||
key: 'type',
|
component: {
|
||||||
value: 'timer',
|
name: 'a-select',
|
||||||
component: {
|
vModel: 'value',
|
||||||
name: 'a-select',
|
disabled: !editMode,
|
||||||
vModel: 'value',
|
options: [{ value: 'timer', label: '定时' }],
|
||||||
disabled: !editMode,
|
},
|
||||||
options: [{ value: 'timer', label: '定时' }],
|
rules: [{ required: true, message: '此项必填' }],
|
||||||
},
|
}" />
|
||||||
rules: [{ required: true, message: '此项必填' }],
|
|
||||||
}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<fs-form-item
|
<fs-form-item v-model="currentTrigger.props.cron" :item="{
|
||||||
v-model="currentTrigger.props.cron"
|
title: t('certd.cronForm.title'),
|
||||||
:item="{
|
key: 'props.cron',
|
||||||
title: '定时脚本',
|
component: {
|
||||||
key: 'props.cron',
|
disabled: !editMode,
|
||||||
component: {
|
name: 'cron-editor',
|
||||||
disabled: !editMode,
|
vModel: 'modelValue',
|
||||||
name: 'cron-editor',
|
},
|
||||||
vModel: 'modelValue',
|
helper: t('certd.cronForm.helper'),
|
||||||
},
|
rules: [{ required: true, message: t('certd.cronForm.required') }],
|
||||||
helper: '点击上面的按钮,选择每天几点定时执行。\n建议设置为每天触发一次,证书未到期之前任务会跳过,不会重复执行',
|
}" />
|
||||||
rules: [{ required: true, message: '此项必填' }],
|
</a-form>
|
||||||
}"
|
|
||||||
/>
|
|
||||||
</a-form>
|
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<a-form-item v-if="editMode" :wrapper-col="{ span: 14, offset: 4 }">
|
<a-form-item v-if="editMode" :wrapper-col="{ span: 14, offset: 4 }">
|
||||||
<a-button type="primary" @click="triggerSave"> 确定 </a-button>
|
<a-button type="primary" @click="triggerSave"> 确定 </a-button>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</template>
|
</template>
|
||||||
</pi-container>
|
</pi-container>
|
||||||
</template>
|
</template>
|
||||||
</a-drawer>
|
</a-drawer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -73,125 +68,124 @@ import { inject, ref } from "vue";
|
||||||
import * as _ from "lodash-es";
|
import * as _ from "lodash-es";
|
||||||
import { nanoid } from "nanoid";
|
import { nanoid } from "nanoid";
|
||||||
export default {
|
export default {
|
||||||
name: "PiTriggerForm",
|
name: "PiTriggerForm",
|
||||||
props: {
|
props: {
|
||||||
editMode: {
|
editMode: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
emits: ["update"],
|
emits: ["update"],
|
||||||
setup(props, context) {
|
setup(props, context) {
|
||||||
/**
|
/**
|
||||||
* trigger drawer
|
* trigger drawer
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function useTriggerForm() {
|
function useTriggerForm() {
|
||||||
const mode = ref("add");
|
const mode = ref("add");
|
||||||
const callback = ref();
|
const callback = ref();
|
||||||
const currentTrigger = ref({ title: undefined, input: {} });
|
const currentTrigger = ref({ title: undefined, input: {} });
|
||||||
const currentPlugin = ref({});
|
const currentPlugin = ref({});
|
||||||
const triggerFormRef = ref(null);
|
const triggerFormRef = ref(null);
|
||||||
const triggerDrawerVisible = ref(false);
|
const triggerDrawerVisible = ref(false);
|
||||||
const rules = ref({
|
const rules = ref({
|
||||||
name: [
|
name: [
|
||||||
{
|
{
|
||||||
type: "string",
|
type: "string",
|
||||||
required: true,
|
required: true,
|
||||||
message: "请输入名称",
|
message: "请输入名称",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const triggerDrawerShow = () => {
|
const triggerDrawerShow = () => {
|
||||||
triggerDrawerVisible.value = true;
|
triggerDrawerVisible.value = true;
|
||||||
};
|
};
|
||||||
const triggerDrawerClose = () => {
|
const triggerDrawerClose = () => {
|
||||||
triggerDrawerVisible.value = false;
|
triggerDrawerVisible.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const triggerDrawerOnAfterVisibleChange = val => {
|
const triggerDrawerOnAfterVisibleChange = val => {
|
||||||
console.log("triggerDrawerOnAfterVisibleChange", val);
|
console.log("triggerDrawerOnAfterVisibleChange", val);
|
||||||
};
|
};
|
||||||
|
|
||||||
const triggerOpen = (trigger, emit) => {
|
const triggerOpen = (trigger, emit) => {
|
||||||
callback.value = emit;
|
callback.value = emit;
|
||||||
currentTrigger.value = _.cloneDeep(trigger);
|
currentTrigger.value = _.cloneDeep(trigger);
|
||||||
console.log("currentTriggerOpen", currentTrigger.value);
|
console.log("currentTriggerOpen", currentTrigger.value);
|
||||||
triggerDrawerShow();
|
triggerDrawerShow();
|
||||||
};
|
};
|
||||||
|
|
||||||
const triggerAdd = emit => {
|
const triggerAdd = emit => {
|
||||||
mode.value = "add";
|
mode.value = "add";
|
||||||
const trigger = { id: nanoid(), title: "定时触发", type: "timer", props: {} };
|
const trigger = { id: nanoid(), title: "定时触发", type: "timer", props: {} };
|
||||||
triggerOpen(trigger, emit);
|
triggerOpen(trigger, emit);
|
||||||
};
|
};
|
||||||
|
|
||||||
const triggerEdit = (trigger, emit) => {
|
const triggerEdit = (trigger, emit) => {
|
||||||
mode.value = "edit";
|
mode.value = "edit";
|
||||||
triggerOpen(trigger, emit);
|
triggerOpen(trigger, emit);
|
||||||
};
|
};
|
||||||
|
|
||||||
const triggerView = (trigger, emit) => {
|
const triggerView = (trigger, emit) => {
|
||||||
mode.value = "view";
|
mode.value = "view";
|
||||||
triggerOpen(trigger, emit);
|
triggerOpen(trigger, emit);
|
||||||
};
|
};
|
||||||
|
|
||||||
const triggerSave = async e => {
|
const triggerSave = async e => {
|
||||||
console.log("currentTriggerSave", currentTrigger.value);
|
console.log("currentTriggerSave", currentTrigger.value);
|
||||||
try {
|
try {
|
||||||
await triggerFormRef.value.validate();
|
await triggerFormRef.value.validate();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("表单验证失败:", e);
|
console.error("表单验证失败:", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.value("save", currentTrigger.value);
|
callback.value("save", currentTrigger.value);
|
||||||
triggerDrawerClose();
|
triggerDrawerClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
const triggerDelete = () => {
|
const triggerDelete = () => {
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: "确认",
|
title: "确认",
|
||||||
content: `确定要删除此触发器吗?`,
|
content: `确定要删除此触发器吗?`,
|
||||||
async onOk() {
|
async onOk() {
|
||||||
callback.value("delete");
|
callback.value("delete");
|
||||||
triggerDrawerClose();
|
triggerDrawerClose();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const blankFn = () => {
|
const blankFn = () => {
|
||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
triggerFormRef,
|
triggerFormRef,
|
||||||
mode,
|
mode,
|
||||||
triggerAdd,
|
triggerAdd,
|
||||||
triggerEdit,
|
triggerEdit,
|
||||||
triggerView,
|
triggerView,
|
||||||
triggerDrawerShow,
|
triggerDrawerShow,
|
||||||
triggerDrawerVisible,
|
triggerDrawerVisible,
|
||||||
triggerDrawerOnAfterVisibleChange,
|
triggerDrawerOnAfterVisibleChange,
|
||||||
currentTrigger,
|
currentTrigger,
|
||||||
currentPlugin,
|
currentPlugin,
|
||||||
triggerSave,
|
triggerSave,
|
||||||
triggerDelete,
|
triggerDelete,
|
||||||
rules,
|
rules,
|
||||||
blankFn,
|
blankFn,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...useTriggerForm(),
|
...useTriggerForm(),
|
||||||
labelCol: { span: 6 },
|
labelCol: { span: 6 },
|
||||||
wrapperCol: { span: 16 },
|
wrapperCol: { span: 16 },
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
.pi-trigger-form {
|
.pi-trigger-form {}
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue