Merge branch 'dev' of gitea.51mars.com:Oak-Team/oak-cli into dev
This commit is contained in:
commit
b8c52becc6
|
|
@ -1,18 +0,0 @@
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化,App也必须输入访问的目标域名,系统根据domain和system的关系来判定appId
|
|
||||||
*/
|
|
||||||
const env = process.env.NODE_ENV;
|
|
||||||
|
|
||||||
const URL = {
|
|
||||||
// 服务器地址数组,和application的domain中要保持一致以确定application
|
|
||||||
development: 'localhost',
|
|
||||||
staging: 'test.com',
|
|
||||||
production: 'test.com',
|
|
||||||
};
|
|
||||||
|
|
||||||
const host = URL[env];
|
|
||||||
|
|
||||||
export {
|
|
||||||
host,
|
|
||||||
};
|
|
||||||
|
|
@ -8,6 +8,7 @@ import { setJSExceptionHandler } from 'react-native-exception-handler';
|
||||||
import features from './initialize';
|
import features from './initialize';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
import { name as appName } from './app.json';
|
import { name as appName } from './app.json';
|
||||||
|
import {setPromiseUnCatchHandler} from './promiseTracker';
|
||||||
import { handler as exceptionHandler } from '@project/exceptionHandler';
|
import { handler as exceptionHandler } from '@project/exceptionHandler';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|
@ -15,9 +16,13 @@ import {
|
||||||
} from 'oak-frontend-base/es/platforms/native/features';
|
} from 'oak-frontend-base/es/platforms/native/features';
|
||||||
|
|
||||||
// to 详化
|
// to 详化
|
||||||
setJSExceptionHandler((exception) => {
|
setJSExceptionHandler(exception => {
|
||||||
exceptionHandler(exception, features);
|
exceptionHandler(exception, features);
|
||||||
});
|
}, true);
|
||||||
|
|
||||||
|
setPromiseUnCatchHandler((id, exception) => {
|
||||||
|
exceptionHandler(exception, features);
|
||||||
|
}, true);
|
||||||
|
|
||||||
function Root() {
|
function Root() {
|
||||||
features.navigator.setNamespace('/frontend');
|
features.navigator.setNamespace('/frontend');
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
export type PromiseUnCatchHandler = (id: string, error: Error) => void;
|
||||||
|
|
||||||
|
const noop: PromiseUnCatchHandler = () => { };
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {Function} customHandler
|
||||||
|
* @param {Boolean} allowedInDevMode
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export const setPromiseUnCatchHandler = (customHandler: PromiseUnCatchHandler = noop, allowedInDevMode = false) => {
|
||||||
|
if (typeof customHandler !== 'function' || typeof allowedInDevMode !== 'boolean') {
|
||||||
|
console.log('setPromiseUnCatchHandler is called with wrong argument types.. first argument should be callback function and second argument is optional should be a boolean');
|
||||||
|
console.log('Not setting the JS handler .. please fix setPromiseUnCatchHandler call');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const customRejectionTrackingOptions = {
|
||||||
|
allRejections: true,
|
||||||
|
onUnhandled: customHandler,
|
||||||
|
onHandled: (id: string) => {
|
||||||
|
const warning =
|
||||||
|
`Promise Rejection Handled (id: ${id})\n` +
|
||||||
|
'This means you can ignore any previous messages of the form ' +
|
||||||
|
`"Possible Unhandled Promise Rejection (id: ${id}):"`;
|
||||||
|
console.warn(warning);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
// @ts-ignore
|
||||||
|
const __DEV__ = process.env.NODE_ENV === 'development';
|
||||||
|
const allowed = allowedInDevMode ? true : !__DEV__;
|
||||||
|
if (allowed) {
|
||||||
|
// @ts-ignore
|
||||||
|
if (global?.HermesInternal?.hasPromise?.()) {
|
||||||
|
// @ts-ignore
|
||||||
|
global.HermesInternal?.enablePromiseRejectionTracker?.(
|
||||||
|
customRejectionTrackingOptions,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
require('promise/setimmediate/rejection-tracking').enable(
|
||||||
|
customRejectionTrackingOptions,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log('Skipping setPromiseUnCatchHandler: Reason: In DEV mode and allowedInDevMode = false');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -5,16 +5,9 @@
|
||||||
const accountInfo = wx.getAccountInfoSync();
|
const accountInfo = wx.getAccountInfoSync();
|
||||||
const envVersion = accountInfo.miniProgram.envVersion; //develop\trial\release
|
const envVersion = accountInfo.miniProgram.envVersion; //develop\trial\release
|
||||||
|
|
||||||
const URL = { // 服务器地址数组,和domain中要保持一致以界定application
|
|
||||||
develop: 'localhost',
|
|
||||||
trial: 'dev.oak-app-id.com',
|
|
||||||
release: 'www.oak-app-id.com',
|
|
||||||
};
|
|
||||||
|
|
||||||
const host = URL[envVersion];
|
|
||||||
const sdkVersion = '2.25.1'; // 小程序运行所需要的sdk最低版本
|
const sdkVersion = '2.25.1'; // 小程序运行所需要的sdk最低版本
|
||||||
|
|
||||||
export {
|
export {
|
||||||
host,
|
envVersion,
|
||||||
sdkVersion,
|
sdkVersion,
|
||||||
};
|
};
|
||||||
Loading…
Reference in New Issue