fix: 工具页剪贴板注入无反应——injectClipboard 函数在阶段3清理时被误删,点击按钮 JS 报错;补全函数(校验→ClipInject 通道 API→逐台结果表+toast 汇总),帮助文案同步更新
This commit is contained in:
@@ -44,6 +44,33 @@ function toggleClipDevice(cb){
|
||||
else _clipSelected.delete(cb.value);
|
||||
}
|
||||
|
||||
// 注入剪贴板(ClipInject APK 通道,Android 10+ 可用):
|
||||
// am start 透明 Activity 写入 + u2 读回比对验证;结果逐台渲染 + toast 汇总
|
||||
function injectClipboard(){
|
||||
const text = document.getElementById('clip-text').value;
|
||||
const serials = [..._clipSelected];
|
||||
if(!serials.length){showToast('请先勾选目标设备','error');return;}
|
||||
if(!text.trim()){showToast('请输入注入内容','error');return;}
|
||||
const btn = Array.from(document.querySelectorAll('#tools-sub-clipboard .btn-primary'))
|
||||
.find(b=>b.textContent.includes('注入剪贴板'));
|
||||
if(btn){btn.disabled = true; const old = btn.textContent; btn.textContent = '注入中...'; btn._old = old;}
|
||||
apiPost('/api/tools/clipboard/set', {serials, text}).then(r=>{
|
||||
if(!r){showToast('请求失败','error');return;}
|
||||
const rows = Object.entries(r.results||{}).map(([s,v])=>{
|
||||
const ok = !!v.ok;
|
||||
return '<tr><td style="font-family:monospace">'+esc(s)+'</td>'
|
||||
+'<td><span class="label '+(ok?'label-success':'label-danger')+'">'
|
||||
+(ok?'成功':'失败')+'</span> '+esc(v.msg||'')+'</td></tr>';
|
||||
}).join('');
|
||||
document.getElementById('clip-result').innerHTML = rows;
|
||||
document.getElementById('clip-result-wrap').style.display='block';
|
||||
const okc = r.ok_count||0, fail = r.fail_count||0;
|
||||
if(fail>0) showToast(okc+' 台成功,'+fail+' 台失败','error');
|
||||
else showToast(okc+' 台设备注入成功','success');
|
||||
}).catch(e=>{showToast('注入异常: '+e,'error');})
|
||||
.finally(()=>{ if(btn){btn.disabled=false; btn.textContent=btn._old;} });
|
||||
}
|
||||
|
||||
// ================== 工具:应用版本管理 ==================
|
||||
let _appVerRows = []; // [{serial, installed, version_name, version_code, error}]
|
||||
|
||||
|
||||
@@ -513,7 +513,7 @@ body{background:var(--bg);font-family:var(--body);color:var(--text);font-size:14
|
||||
<button class="btn btn-primary" onclick="injectClipboard()">注入剪贴板</button>
|
||||
<span class="hint">注入后需在目标 App 的输入框长按选择"粘贴"</span>
|
||||
</div>
|
||||
<div class="help">实现:u2 setClipboard(jsonrpc 直连 atx-agent),实测支持中文、引号、换行;USB 设备首次连接会自动推送 atx-agent。</div>
|
||||
<div class="help">实现:ClipInject APK 透明 Activity 写入剪贴板(Android 10+ 可用,u2 setClipboard 在 Android 12/13 会被系统丢弃);设备需先安装 com.example.clipinject,注入后自动读回比对验证。</div>
|
||||
</div>
|
||||
<div style="flex:1;min-width:280px">
|
||||
<div class="form-group">
|
||||
|
||||
Reference in New Issue
Block a user