feat: 更新贡献昵称逻辑,允许用户留空昵称并调整相关测试用例

This commit is contained in:
QLHazyCoder
2026-04-21 01:55:06 +08:00
parent 2d3111228e
commit 157f49592a
4 changed files with 5 additions and 6 deletions
+1 -1
View File
@@ -6619,7 +6619,7 @@ async function refreshOAuthUrlBeforeStep6(state) {
if (state?.contributionMode && contributionOAuthManager?.startContributionFlow) {
await addLog('步骤 7contributionMode=true,走公开贡献接口,正在申请 OAuth 登录地址...', 'info');
const contributionState = await contributionOAuthManager.startContributionFlow({
nickname: state.email,
nickname: state.contributionNickname || '',
openAuthTab: false,
stateOverride: state,
});
+1 -2
View File
@@ -247,9 +247,8 @@
function buildNickname(state = {}, preferredNickname = '') {
const nickname = normalizeString(preferredNickname)
|| normalizeString(state.email)
|| normalizeString(state.contributionNickname);
return nickname || 'codex-extension-user';
return nickname || '';
}
function buildContributionQq(state = {}, preferredQq = '') {
+1 -1
View File
@@ -112,7 +112,7 @@
<p id="contribution-mode-text" class="contribution-mode-text">当前账号将用于支持项目维护。扩展会自动申请贡献登录地址并持续跟踪授权状态;如检测到回调地址,会自动提交,无需手动复制。</p>
<div class="data-row contribution-mode-field">
<span class="data-label">贡献昵称</span>
<input type="text" id="input-contribution-nickname" class="data-input" placeholder="可留空,默认使用当前邮箱" />
<input type="text" id="input-contribution-nickname" class="data-input" placeholder="可留空,将显示为匿名贡献者" />
</div>
<div class="data-row contribution-mode-field">
<span class="data-label">QQ</span>
+2 -2
View File
@@ -421,7 +421,7 @@ test('contribution oauth manager starts session, opens auth url, submits callbac
assert.equal(startedState.contributionAuthTabId, 88);
assert.equal(tabCalls.length, 1);
assert.match(fetchCalls[0].url, /\/start$/);
assert.match(String(fetchCalls[0].options.body || ''), /"nickname":"user@example\.com"/);
assert.match(String(fetchCalls[0].options.body || ''), /"nickname":""/);
assert.match(String(fetchCalls[0].options.body || ''), /"qq":""/);
assert.match(fetchCalls[1].url, /\/status\?/);
@@ -511,7 +511,7 @@ return { refreshOAuthUrlBeforeStep6 };
{
type: 'contribution',
options: {
nickname: 'user@example.com',
nickname: '',
openAuthTab: false,
stateOverride: {
contributionMode: true,