更新
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
export declare function initDefine(stringifyBoolean?: boolean): {
|
||||
__UNI_FEATURE_VIRTUAL_HOST__: boolean;
|
||||
'process.env.NODE_ENV': string;
|
||||
'process.env.UNI_DEBUG': string | boolean;
|
||||
'process.env.UNI_APP_ID': string;
|
||||
'process.env.UNI_APP_NAME': string;
|
||||
'process.env.UNI_APP_VERSION_NAME': string;
|
||||
'process.env.UNI_APP_VERSION_CODE': string;
|
||||
'process.env.UNI_PLATFORM': string;
|
||||
'process.env.UNI_SUB_PLATFORM': string;
|
||||
'process.env.UNI_MP_PLUGIN': string;
|
||||
'process.env.UNI_SUBPACKAGE': string;
|
||||
'process.env.UNI_COMPILER_VERSION': string;
|
||||
'process.env.RUN_BY_HBUILDERX': string | boolean;
|
||||
'process.env.UNI_AUTOMATOR_WS_ENDPOINT': string;
|
||||
'process.env.UNI_AUTOMATOR_APP_WEBVIEW_SRC': string;
|
||||
'process.env.UNI_CLOUD_PROVIDER': string;
|
||||
'process.env.UNICLOUD_DEBUG': string;
|
||||
'process.env.VUE_APP_PLATFORM': string;
|
||||
'process.env.VUE_APP_DARK_MODE': string;
|
||||
};
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initDefine = void 0;
|
||||
const env_1 = require("../hbx/env");
|
||||
const json_1 = require("../json");
|
||||
function initDefine(stringifyBoolean = false) {
|
||||
const manifestJson = (0, json_1.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR);
|
||||
const platformManifestJson = (0, json_1.getPlatformManifestJsonOnce)();
|
||||
const isRunByHBuilderX = (0, env_1.runByHBuilderX)();
|
||||
const isDebug = !!manifestJson.debug;
|
||||
const isX = process.env.UNI_APP_X === 'true';
|
||||
const isMP = process.env.UNI_PLATFORM.startsWith('mp');
|
||||
process.env['UNI_APP_ID'] = manifestJson.appid;
|
||||
let mpXDefine = isX && isMP
|
||||
? {
|
||||
__UNI_FEATURE_VIRTUAL_HOST__: true,
|
||||
}
|
||||
: {
|
||||
__UNI_FEATURE_VIRTUAL_HOST__: false,
|
||||
};
|
||||
if (isX && isMP) {
|
||||
mpXDefine.__UNI_FEATURE_VIRTUAL_HOST__ =
|
||||
platformManifestJson.enableVirtualHost !== false;
|
||||
}
|
||||
return {
|
||||
...initCustomDefine(),
|
||||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
||||
'process.env.UNI_DEBUG': stringifyBoolean
|
||||
? JSON.stringify(isDebug)
|
||||
: isDebug,
|
||||
'process.env.UNI_APP_ID': JSON.stringify(manifestJson.appid || ''),
|
||||
'process.env.UNI_APP_NAME': JSON.stringify(manifestJson.name || ''),
|
||||
'process.env.UNI_APP_VERSION_NAME': JSON.stringify(manifestJson.versionName || ''),
|
||||
'process.env.UNI_APP_VERSION_CODE': JSON.stringify(manifestJson.versionCode || ''),
|
||||
'process.env.UNI_PLATFORM': JSON.stringify(process.env.UNI_PLATFORM),
|
||||
'process.env.UNI_SUB_PLATFORM': JSON.stringify(process.env.UNI_SUB_PLATFORM || ''),
|
||||
'process.env.UNI_MP_PLUGIN': JSON.stringify(process.env.UNI_MP_PLUGIN || ''),
|
||||
'process.env.UNI_SUBPACKAGE': JSON.stringify(process.env.UNI_SUBPACKAGE || ''),
|
||||
'process.env.UNI_COMPILER_VERSION': JSON.stringify(process.env.UNI_COMPILER_VERSION || ''),
|
||||
'process.env.RUN_BY_HBUILDERX': stringifyBoolean
|
||||
? JSON.stringify(isRunByHBuilderX)
|
||||
: isRunByHBuilderX,
|
||||
'process.env.UNI_AUTOMATOR_WS_ENDPOINT': JSON.stringify(process.env.UNI_AUTOMATOR_WS_ENDPOINT || ''),
|
||||
'process.env.UNI_AUTOMATOR_APP_WEBVIEW_SRC': JSON.stringify(process.env.UNI_AUTOMATOR_APP_WEBVIEW_SRC || ''),
|
||||
'process.env.UNI_CLOUD_PROVIDER': JSON.stringify(process.env.UNI_CLOUD_PROVIDER || ''),
|
||||
'process.env.UNICLOUD_DEBUG': JSON.stringify(process.env.UNICLOUD_DEBUG || ''),
|
||||
// 兼容旧版本
|
||||
'process.env.VUE_APP_PLATFORM': JSON.stringify(process.env.UNI_PLATFORM || ''),
|
||||
'process.env.VUE_APP_DARK_MODE': JSON.stringify(platformManifestJson.darkmode || false),
|
||||
...mpXDefine,
|
||||
};
|
||||
}
|
||||
exports.initDefine = initDefine;
|
||||
function initCustomDefine() {
|
||||
let define = {};
|
||||
if (process.env.UNI_CUSTOM_DEFINE) {
|
||||
try {
|
||||
define = JSON.parse(process.env.UNI_CUSTOM_DEFINE);
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
return Object.keys(define).reduce((res, name) => {
|
||||
res['process.env.' + name] = JSON.stringify(define[name]);
|
||||
return res;
|
||||
}, {});
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export { initDefine } from './define';
|
||||
export { initAppProvide } from './provide';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initAppProvide = exports.initDefine = void 0;
|
||||
var define_1 = require("./define");
|
||||
Object.defineProperty(exports, "initDefine", { enumerable: true, get: function () { return define_1.initDefine; } });
|
||||
var provide_1 = require("./provide");
|
||||
Object.defineProperty(exports, "initAppProvide", { enumerable: true, get: function () { return provide_1.initAppProvide; } });
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
export declare function initAppProvide(): {
|
||||
__f__: string[];
|
||||
crypto: string[];
|
||||
'window.crypto': string[];
|
||||
'global.crypto': string[];
|
||||
'uni.getCurrentSubNVue': string[];
|
||||
'uni.requireNativePlugin': string[];
|
||||
};
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initAppProvide = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const libDir = path_1.default.resolve(__dirname, '../../lib');
|
||||
function initAppProvide() {
|
||||
const cryptoDefine = [path_1.default.join(libDir, 'crypto.js'), 'default'];
|
||||
return {
|
||||
__f__: ['@dcloudio/uni-app', 'formatAppLog'],
|
||||
crypto: cryptoDefine,
|
||||
'window.crypto': cryptoDefine,
|
||||
'global.crypto': cryptoDefine,
|
||||
'uni.getCurrentSubNVue': ['@dcloudio/uni-app', 'getCurrentSubNVue'],
|
||||
'uni.requireNativePlugin': ['@dcloudio/uni-app', 'requireNativePlugin'],
|
||||
};
|
||||
}
|
||||
exports.initAppProvide = initAppProvide;
|
||||
Reference in New Issue
Block a user