mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 00:22:43 +08:00
Removes wx API invocations for JSB projects. (#2668)
* Removes wx API invocation for JSB projects. * sys.openURL fix for JSB. * touches, mouse, keyboard capabilities check.
This commit is contained in:
@@ -24,30 +24,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
window.CC_JSB = true;
|
||||
window.CC_WECHATGAME = true; //FIXME: remove CC_WECHATGAME
|
||||
|
||||
// Simulate wechat game API:
|
||||
|
||||
//FIXME: remove wx
|
||||
window.wx = {
|
||||
getSystemInfoSync() {
|
||||
return {
|
||||
platform: 'mac',
|
||||
language: 'CN',
|
||||
system: 1.0,
|
||||
windowWidth: window.innerWidth,
|
||||
windowHeight: window.innerHeight,
|
||||
};
|
||||
},
|
||||
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
onHide() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
window.CanvasRenderingContext2D = cc.CanvasRenderingContext2D;
|
||||
delete cc.CanvasRenderingContext2D;
|
||||
|
||||
@@ -45,7 +45,7 @@ class Audio extends HTMLAudioElement {
|
||||
//
|
||||
// _src.set(this, '')
|
||||
//
|
||||
// const innerAudioContext = {};//cjh wx.createInnerAudioContext()
|
||||
// const innerAudioContext = {};
|
||||
//
|
||||
// _innerAudioContext.set(this, innerAudioContext)
|
||||
//
|
||||
|
||||
@@ -29,6 +29,12 @@ class HTMLVideoElement extends HTMLMediaElement {
|
||||
constructor() {
|
||||
super('video')
|
||||
}
|
||||
|
||||
canPlayType(type) {
|
||||
if (type === 'video/mp4')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = HTMLVideoElement;
|
||||
|
||||
@@ -29,6 +29,7 @@ class Node extends EventTarget {
|
||||
constructor() {
|
||||
super()
|
||||
this.childNodes = []
|
||||
this.parentNode = window.__cccanvas;
|
||||
}
|
||||
|
||||
appendChild(node) {
|
||||
|
||||
@@ -25,16 +25,13 @@
|
||||
|
||||
let { noop } = require('./util');
|
||||
|
||||
// TODO 需要 wx.getSystemInfo 获取更详细信息
|
||||
// cjh const { platform } = wx.getSystemInfoSync()
|
||||
const navigator = {
|
||||
platform: 'wx', //cjh added wx
|
||||
language: 'zh-cn',
|
||||
platform: __getOS(),
|
||||
language: __getCurrentLanguage(),
|
||||
appVersion: '5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1',
|
||||
userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Mobile/14E8301 NetType/WIFI Language/zh_CN',
|
||||
onLine: true, // TODO 用 wx.getNetworkStateChange 和 wx.onNetworkStateChange 来返回真实的状态
|
||||
onLine: true, //FIXME:
|
||||
|
||||
// TODO 用 wx.getLocation 来封装 geolocation
|
||||
geolocation: {
|
||||
getCurrentPosition: noop,
|
||||
watchPosition: noop,
|
||||
|
||||
@@ -45,6 +45,8 @@ function inject () {
|
||||
window.HTMLAudioElement = require('./HTMLAudioElement');
|
||||
window.HTMLVideoElement = require('./HTMLVideoElement');
|
||||
window.__cccanvas = new HTMLCanvasElement();
|
||||
window.__cccanvas._width = window.innerWidth;
|
||||
window.__cccanvas._height = window.innerHeight;
|
||||
window.__ccgl.canvas = window.__cccanvas;
|
||||
window.navigator = require('./navigator');
|
||||
window.Image = require('./Image');
|
||||
|
||||
Reference in New Issue
Block a user