feat: improve spider md github links and copy actions
This commit is contained in:
@@ -1530,8 +1530,13 @@ export namespace SiteList {
|
||||
gitee_push_attempted?: number;
|
||||
gitee_push_status?: string;
|
||||
gitee_push_error?: string;
|
||||
github_pushed?: number;
|
||||
github_push_attempted?: number;
|
||||
github_push_status?: string;
|
||||
github_push_error?: string;
|
||||
files?: DomainSpiderMdFileItem[];
|
||||
gitee_files?: DomainSpiderMdFileItem[];
|
||||
github_files?: DomainSpiderMdFileItem[];
|
||||
}
|
||||
|
||||
export interface DomainSpiderMdSummaryData {
|
||||
@@ -1564,6 +1569,15 @@ export namespace SiteList {
|
||||
root?: string;
|
||||
sources?: Record<string, string>;
|
||||
};
|
||||
github?: {
|
||||
enabled?: number;
|
||||
configured?: number;
|
||||
owner?: string;
|
||||
repo?: string;
|
||||
branch?: string;
|
||||
root?: string;
|
||||
sources?: Record<string, string>;
|
||||
};
|
||||
latest_run?: DomainSpiderMdRunSummaryItem | null;
|
||||
runs?: DomainSpiderMdRunSummaryItem[];
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
<el-button type="warning" plain @click="runForceGenerate">强制重生成</el-button>
|
||||
<el-button plain :disabled="!lastJobId" @click="reopenLastTask">继续查看任务</el-button>
|
||||
<el-button plain @click="loadData">刷新</el-button>
|
||||
<span class="spider-md-dialog__toolbar-note">当天若仅 Gitee 推送失败,可直接再次点击“生成并推送”重试,无需强制重生成。</span>
|
||||
<span class="spider-md-dialog__toolbar-note">当天若仅远端推送失败,可直接再次点击“生成并推送”重试,无需强制重生成。</span>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
:title="giteeTitle"
|
||||
:description="giteeDescription"
|
||||
:type="summary.gitee?.configured ? 'success' : 'warning'"
|
||||
:title="remoteTitle"
|
||||
:description="remoteDescription"
|
||||
:type="remoteConfigured ? 'success' : 'warning'"
|
||||
:closable="false"
|
||||
show-icon
|
||||
/>
|
||||
@@ -20,10 +20,15 @@
|
||||
<el-descriptions :column="2" border size="small">
|
||||
<el-descriptions-item label="本地目录">{{ summary.run_root || "-" }}</el-descriptions-item>
|
||||
<el-descriptions-item label="Gitee 根目录">{{ summary.gitee?.root || "-" }}</el-descriptions-item>
|
||||
<el-descriptions-item label="GitHub 根目录">{{ summary.github?.root || "-" }}</el-descriptions-item>
|
||||
<el-descriptions-item label="仓库">
|
||||
{{ summary.gitee?.owner && summary.gitee?.repo ? `${summary.gitee.owner}/${summary.gitee.repo}` : "-" }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="GitHub 仓库">
|
||||
{{ summary.github?.owner && summary.github?.repo ? `${summary.github.owner}/${summary.github.repo}` : "-" }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="分支">{{ summary.gitee?.branch || "-" }}</el-descriptions-item>
|
||||
<el-descriptions-item label="GitHub 分支">{{ summary.github?.branch || "-" }}</el-descriptions-item>
|
||||
<el-descriptions-item label="单文件上限">{{ summary.runtime_config?.max_links_per_file || "-" }}</el-descriptions-item>
|
||||
<el-descriptions-item label="详情/泛链">
|
||||
{{ summary.runtime_config?.detail_limit_per_host || 0 }} / {{ summary.runtime_config?.forge_limit_per_host || 0 }}
|
||||
@@ -35,6 +40,9 @@
|
||||
<el-descriptions-item label="配置来源">
|
||||
Gitee开关 {{ summary.gitee?.sources?.enabled || "-" }} / 根目录 {{ summary.gitee?.sources?.root || "-" }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="GitHub来源">
|
||||
GitHub开关 {{ summary.github?.sources?.enabled || "-" }} / 根目录 {{ summary.github?.sources?.root || "-" }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<el-alert
|
||||
@@ -48,7 +56,7 @@
|
||||
|
||||
<el-alert
|
||||
title="推荐配置方式:蜘蛛池MD 相关配置统一走后台系统配置"
|
||||
description="可后台维护:SPIDER_MD_MAX_LINKS_PER_FILE、各类链接上限、Gitee 开关/owner/repo/branch/root/token;token 在运行摘要中会自动打码,不直接回显。"
|
||||
description="可后台维护:SPIDER_MD_MAX_LINKS_PER_FILE、各类链接上限、Gitee / GitHub 开关、owner、repo、branch、root、token;token 在运行摘要中会自动打码,不直接回显。"
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
@@ -60,24 +68,17 @@
|
||||
<template #default="scope">
|
||||
<div class="spider-md-dialog__expand">
|
||||
<el-empty
|
||||
v-if="!(scope.row.gitee_files || []).length"
|
||||
:description="scope.row.gitee_push_status === 'failed' || scope.row.gitee_push_status === 'partial_failed'
|
||||
? `Gitee 推送失败:${scope.row.gitee_push_error || '请查看任务日志'}`
|
||||
: '当前这轮还没有可复制的 Gitee 链接'"
|
||||
v-if="!remoteFiles(scope.row).length"
|
||||
:description="emptyRemoteDescription(scope.row)"
|
||||
/>
|
||||
<template v-else>
|
||||
<div class="spider-md-dialog__expand-toolbar">
|
||||
<el-button size="small" type="primary" plain @click="copyAllHtmlLinks(scope.row.gitee_files || [])">批量复制页面链接</el-button>
|
||||
<el-button size="small" type="primary" plain @click="copyAllMdLinks(remoteMdFiles(scope.row))">一键复制MD链接</el-button>
|
||||
</div>
|
||||
<el-table :data="scope.row.gitee_files || []" border size="small">
|
||||
<el-table-column prop="file_name" label="文件" min-width="180" />
|
||||
<el-table-column prop="html_url" label="Gitee 链接" min-width="420" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="140" fixed="right">
|
||||
<template #default="fileScope">
|
||||
<el-button link type="primary" @click="copyText(fileScope.row.html_url)">复制页面链接</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<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>
|
||||
</div>
|
||||
</template>
|
||||
@@ -101,14 +102,14 @@
|
||||
<template #default="scope">
|
||||
<el-tag
|
||||
size="small"
|
||||
:type="scope.row.gitee_push_status === 'success' ? 'success' : (scope.row.gitee_push_status === 'failed' || scope.row.gitee_push_status === 'partial_failed' ? 'danger' : 'info')"
|
||||
:type="remoteStatus(scope.row) === 'success' ? 'success' : (remoteStatus(scope.row) === 'failed' || remoteStatus(scope.row) === 'partial_failed' ? 'danger' : 'info')"
|
||||
>
|
||||
{{
|
||||
scope.row.gitee_push_status === 'success'
|
||||
remoteStatus(scope.row) === 'success'
|
||||
? "已推送"
|
||||
: scope.row.gitee_push_status === 'failed'
|
||||
: remoteStatus(scope.row) === 'failed'
|
||||
? "推送失败"
|
||||
: scope.row.gitee_push_status === 'partial_failed'
|
||||
: remoteStatus(scope.row) === 'partial_failed'
|
||||
? "部分失败"
|
||||
: "仅本地"
|
||||
}}
|
||||
@@ -120,21 +121,34 @@
|
||||
<el-tag size="small" type="success">本地成功</el-tag>
|
||||
<el-tag
|
||||
size="small"
|
||||
:type="scope.row.gitee_push_status === 'success' ? 'success' : (scope.row.gitee_push_status === 'failed' || scope.row.gitee_push_status === 'partial_failed' ? 'danger' : 'info')"
|
||||
:type="remoteStatus(scope.row) === 'success' ? 'success' : (remoteStatus(scope.row) === 'failed' || remoteStatus(scope.row) === 'partial_failed' ? 'danger' : 'info')"
|
||||
style="margin-left:8px;"
|
||||
>
|
||||
{{
|
||||
scope.row.gitee_push_status === 'success'
|
||||
remoteStatus(scope.row) === 'success'
|
||||
? "远端成功"
|
||||
: scope.row.gitee_push_status === 'failed'
|
||||
: remoteStatus(scope.row) === 'failed'
|
||||
? "远端失败"
|
||||
: scope.row.gitee_push_status === 'partial_failed'
|
||||
: remoteStatus(scope.row) === 'partial_failed'
|
||||
? "远端部分失败"
|
||||
: "未推送远端"
|
||||
}}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="160" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
plain
|
||||
:disabled="!remoteMdFiles(scope.row).length"
|
||||
@click="copyAllMdLinks(remoteMdFiles(scope.row))"
|
||||
>
|
||||
一键复制MD
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</el-dialog>
|
||||
@@ -165,20 +179,26 @@ const formatDateTime = (value?: string) => {
|
||||
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
||||
};
|
||||
|
||||
const giteeTitle = computed(() => {
|
||||
if (summary.value.gitee?.configured) {
|
||||
return "当前已配置 Gitee 自动推送,生成后会自动返回可复制链接";
|
||||
}
|
||||
if (summary.value.gitee?.enabled) {
|
||||
return "Gitee 已启用但未配完整,当前只能保留本地文件";
|
||||
}
|
||||
return "当前未启用 Gitee 推送,生成后仅保留本地文件";
|
||||
const remoteConfigured = computed(() => {
|
||||
return Boolean(summary.value.gitee?.configured || summary.value.github?.configured);
|
||||
});
|
||||
|
||||
const giteeDescription = computed(() => {
|
||||
const remoteTitle = computed(() => {
|
||||
if (summary.value.gitee?.configured || summary.value.github?.configured) {
|
||||
return "当前已配置远端自动推送,生成后会自动返回可复制链接";
|
||||
}
|
||||
if (summary.value.gitee?.enabled || summary.value.github?.enabled) {
|
||||
return "远端推送已启用但未配完整,当前只能保留本地文件";
|
||||
}
|
||||
return "当前未启用远端推送,生成后仅保留本地文件";
|
||||
});
|
||||
|
||||
const remoteDescription = computed(() => {
|
||||
const gitee = summary.value.gitee || {};
|
||||
const repo = gitee.owner && gitee.repo ? `${gitee.owner}/${gitee.repo}` : "未配置仓库";
|
||||
return `仓库:${repo};分支:${gitee.branch || "-"};根目录:${gitee.root || "-"}`;
|
||||
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}` : "未配置";
|
||||
return `Gitee:${giteeRepo} / ${gitee.branch || "-"} / ${gitee.root || "-"};GitHub:${githubRepo} / ${github.branch || "-"} / ${github.root || "-"}`;
|
||||
});
|
||||
|
||||
const latestRunTitle = computed(() => {
|
||||
@@ -194,19 +214,60 @@ const latestRunDescription = computed(() => {
|
||||
const fileCount = Number(row.file_count || 0);
|
||||
const totalLinks = Number(row.total_links || 0);
|
||||
const runRoot = String(row.run_root || "").trim() || "-";
|
||||
const pushStatus = String(row.gitee_push_status || "").trim();
|
||||
const pushError = String(row.gitee_push_error || "").trim();
|
||||
const githubStatus = String(row.github_push_status || "").trim();
|
||||
const githubError = String(row.github_push_error || "").trim();
|
||||
const giteeStatus = String(row.gitee_push_status || "").trim();
|
||||
const giteeError = String(row.gitee_push_error || "").trim();
|
||||
let pushed = "当前仅保留本地";
|
||||
if (pushStatus === "success") {
|
||||
let pushError = "";
|
||||
|
||||
if (githubStatus === "success" && giteeStatus === "success") {
|
||||
pushed = "已推送到 GitHub 和 Gitee";
|
||||
} else if (githubStatus === "success") {
|
||||
pushed = "已推送到 GitHub";
|
||||
pushError = giteeError;
|
||||
} else if (giteeStatus === "success") {
|
||||
pushed = "已推送到 Gitee";
|
||||
} else if (pushStatus === "failed") {
|
||||
pushed = "本地生成成功,Gitee 推送失败";
|
||||
} else if (pushStatus === "partial_failed") {
|
||||
pushed = "本地生成成功,Gitee 部分推送后失败";
|
||||
pushError = githubError;
|
||||
} else if (githubStatus === "failed" || githubStatus === "partial_failed") {
|
||||
pushed = githubStatus === "partial_failed" ? "本地生成成功,GitHub 部分推送后失败" : "本地生成成功,GitHub 推送失败";
|
||||
pushError = githubError;
|
||||
} else if (giteeStatus === "failed" || giteeStatus === "partial_failed") {
|
||||
pushed = giteeStatus === "partial_failed" ? "本地生成成功,Gitee 部分推送后失败" : "本地生成成功,Gitee 推送失败";
|
||||
pushError = giteeError;
|
||||
}
|
||||
|
||||
return `目录:${runRoot};文件数:${fileCount};链接数:${totalLinks};状态:${pushed}${pushError ? `;错误:${pushError}` : ""}`;
|
||||
});
|
||||
|
||||
const remoteFiles = (row: SiteList.DomainSpiderMdRunSummaryItem) => {
|
||||
const githubFiles = row.github_files || [];
|
||||
if (githubFiles.length) return githubFiles;
|
||||
return row.gitee_files || [];
|
||||
};
|
||||
|
||||
const remoteMdFiles = (row: SiteList.DomainSpiderMdRunSummaryItem) => {
|
||||
return remoteFiles(row).filter(item => String(item?.file_name || "").toLowerCase().endsWith(".md"));
|
||||
};
|
||||
|
||||
const remoteStatus = (row: SiteList.DomainSpiderMdRunSummaryItem) => {
|
||||
return String(row.github_push_status || row.gitee_push_status || "").trim();
|
||||
};
|
||||
|
||||
const emptyRemoteDescription = (row: SiteList.DomainSpiderMdRunSummaryItem) => {
|
||||
const githubStatus = String(row.github_push_status || "").trim();
|
||||
const githubError = String(row.github_push_error || "").trim();
|
||||
const giteeStatus = String(row.gitee_push_status || "").trim();
|
||||
const giteeError = String(row.gitee_push_error || "").trim();
|
||||
if (githubStatus === "failed" || githubStatus === "partial_failed") {
|
||||
return `GitHub 推送失败:${githubError || "请查看任务日志"}`;
|
||||
}
|
||||
if (giteeStatus === "failed" || giteeStatus === "partial_failed") {
|
||||
return `Gitee 推送失败:${giteeError || "请查看任务日志"}`;
|
||||
}
|
||||
return "当前这轮还没有可复制的远端链接";
|
||||
};
|
||||
|
||||
const loadData = async () => {
|
||||
const res = await getDomainSpiderMdSummary({ limit: 10 });
|
||||
summary.value = res.data || {};
|
||||
@@ -227,10 +288,12 @@ const copyText = async (text?: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
const copyAllHtmlLinks = async (items: Array<{ html_url?: string }>) => {
|
||||
const lines = (items || []).map(item => String(item?.html_url || "").trim()).filter(Boolean);
|
||||
const copyAllMdLinks = async (items: Array<{ download_url?: string; html_url?: string }>) => {
|
||||
const lines = (items || [])
|
||||
.map(item => String(item?.download_url || item?.html_url || "").trim())
|
||||
.filter(Boolean);
|
||||
if (!lines.length) {
|
||||
ElMessage.warning("当前没有可复制的页面链接");
|
||||
ElMessage.warning("当前没有可复制的MD链接");
|
||||
return;
|
||||
}
|
||||
await copyText(lines.join("\n"));
|
||||
|
||||
Reference in New Issue
Block a user