127 lines
3.0 KiB
JavaScript
127 lines
3.0 KiB
JavaScript
/*******************************************************************************
|
|
*
|
|
* Nx SDK管理器
|
|
*
|
|
*
|
|
*
|
|
* 2021.12.10
|
|
******************************************************************************/
|
|
|
|
const SDKBase = require( "nx.sdk.base" );
|
|
|
|
const NxSDKWeb = cc.Class( {
|
|
|
|
extends: SDKBase,
|
|
name: "NxSDKWeb",
|
|
|
|
// ============================================
|
|
// 设备信息
|
|
// ============================================
|
|
|
|
// 设备ID
|
|
getDeviceID: function() {
|
|
|
|
let storage = cc.sys.localStorage;
|
|
let id = storage ? storage.getItem( "NX_DEVICE_ID" ) : null;
|
|
if( !id ) {
|
|
id = "DEV" + cc.sys.now();
|
|
storage.setItem( "NX_DEVICE_ID", id );
|
|
}
|
|
return id;
|
|
},
|
|
|
|
// 包版本
|
|
getPackVersion: function() {
|
|
return "1.0.1";
|
|
},
|
|
|
|
// 包参数
|
|
getPackArgs: function() {
|
|
|
|
let args = {
|
|
gname : "fc", // 游戏名
|
|
cnn : "", // 渠道名
|
|
lang : "tw", // 初始语种
|
|
ssl : 0, // SSL
|
|
gm : "0", // GM模式
|
|
log : 0, // 日志等级
|
|
};
|
|
|
|
args.cnn = nx.dt.queryURLArg( "ch" ) || "dev";
|
|
args.gm = "1";//CC_DEBUG ? "1" : "0";
|
|
args.log = nx.dt.queryURLArg( "vl" ) || 0;
|
|
|
|
return args;
|
|
},
|
|
|
|
// PHP路径列表
|
|
getPHPURLs: function() {
|
|
|
|
let php = nx.dt.queryURLArg( "cfg" );
|
|
if( nx.dt.strNEmpty( php ) ) {
|
|
return [php];
|
|
}
|
|
|
|
return [
|
|
"twsa.qa.fitfun.net:8310"
|
|
];
|
|
},
|
|
|
|
// ============================================
|
|
// 剪贴板
|
|
// ============================================
|
|
|
|
// 复制
|
|
setClipboard: function( _text ) {
|
|
|
|
let input = _text + "";
|
|
const el = document.createElement( "textarea" );
|
|
el.value = input;
|
|
el.setAttribute( "readonly", "" );
|
|
el.style.contain = "strict";
|
|
el.style.position = "absolute";
|
|
el.style.left = "-9999px";
|
|
el.style.fontSize = "12pt"; // Prevent zooming on iOS
|
|
|
|
const selection = getSelection();
|
|
let originalRange = false;
|
|
if( selection.rangeCount > 0 ) {
|
|
originalRange = selection.getRangeAt( 0 );
|
|
}
|
|
document.body.appendChild( el );
|
|
el.select();
|
|
el.selectionStart = 0;
|
|
el.selectionEnd = input.length;
|
|
|
|
let success = false;
|
|
try {
|
|
success = document.execCommand( "copy" );
|
|
} catch( err ) {
|
|
}
|
|
|
|
document.body.removeChild( el );
|
|
|
|
if( originalRange ) {
|
|
selection.removeAllRanges();
|
|
selection.addRange( originalRange );
|
|
}
|
|
|
|
return success;
|
|
},
|
|
|
|
// 粘贴
|
|
getClipboard: function() {
|
|
nx.warn( "$SDK:WEB该功能尚未实现!" );
|
|
return "";
|
|
},
|
|
|
|
// ============================================
|
|
// 第三方支持
|
|
// ============================================
|
|
|
|
|
|
} );
|
|
|
|
// 模块导出
|
|
module.exports = NxSDKWeb;
|