fix
This commit is contained in:
@@ -544,39 +544,32 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="proxy">代理(可选)</label>
|
||||
<label for="proxy">代理 <span>*</span></label>
|
||||
<input
|
||||
id="proxy"
|
||||
placeholder="socks5://username:password@ipv4:port"
|
||||
placeholder="socks5://ip:port 或 socks5://user:pass@ip:port(必填,香港服务器不上代理必封号)"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<div class="small-label" style="margin-top: 4px;">socks5 代理,必填。服务器在香港,不上代理必封号。</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="device">登录设备类型</label>
|
||||
<select id="device">
|
||||
<option value="">自动</option>
|
||||
<option value="ipad">iPad</option>
|
||||
<option value="mac">Mac</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label> </label>
|
||||
<div class="checkbox-row">
|
||||
<input type="checkbox" id="check-proxy" />
|
||||
<label for="check-proxy">修改代理时自动检测可用性</label>
|
||||
</div>
|
||||
<label>登录方式</label>
|
||||
<div class="small-label" style="padding: 8px 0;">取码用 iPad;仅当「无数字」需滑块时用一次「重新取码(Mac)」</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<button class="primary" id="btn-qrcode">
|
||||
获取登录二维码
|
||||
1. 获取登录二维码
|
||||
</button>
|
||||
<button class="secondary" id="btn-qrcode-mac" title="仅当需滑块且手机无数字验证码时使用,取码后手机显示 Mac,再去滑块">
|
||||
重新取码(Mac)
|
||||
</button>
|
||||
<button class="secondary" id="btn-wake">
|
||||
唤醒
|
||||
</button>
|
||||
<button class="secondary" id="btn-check-scan">
|
||||
检测扫码状态
|
||||
<button class="secondary" id="btn-check-scan" title="state=2 为登录成功;若手机显示 Mac 登录,多点击几次会自动切 iPad">
|
||||
2. 检测扫码状态
|
||||
</button>
|
||||
<button class="secondary" id="btn-online">
|
||||
获取在线状态
|
||||
@@ -629,11 +622,12 @@
|
||||
|
||||
<div id="slider-area" style="display: none;">
|
||||
<div class="card" style="max-width: 480px;">
|
||||
<div class="card-title">滑块验证</div>
|
||||
<div class="card-title">滑块验证(无数字时:先点「重新取码(Mac)」,手机停确认页再滑)</div>
|
||||
<div class="small-label" style="margin-bottom: 8px;">Key 为 7765 服务方 QQ(408449830),与账号 key 无关。Data62=取码返回,Ticket=检测扫码状态返回(无乱码)。</div>
|
||||
<div id="slider-app" data-v-app="">
|
||||
<div class="params-section" style="margin-bottom: 12px;">
|
||||
<label class="form-label" for="keyInput">Key:</label>
|
||||
<input type="text" class="form-control" id="keyInput" placeholder="请输入key" style="width:100%;box-sizing:border-box;padding:8px;margin-bottom:8px;border:1px solid var(--border);border-radius:8px;background:rgba(15,23,42,0.6);color:var(--text);">
|
||||
<label class="form-label" for="keyInput">Key (7765 服务方):</label>
|
||||
<input type="text" class="form-control" id="keyInput" placeholder="408449830" style="width:100%;box-sizing:border-box;padding:8px;margin-bottom:8px;border:1px solid var(--border);border-radius:8px;background:rgba(15,23,42,0.6);color:var(--text);">
|
||||
<label class="form-label" for="data62Input">Data62:</label>
|
||||
<input type="text" class="form-control" id="data62Input" placeholder="请输入data62" style="width:100%;box-sizing:border-box;padding:8px;margin-bottom:8px;border:1px solid var(--border);border-radius:8px;background:rgba(15,23,42,0.6);color:var(--text);">
|
||||
<label class="form-label" for="originalTicketInput">Original Ticket:</label>
|
||||
@@ -755,6 +749,8 @@
|
||||
|
||||
function setLoading(loading) {
|
||||
$('btn-qrcode').disabled = loading;
|
||||
var btnQrcodeMac = $('btn-qrcode-mac');
|
||||
if (btnQrcodeMac) btnQrcodeMac.disabled = loading;
|
||||
var btnWake = $('btn-wake');
|
||||
if (btnWake) btnWake.disabled = loading;
|
||||
$('btn-check-scan').disabled = loading;
|
||||
@@ -762,20 +758,21 @@
|
||||
$('btn-logout').disabled = loading;
|
||||
}
|
||||
|
||||
function getCommonPayload() {
|
||||
function getCommonPayload(requireProxy) {
|
||||
const key = $('key').value.trim();
|
||||
const proxy = $('proxy').value.trim();
|
||||
const device = $('device').value;
|
||||
const check = $('check-proxy').checked;
|
||||
if (!key) {
|
||||
alert('请先填写账号唯一标识(key)');
|
||||
return null;
|
||||
}
|
||||
if (requireProxy && !proxy) {
|
||||
alert('请先填写 socks5 代理。服务器在香港,不上代理必封号。');
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
key,
|
||||
proxy: proxy || undefined,
|
||||
ipadOrMac: device,
|
||||
check,
|
||||
ipadOrMac: 'ipad',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -999,16 +996,46 @@
|
||||
return body;
|
||||
}
|
||||
|
||||
async function onGetQrCode() {
|
||||
async function onWake() {
|
||||
const payload = getCommonPayload();
|
||||
if (!payload) return;
|
||||
setLoading(true);
|
||||
try {
|
||||
log('请求登录二维码...');
|
||||
log('唤醒登录(仅扫码登录)...');
|
||||
const body = {
|
||||
key: payload.key,
|
||||
Check: !!payload.check,
|
||||
IpadOrmac: payload.ipadOrMac || 'ipad',
|
||||
Proxy: payload.proxy || '',
|
||||
};
|
||||
const data = await callApi('/auth/wake', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
log('唤醒请求已发送');
|
||||
if (data && typeof data === 'object' && (data.error || data.detail)) {
|
||||
log(JSON.stringify(data.error || data.detail), 'warn');
|
||||
}
|
||||
updateLoginState('已发送唤醒', 'pending', '如需扫码请点击「获取登录二维码」');
|
||||
} catch (e) {
|
||||
log('唤醒失败: ' + (e.message || e), 'error');
|
||||
updateLoginState('唤醒失败', 'offline', e.message || '');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function onGetQrCode(forceMac) {
|
||||
const payload = getCommonPayload(true);
|
||||
if (!payload) return;
|
||||
setLoading(true);
|
||||
try {
|
||||
log(forceMac ? '重新取码(Mac),用于无数字时走滑块…' : '请求登录二维码(iPad)...');
|
||||
const body = {
|
||||
Proxy: payload.proxy || '',
|
||||
IpadOrmac: payload.ipadOrMac || '',
|
||||
Check: !!payload.check,
|
||||
IpadOrmac: forceMac ? 'mac' : 'ipad',
|
||||
Check: false,
|
||||
force_mac: !!forceMac,
|
||||
};
|
||||
const data = await callApi('/auth/qrcode', {
|
||||
method: 'POST',
|
||||
@@ -1029,17 +1056,22 @@
|
||||
if (line3) log(line3);
|
||||
})();
|
||||
renderQrFromResponse(data);
|
||||
updateLoginState('等待扫码 / 确认中', 'pending', '请在 60 秒内使用微信扫码。');
|
||||
// 仅通过轮询检测扫码状态,不立即查状态(避免沿用上次的「需验证」误弹滑块)
|
||||
if (state.pollingScan) {
|
||||
clearInterval(state.pollingScan);
|
||||
updateLoginState(forceMac ? '已用 Mac 重新取码,请手机停在确认页并完成下方滑块' : '等待扫码 / 确认中', 'pending', forceMac ? '滑块 Key=408449830,Data62 已更新' : '请在 60 秒内使用微信扫码。');
|
||||
if (forceMac && data) {
|
||||
var newData62 = (data.Data && data.Data.Data62) || data.Data62 || data.data62 || '';
|
||||
if (newData62) {
|
||||
if (!state.sliderParams) state.sliderParams = {};
|
||||
state.sliderParams.data62 = newData62;
|
||||
state.sliderParams.key = state.sliderParams.key || '408449830';
|
||||
showSliderAreaAndFill(state.sliderParams);
|
||||
log('已用新 Data62 更新滑块区域,请完成滑块后到手机点确认。', 'warn');
|
||||
}
|
||||
}
|
||||
if (state.pollingScan) clearInterval(state.pollingScan);
|
||||
setTimeout(() => onCheckScanStatus(true), 2000);
|
||||
state.pollingScan = setInterval(() => {
|
||||
onCheckScanStatus(true);
|
||||
}, 5000);
|
||||
state.pollingScan = setInterval(() => { onCheckScanStatus(true); }, 5000);
|
||||
} catch (e) {
|
||||
log('获取二维码失败: ' + e.message, 'error');
|
||||
log('获取二维码失败: ' + (e.message || e), 'error');
|
||||
updateLoginState('二维码获取失败', 'offline', e.message || '');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -1047,7 +1079,7 @@
|
||||
}
|
||||
|
||||
async function onCheckScanStatus(silent = false) {
|
||||
const payload = getCommonPayload();
|
||||
const payload = getCommonPayload(false);
|
||||
if (!payload) return;
|
||||
if (!silent) setLoading(true);
|
||||
try {
|
||||
@@ -1172,17 +1204,15 @@
|
||||
if ($('slider-area') && $('slider-area').style.display !== 'none') {
|
||||
showQrArea();
|
||||
}
|
||||
onGetQrCode();
|
||||
onGetQrCode(false);
|
||||
});
|
||||
$('btn-qrcode-mac') && $('btn-qrcode-mac').addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
onGetQrCode(true);
|
||||
});
|
||||
$('btn-wake') && $('btn-wake').addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
var device = ($('device') && $('device').value) || '';
|
||||
if (device === 'mac') {
|
||||
if ($('slider-area') && $('slider-area').style.display !== 'none') showQrArea();
|
||||
onGetQrCode();
|
||||
} else {
|
||||
log('唤醒:请先将「登录设备类型」选为 Mac,再点击唤醒以获取二维码。', 'warn');
|
||||
}
|
||||
onWake();
|
||||
});
|
||||
$('btn-show-slider') && $('btn-show-slider').addEventListener('click', function() {
|
||||
if (state.sliderParams) showSliderAreaAndFill(state.sliderParams);
|
||||
|
||||
@@ -211,11 +211,6 @@
|
||||
<span id="ai-reply-status-text">—</span>
|
||||
<button type="button" class="secondary" id="btn-ai-reply-status" style="margin-left:8px;padding:2px 8px;font-size:12px">检查状态</button>
|
||||
</div>
|
||||
<div class="field full" style="margin-bottom:12px">
|
||||
<span class="small-label">消息回调(7006 → 本服务):</span>
|
||||
<span id="callback-status-text">—</span>
|
||||
<button type="button" class="secondary" id="btn-callback-status" style="margin-left:8px;padding:2px 8px;font-size:12px">检查回调</button>
|
||||
</div>
|
||||
<div class="mgmt-form-grid">
|
||||
<div class="field full">
|
||||
<label>超级管理员 wxid(每行一个或逗号分隔)</label>
|
||||
@@ -302,43 +297,27 @@
|
||||
}
|
||||
|
||||
async function loadAiReplyStatus() {
|
||||
const key = $('key').value.trim();
|
||||
const key = getKey();
|
||||
const el = $('ai-reply-status-text');
|
||||
if (!el) return;
|
||||
if (!key) { el.textContent = '请先登录'; return; }
|
||||
if (!key) { el.textContent = '请先登录'; el.style.color = 'var(--muted, #94a3b8)'; return; }
|
||||
el.textContent = '检测中…';
|
||||
try {
|
||||
const data = await callApi('/api/ai-reply-status?key=' + encodeURIComponent(key));
|
||||
el.textContent = data.ok ? '正常(WS 已连接,已配置白名单/超级管理员,已选模型)' : (data.message || '异常');
|
||||
el.style.color = data.ok ? 'var(--success, #22c55e)' : 'var(--muted, #94a3b8)';
|
||||
} catch (e) {
|
||||
el.textContent = '检查失败: ' + (e.message || e);
|
||||
el.style.color = 'var(--danger, #ef4444)';
|
||||
}
|
||||
}
|
||||
|
||||
async function loadCallbackStatus() {
|
||||
const key = getKey();
|
||||
const el = $('callback-status-text');
|
||||
if (!el) return;
|
||||
if (!key) { el.textContent = '请先登录'; el.style.color = 'var(--muted)'; return; }
|
||||
el.textContent = '检测中…';
|
||||
el.style.color = 'var(--muted)';
|
||||
el.style.color = 'var(--muted, #94a3b8)';
|
||||
try {
|
||||
const data = await callApi('/api/callback-status?key=' + encodeURIComponent(key));
|
||||
if (!data.configured) {
|
||||
el.textContent = '未配置(未设置 CALLBACK_BASE_URL,使用 WS 拉取消息)';
|
||||
el.textContent = '未配置回调(AI 未接管)';
|
||||
el.style.color = 'var(--muted, #94a3b8)';
|
||||
return;
|
||||
}
|
||||
if (data.registered === true) {
|
||||
el.textContent = '已配置且已向 7006 注册成功,新消息将推送到: ' + (data.callback_url || '');
|
||||
el.textContent = '回调已配置且注册成功(AI 已接管)';
|
||||
el.style.color = 'var(--success, #22c55e)';
|
||||
} else if (data.registered === false) {
|
||||
el.textContent = '已配置但向 7006 注册失败,请检查网络或 7006 服务。回调地址: ' + (data.callback_url || '');
|
||||
el.textContent = '回调已配置但注册失败(AI 未接管)';
|
||||
el.style.color = 'var(--danger, #ef4444)';
|
||||
} else {
|
||||
el.textContent = '已配置,回调地址: ' + (data.callback_url || '');
|
||||
el.textContent = '回调已配置(AI 接管状态未知,请检查 7006)';
|
||||
el.style.color = 'var(--muted, #94a3b8)';
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -403,7 +382,7 @@
|
||||
if (!key) { alert('请先登录'); return; }
|
||||
sel.innerHTML = '<option value="">加载中…</option>';
|
||||
try {
|
||||
const data = await callApi('/api/contact-list?key=' + encodeURIComponent(key), { cache: 'no-store' });
|
||||
const data = await callApi('/api/contact-list?key=' + encodeURIComponent(key) + '&refresh=1', { cache: 'no-store' });
|
||||
const list = data.items || [];
|
||||
lastLoadedContactList = list;
|
||||
if (data.error) {
|
||||
@@ -862,7 +841,6 @@
|
||||
}
|
||||
$('btn-ai-reply-save').addEventListener('click', async () => { await saveAiReplyConfig(); loadAiReplyStatus(); });
|
||||
$('btn-ai-reply-status') && $('btn-ai-reply-status').addEventListener('click', loadAiReplyStatus);
|
||||
$('btn-callback-status') && $('btn-callback-status').addEventListener('click', loadCallbackStatus);
|
||||
$('btn-pt-add').addEventListener('click', addProductTag);
|
||||
$('btn-push-group-add').addEventListener('click', createPushGroup);
|
||||
$('btn-push-send').addEventListener('click', doPushSend);
|
||||
|
||||
Reference in New Issue
Block a user