@umijs/plugins 4.0.28 → 4.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics.d.ts +1 -1
- package/dist/analytics.js +41 -12
- package/dist/antd.js +6 -0
- package/libs/locale/localeExports.tpl +2 -0
- package/package.json +3 -3
package/dist/analytics.d.ts
CHANGED
package/dist/analytics.js
CHANGED
|
@@ -24,6 +24,7 @@ __export(analytics_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(analytics_exports);
|
|
25
25
|
var analytics_default = (api) => {
|
|
26
26
|
const GA_KEY = process.env.GA_KEY;
|
|
27
|
+
const GA_V2_KEY = process.env.GA_V2_KEY;
|
|
27
28
|
const enableBy = (opts) => {
|
|
28
29
|
return opts.config.analytics || GA_KEY;
|
|
29
30
|
};
|
|
@@ -31,7 +32,11 @@ var analytics_default = (api) => {
|
|
|
31
32
|
key: "analytics",
|
|
32
33
|
config: {
|
|
33
34
|
schema(Joi) {
|
|
34
|
-
return Joi.alternatives().try(Joi.object(
|
|
35
|
+
return Joi.alternatives().try(Joi.object({
|
|
36
|
+
baidu: Joi.string(),
|
|
37
|
+
ga: Joi.string(),
|
|
38
|
+
ga_v2: Joi.string()
|
|
39
|
+
}), Joi.boolean().invalid(true));
|
|
35
40
|
},
|
|
36
41
|
onChange: api.ConfigChangeType.reload
|
|
37
42
|
},
|
|
@@ -68,20 +73,44 @@ var analytics_default = (api) => {
|
|
|
68
73
|
})();
|
|
69
74
|
`;
|
|
70
75
|
};
|
|
76
|
+
const gaV2Tpl = (code) => {
|
|
77
|
+
return `
|
|
78
|
+
window.dataLayer = window.dataLayer || [];
|
|
79
|
+
function gtag(){dataLayer.push(arguments);}
|
|
80
|
+
gtag('js', new Date());
|
|
81
|
+
gtag('config', '${code}');
|
|
82
|
+
`.trim();
|
|
83
|
+
};
|
|
71
84
|
api.addHTMLHeadScripts(() => {
|
|
72
|
-
const
|
|
73
|
-
const { ga = GA_KEY,
|
|
74
|
-
|
|
75
|
-
|
|
85
|
+
const analytics = api.config.analytics || {};
|
|
86
|
+
const { baidu, ga = GA_KEY, ga_v2 = GA_V2_KEY } = analytics;
|
|
87
|
+
const scripts = [];
|
|
88
|
+
if (baidu) {
|
|
89
|
+
scripts.push({
|
|
76
90
|
content: "var _hmt = _hmt || [];"
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if (api.env !== "development") {
|
|
94
|
+
if (baidu) {
|
|
95
|
+
scripts.push({
|
|
96
|
+
content: baiduTpl(baidu)
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (ga) {
|
|
100
|
+
scripts.push({
|
|
101
|
+
content: gaTpl(ga)
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (ga_v2) {
|
|
105
|
+
scripts.push({
|
|
106
|
+
async: true,
|
|
107
|
+
src: `//www.googletagmanager.com/gtag/js?id=${ga_v2}`
|
|
108
|
+
}, {
|
|
109
|
+
content: gaV2Tpl(ga_v2)
|
|
110
|
+
});
|
|
83
111
|
}
|
|
84
|
-
|
|
112
|
+
}
|
|
113
|
+
return scripts.filter(Boolean);
|
|
85
114
|
});
|
|
86
115
|
};
|
|
87
116
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/antd.js
CHANGED
|
@@ -74,6 +74,7 @@ var antd_default = (api) => {
|
|
|
74
74
|
return memo;
|
|
75
75
|
});
|
|
76
76
|
api.modifyConfig((memo) => {
|
|
77
|
+
var _a;
|
|
77
78
|
checkPkgPath();
|
|
78
79
|
let antd = memo.antd || {};
|
|
79
80
|
if (process.env.UMI_PLUGIN_ANTD_ENABLE) {
|
|
@@ -90,6 +91,11 @@ var antd_default = (api) => {
|
|
|
90
91
|
...theme,
|
|
91
92
|
...memo.theme
|
|
92
93
|
};
|
|
94
|
+
if ((_a = memo.antd) == null ? void 0 : _a.import) {
|
|
95
|
+
const errorMessage = `Can't set antd.import=true while using antd5 (${antdVersion})`;
|
|
96
|
+
api.logger.fatal("please change config antd.import to false, then start server again");
|
|
97
|
+
throw Error(errorMessage);
|
|
98
|
+
}
|
|
93
99
|
}
|
|
94
100
|
if (antd.dark || antd.compact) {
|
|
95
101
|
const { getThemeVariables } = require("antd/dist/theme");
|
|
@@ -116,6 +116,8 @@ export const getIntl = (locale?: string, changeIntl?: boolean) => {
|
|
|
116
116
|
if (g_intl && !changeIntl && !locale) {
|
|
117
117
|
return g_intl;
|
|
118
118
|
}
|
|
119
|
+
// 获取当前 locale
|
|
120
|
+
if (!locale) locale = getLocale();
|
|
119
121
|
// 如果存在于 localeInfo 中
|
|
120
122
|
if (locale&&localeInfo[locale]) {
|
|
121
123
|
return createIntl(localeInfo[locale]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.29",
|
|
4
4
|
"description": "@umijs/plugins",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/plugins#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@ant-design/antd-theme-variable": "^1.0.0",
|
|
28
28
|
"@ant-design/icons": "^4.7.0",
|
|
29
29
|
"@ant-design/pro-components": "^2.0.1",
|
|
30
|
-
"@umijs/bundler-utils": "4.0.
|
|
30
|
+
"@umijs/bundler-utils": "4.0.29",
|
|
31
31
|
"@umijs/valtio": "^1.0.0",
|
|
32
32
|
"antd-dayjs-webpack-plugin": "^1.0.6",
|
|
33
33
|
"axios": "^0.27.2",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"warning": "^4.0.3"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"umi": "4.0.
|
|
51
|
+
"umi": "4.0.29"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|