mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
7bc135e1c7
* adjust init process * fix bugs * restructure * tweak * delete useless code * fix ci * support more platform and fix some bugs * mark internal * tweak * add docs * add docs and little adjustment * fix bugs * adjust decorator execute order fix mesh error * fix bugs * revert some change * revert auto-generated code * revert auto-generated code
31 lines
968 B
TypeScript
31 lines
968 B
TypeScript
import { COCOSPLAY, HUAWEI, OPPO, VIVO } from 'internal:constants';
|
|
|
|
declare const require: (path: string) => Promise<void>;
|
|
declare const ral: any;
|
|
|
|
export function findCanvas (): { frame: HTMLDivElement, container: HTMLDivElement, canvas: HTMLCanvasElement } {
|
|
const container = document.createElement('div');
|
|
let frame;
|
|
if (COCOSPLAY) {
|
|
frame = {
|
|
clientWidth: window.innerWidth,
|
|
clientHeight: window.innerHeight,
|
|
} as any;
|
|
} else {
|
|
frame = container.parentNode === document.body ? document.documentElement : container.parentNode as any;
|
|
}
|
|
let canvas;
|
|
if (VIVO) {
|
|
canvas = window.mainCanvas;
|
|
window.mainCanvas = undefined;
|
|
} else {
|
|
canvas = ral.createCanvas();
|
|
}
|
|
return { frame, canvas, container };
|
|
}
|
|
|
|
export function loadJsFile (path: string): Promise<void> {
|
|
// eslint-disable-next-line import/no-dynamic-require
|
|
return require(`${path}`);
|
|
}
|