Skip to content

Commit

Permalink
feat(console): 提供独立的mp.esm.js
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Feb 14, 2025
1 parent 3617b3d commit 3e9f9c8
Show file tree
Hide file tree
Showing 5 changed files with 663 additions and 43 deletions.
19 changes: 18 additions & 1 deletion packages/uni-console/build.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,24 @@
"__HARMONY__": "false",
"__DEV__": "process.env.UNI_DEBUG",
"process.env.UNI_CONSOLE_WEBVIEW": false,
"_APP_ANDROID_": "false"
"_APP_ANDROID_": "false",
"__PLATFORM__": "'other'"
},
"compilerOptions": {
"target": "es6",
"declaration": false
}
},
{
"input": {
"src/runtime/index.ts": "dist/mp.esm.js"
},
"replacements": {
"__HARMONY__": "false",
"__DEV__": "process.env.UNI_DEBUG",
"process.env.UNI_CONSOLE_WEBVIEW": false,
"_APP_ANDROID_": "false",
"__PLATFORM__": "'mp'"
},
"compilerOptions": {
"target": "es6",
Expand Down
37 changes: 0 additions & 37 deletions packages/uni-console/dist/index.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,11 +546,9 @@ function initRuntimeSocketService() {
restoreError();
restoreConsole();
originalConsole.error(wrapError('开发模式下日志通道建立 socket 连接失败。'));
originalConsole.error(wrapError('如果是小程序平台,请勾选不校验合法域名配置。'));
originalConsole.error(wrapError('如果是运行到真机,请确认手机与电脑处于同一网络。'));
return false;
}
initMiniProgramGlobalFlag();
socket.onClose(() => {
if (process.env.UNI_DEBUG) {
originalConsole.log(`uni-app:[${Date.now()}][socket]`, 'connect close and restore');
Expand Down Expand Up @@ -583,41 +581,6 @@ const ERROR_CHAR = '\u200C';
function wrapError(error) {
return `${ERROR_CHAR}${error}${ERROR_CHAR}`;
}
function initMiniProgramGlobalFlag() {
if (typeof wx !== 'undefined') {
// @ts-expect-error
wx.__uni_console__ = true;
// @ts-expect-error
}
else if (typeof my !== 'undefined') {
// @ts-expect-error
my.__uni_console__ = true;
}
else if (typeof tt !== 'undefined') {
tt.__uni_console__ = true;
}
else if (typeof swan !== 'undefined') {
swan.__uni_console__ = true;
}
else if (typeof qq !== 'undefined') {
qq.__uni_console__ = true;
}
else if (typeof ks !== 'undefined') {
ks.__uni_console__ = true;
}
else if (typeof jd !== 'undefined') {
jd.__uni_console__ = true;
}
else if (typeof xhs !== 'undefined') {
xhs.__uni_console__ = true;
}
else if (typeof has !== 'undefined') {
has.__uni_console__ = true;
}
else if (typeof qa !== 'undefined') {
qa.__uni_console__ = true;
}
}
initRuntimeSocketService();

export { initRuntimeSocketService };
Loading

0 comments on commit 3e9f9c8

Please sign in to comment.