258 lines
5.0 KiB
JavaScript

import { defineAsyncComponent, h } from 'vue';
import LucideGlobe from '~icons/lucide/globe';
import { getTeam } from '../data/team';
import router from '../router';
import { icon } from '../utils/components';
import { duration, planTitle, userCurrency } from '../utils/format';
import { trialDays } from '../utils/site';
import { getJobsTab } from './common/jobs';
import { tagTab } from './common/tags';
export default {
pagetype: 'Jsite Domain',
whitelistedMethods: {
renew: 'renew',
rename: 'rename',
dropDomain: 'drop_domain',
addTag: 'add_resource_tag',
removeTag: 'remove_resource_tag'
},
list: {
route: '/domains',
title: '域名',
fields: [
'name',
'domain',
'status',
'domain_owner',
'domain_registrar',
'registration_date',
'end_date',
'price',
'period',
'auto_renew',
'team',
'order_id',
'description'
],
filterControls() {
return [
{
type: 'select',
label: '状态',
fieldname: 'status',
options: [
{ label: '', value: '' },
{ label: '待处理', value: 'Pending' },
{ label: '正常', value: 'Active' },
{ label: '已过期', value: 'Expired' },
{ label: '已暂停', value: 'Suspended' },
{ label: '已取消', value: 'Cancelled' }
]
},
{
type: 'select',
label: '自动续费',
fieldname: 'auto_renew',
options: [
{ label: '', value: '' },
{ label: '是', value: '1' },
{ label: '否', value: '0' }
]
}
];
},
orderBy: 'creation desc',
searchField: 'domain',
columns: [
{
label: '域名',
fieldname: 'domain',
width: 2,
class: 'font-medium',
format(value) {
return value;
}
},
{
label: '状态',
fieldname: 'status',
type: 'Badge',
width: 0.8,
format(value) {
const statusMap = {
'Pending': '待处理',
'Active': '正常',
'Expired': '已过期',
'Suspended': '已暂停',
'Cancelled': '已取消'
};
return statusMap[value] || value;
}
},
{
label: '所有者',
fieldname: 'domain_owner',
format(value) {
return value || '-';
}
},
{
label: '注册商',
fieldname: 'domain_registrar',
format(value) {
return value || '-';
}
},
{
label: '注册时间',
fieldname: 'registration_date',
format(value) {
if (!value) return '-';
return value;
}
},
{
label: '到期时间',
fieldname: 'end_date',
format(value) {
if (!value) return '-';
return value;
}
},
{
label: '价格',
fieldname: 'price',
format(value) {
if (!value) return '-';
return `¥${value}/年`;
}
}
],
primaryAction({ listResource: domains }) {
return {
label: '新建域名',
variant: 'solid',
slots: {
prefix: icon('plus')
},
onClick() {
router.push('/domains/new');
}
};
},
statusBadge({ documentResource: domain }) {
const status = domain.pg?.status;
const statusMap = {
'Pending': '待处理',
'Active': '正常',
'Expired': '已过期',
'Suspended': '已暂停',
'Cancelled': '已取消'
};
return {
label: statusMap[status] || status
};
},
breadcrumbs({ documentResource: domain }) {
return [
{
label: '域名',
route: '/domains'
},
{
label: domain.pg?.domain || domain.pg?.name,
route: `/domains/${domain.pg?.name}`
}
];
},
actions({ documentResource: domain }) {
if (!domain) return [];
const actions = [
{
label: '续费',
icon: 'refresh-cw',
onClick() {
domain.renew.submit();
},
condition: () => domain.pg?.status === 'Active'
},
{
label: '重命名',
icon: 'edit-3',
onClick() {
domain.rename.submit();
}
},
{
label: '删除',
icon: 'trash-2',
onClick() {
domain.dropDomain.submit();
},
condition: () => domain.pg?.status !== 'Active'
}
];
return actions.filter(action => !action.condition || action.condition());
}
},
detail: {
route: '/domains/:name',
title: '域名详细信息',
tabs: [
{
label: '概览',
route: '',
type: 'Component',
component: defineAsyncComponent(() => import('../components/JsiteDomainOverview.vue')),
props: domain => {
return { domain: domain.pg?.name };
}
}
],
fields: [
{
label: '基本信息',
fields: [
'domain',
'status',
'domain_owner',
'domain_registrar',
'registration_date',
'end_date'
]
},
{
label: '价格信息',
fields: [
'price',
'period',
'auto_renew',
'order_id'
]
},
{
label: 'DNS设置',
fields: [
'dns_host1',
'dns_host2',
'dns_host3',
'dns_host4',
'dns_host5',
'dns_host6'
]
},
{
label: '其他信息',
fields: [
'description',
'whois_protection'
]
}
],
actions({ documentResource: domain }) {
return [];
}
}
};