Commit ae3f1e22 authored by wildfirecode's avatar wildfirecode

update

parent 32f692d5
...@@ -75,10 +75,12 @@ export const check_webp_feature = () => { ...@@ -75,10 +75,12 @@ export const check_webp_feature = () => {
return _support_webp_ === '1'; return _support_webp_ === '1';
} }
const img = new Image(); const img = new Image();
// tslint:disable-next-line:only-arrow-functions
img.onload = function () { img.onload = function () {
const result = (img.width > 0) && (img.height > 0); const result = (img.width > 0) && (img.height > 0);
localStorage.setItem('_support_webp_', result ? '1' : '0') localStorage.setItem('_support_webp_', result ? '1' : '0')
}; };
// tslint:disable-next-line:only-arrow-functions
img.onerror = function () { img.onerror = function () {
localStorage.setItem('_support_webp_', '0') localStorage.setItem('_support_webp_', '0')
}; };
......
export default function isIPhoneX() { const isIPhoneX = () => {
var u = navigator.userAgent; var u = navigator.userAgent;
var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端 var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
return isIOS && screen.height == 812 && screen.width == 375 return isIOS && screen.height == 812 && screen.width == 375
} }
\ No newline at end of file
export default isIPhoneX
\ No newline at end of file
...@@ -3,11 +3,10 @@ import SceneCtrl from "../../src/ctrls/sceneCtrl"; ...@@ -3,11 +3,10 @@ import SceneCtrl from "../../src/ctrls/sceneCtrl";
import Loading from "../../src/loading/Loading"; import Loading from "../../src/loading/Loading";
import { getResPath } from "../../src/utils"; import { getResPath } from "../../src/utils";
import layers from "../../src/views/layers"; import layers from "../../src/views/layers";
import { check_webp_feature } from "../tc/util/GFun";
import { DataManager } from "../tw/manager/DataManager"; import { DataManager } from "../tw/manager/DataManager";
import { NetManager } from "../tw/manager/NetManager";
import AssetAdapter from "./adapter/AssetAdapter"; import AssetAdapter from "./adapter/AssetAdapter";
import ThemeAdapter from "./adapter/ThemeAdapter"; import ThemeAdapter from "./adapter/ThemeAdapter";
import { check_webp_feature } from "../tc/util/GFun";
export default class MainBase extends eui.UILayer { export default class MainBase extends eui.UILayer {
constructor() { constructor() {
...@@ -15,36 +14,6 @@ export default class MainBase extends eui.UILayer { ...@@ -15,36 +14,6 @@ export default class MainBase extends eui.UILayer {
check_webp_feature(); check_webp_feature();
} }
private injectRES() {
if (RES.fileSystem['getFileOld']) return;
RES.fileSystem['getFileOld'] = RES.fileSystem.getFile;
window['RES'].fileSystem.getFile = function (filename: string) {
//生效情况
//RES.getResByUrl spritesheet类型
//不生效
//RES.getResAsync('net_png') spritesheet类型
// if (filename.indexOf('.json') != -1) {
// var arr = filename.split('.json')[0].split('/');
// var filename1 = arr[arr.length - 1] + '_png';
// var filename2 = filename.split('.json')[0] + '.png';
// if (!RES.fileSystem['fsData'][filename1])
// RES.fileSystem['fsData'][filename1] =
// { name: filename1, type: 'image', url: filename2, root: '', extra: '1' };
// }
var result = RES.fileSystem['getFileOld'](filename);
if (result && result.url && check_webp_feature()) {
//生效情况
//RES.getResByUrl jpg or png类型
//RES.getResAsync('monkey_png')
if (filename.indexOf('png') != -1 || filename.indexOf('jpg') != -1)
result = JSON.parse(JSON.stringify(result));
// result.url = result.url.replace('.png', '.png?x-oss-process=image/format,webp');
result.url = result.url.replace('.jpg', '.jpg?x-oss-process=image/format,webp');
}
return result;
}
}
protected createChildren(): void { protected createChildren(): void {
super.createChildren(); super.createChildren();
egret.lifecycle.addLifecycleListener((context) => { egret.lifecycle.addLifecycleListener((context) => {
...@@ -107,7 +76,6 @@ export default class MainBase extends eui.UILayer { ...@@ -107,7 +76,6 @@ export default class MainBase extends eui.UILayer {
try { try {
await RES.loadConfig("default.res.json", getResPath() + "resource/"); await RES.loadConfig("default.res.json", getResPath() + "resource/");
await this.loadTheme(); await this.loadTheme();
// this.injectRES();
} }
catch (e) { catch (e) {
console.error(e); console.error(e);
......
...@@ -7,6 +7,7 @@ export default class AssetAdapter implements eui.IAssetAdapter { ...@@ -7,6 +7,7 @@ export default class AssetAdapter implements eui.IAssetAdapter {
* @param thisObject callBack的 this 引用 * @param thisObject callBack的 this 引用
*/ */
public getAsset(source: string, compFunc:Function, thisObject: any): void { public getAsset(source: string, compFunc:Function, thisObject: any): void {
// tslint:disable-next-line:only-arrow-functions
function onGetRes(data: any): void { function onGetRes(data: any): void {
compFunc.call(thisObject, data, source); compFunc.call(thisObject, data, source);
} }
......
...@@ -9,9 +9,11 @@ export default class ThemeAdapter implements eui.IThemeAdapter { ...@@ -9,9 +9,11 @@ export default class ThemeAdapter implements eui.IThemeAdapter {
*/ */
public getTheme(url: string, onSuccess: Function, onError: Function, thisObject: any): void { public getTheme(url: string, onSuccess: Function, onError: Function, thisObject: any): void {
// tslint:disable-next-line:only-arrow-functions
function onResGet(e: string): void { function onResGet(e: string): void {
onSuccess.call(thisObject, e); onSuccess.call(thisObject, e);
} }
// tslint:disable-next-line:only-arrow-functions
function onResError(e: RES.ResourceEvent): void { function onResError(e: RES.ResourceEvent): void {
if (e.resItem.url == url) { if (e.resItem.url == url) {
RES.removeEventListener(RES.ResourceEvent.ITEM_LOAD_ERROR, onResError, null); RES.removeEventListener(RES.ResourceEvent.ITEM_LOAD_ERROR, onResError, null);
......
...@@ -36,7 +36,7 @@ class Main extends MainBase { ...@@ -36,7 +36,7 @@ class Main extends MainBase {
window['Main'] = Main; window['Main'] = Main;
egret.runEgret({ egret.runEgret({
renderMode: "webgl", audioType: 0, calculateCanvasScaleFactor: function (context:any) { renderMode: "webgl", audioType: 0, calculateCanvasScaleFactor: (context:any)=> {
var backingStore = context.backingStorePixelRatio || var backingStore = context.backingStorePixelRatio ||
context.webkitBackingStorePixelRatio || context.webkitBackingStorePixelRatio ||
context.mozBackingStorePixelRatio || context.mozBackingStorePixelRatio ||
......
...@@ -27,4 +27,4 @@ ...@@ -27,4 +27,4 @@
"progress": "^2.0.0" "progress": "^2.0.0"
}, },
"sideEffects": false "sideEffects": false
} }
\ No newline at end of file
{
"defaultSeverity": "error",
"extends": [
// "tslint:recommended"
],
"jsRules": {},
"rules": {
"only-arrow-functions":true
},
"rulesDirectory": []
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment