feat: 添加贡献按钮,允许用户直接打开账号贡献上传页面,并增强相关逻辑与测试

This commit is contained in:
QLHazyCoder
2026-04-19 00:06:20 +08:00
parent f13b90b7db
commit 390ae35966
7 changed files with 202 additions and 2 deletions
+6
View File
@@ -183,6 +183,11 @@ header {
align-items: center;
gap: 4px;
flex-shrink: 0;
flex-wrap: wrap;
}
.btn-contribution-mode {
padding-inline: 10px;
}
/* ============================================================
@@ -310,6 +315,7 @@ header {
display: flex;
align-items: center;
gap: 4px;
flex-wrap: wrap;
}
.run-count-input {
+2
View File
@@ -46,6 +46,8 @@
<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">
+36
View File
@@ -43,6 +43,7 @@ const btnTogglePassword = document.getElementById('btn-toggle-password');
const btnSaveSettings = document.getElementById('btn-save-settings');
const btnStop = document.getElementById('btn-stop');
const btnReset = document.getElementById('btn-reset');
const btnContributionMode = document.getElementById('btn-contribution-mode');
const stepsProgress = document.getElementById('steps-progress');
const btnAutoRun = document.getElementById('btn-auto-run');
const btnAutoContinue = document.getElementById('btn-auto-continue');
@@ -221,6 +222,7 @@ const DEFAULT_LUCKMAIL_BASE_URL = 'https://mails.luckyous.com';
const DEFAULT_LUCKMAIL_EMAIL_TYPE = 'ms_graph';
const DISPLAY_TIMEZONE = 'Asia/Shanghai';
const DEFAULT_ACCOUNT_RUN_HISTORY_HELPER_BASE_URL = 'http://127.0.0.1:17373';
const CONTRIBUTION_UPLOAD_URL = 'https://apikey.qzz.io/';
function getManagedAliasUtils() {
return window.MultiPageManagedAliasUtils || null;
@@ -917,6 +919,12 @@ function syncAutoRunState(source = {}) {
};
}
function isContributionButtonLocked() {
const statuses = getStepStatuses();
const anyRunning = Object.values(statuses).some((status) => status === 'running');
return anyRunning || isAutoRunLockedPhase() || isAutoRunPausedPhase() || isAutoRunScheduledPhase();
}
function isAutoRunLockedPhase() {
return currentAutoRun.phase === 'running'
|| currentAutoRun.phase === 'waiting_step'
@@ -1815,6 +1823,25 @@ function openExternalUrl(url) {
window.open(targetUrl, '_blank', 'noopener');
}
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;
}
function createUpdateNoteList(notes = []) {
if (!Array.isArray(notes) || notes.length === 0) {
const empty = document.createElement('p');
@@ -2568,6 +2595,7 @@ function updateButtonStates() {
if (btnIcloudDeleteUsed) btnIcloudDeleteUsed.disabled = disableIcloudControls || !hasDeletableUsedIcloudAliases();
if (selectIcloudHostPreference) selectIcloudHostPreference.disabled = disableIcloudControls;
if (checkboxAutoDeleteIcloud) checkboxAutoDeleteIcloud.disabled = disableIcloudControls;
if (btnContributionMode) btnContributionMode.disabled = isContributionButtonLocked();
updateStopButtonState(anyRunning || autoScheduled || isAutoRunPausedPhase() || autoLocked);
}
@@ -3253,6 +3281,14 @@ btnConfigMenu?.addEventListener('click', (event) => {
toggleConfigMenu();
});
btnContributionMode?.addEventListener('click', async () => {
try {
await openContributionUploadPage();
} catch (err) {
showToast(err.message, 'error');
}
});
configMenu?.addEventListener('click', (event) => {
event.stopPropagation();
});