mirror of
https://github.com/certd/certd.git
synced 2026-07-27 14:57:40 +08:00
Compare commits
22 Commits
v1.38.2
...
640950d4c8
| Author | SHA1 | Date | |
|---|---|---|---|
| 640950d4c8 | |||
| 998de0f9a0 | |||
| ce6e515309 | |||
| e054c8fc55 | |||
| 9fa1c2eb3e | |||
| 64a314c19e | |||
| 40be42406c | |||
| bca0eefc83 | |||
| 662ca19f8f | |||
| 65f9d482f3 | |||
| 7058d5cb93 | |||
| f7b13c69e9 | |||
| 9f21b1a097 | |||
| 53983002b6 | |||
| d3c0914ac1 | |||
| 7eb9694221 | |||
| b8f0d37420 | |||
| 1d5b1c239c | |||
| d1ebc08478 | |||
| 5074a91669 | |||
| 40e56c4040 | |||
| 3b0ed9310a |
@@ -30,7 +30,7 @@ jobs:
|
||||
- name: publish_to_github
|
||||
id: publish_to_github
|
||||
run: |
|
||||
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
|
||||
export GITHUB_TOKEN=${{ secrets.GH_TOKEN }}
|
||||
rm -rf ./pnpm*.yaml
|
||||
npm install -g pnpm
|
||||
pnpm install
|
||||
|
||||
Vendored
+3
@@ -13,5 +13,8 @@
|
||||
"explorer.autoReveal": false,
|
||||
"[javascript]": {
|
||||
"editor.defaultFormatter": "vscode.typescript-language-features"
|
||||
},
|
||||
"[less]": {
|
||||
"editor.defaultFormatter": "vscode.css-language-features"
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ Certd® 是一个免费的全自动证书管理系统,让你的网站证书永
|
||||
* **站点证书监控**: 定时监控网站证书的过期时间
|
||||
* **多用户管理**: 用户可以管理自己的证书流水线
|
||||
* **多语言支持**: 中英双语切换
|
||||
* **一键无忧升级**: 版本向下兼容
|
||||
* **无忧升级**: 版本向下兼容
|
||||
|
||||
|
||||

|
||||
|
||||
@@ -3,6 +3,22 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.38.2](https://github.com/certd/certd/compare/v1.38.1...v1.38.2) (2026-01-22)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 编辑插件author不允许出现符号 ([5ea2b09](https://github.com/certd/certd/commit/5ea2b09dc30397c086a2498f958f661e7fef10fc))
|
||||
* 修复插件修改名字和删除后没有注销注册的bug ([61192b9](https://github.com/certd/certd/commit/61192b998a7088a8f446fd224cc242def462a79b))
|
||||
* 修复流水线复制出错的bug ([418bcdd](https://github.com/certd/certd/commit/418bcddc95bf19d2659d2a9cfe336bc059d157b0))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 优化流水线创建入口,各种证书申请任务类型拆分成多个按钮 ([f75c73d](https://github.com/certd/certd/commit/f75c73d739ee271fb718148416836dbe09bb3266))
|
||||
* 域名导入 ([ad64384](https://github.com/certd/certd/commit/ad64384891c13342980b7559924666dcfb2796c2))
|
||||
* 支持从提供商导入域名列表 ([f442363](https://github.com/certd/certd/commit/f4423638a2ee779d48fc17b3819ce3bee55b0361))
|
||||
* 支持同步域名过期时间 ([a97cee8](https://github.com/certd/certd/commit/a97cee84f3bfdeeb2083d91f748cac5405fed6ae))
|
||||
* cname记录支持批量导入和导出 ([607afe8](https://github.com/certd/certd/commit/607afe864a12d6f50993895a4e10f4c9a3dd8fee))
|
||||
|
||||
## [1.38.1](https://github.com/certd/certd/compare/v1.38.0...v1.38.1) (2026-01-15)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
# 专业版赞助
|
||||
|
||||
## 开源为什么要做专业版收费?
|
||||
1. 纯靠为爱发电不可持续,容易烂尾(比如:我的dev-sidecar项目即便是拥有20K+star,也差点凉凉,幸亏有另外大佬接手用爱发电)
|
||||
2. 没有赞助的项目,作者会比较任性,不会用心倾听用户的心声,不顾用户体验(比如:下意识拒绝需求、频繁破坏性变更升级、全盘推倒重来之类的)
|
||||
3. 没有赞助的项目,交流群的戾气有时候比较重,容易起冲突
|
||||
|
||||
## 赞助权益:
|
||||
1. 可加入专属VIP群,可以获得作者一对一技术支持,必要时可以远程协助
|
||||
# 专业版赞助
|
||||
|
||||
## 开源为什么要做专业版收费?
|
||||
1. 纯靠为爱发电不可持续,容易烂尾(比如:我的[dev-sidecar项目](https://github.com/docmirror/dev-sidecar)即便是拥有20K+star,也差点凉凉,幸亏有另外大佬接手用爱发电)
|
||||
2. 没有赞助的项目,作者会比较任性,不会用心倾听用户的心声,不顾用户体验(比如:下意识拒绝需求、频繁破坏性变更升级、全盘推倒重来之类的)
|
||||
|
||||
@@ -15,6 +15,8 @@ Certd 是一款开源、免费、全自动申请和部署更新SSL证书的工
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## 1、关于证书续期
|
||||
>* 实际上没有办法不改变证书文件本身情况下直接续期或者续签。
|
||||
>* 我们所说的续期,其实就是按照全套流程重新申请一份新证书,然后重新部署上去。
|
||||
|
||||
@@ -5,12 +5,20 @@
|
||||
|
||||

|
||||
|
||||
:::tip
|
||||
|
||||
接口key分两种权限范围:
|
||||
1. 仅开放接口: 仅能访问下面`接口文档`中的接口
|
||||
2. 用户级别: 可访问Certd所有接口,没有文档,可以在浏览器中F12抓取网络请求参考
|
||||
|
||||
:::
|
||||
|
||||
## 接口文档
|
||||
|
||||
https://apifox.com/apidoc/shared-2e76f8c4-7c58-413b-a32d-a1316529af44/254949529e0
|
||||
|
||||
|
||||
## Token生成方法
|
||||
### Token生成方法
|
||||
|
||||
header中传入x-certd-token即可调用开放接口
|
||||
1、首先从OpenKey页面生成keyId,keySecret;
|
||||
@@ -19,10 +27,10 @@ header中传入x-certd-token即可调用开放接口
|
||||
4、然后将content和sign分别base64后用.号连接: x-certd-token = base64(content) +"."+base64(sign)
|
||||
|
||||
|
||||
## 参数
|
||||
### 参数
|
||||
支持证书id和域名两种方式获取证书。
|
||||
|
||||
## 创建新的证书申请
|
||||
### 创建新的证书申请
|
||||
参数autoApply=true,将在没有证书时自动触发申请证书,检查逻辑如下:
|
||||
1. 如果证书仓库里面有,且没有过期,就直接返回证书
|
||||
2. 如果没有或者已过期,就会去找流水线,有就触发流水线执行
|
||||
@@ -30,7 +38,7 @@ header中传入x-certd-token即可调用开放接口
|
||||
4. 再次采用相同参数请求接口,如果在申请过程中,就会提示`正在申请中`,可轮循获取状态,直到证书申请成功。
|
||||
|
||||
|
||||
## SDK
|
||||
### SDK
|
||||
待开发
|
||||
|
||||
## 客户端工具
|
||||
|
||||
@@ -15,3 +15,4 @@
|
||||
## 2. 图文教程链接
|
||||
如果不方便登录系统,您还可以直接查看 [图文教程](https://gitee.com/certd/certd/blob/v2/step.md)
|
||||
|
||||

|
||||
Binary file not shown.
|
After Width: | Height: | Size: 109 KiB |
@@ -70,5 +70,5 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/publishlab/node-acme-client/issues"
|
||||
},
|
||||
"gitHead": "2c80c35b21b3f435e835167fca13db510bbc38a2"
|
||||
"gitHead": "f92dc6a1ad103de9cc184da3b84096943906cb59"
|
||||
}
|
||||
|
||||
@@ -47,5 +47,5 @@
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.4.2"
|
||||
},
|
||||
"gitHead": "2c80c35b21b3f435e835167fca13db510bbc38a2"
|
||||
"gitHead": "f92dc6a1ad103de9cc184da3b84096943906cb59"
|
||||
}
|
||||
|
||||
@@ -45,5 +45,5 @@
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.4.2"
|
||||
},
|
||||
"gitHead": "2c80c35b21b3f435e835167fca13db510bbc38a2"
|
||||
"gitHead": "f92dc6a1ad103de9cc184da3b84096943906cb59"
|
||||
}
|
||||
|
||||
@@ -35,7 +35,14 @@ export class Pager {
|
||||
}
|
||||
}
|
||||
|
||||
export async function doPageTurn<T>(req: { pager: Pager; getPage: (pager: Pager) => Promise<PageRes<T>>; itemHandle?: (item: T) => Promise<void>; batchHandle?: (pageRes: PageRes<T>) => Promise<void> }) {
|
||||
export type PageTurnReq<T = any> = {
|
||||
pager: Pager;
|
||||
getPage: (pager: Pager) => Promise<PageRes<T>>;
|
||||
itemHandle?: (item: T) => Promise<void>;
|
||||
batchHandle?: (pageRes: PageRes<T>) => Promise<void>;
|
||||
};
|
||||
|
||||
export async function doPageTurn<T>(req: PageTurnReq<T>) {
|
||||
let count = 0;
|
||||
const { pager, getPage, itemHandle, batchHandle } = req;
|
||||
while (true) {
|
||||
|
||||
@@ -24,5 +24,5 @@
|
||||
"prettier": "^2.8.8",
|
||||
"tslib": "^2.8.1"
|
||||
},
|
||||
"gitHead": "2c80c35b21b3f435e835167fca13db510bbc38a2"
|
||||
"gitHead": "f92dc6a1ad103de9cc184da3b84096943906cb59"
|
||||
}
|
||||
|
||||
@@ -31,5 +31,5 @@
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.4.2"
|
||||
},
|
||||
"gitHead": "2c80c35b21b3f435e835167fca13db510bbc38a2"
|
||||
"gitHead": "f92dc6a1ad103de9cc184da3b84096943906cb59"
|
||||
}
|
||||
|
||||
@@ -56,5 +56,5 @@
|
||||
"fetch"
|
||||
]
|
||||
},
|
||||
"gitHead": "2c80c35b21b3f435e835167fca13db510bbc38a2"
|
||||
"gitHead": "f92dc6a1ad103de9cc184da3b84096943906cb59"
|
||||
}
|
||||
|
||||
@@ -32,5 +32,5 @@
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.4.2"
|
||||
},
|
||||
"gitHead": "2c80c35b21b3f435e835167fca13db510bbc38a2"
|
||||
"gitHead": "f92dc6a1ad103de9cc184da3b84096943906cb59"
|
||||
}
|
||||
|
||||
@@ -64,5 +64,5 @@
|
||||
"typeorm": "^0.3.11",
|
||||
"typescript": "^5.4.2"
|
||||
},
|
||||
"gitHead": "2c80c35b21b3f435e835167fca13db510bbc38a2"
|
||||
"gitHead": "f92dc6a1ad103de9cc184da3b84096943906cb59"
|
||||
}
|
||||
|
||||
@@ -255,3 +255,4 @@ export class SysSafeSetting extends BaseSettings {
|
||||
autoHiddenTimes: 5,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -46,5 +46,5 @@
|
||||
"typeorm": "^0.3.11",
|
||||
"typescript": "^5.4.2"
|
||||
},
|
||||
"gitHead": "2c80c35b21b3f435e835167fca13db510bbc38a2"
|
||||
"gitHead": "f92dc6a1ad103de9cc184da3b84096943906cb59"
|
||||
}
|
||||
|
||||
@@ -38,5 +38,5 @@
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.4.2"
|
||||
},
|
||||
"gitHead": "2c80c35b21b3f435e835167fca13db510bbc38a2"
|
||||
"gitHead": "f92dc6a1ad103de9cc184da3b84096943906cb59"
|
||||
}
|
||||
|
||||
@@ -57,5 +57,5 @@
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.4.2"
|
||||
},
|
||||
"gitHead": "2c80c35b21b3f435e835167fca13db510bbc38a2"
|
||||
"gitHead": "f92dc6a1ad103de9cc184da3b84096943906cb59"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpClient, ILogger, utils } from "@certd/basic";
|
||||
import { IAccess, IServiceGetter, Pager, PageRes, Registrable } from "@certd/pipeline";
|
||||
import { IAccess, IServiceGetter, PageRes, PageSearch, Registrable } from "@certd/pipeline";
|
||||
|
||||
export type DnsProviderDefine = Registrable & {
|
||||
accessType: string;
|
||||
@@ -57,7 +57,7 @@ export interface IDnsProvider<T = any> {
|
||||
//中文域名是否需要punycode转码,如果返回True,则使用punycode来添加解析记录,否则使用中文域名添加解析记录
|
||||
usePunyCode(): boolean;
|
||||
|
||||
getDomainListPage(pager: Pager): Promise<PageRes<DomainRecord>>;
|
||||
getDomainListPage(pager: PageSearch): Promise<PageRes<DomainRecord>>;
|
||||
}
|
||||
|
||||
export interface ISubDomainsGetter {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Pager, PageRes } from "@certd/pipeline";
|
||||
import { HttpClient, ILogger } from "@certd/basic";
|
||||
import { PageRes, PageSearch } from "@certd/pipeline";
|
||||
import punycode from "punycode.js";
|
||||
import { CreateRecordOptions, DnsProviderContext, DnsProviderDefine, DomainRecord, IDnsProvider, RemoveRecordOptions } from "./api.js";
|
||||
import { dnsProviderRegistry } from "./registry.js";
|
||||
import { HttpClient, ILogger } from "@certd/basic";
|
||||
import punycode from "punycode.js";
|
||||
export abstract class AbstractDnsProvider<T = any> implements IDnsProvider<T> {
|
||||
ctx!: DnsProviderContext;
|
||||
http!: HttpClient;
|
||||
@@ -46,7 +46,7 @@ export abstract class AbstractDnsProvider<T = any> implements IDnsProvider<T> {
|
||||
|
||||
abstract removeRecord(options: RemoveRecordOptions<T>): Promise<void>;
|
||||
|
||||
async getDomainListPage(pager: Pager): Promise<PageRes<DomainRecord>> {
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -39,6 +39,7 @@ import { dict } from "@fast-crud/fast-crud";
|
||||
import * as api from "./api.js";
|
||||
import CnameTip from "./cname-tip.vue";
|
||||
import { Modal } from "ant-design-vue";
|
||||
import { utils } from "/@/utils/index.js";
|
||||
const statusDict = dict({
|
||||
data: [
|
||||
{ label: "待设置CNAME", value: "cname", color: "warning" },
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
<template>
|
||||
<div class="domain-select">
|
||||
<div class="flex flex-row">
|
||||
<a-select
|
||||
class="domain-select-input"
|
||||
:dropdown-style="dropdownStyle"
|
||||
show-search
|
||||
:filter-option="filterOption"
|
||||
:options="optionsRef"
|
||||
:value="value"
|
||||
v-bind="attrs"
|
||||
@click="onClick"
|
||||
@update:value="emit('update:value', $event)"
|
||||
>
|
||||
<template #dropdownRender="{ menuNode }">
|
||||
<template v-if="search">
|
||||
<div class="flex w-full items-center justify-between flex-wrap" style="padding: 4px 8px">
|
||||
<div class="flex-1 flex flex-row items-center">
|
||||
<a-input ref="inputRef" v-model:value="searchKeyRef" class="flex-1" allow-clear placeholder="这里可以搜索域名(数据来自“设置->域名管理”),您也可以直接在上面输入框输入" @keydown.enter="doSearch" />
|
||||
<fs-button type="primary" class="m-1" :loading="loading" icon="mingcute:search-2-line" @click="doSearch"> 查询 </fs-button>
|
||||
</div>
|
||||
<div class="manager flex flex-row items-center">
|
||||
<fs-button type="primary" class="m-1" icon="mingcute:vip-1-line" @click="openDomainImportDialog">导入域名</fs-button>
|
||||
<fs-button class="m-1" type="primary" icon="carbon:gui-management" @click="openDomainManager">管理域名</fs-button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="hasError" class="helper p-2" :class="{ error: hasError }">
|
||||
{{ message }}
|
||||
</div>
|
||||
<a-divider style="margin: 4px 0" />
|
||||
</template>
|
||||
<v-nodes :vnodes="menuNode" />
|
||||
|
||||
<div v-if="pager === true" class="pager text-center p-5" @click="paginationClick">
|
||||
<a-pagination v-model:current="pagerRef.pageNo" simple :total="pagerRef.total" :page-size="pagerRef.pageSize" @change="onPageChange" />
|
||||
</div>
|
||||
</template>
|
||||
<template #option="scope">
|
||||
<div class="flex flex-row items-center">
|
||||
<span class="min-w-60">{{ scope.label }}</span>
|
||||
<div>
|
||||
<fs-values-format :model-value="scope.challengeType" :dict="challengeTypeDict"></fs-values-format>
|
||||
<fs-values-format :model-value="scope.dnsProviderType" :dict="dnsProviderTypeDict"></fs-values-format>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</a-select>
|
||||
<div class="ml-5">
|
||||
<fs-button :loading="loading" title="刷新我的域名列表" icon="ion:refresh-outline" @click="refreshOptions"></fs-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="helper" :class="{ error: hasError }">
|
||||
{{ message }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed, defineComponent, ref, Ref, useAttrs } from "vue";
|
||||
import { request } from "/@/api/service";
|
||||
import { Dicts } from "../lib/dicts";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useDomainImport, useDomainImportManage } from "/@/views/certd/cert/domain/use";
|
||||
|
||||
defineOptions({
|
||||
name: "DomainSelector",
|
||||
});
|
||||
|
||||
const VNodes = defineComponent({
|
||||
props: {
|
||||
vnodes: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
render() {
|
||||
return this.vnodes;
|
||||
},
|
||||
});
|
||||
|
||||
const props = defineProps<{
|
||||
search?: boolean;
|
||||
pager?: boolean;
|
||||
value?: any[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
"update:value": any;
|
||||
}>();
|
||||
|
||||
const attrs = useAttrs();
|
||||
|
||||
const searchKeyRef = ref("");
|
||||
const optionsRef = ref([]);
|
||||
const message = ref("");
|
||||
const hasError = ref(false);
|
||||
const loading = ref(false);
|
||||
const pagerRef: Ref = ref({
|
||||
pageNo: 1,
|
||||
total: 0,
|
||||
pageSize: 20,
|
||||
});
|
||||
const getOptions = async () => {
|
||||
if (loading.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
message.value = "";
|
||||
hasError.value = false;
|
||||
loading.value = true;
|
||||
const pageNo = pagerRef.value.pageNo;
|
||||
const pageSize = pagerRef.value.pageSize;
|
||||
try {
|
||||
const res = await request({
|
||||
url: "/cert/domain/page",
|
||||
method: "POST",
|
||||
data: {
|
||||
query: {
|
||||
domain: props.search ? searchKeyRef.value : undefined,
|
||||
},
|
||||
page: {
|
||||
offset: (pageNo - 1) * pageSize,
|
||||
limit: pageSize,
|
||||
},
|
||||
},
|
||||
});
|
||||
const list = res?.records || res || [];
|
||||
|
||||
const options = [];
|
||||
for (let item of list) {
|
||||
options.push({
|
||||
value: item.domain,
|
||||
label: item.domain,
|
||||
dnsProviderType: item.dnsProviderType,
|
||||
challengeType: item.challengeType,
|
||||
});
|
||||
options.push({
|
||||
value: `*.${item.domain}`,
|
||||
label: `*.${item.domain}`,
|
||||
dnsProviderType: item.dnsProviderType,
|
||||
challengeType: item.challengeType,
|
||||
});
|
||||
}
|
||||
|
||||
optionsRef.value = options;
|
||||
pagerRef.value.total = list.length;
|
||||
if (props.pager) {
|
||||
if (res.total != null) {
|
||||
pagerRef.value.total = res.total;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const filterOption = (input: string, option: any) => {
|
||||
return option.label.toLowerCase().includes(input.toLowerCase()) || String(option.value).toLowerCase().includes(input.toLowerCase());
|
||||
};
|
||||
|
||||
async function onClick() {
|
||||
if (optionsRef.value?.length === 0) {
|
||||
await refreshOptions();
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshOptions() {
|
||||
await getOptions();
|
||||
}
|
||||
|
||||
async function doSearch() {
|
||||
pagerRef.value.pageNo = 1;
|
||||
await refreshOptions();
|
||||
}
|
||||
|
||||
async function onPageChange(current: any) {
|
||||
await refreshOptions();
|
||||
}
|
||||
|
||||
async function paginationClick(e: any) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
const dnsProviderTypeDict = Dicts.dnsProviderTypeDict;
|
||||
const challengeTypeDict = Dicts.challengeTypeDict;
|
||||
|
||||
const router = useRouter();
|
||||
function openDomainManager(e: any) {
|
||||
e.preventDefault();
|
||||
// router.push("/certd/cert/domain");
|
||||
window.open(`${window.location.origin}/#/certd/cert/domain`);
|
||||
}
|
||||
|
||||
const openDomainImportManageDialog = useDomainImportManage();
|
||||
function openDomainImportDialog() {
|
||||
openDomainImportManageDialog({
|
||||
afterSubmit: res => {
|
||||
refreshOptions();
|
||||
},
|
||||
});
|
||||
}
|
||||
const dropdownStyle = ref({
|
||||
zIndex: 2000,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less"></style>
|
||||
@@ -85,7 +85,9 @@ const message = ref("");
|
||||
const hasError = ref(false);
|
||||
const loading = ref(false);
|
||||
const pagerRef: Ref = ref({
|
||||
current: 1,
|
||||
pageNo: 1,
|
||||
total: 0,
|
||||
pageSize: 100,
|
||||
});
|
||||
const getOptions = async () => {
|
||||
if (loading.value) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import RemoteSelect from "./common/remote-select.vue";
|
||||
import RemoteInput from "./common/remote-input.vue";
|
||||
import RemoteTreeSelect from "./common/remote-tree-select.vue";
|
||||
import CertDomainsGetter from "./common/cert-domains-getter.vue";
|
||||
import DomainSelector from "./common/domain-selector.vue";
|
||||
import OutputSelector from "/@/components/plugins/common/output-selector/index.vue";
|
||||
import DnsProviderSelector from "/@/components/plugins/cert/dns-provider-selector/index.vue";
|
||||
import DomainsVerifyPlanEditor from "/@/components/plugins/cert/domains-verify-plan-editor/index.vue";
|
||||
@@ -29,6 +30,7 @@ export default {
|
||||
app.component("RemoteTreeSelect", RemoteTreeSelect);
|
||||
app.component("RemoteInput", RemoteInput);
|
||||
app.component("CertDomainsGetter", CertDomainsGetter);
|
||||
app.component("DomainSelector", DomainSelector);
|
||||
app.component("InputPassword", InputPassword);
|
||||
app.component("ParamsShow", ParamsShow);
|
||||
},
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="tsx" setup>
|
||||
import { defineProps, inject, ref, useAttrs } from "vue";
|
||||
import { inject, ref, useAttrs } from "vue";
|
||||
import { Modal } from "ant-design-vue";
|
||||
import { ComponentPropsType, doRequest } from "/@/components/plugins/lib";
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { onMounted, ref } from "vue";
|
||||
import TutorialSteps from "/@/components/tutorial/tutorial-steps.vue";
|
||||
import { mitter } from "/@/utils/util.mitt";
|
||||
import { useI18n } from "/@/locales";
|
||||
|
||||
defineOptions({
|
||||
name: "TutorialModal",
|
||||
@@ -8,6 +10,7 @@ defineOptions({
|
||||
|
||||
const props = defineProps<{
|
||||
showIcon?: boolean;
|
||||
mode?: string;
|
||||
}>();
|
||||
|
||||
const openedRef = ref(false);
|
||||
@@ -15,17 +18,26 @@ function open() {
|
||||
openedRef.value = true;
|
||||
}
|
||||
const slots = defineSlots();
|
||||
|
||||
onMounted(() => {
|
||||
mitter.on("openTutorialModal", () => {
|
||||
if (props.mode === "nav") {
|
||||
open();
|
||||
}
|
||||
});
|
||||
});
|
||||
const { t } = useI18n();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="tutorial-button pointer" @click="open">
|
||||
<template v-if="!slots.default">
|
||||
<fs-icon v-if="showIcon === false" icon="ant-design:question-circle-outlined" class="mr-0.5"></fs-icon>
|
||||
<div class="hidden md:block">{{ $t("tutorial.title") }}</div>
|
||||
<div class="hidden md:block">{{ t("tutorial.title") }}</div>
|
||||
</template>
|
||||
<slot></slot>
|
||||
<a-modal v-model:open="openedRef" class="tutorial-modal" width="90%">
|
||||
<template #title>{{ $t("tutorial.title") }}</template>
|
||||
<template #title>{{ t("tutorial.title") }}</template>
|
||||
<tutorial-steps v-if="openedRef" />
|
||||
<template #footer></template>
|
||||
</a-modal>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<a-steps :current="3" class="mt-10" size="small" :items="steps" @click="goPipeline"></a-steps>
|
||||
<a-steps :current="3" class="mt-10 simple-steps" size="small" :items="steps" @click="goPipeline"></a-steps>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
<script lang="tsx" setup>
|
||||
import { useRouter } from "vue-router";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
@@ -11,14 +11,26 @@ const { t } = useI18n();
|
||||
type Step = {
|
||||
title: string;
|
||||
description?: string;
|
||||
icon?: any;
|
||||
};
|
||||
|
||||
import { ref } from "vue";
|
||||
import { mitter } from "/@/utils/util.mitt";
|
||||
|
||||
const steps = ref<Step[]>([{ title: t("certd.steps.createPipeline") }, { title: t("certd.steps.addTask") }, { title: t("certd.steps.scheduledRun") }]);
|
||||
const steps = ref<Step[]>([
|
||||
{ title: t("certd.steps.createPipeline"), icon: <fs-icon icon="tabler:circle-number-1-filled"></fs-icon> },
|
||||
{ title: t("certd.steps.addTask"), icon: <fs-icon icon="tabler:circle-number-2-filled"></fs-icon> },
|
||||
{ title: t("certd.steps.scheduledRun"), icon: <fs-icon icon="tabler:circle-number-3-filled"></fs-icon> },
|
||||
]);
|
||||
|
||||
const router = useRouter();
|
||||
function goPipeline() {
|
||||
router.push({ path: "/certd/pipeline" });
|
||||
mitter.emit("openTutorialModal");
|
||||
}
|
||||
</script>
|
||||
<style lang="less">
|
||||
.simple-steps {
|
||||
.fs-icon {
|
||||
font-size: 18px !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<div class="text">
|
||||
<h3 class="title">{{ number }} {{ currentStepItem.title }}</h3>
|
||||
<div class="description mt-5">
|
||||
<div v-for="desc of currentStepItem.descriptions">{{ desc }}</div>
|
||||
<div v-for="(desc, index) of currentStepItem.descriptions" :key="index">{{ desc }}</div>
|
||||
</div>
|
||||
<div v-if="currentStepItem.body">
|
||||
<fs-render :render-func="currentStepItem.body" />
|
||||
@@ -29,9 +29,12 @@
|
||||
<script setup lang="tsx">
|
||||
import { FsRender } from "@fast-crud/fast-crud";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
const { t } = useI18n();
|
||||
import SimpleSteps from "./simple-steps.vue";
|
||||
|
||||
const props = defineProps<{
|
||||
mode?: string;
|
||||
}>();
|
||||
const { t } = useI18n();
|
||||
type Step = {
|
||||
title: string;
|
||||
subTitle?: string;
|
||||
@@ -69,10 +72,10 @@ const steps = ref<Step[]>([
|
||||
title: t("guide.createCertPipeline.items.successTitle"),
|
||||
descriptions: [t("guide.createCertPipeline.items.successDesc")],
|
||||
},
|
||||
{
|
||||
title: t("guide.createCertPipeline.items.nextTitle"),
|
||||
descriptions: [t("guide.createCertPipeline.items.nextDesc")],
|
||||
},
|
||||
// {
|
||||
// title: t("guide.createCertPipeline.items.nextTitle"),
|
||||
// descriptions: [t("guide.createCertPipeline.items.nextDesc")],
|
||||
// },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -252,7 +255,7 @@ function previewMask() {
|
||||
flex: 1;
|
||||
padding: 20px;
|
||||
.text {
|
||||
width: 350px;
|
||||
width: 400px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
@@ -12,16 +12,16 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="tsx" setup>
|
||||
import { computed, onMounted, reactive, ref } from "vue";
|
||||
import dayjs from "dayjs";
|
||||
import { message, Modal } from "ant-design-vue";
|
||||
import dayjs from "dayjs";
|
||||
import { computed, onMounted, reactive, ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRouter } from "vue-router";
|
||||
import * as api from "./api";
|
||||
import { useSettingStore } from "/@/store/settings";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useUserStore } from "/@/store/user";
|
||||
import { mitter } from "/@/utils/util.mitt";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { env } from "/@/utils/util.env";
|
||||
import { mitter } from "/@/utils/util.mitt";
|
||||
const { t } = useI18n();
|
||||
|
||||
const settingStore = useSettingStore();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="tsx" setup>
|
||||
import { ref, watch, defineOptions } from "vue";
|
||||
import { ref, watch } from "vue";
|
||||
import { routerUtils } from "/@/utils/util.router";
|
||||
import { useRoute } from "vue-router";
|
||||
import { utils } from "@fast-crud/fast-crud";
|
||||
|
||||
@@ -83,7 +83,7 @@ provide("fn:ai.open", openChat);
|
||||
</template>
|
||||
<template #header-right-0>
|
||||
<div class="hover:bg-accent ml-1 mr-2 cursor-pointer rounded-full hidden md:block">
|
||||
<tutorial-button class="flex-center header-btn" />
|
||||
<tutorial-button class="flex-center header-btn" mode="nav" />
|
||||
</div>
|
||||
<div class="hover:bg-accent ml-1 mr-2 cursor-pointer rounded-full">
|
||||
<vip-button class="flex-center header-btn" mode="nav" />
|
||||
|
||||
@@ -19,6 +19,7 @@ export default {
|
||||
legoCertPipeline: "Lego Certificate Pipeline",
|
||||
customPipeline: "Custom Pipeline",
|
||||
batchAddPipeline: "Add Pipeline Use Template",
|
||||
myPipelinesDesc: "Pipeline Mode: Apply -> Deploy -> Schedule",
|
||||
},
|
||||
order: {
|
||||
confirmTitle: "Order Confirmation",
|
||||
@@ -88,6 +89,14 @@ export default {
|
||||
helpDoc: "Help Docs",
|
||||
pipelineCount: "Number of Certificate Pipelines",
|
||||
noPipeline: "You have no certificate pipelines yet",
|
||||
enabledCount: "Enabled",
|
||||
disabledCount: "Disabled",
|
||||
certCount: "Number of Certificates",
|
||||
noCert: "You have no certificates yet",
|
||||
manageCert: "View Certificates",
|
||||
certExpiringCount: "Soon-to-Expire",
|
||||
certExpiredCount: "Expired",
|
||||
certNoExpireCount: "Not Expired",
|
||||
createNow: "Create Now",
|
||||
managePipeline: "Manage Pipelines",
|
||||
pipelineStatus: "Pipeline Status",
|
||||
|
||||
@@ -3,9 +3,9 @@ export default {
|
||||
title: "Create Certificate Application Pipeline",
|
||||
description: "Demonstrate how to configure a certificate application task",
|
||||
items: {
|
||||
tutorialTitle: "Tutorial Demo Content",
|
||||
tutorialDesc1: "This tutorial demonstrates how to automatically apply for a certificate and deploy it to Nginx",
|
||||
tutorialDesc2: "Only 3 steps, fully automatic application and deployment",
|
||||
tutorialTitle: "This tutorial demonstrates how to automatically apply for a certificate and deploy it to Nginx",
|
||||
tutorialDesc1: "Only 3 steps, fully automatic application and deployment",
|
||||
tutorialDesc2: "",
|
||||
createTitle: "Create Certificate Pipeline",
|
||||
createDesc: "Click to add a certificate pipeline and fill in the certificate application information",
|
||||
successTitle: "Pipeline Created Successfully",
|
||||
|
||||
@@ -23,6 +23,7 @@ export default {
|
||||
legoCertPipeline: "Lego证书流水线",
|
||||
customPipeline: "自定义流水线",
|
||||
batchAddPipeline: "模版批量创建流水线",
|
||||
myPipelinesDesc: "流水线模式:申请证书->部署证书->定时运行",
|
||||
},
|
||||
order: {
|
||||
confirmTitle: "订单确认",
|
||||
@@ -93,7 +94,16 @@ export default {
|
||||
alertMessage: "证书和授权为敏感信息,不要使用来历不明的在线Certd服务和镜像,以免泄露;请务必私有化部署使用,认准官方版本发布渠道:",
|
||||
helpDoc: "帮助文档",
|
||||
pipelineCount: "证书流水线数量",
|
||||
enabledCount: "已启用",
|
||||
disabledCount: "已禁用",
|
||||
noPipeline: "您还没有证书流水线",
|
||||
certCount: "证书数量",
|
||||
certExpiringCount: "即将过期",
|
||||
certExpiredCount: "已过期",
|
||||
certNoExpireCount: "未过期",
|
||||
noCert: "还没有证书",
|
||||
manageCert: "查看证书",
|
||||
|
||||
createNow: "立即创建",
|
||||
managePipeline: "管理流水线",
|
||||
pipelineStatus: "流水线状态",
|
||||
|
||||
@@ -3,9 +3,9 @@ export default {
|
||||
title: "创建证书申请流水线",
|
||||
description: "演示证书申请任务如何配置",
|
||||
items: {
|
||||
tutorialTitle: "教程演示内容",
|
||||
tutorialDesc1: "本教程演示如何自动申请证书并部署到Nginx上",
|
||||
tutorialDesc2: "仅需3步,全自动申请部署证书",
|
||||
tutorialTitle: "本教程演示如何自动申请证书并部署到Nginx上",
|
||||
tutorialDesc1: "仅需3步,全自动申请部署证书",
|
||||
tutorialDesc2: "",
|
||||
createTitle: "创建证书流水线",
|
||||
createDesc: "点击添加证书流水线,填写证书申请信息",
|
||||
successTitle: "流水线创建成功",
|
||||
|
||||
@@ -19,8 +19,8 @@ div#app {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
pre.pre{
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
||||
pre.pre {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
||||
}
|
||||
|
||||
h1,
|
||||
@@ -61,16 +61,20 @@ h6 {
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.flex-vc {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.flex-vb {
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
.flex-o {
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.flex-baseline {
|
||||
display: flex !important;
|
||||
align-items: baseline;
|
||||
@@ -82,9 +86,15 @@ h6 {
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
.flex-evenly {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.flex-inline {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -93,6 +103,7 @@ h6 {
|
||||
.flex-1 {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.flex-0 {
|
||||
flex: 0;
|
||||
}
|
||||
@@ -101,9 +112,11 @@ h6 {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.align-left {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.align-right {
|
||||
text-align: right;
|
||||
}
|
||||
@@ -111,18 +124,23 @@ h6 {
|
||||
.scroll-y {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.m-0 {
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
.m-2 {
|
||||
margin: 2px !important;
|
||||
}
|
||||
|
||||
.m-3 {
|
||||
margin: 3px !important;
|
||||
}
|
||||
|
||||
.m-5 {
|
||||
margin: 5px !important;
|
||||
}
|
||||
|
||||
.m-10 {
|
||||
margin: 10px !important;
|
||||
}
|
||||
@@ -130,6 +148,7 @@ h6 {
|
||||
.m-20 {
|
||||
margin: 20px !important;
|
||||
}
|
||||
|
||||
.mb-2 {
|
||||
margin-bottom: 2px !important;
|
||||
}
|
||||
@@ -137,6 +156,7 @@ h6 {
|
||||
.mb-5 {
|
||||
margin-bottom: 5px !important;
|
||||
}
|
||||
|
||||
.ml-5 {
|
||||
margin-left: 5px !important;
|
||||
}
|
||||
@@ -192,6 +212,7 @@ h6 {
|
||||
.p-20 {
|
||||
padding: 20px !important;
|
||||
}
|
||||
|
||||
.ellipsis {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
@@ -220,6 +241,7 @@ h6 {
|
||||
.color-plus {
|
||||
color: #c5913f;
|
||||
}
|
||||
|
||||
.color-blue {
|
||||
color: #1890ff;
|
||||
}
|
||||
@@ -231,6 +253,7 @@ h6 {
|
||||
.color-green {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.color-gray {
|
||||
color: gray;
|
||||
}
|
||||
@@ -274,6 +297,7 @@ h6 {
|
||||
font-size: 12px;
|
||||
margin-top: 3px;
|
||||
margin-bottom: 3px;
|
||||
|
||||
&.error {
|
||||
color: #ff4d4f;
|
||||
}
|
||||
@@ -281,6 +305,7 @@ h6 {
|
||||
|
||||
.fs-copyable {
|
||||
display: inline-flex;
|
||||
|
||||
.text {
|
||||
flex: 1;
|
||||
}
|
||||
@@ -292,7 +317,11 @@ h6 {
|
||||
}
|
||||
|
||||
.fs-16 {
|
||||
font-size: 16px;
|
||||
font-size: 16px !important;
|
||||
}
|
||||
|
||||
.fs-28 {
|
||||
font-size: 28px !important;
|
||||
}
|
||||
|
||||
.w-50\% {
|
||||
@@ -309,14 +338,121 @@ h6 {
|
||||
color: #6e6e6e;
|
||||
}
|
||||
|
||||
.ant-modal-body{
|
||||
.fs-form-body{
|
||||
.ant-modal-body {
|
||||
.fs-form-body {
|
||||
max-height: 66vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.ant-input-number{
|
||||
.ant-input-number {
|
||||
min-width: 100px;
|
||||
}
|
||||
|
||||
|
||||
.cd-table {
|
||||
width: 100%;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
overflow: auto;
|
||||
|
||||
.fs-loading {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.05);
|
||||
z-index: 10000
|
||||
}
|
||||
|
||||
table {
|
||||
width: 1000px;
|
||||
min-width: 100%;
|
||||
table-layout: fixed;
|
||||
font-size: 16px;
|
||||
|
||||
}
|
||||
|
||||
thead {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.position-sticky-right {
|
||||
position: sticky;
|
||||
right: 0;
|
||||
z-index: 100;
|
||||
border-left: 0px;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 1px;
|
||||
/* 边框宽度 */
|
||||
background: #eee;
|
||||
/* 边框颜色 */
|
||||
}
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #eee;
|
||||
border-left: 1px solid #eee;
|
||||
}
|
||||
|
||||
th {
|
||||
padding: 10px 5px;
|
||||
background: #fbfbfb;
|
||||
font-weight: 600;
|
||||
color: #000000;
|
||||
font-size: 14px;
|
||||
border-top: 1px solid #eee;
|
||||
|
||||
&:last-child {
|
||||
border-right: 1px solid #eee;
|
||||
}
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 10px;
|
||||
font-size: 14px;
|
||||
|
||||
&:last-child {
|
||||
border-right: 1px solid #eee;
|
||||
}
|
||||
}
|
||||
|
||||
td.position-sticky-right {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
|
||||
tr.hover-color:hover td {
|
||||
background: #f9f9ff;
|
||||
}
|
||||
|
||||
.status {
|
||||
padding: 5px 10px;
|
||||
border-radius: 20px;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.status-active {
|
||||
background: #e7f6e9;
|
||||
color: #2e7d32;
|
||||
}
|
||||
|
||||
.status-pending {
|
||||
background: #ffecb3;
|
||||
color: #f57c00;
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,11 @@ import { useFormWrapper } from "@fast-crud/fast-crud";
|
||||
|
||||
export type FormOptionReq = {
|
||||
title: string;
|
||||
columns: any;
|
||||
columns?: any;
|
||||
onSubmit?: any;
|
||||
body?: any;
|
||||
initialForm?: any;
|
||||
zIndex?: number;
|
||||
};
|
||||
|
||||
export function useFormDialog() {
|
||||
@@ -15,9 +18,14 @@ export function useFormDialog() {
|
||||
crudOptions: {
|
||||
columns: req.columns,
|
||||
form: {
|
||||
initialForm: req.initialForm,
|
||||
wrapper: {
|
||||
zIndex: req.zIndex,
|
||||
title: req.title,
|
||||
saveRemind: false,
|
||||
slots: {
|
||||
"form-body-top": req.body,
|
||||
},
|
||||
},
|
||||
async afterSubmit() {},
|
||||
async doSubmit({ form }: any) {
|
||||
|
||||
@@ -58,17 +58,44 @@ export async function DeleteBatch(ids: any[]) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function SyncSubmit(body: any) {
|
||||
export async function ImportTaskSave(body: any) {
|
||||
return await request({
|
||||
url: apiPrefix + "/sync/import",
|
||||
url: apiPrefix + "/import/save",
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
}
|
||||
|
||||
export async function SyncDomainsExpiration() {
|
||||
export async function ImportTaskStatus() {
|
||||
return await request({
|
||||
url: apiPrefix + "/sync/expiration",
|
||||
url: apiPrefix + "/import/status",
|
||||
method: "post",
|
||||
});
|
||||
}
|
||||
export async function ImportTaskDelete(key: string) {
|
||||
return await request({
|
||||
url: apiPrefix + "/import/delete",
|
||||
method: "post",
|
||||
data: { key },
|
||||
});
|
||||
}
|
||||
export async function ImportTaskStart(key: string) {
|
||||
return await request({
|
||||
url: apiPrefix + "/import/start",
|
||||
method: "post",
|
||||
data: { key },
|
||||
});
|
||||
}
|
||||
|
||||
export async function SyncExpirationStart() {
|
||||
return await request({
|
||||
url: apiPrefix + "/sync/expiration/start",
|
||||
method: "post",
|
||||
});
|
||||
}
|
||||
|
||||
export async function SyncExpirationStatus() {
|
||||
return await request({
|
||||
url: apiPrefix + "/sync/expiration/status",
|
||||
method: "post",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import * as api from "./api";
|
||||
import { useI18n } from "/src/locales";
|
||||
import { AddReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
|
||||
import { Modal, notification } from "ant-design-vue";
|
||||
import { Ref, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { AddReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
|
||||
import { useUserStore } from "/@/store/user";
|
||||
import { useSettingStore } from "/@/store/settings";
|
||||
import * as api from "./api";
|
||||
import { useDomainImportManage } from "./use";
|
||||
import { Dicts } from "/@/components/plugins/lib/dicts";
|
||||
import { useSettingStore } from "/@/store/settings";
|
||||
import { useUserStore } from "/@/store/user";
|
||||
import { createAccessApi } from "/@/views/certd/access/api";
|
||||
import { Modal, notification } from "ant-design-vue";
|
||||
import { useDomainImport } from "./use";
|
||||
|
||||
import { useI18n } from "/src/locales";
|
||||
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
||||
const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
@@ -51,7 +50,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
url: "pi/dnsProvider/dnsProviderTypeDict",
|
||||
});
|
||||
|
||||
const openDomainImportDialog = useDomainImport();
|
||||
const openDomainImportManageDialog = useDomainImportManage();
|
||||
return {
|
||||
crudOptions: {
|
||||
settings: {
|
||||
@@ -103,13 +102,10 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
needPlus: true,
|
||||
color: "gold",
|
||||
icon: "mingcute:vip-1-line",
|
||||
click: () => {
|
||||
settingStore.checkPlus();
|
||||
openDomainImportDialog({
|
||||
afterSubmit: () => {
|
||||
setTimeout(() => {
|
||||
crudExpose.doRefresh();
|
||||
}, 2000);
|
||||
click: async () => {
|
||||
await openDomainImportManageDialog({
|
||||
afterSubmit: res => {
|
||||
crudExpose.doRefresh();
|
||||
},
|
||||
});
|
||||
},
|
||||
@@ -120,7 +116,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
icon: "ion:refresh-outline",
|
||||
text: "同步域名过期时间",
|
||||
click: async () => {
|
||||
await api.SyncDomainsExpiration();
|
||||
await api.SyncExpirationStart();
|
||||
notification.success({
|
||||
message: "同步任务已提交",
|
||||
});
|
||||
@@ -339,10 +335,14 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
title: t("certd.domain.fromType"),
|
||||
type: "dict-select",
|
||||
dict: Dicts.domainFromTypeDict,
|
||||
form: {
|
||||
show: false,
|
||||
},
|
||||
column: {
|
||||
component: {
|
||||
color: "auto",
|
||||
},
|
||||
show: false,
|
||||
},
|
||||
},
|
||||
disabled: {
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
<template>
|
||||
<div class="domain-import-task-status min-h-[300px]">
|
||||
<div class="action mb-5">
|
||||
<fs-button type="primary" icon="mingcute:vip-1-line" @click="addTask">添加导入任务</fs-button>
|
||||
<fs-button type="primary" icon="ion:refresh-outline" class="ml-2" @click="loadImportTaskStatus">刷新</fs-button>
|
||||
</div>
|
||||
<div class="table-container overflow-auto mb-10">
|
||||
<table class="cd-table border-gray-300 w-full">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-[220px]">来源</th>
|
||||
<th class="">进度</th>
|
||||
<th class="w-[220px]">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="item in list" :key="item.key">
|
||||
<td class="ellipsis">
|
||||
<span class="flex items-center pointer" @click="editTask(item)">
|
||||
<span class="flex-1 ellipsis flex items-center">
|
||||
<fs-icon :icon="item.icon" class="mr-2"></fs-icon>
|
||||
{{ item.title }}
|
||||
</span>
|
||||
<fs-icon icon="ant-design:edit-outlined" class="ml-2" />
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div v-if="item.task">
|
||||
<div>
|
||||
<a-tag color="blue">总数:{{ item.task?.total }}</a-tag>
|
||||
<a-tag color="success" class="ml-2">成功:{{ item.task?.successCount }}</a-tag>
|
||||
<a-tag type="info" class="ml-2">跳过:{{ item.task?.skipCount }}</a-tag>
|
||||
<a-tooltip v-if="item.task?.errors.length > 0">
|
||||
<template #title>
|
||||
<div v-for="error in item.task?.errors" :key="error">{{ error }}</div>
|
||||
</template>
|
||||
<a-tag color="red" class="ml-2">失败:{{ item.task?.errors.length }}</a-tag>
|
||||
</a-tooltip>
|
||||
</div>
|
||||
<a-progress :percent="item.task?.progress" size="small" status="active" />
|
||||
</div>
|
||||
<div v-else>未执行</div>
|
||||
</td>
|
||||
<td>
|
||||
<fs-button type="primary" icon="ion:play-outline" :disabled="item.task?.status === 'running'" @click="startTask(item)">执行</fs-button>
|
||||
<fs-button type="primary" class="ml-2" danger icon="ion:trash-outline" @click="deleteTask(item)">删除</fs-button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Modal } from "ant-design-vue";
|
||||
import { onMounted, onUnmounted, ref } from "vue";
|
||||
import * as api from "./api";
|
||||
import { useDomainImport } from "./use";
|
||||
import { useSettingStore } from "/@/store/settings";
|
||||
defineOptions({
|
||||
name: "DomainImportTaskStatus",
|
||||
});
|
||||
|
||||
const list = ref([]);
|
||||
|
||||
async function loadImportTaskStatus() {
|
||||
const res = await api.ImportTaskStatus();
|
||||
list.value = res || [];
|
||||
}
|
||||
|
||||
async function startTask(item: any) {
|
||||
settingStore.checkPlus();
|
||||
await api.ImportTaskStart(item.key);
|
||||
await loadImportTaskStatus();
|
||||
}
|
||||
|
||||
async function deleteTask(item: any) {
|
||||
Modal.confirm({
|
||||
title: "确认删除吗?",
|
||||
okText: "确认",
|
||||
okType: "danger",
|
||||
onOk: async () => {
|
||||
await api.ImportTaskDelete(item.key);
|
||||
await loadImportTaskStatus();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const openDomainImportDialog = useDomainImport();
|
||||
const settingStore = useSettingStore();
|
||||
async function addTask() {
|
||||
settingStore.checkPlus();
|
||||
await openDomainImportDialog({
|
||||
afterSubmit: async (res?: any) => {
|
||||
if (res) {
|
||||
await api.ImportTaskStart(res.key);
|
||||
}
|
||||
await loadImportTaskStatus();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function editTask(item: any) {
|
||||
settingStore.checkPlus();
|
||||
await openDomainImportDialog({
|
||||
afterSubmit: async () => {
|
||||
await loadImportTaskStatus();
|
||||
},
|
||||
form: item,
|
||||
});
|
||||
}
|
||||
|
||||
const checkIntervalRef = ref();
|
||||
onMounted(async () => {
|
||||
await loadImportTaskStatus();
|
||||
checkIntervalRef.value = setInterval(async () => {
|
||||
await loadImportTaskStatus();
|
||||
}, 3000);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
clearInterval(checkIntervalRef.value);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.domain-import-task-status {
|
||||
.table-container {
|
||||
height: 50vh;
|
||||
}
|
||||
|
||||
.ant-progress {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -2,7 +2,9 @@ import { message } from "ant-design-vue";
|
||||
import * as api from "./api";
|
||||
import { useFormDialog } from "/@/use/use-dialog";
|
||||
import { compute } from "@fast-crud/fast-crud";
|
||||
|
||||
import { Dicts } from "/@/components/plugins/lib/dicts";
|
||||
import { useSettingStore } from "/@/store/settings";
|
||||
import DomainImportTaskStatus from "./import.vue";
|
||||
export function useDomainImport() {
|
||||
const { openFormDialog } = useFormDialog();
|
||||
|
||||
@@ -13,11 +15,11 @@ export function useDomainImport() {
|
||||
form: {
|
||||
component: {
|
||||
name: "dns-provider-selector",
|
||||
},
|
||||
on: {
|
||||
//@ts-ignore
|
||||
onSelectedChange: ({ form, $event }) => {
|
||||
form.dnsProviderAccessType = $event.accessType;
|
||||
on: {
|
||||
//@ts-ignore
|
||||
selectedChange: ({ form, $event }) => {
|
||||
form.dnsProviderAccessType = $event.accessType;
|
||||
},
|
||||
},
|
||||
},
|
||||
//@ts-ignore
|
||||
@@ -48,18 +50,40 @@ export function useDomainImport() {
|
||||
},
|
||||
};
|
||||
|
||||
return function openDomainImportDialog(req: { afterSubmit?: () => void }) {
|
||||
return function openDomainImportDialog(req: { afterSubmit?: (res?: any) => void; form?: any }) {
|
||||
openFormDialog({
|
||||
title: "从域名提供商导入域名",
|
||||
columns: columns,
|
||||
initialForm: {
|
||||
...req.form,
|
||||
},
|
||||
onSubmit: async (form: any) => {
|
||||
await api.SyncSubmit({
|
||||
const res = await api.ImportTaskSave({
|
||||
key: form.key,
|
||||
dnsProviderType: form.dnsProviderType,
|
||||
dnsProviderAccessId: form.dnsProviderAccessId,
|
||||
});
|
||||
message.success("导入任务已提交");
|
||||
if (req.afterSubmit) {
|
||||
req.afterSubmit();
|
||||
req.afterSubmit(res);
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function useDomainImportManage() {
|
||||
const { openFormDialog } = useFormDialog();
|
||||
const settingStore = useSettingStore();
|
||||
return async function openDomainImportManageDialog(req: { afterSubmit?: (res?: any) => void; form?: any; zIndex?: number }) {
|
||||
await openFormDialog({
|
||||
title: "从域名提供商导入域名",
|
||||
body: () => {
|
||||
return <DomainImportTaskStatus />;
|
||||
},
|
||||
zIndex: req.zIndex,
|
||||
onSubmit: async (form: any) => {
|
||||
if (req.afterSubmit) {
|
||||
req.afterSubmit(form);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -167,8 +167,8 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
show: true,
|
||||
},
|
||||
type: "text",
|
||||
helper: t("certd.helperIpCname"),
|
||||
form: {
|
||||
helper: t("certd.helperIpCname"),
|
||||
rules: [{ required: true, message: t("certd.ruleIpRequired") }],
|
||||
},
|
||||
column: {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
<template>
|
||||
<fs-page class="page-cert">
|
||||
<template #header>
|
||||
<div class="title">{{ t("certd.myPipelines") }}</div>
|
||||
<div class="title">
|
||||
{{ t("certd.myPipelines") }}
|
||||
<div class="sub">{{ t("certd.pipelinePage.myPipelinesDesc") }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<!-- <a-alert v-if="settingStore.sysPublic.notice" type="warning" show-icon>
|
||||
<template #message>
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
<div class="statistic-data m-20">
|
||||
<a-row :gutter="20" class="flex-wrap">
|
||||
<a-col :md="6" :xs="24">
|
||||
<statistic-card :title="t('certd.dashboard.pipelineCount')" :count="count.pipelineCount">
|
||||
<statistic-card icon="fluent-color:data-line-24" :title="t('certd.dashboard.pipelineCount')" :count="count.pipelineCount" :sub-counts="count.pipelineEnableCount">
|
||||
<template v-if="count.pipelineCount === 0" #default>
|
||||
<div class="flex-center flex-1 flex-col">
|
||||
<div style="font-size: 18px; font-weight: 700">{{ t("certd.dashboard.noPipeline") }}</div>
|
||||
@@ -79,18 +79,30 @@
|
||||
</template>
|
||||
</statistic-card>
|
||||
</a-col>
|
||||
<a-col :md="6" :xs="24">
|
||||
<!-- <a-col :md="6" :xs="24">
|
||||
<statistic-card :title="t('certd.dashboard.pipelineStatus')" :footer="false">
|
||||
<pie-count v-if="count.pipelineStatusCount" :data="count.pipelineStatusCount"></pie-count>
|
||||
</statistic-card>
|
||||
</a-col> -->
|
||||
<a-col :md="6" :xs="24">
|
||||
<statistic-card icon="fluent-color:certificate-24" :title="t('certd.dashboard.certCount')" :count="count.certCount" :sub-counts="count.certStatusCount">
|
||||
<template v-if="count.certCount === 0" #default>
|
||||
<div class="flex-center flex-1 flex-col">
|
||||
<div style="font-size: 18px; font-weight: 700">{{ t("certd.dashboard.noCert") }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #footer>
|
||||
<router-link to="/certd/monitor/cert" class="flex"> <fs-icon icon="ion:settings-outline" class="mr-5 fs-16" /> {{ t("certd.dashboard.manageCert") }} </router-link>
|
||||
</template>
|
||||
</statistic-card>
|
||||
</a-col>
|
||||
<a-col :md="6" :xs="24">
|
||||
<statistic-card :title="t('certd.dashboard.recentRun')" :footer="false">
|
||||
<statistic-card icon="fluent-color:data-trending-24" :title="t('certd.dashboard.recentRun')" :footer="false">
|
||||
<day-count v-if="count.historyCountPerDay" :data="count.historyCountPerDay" :title="t('certd.dashboard.runCount')"></day-count>
|
||||
</statistic-card>
|
||||
</a-col>
|
||||
<a-col :md="6" :xs="24">
|
||||
<statistic-card :title="t('certd.dashboard.expiringCerts')">
|
||||
<statistic-card icon="fluent-color:alert-urgent-24" :title="t('certd.dashboard.expiringCerts')">
|
||||
<expiring-list v-if="count.expiringList" :data="count.expiringList"></expiring-list>
|
||||
</statistic-card>
|
||||
</a-col>
|
||||
@@ -100,8 +112,11 @@
|
||||
<div v-if="pluginGroups" class="plugin-list">
|
||||
<a-card>
|
||||
<template #title>
|
||||
{{ t("certd.dashboard.supportedTasks") }}
|
||||
<a-tag color="green">{{ pluginGroups.groups.all.plugins.length }}</a-tag>
|
||||
<div class="flex items-center">
|
||||
<fs-icon icon="fluent-color:puzzle-piece-24" class="mr-5 fs-28" />
|
||||
<div class="mr-5">{{ t("certd.dashboard.supportedTasks") }}</div>
|
||||
<a-tag color="green">{{ pluginGroups.groups.all.plugins.length }}</a-tag>
|
||||
</div>
|
||||
</template>
|
||||
<a-row :gutter="10">
|
||||
<a-col v-for="item of pluginGroups.groups.all.plugins" :key="item.name" class="plugin-item-col" :xl="4" :md="6" :xs="24">
|
||||
@@ -126,32 +141,33 @@
|
||||
</a-row>
|
||||
</a-card>
|
||||
</div>
|
||||
<a-tour v-bind="tour" v-model:current="tour.current" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { FsIcon } from "@fast-crud/fast-crud";
|
||||
import SimpleSteps from "/@/components/tutorial/simple-steps.vue";
|
||||
import { useUserStore } from "/@/store/user";
|
||||
import { computed, ComputedRef, onMounted, Ref, ref } from "vue";
|
||||
import { notification } from "ant-design-vue";
|
||||
import dayjs from "dayjs";
|
||||
import StatisticCard from "/@/views/framework/home/dashboard/statistic-card.vue";
|
||||
import TutorialButton from "/@/components/tutorial/index.vue";
|
||||
import DayCount from "./charts/day-count.vue";
|
||||
import PieCount from "./charts/pie-count.vue";
|
||||
import ExpiringList from "./charts/expiring-list.vue";
|
||||
import SuiteCard from "./suite-card.vue";
|
||||
import { useSettingStore } from "/@/store/settings";
|
||||
import { SiteInfo } from "/@/store/settings/api.basic";
|
||||
import { UserInfoRes } from "/@/store/user/api.user";
|
||||
import { GetStatisticCount } from "/@/views/framework/home/dashboard/api";
|
||||
import { computed, ComputedRef, onMounted, Ref, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import * as api from "./api";
|
||||
import DayCount from "./charts/day-count.vue";
|
||||
import ExpiringList from "./charts/expiring-list.vue";
|
||||
import NoticeBar from "./notice-bar.vue";
|
||||
import SuiteCard from "./suite-card.vue";
|
||||
import TutorialButton from "/@/components/tutorial/index.vue";
|
||||
import SimpleSteps from "/@/components/tutorial/simple-steps.vue";
|
||||
import { usePluginStore } from "/@/store/plugin";
|
||||
import { useSettingStore } from "/@/store/settings";
|
||||
import { SiteInfo } from "/@/store/settings/api.basic";
|
||||
import { useUserStore } from "/@/store/user";
|
||||
import { UserInfoRes } from "/@/store/user/api.user";
|
||||
import { LocalStorage } from "/@/utils/util.storage";
|
||||
import { GetStatisticCount } from "/@/views/framework/home/dashboard/api";
|
||||
import StatisticCard from "/@/views/framework/home/dashboard/statistic-card.vue";
|
||||
import { useI18n } from "/src/locales";
|
||||
const { t } = useI18n();
|
||||
import { usePluginStore } from "/@/store/plugin";
|
||||
import { notification } from "ant-design-vue";
|
||||
import NoticeBar from "./notice-bar.vue";
|
||||
defineOptions({
|
||||
name: "DashboardUser",
|
||||
});
|
||||
@@ -242,6 +258,19 @@ function transformStatusCount() {
|
||||
}
|
||||
}
|
||||
count.value.pipelineStatusCount = result;
|
||||
|
||||
const pipelineEnableCount = count.value.pipelineEnableCount;
|
||||
count.value.pipelineEnableCount = [
|
||||
{ name: t("certd.dashboard.enabledCount"), value: pipelineEnableCount.enabled, color: "green" },
|
||||
{ name: t("certd.dashboard.disabledCount"), value: pipelineEnableCount.disabled, color: "gray" },
|
||||
];
|
||||
const certCount = count.value.certCount;
|
||||
count.value.certStatusCount = [
|
||||
{ name: t("certd.dashboard.certExpiredCount"), value: certCount.expired, color: "red", checkIcon: "mingcute:warning-fill:#f44336" },
|
||||
{ name: t("certd.dashboard.certExpiringCount"), value: certCount.expiring, color: "yellow", checkIcon: "mingcute:alert-fill:#ff9800", title: "到期不足15天" },
|
||||
{ name: t("certd.dashboard.certNoExpireCount"), value: certCount.notExpired, color: "green" },
|
||||
];
|
||||
count.value.certCount = certCount.total;
|
||||
}
|
||||
async function loadCount() {
|
||||
count.value = await GetStatisticCount();
|
||||
@@ -266,6 +295,9 @@ onMounted(async () => {
|
||||
loadLatestVersion();
|
||||
loadCount();
|
||||
loadPluginGroups();
|
||||
if (count.value.pipelineCount === 0) {
|
||||
tourHandleOpen(true);
|
||||
}
|
||||
});
|
||||
|
||||
function openUpgradeUrl() {
|
||||
@@ -300,6 +332,50 @@ const noticeList = computed(() => {
|
||||
|
||||
return list;
|
||||
});
|
||||
|
||||
function useTour() {
|
||||
const tour = ref({
|
||||
open: false,
|
||||
current: 0,
|
||||
steps: [],
|
||||
onClose: () => {
|
||||
tour.value.open = false;
|
||||
LocalStorage.set("home-tour-off", true, 999999999);
|
||||
},
|
||||
onFinish: () => {
|
||||
tour.value.open = false;
|
||||
LocalStorage.set("home-tour-off", true, 999999999);
|
||||
},
|
||||
});
|
||||
|
||||
const tourHandleOpen = (val: boolean): void => {
|
||||
if (LocalStorage.get("home-tour-off")) {
|
||||
return;
|
||||
}
|
||||
initSteps();
|
||||
tour.value.open = val;
|
||||
};
|
||||
|
||||
function initSteps() {
|
||||
//@ts-ignore
|
||||
tour.value.steps = [
|
||||
{
|
||||
title: "您是第一次使用吗?",
|
||||
description: "此处可以查看新手教程哦 ↑↑↑↑",
|
||||
target: () => {
|
||||
return document.querySelector("header .tutorial-button");
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return {
|
||||
tour,
|
||||
tourHandleOpen,
|
||||
};
|
||||
}
|
||||
|
||||
const { tour, tourHandleOpen } = useTour();
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
|
||||
@@ -3,12 +3,35 @@
|
||||
<a-card>
|
||||
<div class="data-item">
|
||||
<div class="header">
|
||||
<div class="title">{{ title }}</div>
|
||||
<div class="title">
|
||||
<fs-icon :icon="icon" class="statistic-icon"></fs-icon>
|
||||
{{ title }}
|
||||
</div>
|
||||
<div class="more"></div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div v-if="!slots.default" class="statistic">
|
||||
<div v-if="count !== 0" class="value">{{ count }}</div>
|
||||
<div v-if="count !== 0" class="value flex items-center w-full">
|
||||
<div class="total flex-center flex-1 flex-col">
|
||||
<span>{{ count }}</span>
|
||||
<span class="sub-title">{{ title }}</span>
|
||||
</div>
|
||||
<a-divider type="vertical h-10"></a-divider>
|
||||
<div class="sub flex-1 flex-col h-[80%] flex-evenly pl-4">
|
||||
<div v-for="item in subCounts" :key="item.name" class="sub-item flex justify-center w-full" :title="item.title">
|
||||
<div class="flex items-center w-[60%] ellipsis overflow-hidden">
|
||||
<div class="status-indicator" :class="`bg-${item.color}`"></div>
|
||||
{{ item.name }}:
|
||||
</div>
|
||||
<div class="w-[40%] flex items-center justify-center relative">
|
||||
<span class="icon-text">{{ item.value }}</span>
|
||||
<div v-if="item.value !== 0 && item.checkIcon" class="ml-2 flex items-center absolute right-0">
|
||||
<fs-icon :icon="item.checkIcon" class="fs-icon"></fs-icon>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a-empty v-else></a-empty>
|
||||
</div>
|
||||
<slot></slot>
|
||||
@@ -23,53 +46,126 @@
|
||||
<script setup lang="ts">
|
||||
import { FsIcon } from "@fast-crud/fast-crud";
|
||||
const props = defineProps<{
|
||||
icon: string;
|
||||
title: string;
|
||||
count?: number;
|
||||
subCounts?: {
|
||||
name: string;
|
||||
value: number;
|
||||
color: string;
|
||||
checkIcon?: string;
|
||||
title?: string;
|
||||
}[];
|
||||
}>();
|
||||
const slots = defineSlots();
|
||||
</script>
|
||||
<style lang="less">
|
||||
.statistic-card {
|
||||
margin-bottom: 10px;
|
||||
|
||||
.ant-card-body {
|
||||
padding: 15px 24px;
|
||||
}
|
||||
.icon-text {
|
||||
display: inline-flex;
|
||||
justify-content: left;
|
||||
align-items: center;
|
||||
|
||||
.fs-icon {
|
||||
margin-right: 5px;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.data-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 188px;
|
||||
height: 200px;
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
//padding-bottom: 10px;
|
||||
color: #8077a4;
|
||||
margin-top: 6px;
|
||||
margin-bottom: 6px;
|
||||
color: #494949;
|
||||
align-items: center;
|
||||
|
||||
.title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font-weight: 600;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.more {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.statistic-icon {
|
||||
font-size: 28px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
|
||||
.statistic {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
.value {
|
||||
font-size: 50px;
|
||||
font-weight: 700;
|
||||
color: #2c254e;
|
||||
.total {
|
||||
color: hsl(var(--primary));
|
||||
.sub-title {
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
color: #626262;
|
||||
}
|
||||
}
|
||||
|
||||
.sub-item {
|
||||
font-size: 14px;
|
||||
|
||||
.status-indicator {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
margin-right: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.bg-green {
|
||||
background: linear-gradient(90deg, #4caf50, #8bc34a);
|
||||
}
|
||||
|
||||
.bg-red {
|
||||
background: linear-gradient(90deg, #f44336, #e57373);
|
||||
}
|
||||
|
||||
.bg-yellow {
|
||||
background: linear-gradient(90deg, #ff9800, #ffc107);
|
||||
}
|
||||
.bg-blue {
|
||||
background: linear-gradient(90deg, #2196f3, #64b5f6);
|
||||
}
|
||||
.bg-gray {
|
||||
background: linear-gradient(90deg, #9e9e9e, #bdbdbd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
x-vue-echarts {
|
||||
}
|
||||
}
|
||||
|
||||
.footer {
|
||||
color: #8077a4;
|
||||
font-size: 12px;
|
||||
@@ -81,10 +177,10 @@ const slots = defineSlots();
|
||||
border-style: dashed;
|
||||
border-width: 1px 0 0;
|
||||
padding-top: 15px;
|
||||
|
||||
> * {
|
||||
cursor: pointer;
|
||||
}
|
||||
margin-bottom: -10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ import { createHtmlPlugin } from "vite-plugin-html";
|
||||
import { loadEnv } from "vite";
|
||||
import * as path from "path";
|
||||
import DefineOptions from "unplugin-vue-define-options/vite";
|
||||
import { theme } from "ant-design-vue";
|
||||
const { defaultAlgorithm, defaultSeed } = theme;
|
||||
const mapToken = defaultAlgorithm(defaultSeed);
|
||||
// import WindiCSS from "vite-plugin-windicss";
|
||||
// import { generateModifyVars } from "./build/modify-vars";
|
||||
// import { configThemePlugin } from "./build/theme-plugin";
|
||||
@@ -76,7 +79,7 @@ export default ({ command, mode }) => {
|
||||
// 修改默认主题颜色,配置less变量
|
||||
// modifyVars: generateModifyVars(),
|
||||
javascriptEnabled: true,
|
||||
// modifyVars: mapToken
|
||||
modifyVars: mapToken,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
|
||||
import { Constants, CrudController } from '@certd/lib-server';
|
||||
import {DomainService} from "../../../modules/cert/service/domain-service.js";
|
||||
import { DomainService } from "../../../modules/cert/service/domain-service.js";
|
||||
import { checkPlus } from '@certd/plus-core';
|
||||
|
||||
/**
|
||||
@@ -80,23 +80,65 @@ export class DomainController extends CrudController<DomainService> {
|
||||
}
|
||||
|
||||
|
||||
@Post('/sync/import', { summary: Constants.per.authOnly })
|
||||
async syncImport(@Body(ALL) body: any) {
|
||||
const { dnsProviderType, dnsProviderAccessId } = body;
|
||||
@Post('/import/start', { summary: Constants.per.authOnly })
|
||||
async importStart(@Body(ALL) body: any) {
|
||||
checkPlus();
|
||||
const { key } = body;
|
||||
const req = {
|
||||
dnsProviderType, dnsProviderAccessId, userId: this.getUserId(),
|
||||
key, userId: this.getUserId(),
|
||||
}
|
||||
checkPlus()
|
||||
await this.service.doSyncFromProvider(req);
|
||||
await this.service.startDomainImportTask(req);
|
||||
return this.ok();
|
||||
}
|
||||
|
||||
@Post('/sync/expiration', { summary: Constants.per.authOnly })
|
||||
async syncExpiration(@Body(ALL) body: any) {
|
||||
await this.service.doSyncDomainsExpirationDate({
|
||||
@Post('/import/status', { summary: Constants.per.authOnly })
|
||||
async importStatus() {
|
||||
const req = {
|
||||
userId: this.getUserId(),
|
||||
}
|
||||
const task = await this.service.getDomainImportTaskStatus(req);
|
||||
return this.ok(task);
|
||||
}
|
||||
|
||||
|
||||
@Post('/import/delete', { summary: Constants.per.authOnly })
|
||||
async importDelete(@Body(ALL) body: any) {
|
||||
const { key } = body;
|
||||
const req = {
|
||||
userId: this.getUserId(),
|
||||
key,
|
||||
}
|
||||
await this.service.deleteDomainImportTask(req);
|
||||
return this.ok();
|
||||
}
|
||||
|
||||
@Post('/import/save', { summary: Constants.per.authOnly })
|
||||
async importSave(@Body(ALL) body: any) {
|
||||
checkPlus();
|
||||
const { dnsProviderType, dnsProviderAccessId, key } = body;
|
||||
const req = {
|
||||
userId: this.getUserId(),
|
||||
dnsProviderType, dnsProviderAccessId, key
|
||||
}
|
||||
const item = await this.service.saveDomainImportTask(req);
|
||||
return this.ok(item);
|
||||
}
|
||||
|
||||
|
||||
@Post('/sync/expiration/start', { summary: Constants.per.authOnly })
|
||||
async syncExpirationStart(@Body(ALL) body: any) {
|
||||
await this.service.startSyncExpirationTask({
|
||||
userId: this.getUserId(),
|
||||
})
|
||||
return this.ok();
|
||||
}
|
||||
@Post('/sync/expiration/status', { summary: Constants.per.authOnly })
|
||||
async syncExpirationStatus(@Body(ALL) body: any) {
|
||||
const status = await this.service.getSyncExpirationTaskStatus({
|
||||
userId: this.getUserId(),
|
||||
})
|
||||
return this.ok(status);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { UserService } from '../../../modules/sys/authority/service/user-service
|
||||
import { RoleService } from '../../../modules/sys/authority/service/role-service.js';
|
||||
import { PipelineService } from '../../../modules/pipeline/service/pipeline-service.js';
|
||||
import { HistoryService } from '../../../modules/pipeline/service/history-service.js';
|
||||
import { CertInfoService } from '../../../modules/monitor/index.js';
|
||||
|
||||
export type ChartItem = {
|
||||
name: string;
|
||||
@@ -12,7 +13,17 @@ export type ChartItem = {
|
||||
export type UserStatisticCount = {
|
||||
pipelineCount?: number;
|
||||
pipelineStatusCount?: ChartItem[];
|
||||
pipelineEnableCount?: {
|
||||
enabled: number;
|
||||
disabled: number;
|
||||
};
|
||||
historyCountPerDay: ChartItem[];
|
||||
certCount?: {
|
||||
total: number;
|
||||
expired: number;
|
||||
expiring: number;
|
||||
notExpired: number;
|
||||
};
|
||||
expiringList: any[];
|
||||
};
|
||||
/**
|
||||
@@ -30,15 +41,25 @@ export class StatisticController extends BaseController {
|
||||
@Inject()
|
||||
historyService: HistoryService;
|
||||
|
||||
@Inject()
|
||||
certInfoService: CertInfoService;
|
||||
|
||||
@Post('/count', { summary: Constants.per.authOnly })
|
||||
public async count() {
|
||||
const pipelineCount = await this.pipelineService.count({ userId: this.getUserId() });
|
||||
const pipelineStatusCount = await this.pipelineService.statusCount({ userId: this.getUserId() });
|
||||
const pipelineEnableCount = await this.pipelineService.enableCount({ userId: this.getUserId() });
|
||||
|
||||
const historyCount = await this.historyService.countPerDay({ userId: this.getUserId(), days: 7 });
|
||||
const expiringList = await this.pipelineService.latestExpiringList({ userId: this.getUserId(), count: 5 });
|
||||
|
||||
const certCount = await this.certInfoService.count({ userId: this.getUserId() });
|
||||
|
||||
const count: UserStatisticCount = {
|
||||
pipelineCount,
|
||||
pipelineStatusCount,
|
||||
pipelineEnableCount,
|
||||
certCount,
|
||||
historyCountPerDay: historyCount,
|
||||
expiringList,
|
||||
};
|
||||
|
||||
@@ -220,7 +220,7 @@ export class AutoCRegisterCron {
|
||||
name: 'domain-expire-check',
|
||||
cron: `0 ${randomMinute} ${randomHour} ? * ${randomWeek}`, // 每周随机一天检查一次
|
||||
job: async () => {
|
||||
await this.domainService.doSyncDomainsExpirationDate({})
|
||||
await this.domainService.startSyncExpirationTask({})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
import { logger } from "@certd/basic"
|
||||
|
||||
export class BackTaskExecutor {
|
||||
tasks: Record<string, Record<string, BackTask>> = {}
|
||||
|
||||
start(task: BackTask) {
|
||||
const type = task.type || 'default'
|
||||
if (!this.tasks[type]) {
|
||||
this.tasks[type] = {}
|
||||
}
|
||||
const oldTask = this.tasks[type][task.key]
|
||||
if (oldTask ){
|
||||
if (oldTask.status === "running") {
|
||||
throw new Error(`任务 ${task.title} 正在运行中`)
|
||||
}
|
||||
this.clear(type, task.key);
|
||||
}
|
||||
this.tasks[type][task.key] = task
|
||||
this.run(task);
|
||||
}
|
||||
|
||||
get(type: string, key: string) {
|
||||
if (!this.tasks[type]) {
|
||||
this.tasks[type] = {}
|
||||
}
|
||||
return this.tasks[type][key]
|
||||
}
|
||||
|
||||
removeIsEnd(type: string, key: string) {
|
||||
const task = this.tasks[type]?.[key]
|
||||
if (task && task.status !== "running") {
|
||||
this.clear(type, key);
|
||||
}
|
||||
}
|
||||
|
||||
clear(type: string, key: string) {
|
||||
const task = this.tasks[type]?.[key]
|
||||
if (task) {
|
||||
task.clearTimeout();
|
||||
delete this.tasks[type][key]
|
||||
}
|
||||
}
|
||||
|
||||
private async run(task: BackTask) {
|
||||
const type = task.type || 'default'
|
||||
if (task.status === "running") {
|
||||
throw new Error(`任务 ${type}—${task.key} 正在运行中`)
|
||||
}
|
||||
task.startTime = Date.now();
|
||||
task.clearTimeout();
|
||||
try {
|
||||
task.status = "running";
|
||||
return await task.run(task);
|
||||
} catch (e) {
|
||||
logger.error(`任务 ${task.title}[${type}-${task.key}] 执行失败`, e.message);
|
||||
task.status = "failed";
|
||||
task.addError(e.message)
|
||||
} finally {
|
||||
task.endTime = Date.now();
|
||||
task.status = "done";
|
||||
task.setTimeoutId(setTimeout(() => {
|
||||
this.clear(type, task.key);
|
||||
}, 24 * 60 * 60 * 1000));
|
||||
delete task.run;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
export class BackTask {
|
||||
type: string;
|
||||
key: string;
|
||||
title: string;
|
||||
total: number = 0;
|
||||
current: number = 0;
|
||||
skip: number = 0;
|
||||
startTime: number;
|
||||
endTime: number;
|
||||
status: string = "pending";
|
||||
errors?: string[] = [];
|
||||
private _timeoutId?: NodeJS.Timeout;
|
||||
|
||||
|
||||
|
||||
private _run: (task: BackTask) => Promise<void>;
|
||||
|
||||
constructor(opts: {
|
||||
type: string,
|
||||
key: string, title: string, run: (task: BackTask) => Promise<void>
|
||||
}) {
|
||||
const { key, title, run, type } = opts
|
||||
this.type = type
|
||||
this.key = key;
|
||||
this.title = title;
|
||||
this._run = run;
|
||||
|
||||
Object.defineProperty(this, '_run', {
|
||||
enumerable: false,
|
||||
value: this._run
|
||||
})
|
||||
Object.defineProperty(this, '_timeoutId', {
|
||||
enumerable: false,
|
||||
value: null
|
||||
})
|
||||
|
||||
Object.defineProperty(this, 'progress', {
|
||||
get: ()=> {
|
||||
return this.getProgress()
|
||||
},
|
||||
enumerable: true, // 关键:设置为可枚举
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(this, 'successCount', {
|
||||
get: ()=> {
|
||||
return this.getSuccessCount()
|
||||
},
|
||||
enumerable: true, // 关键:设置为可枚举
|
||||
configurable: true
|
||||
})
|
||||
Object.defineProperty(this, 'errorCount', {
|
||||
get: ()=> {
|
||||
return this.getErrorCount()
|
||||
},
|
||||
enumerable: true, // 关键:设置为可枚举
|
||||
configurable: true
|
||||
})
|
||||
Object.defineProperty(this, 'skipCount', {
|
||||
get: ()=> {
|
||||
return this.getSkipCount()
|
||||
},
|
||||
enumerable: true, // 关键:设置为可枚举
|
||||
configurable: true
|
||||
})
|
||||
}
|
||||
|
||||
async run(task: BackTask) {
|
||||
return await this._run(task);
|
||||
}
|
||||
|
||||
clearTimeout() {
|
||||
if (this._timeoutId) {
|
||||
clearTimeout(this._timeoutId);
|
||||
this._timeoutId = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setTimeoutId(timeoutId: NodeJS.Timeout) {
|
||||
this.clearTimeout();
|
||||
this._timeoutId = timeoutId;
|
||||
}
|
||||
|
||||
setTotal(total: number) {
|
||||
this.total = total;
|
||||
}
|
||||
incrementCurrent() {
|
||||
this.current++
|
||||
}
|
||||
|
||||
addError(error: string) {
|
||||
logger.error(error)
|
||||
this.errors.push(error)
|
||||
}
|
||||
|
||||
getErrorCount() {
|
||||
return this.errors.length
|
||||
}
|
||||
|
||||
getSkipCount() {
|
||||
return this.skip
|
||||
}
|
||||
|
||||
getSuccessCount() {
|
||||
return this.current - this.errors.length
|
||||
}
|
||||
|
||||
getProgress() {
|
||||
return (this.current * 1.0 / this.total * 100.0);
|
||||
}
|
||||
|
||||
|
||||
incrementSkip() {
|
||||
this.skip++
|
||||
}
|
||||
}
|
||||
|
||||
export const taskExecutor = new BackTaskExecutor();
|
||||
@@ -2,26 +2,31 @@ import { http, logger, utils } from '@certd/basic';
|
||||
import { AccessService, BaseService } from '@certd/lib-server';
|
||||
import { doPageTurn, Pager, PageRes } from '@certd/pipeline';
|
||||
import { DomainVerifiers } from "@certd/plugin-cert";
|
||||
import { createDnsProvider, DomainParser, parseDomainByPsl } from "@certd/plugin-lib";
|
||||
import { createDnsProvider, dnsProviderRegistry, DomainParser, parseDomainByPsl } from "@certd/plugin-lib";
|
||||
import { Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { InjectEntityModel } from '@midwayjs/typeorm';
|
||||
import dayjs from 'dayjs';
|
||||
import { In, Not, Repository } from 'typeorm';
|
||||
import { BackTask, taskExecutor } from '../../basic/service/task-executor.js';
|
||||
import { CnameRecordEntity } from "../../cname/entity/cname-record.js";
|
||||
import { CnameRecordService } from '../../cname/service/cname-record-service.js';
|
||||
import { UserDomainImportSetting } from '../../mine/service/models.js';
|
||||
import { UserSettingsService } from '../../mine/service/user-settings-service.js';
|
||||
import { SubDomainsGetter } from '../../pipeline/service/getter/sub-domain-getter.js';
|
||||
import { TaskServiceBuilder } from '../../pipeline/service/getter/task-service-getter.js';
|
||||
import { SubDomainService } from "../../pipeline/service/sub-domain-service.js";
|
||||
import { DomainEntity } from '../entity/domain.js';
|
||||
import { BackTask, taskExecutor } from './task-executor.js';
|
||||
|
||||
export interface SyncFromProviderReq {
|
||||
userId: number;
|
||||
dnsProviderType: string;
|
||||
dnsProviderAccessId: string;
|
||||
dnsProviderAccessId: number;
|
||||
}
|
||||
|
||||
|
||||
const DOMAIN_IMPORT_TASK_TYPE = 'domainImportTask'
|
||||
const DOMAIN_EXPIRE_TASK_TYPE = 'domainExpirationSyncTask'
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -43,6 +48,9 @@ export class DomainService extends BaseService<DomainEntity> {
|
||||
@Inject()
|
||||
taskServiceBuilder: TaskServiceBuilder;
|
||||
|
||||
@Inject()
|
||||
userSettingService: UserSettingsService;
|
||||
|
||||
//@ts-ignore
|
||||
getRepository() {
|
||||
return this.repository;
|
||||
@@ -207,12 +215,26 @@ export class DomainService extends BaseService<DomainEntity> {
|
||||
}
|
||||
|
||||
|
||||
async doSyncFromProvider(req: SyncFromProviderReq) {
|
||||
taskExecutor.start('syncFromProviderTask', new BackTask({
|
||||
key: `user_${req.userId}`,
|
||||
title: `同步用户${req.userId}从域名提供商导入域名`,
|
||||
async startDomainImportTask(req: {userId:number,key:string}) {
|
||||
const key = req.key
|
||||
const setting = await this.userSettingService.getSetting<UserDomainImportSetting>(req.userId, UserDomainImportSetting)
|
||||
|
||||
const item = setting.domainImportList.find(item => item.key === key)
|
||||
if (!item) {
|
||||
throw new Error(`域名导入任务配置(${key})还未注册`)
|
||||
}
|
||||
const { dnsProviderType, dnsProviderAccessId,title } = item
|
||||
|
||||
taskExecutor.start(new BackTask({
|
||||
type: DOMAIN_IMPORT_TASK_TYPE,
|
||||
key,
|
||||
title: title,
|
||||
run: async (task: BackTask) => {
|
||||
await this._syncFromProvider(req, task)
|
||||
await this._syncFromProvider({
|
||||
userId: req.userId,
|
||||
dnsProviderType,
|
||||
dnsProviderAccessId,
|
||||
}, task)
|
||||
},
|
||||
}))
|
||||
}
|
||||
@@ -239,7 +261,10 @@ export class DomainService extends BaseService<DomainEntity> {
|
||||
|
||||
const itemHandle = async (domainRecord: any) => {
|
||||
task.incrementCurrent()
|
||||
const domain = domainRecord.domain
|
||||
let domain = domainRecord.domain
|
||||
if (domain.endsWith(".")) {
|
||||
domain = domain.slice(0, -1)
|
||||
}
|
||||
|
||||
const old = await this.findOne({
|
||||
where: {
|
||||
@@ -248,8 +273,13 @@ export class DomainService extends BaseService<DomainEntity> {
|
||||
}
|
||||
})
|
||||
if (old) {
|
||||
if (old.fromType !== 'auto') {
|
||||
//如果是手动的,跳过更新校验配置
|
||||
// if (old.fromType !== 'auto') {
|
||||
// //如果是手动的,跳过更新校验配置
|
||||
// return
|
||||
// }
|
||||
if (old) {
|
||||
//如果old存在,直接跳过
|
||||
task.incrementSkip()
|
||||
return
|
||||
}
|
||||
const updateObj: any = {
|
||||
@@ -269,26 +299,140 @@ export class DomainService extends BaseService<DomainEntity> {
|
||||
dnsProviderAccess: dnsProviderAccessId,
|
||||
challengeType,
|
||||
disabled: false,
|
||||
fromType: 'auto',
|
||||
fromType: 'manual',
|
||||
})
|
||||
logger.info(`导入域名${domain}到用户${userId}`)
|
||||
}
|
||||
}
|
||||
const batchHandle = async (pageRes: PageRes<any>) => {
|
||||
task.setTotal(pageRes.total || 0)
|
||||
task.setTotal(pageRes.total || 0)
|
||||
}
|
||||
const start = async () => {
|
||||
await doPageTurn({ pager, getPage, itemHandle, batchHandle })
|
||||
}
|
||||
|
||||
start()
|
||||
|
||||
await doPageTurn({ pager, getPage, itemHandle, batchHandle })
|
||||
const key = `user_${userId || 0}`
|
||||
logger.info(`从域名提供商${dnsProviderType}导入域名完成(${key}),共导入${task.total}个域名,跳过${task.getSkipCount()}个域名,成功${task.getSuccessCount()}个域名,失败${task.getErrorCount()}个域名`)
|
||||
}
|
||||
|
||||
async doSyncDomainsExpirationDate(req: { userId?: number }) {
|
||||
async getDomainImportTaskStatus(req:{userId?:number}) {
|
||||
const userId = req.userId || 0
|
||||
|
||||
const setting = await this.userSettingService.getSetting<UserDomainImportSetting>(userId, UserDomainImportSetting)
|
||||
const list= setting?.domainImportList || []
|
||||
|
||||
const taskList:any = []
|
||||
|
||||
for (const item of list) {
|
||||
const { key } = item
|
||||
|
||||
const task = taskExecutor.get(DOMAIN_IMPORT_TASK_TYPE,key)
|
||||
|
||||
taskList.push({
|
||||
...item,
|
||||
task:task,
|
||||
})
|
||||
}
|
||||
return taskList
|
||||
}
|
||||
|
||||
async getProviderTitle(req:{userId?:number,dnsProviderType:string,dnsProviderAccessId:number}) {
|
||||
const userId = req.userId || 0
|
||||
const { dnsProviderType, dnsProviderAccessId} = req
|
||||
const dnsProviderDefine = dnsProviderRegistry.getDefine(dnsProviderType)
|
||||
if (!dnsProviderDefine) {
|
||||
throw new Error(`该域名提供商(${dnsProviderType})不存在,请检查是否已被注册`)
|
||||
}
|
||||
const access = await this.accessService.getSimpleInfo(dnsProviderAccessId)
|
||||
if (!access || access.userId !== userId) {
|
||||
throw new Error(`该授权(${dnsProviderAccessId})不存在,请检查是否已被删除`)
|
||||
}
|
||||
return {
|
||||
title: `${dnsProviderDefine.title}_${access.name || ''}`,
|
||||
//@ts-ignore
|
||||
icon: dnsProviderDefine.icon || '',
|
||||
}
|
||||
}
|
||||
|
||||
async addDomainImportTask(req:{userId?:number,dnsProviderType:string,dnsProviderAccessId:number,index?:number}) {
|
||||
const userId = req.userId || 0
|
||||
const { dnsProviderType, dnsProviderAccessId,index=0 } = req
|
||||
const key = `user_${userId}_${dnsProviderType}_${dnsProviderAccessId}`
|
||||
|
||||
const {title,icon} = await this.getProviderTitle(req)
|
||||
|
||||
|
||||
const setting = await this.userSettingService.getSetting<UserDomainImportSetting>(userId, UserDomainImportSetting)
|
||||
setting.domainImportList = setting.domainImportList || []
|
||||
if (setting.domainImportList.find(item => item.key === key)) {
|
||||
throw new Error(`该域名导入任务${key}已存在`)
|
||||
}
|
||||
|
||||
const access = await this.accessService.getAccessById(dnsProviderAccessId, true, userId)
|
||||
if (!access) {
|
||||
throw new Error(`该授权(${dnsProviderAccessId})不存在,请检查是否已被删除`)
|
||||
}
|
||||
|
||||
const item = {
|
||||
dnsProviderType,
|
||||
dnsProviderAccessId,
|
||||
key,
|
||||
title,
|
||||
icon: icon || '',
|
||||
}
|
||||
setting.domainImportList.splice(index, 0, item)
|
||||
await this.userSettingService.saveSetting(userId, setting)
|
||||
|
||||
return item
|
||||
}
|
||||
|
||||
async deleteDomainImportTask(req:{userId?:number,key:string}) {
|
||||
const userId = req.userId || 0
|
||||
const { key } = req
|
||||
|
||||
const setting = await this.userSettingService.getSetting<UserDomainImportSetting>(userId, UserDomainImportSetting)
|
||||
setting.domainImportList = setting.domainImportList || []
|
||||
const index = setting.domainImportList.findIndex(item => item.key === key)
|
||||
if (index === -1) {
|
||||
throw new Error(`该域名导入任务${key}不存在`)
|
||||
}
|
||||
setting.domainImportList.splice(index, 1)
|
||||
taskExecutor.clear(DOMAIN_IMPORT_TASK_TYPE,key)
|
||||
await this.userSettingService.saveSetting(userId, setting)
|
||||
}
|
||||
|
||||
async saveDomainImportTask(req:{userId?:number,dnsProviderType:string,dnsProviderAccessId:number,key?:string}) {
|
||||
const userId = req.userId || 0
|
||||
const { dnsProviderType, dnsProviderAccessId,key } = req
|
||||
const setting = await this.userSettingService.getSetting<UserDomainImportSetting>(userId, UserDomainImportSetting)
|
||||
setting.domainImportList = setting.domainImportList || []
|
||||
|
||||
let index = 0
|
||||
if (key) {
|
||||
index = setting.domainImportList.findIndex(item => item.key === key)
|
||||
if (index === -1) {
|
||||
throw new Error(`该域名导入任务${key}不存在`)
|
||||
}
|
||||
await this.deleteDomainImportTask({userId,key})
|
||||
}
|
||||
|
||||
return await this.addDomainImportTask({userId,dnsProviderType,dnsProviderAccessId,index})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
async getSyncExpirationTaskStatus(req:{userId?:number}) {
|
||||
const userId = req.userId ?? 'all'
|
||||
const key = `user_${userId}`
|
||||
const task = taskExecutor.get(DOMAIN_EXPIRE_TASK_TYPE,key)
|
||||
return task
|
||||
}
|
||||
|
||||
async startSyncExpirationTask(req: { userId?: number }) {
|
||||
const userId = req.userId
|
||||
taskExecutor.start('syncDomainsExpirationDateTask', new BackTask({
|
||||
key: `user_${userId}`,
|
||||
title: `同步用户(${userId ?? '全部'})注册域名过期时间`,
|
||||
const key = `user_${userId ?? 'all'}`
|
||||
taskExecutor.start(new BackTask({
|
||||
type: DOMAIN_EXPIRE_TASK_TYPE,
|
||||
key,
|
||||
title: `同步注册域名过期时间(${key}))`,
|
||||
run: async (task: BackTask) => {
|
||||
await this._syncDomainsExpirationDate({ userId, task })
|
||||
}
|
||||
@@ -320,13 +464,14 @@ export class DomainService extends BaseService<DomainEntity> {
|
||||
const parsed = parseDomainByPsl(domain)
|
||||
const mainDomain = parsed.domain || ''
|
||||
if (mainDomain !== domain) {
|
||||
logger.warn(`${domain}为子域名,跳过同步`)
|
||||
req.task.addError(`【${domain}】为子域名,跳过同步`)
|
||||
return
|
||||
}
|
||||
const suffix = parsed.tld || ''
|
||||
const rdapUrl = rdapMap[suffix]
|
||||
if (!rdapUrl) {
|
||||
throw new Error(`未找到${suffix}的rdap地址`)
|
||||
req.task.addError(`【${domain}】未找到${suffix}的rdap地址`)
|
||||
return
|
||||
}
|
||||
// https://rdap.nic.work/domain/handsfree.work
|
||||
const rdap = await http.request({
|
||||
@@ -348,7 +493,7 @@ export class DomainService extends BaseService<DomainEntity> {
|
||||
const query: any = {
|
||||
challengeType: "dns",
|
||||
}
|
||||
if (req.userId!=null) {
|
||||
if (req.userId != null) {
|
||||
query.userId = req.userId
|
||||
}
|
||||
const getDomainPage = async (pager: Pager) => {
|
||||
@@ -378,10 +523,10 @@ export class DomainService extends BaseService<DomainEntity> {
|
||||
}
|
||||
const { expirationDate, registrationDate } = res
|
||||
if (!expirationDate) {
|
||||
logger.error(`获取域名${item.domain}过期时间失败`)
|
||||
req.task.addError(`【${item.domain}】获取域名${item.domain}过期时间失败`)
|
||||
return
|
||||
}
|
||||
logger.info(`更新域名${item.domain}过期时间:${dayjs(expirationDate).format('YYYY-MM-DD')}`)
|
||||
logger.info(`【${item.domain}】更新域名过期时间:${dayjs(expirationDate).format('YYYY-MM-DD')}`)
|
||||
const updateObj: any = {
|
||||
id: item.id,
|
||||
expirationDate: expirationDate,
|
||||
@@ -390,12 +535,17 @@ export class DomainService extends BaseService<DomainEntity> {
|
||||
//更新
|
||||
await super.update(updateObj)
|
||||
} catch (error) {
|
||||
logger.error(`更新域名${item.domain}过期时间失败:${error}`)
|
||||
const errorMsg = `【${item.domain}】${error.message ?? error}`
|
||||
req.task.addError(errorMsg)
|
||||
} finally {
|
||||
await utils.sleep(1000)
|
||||
}
|
||||
}
|
||||
|
||||
await doPageTurn({ pager, getPage: getDomainPage, itemHandle: itemHandle })
|
||||
const key = `user_${req.userId || 'all'}`
|
||||
logger.info(`同步用户(${key})注册域名过期时间完成(${req.task.getSuccessCount()}个成功,${req.task.getErrorCount()}个失败)` )
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
import { logger } from "@certd/basic"
|
||||
|
||||
export class BackTaskExecutor {
|
||||
tasks: Record<string, Record<string, BackTask>> = {}
|
||||
|
||||
start(type: string, task: BackTask) {
|
||||
if (!this.tasks[type]) {
|
||||
this.tasks[type] = {}
|
||||
}
|
||||
const oldTask = this.tasks[type][task.key]
|
||||
if (oldTask && oldTask.status === "running") {
|
||||
throw new Error(`任务 ${type}—${task.key} 正在运行中`)
|
||||
}
|
||||
this.tasks[type][task.key] = task
|
||||
this.run(type, task);
|
||||
}
|
||||
|
||||
get(type: string, key: string) {
|
||||
if (!this.tasks[type]) {
|
||||
this.tasks[type] = {}
|
||||
}
|
||||
return this.tasks[type][key]
|
||||
}
|
||||
|
||||
removeIsEnd(type: string, key: string) {
|
||||
const task = this.tasks[type]?.[key]
|
||||
if (task && task.status !== "running") {
|
||||
this.clear(type, key);
|
||||
}
|
||||
}
|
||||
|
||||
clear(type: string, key: string) {
|
||||
const task = this.tasks[type]?.[key]
|
||||
if (task) {
|
||||
task.clearTimeout();
|
||||
delete this.tasks[type][key]
|
||||
}
|
||||
}
|
||||
|
||||
private async run(type: string, task: any) {
|
||||
if (task.status === "running") {
|
||||
throw new Error(`任务 ${type}—${task.key} 正在运行中`)
|
||||
}
|
||||
task.startTime = Date.now();
|
||||
task.clearTimeout();
|
||||
try {
|
||||
task.status = "running";
|
||||
return await task.run(task);
|
||||
} catch (e) {
|
||||
logger.error(`任务 ${task.title}[${type}-${task.key}] 执行失败`, e.message);
|
||||
task.status = "failed";
|
||||
task.error = e.message;
|
||||
} finally {
|
||||
task.endTime = Date.now();
|
||||
task.status = "done";
|
||||
task.timeoutId = setTimeout(() => {
|
||||
this.clear(type, task.key);
|
||||
}, 24 * 60 * 60 * 1000);
|
||||
delete task.run;
|
||||
}
|
||||
}
|
||||
}
|
||||
export class BackTask {
|
||||
key: string;
|
||||
title: string;
|
||||
total: number = 0;
|
||||
current: number = 0;
|
||||
startTime: number;
|
||||
endTime: number;
|
||||
status: string = "pending";
|
||||
error?: string;
|
||||
timeoutId?: NodeJS.Timeout;
|
||||
|
||||
|
||||
run: (task: BackTask) => Promise<void>;
|
||||
|
||||
constructor(opts:{
|
||||
key: string, title: string, run: (task: BackTask) => Promise<void>
|
||||
}) {
|
||||
const {key, title, run} = opts
|
||||
this.key = key;
|
||||
this.title = title;
|
||||
Object.defineProperty(this, 'run', {
|
||||
value: run,
|
||||
writable: true,
|
||||
enumerable: false, // 设置为false使其不可遍历
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
|
||||
clearTimeout() {
|
||||
if (this.timeoutId) {
|
||||
clearTimeout(this.timeoutId);
|
||||
this.timeoutId = null;
|
||||
}
|
||||
}
|
||||
|
||||
setTotal(total: number) {
|
||||
this.total = total;
|
||||
}
|
||||
incrementCurrent() {
|
||||
this.current++
|
||||
}
|
||||
}
|
||||
|
||||
export const taskExecutor = new BackTaskExecutor();
|
||||
@@ -22,7 +22,7 @@ import punycode from "punycode.js";
|
||||
import { SubDomainService } from "../../pipeline/service/sub-domain-service.js";
|
||||
import { SubDomainsGetter } from "../../pipeline/service/getter/sub-domain-getter.js";
|
||||
import { TaskServiceBuilder } from "../../pipeline/service/getter/task-service-getter.js";
|
||||
import { BackTask, taskExecutor } from "../../cert/service/task-executor.js";
|
||||
import { BackTask, taskExecutor } from "../../basic/service/task-executor.js";
|
||||
|
||||
type CnameCheckCacheValue = {
|
||||
validating: boolean;
|
||||
@@ -499,7 +499,8 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
|
||||
throw new ValidateException("CNAME服务提供商不能为空");
|
||||
}
|
||||
|
||||
taskExecutor.start("cnameImport",new BackTask({
|
||||
taskExecutor.start(new BackTask({
|
||||
type:"cnameImport",
|
||||
key: "user_"+userId,
|
||||
title: "导入CNAME记录",
|
||||
run: async (task) => {
|
||||
|
||||
@@ -46,3 +46,11 @@ export class UserGrantSetting extends BaseSettings {
|
||||
|
||||
allowAdminViewCerts:boolean = false;
|
||||
}
|
||||
|
||||
|
||||
export class UserDomainImportSetting extends BaseSettings {
|
||||
static __title__ = "用户域名导入设置";
|
||||
static __key__ = "user.domain.import";
|
||||
|
||||
domainImportList:{dnsProviderType:string,dnsProviderAccessId:number,key:string,title:string,icon?:string}[];
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Provide, Scope, ScopeEnum } from "@midwayjs/core";
|
||||
import { BaseService, CodeException, Constants, PageReq } from "@certd/lib-server";
|
||||
import { InjectEntityModel } from "@midwayjs/typeorm";
|
||||
import { Repository } from "typeorm";
|
||||
import { Between, IsNull, LessThan, Not, Repository } from "typeorm";
|
||||
import { CertInfoEntity } from "../entity/cert-info.js";
|
||||
import { utils } from "@certd/basic";
|
||||
import { CertInfo, CertReader } from "@certd/plugin-cert";
|
||||
@@ -181,6 +181,36 @@ export class CertInfoService extends BaseService<CertInfoEntity> {
|
||||
pipelineId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async count({ userId }: { userId: number }) {
|
||||
const total = await this.repository.count({
|
||||
where: {
|
||||
userId,
|
||||
expiresTime: Not(IsNull()),
|
||||
},
|
||||
});
|
||||
|
||||
const expired = await this.repository.count({
|
||||
where: {
|
||||
userId,
|
||||
expiresTime: LessThan(new Date().getTime()),
|
||||
},
|
||||
});
|
||||
|
||||
const expiring = await this.repository.count({
|
||||
where: {
|
||||
userId,
|
||||
expiresTime: Between(new Date().getTime(), new Date().getTime() + 15 * 24 * 60 * 60 * 1000),
|
||||
},
|
||||
});
|
||||
|
||||
const notExpired = total - expired - expiring;
|
||||
return {
|
||||
total,
|
||||
expired,
|
||||
expiring,
|
||||
notExpired,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,15 +179,13 @@ export class NotificationService extends BaseService<NotificationEntity> {
|
||||
if (req.id && req.id > 0) {
|
||||
notifyConfig = await this.getById(req.id, userId);
|
||||
if (!notifyConfig) {
|
||||
logger.warn(`未找到通知配置<${req.id}>`);
|
||||
logger.warn(`未找到通知配置<${req.id}>,请确认是否已被删除`);
|
||||
}
|
||||
}
|
||||
if (!notifyConfig) {
|
||||
if (req.id === 0 || req.useDefault) {
|
||||
notifyConfig = await this.getDefault(userId);
|
||||
if (!notifyConfig) {
|
||||
logger.warn(`未找到默认通知配置`);
|
||||
}
|
||||
notifyConfig = await this.getDefault(userId);
|
||||
if (!notifyConfig) {
|
||||
logger.warn(`未找到默认通知配置`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -771,6 +771,26 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
return statusCount;
|
||||
}
|
||||
|
||||
async enableCount(param: { userId?: any } = {}) {
|
||||
const statusCount = await this.repository
|
||||
.createQueryBuilder()
|
||||
.select("disabled")
|
||||
.addSelect("count(1)", "count")
|
||||
.where({
|
||||
userId: param.userId
|
||||
})
|
||||
.groupBy("disabled")
|
||||
.getRawMany();
|
||||
const result = {
|
||||
enabled: 0,
|
||||
disabled: 0,
|
||||
};
|
||||
for (const item of statusCount) {
|
||||
result[item.disabled ? "disabled" : "enabled"] = parseInt(item.count);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
async latestExpiringList({ userId }: any) {
|
||||
let list = await this.repository.find({
|
||||
select: {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import {createAxiosService, HttpClient, ILogger} from "@certd/basic";
|
||||
import {Dns51Access} from "./access.js";
|
||||
|
||||
import { createAxiosService, HttpClient, ILogger } from "@certd/basic";
|
||||
import { PageRes, PageSearch } from "@certd/pipeline";
|
||||
import { DomainRecord } from "@certd/plugin-lib/dist/cert/dns-provider/api.js";
|
||||
import qs from "qs";
|
||||
import { Dns51Access } from "./access.js";
|
||||
export class Dns51Client {
|
||||
logger: ILogger;
|
||||
access: Dns51Access;
|
||||
@@ -234,4 +236,64 @@ _token: ieOfM21eDd9nWJv3OZtMJF6ogDsnPKQHJ17dlMck
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
if (req.pageNo >=2) { //不知道翻页查询的参数是什么
|
||||
return {
|
||||
total: 0,
|
||||
list: []
|
||||
}
|
||||
}
|
||||
await this.login();
|
||||
const query = {
|
||||
//domain=&id=&status=&perPage=500
|
||||
perPage: 1000,
|
||||
}
|
||||
const res = await this.http.request({
|
||||
url: 'https://www.51dns.com/domain?' + qs.stringify(query),
|
||||
method: 'get',
|
||||
withCredentials: true,
|
||||
logRes: false,
|
||||
returnOriginRes: true,
|
||||
headers: this.getRequestHeaders()
|
||||
});
|
||||
//提取记录
|
||||
const content = res.data || ""
|
||||
const startIndex = content.indexOf(`<table cellpadding="0" cellspacing="0" class="domiantable">`)
|
||||
if (startIndex < 0) {
|
||||
throw new Error("解析域名列表失败,未找到域名列表")
|
||||
}
|
||||
const endIndex = content.indexOf(`</table>`, startIndex)
|
||||
const tableContent = content.substring(startIndex, endIndex + 8)
|
||||
// <tr class="">
|
||||
// <a target="_blank" href="https://www.51dns.com/domain/record/199820259"
|
||||
// class="color47">docmirror.cn</a>
|
||||
|
||||
const list: DomainRecord[] = []
|
||||
const trArr = tableContent.split(`<tr class="">`)
|
||||
for (const tr of trArr) {
|
||||
const lines = tr.trim().split("\n")
|
||||
const row:any = {}
|
||||
for (const line of lines) {
|
||||
if (line.includes(`<a target="_blank" href="https://www.51dns.com/domain/record/`)) {
|
||||
// 提取id
|
||||
const domainId = line.match(/record\/(\d+)"/i)[1];
|
||||
row.id = parseInt(domainId);
|
||||
}
|
||||
if (line.includes(`class="color47"`)) {
|
||||
// 提取域名
|
||||
const domain = line.match(/class="color47">(.*?)<\/a>/i)[1];
|
||||
row.domain = domain;
|
||||
}
|
||||
}
|
||||
if (row.domain) {
|
||||
list.push(row)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
total: list.length,
|
||||
list
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
||||
import { AbstractDnsProvider, CreateRecordOptions, DomainRecord, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
||||
|
||||
import { PageRes, PageSearch } from "@certd/pipeline";
|
||||
import { Dns51Access } from "./access.js";
|
||||
import { Dns51Client } from "./client.js";
|
||||
|
||||
@@ -92,6 +93,10 @@ export class Dns51DnsProvider extends AbstractDnsProvider<Dns51Record> {
|
||||
})
|
||||
this.logger.info(`删除域名解析成功:fullRecord=${fullRecord},id=${id}`);
|
||||
}
|
||||
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
return await this.client.getDomainListPage(req)
|
||||
}
|
||||
}
|
||||
|
||||
//实例化这个provider,将其自动注册到系统中
|
||||
|
||||
+36
-2
@@ -1,5 +1,5 @@
|
||||
import { IAccessService } from '@certd/pipeline';
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
import { IAccessService, Pager, PageRes, PageSearch } from '@certd/pipeline';
|
||||
import { AbstractDnsProvider, CreateRecordOptions, DomainRecord, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
import { AliesaAccess, AliyunAccess } from '../../plugin-lib/aliyun/index.js';
|
||||
import { AliyunClientV2 } from '../../plugin-lib/aliyun/lib/aliyun-client-v2.js';
|
||||
|
||||
@@ -101,6 +101,40 @@ export class AliesaDnsProvider extends AbstractDnsProvider {
|
||||
})
|
||||
this.logger.info('删除域名解析成功:', record.RecordId);
|
||||
}
|
||||
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
const pager = new Pager(req)
|
||||
const ret = await this.client.doRequest({
|
||||
// 接口名称
|
||||
action: "ListSites",
|
||||
// 接口版本
|
||||
version: "2024-09-10",
|
||||
// 接口协议
|
||||
protocol: "HTTPS",
|
||||
// 接口 HTTP 方法
|
||||
method: "GET",
|
||||
authType: "AK",
|
||||
style: "RPC",
|
||||
data: {
|
||||
query: {
|
||||
SiteName: req.searchKey,
|
||||
// ["SiteSearchType"] = "exact";
|
||||
SiteSearchType: "fuzzy",
|
||||
AccessType: "NS",
|
||||
PageSize: pager.pageSize,
|
||||
PageNumber: pager.pageNo,
|
||||
}
|
||||
}
|
||||
})
|
||||
const list = ret.Sites?.map(item => ({
|
||||
domain: item.SiteName,
|
||||
id: item.SiteId,
|
||||
}))
|
||||
return {
|
||||
list: list || [],
|
||||
total: ret.TotalCount,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new AliesaDnsProvider();
|
||||
|
||||
+3
-2
@@ -1,7 +1,7 @@
|
||||
import { AbstractDnsProvider, CreateRecordOptions, DomainRecord, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
import { AliyunAccess } from '../../plugin-lib/aliyun/access/aliyun-access.js';
|
||||
import { AliyunClient } from '../../plugin-lib/aliyun/index.js';
|
||||
import { Pager, PageRes } from '@certd/pipeline';
|
||||
import { Pager, PageRes, PageSearch } from '@certd/pipeline';
|
||||
|
||||
|
||||
@IsDnsProvider({
|
||||
@@ -155,7 +155,8 @@ export class AliyunDnsProvider extends AbstractDnsProvider {
|
||||
}
|
||||
}
|
||||
|
||||
async getDomainListPage(pager: Pager) :Promise<PageRes<DomainRecord>> {
|
||||
async getDomainListPage(req: PageSearch) :Promise<PageRes<DomainRecord>> {
|
||||
const pager = new Pager(req);
|
||||
const params = {
|
||||
RegionId: 'cn-hangzhou',
|
||||
PageSize: pager.pageSize,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
import { AbstractDnsProvider, CreateRecordOptions, DomainRecord, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
import { AwsClient } from './libs/aws-client.js';
|
||||
import { AwsAccess } from './access.js';
|
||||
import { PageRes, PageSearch } from '@certd/pipeline';
|
||||
|
||||
|
||||
@IsDnsProvider({
|
||||
@@ -57,6 +58,10 @@ export class AwsRoute53Provider extends AbstractDnsProvider {
|
||||
this.logger.warn(`删除域名解析失败:${e.message} : ${hostedZoneId} ${fullRecord} ${value} ${type} `, );
|
||||
}
|
||||
}
|
||||
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
return await this.client.route53ListHostedZonesPage(req);
|
||||
}
|
||||
}
|
||||
|
||||
new AwsRoute53Provider();
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
// 导入所需的 SDK 模块
|
||||
import { AwsAccess } from '../access.js';
|
||||
import { CertInfo } from '@certd/plugin-cert';
|
||||
import { CertInfo, DomainRecord } from '@certd/plugin-cert';
|
||||
import { ILogger, utils } from '@certd/basic';
|
||||
import { PageRes, PageSearch } from '@certd/pipeline';
|
||||
type AwsClientOptions = { access: AwsAccess; region: string, logger: ILogger };
|
||||
|
||||
/**
|
||||
* https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/route-53-domains/
|
||||
*/
|
||||
export class AwsClient {
|
||||
options: AwsClientOptions;
|
||||
access: AwsAccess;
|
||||
@@ -77,6 +81,29 @@ export class AwsClient {
|
||||
return response.HostedZones;
|
||||
}
|
||||
|
||||
async route53ListHostedZonesPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
const { ListHostedZonesByNameCommand } = await import("@aws-sdk/client-route-53"); // ES Modules import
|
||||
|
||||
const client = await this.route53ClientGet();
|
||||
const input:any = { // ListHostedZonesByNameRequest
|
||||
MaxItems: req.pageSize,
|
||||
};
|
||||
if (req.searchKey) {
|
||||
input.DNSName = req.searchKey;
|
||||
}
|
||||
const command = new ListHostedZonesByNameCommand(input);
|
||||
const response = await this.doRequest(() => client.send(command));
|
||||
let list :any[]= response.HostedZones || [];
|
||||
list = list.map((item: any) => ({
|
||||
id: item.Id.replace('/hostedzone/', ''),
|
||||
domain: item.Name,
|
||||
}));
|
||||
return {
|
||||
total: list.length,
|
||||
list,
|
||||
};
|
||||
}
|
||||
|
||||
async route53ChangeRecord(req: {
|
||||
hostedZoneId: string, fullRecord: string, type: string, value: string, action: "UPSERT" | "DELETE"
|
||||
}) {
|
||||
|
||||
@@ -9,12 +9,14 @@ export abstract class CertApplyBaseConvertPlugin extends AbstractTaskPlugin {
|
||||
@TaskInput({
|
||||
title: "证书域名",
|
||||
component: {
|
||||
name: "a-select",
|
||||
name: "domain-selector",
|
||||
vModel: "value",
|
||||
mode: "tags",
|
||||
open: false,
|
||||
placeholder: "foo.com / *.foo.com / *.bar.com",
|
||||
// open: false,
|
||||
placeholder: "请输入证书域名,比如:foo.com / *.foo.com / *.sub.foo.com / *.bar.com",
|
||||
tokenSeparators: [",", " ", ",", "、", "|"],
|
||||
search: true,
|
||||
pager:true,
|
||||
},
|
||||
rules: [{ type: "domains" }],
|
||||
required: true,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
import { AbstractDnsProvider, CreateRecordOptions, DomainRecord, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
|
||||
import { CloudflareAccess } from './access.js';
|
||||
import { Pager, PageRes, PageSearch } from '@certd/pipeline';
|
||||
|
||||
export type CloudflareRecord = {
|
||||
id: string;
|
||||
@@ -144,6 +145,27 @@ export class CloudflareDnsProvider extends AbstractDnsProvider<CloudflareRecord>
|
||||
await this.doRequestApi(url, null, 'delete');
|
||||
this.logger.info(`删除域名解析成功:fullRecord=${fullRecord},value=${value}`);
|
||||
}
|
||||
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
const pager = new Pager(req);
|
||||
|
||||
let url = `https://api.cloudflare.com/client/v4/zones?page=${pager.pageNo}&per_page=${pager.pageSize}`;
|
||||
if (req.searchKey) {
|
||||
url += `&name=${req.searchKey}`;
|
||||
}
|
||||
const ret = await this.doRequestApi(url, null, 'get');
|
||||
|
||||
let list = ret.result || []
|
||||
list = list.map((item: any) => ({
|
||||
id: item.id,
|
||||
domain: item.name,
|
||||
}));
|
||||
const total = ret.result_info.total_count || list.length;
|
||||
return {
|
||||
total,
|
||||
list,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//实例化这个provider,将其自动注册到系统中
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AccessInput, BaseAccess, IsAccess } from '@certd/pipeline';
|
||||
import { isDev } from '../../utils/env.js';
|
||||
import { AccessInput, BaseAccess, IsAccess, Pager, PageRes, PageSearch } from '@certd/pipeline';
|
||||
import { DomainRecord } from '@certd/plugin-lib';
|
||||
|
||||
/**
|
||||
* 这个注解将注册一个授权配置
|
||||
@@ -8,42 +8,125 @@ import { isDev } from '../../utils/env.js';
|
||||
@IsAccess({
|
||||
name: 'demo',
|
||||
title: '授权插件示例',
|
||||
icon: 'clarity:plugin-line',
|
||||
desc: '',
|
||||
icon: 'clarity:plugin-line', //插件图标
|
||||
desc: '这是一个示例授权插件,用于演示如何实现一个授权插件',
|
||||
})
|
||||
export class DemoAccess extends BaseAccess {
|
||||
|
||||
/**
|
||||
* 授权属性配置
|
||||
*/
|
||||
@AccessInput({
|
||||
title: '授权方式',
|
||||
value: 'apiKey', //默认值
|
||||
component: {
|
||||
name: "a-select", //基于antdv的输入组件
|
||||
vModel: "value", // v-model绑定的属性名
|
||||
options: [ //组件参数
|
||||
{ label: "API密钥(推荐)", value: "apiKey" },
|
||||
{ label: "账号密码", value: "account" },
|
||||
],
|
||||
placeholder: 'demoKeyId',
|
||||
},
|
||||
required: true,
|
||||
})
|
||||
apiType = '';
|
||||
|
||||
/**
|
||||
* 授权属性配置
|
||||
*/
|
||||
@AccessInput({
|
||||
title: '密钥Id',
|
||||
component: {
|
||||
name:"a-input",
|
||||
allowClear: true,
|
||||
placeholder: 'demoKeyId',
|
||||
},
|
||||
required: true,
|
||||
})
|
||||
demoKeyId = '';
|
||||
|
||||
/**
|
||||
* 授权属性配置
|
||||
*/
|
||||
@AccessInput({
|
||||
//标题
|
||||
title: '密钥串',
|
||||
component: {
|
||||
//input组件的placeholder
|
||||
placeholder: 'demoKeySecret',
|
||||
},
|
||||
//是否必填
|
||||
required: true,
|
||||
//改属性是否需要加密
|
||||
encrypt: true,
|
||||
title: '密钥',//标题
|
||||
required: true, //text组件可以省略
|
||||
encrypt: true, //该属性是否需要加密
|
||||
})
|
||||
//属性名称
|
||||
demoKeySecret = '';
|
||||
}
|
||||
|
||||
if (isDev()) {
|
||||
//你的实现 要去掉这个if,不然生产环境将不会显示
|
||||
new DemoAccess();
|
||||
|
||||
@AccessInput({
|
||||
title: "测试",
|
||||
component: {
|
||||
name: "api-test",
|
||||
action: "TestRequest"
|
||||
},
|
||||
helper: "点击测试接口是否正常"
|
||||
})
|
||||
testRequest = true;
|
||||
|
||||
/**
|
||||
* 会通过上面的testRequest参数在ui界面上生成测试按钮,供用户测试接口调用是否正常
|
||||
*/
|
||||
async onTestRequest() {
|
||||
await this.GetDomainList({});
|
||||
return "ok"
|
||||
}
|
||||
|
||||
/**
|
||||
* 获api接口示例 取域名列表,
|
||||
*/
|
||||
async GetDomainList(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
//输出日志必须使用ctx.logger
|
||||
this.ctx.logger.info(`获取域名列表,req:${JSON.stringify(req)}`);
|
||||
const pager = new Pager(req);
|
||||
const resp = await this.doRequest({
|
||||
action: "ListDomains",
|
||||
data: {
|
||||
domain: req.searchKey,
|
||||
offset: pager.getOffset(),
|
||||
limit: pager.pageSize,
|
||||
}
|
||||
});
|
||||
const total = resp?.TotalCount || 0;
|
||||
let list = resp?.DomainList?.map((item) => {
|
||||
item.domain = item.Domain;
|
||||
item.id = item.DomainId;
|
||||
return item;
|
||||
})
|
||||
return {
|
||||
total,
|
||||
list
|
||||
};
|
||||
}
|
||||
|
||||
// 还可以继续编写API
|
||||
|
||||
/**
|
||||
* 通用api调用方法, 具体如何构造请求体,需参考对应应用的API文档
|
||||
*/
|
||||
async doRequest(req: { action: string, data?: any }) {
|
||||
/**
|
||||
this.ctx中包含很多有用的工具类
|
||||
type AccessContext = {
|
||||
http: HttpClient;
|
||||
logger: ILogger;
|
||||
utils: typeof utils;
|
||||
accessService: IAccessService;
|
||||
}
|
||||
*/
|
||||
const res = await this.ctx.http.request({
|
||||
url: "https://api.demo.cn/api/",
|
||||
method: "POST",
|
||||
data: {
|
||||
Action: req.action,
|
||||
Body: req.data
|
||||
}
|
||||
});
|
||||
|
||||
if (res.Code !== 0) {
|
||||
//异常处理
|
||||
throw new Error(res.Message || "请求失败");
|
||||
}
|
||||
return res.Resp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, PageSearch, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||
import { CertInfo, CertReader } from '@certd/plugin-cert';
|
||||
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from '@certd/plugin-lib';
|
||||
import { optionsUtils } from '@certd/basic';
|
||||
@@ -171,7 +171,7 @@ export class DemoTest extends AbstractTaskPlugin {
|
||||
}
|
||||
|
||||
//此方法演示,如何让前端在添加插件时可以从后端获取选项,这里是后端返回选项的方法
|
||||
async onGetSiteList() {
|
||||
async onGetSiteList(req: PageSearch) {
|
||||
if (!this.accessId) {
|
||||
throw new Error('请选择Access授权');
|
||||
}
|
||||
@@ -179,13 +179,7 @@ export class DemoTest extends AbstractTaskPlugin {
|
||||
// @ts-ignore
|
||||
const access = await this.getAccess(this.accessId);
|
||||
|
||||
// const siteRes = await this.ctx.http.request({
|
||||
// url: '你的服务端获取选项的请求地址',
|
||||
// method: 'GET',
|
||||
// data: {
|
||||
// token:access.xxxx
|
||||
// }, //请求参数
|
||||
// });
|
||||
// const siteRes = await access.GetDomainList(req);
|
||||
//以下是模拟数据
|
||||
const siteRes = [
|
||||
{ id: 1, siteName: 'site1.com' },
|
||||
@@ -204,5 +198,3 @@ export class DemoTest extends AbstractTaskPlugin {
|
||||
return optionsUtils.buildGroupOptions(options, this.certDomains);
|
||||
}
|
||||
}
|
||||
//实例化一下,注册插件
|
||||
new DemoTest();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
||||
import { AbstractDnsProvider, CreateRecordOptions, DomainRecord, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
||||
|
||||
import { DnslaAccess } from "./access.js";
|
||||
import { Pager, PageRes, PageSearch } from "@certd/pipeline";
|
||||
|
||||
export type DnslaRecord = {
|
||||
id: string;
|
||||
@@ -176,6 +177,24 @@ export class DnslaDnsProvider extends AbstractDnsProvider<DnslaRecord> {
|
||||
await this.doRequestApi(url, null, 'delete');
|
||||
this.logger.info(`删除域名解析成功:fullRecord=${fullRecord},value=${value}`);
|
||||
}
|
||||
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
const pager = new Pager(req);
|
||||
const url = `/api/domain?pageIndex=${pager.pageNo}&pageSize=${pager.pageSize}`;
|
||||
const ret = await this.doRequestApi(url, null, 'get');
|
||||
|
||||
|
||||
let list = ret.data.results || []
|
||||
list = list.map((item: any) => ({
|
||||
id: item.id,
|
||||
domain: item.domain,
|
||||
}));
|
||||
const total = ret.data.total || list.length;
|
||||
return {
|
||||
total,
|
||||
list,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//实例化这个provider,将其自动注册到系统中
|
||||
|
||||
@@ -68,7 +68,7 @@ export class GodaddyAccess extends BaseAccess {
|
||||
|
||||
const pager = new Pager(opts);
|
||||
const req = {
|
||||
url :`/v1/domains?limit=${pager.pageSize}`,
|
||||
url :`/v1/domains?limit=${pager.pageSize}&offset=${pager.getOffset()}`,
|
||||
method: "get",
|
||||
}
|
||||
return await this.doRequest(req);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
||||
import { AbstractDnsProvider, CreateRecordOptions, DomainRecord, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
||||
|
||||
import { GodaddyAccess } from "./access.js";
|
||||
import { Pager, PageRes, PageSearch } from "@certd/pipeline";
|
||||
|
||||
export type GodaddyRecord = {
|
||||
domain: string,
|
||||
@@ -84,6 +85,23 @@ export class GodaddyDnsProvider extends AbstractDnsProvider<GodaddyRecord> {
|
||||
})
|
||||
this.logger.info(`删除域名解析成功:fullRecord=${fullRecord},id=${res}`);
|
||||
}
|
||||
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
const pager = new Pager(req);
|
||||
|
||||
const ret = await this.access.getDomainList(req)
|
||||
|
||||
let list = ret.zones || []
|
||||
list = list.map((item: any) => ({
|
||||
id: item.domainId,
|
||||
domain: item.domain,
|
||||
}));
|
||||
const total = list.length === pager.pageSize ? list.length+1: list.length
|
||||
return {
|
||||
total,
|
||||
list,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//实例化这个provider,将其自动注册到系统中
|
||||
|
||||
+23
-1
@@ -1,8 +1,9 @@
|
||||
import * as _ from "lodash-es";
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
||||
import { AbstractDnsProvider, CreateRecordOptions, DomainRecord, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
||||
|
||||
import { HuaweiAccess } from "../access/index.js";
|
||||
import { ApiRequestOptions, HuaweiYunClient } from "@certd/lib-huawei";
|
||||
import { Pager, PageRes, PageSearch } from "@certd/pipeline";
|
||||
|
||||
export type SearchRecordOptions = {
|
||||
zoneId: string;
|
||||
@@ -177,6 +178,27 @@ export class HuaweiDnsProvider extends AbstractDnsProvider {
|
||||
this.logger.info("删除域名解析失败,没有找到解析记录", fullRecord, value);
|
||||
}
|
||||
}
|
||||
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
const pager = new Pager(req);
|
||||
let url = `${this.dnsEndpoint}/v2/zones?offset=${pager.getOffset()}&limit=${pager.pageSize}`;
|
||||
if (req.searchKey){
|
||||
url += `&name=${req.searchKey}`
|
||||
}
|
||||
const ret = await this.client.request({
|
||||
url,
|
||||
method: "GET"
|
||||
});
|
||||
let list = ret.zones || []
|
||||
list = list.map((item: any) => ({
|
||||
id: item.id,
|
||||
domain: item.name.endsWith(".") ? item.name.slice(0, -1) : item.name,
|
||||
}));
|
||||
return {
|
||||
total:ret.metadata.total_count || list.length,
|
||||
list,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
new HuaweiDnsProvider();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
||||
import { AbstractDnsProvider, CreateRecordOptions, DomainRecord, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
||||
import { JDCloudAccess } from "./access.js";
|
||||
import { Pager, PageRes, PageSearch } from "@certd/pipeline";
|
||||
|
||||
@IsDnsProvider({
|
||||
name: "jdcloud",
|
||||
@@ -92,6 +93,25 @@ export class JDCloudDnsProvider extends AbstractDnsProvider {
|
||||
return service;
|
||||
}
|
||||
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
const pager = new Pager(req);
|
||||
const service = await this.getJDDomainService();
|
||||
const domainRes = await service.describeDomains({
|
||||
domainName: req.searchKey,
|
||||
pageNumber: pager.pageNo,
|
||||
pageSize: pager.pageSize,
|
||||
})
|
||||
let list = domainRes.result?.dataList || []
|
||||
list = list.map((item: any) => ({
|
||||
id: item.domainId,
|
||||
domain: item.domainName,
|
||||
}));
|
||||
return {
|
||||
total:domainRes.result.totalCount || list.length,
|
||||
list,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new JDCloudDnsProvider();
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
import { AbstractDnsProvider, CreateRecordOptions, DomainRecord, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
import qs from 'qs';
|
||||
import { NamesiloAccess } from './access.js';
|
||||
import { merge } from 'lodash-es';
|
||||
import { Pager, PageRes, PageSearch } from '@certd/pipeline';
|
||||
|
||||
export type NamesiloRecord = {
|
||||
record_id: string;
|
||||
@@ -102,6 +103,25 @@ export class NamesiloDnsProvider extends AbstractDnsProvider<NamesiloRecord> {
|
||||
});
|
||||
this.logger.info(`删除域名解析成功:fullRecord=${fullRecord},value=${value}`);
|
||||
}
|
||||
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
|
||||
const pager = new Pager(req);
|
||||
const ret =await this.doRequest('/api/listDomains', {
|
||||
key:req.searchKey,
|
||||
page: pager.pageNo,
|
||||
pageSize: pager.pageSize,
|
||||
});
|
||||
// this.logger.info("获取域名列表成功:", ret);
|
||||
const list = ret.domains.map((item: any) => ({
|
||||
id: item.domain,
|
||||
domain: item.domain,
|
||||
}));
|
||||
return {
|
||||
total:ret.pager?.total || list.length,
|
||||
list,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//实例化这个provider,将其自动注册到系统中
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
||||
import { AbstractDnsProvider, CreateRecordOptions, DomainRecord, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
||||
import { RainyunAccess } from "./access.js";
|
||||
import { Pager, PageRes, PageSearch } from "@certd/pipeline";
|
||||
|
||||
@IsDnsProvider({
|
||||
name: "rainyun",
|
||||
@@ -60,6 +61,25 @@ export class RainyunDnsProvider extends AbstractDnsProvider {
|
||||
this.logger.info("删除域名解析成功:", fullRecord, value, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
const access: RainyunAccess = this.ctx.access as RainyunAccess;
|
||||
const pager = new Pager(req);
|
||||
const ret = await access.getDomainList({
|
||||
offset: pager.getOffset(),
|
||||
limit: pager.pageSize,
|
||||
query: req.searchKey,
|
||||
})
|
||||
// this.logger.info("获取域名列表成功:", ret);
|
||||
const list = ret.list.map((item: any) => ({
|
||||
id: item.id,
|
||||
domain: item.domain,
|
||||
}));
|
||||
return {
|
||||
total:ret.total || list.length,
|
||||
list,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
new RainyunDnsProvider();
|
||||
|
||||
+23
-1
@@ -1,5 +1,6 @@
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
import { AbstractDnsProvider, CreateRecordOptions, DomainRecord, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
import { TencentAccess } from '../../plugin-lib/tencent/index.js';
|
||||
import { Pager, PageRes, PageSearch } from '@certd/pipeline';
|
||||
|
||||
@IsDnsProvider({
|
||||
name: 'tencent',
|
||||
@@ -93,5 +94,26 @@ export class TencentDnsProvider extends AbstractDnsProvider {
|
||||
this.logger.info('删除域名解析成功:', fullRecord, value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
|
||||
const pager = new Pager(req);
|
||||
|
||||
const params:any = {
|
||||
Offset: pager.getOffset(),
|
||||
Limit: pager.pageSize,
|
||||
};
|
||||
if (req.searchKey) {
|
||||
params.Keyword = req.searchKey;
|
||||
}
|
||||
const ret = await this.client.DescribeDomainList(params);
|
||||
let list = ret.DomainList || [];
|
||||
list = list.map((item) => ({
|
||||
id: item.DomainId,
|
||||
domain: item.Name,
|
||||
}));
|
||||
const total = ret.DomainCountInfo?.AllTotal || list.length
|
||||
return {total,list,};
|
||||
}
|
||||
}
|
||||
new TencentDnsProvider();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './plugin-deploy-to-cdn.js';
|
||||
export * from './plugin-upload-to-ussl.js';
|
||||
export * from './plugin-deploy-to-waf.js';
|
||||
export * from './plugin-deploy-to-alb.js';
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, PageSearch, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
|
||||
import { CertApplyPluginNames, CertInfo } from "@certd/plugin-cert";
|
||||
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from "@certd/plugin-lib";
|
||||
import { UCloudAccess } from "../access.js";
|
||||
|
||||
@IsTaskPlugin({
|
||||
name: "UCloudDeployToALB",
|
||||
title: "UCloud-部署到ALB",
|
||||
desc: "将证书部署到UCloud ALB(应用负载均衡)",
|
||||
icon: "svg:icon-ucloud",
|
||||
group: pluginGroups.ucloud.key,
|
||||
needPlus: false,
|
||||
default: {
|
||||
strategy: {
|
||||
runStrategy: RunStrategy.SkipWhenSucceed
|
||||
}
|
||||
}
|
||||
})
|
||||
export class UCloudDeployToALB extends AbstractTaskPlugin {
|
||||
@TaskInput({
|
||||
title: "域名证书",
|
||||
helper: "请选择前置任务输出的域名证书",
|
||||
component: {
|
||||
name: "output-selector",
|
||||
from: [...CertApplyPluginNames, ":UCloudCertId:"]
|
||||
}
|
||||
})
|
||||
cert!: CertInfo | { type: string, id: number, name: string };
|
||||
|
||||
@TaskInput(createCertDomainGetterInputDefine({ props: { required: false } }))
|
||||
certDomains!: string[];
|
||||
|
||||
@TaskInput({
|
||||
title: "UCloud授权",
|
||||
component: {
|
||||
name: "access-selector",
|
||||
type: "ucloud"
|
||||
},
|
||||
required: true
|
||||
})
|
||||
accessId!: string;
|
||||
|
||||
@TaskInput(
|
||||
createRemoteSelectInputDefine({
|
||||
title: "负载均衡实例",
|
||||
helper: "选择ULB负载均衡实例",
|
||||
action: UCloudDeployToALB.prototype.onGetULBList.name
|
||||
})
|
||||
)
|
||||
ulbId!: string;
|
||||
|
||||
@TaskInput(
|
||||
createRemoteSelectInputDefine({
|
||||
title: "监听器列表",
|
||||
helper: "要更新的ALB监听器列表",
|
||||
action: UCloudDeployToALB.prototype.onGetVServerList.name
|
||||
})
|
||||
)
|
||||
vServerList!: string[];
|
||||
|
||||
async onInstance() {
|
||||
}
|
||||
|
||||
async execute(): Promise<void> {
|
||||
const access = await this.getAccess<UCloudAccess>(this.accessId);
|
||||
let certType = "ussl"
|
||||
let certId = 0
|
||||
|
||||
if (this.cert && typeof this.cert === 'object' && 'id' in this.cert) {
|
||||
certId = this.cert.id
|
||||
} else {
|
||||
const cert = await access.SslUploadCert({
|
||||
cert: this.cert as CertInfo
|
||||
});
|
||||
certId = cert.id
|
||||
}
|
||||
|
||||
for (const item of this.vServerList) {
|
||||
this.logger.info(`----------- 开始更新监听器:${item}`);
|
||||
await this.deployToAlb({
|
||||
access: access,
|
||||
ulbId: this.ulbId,
|
||||
vServerId: item,
|
||||
certId: certId,
|
||||
certType: certType
|
||||
});
|
||||
this.logger.info(`----------- 更新监听器证书${item}成功`);
|
||||
}
|
||||
|
||||
this.logger.info("部署完成");
|
||||
}
|
||||
|
||||
async deployToAlb(req: { access: any, ulbId: string, vServerId: string, certId: number, certType: string }) {
|
||||
const { access, ulbId, vServerId, certId, certType } = req
|
||||
|
||||
this.logger.info(`----------- 获取监听器${vServerId}配置`);
|
||||
const vServerRes = await access.invoke({
|
||||
"Action": "DescribeVServer",
|
||||
"ProjectId": access.projectId,
|
||||
"ULBId": ulbId,
|
||||
"VServerId": vServerId
|
||||
});
|
||||
|
||||
const vServer = vServerRes.VServerSet?.[0];
|
||||
if (!vServer) {
|
||||
throw new Error(`没有找到监听器${vServerId}`);
|
||||
}
|
||||
|
||||
this.logger.info(`----------- 更新ALB监听器HTTPS配置${vServerId}`);
|
||||
const resp = await access.invoke({
|
||||
"Action": "UpdateVServerAttribute",
|
||||
"ProjectId": access.projectId,
|
||||
"ULBId": ulbId,
|
||||
"VServerId": vServerId,
|
||||
"SSLMode": "port",
|
||||
"CertificateId": certId,
|
||||
"CertificateType": certType
|
||||
});
|
||||
this.logger.info(`----------- 部署ALB证书${vServerId}成功,${JSON.stringify(resp)}`);
|
||||
}
|
||||
|
||||
async onGetULBList(req: PageSearch = {}) {
|
||||
const access = await this.getAccess<UCloudAccess>(this.accessId);
|
||||
|
||||
const pageNo = req.pageNo ?? 1;
|
||||
const pageSize = req.pageSize ?? 100;
|
||||
|
||||
const res = await access.invoke({
|
||||
"Action": "DescribeULB",
|
||||
"ProjectId": access.projectId,
|
||||
"Offset": (pageNo - 1) * pageSize,
|
||||
"Limit": pageSize
|
||||
});
|
||||
|
||||
const total = res.TotalCount || 0;
|
||||
const list = res.Dataset || [];
|
||||
|
||||
if (!list || list.length === 0) {
|
||||
throw new Error("没有找到ULB实例,请先在控制台创建ULB实例");
|
||||
}
|
||||
|
||||
const options = list.map((item: any) => {
|
||||
return {
|
||||
label: `${item.Name || item.ULBId}<${item.ULBId}>`,
|
||||
value: `${item.ULBId}`
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
list: options,
|
||||
total: total,
|
||||
pageNo: pageNo,
|
||||
pageSize: pageSize
|
||||
};
|
||||
}
|
||||
|
||||
async onGetVServerList(req: PageSearch = {}) {
|
||||
const access = await this.getAccess<UCloudAccess>(this.accessId);
|
||||
|
||||
if (!this.ulbId) {
|
||||
throw new Error("请先选择ULB负载均衡实例");
|
||||
}
|
||||
|
||||
const pageNo = req.pageNo ?? 1;
|
||||
const pageSize = req.pageSize ?? 100;
|
||||
|
||||
const res = await access.invoke({
|
||||
"Action": "DescribeVServer",
|
||||
"ProjectId": access.projectId,
|
||||
"ULBId": this.ulbId,
|
||||
"Offset": (pageNo - 1) * pageSize,
|
||||
"Limit": pageSize
|
||||
});
|
||||
|
||||
const total = res.TotalCount || 0;
|
||||
const list = res.VServerSet || [];
|
||||
|
||||
if (!list || list.length === 0) {
|
||||
throw new Error("没有找到ALB监听器,请先在控制台创建ALB实例和监听器");
|
||||
}
|
||||
|
||||
const options = list.map((item: any) => {
|
||||
return {
|
||||
label: `${item.VServerName || item.VServerId}<${item.VServerId}>`,
|
||||
value: `${item.VServerId}`,
|
||||
domain: item.VServerName || item.VServerId
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
list: this.ctx.utils.options.buildGroupOptions(options, this.certDomains),
|
||||
total: total,
|
||||
pageNo: pageNo,
|
||||
pageSize: pageSize
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
new UCloudDeployToALB();
|
||||
@@ -1,6 +1,7 @@
|
||||
import {http} from "@certd/basic";
|
||||
import querystring from "querystring";
|
||||
import {VolcengineOpts} from "./ve-client.js";
|
||||
import { Pager, PageSearch } from "@certd/pipeline";
|
||||
|
||||
|
||||
export type VolcengineReq = {
|
||||
@@ -79,7 +80,6 @@ export class VolcengineDnsClient {
|
||||
}
|
||||
|
||||
|
||||
// 列出域名解析记录
|
||||
async findDomain(domain: string) {
|
||||
const req: VolcengineReq = {
|
||||
method: "POST",
|
||||
@@ -97,5 +97,41 @@ export class VolcengineDnsClient {
|
||||
|
||||
return this.doRequest(req);
|
||||
}
|
||||
|
||||
async getDomainList(page: PageSearch) {
|
||||
const pager = new Pager(page)
|
||||
const body:any = {
|
||||
SearchMode: "like",
|
||||
PageNumber: pager.pageNo,
|
||||
PageSize: pager.pageSize,
|
||||
}
|
||||
if (page.searchKey) {
|
||||
body.Key = page.searchKey
|
||||
}
|
||||
const req: VolcengineReq = {
|
||||
method: "POST",
|
||||
region: "cn-beijing",
|
||||
service: "dns",
|
||||
query: {
|
||||
Action: "ListZones",
|
||||
Version: "2018-08-01",
|
||||
},
|
||||
body:body
|
||||
};
|
||||
|
||||
const res = await this.doRequest(req);
|
||||
let list = res.Result?.Zones || []
|
||||
list = list.map((item:any) => {
|
||||
return {
|
||||
id: item.ZID,
|
||||
domain: item.ZoneName,
|
||||
}
|
||||
})
|
||||
const total = res.Result?.Total|| list.length
|
||||
return {
|
||||
list,
|
||||
total
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOp
|
||||
|
||||
import { VolcengineDnsClient } from "./dns-client.js";
|
||||
import { VolcengineAccess } from "./access.js";
|
||||
import { PageSearch } from "@certd/pipeline";
|
||||
|
||||
@IsDnsProvider({
|
||||
name: "volcengine",
|
||||
@@ -88,6 +89,10 @@ export class VolcengineDnsProvider extends AbstractDnsProvider {
|
||||
body
|
||||
});
|
||||
}
|
||||
|
||||
async getDomainListPage(page: PageSearch) {
|
||||
return await this.client.getDomainList(page)
|
||||
}
|
||||
}
|
||||
|
||||
new VolcengineDnsProvider();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpRequestConfig } from '@certd/basic';
|
||||
import { IsAccess, AccessInput, BaseAccess } from '@certd/pipeline';
|
||||
import { IsAccess, AccessInput, BaseAccess, PageSearch, Pager } from '@certd/pipeline';
|
||||
import qs from 'qs';
|
||||
import iconv from 'iconv-lite';
|
||||
/**
|
||||
@@ -133,7 +133,7 @@ export class WestAccess extends BaseAccess {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
await this.getDomainList();
|
||||
await this.getDomainList({pageNo:1,pageSize:1});
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@@ -166,14 +166,15 @@ export class WestAccess extends BaseAccess {
|
||||
return res;
|
||||
}
|
||||
|
||||
async getDomainList() {
|
||||
async getDomainList(req: PageSearch) {
|
||||
const pager = new Pager(req)
|
||||
const res = await this.doRequest({
|
||||
url: '/v2/domain',
|
||||
method: 'GET',
|
||||
data:{
|
||||
act:'getdomains',
|
||||
limit:1,
|
||||
page:1
|
||||
limit: pager.pageSize,
|
||||
page: pager.pageNo,
|
||||
}
|
||||
});
|
||||
return res;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
import { WestDnsProviderDomain } from './dns-provider-domain.js';
|
||||
import { PageRes, PageSearch } from '@certd/pipeline';
|
||||
import { AbstractDnsProvider, CreateRecordOptions, DomainRecord, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
import { WestAccess } from './access.js';
|
||||
import { WestDnsProviderDomain } from './dns-provider-domain.js';
|
||||
|
||||
type westRecord = {
|
||||
// 这里定义Record记录的数据结构,跟对应云平台接口返回值一样即可,一般是拿到id就行,用于删除txt解析记录,清理申请痕迹
|
||||
@@ -128,6 +129,10 @@ export class WestDnsProvider extends AbstractDnsProvider<westRecord> {
|
||||
const result = res.result;
|
||||
this.logger.info('删除域名解析成功:', fullRecord, value, JSON.stringify(result));
|
||||
}
|
||||
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
return await this.access.getDomainList(req);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO 实例化这个provider,将其自动注册到系统中
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
||||
import { AbstractDnsProvider, CreateRecordOptions, DomainRecord, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
||||
import { XinnetAgentAccess } from "./access-agent.js";
|
||||
import { PageRes, PageSearch } from "@certd/pipeline";
|
||||
|
||||
export type XinnetAgentRecord = {
|
||||
recordId: number;
|
||||
@@ -81,9 +82,20 @@ line 是 string 线路 只能传"默认"
|
||||
domainName: domainName
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
const res = await this.access.getDomainList(req);
|
||||
const list = res.list.map((item) => ({
|
||||
domain: item.domainName,
|
||||
id: item.domainName
|
||||
}));
|
||||
return {
|
||||
list: list || [],
|
||||
total: res.totalRows || 0
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//实例化这个provider,将其自动注册到系统中
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
||||
import { AbstractDnsProvider, CreateRecordOptions, DomainRecord, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
||||
import { XinnetAccess } from "./access.js";
|
||||
import { XinnetClient } from "@certd/plugin-plus";
|
||||
import { PageRes, PageSearch } from "@certd/pipeline";
|
||||
|
||||
export type XinnetRecord = {
|
||||
recordId: number;
|
||||
@@ -104,6 +105,26 @@ export class XinnetProvider extends AbstractDnsProvider<XinnetRecord> {
|
||||
|
||||
|
||||
}
|
||||
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
|
||||
const client = new XinnetClient({
|
||||
logger: this.logger,
|
||||
access: this.access,
|
||||
http: this.http
|
||||
});
|
||||
|
||||
const res = await client.getDomainList(req);
|
||||
|
||||
const list = res.list.map((item) => ({
|
||||
domain: item.domainName,
|
||||
id: item.domainName
|
||||
}));
|
||||
return {
|
||||
list: list || [],
|
||||
total: res.totalRows || 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//实例化这个provider,将其自动注册到系统中
|
||||
|
||||
@@ -164,10 +164,9 @@ async function publishToAtomgit() {
|
||||
console.log("publishToAtomgit success")
|
||||
}catch(error){
|
||||
if (error?.response?.data){
|
||||
console.log("publishToAtomgit error:",error.response.data)
|
||||
}else{
|
||||
console.log("publishToAtomgit error:",error)
|
||||
throw new Error("publishToAtomgit error:",error.response.data)
|
||||
}
|
||||
throw new Error("publishToAtomgit error:",error)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,10 +34,9 @@ async function publishToGitee() {
|
||||
console.log("publishToGitee success")
|
||||
} catch (error) {
|
||||
if (error?.response?.data){
|
||||
console.log("publishToGitee error:",error.response.data)
|
||||
}else{
|
||||
console.log("publishToGitee error:",error)
|
||||
throw new Error("publishToGitee error:",error.response.data)
|
||||
}
|
||||
throw new Error("publishToGitee error:",error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,10 +34,9 @@ async function publishToGithub() {
|
||||
console.log("publishToGithub success")
|
||||
} catch (error) {
|
||||
if (error?.response?.data){
|
||||
console.log("publishToGithub error:",error.response.data)
|
||||
}else{
|
||||
console.log("publishToGithub error:",error)
|
||||
throw new Error("publishToGithub error:",error.response.data)
|
||||
}
|
||||
throw new Error("publishToGithub error:",error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
01:00
|
||||
12:32
|
||||
|
||||
@@ -1 +1 @@
|
||||
01:32
|
||||
13:11
|
||||
|
||||
Reference in New Issue
Block a user