yuang-framework-ui-pc 1.1.90 → 1.1.92
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/es/utils/resolvers.d.ts +1 -1
- package/es/utils/resolvers.js +34 -25
- package/lib/utils/resolvers.cjs +34 -25
- package/lib/utils/resolvers.d.ts +1 -1
- package/package.json +1 -1
package/es/utils/resolvers.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface EleAdminResolverOptions {
|
|
|
12
12
|
importStyle?: boolean | 'css' | 'sass';
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* 按需加载插件(彻底修复undefined路径问题)
|
|
16
16
|
* @param options 参数
|
|
17
17
|
*/
|
|
18
18
|
export declare function EleAdminResolver(options?: EleAdminResolverOptions): ComponentResolver;
|
package/es/utils/resolvers.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
function getSideEffects(path, options) {
|
|
2
|
+
if (!path) return void 0;
|
|
2
3
|
const importStyle = options == null ? void 0 : options.importStyle;
|
|
3
4
|
if (!importStyle) {
|
|
4
|
-
return;
|
|
5
|
+
return void 0;
|
|
5
6
|
}
|
|
6
7
|
if (importStyle === "css") {
|
|
7
8
|
return `${path}/style/css`;
|
|
@@ -9,16 +10,15 @@ function getSideEffects(path, options) {
|
|
|
9
10
|
return `${path}/style/index`;
|
|
10
11
|
}
|
|
11
12
|
function getStylePath(namePath, packageName, path = "/es") {
|
|
12
|
-
|
|
13
|
+
const safePath = path || "/es";
|
|
14
|
+
if (["", "/es/core", "/lib/core"].includes(safePath)) {
|
|
13
15
|
return `${packageName}/es/${namePath}`;
|
|
14
16
|
}
|
|
15
|
-
|
|
17
|
+
const finalPath = safePath.startsWith("/") ? safePath : `/${safePath}`;
|
|
18
|
+
return `${packageName}${finalPath}/${namePath}`;
|
|
16
19
|
}
|
|
17
20
|
const componentDependencyMap = {
|
|
18
21
|
YuFrameworkAttachmentUpload: ["EleUploadList"]
|
|
19
|
-
// 可继续添加其他依赖:
|
|
20
|
-
// EleTable: ['EleTableColumn'],
|
|
21
|
-
// EleForm: ['EleFormItem', 'EleInput']
|
|
22
22
|
};
|
|
23
23
|
const allNeedResolveComponents = /* @__PURE__ */ new Set();
|
|
24
24
|
Object.keys(componentDependencyMap).forEach((parent) => allNeedResolveComponents.add(parent));
|
|
@@ -28,23 +28,28 @@ Object.values(componentDependencyMap).forEach((children) => {
|
|
|
28
28
|
function generateComponentResolveConfig(name, options) {
|
|
29
29
|
const { path = "/es", exclude = [] } = options || {};
|
|
30
30
|
const packageName = "yuang-framework-ui-pc";
|
|
31
|
-
const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").join("-").toLowerCase();
|
|
31
|
+
const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").filter(Boolean).join("-").toLowerCase() || name.toLowerCase();
|
|
32
32
|
const stylePath = getStylePath(namePath, packageName, path);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
from: `${packageName}${path}`,
|
|
37
|
-
// path已有默认值,无需??兜底
|
|
38
|
-
sideEffects: getSideEffects(stylePath, options)
|
|
39
|
-
};
|
|
33
|
+
let fromPath = "";
|
|
34
|
+
if (["", "/es/core", "/lib/core"].includes(path)) {
|
|
35
|
+
fromPath = `${packageName}${path || "/es"}`;
|
|
40
36
|
} else {
|
|
41
|
-
|
|
42
|
-
name,
|
|
43
|
-
// 关键修复:补充name字段,符合解析配置规范
|
|
44
|
-
from: `${packageName}${path}/${namePath}/index`,
|
|
45
|
-
sideEffects: getSideEffects(stylePath, options)
|
|
46
|
-
};
|
|
37
|
+
fromPath = `${packageName}${path.startsWith("/") ? path : "/" + path}/${namePath}/index`;
|
|
47
38
|
}
|
|
39
|
+
fromPath = fromPath.replace("undefined", "").replace(/\/+/g, "/");
|
|
40
|
+
if (!fromPath || fromPath === packageName) {
|
|
41
|
+
fromPath = `${packageName}/es/${namePath}`;
|
|
42
|
+
}
|
|
43
|
+
const config = {
|
|
44
|
+
name: name || "",
|
|
45
|
+
from: fromPath,
|
|
46
|
+
sideEffects: getSideEffects(stylePath, options)
|
|
47
|
+
};
|
|
48
|
+
if (config.from.includes("undefined") || !config.from) {
|
|
49
|
+
console.error(`[配置修复] 组件${name}的from路径异常,强制兜底为: ${packageName}/es/${namePath}`);
|
|
50
|
+
config.from = `${packageName}/es/${namePath}`;
|
|
51
|
+
}
|
|
52
|
+
return config;
|
|
48
53
|
}
|
|
49
54
|
function EleAdminResolver(options = { path: "/es", exclude: [], importStyle: true }) {
|
|
50
55
|
return {
|
|
@@ -52,16 +57,20 @@ function EleAdminResolver(options = { path: "/es", exclude: [], importStyle: tru
|
|
|
52
57
|
resolve: (name) => {
|
|
53
58
|
const { exclude = [] } = options;
|
|
54
59
|
const isMatch = /^(Ele|Yu)/.test(name) && !exclude.includes(name) && allNeedResolveComponents.has(name);
|
|
55
|
-
console.log(
|
|
60
|
+
console.log(`[匹配校验] 组件名: ${name},是否匹配: ${isMatch}`);
|
|
56
61
|
if (isMatch) {
|
|
57
62
|
const currentConfig = generateComponentResolveConfig(name, options);
|
|
63
|
+
if (currentConfig.from.includes("undefined")) {
|
|
64
|
+
console.error(`[当前组件错误] ${name} 的from路径异常: ${currentConfig.from}`);
|
|
65
|
+
}
|
|
58
66
|
const dependencyList = componentDependencyMap[name];
|
|
59
67
|
if (dependencyList && dependencyList.length) {
|
|
60
|
-
const dependencyConfigs = dependencyList.map(
|
|
61
|
-
|
|
62
|
-
);
|
|
63
|
-
return
|
|
68
|
+
const dependencyConfigs = dependencyList.map((depName) => generateComponentResolveConfig(depName, options)).filter((config) => !!config && !!config.from);
|
|
69
|
+
const allConfigs = [currentConfig, ...dependencyConfigs].filter(Boolean);
|
|
70
|
+
console.log(`[返回配置] 组件${name}的解析配置:`, JSON.stringify(allConfigs));
|
|
71
|
+
return allConfigs;
|
|
64
72
|
}
|
|
73
|
+
console.log(`[返回配置] 组件${name}的解析配置:`, JSON.stringify(currentConfig));
|
|
65
74
|
return currentConfig;
|
|
66
75
|
}
|
|
67
76
|
return void 0;
|
package/lib/utils/resolvers.cjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
function getSideEffects(path, options) {
|
|
4
|
+
if (!path) return void 0;
|
|
4
5
|
const importStyle = options == null ? void 0 : options.importStyle;
|
|
5
6
|
if (!importStyle) {
|
|
6
|
-
return;
|
|
7
|
+
return void 0;
|
|
7
8
|
}
|
|
8
9
|
if (importStyle === "css") {
|
|
9
10
|
return `${path}/style/css`;
|
|
@@ -11,16 +12,15 @@ function getSideEffects(path, options) {
|
|
|
11
12
|
return `${path}/style/index`;
|
|
12
13
|
}
|
|
13
14
|
function getStylePath(namePath, packageName, path = "/es") {
|
|
14
|
-
|
|
15
|
+
const safePath = path || "/es";
|
|
16
|
+
if (["", "/es/core", "/lib/core"].includes(safePath)) {
|
|
15
17
|
return `${packageName}/es/${namePath}`;
|
|
16
18
|
}
|
|
17
|
-
|
|
19
|
+
const finalPath = safePath.startsWith("/") ? safePath : `/${safePath}`;
|
|
20
|
+
return `${packageName}${finalPath}/${namePath}`;
|
|
18
21
|
}
|
|
19
22
|
const componentDependencyMap = {
|
|
20
23
|
YuFrameworkAttachmentUpload: ["EleUploadList"]
|
|
21
|
-
// 可继续添加其他依赖:
|
|
22
|
-
// EleTable: ['EleTableColumn'],
|
|
23
|
-
// EleForm: ['EleFormItem', 'EleInput']
|
|
24
24
|
};
|
|
25
25
|
const allNeedResolveComponents = /* @__PURE__ */ new Set();
|
|
26
26
|
Object.keys(componentDependencyMap).forEach((parent) => allNeedResolveComponents.add(parent));
|
|
@@ -30,23 +30,28 @@ Object.values(componentDependencyMap).forEach((children) => {
|
|
|
30
30
|
function generateComponentResolveConfig(name, options) {
|
|
31
31
|
const { path = "/es", exclude = [] } = options || {};
|
|
32
32
|
const packageName = "yuang-framework-ui-pc";
|
|
33
|
-
const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").join("-").toLowerCase();
|
|
33
|
+
const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").filter(Boolean).join("-").toLowerCase() || name.toLowerCase();
|
|
34
34
|
const stylePath = getStylePath(namePath, packageName, path);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
from: `${packageName}${path}`,
|
|
39
|
-
// path已有默认值,无需??兜底
|
|
40
|
-
sideEffects: getSideEffects(stylePath, options)
|
|
41
|
-
};
|
|
35
|
+
let fromPath = "";
|
|
36
|
+
if (["", "/es/core", "/lib/core"].includes(path)) {
|
|
37
|
+
fromPath = `${packageName}${path || "/es"}`;
|
|
42
38
|
} else {
|
|
43
|
-
|
|
44
|
-
name,
|
|
45
|
-
// 关键修复:补充name字段,符合解析配置规范
|
|
46
|
-
from: `${packageName}${path}/${namePath}/index`,
|
|
47
|
-
sideEffects: getSideEffects(stylePath, options)
|
|
48
|
-
};
|
|
39
|
+
fromPath = `${packageName}${path.startsWith("/") ? path : "/" + path}/${namePath}/index`;
|
|
49
40
|
}
|
|
41
|
+
fromPath = fromPath.replace("undefined", "").replace(/\/+/g, "/");
|
|
42
|
+
if (!fromPath || fromPath === packageName) {
|
|
43
|
+
fromPath = `${packageName}/es/${namePath}`;
|
|
44
|
+
}
|
|
45
|
+
const config = {
|
|
46
|
+
name: name || "",
|
|
47
|
+
from: fromPath,
|
|
48
|
+
sideEffects: getSideEffects(stylePath, options)
|
|
49
|
+
};
|
|
50
|
+
if (config.from.includes("undefined") || !config.from) {
|
|
51
|
+
console.error(`[配置修复] 组件${name}的from路径异常,强制兜底为: ${packageName}/es/${namePath}`);
|
|
52
|
+
config.from = `${packageName}/es/${namePath}`;
|
|
53
|
+
}
|
|
54
|
+
return config;
|
|
50
55
|
}
|
|
51
56
|
function EleAdminResolver(options = { path: "/es", exclude: [], importStyle: true }) {
|
|
52
57
|
return {
|
|
@@ -54,16 +59,20 @@ function EleAdminResolver(options = { path: "/es", exclude: [], importStyle: tru
|
|
|
54
59
|
resolve: (name) => {
|
|
55
60
|
const { exclude = [] } = options;
|
|
56
61
|
const isMatch = /^(Ele|Yu)/.test(name) && !exclude.includes(name) && allNeedResolveComponents.has(name);
|
|
57
|
-
console.log(
|
|
62
|
+
console.log(`[匹配校验] 组件名: ${name},是否匹配: ${isMatch}`);
|
|
58
63
|
if (isMatch) {
|
|
59
64
|
const currentConfig = generateComponentResolveConfig(name, options);
|
|
65
|
+
if (currentConfig.from.includes("undefined")) {
|
|
66
|
+
console.error(`[当前组件错误] ${name} 的from路径异常: ${currentConfig.from}`);
|
|
67
|
+
}
|
|
60
68
|
const dependencyList = componentDependencyMap[name];
|
|
61
69
|
if (dependencyList && dependencyList.length) {
|
|
62
|
-
const dependencyConfigs = dependencyList.map(
|
|
63
|
-
|
|
64
|
-
);
|
|
65
|
-
return
|
|
70
|
+
const dependencyConfigs = dependencyList.map((depName) => generateComponentResolveConfig(depName, options)).filter((config) => !!config && !!config.from);
|
|
71
|
+
const allConfigs = [currentConfig, ...dependencyConfigs].filter(Boolean);
|
|
72
|
+
console.log(`[返回配置] 组件${name}的解析配置:`, JSON.stringify(allConfigs));
|
|
73
|
+
return allConfigs;
|
|
66
74
|
}
|
|
75
|
+
console.log(`[返回配置] 组件${name}的解析配置:`, JSON.stringify(currentConfig));
|
|
67
76
|
return currentConfig;
|
|
68
77
|
}
|
|
69
78
|
return void 0;
|
package/lib/utils/resolvers.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface EleAdminResolverOptions {
|
|
|
12
12
|
importStyle?: boolean | 'css' | 'sass';
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* 按需加载插件(彻底修复undefined路径问题)
|
|
16
16
|
* @param options 参数
|
|
17
17
|
*/
|
|
18
18
|
export declare function EleAdminResolver(options?: EleAdminResolverOptions): ComponentResolver;
|