From d9b3edb7ae25506786334c917bf23e096390b77c Mon Sep 17 00:00:00 2001 From: jingrow Date: Sat, 2 Aug 2025 20:38:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=9F=E5=90=8D=E8=AF=A6=E6=83=85=E9=A1=B5?= =?UTF-8?q?=E6=89=80=E6=9C=89=E8=80=85=E6=98=BE=E7=A4=BA=E4=B8=BA=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E5=A7=93=E5=90=8D=E6=88=96=E5=85=AC=E5=8F=B8=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=EF=BC=8C=E7=8A=B6=E6=80=81=E6=98=BE=E7=A4=BA=E4=B8=BA?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E6=88=96=E5=B7=B2=E5=88=B0=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src2/components/JsiteDomainOverview.vue | 92 +++++++++++++++---- jcloud/api/domain_west.py | 42 +++++++++ .../pagetype/jsite_domain/jsite_domain.json | 7 +- .../pagetype/jsite_domain/jsite_domain.py | 4 +- 4 files changed, 123 insertions(+), 22 deletions(-) diff --git a/dashboard/src2/components/JsiteDomainOverview.vue b/dashboard/src2/components/JsiteDomainOverview.vue index 1464a66..89b3685 100644 --- a/dashboard/src2/components/JsiteDomainOverview.vue +++ b/dashboard/src2/components/JsiteDomainOverview.vue @@ -59,7 +59,7 @@
所有者: - {{ $domain.pg.domain_owner || '未知' }} + {{ getOwnerDisplayName() || '未知' }}
购买时长: @@ -208,29 +208,70 @@ export default { autoRenewLoading: false, whoisProtectionLoading: false, deleteLoading: false, + domainOwner: null, }; }, methods: { getStatusText(status) { const statusMap = { - 'Pending': '待处理', - 'Active': '活跃', - 'Expired': '已过期', - 'Suspended': '已暂停', - 'Cancelled': '已取消' + 'Active': '正常', + 'Expired': '已过期' }; return statusMap[status] || status; }, getStatusVariant(status) { const variantMap = { - 'Pending': 'warning', 'Active': 'success', - 'Expired': 'danger', - 'Suspended': 'danger', - 'Cancelled': 'danger' + 'Expired': 'danger' }; return variantMap[status] || 'default'; }, + // 获取域名所有者显示名称 + getOwnerDisplayName() { + if (!this.domainOwner) { + return null; + } + + // 如果是个人,优先显示fullname,没有的话显示title + if (this.domainOwner.c_regtype === 'I') { + return this.domainOwner.fullname || this.domainOwner.title; + } + // 如果是公司,优先显示c_org_m,没有的话显示title + else if (this.domainOwner.c_regtype === 'E') { + return this.domainOwner.c_org_m || this.domainOwner.title; + } + // 默认显示title + return this.domainOwner.title; + }, + // 获取域名所有者信息 + async getDomainOwner() { + if (!this.$domain.pg?.domain_owner) { + this.domainOwner = null; + return; + } + + try { + const getOwnerRequest = createResource({ + url: 'jcloud.api.domain_west.get_domain_owner', + params: { + name: this.$domain.pg.domain_owner + }, + onSuccess: (response) => { + if (response && response.status === "Success" && response.data) { + this.domainOwner = response.data; + } + }, + onError: (error) => { + console.error('获取域名所有者信息失败:', error); + this.domainOwner = null; + } + }); + getOwnerRequest.submit(); + } catch (error) { + console.error('获取域名所有者信息失败:', error); + this.domainOwner = null; + } + }, renewDomain() { const JsiteDomainRenewalDialog = defineAsyncComponent(() => import('./JsiteDomainRenewalDialog.vue')); @@ -273,12 +314,12 @@ export default { primaryAction: { label: '确定', onClick: ({ hide }) => { - toast.success(`${actionText}自动续费请求已提交`); + toast.success(`${actionText}自动续费已开通`); hide(); this.autoRenewLoading = true; const toggleRequest = createResource({ - url: '/api/action/jcloud.api.domain_west.toggle_domain_auto_renew', + url: 'jcloud.api.domain_west.toggle_domain_auto_renew', params: { pagetype: 'Jsite Domain', name: this.$domain.pg.name, @@ -313,12 +354,12 @@ export default { primaryAction: { label: '确定', onClick: ({ hide }) => { - toast.success(`${actionText}隐私保护请求已提交`); + toast.success(`${actionText}隐私保护已开启`); hide(); this.whoisProtectionLoading = true; const toggleRequest = createResource({ - url: '/api/action/jcloud.api.domain_west.toggle_domain_whois_protection', + url: 'jcloud.api.domain_west.toggle_domain_whois_protection', params: { pagetype: 'Jsite Domain', name: this.$domain.pg.name, @@ -355,7 +396,7 @@ export default { this.deleteLoading = true; const deleteRequest = createResource({ - url: '/api/action/jcloud.api.domain_west.delete_domain', + url: 'jcloud.api.domain_west.delete_domain', params: { pagetype: 'Jsite Domain', name: this.$domain.pg.name @@ -384,6 +425,19 @@ export default { this.$domain.reload(); }, }, + watch: { + // 监听域名数据变化,重新获取所有者信息 + '$domain.pg.domain_owner': { + handler(newVal) { + if (newVal) { + this.getDomainOwner(); + } else { + this.domainOwner = null; + } + }, + immediate: true + } + }, computed: { domainInformation() { return [ @@ -405,7 +459,7 @@ export default { }, { label: '所有者', - value: this.$domain.pg?.domain_owner || '未知', + value: this.getOwnerDisplayName() || '未知', }, ]; }, @@ -413,5 +467,11 @@ export default { return getCachedDocumentResource('Jsite Domain', this.domain); }, }, + mounted() { + // 初始化时获取域名所有者信息 + if (this.$domain.pg?.domain_owner) { + this.getDomainOwner(); + } + }, }; \ No newline at end of file diff --git a/jcloud/api/domain_west.py b/jcloud/api/domain_west.py index 779c7e9..f17ecbf 100644 --- a/jcloud/api/domain_west.py +++ b/jcloud/api/domain_west.py @@ -1094,6 +1094,48 @@ def get_domain_owners(): jingrow.log_error("获取域名所有者列表失败", str(e)) return {"status": "Error", "message": f"获取域名所有者列表失败: {str(e)}"} +@jingrow.whitelist() +def get_domain_owner(name): + """获取单个域名所有者信息""" + try: + if not name: + return {"status": "Error", "message": "域名所有者名称不能为空"} + + # 获取指定的域名所有者 + domain_owner = jingrow.get_pg("Domain Owner", name) + if not domain_owner: + return {"status": "Error", "message": "未找到指定的域名所有者"} + + # 检查权限(只能查看当前团队的所有者) + team = get_current_team() + if not team or domain_owner.team != team: + return {"status": "Error", "message": "无权访问该域名所有者信息"} + + # 返回所有者信息 + owner_data = { + "name": domain_owner.name, + "title": domain_owner.title, + "fullname": domain_owner.fullname, + "c_regtype": domain_owner.c_regtype, + "c_org_m": domain_owner.c_org_m, + "c_ln_m": domain_owner.c_ln_m, + "c_fn_m": domain_owner.c_fn_m, + "c_em": domain_owner.c_em, + "c_ph": domain_owner.c_ph, + "c_st_m": domain_owner.c_st_m, + "c_ct_m": domain_owner.c_ct_m, + "c_adr_m": domain_owner.c_adr_m, + "c_pc": domain_owner.c_pc + } + + return { + "status": "Success", + "data": owner_data + } + except Exception as e: + jingrow.log_error("获取域名所有者信息失败", str(e)) + return {"status": "Error", "message": f"获取域名所有者信息失败: {str(e)}"} + @jingrow.whitelist() def create_domain_template(**data): """创建域名模板""" diff --git a/jcloud/jcloud/pagetype/jsite_domain/jsite_domain.json b/jcloud/jcloud/pagetype/jsite_domain/jsite_domain.json index 7492129..40ffab9 100644 --- a/jcloud/jcloud/pagetype/jsite_domain/jsite_domain.json +++ b/jcloud/jcloud/pagetype/jsite_domain/jsite_domain.json @@ -40,14 +40,13 @@ "options": "Team" }, { - "default": "Pending", + "default": "Active", "fieldname": "status", "fieldtype": "Select", "in_list_view": 1, "in_standard_filter": 1, "label": "状态", - "options": "Pending\nActive\nExpired\nSuspended\nCancelled", - "read_only": 1 + "options": "Active\nExpired" }, { "fieldname": "order_id", @@ -197,7 +196,7 @@ "grid_page_length": 50, "index_web_pages_for_search": 1, "links": [], - "modified": "2025-08-01 04:11:35.696328", + "modified": "2025-08-02 20:35:58.740670", "modified_by": "Administrator", "module": "Jcloud", "name": "Jsite Domain", diff --git a/jcloud/jcloud/pagetype/jsite_domain/jsite_domain.py b/jcloud/jcloud/pagetype/jsite_domain/jsite_domain.py index 5c63e4f..cc722cc 100644 --- a/jcloud/jcloud/pagetype/jsite_domain/jsite_domain.py +++ b/jcloud/jcloud/pagetype/jsite_domain/jsite_domain.py @@ -26,7 +26,7 @@ class JsiteDomain(Document): dns_host6: DF.Data | None dns_resolution: DF.Table[DnsResolution] domain: DF.Data - domain_owner: DF.Data | None + domain_owner: DF.Link | None domain_registrar: DF.Data | None end_date: DF.Datetime | None group: DF.Data | None @@ -34,7 +34,7 @@ class JsiteDomain(Document): period: DF.Int price: DF.Int registration_date: DF.Datetime | None - status: DF.Literal["Pending", "Active", "Expired", "Suspended", "Cancelled"] + status: DF.Literal["Active", "Expired"] team: DF.Link | None whois_protection: DF.Check # end: auto-generated types