feat: 增加 Git 标签清单策略和接口
This commit is contained in:
@@ -84,6 +84,7 @@ const policyForm = reactive<any>({
|
||||
min_supported_version: "",
|
||||
valid_until: "",
|
||||
message: "",
|
||||
git_tags_enabled: false,
|
||||
policy_seq: null
|
||||
});
|
||||
const currentPolicy = reactive<any>({
|
||||
@@ -95,6 +96,7 @@ const currentPolicy = reactive<any>({
|
||||
min_supported_version: "",
|
||||
valid_until: "2099-12-31T23:59:59Z",
|
||||
disabled_versions: [],
|
||||
git_tags_enabled: false,
|
||||
message: "",
|
||||
policy_seq: null,
|
||||
saved: false
|
||||
@@ -139,6 +141,10 @@ const releaseManifestError = ref("");
|
||||
const installRootDetectMessage = ref("");
|
||||
const installRootDialogVisible = ref(false);
|
||||
const installRootDialogReason = ref("");
|
||||
const gitTagsPreview = ref("");
|
||||
const gitTagsSummary = ref("");
|
||||
const gitTagsLoading = ref(false);
|
||||
const gitTagsError = ref("");
|
||||
let dashboardResizeObserver: ResizeObserver | null = null;
|
||||
|
||||
const enabledChannels = computed(() =>
|
||||
@@ -693,6 +699,42 @@ async function loadPolicy() {
|
||||
disabled_versions: data?.disabled_versions || []
|
||||
});
|
||||
policyDisabledText.value = (data?.disabled_versions || []).join(", ");
|
||||
if (policyForm.git_tags_enabled) {
|
||||
await loadGitTagsPreview(false);
|
||||
} else {
|
||||
gitTagsPreview.value = "";
|
||||
gitTagsSummary.value = "";
|
||||
gitTagsError.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
async function loadGitTagsPreview(forceRefresh = true) {
|
||||
gitTagsLoading.value = true;
|
||||
gitTagsError.value = "";
|
||||
try {
|
||||
const data = await adminRequest<any>(
|
||||
`/admin/git/tags?force_refresh=${forceRefresh ? "true" : "false"}`
|
||||
);
|
||||
gitTagsPreview.value = data?.tags_text || "";
|
||||
gitTagsSummary.value = `仓库 ${data?.repo_count || 0} 个,标签 ${data?.tag_count || 0} 个,生成时间 ${data?.generated_at || "未知"}`;
|
||||
} catch (error) {
|
||||
gitTagsPreview.value = "";
|
||||
gitTagsSummary.value = "";
|
||||
gitTagsError.value = friendlyError(error);
|
||||
ElMessage.error(`获取 Git 标签失败:${gitTagsError.value}`);
|
||||
} finally {
|
||||
gitTagsLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handlePolicyGitTagsChange(value: boolean) {
|
||||
if (value) {
|
||||
await loadGitTagsPreview(true);
|
||||
} else {
|
||||
gitTagsPreview.value = "";
|
||||
gitTagsSummary.value = "";
|
||||
gitTagsError.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
async function savePolicy() {
|
||||
@@ -1407,6 +1449,9 @@ test_file/*
|
||||
<el-descriptions-item label="离线启动">
|
||||
<el-tag :type="currentPolicy.offline_allowed ? 'success' : 'warning'">{{ currentPolicy.offline_allowed ? "允许" : "禁止" }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="Git 标签清单">
|
||||
<el-tag :type="currentPolicy.git_tags_enabled ? 'success' : 'info'">{{ currentPolicy.git_tags_enabled ? "生成" : "不生成" }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="最低支持版本">{{ currentPolicy.min_supported_version || "无" }}</el-descriptions-item>
|
||||
<el-descriptions-item label="有效期">{{ currentPolicy.valid_until || "未设置" }}</el-descriptions-item>
|
||||
<el-descriptions-item label="禁用版本" :span="3">{{ currentPolicyDisabledText }}</el-descriptions-item>
|
||||
@@ -1423,6 +1468,26 @@ test_file/*
|
||||
<el-checkbox v-model="policyForm.force_update">强制更新</el-checkbox>
|
||||
<el-checkbox v-model="policyForm.allow_rollback">允许回滚</el-checkbox>
|
||||
<el-checkbox v-model="policyForm.offline_allowed">允许离线启动</el-checkbox>
|
||||
<el-checkbox v-model="policyForm.git_tags_enabled" @change="handlePolicyGitTagsChange">允许 Launcher 生成 Git 标签清单</el-checkbox>
|
||||
</div>
|
||||
<div v-if="policyForm.git_tags_enabled" class="git-tags-preview" v-loading="gitTagsLoading">
|
||||
<div class="card-header-row">
|
||||
<div>
|
||||
<strong>Git 标签清单预览</strong>
|
||||
<div class="field-help">服务端使用 Gitea Token 拉取仓库和标签,页面只展示整理后的结果,不会暴露 Token。</div>
|
||||
</div>
|
||||
<el-button :loading="gitTagsLoading" @click="loadGitTagsPreview(true)">刷新标签</el-button>
|
||||
</div>
|
||||
<el-alert
|
||||
v-if="gitTagsError"
|
||||
class="mt-sm"
|
||||
type="error"
|
||||
:closable="false"
|
||||
show-icon
|
||||
:title="gitTagsError"
|
||||
/>
|
||||
<div v-if="gitTagsSummary" class="field-help">{{ gitTagsSummary }}</div>
|
||||
<pre class="code-block git-tags-code">{{ gitTagsPreview || "尚未获取 Git 标签清单" }}</pre>
|
||||
</div>
|
||||
<el-input v-model="policyForm.message" type="textarea" :rows="3" placeholder="策略消息,可空" />
|
||||
<el-button class="mt-sm" type="primary" @click="savePolicy">保存策略</el-button>
|
||||
@@ -2083,6 +2148,15 @@ test_file/*
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.git-tags-preview {
|
||||
padding: 14px;
|
||||
margin: 16px 0;
|
||||
background: linear-gradient(135deg, #f8fbff, #fff);
|
||||
border: 1px solid rgb(64 158 255 / 18%);
|
||||
border-left: 4px solid #2563eb;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.card-header-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -2313,6 +2387,12 @@ test_file/*
|
||||
min-height: 96px;
|
||||
}
|
||||
|
||||
.git-tags-code {
|
||||
min-height: 160px;
|
||||
max-height: 320px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.metric-grid,
|
||||
.form-grid,
|
||||
|
||||
Reference in New Issue
Block a user