前端 uni-app 重写: 9页面 H5

This commit is contained in:
zhiqui
2026-11-15 15:09:37 +08:00
parent 513b53672e
commit ea7c2529e9
24104 changed files with 3667749 additions and 0 deletions
+202
View File
@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+389
View File
@@ -0,0 +1,389 @@
'use strict';
var debug = require('debug');
var uniCliShared = require('@dcloudio/uni-cli-shared');
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
var debug__default = /*#__PURE__*/_interopDefault(debug);
function once(fn, ctx = null) {
let res;
return ((...args) => {
if (fn) {
res = fn.apply(ctx, args);
fn = null;
}
return res;
});
}
/**
* 解析当前平台对应的 manifest 平台节点。
*
* 与 `uni-cli-shared#getPlatformManifestJson` 行为保持一致:app → app-plus/plus,
* h5 → web/h5,uni-app x 的 app-android/app-ios/app 走各自分支,其余平台取同名节点。
*
* 逻辑内聚在 uni-stat 插件内(仅依赖 `parseManifestJsonOnce`),避免依赖
* HBuilderX 内置旧版 uni-cli-shared 可能缺失的新导出(如 `getUniStatistics`)。
*
* @param manifest 已解析的 manifest.json 对象
* @param platform 目标平台;缺省读 `process.env.UNI_PLATFORM`
*/
function getPlatformManifest(manifest, platform) {
const isX = process.env.UNI_APP_X === 'true';
if (!platform) {
platform = process.env.UNI_PLATFORM;
}
if (isX) {
if (platform === 'app-android' || platform === 'app-ios') {
return (manifest === null || manifest === void 0 ? void 0 : manifest[platform]) || (manifest === null || manifest === void 0 ? void 0 : manifest['app']) || {};
}
else if (platform === 'app') {
return ((manifest === null || manifest === void 0 ? void 0 : manifest[process.env.UNI_UTS_PLATFORM]) || (manifest === null || manifest === void 0 ? void 0 : manifest['app']) || {});
}
}
if (platform === 'app') {
return (manifest === null || manifest === void 0 ? void 0 : manifest['app-plus']) || (manifest === null || manifest === void 0 ? void 0 : manifest['plus']) || {};
}
if (platform === 'h5') {
return (manifest === null || manifest === void 0 ? void 0 : manifest.web) || (manifest === null || manifest === void 0 ? void 0 : manifest.h5) || {};
}
return (platform && (manifest === null || manifest === void 0 ? void 0 : manifest[platform])) || {};
}
/**
* 根据 manifest 判定是否自动开启统计(是否向 main 注入统计运行时)。
*
* ## 范围
*
* 仅控制完整运行时或 Vapor 生命周期桥接的注入;**不**影响 `plugin/index.ts` 对
* `UNI_STATISTICS_CONFIG` 等 define 的注入(配置合并仍走 `getUniStatistics`)。
*
* ## enable 判定规则(仅以 `enable` 是否显式存在作为覆盖条件)
*
* 子平台存在 `uniStatistics` 但只配置了 `debug` / `reportInterval` 等、未写 `enable` 时,
* **不视为**子节点覆盖,仍继承根节点 `enable`。
*
* 判定顺序:
* 1. 子平台 `uniStatistics.enable` 已显式配置(`true` / `false`)→ 以子为准;
* 2. 否则,根 `uniStatistics.enable` 已显式配置 → 继承根;
* 3. 否则(根/子均无 `enable`,或均无 `uniStatistics` 节点)→ **默认开启**。
*
* ## 用例矩阵
*
* | 根 enable | 子 uniStatistics | 子 enable | 结果 |
* |-----------|------------------|-----------|--------|
* | false | 有 | true | 开启 |
* | true | 有 | false | 关闭 |
* | true | 无 | — | 开启 |
* | false | 无 | — | 关闭 |
* | false | 有(仅 debug 等)| 未配置 | 关闭 |
* | 无节点 | 有 | true | 开启 |
* | 无节点 | 有 | false | 关闭 |
* | 无节点 | 无 | — | 开启 |
* | 无节点 | 有(仅非 enable)| 未配置 | 开启 |
*
* @param inputDir 工程输入目录
* @param platform 目标平台;缺省读 `process.env.UNI_PLATFORM`
*/
function isUniStatisticsEnabled(inputDir, platform) {
var _a;
const manifest = uniCliShared.parseManifestJsonOnce(inputDir);
const root = manifest === null || manifest === void 0 ? void 0 : manifest.uniStatistics;
const platformStat = (_a = getPlatformManifest(manifest, platform)) === null || _a === void 0 ? void 0 : _a.uniStatistics;
if (platformStat && platformStat.enable !== undefined) {
return platformStat.enable !== false;
}
if (root && root.enable !== undefined) {
return root.enable !== false;
}
return true;
}
/** 当前是否为 uni-app x 编译目标。 */
function isUniAppXCompile() {
return process.env.UNI_APP_X === 'true';
}
/**
* 本地运行仅在 manifest 显式开启 debug 时加载统计;发行构建保持原行为。
*/
function shouldRunStatRuntime(debug, nodeEnv = process.env.NODE_ENV) {
return nodeEnv !== 'development' || debug === true;
}
function getCurrentPlatform(platform) {
var _a;
return (_a = platform !== null && platform !== void 0 ? platform : process.env.UNI_UTS_PLATFORM) !== null && _a !== void 0 ? _a : process.env.UNI_PLATFORM;
}
function isAppPlatform(platform) {
const currentPlatform = getCurrentPlatform(platform);
return (currentPlatform === 'app' ||
currentPlatform === 'app-plus' ||
currentPlatform === 'app-android' ||
currentPlatform === 'app-ios' ||
currentPlatform === 'app-harmony');
}
function isWebOrWeixinPlatform(platform) {
const currentPlatform = getCurrentPlatform(platform);
return (currentPlatform === 'h5' ||
currentPlatform === 'web' ||
currentPlatform === 'mp-weixin');
}
/** 当前是否使用 uni-app x route bridge 统计方案。 */
function isUniAppXVaporCompile(platform) {
if (!isUniAppXCompile())
return false;
if (isAppPlatform(platform)) {
return process.env.UNI_APP_X_DOM2 === 'true';
}
return isWebOrWeixinPlatform(platform);
}
/**
* 是否开启 uni-app x 蒸汽模式的统计入口桥接。
*/
function shouldBootstrapVaporRuntime(inputDir, platform) {
return (isUniAppXVaporCompile(platform) &&
isUniStatisticsEnabled(inputDir, platform));
}
/**
* 是否应向 main 入口自动 import 统计运行时。
* uni-app x 不走普通 Vue mixin 运行时:Web / 微信小程序和 Vapor App 使用 route
* bridge,VDOM App 与其他小程序保持关闭。define 配置注入始终保留。
*
* @param inputDir 工程输入目录
* @param platform 目标平台;缺省读 `process.env.UNI_PLATFORM`。传入以支持分平台 enable 覆盖。
*/
function shouldAutoImportStatRuntime(inputDir, platform) {
if (isUniAppXCompile()) {
return false;
}
return isUniStatisticsEnabled(inputDir, platform);
}
const PUBLIC_STAT_RUNTIME = '@dcloudio/uni-stat-public';
const MP_WEIXIN_PUBLIC_STAT_RUNTIME = '@dcloudio/uni-stat-public-mp-weixin';
function resolvePublicStatImportPath(platform) {
return platform === 'mp-weixin'
? MP_WEIXIN_PUBLIC_STAT_RUNTIME
: PUBLIC_STAT_RUNTIME;
}
/**
* 解析统计版本类型(公有版 / 私有版)。
* - 优先 `type`;缺失时回退旧版 `version`(2=private,其余=public)。
*/
function resolveUniStatisticsType(statConfig) {
var _a;
const type = String((_a = statConfig === null || statConfig === void 0 ? void 0 : statConfig.type) !== null && _a !== void 0 ? _a : '').trim();
if (type === 'public' || type === 'private') {
return type;
}
const versionNum = Number(statConfig === null || statConfig === void 0 ? void 0 : statConfig.version);
return versionNum === 2 ? 'private' : 'public';
}
const uniStatLog = once((text) => {
console.log();
console.warn(text);
console.log();
});
/** 与 `public/config.ts#MP_WEIXIN_USE_PRELOAD_ASSETS_REPORT` 保持一致。 */
const MP_WEIXIN_USE_PRELOAD_ASSETS_REPORT = true;
/** 公有版小程序 GET 上报域名(与 `public/config.ts#IMAGE_REPORT_DEFAULTS.host` 一致)。 */
const STAT_MP_REQUEST_DOMAIN = 'tongji-collector.dcloud.net.cn';
const STAT_MP_DOMAIN_DOC_URL = 'https://uniapp.dcloud.net.cn/uni-stat-public.html';
/**
* 构建期「统计已开启」提示文案(不依赖 i18n 占位符,避免 HBuilderX 内置文案仍为 `{version}` 时原样输出)。
* - public:已开启 uni 统计 2.0
* - private:已开启 uni 统计 2.0(私有版)
*/
function formatStatEnabledTip(statType) {
return statType === 'private'
? '已开启 uni统计 2.0(私有版)'
: '已开启 uni统计 2.0';
}
/**
* 构建期小程序 request 合法域名提示(单条合并「已开启」与域名说明)。
*/
function formatMpStatDomainTip() {
return `已开启 uni统计 2.0,为保障数据正常上报,请在小程序后台配置 request 合法域名:${STAT_MP_REQUEST_DOMAIN}。详情:${STAT_MP_DOMAIN_DOC_URL}`;
}
/**
* 是否需要在构建期提示配置小程序 request 合法域名。
* 微信默认 preload 信标不走 uni.request,无需配置;开关关闭时与其它小程序一致。
*/
function shouldShowMpDomainTip(platform, statType) {
if (statType !== 'public' || !platform.startsWith('mp-')) {
return false;
}
if (platform === 'mp-weixin' && MP_WEIXIN_USE_PRELOAD_ASSETS_REPORT) {
return false;
}
return true;
}
/**
* 输出构建期「统计已开启」提示:小程序公有版(需配置域名)走合并文案,其余走简短文案。
*/
function logStatEnabledTip(platform, statType) {
if (shouldShowMpDomainTip(platform, statType)) {
uniStatLog(formatMpStatDomainTip());
return;
}
uniStatLog(formatStatEnabledTip(statType));
}
var index = () => [
uniCliShared.defineUniMainJsPlugin((opts) => {
/**
* 统计类型(仅用于新编译器):
* - public:公有版(uni-stat-public)
* - private:私有版(uni-cloud-stat)
*
* 兼容策略:
* - 优先读取 manifest.uniStatistics.type(public/private)
* - type 缺失或非法时,回退旧版 version(2=private,其余=public)
*/
let statType = 'public';
let isEnable = false;
let shouldImportRuntime = false;
let vaporLifecycleEnabled = false;
let currentPlatform = process.env.UNI_PLATFORM || '';
const stats = {
'@dcloudio/uni-stat': uniCliShared.resolveBuiltIn('@dcloudio/uni-stat/dist/uni-stat.es.js'),
'@dcloudio/uni-cloud-stat': uniCliShared.resolveBuiltIn('@dcloudio/uni-stat/dist/uni-cloud-stat.es.js'),
'@dcloudio/uni-cloud-stat-vapor': uniCliShared.resolveBuiltIn('@dcloudio/uni-stat/dist/uni-cloud-stat-vapor.es.js'),
'@dcloudio/uni-stat-public': uniCliShared.resolveBuiltIn('@dcloudio/uni-stat/dist/uni-stat-public.es.js'),
'@dcloudio/uni-stat-public-mp-weixin': uniCliShared.resolveBuiltIn('@dcloudio/uni-stat/dist/uni-stat-public.mp-weixin.es.js'),
};
return {
name: 'uni:stat',
enforce: 'pre',
config(config, env) {
var _a, _b, _c, _d, _e;
if (!uniCliShared.isNormalCompileTarget()) {
// 不需要统计
return;
}
const inputDir = process.env.UNI_INPUT_DIR;
const platform = process.env.UNI_PLATFORM;
currentPlatform = platform;
const titlesJson = Object.create(null);
uniCliShared.parsePagesJson(inputDir, platform).pages.forEach((page) => {
var _a;
const style = page.style || {};
const titleText =
// MP
style.navigationBarTitleText ||
(
// H5 || App
(_a = style.navigationBar) === null || _a === void 0 ? void 0 : _a.titleText) ||
'';
if (titleText) {
titlesJson[page.path] = titleText;
}
});
// 注意:勿在此对 mp- + UNI_APP_X 提前 return。
// 提前 return 会导致后续未执行 getUniStatistics / UNI_STATISTICS_CONFIG,
// 小程序公有版运行时 manifest(backgroundTimeout / reportInterval 等)全部丢失,仍走默认值;
// H5 不走 mp- 分支故无此问题。标题 JSON 与统计配置在同一套 define 末尾统一注入。
// ssr 时不开启
if (!uniCliShared.isSsr(env.command, config)) {
const statConfig = uniCliShared.getUniStatistics(inputDir, platform);
// 始终注入完整 manifest.uniStatistics(与 enable 无关)。
// enable 仅控制是否注入完整统计入口或 Vapor 桥接;业务手动 import 或
// enable:false 调试时,运行时仍须能读到 backgroundTimeout / reportInterval 等字段。
process.env.UNI_STATISTICS_CONFIG = JSON.stringify(statConfig);
process.env.UNI_STAT_DEBUG = statConfig.debug ? 'true' : 'false';
statType = resolveUniStatisticsType(statConfig);
// Web / 微信小程序和 Vapor App 走 route bridge;VDOM App 保持关闭。
shouldImportRuntime = shouldAutoImportStatRuntime(inputDir, platform);
vaporLifecycleEnabled = shouldBootstrapVaporRuntime(inputDir, platform);
isEnable = shouldImportRuntime || vaporLifecycleEnabled;
// 本地运行默认不采集,避免开发数据污染;发行构建仍只受 enable 控制。
if (isEnable && !shouldRunStatRuntime(statConfig.debug)) {
shouldImportRuntime = false;
vaporLifecycleEnabled = false;
isEnable = false;
uniStatLog('本地运行未开启 manifest.json 的 uniStatistics.debug,uni统计不采集、不上报;发行模式不受影响');
}
if (isEnable) {
const uniCloudConfig = statConfig.uniCloud || {};
process.env.UNI_STAT_UNI_CLOUD = JSON.stringify(uniCloudConfig);
// 公有版字段 `an` 兜底:注入 manifest.json#name 到 process.env.UNI_APP_NAME,
// 由 `public/adapter/package.ts#getEnvAppName` 读取。任意阶段读 manifest 失败
// 都走 try/catch,不阻断构建。
try {
const manifestForName = uniCliShared.parseManifestJsonOnce(inputDir);
if (manifestForName && typeof manifestForName.name === 'string') {
process.env.UNI_APP_NAME = manifestForName.name;
}
}
catch (e) {
debug__default.default('uni:stat')('parse manifest for UNI_APP_NAME failed', e);
}
if (process.env.NODE_ENV === 'production') {
const manifestJson = uniCliShared.parseManifestJsonOnce(inputDir);
if (!manifestJson.appid) {
uniStatLog(uniCliShared.M['stat.warn.appid']);
isEnable = false;
}
else {
logStatEnabledTip(platform, statType);
}
}
else {
logStatEnabledTip(platform, statType);
}
}
debug__default.default('uni:stat')('isEnable', isEnable, 'type', statType);
}
process.env.UNI_STAT_TITLE_JSON = JSON.stringify(titlesJson);
return {
define: {
// 与 UNI_APP_NAME 同理:外层 JSON.stringify 才能得到合法的内联字符串字面量
'process.env.UNI_STAT_TITLE_JSON': JSON.stringify((_a = process.env.UNI_STAT_TITLE_JSON) !== null && _a !== void 0 ? _a : '{}'),
'process.env.UNI_STAT_UNI_CLOUD': JSON.stringify((_b = process.env.UNI_STAT_UNI_CLOUD) !== null && _b !== void 0 ? _b : '{}'),
// 注意:define 的 value 是「替换后的源码字面量」,必须 JSON.stringify 一次,
// 否则 'true' / 'false' 字符串会被当成布尔字面量替换进源码,导致
// dist 中 `process.env.UNI_STAT_DEBUG === 'true'` 永远等于 false(公有版调试日志失效根因)。
'process.env.UNI_STAT_DEBUG': JSON.stringify((_c = process.env.UNI_STAT_DEBUG) !== null && _c !== void 0 ? _c : 'false'),
// 与 UNI_STAT_TITLE_JSON 同理:`statConfig` 已是 JSON 字符串,若不经
// JSON.stringify 再包一层,esbuild/vite define 会把串内 `"` 当成源码边界,
// 运行时替换结果残缺 → JSON.parse 失败 → readManifestStatConfig 静默回退,
// manifest 里的 backgroundTimeout / pageInactiveTimeout 等全部丢失(表现为默认 300/1800)。
'process.env.UNI_STATISTICS_CONFIG': JSON.stringify((_d = process.env.UNI_STATISTICS_CONFIG) !== null && _d !== void 0 ? _d : '{}'),
'process.env.UNI_APP_NAME': JSON.stringify((_e = process.env.UNI_APP_NAME) !== null && _e !== void 0 ? _e : ''),
'process.env.UNI_STAT_VAPOR': JSON.stringify(vaporLifecycleEnabled ? 'true' : 'false'),
},
};
},
resolveId(id) {
return stats[id] || null;
},
transform(code, id) {
if (isEnable && vaporLifecycleEnabled && opts.filter(id)) {
const importPath = statType === 'private'
? '@dcloudio/uni-cloud-stat-vapor'
: resolvePublicStatImportPath(currentPlatform);
return {
code: code + `;import '${importPath}';`,
map: null,
};
}
if (isEnable && shouldImportRuntime && opts.filter(id)) {
// 新编译器只保留类型分流:
// public → @dcloudio/uni-stat-public
// private → @dcloudio/uni-cloud-stat
//
// 兼容旧配置:
// type 缺失时回退 version(2=private,其余=public)
const importPath = statType === 'private'
? '@dcloudio/uni-cloud-stat'
: resolvePublicStatImportPath(currentPlatform);
return {
code: code + `;import '${importPath}';`,
map: null,
};
}
},
};
}),
];
module.exports = index;
+1
View File
@@ -0,0 +1 @@
[https://dcloud.io/license/uni-app.html](https://dcloud.io/license/uni-app.html)
+30
View File
@@ -0,0 +1,30 @@
{
"name": "@dcloudio/uni-stat",
"version": "3.0.0-alpha-5030620261112001",
"description": "@dcloudio/uni-stat",
"main": "dist/uni-stat.es.js",
"module": "dist/uni-stat.es.js",
"files": [
"dist",
"lib"
],
"sideEffects": false,
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/uni-stat"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/dcloudio/uni-app/issues"
},
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
"dependencies": {
"debug": "4.3.7",
"@dcloudio/uni-shared": "3.0.0-alpha-5030620261112001",
"@dcloudio/uni-cli-shared": "3.0.0-alpha-5030620261112001"
},
"devDependencies": {
"@types/debug": "4.1.12"
}
}