feat: 生成页面根据 URL 查询参数预选 Base/Head
This commit is contained in:
@@ -113,12 +113,25 @@
|
|||||||
headSelect.appendChild(opt2);
|
headSelect.appendChild(opt2);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Auto-select main/master as base, HEAD as head
|
// Auto-select from URL params, or fall back to main/master and HEAD
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
const urlBase = params.get('base');
|
||||||
|
const urlHead = params.get('head');
|
||||||
|
|
||||||
const mainBranch = branches.find(b => b.name === 'main' || b.name === 'master');
|
const mainBranch = branches.find(b => b.name === 'main' || b.name === 'master');
|
||||||
const headBranch = branches.find(r => r.is_head);
|
const headBranch = branches.find(r => r.is_head);
|
||||||
|
|
||||||
if (mainBranch) baseSelect.value = mainBranch.name;
|
if (urlBase && branches.some(b => b.name === urlBase)) {
|
||||||
if (headBranch) headSelect.value = headBranch.name;
|
baseSelect.value = urlBase;
|
||||||
|
} else if (mainBranch) {
|
||||||
|
baseSelect.value = mainBranch.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (urlHead && branches.some(b => b.name === urlHead)) {
|
||||||
|
headSelect.value = urlHead;
|
||||||
|
} else if (headBranch) {
|
||||||
|
headSelect.value = headBranch.name;
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Load refs error:', err);
|
console.error('Load refs error:', err);
|
||||||
const errDiv = document.getElementById('load-error');
|
const errDiv = document.getElementById('load-error');
|
||||||
|
|||||||
Reference in New Issue
Block a user