yuang-framework-ui-pc 1.1.94 → 1.1.95

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.
@@ -5,13 +5,14 @@ import { ComponentResolver } from 'unplugin-vue-components/types';
5
5
  */
6
6
  export interface EleAdminResolverOptions {
7
7
  /** 包路径 */
8
- path?: string | '/es' | '/lib';
8
+ path?: string | '' | '/es' | '/lib' | '/es/core' | '/lib/core';
9
9
  /** 排除的组件名称 */
10
10
  exclude?: string[];
11
11
  /** 是否导入样式 */
12
12
  importStyle?: boolean | 'css' | 'sass';
13
13
  }
14
14
  /**
15
- * 极简版组件解析器:仅返回单个配置,避免数组兼容性问题
15
+ * 按需加载插件,这里控制打包后的组件按需加载,如果匹配不上,会出现:开发环境组件正常显示,但是生产环境无法解析组件的情况
16
+ * @param options 参数
16
17
  */
17
18
  export declare function EleAdminResolver(options?: EleAdminResolverOptions): ComponentResolver;
@@ -1,29 +1,49 @@
1
- function EleAdminResolver(options = { path: "/es", exclude: [], importStyle: true }) {
2
- const packageName = "yuang-framework-ui-pc";
3
- const {
4
- path = "/es",
5
- exclude = [],
6
- importStyle = true
7
- } = options;
1
+ function getSideEffects(path, options) {
2
+ const importStyle = options == null ? void 0 : options.importStyle;
3
+ if (!importStyle) {
4
+ return;
5
+ }
6
+ if (importStyle === "css") {
7
+ return `${path}/style/css`;
8
+ }
9
+ return `${path}/style/index`;
10
+ }
11
+ function getStylePath(namePath, packageName, path) {
12
+ if (!path) {
13
+ return `${packageName}/es/${namePath}`;
14
+ }
15
+ if (path === "/es/core") {
16
+ return `${packageName}/es/${namePath}`;
17
+ }
18
+ if (path === "/lib/core") {
19
+ return `${packageName}/lib/${namePath}`;
20
+ }
21
+ return `${packageName}${path}/${namePath}`;
22
+ }
23
+ function EleAdminResolver(options) {
8
24
  return {
9
25
  type: "component",
10
26
  resolve: (name) => {
11
- if (!/^(Ele|Yu)/.test(name) || exclude.includes(name)) {
12
- console.log(`[解析跳过] 组件${name}:非Ele/Yu开头或在排除列表`);
13
- return void 0;
27
+ var _a;
28
+ const { path, exclude } = options || {};
29
+ const isMatch = /^(Ele|Yu)/.test(name) && !((_a = exclude == null ? void 0 : exclude.includes) == null ? void 0 : _a.call(exclude, name));
30
+ console.log("按需加载插件:" + name + ",是否匹配:" + isMatch);
31
+ if (isMatch) {
32
+ const packageName = "yuang-framework-ui-pc";
33
+ const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").join("-").toLowerCase();
34
+ const stylePath = getStylePath(namePath, packageName, path);
35
+ if (!path || path === "/es/core" || path === "/lib/core") {
36
+ return {
37
+ name,
38
+ from: `${packageName}${path ?? "/es"}`,
39
+ sideEffects: getSideEffects(stylePath, options)
40
+ };
41
+ }
42
+ return {
43
+ from: `${packageName}${path}/${namePath}/index`,
44
+ sideEffects: getSideEffects(stylePath, options)
45
+ };
14
46
  }
15
- const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").filter(Boolean).join("-").toLowerCase();
16
- const basePath = path === "/lib" ? "/lib" : "/es";
17
- const fromPath = `${packageName}${basePath}/${namePath}/index`;
18
- const stylePath = `${packageName}${basePath}/${namePath}`;
19
- const sideEffects = importStyle ? importStyle === "css" ? `${stylePath}/style/css` : `${stylePath}/style/index` : void 0;
20
- const resolveConfig = {
21
- name,
22
- from: fromPath,
23
- sideEffects
24
- };
25
- console.log(`[解析成功] 组件${name} -> 路径: ${fromPath},样式: ${sideEffects}`);
26
- return resolveConfig;
27
47
  }
28
48
  };
29
49
  }
@@ -1,31 +1,51 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- function EleAdminResolver(options = { path: "/es", exclude: [], importStyle: true }) {
4
- const packageName = "yuang-framework-ui-pc";
5
- const {
6
- path = "/es",
7
- exclude = [],
8
- importStyle = true
9
- } = options;
3
+ function getSideEffects(path, options) {
4
+ const importStyle = options == null ? void 0 : options.importStyle;
5
+ if (!importStyle) {
6
+ return;
7
+ }
8
+ if (importStyle === "css") {
9
+ return `${path}/style/css`;
10
+ }
11
+ return `${path}/style/index`;
12
+ }
13
+ function getStylePath(namePath, packageName, path) {
14
+ if (!path) {
15
+ return `${packageName}/es/${namePath}`;
16
+ }
17
+ if (path === "/es/core") {
18
+ return `${packageName}/es/${namePath}`;
19
+ }
20
+ if (path === "/lib/core") {
21
+ return `${packageName}/lib/${namePath}`;
22
+ }
23
+ return `${packageName}${path}/${namePath}`;
24
+ }
25
+ function EleAdminResolver(options) {
10
26
  return {
11
27
  type: "component",
12
28
  resolve: (name) => {
13
- if (!/^(Ele|Yu)/.test(name) || exclude.includes(name)) {
14
- console.log(`[解析跳过] 组件${name}:非Ele/Yu开头或在排除列表`);
15
- return void 0;
29
+ var _a;
30
+ const { path, exclude } = options || {};
31
+ const isMatch = /^(Ele|Yu)/.test(name) && !((_a = exclude == null ? void 0 : exclude.includes) == null ? void 0 : _a.call(exclude, name));
32
+ console.log("按需加载插件:" + name + ",是否匹配:" + isMatch);
33
+ if (isMatch) {
34
+ const packageName = "yuang-framework-ui-pc";
35
+ const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").join("-").toLowerCase();
36
+ const stylePath = getStylePath(namePath, packageName, path);
37
+ if (!path || path === "/es/core" || path === "/lib/core") {
38
+ return {
39
+ name,
40
+ from: `${packageName}${path ?? "/es"}`,
41
+ sideEffects: getSideEffects(stylePath, options)
42
+ };
43
+ }
44
+ return {
45
+ from: `${packageName}${path}/${namePath}/index`,
46
+ sideEffects: getSideEffects(stylePath, options)
47
+ };
16
48
  }
17
- const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").filter(Boolean).join("-").toLowerCase();
18
- const basePath = path === "/lib" ? "/lib" : "/es";
19
- const fromPath = `${packageName}${basePath}/${namePath}/index`;
20
- const stylePath = `${packageName}${basePath}/${namePath}`;
21
- const sideEffects = importStyle ? importStyle === "css" ? `${stylePath}/style/css` : `${stylePath}/style/index` : void 0;
22
- const resolveConfig = {
23
- name,
24
- from: fromPath,
25
- sideEffects
26
- };
27
- console.log(`[解析成功] 组件${name} -> 路径: ${fromPath},样式: ${sideEffects}`);
28
- return resolveConfig;
29
49
  }
30
50
  };
31
51
  }
@@ -5,13 +5,14 @@ import { ComponentResolver } from 'unplugin-vue-components/types';
5
5
  */
6
6
  export interface EleAdminResolverOptions {
7
7
  /** 包路径 */
8
- path?: string | '/es' | '/lib';
8
+ path?: string | '' | '/es' | '/lib' | '/es/core' | '/lib/core';
9
9
  /** 排除的组件名称 */
10
10
  exclude?: string[];
11
11
  /** 是否导入样式 */
12
12
  importStyle?: boolean | 'css' | 'sass';
13
13
  }
14
14
  /**
15
- * 极简版组件解析器:仅返回单个配置,避免数组兼容性问题
15
+ * 按需加载插件,这里控制打包后的组件按需加载,如果匹配不上,会出现:开发环境组件正常显示,但是生产环境无法解析组件的情况
16
+ * @param options 参数
16
17
  */
17
18
  export declare function EleAdminResolver(options?: EleAdminResolverOptions): ComponentResolver;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuang-framework-ui-pc",
3
- "version": "1.1.94",
3
+ "version": "1.1.95",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite --host --config vite.global.ts --mode dev",