完善联机模式(应用外)邀请功能-2

This commit is contained in:
shijian 2023-10-27 16:00:38 +08:00 committed by Tipx-L
parent fd9972f6f3
commit 70852b815f
2 changed files with 6 additions and 6 deletions

View File

@ -34867,12 +34867,14 @@
ui.rooms.push(player); ui.rooms.push(player);
} }
} }
if(get.config('read_clipboard','connect')){ if(!_status.requestReadClipboard&&get.config('read_clipboard','connect')){
//每次启动只请求一次
_status.requestReadClipboard=true;
function read(text){ function read(text){
try{ try{
var roomId=text.split('\n')[1].match(/\d+/); var roomId=text.split('\n')[1].match(/\d+/);
var caption=ui.rooms.find(caption=>caption.key==roomId); var caption=ui.rooms.find(caption=>caption.key==roomId);
if (caption&&(confirm(`是否通过复制的内容加入${roomId}房间?`)||_status.read_clipboard_text)){ if (caption&&(_status.read_clipboard_text||confirm(`是否通过复制的内容加入${roomId}房间?`))){
ui.click.connectroom.call(caption); ui.click.connectroom.call(caption);
delete _status.read_clipboard_text; delete _status.read_clipboard_text;
} }
@ -34891,7 +34893,6 @@
input.blur(); input.blur();
ui.window.removeChild(input); ui.window.removeChild(input);
if(result||input.value.length>0) read(input.value); if(result||input.value.length>0) read(input.value);
//也就小b兼容版不支持直接读取了
else if(confirm('是否输入邀请链接以加入房间?')){ else if(confirm('是否输入邀请链接以加入房间?')){
var text=prompt('请输入邀请链接'); var text=prompt('请输入邀请链接');
if(typeof text=='string'&&text.length>0) read(text); if(typeof text=='string'&&text.length>0) read(text);

View File

@ -141,7 +141,7 @@ game.import('mode',function(lib,game,ui,get,ai,_status){
}catch(e){console.log(e);} }catch(e){console.log(e);}
} }
window.focus(); window.focus();
if (navigator.clipboard){ if (navigator.clipboard&&lib.node){
navigator.clipboard.readText().then(read).catch(_=>{}); navigator.clipboard.readText().then(read).catch(_=>{});
}else{ }else{
var input=ui.create.node('textarea',ui.window,{opacity:'0'}); var input=ui.create.node('textarea',ui.window,{opacity:'0'});
@ -149,8 +149,7 @@ game.import('mode',function(lib,game,ui,get,ai,_status){
var result=document.execCommand('paste'); var result=document.execCommand('paste');
input.blur(); input.blur();
ui.window.removeChild(input); ui.window.removeChild(input);
if(result) read(input.value); if(result||input.value.length>0) read(input.value);
//也就小b兼容版不支持直接读取了
else if(confirm('是否输入邀请链接以进入联机地址和房间?')){ else if(confirm('是否输入邀请链接以进入联机地址和房间?')){
ced=true; ced=true;
var text=prompt('请输入邀请链接'); var text=prompt('请输入邀请链接');