From c42115a0adce0f9af2ba40bdd81dad1cc969aaa8 Mon Sep 17 00:00:00 2001 From: jingrow Date: Sun, 3 Aug 2025 19:55:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9F=9F=E5=90=8D=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E6=A0=87=E7=AD=BE=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JsiteDomainAddDNSRecordDialog.vue | 246 +++++++++++++ .../src2/components/JsiteDomainDNSRecords.vue | 347 ++++++++++++++++++ .../JsiteDomainEditDNSRecordDialog.vue | 259 +++++++++++++ dashboard/src2/objects/domain.js | 9 + jcloud/api/domain_west.py | 29 +- 5 files changed, 887 insertions(+), 3 deletions(-) create mode 100644 dashboard/src2/components/JsiteDomainAddDNSRecordDialog.vue create mode 100644 dashboard/src2/components/JsiteDomainDNSRecords.vue create mode 100644 dashboard/src2/components/JsiteDomainEditDNSRecordDialog.vue diff --git a/dashboard/src2/components/JsiteDomainAddDNSRecordDialog.vue b/dashboard/src2/components/JsiteDomainAddDNSRecordDialog.vue new file mode 100644 index 0000000..070c5f7 --- /dev/null +++ b/dashboard/src2/components/JsiteDomainAddDNSRecordDialog.vue @@ -0,0 +1,246 @@ + + + \ No newline at end of file diff --git a/dashboard/src2/components/JsiteDomainDNSRecords.vue b/dashboard/src2/components/JsiteDomainDNSRecords.vue new file mode 100644 index 0000000..719da8d --- /dev/null +++ b/dashboard/src2/components/JsiteDomainDNSRecords.vue @@ -0,0 +1,347 @@ + + + \ No newline at end of file diff --git a/dashboard/src2/components/JsiteDomainEditDNSRecordDialog.vue b/dashboard/src2/components/JsiteDomainEditDNSRecordDialog.vue new file mode 100644 index 0000000..3d21515 --- /dev/null +++ b/dashboard/src2/components/JsiteDomainEditDNSRecordDialog.vue @@ -0,0 +1,259 @@ + + + \ No newline at end of file diff --git a/dashboard/src2/objects/domain.js b/dashboard/src2/objects/domain.js index 6ee8f19..2731a20 100644 --- a/dashboard/src2/objects/domain.js +++ b/dashboard/src2/objects/domain.js @@ -174,6 +174,15 @@ export default { props: domain => { return { domain: domain.pg?.name }; } + }, + { + label: '域名解析', + route: 'dns', + type: 'Component', + component: defineAsyncComponent(() => import('../components/JsiteDomainDNSRecords.vue')), + props: domain => { + return { domain: domain.pg?.name }; + } } ], fields: [ diff --git a/jcloud/api/domain_west.py b/jcloud/api/domain_west.py index ea1c75d..a02a700 100644 --- a/jcloud/api/domain_west.py +++ b/jcloud/api/domain_west.py @@ -312,7 +312,7 @@ class WestDomain: return self._make_request('/domain/?act=modifydns', 'POST', body_params=body_params) def add_dns_record(self, domain: str, record_type: str, - host: str, value: str, ttl: int = 600) -> Dict[str, Any]: + host: str, value: str, ttl: int = 600, level: int = 10) -> Dict[str, Any]: """ 添加DNS记录 @@ -322,6 +322,7 @@ class WestDomain: host: 主机记录 value: 记录值 ttl: TTL值 + level: 优先级(MX记录使用) """ record = { 'type': record_type, @@ -329,6 +330,11 @@ class WestDomain: 'value': value, 'ttl': ttl, } + + # 如果是MX记录,添加优先级 + if record_type == 'MX': + record['level'] = level + return self.modify_dns_records(domain, [record]) def delete_dns_record(self, domain: str, record_id: str) -> Dict[str, Any]: @@ -829,7 +835,23 @@ def west_domain_modify_dns(**data): if not records: return {"status": "error", "message": "缺少DNS记录参数"} - return client.modify_dns_records(domain, records) + # 处理记录数据,确保MX记录有正确的优先级字段 + processed_records = [] + for record in records: + processed_record = { + 'type': record.get('type'), + 'host': record.get('host'), + 'value': record.get('value'), + 'ttl': record.get('ttl', 600) + } + + # 如果是MX记录,添加优先级 + if record.get('type') == 'MX': + processed_record['level'] = record.get('level', 10) + + processed_records.append(processed_record) + + return client.modify_dns_records(domain, processed_records) @jingrow.whitelist() @@ -844,11 +866,12 @@ def west_domain_add_dns_record(**data): host = data.get('host') value = data.get('value') ttl = data.get('ttl', 600) + level = data.get('level', 10) if not all([domain, record_type, host, value]): return {"status": "error", "message": "缺少必要参数"} - return client.add_dns_record(domain, record_type, host, value, ttl) + return client.add_dns_record(domain, record_type, host, value, ttl, level) @jingrow.whitelist()