Plua模式开发
This commit is contained in:
@@ -212,6 +212,28 @@
|
||||
<button id="btn-toggle-password" class="input-icon-btn" type="button" aria-label="显示密码" title="显示密码"></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-row" id="row-plus-mode">
|
||||
<span class="data-label">Plus 模式</span>
|
||||
<div class="data-inline setting-pair">
|
||||
<div class="setting-group setting-group-primary">
|
||||
<label class="toggle-switch" for="input-plus-mode-enabled" title="开启后使用 Plus Checkout + PayPal 授权流程">
|
||||
<input type="checkbox" id="input-plus-mode-enabled" />
|
||||
<span class="toggle-switch-track" aria-hidden="true">
|
||||
<span class="toggle-switch-thumb"></span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<span class="setting-caption">PayPal 订阅链路</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-row" id="row-paypal-email" style="display:none;">
|
||||
<span class="data-label">PayPal 账号</span>
|
||||
<input type="text" id="input-paypal-email" class="data-input" placeholder="请输入 PayPal 登录邮箱" />
|
||||
</div>
|
||||
<div class="data-row" id="row-paypal-password" style="display:none;">
|
||||
<span class="data-label">PayPal 密码</span>
|
||||
<input type="password" id="input-paypal-password" class="data-input" placeholder="请输入 PayPal 登录密码" />
|
||||
</div>
|
||||
<div class="data-row">
|
||||
<span class="data-label">邮箱服务</span>
|
||||
<div class="data-inline">
|
||||
|
||||
+105
-5
@@ -99,6 +99,12 @@ const inputCodex2ApiUrl = document.getElementById('input-codex2api-url');
|
||||
const rowCodex2ApiAdminKey = document.getElementById('row-codex2api-admin-key');
|
||||
const inputCodex2ApiAdminKey = document.getElementById('input-codex2api-admin-key');
|
||||
const rowCustomPassword = document.getElementById('row-custom-password');
|
||||
const rowPlusMode = document.getElementById('row-plus-mode');
|
||||
const inputPlusModeEnabled = document.getElementById('input-plus-mode-enabled');
|
||||
const rowPaypalEmail = document.getElementById('row-paypal-email');
|
||||
const inputPaypalEmail = document.getElementById('input-paypal-email');
|
||||
const rowPaypalPassword = document.getElementById('row-paypal-password');
|
||||
const inputPaypalPassword = document.getElementById('input-paypal-password');
|
||||
const selectMailProvider = document.getElementById('select-mail-provider');
|
||||
const btnMailLogin = document.getElementById('btn-mail-login');
|
||||
const rowCustomMailProviderPool = document.getElementById('row-custom-mail-provider-pool');
|
||||
@@ -244,11 +250,12 @@ const btnAutoStartCancel = document.getElementById('btn-auto-start-cancel');
|
||||
const btnAutoStartRestart = document.getElementById('btn-auto-start-restart');
|
||||
const btnAutoStartContinue = document.getElementById('btn-auto-start-continue');
|
||||
const autoHintText = document.querySelector('.auto-hint');
|
||||
const stepDefinitions = (window.MultiPageStepDefinitions?.getSteps?.() || []).sort((left, right) => left.order - right.order);
|
||||
const STEP_IDS = stepDefinitions.map((step) => Number(step.id)).filter(Number.isFinite);
|
||||
const STEP_DEFAULT_STATUSES = Object.fromEntries(STEP_IDS.map((stepId) => [stepId, 'pending']));
|
||||
const SKIPPABLE_STEPS = new Set(STEP_IDS);
|
||||
const stepsList = document.querySelector('.steps-list');
|
||||
let currentPlusModeEnabled = false;
|
||||
let stepDefinitions = getStepDefinitionsForMode(false);
|
||||
let STEP_IDS = stepDefinitions.map((step) => Number(step.id)).filter(Number.isFinite);
|
||||
let STEP_DEFAULT_STATUSES = Object.fromEntries(STEP_IDS.map((stepId) => [stepId, 'pending']));
|
||||
let SKIPPABLE_STEPS = new Set(STEP_IDS);
|
||||
const AUTO_DELAY_MIN_MINUTES = 1;
|
||||
const AUTO_DELAY_MAX_MINUTES = 1440;
|
||||
const AUTO_DELAY_DEFAULT_MINUTES = 30;
|
||||
@@ -269,6 +276,24 @@ const DEFAULT_MAIL_2925_MODE = MAIL_2925_MODE_PROVIDE;
|
||||
const NEW_USER_GUIDE_PROMPT_DISMISSED_STORAGE_KEY = 'multipage-new-user-guide-prompt-dismissed';
|
||||
const AUTO_SKIP_FAILURES_PROMPT_DISMISSED_STORAGE_KEY = 'multipage-auto-skip-failures-prompt-dismissed';
|
||||
const AUTO_RUN_FALLBACK_RISK_PROMPT_DISMISSED_STORAGE_KEY = 'multipage-auto-run-fallback-risk-prompt-dismissed';
|
||||
|
||||
function getStepDefinitionsForMode(plusModeEnabled = false) {
|
||||
return (window.MultiPageStepDefinitions?.getSteps?.({ plusModeEnabled }) || [])
|
||||
.sort((left, right) => {
|
||||
const leftOrder = Number.isFinite(left.order) ? left.order : left.id;
|
||||
const rightOrder = Number.isFinite(right.order) ? right.order : right.id;
|
||||
if (leftOrder !== rightOrder) return leftOrder - rightOrder;
|
||||
return left.id - right.id;
|
||||
});
|
||||
}
|
||||
|
||||
function rebuildStepDefinitionState(plusModeEnabled = false) {
|
||||
currentPlusModeEnabled = Boolean(plusModeEnabled);
|
||||
stepDefinitions = getStepDefinitionsForMode(currentPlusModeEnabled);
|
||||
STEP_IDS = stepDefinitions.map((step) => Number(step.id)).filter(Number.isFinite);
|
||||
STEP_DEFAULT_STATUSES = Object.fromEntries(STEP_IDS.map((stepId) => [stepId, 'pending']));
|
||||
SKIPPABLE_STEPS = new Set(STEP_IDS);
|
||||
}
|
||||
const CONTRIBUTION_CONTENT_PROMPT_DISMISSED_VERSION_STORAGE_KEY = 'multipage-contribution-content-prompt-dismissed-version';
|
||||
const AUTO_RUN_FALLBACK_RISK_WARNING_MIN_RUNS = 3;
|
||||
const HOTMAIL_SERVICE_MODE_REMOTE = 'remote';
|
||||
@@ -1100,7 +1125,8 @@ function isDoneStatus(status) {
|
||||
}
|
||||
|
||||
function getStepStatuses(state = latestState) {
|
||||
return { ...STEP_DEFAULT_STATUSES, ...(state?.stepStatuses || {}) };
|
||||
const merged = { ...STEP_DEFAULT_STATUSES, ...(state?.stepStatuses || {}) };
|
||||
return Object.fromEntries(STEP_IDS.map((stepId) => [stepId, merged[stepId] || 'pending']));
|
||||
}
|
||||
|
||||
function getFirstUnfinishedStep(state = latestState) {
|
||||
@@ -1690,6 +1716,15 @@ function collectSettingsPayload() {
|
||||
sub2apiDefaultProxyName: inputSub2ApiDefaultProxy.value.trim(),
|
||||
codex2apiUrl: inputCodex2ApiUrl.value.trim(),
|
||||
codex2apiAdminKey: inputCodex2ApiAdminKey.value.trim(),
|
||||
plusModeEnabled: typeof inputPlusModeEnabled !== 'undefined' && inputPlusModeEnabled
|
||||
? Boolean(inputPlusModeEnabled.checked)
|
||||
: Boolean(latestState?.plusModeEnabled),
|
||||
paypalEmail: typeof inputPaypalEmail !== 'undefined' && inputPaypalEmail
|
||||
? inputPaypalEmail.value.trim()
|
||||
: String(latestState?.paypalEmail || ''),
|
||||
paypalPassword: typeof inputPaypalPassword !== 'undefined' && inputPaypalPassword
|
||||
? inputPaypalPassword.value
|
||||
: String(latestState?.paypalPassword || ''),
|
||||
...(contributionModeEnabled ? {} : {
|
||||
customPassword: inputPassword.value,
|
||||
}),
|
||||
@@ -1924,6 +1959,21 @@ function updatePhoneVerificationSettingsUI() {
|
||||
});
|
||||
}
|
||||
|
||||
function updatePlusModeUI() {
|
||||
const enabled = typeof inputPlusModeEnabled !== 'undefined' && inputPlusModeEnabled
|
||||
? Boolean(inputPlusModeEnabled.checked)
|
||||
: false;
|
||||
[
|
||||
typeof rowPaypalEmail !== 'undefined' ? rowPaypalEmail : null,
|
||||
typeof rowPaypalPassword !== 'undefined' ? rowPaypalPassword : null,
|
||||
].forEach((row) => {
|
||||
if (!row) {
|
||||
return;
|
||||
}
|
||||
row.style.display = enabled ? '' : 'none';
|
||||
});
|
||||
}
|
||||
|
||||
function setSettingsCardLocked(locked) {
|
||||
if (!settingsCard) {
|
||||
return;
|
||||
@@ -2104,6 +2154,9 @@ function applyAutoRunStatus(payload = currentAutoRun) {
|
||||
|
||||
function initializeManualStepActions() {
|
||||
document.querySelectorAll('.step-row').forEach((row) => {
|
||||
if (row.querySelector('.step-actions')) {
|
||||
return;
|
||||
}
|
||||
const step = Number(row.dataset.step);
|
||||
const statusEl = row.querySelector('.step-status');
|
||||
if (!statusEl) return;
|
||||
@@ -2147,6 +2200,21 @@ function renderStepsList() {
|
||||
if (stepsProgress) {
|
||||
stepsProgress.textContent = `0 / ${STEP_IDS.length}`;
|
||||
}
|
||||
|
||||
initializeManualStepActions();
|
||||
updateProgressCounter();
|
||||
updateButtonStates();
|
||||
}
|
||||
|
||||
function syncStepDefinitionsForMode(plusModeEnabled = false, options = {}) {
|
||||
const nextPlusModeEnabled = Boolean(plusModeEnabled);
|
||||
const shouldRender = Boolean(options.render) || nextPlusModeEnabled !== currentPlusModeEnabled;
|
||||
if (!shouldRender) {
|
||||
return;
|
||||
}
|
||||
|
||||
rebuildStepDefinitionState(nextPlusModeEnabled);
|
||||
renderStepsList();
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
@@ -2154,11 +2222,23 @@ function renderStepsList() {
|
||||
// ============================================================
|
||||
|
||||
function applySettingsState(state) {
|
||||
if (typeof syncStepDefinitionsForMode === 'function') {
|
||||
syncStepDefinitionsForMode(Boolean(state?.plusModeEnabled), { render: true });
|
||||
}
|
||||
syncLatestState(state);
|
||||
syncAutoRunState(state);
|
||||
|
||||
inputEmail.value = state?.email || '';
|
||||
syncPasswordField(state || {});
|
||||
if (typeof inputPlusModeEnabled !== 'undefined' && inputPlusModeEnabled) {
|
||||
inputPlusModeEnabled.checked = Boolean(state?.plusModeEnabled);
|
||||
}
|
||||
if (typeof inputPaypalEmail !== 'undefined' && inputPaypalEmail) {
|
||||
inputPaypalEmail.value = state?.paypalEmail || '';
|
||||
}
|
||||
if (typeof inputPaypalPassword !== 'undefined' && inputPaypalPassword) {
|
||||
inputPaypalPassword.value = state?.paypalPassword || '';
|
||||
}
|
||||
inputVpsUrl.value = state?.vpsUrl || '';
|
||||
inputVpsPassword.value = state?.vpsPassword || '';
|
||||
setLocalCpaStep9Mode(state?.localCpaStep9Mode);
|
||||
@@ -2277,6 +2357,9 @@ function applySettingsState(state) {
|
||||
updateFallbackThreadIntervalInputState();
|
||||
updateAccountRunHistorySettingsUI();
|
||||
updatePhoneVerificationSettingsUI();
|
||||
if (typeof updatePlusModeUI === 'function') {
|
||||
updatePlusModeUI();
|
||||
}
|
||||
updatePanelModeUI();
|
||||
updateMailProviderUI();
|
||||
if (isLuckmailProvider(state?.mailProvider)) {
|
||||
@@ -4651,6 +4734,23 @@ inputPassword.addEventListener('blur', () => {
|
||||
saveSettings({ silent: true }).catch(() => { });
|
||||
});
|
||||
|
||||
inputPlusModeEnabled?.addEventListener('change', () => {
|
||||
updatePlusModeUI();
|
||||
syncStepDefinitionsForMode(Boolean(inputPlusModeEnabled.checked), { render: true });
|
||||
markSettingsDirty(true);
|
||||
saveSettings({ silent: true }).catch(() => { });
|
||||
});
|
||||
|
||||
[inputPaypalEmail, inputPaypalPassword].forEach((input) => {
|
||||
input?.addEventListener('input', () => {
|
||||
markSettingsDirty(true);
|
||||
scheduleSettingsAutoSave();
|
||||
});
|
||||
input?.addEventListener('blur', () => {
|
||||
saveSettings({ silent: true }).catch(() => { });
|
||||
});
|
||||
});
|
||||
|
||||
selectMailProvider.addEventListener('change', async () => {
|
||||
const previousProvider = latestState?.mailProvider || '';
|
||||
const previousMail2925Mode = latestState?.mail2925Mode;
|
||||
|
||||
Reference in New Issue
Block a user