feat: 更新贡献上传URL逻辑,优化上传页面打开功能并更新相关测试用例

This commit is contained in:
QLHazyCoder
2026-04-21 12:40:26 +08:00
parent 239120c983
commit d85f7feaef
5 changed files with 25 additions and 7 deletions
+19 -2
View File
@@ -12,7 +12,7 @@
constants = {},
} = context;
const contributionUploadUrl = constants.contributionUploadUrl || 'https://apikey.qzz.io/';
const contributionUploadUrl = constants.contributionUploadUrl || 'https://apikey.qzz.io';
const pollIntervalMs = Math.max(1500, Math.floor(Number(constants.pollIntervalMs) || 2500));
const hiddenRows = [
@@ -173,6 +173,18 @@
return normalizeString(currentState.contributionStatusMessage) || DEFAULT_COPY;
}
function getContributionUploadPageUrl() {
return normalizeString(contributionUploadUrl);
}
function openContributionUploadPage() {
const targetUrl = getContributionUploadPageUrl();
if (!targetUrl) {
return;
}
helpers.openExternalUrl?.(targetUrl);
}
async function syncContributionProfile(partial = {}) {
const payload = {
nickname: normalizeString(partial.nickname),
@@ -360,6 +372,11 @@
return;
}
actionInFlight = true;
try {
openContributionUploadPage();
} catch (error) {
helpers.showToast?.(`打开上传页面失败:${error.message}`, 'error');
}
render();
try {
await enterContributionMode();
@@ -415,7 +432,7 @@
dom.btnOpenContributionUpload?.addEventListener('click', () => {
try {
helpers.openExternalUrl?.(contributionUploadUrl);
openContributionUploadPage();
} catch (error) {
helpers.showToast?.(`打开上传页面失败:${error.message}`, 'error');
}
+1 -1
View File
@@ -35,7 +35,7 @@
<div class="header-btns">
<div class="run-group">
<button id="btn-contribution-mode" class="btn btn-outline btn-sm btn-contribution-mode" type="button"
aria-pressed="false" title="进入贡献模式">贡献/使用</button>
aria-pressed="false" 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">
+1 -1
View File
@@ -3271,7 +3271,7 @@ const contributionModeManager = window.SidepanelContributionMode?.createContribu
},
constants: {
contributionOauthUrl: 'https://apikey.qzz.io/oauth/',
contributionUploadUrl: 'https://apikey.qzz.io/',
contributionUploadUrl: 'https://apikey.qzz.io',
},
});
const renderContributionMode = contributionModeManager?.render
+1 -1
View File
@@ -7,7 +7,7 @@ test('sidepanel html keeps a single contribution mode button in header', () => {
const matches = html.match(/id="btn-contribution-mode"/g) || [];
assert.equal(matches.length, 1);
assert.match(html, /id="btn-contribution-mode"[^>]*title="进入贡献模式"/);
assert.match(html, /id="btn-contribution-mode"[^>]*title="进入贡献模式并打开上传页"/);
assert.match(html, />贡献\/使用<\/button>/);
});
+3 -2
View File
@@ -393,7 +393,7 @@ test('contribution mode manager enters mode, starts main auto flow, polls contri
},
},
constants: {
contributionUploadUrl: 'https://apikey.qzz.io/',
contributionUploadUrl: 'https://apikey.qzz.io',
pollIntervalMs: 2500,
},
});
@@ -420,6 +420,7 @@ test('contribution mode manager enters mode, starts main auto flow, polls contri
assert.ok(updateSyncUiCount >= 1);
assert.ok(updateConfigMenuCount >= 1);
assert.equal(timers.length, 0);
assert.deepStrictEqual(openedUrls, ['https://apikey.qzz.io']);
dom.inputContributionNickname.value = '贡献者昵称';
dom.inputContributionQq.value = '123456';
@@ -440,7 +441,7 @@ test('contribution mode manager enters mode, starts main auto flow, polls contri
assert.equal(dom.contributionModeSummary.textContent, '\u5df2\u63d0\u4ea4\u56de\u8c03\uff0c\u7b49\u5f85 CPA \u786e\u8ba4');
dom.btnOpenContributionUpload.listeners.click();
assert.deepStrictEqual(openedUrls, ['https://apikey.qzz.io/']);
assert.deepStrictEqual(openedUrls, ['https://apikey.qzz.io', 'https://apikey.qzz.io']);
await dom.btnExitContributionMode.listeners.click();
manager.render();