fix: prefer github blob links in spider md dialog
This commit is contained in:
@@ -68,17 +68,52 @@
|
|||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<div class="spider-md-dialog__expand">
|
<div class="spider-md-dialog__expand">
|
||||||
<el-empty
|
<el-empty
|
||||||
v-if="!remoteFiles(scope.row).length"
|
v-if="!hasRemoteFiles(scope.row)"
|
||||||
:description="emptyRemoteDescription(scope.row)"
|
:description="emptyRemoteDescription(scope.row)"
|
||||||
/>
|
/>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<div class="spider-md-dialog__expand-toolbar">
|
<div v-if="remoteMdFiles(scope.row, 'gitee').length" class="spider-md-dialog__provider-block">
|
||||||
<el-button size="small" type="primary" plain @click="copyAllMdLinks(remoteMdFiles(scope.row))">一键复制MD链接</el-button>
|
<div class="spider-md-dialog__expand-toolbar">
|
||||||
|
<div class="spider-md-dialog__provider-title">Gitee 链接</div>
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
@click="copyAllMdLinks(remoteMdFiles(scope.row, 'gitee'), 'gitee')"
|
||||||
|
>
|
||||||
|
一键复制 Gitee MD
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
<el-table :data="remoteMdFiles(scope.row, 'gitee')" border size="small">
|
||||||
|
<el-table-column prop="file_name" label="文件" min-width="180" />
|
||||||
|
<el-table-column label="MD链接" min-width="420" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ getRemoteLink(row, "gitee") }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
<div v-if="remoteMdFiles(scope.row, 'github').length" class="spider-md-dialog__provider-block">
|
||||||
|
<div class="spider-md-dialog__expand-toolbar">
|
||||||
|
<div class="spider-md-dialog__provider-title">GitHub 链接</div>
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
@click="copyAllMdLinks(remoteMdFiles(scope.row, 'github'), 'github')"
|
||||||
|
>
|
||||||
|
一键复制 GitHub MD
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
<el-table :data="remoteMdFiles(scope.row, 'github')" border size="small">
|
||||||
|
<el-table-column prop="file_name" label="文件" min-width="180" />
|
||||||
|
<el-table-column label="MD链接" min-width="420" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ getRemoteLink(row, "github") }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
</div>
|
</div>
|
||||||
<el-table :data="remoteMdFiles(scope.row)" border size="small">
|
|
||||||
<el-table-column prop="file_name" label="文件" min-width="180" />
|
|
||||||
<el-table-column prop="download_url" label="MD链接" min-width="420" show-overflow-tooltip />
|
|
||||||
</el-table>
|
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -98,21 +133,20 @@
|
|||||||
聚合 {{ scope.row.aggregate_count || 0 }} / 详情 {{ scope.row.detail_count || 0 }} / 泛链 {{ scope.row.forge_count || 0 }}
|
聚合 {{ scope.row.aggregate_count || 0 }} / 详情 {{ scope.row.detail_count || 0 }} / 泛链 {{ scope.row.forge_count || 0 }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="推送状态" min-width="110">
|
<el-table-column label="推送状态" min-width="180">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-tag
|
<el-tag
|
||||||
size="small"
|
size="small"
|
||||||
:type="remoteStatus(scope.row) === 'success' ? 'success' : (remoteStatus(scope.row) === 'failed' || remoteStatus(scope.row) === 'partial_failed' ? 'danger' : 'info')"
|
:type="remoteStatus(scope.row, 'gitee') === 'success' ? 'success' : (remoteStatus(scope.row, 'gitee') === 'failed' || remoteStatus(scope.row, 'gitee') === 'partial_failed' ? 'danger' : 'info')"
|
||||||
>
|
>
|
||||||
{{
|
Gitee:{{ statusLabel(remoteStatus(scope.row, "gitee")) }}
|
||||||
remoteStatus(scope.row) === 'success'
|
</el-tag>
|
||||||
? "已推送"
|
<el-tag
|
||||||
: remoteStatus(scope.row) === 'failed'
|
size="small"
|
||||||
? "推送失败"
|
style="margin-left:8px;"
|
||||||
: remoteStatus(scope.row) === 'partial_failed'
|
:type="remoteStatus(scope.row, 'github') === 'success' ? 'success' : (remoteStatus(scope.row, 'github') === 'failed' || remoteStatus(scope.row, 'github') === 'partial_failed' ? 'danger' : 'info')"
|
||||||
? "部分失败"
|
>
|
||||||
: "仅本地"
|
GitHub:{{ statusLabel(remoteStatus(scope.row, "github")) }}
|
||||||
}}
|
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -121,15 +155,15 @@
|
|||||||
<el-tag size="small" type="success">本地成功</el-tag>
|
<el-tag size="small" type="success">本地成功</el-tag>
|
||||||
<el-tag
|
<el-tag
|
||||||
size="small"
|
size="small"
|
||||||
:type="remoteStatus(scope.row) === 'success' ? 'success' : (remoteStatus(scope.row) === 'failed' || remoteStatus(scope.row) === 'partial_failed' ? 'danger' : 'info')"
|
:type="remoteOverallStatus(scope.row) === 'success' ? 'success' : (remoteOverallStatus(scope.row) === 'failed' || remoteOverallStatus(scope.row) === 'partial_failed' ? 'danger' : 'info')"
|
||||||
style="margin-left:8px;"
|
style="margin-left:8px;"
|
||||||
>
|
>
|
||||||
{{
|
{{
|
||||||
remoteStatus(scope.row) === 'success'
|
remoteOverallStatus(scope.row) === 'success'
|
||||||
? "远端成功"
|
? "远端成功"
|
||||||
: remoteStatus(scope.row) === 'failed'
|
: remoteOverallStatus(scope.row) === 'failed'
|
||||||
? "远端失败"
|
? "远端失败"
|
||||||
: remoteStatus(scope.row) === 'partial_failed'
|
: remoteOverallStatus(scope.row) === 'partial_failed'
|
||||||
? "远端部分失败"
|
? "远端部分失败"
|
||||||
: "未推送远端"
|
: "未推送远端"
|
||||||
}}
|
}}
|
||||||
@@ -142,8 +176,8 @@
|
|||||||
size="small"
|
size="small"
|
||||||
type="primary"
|
type="primary"
|
||||||
plain
|
plain
|
||||||
:disabled="!remoteMdFiles(scope.row).length"
|
:disabled="!hasRemoteFiles(scope.row)"
|
||||||
@click="copyAllMdLinks(remoteMdFiles(scope.row))"
|
@click="copyPreferredMdLinks(scope.row)"
|
||||||
>
|
>
|
||||||
一键复制MD
|
一键复制MD
|
||||||
</el-button>
|
</el-button>
|
||||||
@@ -179,24 +213,34 @@ const formatDateTime = (value?: string) => {
|
|||||||
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type RemoteProvider = "gitee" | "github";
|
||||||
|
|
||||||
const remoteConfigured = computed(() => {
|
const remoteConfigured = computed(() => {
|
||||||
return Boolean(summary.value.github?.configured);
|
return Boolean(summary.value.gitee?.configured || summary.value.github?.configured);
|
||||||
});
|
});
|
||||||
|
|
||||||
const remoteTitle = computed(() => {
|
const remoteTitle = computed(() => {
|
||||||
|
if (summary.value.gitee?.configured && summary.value.github?.configured) {
|
||||||
|
return "当前已同时配置 Gitee 和 GitHub 自动推送,生成后会分别返回可复制链接";
|
||||||
|
}
|
||||||
|
if (summary.value.gitee?.configured) {
|
||||||
|
return "当前已配置 Gitee 自动推送,生成后会返回 Gitee 可复制链接";
|
||||||
|
}
|
||||||
if (summary.value.github?.configured) {
|
if (summary.value.github?.configured) {
|
||||||
return "当前已配置 GitHub 自动推送,生成后会自动返回可复制链接";
|
return "当前已配置 GitHub 自动推送,生成后会返回 GitHub 可复制链接";
|
||||||
}
|
}
|
||||||
if (summary.value.github?.enabled) {
|
if (summary.value.gitee?.enabled || summary.value.github?.enabled) {
|
||||||
return "GitHub 推送已启用但未配完整,当前只能保留本地文件";
|
return "远端推送已启用但未配完整,当前可能只保留本地文件";
|
||||||
}
|
}
|
||||||
return "当前未启用 GitHub 推送,生成后仅保留本地文件";
|
return "当前未启用远端推送,生成后仅保留本地文件";
|
||||||
});
|
});
|
||||||
|
|
||||||
const remoteDescription = computed(() => {
|
const remoteDescription = computed(() => {
|
||||||
|
const gitee = summary.value.gitee || {};
|
||||||
const github = summary.value.github || {};
|
const github = summary.value.github || {};
|
||||||
|
const giteeRepo = gitee.owner && gitee.repo ? `${gitee.owner}/${gitee.repo}` : "未配置";
|
||||||
const githubRepo = github.owner && github.repo ? `${github.owner}/${github.repo}` : "未配置";
|
const githubRepo = github.owner && github.repo ? `${github.owner}/${github.repo}` : "未配置";
|
||||||
return `GitHub:${githubRepo} / ${github.branch || "-"} / ${github.root || "-"}`;
|
return `Gitee:${giteeRepo} / ${gitee.branch || "-"} / ${gitee.root || "-"};GitHub:${githubRepo} / ${github.branch || "-"} / ${github.root || "-"}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
const latestRunTitle = computed(() => {
|
const latestRunTitle = computed(() => {
|
||||||
@@ -214,37 +258,72 @@ const latestRunDescription = computed(() => {
|
|||||||
const runRoot = String(row.run_root || "").trim() || "-";
|
const runRoot = String(row.run_root || "").trim() || "-";
|
||||||
const githubStatus = String(row.github_push_status || "").trim();
|
const githubStatus = String(row.github_push_status || "").trim();
|
||||||
const githubError = String(row.github_push_error || "").trim();
|
const githubError = String(row.github_push_error || "").trim();
|
||||||
let pushed = "当前仅保留本地";
|
const giteeStatus = String(row.gitee_push_status || "").trim();
|
||||||
const pushError = githubError;
|
const giteeError = String(row.gitee_push_error || "").trim();
|
||||||
|
const statusParts: string[] = [];
|
||||||
|
const errorParts: string[] = [];
|
||||||
|
|
||||||
if (githubStatus === "success") {
|
statusParts.push(`Gitee ${statusLabel(giteeStatus)}`);
|
||||||
pushed = "已推送到 GitHub";
|
statusParts.push(`GitHub ${statusLabel(githubStatus)}`);
|
||||||
} else if (githubStatus === "failed" || githubStatus === "partial_failed") {
|
if (giteeError) errorParts.push(`Gitee:${giteeError}`);
|
||||||
pushed = githubStatus === "partial_failed" ? "本地生成成功,GitHub 部分推送后失败" : "本地生成成功,GitHub 推送失败";
|
if (githubError) errorParts.push(`GitHub:${githubError}`);
|
||||||
}
|
|
||||||
|
|
||||||
return `目录:${runRoot};文件数:${fileCount};链接数:${totalLinks};状态:${pushed}${pushError ? `;错误:${pushError}` : ""}`;
|
return `目录:${runRoot};文件数:${fileCount};链接数:${totalLinks};状态:${statusParts.join(" / ")}${errorParts.length ? `;错误:${errorParts.join(";")}` : ""}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
const remoteFiles = (row: SiteList.DomainSpiderMdRunSummaryItem) => {
|
const statusLabel = (status?: string) => {
|
||||||
return row.github_files || [];
|
if (status === "success") return "已推送";
|
||||||
|
if (status === "failed") return "失败";
|
||||||
|
if (status === "partial_failed") return "部分失败";
|
||||||
|
return "仅本地";
|
||||||
};
|
};
|
||||||
|
|
||||||
const remoteMdFiles = (row: SiteList.DomainSpiderMdRunSummaryItem) => {
|
const remoteFiles = (row: SiteList.DomainSpiderMdRunSummaryItem, provider: RemoteProvider) => {
|
||||||
return remoteFiles(row).filter(item => String(item?.file_name || "").toLowerCase().endsWith(".md"));
|
return provider === "github" ? (row.github_files || []) : (row.gitee_files || []);
|
||||||
};
|
};
|
||||||
|
|
||||||
const remoteStatus = (row: SiteList.DomainSpiderMdRunSummaryItem) => {
|
const remoteMdFiles = (row: SiteList.DomainSpiderMdRunSummaryItem, provider: RemoteProvider) => {
|
||||||
return String(row.github_push_status || "").trim();
|
return remoteFiles(row, provider).filter(item => String(item?.file_name || "").toLowerCase().endsWith(".md"));
|
||||||
|
};
|
||||||
|
|
||||||
|
const hasRemoteFiles = (row: SiteList.DomainSpiderMdRunSummaryItem) => {
|
||||||
|
return Boolean(remoteMdFiles(row, "gitee").length || remoteMdFiles(row, "github").length);
|
||||||
|
};
|
||||||
|
|
||||||
|
const remoteStatus = (row: SiteList.DomainSpiderMdRunSummaryItem, provider: RemoteProvider) => {
|
||||||
|
return String(provider === "github" ? row.github_push_status : row.gitee_push_status || "").trim();
|
||||||
|
};
|
||||||
|
|
||||||
|
const remoteOverallStatus = (row: SiteList.DomainSpiderMdRunSummaryItem) => {
|
||||||
|
const gitee = remoteStatus(row, "gitee");
|
||||||
|
const github = remoteStatus(row, "github");
|
||||||
|
const list = [gitee, github].filter(Boolean);
|
||||||
|
if (!list.length || list.every(item => !item || item === "local")) return "";
|
||||||
|
if (list.includes("failed")) return "failed";
|
||||||
|
if (list.includes("partial_failed")) return "partial_failed";
|
||||||
|
if (list.includes("success")) return "success";
|
||||||
|
return "";
|
||||||
|
};
|
||||||
|
|
||||||
|
const getRemoteLink = (item: { download_url?: string; html_url?: string }, provider: RemoteProvider) => {
|
||||||
|
if (provider === "github") {
|
||||||
|
return String(item?.html_url || item?.download_url || "").trim();
|
||||||
|
}
|
||||||
|
return String(item?.download_url || item?.html_url || "").trim();
|
||||||
};
|
};
|
||||||
|
|
||||||
const emptyRemoteDescription = (row: SiteList.DomainSpiderMdRunSummaryItem) => {
|
const emptyRemoteDescription = (row: SiteList.DomainSpiderMdRunSummaryItem) => {
|
||||||
|
const giteeStatus = String(row.gitee_push_status || "").trim();
|
||||||
|
const giteeError = String(row.gitee_push_error || "").trim();
|
||||||
const githubStatus = String(row.github_push_status || "").trim();
|
const githubStatus = String(row.github_push_status || "").trim();
|
||||||
const githubError = String(row.github_push_error || "").trim();
|
const githubError = String(row.github_push_error || "").trim();
|
||||||
|
if (giteeStatus === "failed" || giteeStatus === "partial_failed") {
|
||||||
|
return `Gitee 推送失败:${giteeError || "请查看任务日志"}`;
|
||||||
|
}
|
||||||
if (githubStatus === "failed" || githubStatus === "partial_failed") {
|
if (githubStatus === "failed" || githubStatus === "partial_failed") {
|
||||||
return `GitHub 推送失败:${githubError || "请查看任务日志"}`;
|
return `GitHub 推送失败:${githubError || "请查看任务日志"}`;
|
||||||
}
|
}
|
||||||
return "当前这轮还没有可复制的 GitHub 链接";
|
return "当前这轮还没有可复制的远端链接";
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
@@ -267,9 +346,9 @@ const copyText = async (text?: string) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const copyAllMdLinks = async (items: Array<{ download_url?: string; html_url?: string }>) => {
|
const copyAllMdLinks = async (items: Array<{ download_url?: string; html_url?: string }>, provider: RemoteProvider) => {
|
||||||
const lines = (items || [])
|
const lines = (items || [])
|
||||||
.map(item => String(item?.download_url || item?.html_url || "").trim())
|
.map(item => getRemoteLink(item, provider))
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
if (!lines.length) {
|
if (!lines.length) {
|
||||||
ElMessage.warning("当前没有可复制的MD链接");
|
ElMessage.warning("当前没有可复制的MD链接");
|
||||||
@@ -278,6 +357,20 @@ const copyAllMdLinks = async (items: Array<{ download_url?: string; html_url?: s
|
|||||||
await copyText(lines.join("\n"));
|
await copyText(lines.join("\n"));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const copyPreferredMdLinks = async (row: SiteList.DomainSpiderMdRunSummaryItem) => {
|
||||||
|
const githubItems = remoteMdFiles(row, "github");
|
||||||
|
if (githubItems.length) {
|
||||||
|
await copyAllMdLinks(githubItems, "github");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const giteeItems = remoteMdFiles(row, "gitee");
|
||||||
|
if (giteeItems.length) {
|
||||||
|
await copyAllMdLinks(giteeItems, "gitee");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ElMessage.warning("当前没有可复制的MD链接");
|
||||||
|
};
|
||||||
|
|
||||||
const runGenerate = async () => {
|
const runGenerate = async () => {
|
||||||
const res = await runDomainSpiderMdGenerate({});
|
const res = await runDomainSpiderMdGenerate({});
|
||||||
const jobId = String(res.data?.job?.job_id || "").trim();
|
const jobId = String(res.data?.job?.job_id || "").trim();
|
||||||
@@ -357,7 +450,19 @@ defineExpose({
|
|||||||
|
|
||||||
.spider-md-dialog__expand-toolbar {
|
.spider-md-dialog__expand-toolbar {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.spider-md-dialog__provider-block + .spider-md-dialog__provider-block {
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spider-md-dialog__provider-title {
|
||||||
|
margin-right: auto;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #303133;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user