feat: 添加账号运行历史功能,支持独立配置与文本留档
This commit is contained in:
@@ -288,6 +288,22 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-row">
|
||||
<span class="data-label">本地留档</span>
|
||||
<div class="data-inline">
|
||||
<label class="toggle-switch" for="input-account-run-history-text-enabled">
|
||||
<input type="checkbox" id="input-account-run-history-text-enabled" />
|
||||
<span class="toggle-switch-track" aria-hidden="true">
|
||||
<span class="toggle-switch-thumb"></span>
|
||||
</span>
|
||||
</label>
|
||||
<span class="data-value">同步写入账号运行历史 txt</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-row" id="row-account-run-history-helper-base-url" style="display:none;">
|
||||
<span class="data-label">留档服务</span>
|
||||
<input type="text" id="input-account-run-history-helper-base-url" class="data-input mono" placeholder="http://127.0.0.1:17373" />
|
||||
</div>
|
||||
<div class="data-row">
|
||||
<span class="data-label">OAuth</span>
|
||||
<span id="display-oauth-url" class="data-value mono truncate">等待中...</span>
|
||||
|
||||
@@ -164,6 +164,9 @@ const inputAutoSkipFailuresThreadIntervalMinutes = document.getElementById('inpu
|
||||
const inputAutoDelayEnabled = document.getElementById('input-auto-delay-enabled');
|
||||
const inputAutoDelayMinutes = document.getElementById('input-auto-delay-minutes');
|
||||
const inputAutoStepDelaySeconds = document.getElementById('input-auto-step-delay-seconds');
|
||||
const inputAccountRunHistoryTextEnabled = document.getElementById('input-account-run-history-text-enabled');
|
||||
const rowAccountRunHistoryHelperBaseUrl = document.getElementById('row-account-run-history-helper-base-url');
|
||||
const inputAccountRunHistoryHelperBaseUrl = document.getElementById('input-account-run-history-helper-base-url');
|
||||
const autoStartModal = document.getElementById('auto-start-modal');
|
||||
const autoStartTitle = autoStartModal?.querySelector('.modal-title');
|
||||
const autoStartMessage = document.getElementById('auto-start-message');
|
||||
@@ -207,6 +210,7 @@ const LUCKMAIL_PROVIDER = 'luckmail-api';
|
||||
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';
|
||||
|
||||
let latestState = null;
|
||||
let currentAutoRun = {
|
||||
@@ -1140,6 +1144,8 @@ function collectSettingsPayload() {
|
||||
emailGenerator: selectEmailGenerator.value,
|
||||
autoDeleteUsedIcloudAlias: checkboxAutoDeleteIcloud?.checked,
|
||||
icloudHostPreference: selectIcloudHostPreference?.value || 'auto',
|
||||
accountRunHistoryTextEnabled: Boolean(inputAccountRunHistoryTextEnabled?.checked),
|
||||
accountRunHistoryHelperBaseUrl: normalizeAccountRunHistoryHelperBaseUrlValue(inputAccountRunHistoryHelperBaseUrl?.value),
|
||||
emailPrefix: inputEmailPrefix.value.trim(),
|
||||
inbucketHost: inputInbucketHost.value.trim(),
|
||||
inbucketMailbox: inputInbucketMailbox.value.trim(),
|
||||
@@ -1193,6 +1199,30 @@ function normalizeHotmailServiceMode(value = '') {
|
||||
: HOTMAIL_SERVICE_MODE_LOCAL;
|
||||
}
|
||||
|
||||
function normalizeAccountRunHistoryHelperBaseUrlValue(value = '') {
|
||||
const trimmed = String(value || '').trim();
|
||||
if (!trimmed) {
|
||||
return DEFAULT_ACCOUNT_RUN_HISTORY_HELPER_BASE_URL;
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = new URL(trimmed);
|
||||
if (!['http:', 'https:'].includes(parsed.protocol)) {
|
||||
return DEFAULT_ACCOUNT_RUN_HISTORY_HELPER_BASE_URL;
|
||||
}
|
||||
|
||||
if (parsed.pathname === '/append-account-log') {
|
||||
parsed.pathname = '';
|
||||
parsed.search = '';
|
||||
parsed.hash = '';
|
||||
}
|
||||
|
||||
return parsed.toString().replace(/\/$/, '');
|
||||
} catch {
|
||||
return DEFAULT_ACCOUNT_RUN_HISTORY_HELPER_BASE_URL;
|
||||
}
|
||||
}
|
||||
|
||||
function getSelectedLocalCpaStep9Mode() {
|
||||
const activeButton = localCpaStep9ModeButtons.find((button) => button.classList.contains('is-active'));
|
||||
return normalizeLocalCpaStep9Mode(activeButton?.dataset.localCpaStep9Mode);
|
||||
@@ -1251,6 +1281,14 @@ function setHotmailServiceMode(mode) {
|
||||
});
|
||||
}
|
||||
|
||||
function updateAccountRunHistorySettingsUI() {
|
||||
if (!rowAccountRunHistoryHelperBaseUrl || !inputAccountRunHistoryTextEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
rowAccountRunHistoryHelperBaseUrl.style.display = inputAccountRunHistoryTextEnabled.checked ? '' : 'none';
|
||||
}
|
||||
|
||||
function setSettingsCardLocked(locked) {
|
||||
if (!settingsCard) {
|
||||
return;
|
||||
@@ -1518,6 +1556,12 @@ function applySettingsState(state) {
|
||||
if (checkboxAutoDeleteIcloud) {
|
||||
checkboxAutoDeleteIcloud.checked = Boolean(state?.autoDeleteUsedIcloudAlias);
|
||||
}
|
||||
if (inputAccountRunHistoryTextEnabled) {
|
||||
inputAccountRunHistoryTextEnabled.checked = Boolean(state?.accountRunHistoryTextEnabled);
|
||||
}
|
||||
if (inputAccountRunHistoryHelperBaseUrl) {
|
||||
inputAccountRunHistoryHelperBaseUrl.value = normalizeAccountRunHistoryHelperBaseUrlValue(state?.accountRunHistoryHelperBaseUrl);
|
||||
}
|
||||
inputEmailPrefix.value = state?.emailPrefix || '';
|
||||
inputInbucketHost.value = state?.inbucketHost || '';
|
||||
inputInbucketMailbox.value = state?.inbucketMailbox || '';
|
||||
@@ -1549,6 +1593,7 @@ function applySettingsState(state) {
|
||||
markSettingsDirty(false);
|
||||
updateAutoDelayInputState();
|
||||
updateFallbackThreadIntervalInputState();
|
||||
updateAccountRunHistorySettingsUI();
|
||||
updatePanelModeUI();
|
||||
updateMailProviderUI();
|
||||
if (isLuckmailProvider(state?.mailProvider)) {
|
||||
@@ -3758,6 +3803,22 @@ inputAutoDelayMinutes.addEventListener('blur', () => {
|
||||
saveSettings({ silent: true }).catch(() => { });
|
||||
});
|
||||
|
||||
inputAccountRunHistoryTextEnabled?.addEventListener('change', () => {
|
||||
updateAccountRunHistorySettingsUI();
|
||||
markSettingsDirty(true);
|
||||
saveSettings({ silent: true }).catch(() => { });
|
||||
});
|
||||
|
||||
inputAccountRunHistoryHelperBaseUrl?.addEventListener('input', () => {
|
||||
markSettingsDirty(true);
|
||||
scheduleSettingsAutoSave();
|
||||
});
|
||||
|
||||
inputAccountRunHistoryHelperBaseUrl?.addEventListener('blur', () => {
|
||||
inputAccountRunHistoryHelperBaseUrl.value = normalizeAccountRunHistoryHelperBaseUrlValue(inputAccountRunHistoryHelperBaseUrl.value);
|
||||
saveSettings({ silent: true }).catch(() => { });
|
||||
});
|
||||
|
||||
function syncAutoStepDelayInputs() {
|
||||
inputAutoStepDelaySeconds.value = formatAutoStepDelayInputValue(inputAutoStepDelaySeconds.value);
|
||||
}
|
||||
@@ -3938,6 +3999,13 @@ chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
||||
if (message.payload.autoDeleteUsedIcloudAlias !== undefined && checkboxAutoDeleteIcloud) {
|
||||
checkboxAutoDeleteIcloud.checked = Boolean(message.payload.autoDeleteUsedIcloudAlias);
|
||||
}
|
||||
if (message.payload.accountRunHistoryTextEnabled !== undefined && inputAccountRunHistoryTextEnabled) {
|
||||
inputAccountRunHistoryTextEnabled.checked = Boolean(message.payload.accountRunHistoryTextEnabled);
|
||||
updateAccountRunHistorySettingsUI();
|
||||
}
|
||||
if (message.payload.accountRunHistoryHelperBaseUrl !== undefined && inputAccountRunHistoryHelperBaseUrl) {
|
||||
inputAccountRunHistoryHelperBaseUrl.value = normalizeAccountRunHistoryHelperBaseUrlValue(message.payload.accountRunHistoryHelperBaseUrl);
|
||||
}
|
||||
if (message.payload.icloudHostPreference !== undefined && selectIcloudHostPreference) {
|
||||
const hostPreference = String(message.payload.icloudHostPreference || '').trim().toLowerCase();
|
||||
selectIcloudHostPreference.value = hostPreference === 'icloud.com'
|
||||
|
||||
Reference in New Issue
Block a user