优化首页托管域名分页布局

将首页信息卡片移动到托管域名列表上方,增加证书状态列表和每页条数分页,并修正正常状态显示。
This commit is contained in:
xuans committed 2026-09-25 18:33:48 +08:00
1 parent 040ad2ed49
commit a0b1f745c9
5 files changed
+255 -33

No files matched your search

+46 -1
View File
@@ -22,6 +22,9 @@ export function useDashboard() {
const settings = ref(null);
const dnsProviderCatalog = ref([]);
const domainServers = ref({});
const domainPage = ref(1);
const domainPageSize = ref(5);
const domainPageSizeOptions = [5, 10, 15, 30];
const loading = ref(true);
const saving = ref(false);
const error = ref("");
@@ -79,6 +82,30 @@ export function useDashboard() {
);
let previousBodyOverflow = "";
const domainPageCount = computed(() =>
Math.max(1, Math.ceil(domains.value.length / domainPageSize.value)),
);
const paginatedDomains = computed(() => {
const start = (domainPage.value - 1) * domainPageSize.value;
return domains.value.slice(start, start + domainPageSize.value);
});
const domainPageStart = computed(() =>
domains.value.length === 0 ? 0 : (domainPage.value - 1) * domainPageSize.value + 1,
);
const domainPageEnd = computed(() =>
Math.min(domainPage.value * domainPageSize.value, domains.value.length),
);
watch(domainPageSize, () => {
domainPage.value = 1;
});
watch(domains, () => {
if (domainPage.value > domainPageCount.value) {
domainPage.value = domainPageCount.value;
}
});
watch(hasOpenModal, (isOpen) => {
if (isOpen) {
previousBodyOverflow = document.body.style.overflow;
@@ -180,6 +207,7 @@ export function useDashboard() {
const domainStatusLabels = {
pending: "等待申请",
active: "正常",
valid: "正常",
error: "错误",
};
const httpsModeLabels = { direct: "核心服务 HTTPS", proxy: "反向代理 HTTPS" };
@@ -486,13 +514,21 @@ export function useDashboard() {
}
function statusClass(value) {
return value === "active" || value === "success"
return value === "active" || value === "valid" || value === "success"
? "success"
: value === "error" || value === "failed"
? "danger"
: "warning";
}
function previousDomainPage() {
domainPage.value = Math.max(1, domainPage.value - 1);
}
function nextDomainPage() {
domainPage.value = Math.min(domainPageCount.value, domainPage.value + 1);
}
function openCreate() {
editingId.value = "";
form.value = createEmptyForm();
@@ -1192,6 +1228,15 @@ export function useDashboard() {
clearDNSCredentials,
testDNS,
domainServers,
domainPage,
domainPageSize,
domainPageSizeOptions,
domainPageCount,
paginatedDomains,
domainPageStart,
domainPageEnd,
previousDomainPage,
nextDomainPage,
loading,
saving,
error,