feat: 添加侧边栏贡献按钮,优化打开上传页面逻辑,更新相关测试
This commit is contained in:
@@ -118,6 +118,30 @@ header {
|
||||
|
||||
.header-left svg { color: var(--blue); }
|
||||
|
||||
.header-icon-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
appearance: none;
|
||||
}
|
||||
|
||||
.header-icon-link:hover svg {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.header-icon-link:focus-visible,
|
||||
.header-version-link:focus-visible {
|
||||
outline: 2px solid color-mix(in srgb, var(--blue) 28%, transparent);
|
||||
outline-offset: 2px;
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.header-version-block {
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
@@ -144,6 +168,22 @@ header {
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.header-version-link {
|
||||
display: block;
|
||||
padding: 0;
|
||||
border: none;
|
||||
background: transparent;
|
||||
font: inherit;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
appearance: none;
|
||||
}
|
||||
|
||||
.header-version-link:hover {
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 2px;
|
||||
}
|
||||
|
||||
.header-version-title.is-version-label { color: var(--blue); }
|
||||
.header-version-title.is-update-available { color: var(--orange); }
|
||||
.header-version-title.is-check-failed { color: var(--text-primary); }
|
||||
|
||||
@@ -16,13 +16,17 @@
|
||||
<body>
|
||||
<header>
|
||||
<div class="header-left">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
|
||||
stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z" />
|
||||
</svg>
|
||||
<button id="btn-repo-home" class="header-icon-link" type="button" aria-label="打开 GitHub 仓库"
|
||||
title="打开 GitHub 仓库">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
|
||||
stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||
<path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z" />
|
||||
</svg>
|
||||
</button>
|
||||
<div class="header-version-block">
|
||||
<div class="header-version-main">
|
||||
<div id="extension-update-status" class="header-version-title">Pro0.0</div>
|
||||
<button id="extension-update-status" class="header-version-title header-version-link" type="button"
|
||||
aria-label="打开 GitHub Releases 页面" title="打开 GitHub Releases 页面">Pro0.0</button>
|
||||
<button id="btn-release-log" class="header-link-btn" type="button" hidden>更新日志</button>
|
||||
</div>
|
||||
<span id="extension-version-meta" class="header-version-meta" hidden></span>
|
||||
@@ -30,6 +34,8 @@
|
||||
</div>
|
||||
<div class="header-btns">
|
||||
<div class="run-group">
|
||||
<button id="btn-contribution-mode" class="btn btn-outline btn-sm btn-contribution-mode" type="button"
|
||||
title="打开账号贡献上传页面">贡献</button>
|
||||
<input type="number" id="input-run-count" class="run-count-input" value="1" min="1" max="50" title="运行次数" />
|
||||
<button id="btn-auto-run" class="btn btn-success" title="自动执行全部步骤">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor">
|
||||
@@ -46,8 +52,6 @@
|
||||
<path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10" />
|
||||
</svg>
|
||||
</button>
|
||||
<button id="btn-contribution-mode" class="btn btn-outline btn-sm btn-contribution-mode" type="button"
|
||||
title="打开账号贡献上传页面">贡献</button>
|
||||
<button id="btn-theme" class="theme-toggle" title="切换主题">
|
||||
<svg class="icon-moon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
|
||||
+45
-10
@@ -22,6 +22,7 @@ const btnAccountRecordsNext = document.getElementById('btn-account-records-next'
|
||||
const btnCloseAccountRecords = document.getElementById('btn-close-account-records');
|
||||
const btnClearAccountRecords = document.getElementById('btn-clear-account-records');
|
||||
const updateSection = document.getElementById('update-section');
|
||||
const btnRepoHome = document.getElementById('btn-repo-home');
|
||||
const extensionUpdateStatus = document.getElementById('extension-update-status');
|
||||
const extensionVersionMeta = document.getElementById('extension-version-meta');
|
||||
const btnReleaseLog = document.getElementById('btn-release-log');
|
||||
@@ -1823,21 +1824,47 @@ function openExternalUrl(url) {
|
||||
window.open(targetUrl, '_blank', 'noopener');
|
||||
}
|
||||
|
||||
function getRepositoryHomeUrl() {
|
||||
const serviceRepositoryUrl = String(sidepanelUpdateService?.repositoryUrl || '').trim();
|
||||
if (serviceRepositoryUrl) {
|
||||
return serviceRepositoryUrl;
|
||||
}
|
||||
|
||||
const releasesPageUrl = String(sidepanelUpdateService?.releasesPageUrl || '').trim();
|
||||
if (releasesPageUrl) {
|
||||
return releasesPageUrl.replace(/\/releases\/?$/, '');
|
||||
}
|
||||
|
||||
return 'https://github.com/QLHazyCoder/codex-oauth-automation-extension';
|
||||
}
|
||||
|
||||
function getReleaseListUrl() {
|
||||
const snapshotReleaseListUrl = String(currentReleaseSnapshot?.releasesPageUrl || '').trim();
|
||||
if (snapshotReleaseListUrl) {
|
||||
return snapshotReleaseListUrl;
|
||||
}
|
||||
|
||||
const serviceReleaseListUrl = String(sidepanelUpdateService?.releasesPageUrl || '').trim();
|
||||
if (serviceReleaseListUrl) {
|
||||
return serviceReleaseListUrl;
|
||||
}
|
||||
|
||||
return `${getRepositoryHomeUrl()}/releases`;
|
||||
}
|
||||
|
||||
function openRepositoryHomePage() {
|
||||
openExternalUrl(getRepositoryHomeUrl());
|
||||
}
|
||||
|
||||
function openReleaseListPage() {
|
||||
openExternalUrl(getReleaseListUrl());
|
||||
}
|
||||
|
||||
async function openContributionUploadPage() {
|
||||
if (isContributionButtonLocked()) {
|
||||
throw new Error('当前流程运行中,请先停止后再打开贡献页面。');
|
||||
}
|
||||
|
||||
const confirmed = await openConfirmModal({
|
||||
title: '账号贡献',
|
||||
message: '确认打开账号贡献上传页面吗?',
|
||||
confirmLabel: '前往上传',
|
||||
confirmVariant: 'btn-primary',
|
||||
});
|
||||
if (!confirmed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
openExternalUrl(CONTRIBUTION_UPLOAD_URL);
|
||||
return true;
|
||||
}
|
||||
@@ -3289,6 +3316,14 @@ btnContributionMode?.addEventListener('click', async () => {
|
||||
}
|
||||
});
|
||||
|
||||
btnRepoHome?.addEventListener('click', () => {
|
||||
openRepositoryHomePage();
|
||||
});
|
||||
|
||||
extensionUpdateStatus?.addEventListener('click', () => {
|
||||
openReleaseListPage();
|
||||
});
|
||||
|
||||
configMenu?.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user