mirror of https://github.com/certd/certd
chore: 新网已支持
parent
1c15beadc7
commit
48f4298a8d
|
|
@ -207,9 +207,13 @@ export function createAxiosService({ logger }: { logger: ILogger }) {
|
|||
case 505:
|
||||
error.message = "HTTP版本不受支持";
|
||||
break;
|
||||
case 302:
|
||||
//重定向
|
||||
return Promise.resolve(error.response);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
logger.error(`请求出错:status:${error.response?.status},statusText:${error.response?.statusText},url:${error.config?.url},method:${error.config?.method}。`);
|
||||
logger.error("返回数据:", JSON.stringify(error.response?.data));
|
||||
if (error.response?.data) {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ watch(
|
|||
},
|
||||
value => {
|
||||
if (value == null) {
|
||||
reset();
|
||||
resetImageCode();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -155,7 +155,6 @@ watch(forgotPasswordType, () => {
|
|||
});
|
||||
|
||||
const handleFinish = async (values: any) => {
|
||||
try {
|
||||
await userStore.forgotPassword(
|
||||
toRaw({
|
||||
type: forgotPasswordType.value,
|
||||
|
|
@ -165,10 +164,6 @@ const handleFinish = async (values: any) => {
|
|||
confirmPassword: formState.confirmPassword,
|
||||
}) as any
|
||||
);
|
||||
} finally {
|
||||
formState.captchaForSms = null;
|
||||
formState.captchaForEmail = null;
|
||||
}
|
||||
};
|
||||
|
||||
const handleFinishFailed = (errors: any) => {
|
||||
|
|
|
|||
|
|
@ -189,7 +189,6 @@ export default defineComponent({
|
|||
} finally {
|
||||
loading.value = false;
|
||||
formState.captcha = null;
|
||||
formState.smsCaptcha = null;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import { XinnetClient } from "@certd/plugin-plus";
|
|||
@IsAccess({
|
||||
name: "xinnet",
|
||||
title: "新网授权",
|
||||
icon: "arcticons:dns-changer-3",
|
||||
icon: "lsicon:badge-new-filled",
|
||||
desc: ""
|
||||
})
|
||||
export class XinnetAccess extends BaseAccess {
|
||||
|
|
@ -19,7 +19,7 @@ export class XinnetAccess extends BaseAccess {
|
|||
@AccessInput({
|
||||
title: "用户名",
|
||||
component: {
|
||||
placeholder: "手机号"
|
||||
placeholder: "手机号/用户名"
|
||||
},
|
||||
required: true,
|
||||
encrypt: true
|
||||
|
|
@ -27,13 +27,12 @@ export class XinnetAccess extends BaseAccess {
|
|||
username = "";
|
||||
|
||||
@AccessInput({
|
||||
title: "域名登录密码",
|
||||
title: "登录密码",
|
||||
component: {
|
||||
name: "a-input-password",
|
||||
vModel: "value",
|
||||
placeholder: "域名密码"
|
||||
placeholder: "登录密码"
|
||||
},
|
||||
helper: "您可以在此处[重置域名管理密码](https://domain.xinnet.com/#domain/manage/domain_manage_pwd)",
|
||||
required: true,
|
||||
encrypt: true
|
||||
})
|
||||
|
|
@ -62,6 +61,19 @@ export class XinnetAccess extends BaseAccess {
|
|||
return "ok";
|
||||
}
|
||||
|
||||
|
||||
getCacheKey () {
|
||||
let hashStr = ""
|
||||
for (const key in this) {
|
||||
if (Object.prototype.hasOwnProperty.call(this, key)) {
|
||||
const element = this[key];
|
||||
hashStr += element;
|
||||
}
|
||||
}
|
||||
const hashCode = this.ctx.utils.hash.sha256(hashStr);
|
||||
return `xinnet-${hashCode}`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new XinnetAccess();
|
||||
|
|
|
|||
|
|
@ -3,24 +3,27 @@ import { XinnetAccess } from "./access.js";
|
|||
import { XinnetClient } from "@certd/plugin-plus";
|
||||
|
||||
export type XinnetRecord = {
|
||||
id: number;
|
||||
domainId: number,
|
||||
recordId: number;
|
||||
recordFullName: string;
|
||||
recordValue: string;
|
||||
type: string;
|
||||
serviceCode: string;
|
||||
dcpCookie: string;
|
||||
};
|
||||
|
||||
// 这里通过IsDnsProvider注册一个dnsProvider
|
||||
@IsDnsProvider({
|
||||
name: 'xinnet',
|
||||
title: '新网',
|
||||
desc: '新网域名解析',
|
||||
icon: 'arcticons:dns-changer-3',
|
||||
name: "xinnet",
|
||||
title: "新网",
|
||||
desc: "新网域名解析",
|
||||
icon: "lsicon:badge-new-filled",
|
||||
// 这里是对应的 cloudflare的access类型名称
|
||||
accessType: 'xinnet',
|
||||
order:7,
|
||||
accessType: "xinnet",
|
||||
order: 7
|
||||
})
|
||||
export class XinnetProvider extends AbstractDnsProvider<XinnetRecord> {
|
||||
access!: XinnetAccess;
|
||||
|
||||
client!:XinnetClient;
|
||||
async onInstance() {
|
||||
//一些初始化的操作
|
||||
// 也可以通过ctx成员变量传递context
|
||||
|
|
@ -37,37 +40,41 @@ export class XinnetProvider extends AbstractDnsProvider<XinnetRecord> {
|
|||
* type: 'TXT',
|
||||
* domain: 'example.com'
|
||||
*/
|
||||
// const { fullRecord,hostRecord, value, type, domain } = options;
|
||||
// this.logger.info('添加域名解析:', fullRecord, value, type, domain);
|
||||
const { fullRecord, hostRecord, value, type, domain } = options;
|
||||
this.logger.info("添加域名解析:", fullRecord, value, type, domain);
|
||||
|
||||
// const client = new XinnetClient({
|
||||
// logger: this.logger,
|
||||
// access: {
|
||||
// domain: "",
|
||||
// password: this.access.password
|
||||
// },
|
||||
// http: this.http
|
||||
// });
|
||||
const client = new XinnetClient({
|
||||
logger: this.logger,
|
||||
access: this.access,
|
||||
http: this.http
|
||||
});
|
||||
|
||||
const res = await client.getDomainList({
|
||||
searchKey: domain
|
||||
});
|
||||
|
||||
if (!res.list || res.list.length == 0) {
|
||||
throw new Error("域名不存在");
|
||||
}
|
||||
const serviceCode = res.list[0].serviceCode;
|
||||
|
||||
// const domainId = await this.client.getDomainId(domain);
|
||||
// this.logger.info('获取domainId成功:', domainId);
|
||||
//
|
||||
// const res = await this.client.createRecord({
|
||||
// domain: domain,
|
||||
// domainId: domainId,
|
||||
// type: 'TXT',
|
||||
// host: hostRecord,
|
||||
// data: value,
|
||||
// ttl: 300,
|
||||
// })
|
||||
// return {
|
||||
// id: res.id,
|
||||
// domainId: domainId,
|
||||
// };
|
||||
const dcpCookie = await client.getDcpCookie({
|
||||
serviceCode
|
||||
});
|
||||
|
||||
return 1 as any
|
||||
const recordRes = await client.addDomainDnsRecord({
|
||||
recordName: hostRecord,
|
||||
type: type,
|
||||
recordValue: value
|
||||
}, {
|
||||
dcpCookie,
|
||||
serviceCode
|
||||
});
|
||||
return {
|
||||
...recordRes,
|
||||
serviceCode,
|
||||
dcpCookie
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -76,27 +83,26 @@ export class XinnetProvider extends AbstractDnsProvider<XinnetRecord> {
|
|||
* @param options
|
||||
*/
|
||||
async removeRecord(options: RemoveRecordOptions<XinnetRecord>): Promise<void> {
|
||||
// const { fullRecord, value } = options.recordReq;
|
||||
// const record = options.recordRes;
|
||||
// this.logger.info('删除域名解析:', fullRecord, value);
|
||||
// if (!record) {
|
||||
// this.logger.info('record为空,不执行删除');
|
||||
// return;
|
||||
// }
|
||||
// //这里调用删除txt dns解析记录接口
|
||||
// /**
|
||||
// * 请求示例
|
||||
// * DELETE /api/record?id=85371689655342080 HTTP/1.1
|
||||
// * Authorization: Basic {token}
|
||||
// * 请求参数
|
||||
// */
|
||||
// const {id,domainId} = record
|
||||
// await this.client.deleteRecord({
|
||||
// id,
|
||||
// domainId
|
||||
// })
|
||||
// this.logger.info(`删除域名解析成功:fullRecord=${fullRecord},id=${id}`);
|
||||
// }
|
||||
const client = new XinnetClient({
|
||||
logger: this.logger,
|
||||
access: this.access,
|
||||
http: this.http
|
||||
});
|
||||
|
||||
const recordRes = options.recordRes;
|
||||
let dcpCookie = recordRes.dcpCookie;
|
||||
if (!dcpCookie) {
|
||||
dcpCookie = await client.getDcpCookie({
|
||||
serviceCode: recordRes.serviceCode
|
||||
});
|
||||
}
|
||||
|
||||
await client.deleteDomainDnsRecord(recordRes, {
|
||||
dcpCookie,
|
||||
serviceCode: recordRes.serviceCode
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue