feat: add Luban SMS provider

This commit is contained in:
chick
2026-05-31 19:13:45 +08:00
parent 2b127d070b
commit 09ccc76e71
5 changed files with 239 additions and 90 deletions
+24 -6
View File
@@ -177,9 +177,12 @@
function collectSettings() {
return {
provider: $('.sb-provider')?.value || 'sms-bower',
apiKey: $('.sb-api-key')?.value.trim() || '',
baseUrl: $('.sb-base-url')?.value.trim() || '',
lubanBaseUrl: $('.sb-luban-base-url')?.value.trim() || '',
serviceCode: $('.sb-service-code')?.value.trim() || 'dr',
lubanServiceId: $('.sb-luban-service-id')?.value.trim() || '',
minPrice: $('.sb-min-price')?.value.trim() || '',
maxPrice: $('.sb-max-price')?.value.trim() || '',
countries: selectedCountries,
@@ -246,6 +249,13 @@
btn.classList.toggle('sb-auto-on', autoRotateEnabled);
}
function updateProviderFields() {
const provider = $('.sb-provider')?.value || 'sms-bower';
const isLuban = provider === 'luban-sms';
panel?.querySelectorAll('.sb-smsbower-only').forEach((el) => { el.style.display = isLuban ? 'none' : ''; });
panel?.querySelectorAll('.sb-luban-only').forEach((el) => { el.style.display = isLuban ? '' : 'none'; });
}
function getCurrentPhoneNumber() {
const phone = $('.sb-current-phone')?.textContent || latestSettings?.activeActivation?.phoneNumber || '';
return String(phone).trim();
@@ -416,7 +426,7 @@
#${PANEL_ID} .sb-title { font-size: 16px; font-weight: 700; }
#${PANEL_ID} .sb-close { width: 28px; height: 28px; padding: 0; border: 1px solid #334155; border-radius: 8px; color: #e5e7eb; background: #1f2937; cursor: pointer; }
#${PANEL_ID} label { display: grid; gap: 4px; margin: 7px 0; color: #cbd5e1; }
#${PANEL_ID} input { width: 100%; padding: 7px 9px; border: 1px solid #334155; border-radius: 8px; color: #e5e7eb; background: #111827; outline: none; }
#${PANEL_ID} input, #${PANEL_ID} select { width: 100%; padding: 7px 9px; border: 1px solid #334155; border-radius: 8px; color: #e5e7eb; background: #111827; outline: none; }
#${PANEL_ID} input:focus { border-color: #38bdf8; box-shadow: 0 0 0 2px rgba(56,189,248,.18); }
#${PANEL_ID} .sb-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
#${PANEL_ID} .sb-country-box { margin-top: 9px; padding: 9px; border: 1px solid #253244; border-radius: 10px; background: #111827; }
@@ -450,19 +460,22 @@
panel.id = PANEL_ID;
panel.innerHTML = `
<div class="sb-head">
<span class="sb-title">SMSBower 填号</span>
<span class="sb-title">接码填号</span>
<button class="sb-close" type="button" title="隐藏">×</button>
</div>
<button class="sb-fetch sb-primary sb-top-fetch" type="button">获取并填入</button>
<button class="sb-auto-toggle sb-auto-on" type="button">自动切号:开</button>
<label>API Key <input class="sb-api-key" type="password" placeholder="SMSBower API Key" /></label>
<label>API 地址 <input class="sb-base-url" type="url" /></label>
<label>接码平台 <select class="sb-provider"><option value="sms-bower">SMSBower</option><option value="luban-sms">Luban SMS</option></select></label>
<label>API Key <input class="sb-api-key" type="password" placeholder="API Key / apikey" /></label>
<label class="sb-smsbower-only">SMSBower API 地址 <input class="sb-base-url" type="url" /></label>
<label class="sb-luban-only">Luban API 地址 <input class="sb-luban-base-url" type="url" /></label>
<div class="sb-row">
<label>项目 <input class="sb-service-code" type="text" value="dr" /></label>
<label class="sb-smsbower-only">SMSBower 项目 <input class="sb-service-code" type="text" value="dr" /></label>
<label class="sb-luban-only">Luban service_id <input class="sb-luban-service-id" type="text" placeholder="如 121949" /></label>
<label>最低价 <input class="sb-min-price" type="number" min="0" step="0.0001" placeholder="可空" /></label>
<label>最高价 <input class="sb-max-price" type="number" min="0" step="0.0001" placeholder="可空" /></label>
</div>
<section class="sb-country-box">
<section class="sb-country-box sb-smsbower-only">
<div class="sb-country-head"><strong>国家顺序</strong><button class="sb-refresh" type="button">刷新国家</button></div>
<input class="sb-country-search" type="search" placeholder="搜索国家 / ID" />
<div class="sb-selected-countries"></div>
@@ -497,6 +510,7 @@
function bindPanelEvents() {
$('.sb-close').addEventListener('click', () => { panel.style.display = 'none'; });
$('.sb-save').addEventListener('click', saveSettings);
$('.sb-provider').addEventListener('change', updateProviderFields);
$('.sb-fetch').addEventListener('click', () => fetchAndFill({ reason: 'manual_replace', releaseAction: 'cancel' }));
$('.sb-auto-toggle').addEventListener('click', () => {
autoRotateEnabled = !autoRotateEnabled;
@@ -540,9 +554,12 @@
latestSettings = res.settings;
allCountries = (res.fallbackCountries || FALLBACK_COUNTRIES).map(normalizeCountry);
selectedCountries = (latestSettings.countries || []).map(normalizeCountry);
$('.sb-provider').value = latestSettings.provider || 'sms-bower';
$('.sb-api-key').value = latestSettings.apiKey || '';
$('.sb-base-url').value = latestSettings.baseUrl || '';
$('.sb-luban-base-url').value = latestSettings.lubanBaseUrl || 'https://lubansms.com/v2/api';
$('.sb-service-code').value = latestSettings.serviceCode || 'dr';
$('.sb-luban-service-id').value = latestSettings.lubanServiceId || '';
$('.sb-min-price').value = latestSettings.minPrice || '';
$('.sb-max-price').value = latestSettings.maxPrice || '';
if (latestSettings.activeActivation) {
@@ -551,6 +568,7 @@
const codeNode = $('.sb-current-code');
if (codeNode) codeNode.textContent = latestSettings.activeActivation.lastCode || '无';
}
updateProviderFields();
renderCountries();
}