@meng-xi/vite-plugin 0.1.3 → 0.1.4

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.
Files changed (75) hide show
  1. package/README-en.md +48 -774
  2. package/README.md +45 -769
  3. package/dist/common/html/index.cjs +2 -2
  4. package/dist/common/html/index.d.cts +268 -19
  5. package/dist/common/html/index.d.mts +268 -19
  6. package/dist/common/html/index.d.ts +268 -19
  7. package/dist/common/html/index.mjs +2 -2
  8. package/dist/common/index.cjs +1 -1
  9. package/dist/common/index.d.cts +4 -1
  10. package/dist/common/index.d.mts +4 -1
  11. package/dist/common/index.d.ts +4 -1
  12. package/dist/common/index.mjs +1 -1
  13. package/dist/common/ui/index.cjs +1 -0
  14. package/dist/common/ui/index.d.cts +132 -0
  15. package/dist/common/ui/index.d.mts +132 -0
  16. package/dist/common/ui/index.d.ts +132 -0
  17. package/dist/common/ui/index.mjs +1 -0
  18. package/dist/common/validation/index.cjs +1 -1
  19. package/dist/common/validation/index.d.cts +1 -0
  20. package/dist/common/validation/index.d.mts +1 -0
  21. package/dist/common/validation/index.d.ts +1 -0
  22. package/dist/common/validation/index.mjs +1 -1
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.d.cts +6 -2
  25. package/dist/index.d.mts +6 -2
  26. package/dist/index.d.ts +6 -2
  27. package/dist/index.mjs +1 -1
  28. package/dist/plugins/buildProgress/index.cjs +2 -2
  29. package/dist/plugins/buildProgress/index.mjs +2 -2
  30. package/dist/plugins/copyFile/index.d.cts +20 -2
  31. package/dist/plugins/copyFile/index.d.mts +20 -2
  32. package/dist/plugins/copyFile/index.d.ts +20 -2
  33. package/dist/plugins/envGuard/index.cjs +67 -0
  34. package/dist/plugins/envGuard/index.d.cts +156 -0
  35. package/dist/plugins/envGuard/index.d.mts +156 -0
  36. package/dist/plugins/envGuard/index.d.ts +156 -0
  37. package/dist/plugins/envGuard/index.mjs +67 -0
  38. package/dist/plugins/faviconManager/index.cjs +1 -1
  39. package/dist/plugins/faviconManager/index.d.cts +43 -5
  40. package/dist/plugins/faviconManager/index.d.mts +43 -5
  41. package/dist/plugins/faviconManager/index.d.ts +43 -5
  42. package/dist/plugins/faviconManager/index.mjs +1 -1
  43. package/dist/plugins/generateRouter/index.d.cts +61 -14
  44. package/dist/plugins/generateRouter/index.d.mts +61 -14
  45. package/dist/plugins/generateRouter/index.d.ts +61 -14
  46. package/dist/plugins/generateVersion/index.d.cts +12 -0
  47. package/dist/plugins/generateVersion/index.d.mts +12 -0
  48. package/dist/plugins/generateVersion/index.d.ts +12 -0
  49. package/dist/plugins/htmlInject/index.cjs +1 -7
  50. package/dist/plugins/htmlInject/index.d.cts +49 -194
  51. package/dist/plugins/htmlInject/index.d.mts +49 -194
  52. package/dist/plugins/htmlInject/index.d.ts +49 -194
  53. package/dist/plugins/htmlInject/index.mjs +1 -7
  54. package/dist/plugins/index.cjs +1 -1
  55. package/dist/plugins/index.d.cts +4 -1
  56. package/dist/plugins/index.d.mts +4 -1
  57. package/dist/plugins/index.d.ts +4 -1
  58. package/dist/plugins/index.mjs +1 -1
  59. package/dist/plugins/loadingManager/index.cjs +2 -2
  60. package/dist/plugins/loadingManager/index.mjs +1 -1
  61. package/dist/plugins/versionUpdateChecker/index.cjs +2 -2
  62. package/dist/plugins/versionUpdateChecker/index.mjs +3 -3
  63. package/dist/shared/vite-plugin.BCuhU1au.mjs +7 -0
  64. package/dist/shared/vite-plugin.BrI73DHA.cjs +7 -0
  65. package/dist/shared/vite-plugin.CmtcnItg.d.cts +261 -0
  66. package/dist/shared/vite-plugin.CmtcnItg.d.mts +261 -0
  67. package/dist/shared/vite-plugin.CmtcnItg.d.ts +261 -0
  68. package/dist/shared/vite-plugin.DnFDPjNf.mjs +1 -0
  69. package/dist/shared/vite-plugin.Dumot0up.mjs +1 -0
  70. package/dist/shared/vite-plugin.FfJ-Wwfu.d.cts +143 -0
  71. package/dist/shared/vite-plugin.FfJ-Wwfu.d.mts +143 -0
  72. package/dist/shared/vite-plugin.FfJ-Wwfu.d.ts +143 -0
  73. package/dist/shared/vite-plugin.soT9a-KD.cjs +1 -0
  74. package/dist/shared/vite-plugin.vwox4bU0.cjs +1 -0
  75. package/package.json +11 -1
@@ -7,22 +7,36 @@ import '../../shared/vite-plugin.DRRlWY8P.mjs';
7
7
  * 图标配置项接口
8
8
  *
9
9
  * @interface Icon
10
+ * @description 定义单个网站图标的属性,对应 HTML `<link>` 标签的各个属性。
10
11
  */
11
12
  interface Icon {
12
13
  /**
13
- * 图标关系类型
14
+ * 图标关系类型,对应 `<link>` 标签的 `rel` 属性
15
+ *
16
+ * @example 'icon'
17
+ * @example 'apple-touch-icon'
18
+ * @example 'manifest'
14
19
  */
15
20
  rel: string;
16
21
  /**
17
- * 图标 URL
22
+ * 图标 URL,对应 `<link>` 标签的 `href` 属性
23
+ *
24
+ * @example '/favicon.ico'
25
+ * @example '/apple-touch-icon.png'
18
26
  */
19
27
  href: string;
20
28
  /**
21
- * 图标尺寸
29
+ * 图标尺寸,对应 `<link>` 标签的 `sizes` 属性
30
+ *
31
+ * @example '32x32'
32
+ * @example '180x180'
22
33
  */
23
34
  sizes?: string;
24
35
  /**
25
- * 图标 MIME 类型
36
+ * 图标 MIME 类型,对应 `<link>` 标签的 `type` 属性
37
+ *
38
+ * @example 'image/png'
39
+ * @example 'image/svg+xml'
26
40
  */
27
41
  type?: string;
28
42
  }
@@ -30,6 +44,8 @@ interface Icon {
30
44
  * 图标文件复制配置选项接口
31
45
  *
32
46
  * @interface CopyOptions
47
+ * @description 配置图标文件从源目录到构建输出目录的复制行为,
48
+ * 仅当此对象存在时才开启图标文件复制功能。
33
49
  */
34
50
  interface CopyOptions {
35
51
  /**
@@ -51,7 +67,7 @@ interface CopyOptions {
51
67
  */
52
68
  overwrite?: boolean;
53
69
  /**
54
- * 是否支持递归复制
70
+ * 是否支持递归复制子目录
55
71
  *
56
72
  * @default true
57
73
  */
@@ -61,6 +77,28 @@ interface CopyOptions {
61
77
  * 网站图标管理插件的配置选项接口
62
78
  *
63
79
  * @interface FaviconManagerOptions
80
+ * @extends {BasePluginOptions}
81
+ *
82
+ * @description 支持三种图标配置方式(优先级从高到低):
83
+ * 1. `link` - 自定义完整的 `<link>` 标签 HTML
84
+ * 2. `url` - 完整的图标 URL
85
+ * 3. `base` + 默认 favicon.ico - 基础路径拼接
86
+ * 此外还支持通过 `icons` 数组配置多个图标,以及通过 `copyOptions` 复制图标文件。
87
+ *
88
+ * @example
89
+ * ```typescript
90
+ * faviconManager({
91
+ * base: '/assets',
92
+ * icons: [
93
+ * { rel: 'icon', href: '/favicon.svg', type: 'image/svg+xml' },
94
+ * { rel: 'icon', href: '/favicon-32x32.png', sizes: '32x32', type: 'image/png' }
95
+ * ],
96
+ * copyOptions: {
97
+ * sourceDir: 'src/assets/icons',
98
+ * targetDir: 'dist/assets/icons'
99
+ * }
100
+ * })
101
+ * ```
64
102
  */
65
103
  interface FaviconManagerOptions extends BasePluginOptions {
66
104
  /**
@@ -7,22 +7,36 @@ import '../../shared/vite-plugin.DRRlWY8P.js';
7
7
  * 图标配置项接口
8
8
  *
9
9
  * @interface Icon
10
+ * @description 定义单个网站图标的属性,对应 HTML `<link>` 标签的各个属性。
10
11
  */
11
12
  interface Icon {
12
13
  /**
13
- * 图标关系类型
14
+ * 图标关系类型,对应 `<link>` 标签的 `rel` 属性
15
+ *
16
+ * @example 'icon'
17
+ * @example 'apple-touch-icon'
18
+ * @example 'manifest'
14
19
  */
15
20
  rel: string;
16
21
  /**
17
- * 图标 URL
22
+ * 图标 URL,对应 `<link>` 标签的 `href` 属性
23
+ *
24
+ * @example '/favicon.ico'
25
+ * @example '/apple-touch-icon.png'
18
26
  */
19
27
  href: string;
20
28
  /**
21
- * 图标尺寸
29
+ * 图标尺寸,对应 `<link>` 标签的 `sizes` 属性
30
+ *
31
+ * @example '32x32'
32
+ * @example '180x180'
22
33
  */
23
34
  sizes?: string;
24
35
  /**
25
- * 图标 MIME 类型
36
+ * 图标 MIME 类型,对应 `<link>` 标签的 `type` 属性
37
+ *
38
+ * @example 'image/png'
39
+ * @example 'image/svg+xml'
26
40
  */
27
41
  type?: string;
28
42
  }
@@ -30,6 +44,8 @@ interface Icon {
30
44
  * 图标文件复制配置选项接口
31
45
  *
32
46
  * @interface CopyOptions
47
+ * @description 配置图标文件从源目录到构建输出目录的复制行为,
48
+ * 仅当此对象存在时才开启图标文件复制功能。
33
49
  */
34
50
  interface CopyOptions {
35
51
  /**
@@ -51,7 +67,7 @@ interface CopyOptions {
51
67
  */
52
68
  overwrite?: boolean;
53
69
  /**
54
- * 是否支持递归复制
70
+ * 是否支持递归复制子目录
55
71
  *
56
72
  * @default true
57
73
  */
@@ -61,6 +77,28 @@ interface CopyOptions {
61
77
  * 网站图标管理插件的配置选项接口
62
78
  *
63
79
  * @interface FaviconManagerOptions
80
+ * @extends {BasePluginOptions}
81
+ *
82
+ * @description 支持三种图标配置方式(优先级从高到低):
83
+ * 1. `link` - 自定义完整的 `<link>` 标签 HTML
84
+ * 2. `url` - 完整的图标 URL
85
+ * 3. `base` + 默认 favicon.ico - 基础路径拼接
86
+ * 此外还支持通过 `icons` 数组配置多个图标,以及通过 `copyOptions` 复制图标文件。
87
+ *
88
+ * @example
89
+ * ```typescript
90
+ * faviconManager({
91
+ * base: '/assets',
92
+ * icons: [
93
+ * { rel: 'icon', href: '/favicon.svg', type: 'image/svg+xml' },
94
+ * { rel: 'icon', href: '/favicon-32x32.png', sizes: '32x32', type: 'image/png' }
95
+ * ],
96
+ * copyOptions: {
97
+ * sourceDir: 'src/assets/icons',
98
+ * targetDir: 'dist/assets/icons'
99
+ * }
100
+ * })
101
+ * ```
64
102
  */
65
103
  interface FaviconManagerOptions extends BasePluginOptions {
66
104
  /**
@@ -1 +1 @@
1
- import{createPluginFactory as n,BasePlugin as a}from"../../factory/index.mjs";import{checkSourceExists as c,copySourceToTarget as l}from"../../common/fs/index.mjs";import{V as g}from"../../shared/vite-plugin.DcExl6jd.mjs";import{injectBeforeTag as p}from"../../common/html/index.mjs";import"../../logger/index.mjs";import"../../common/object/index.mjs";import"fs";import"path";function F(u){const i=[];if(u.link)return[];if(u.icons&&u.icons.length>0)for(const e of u.icons){const t={rel:e.rel,href:e.href};e.sizes&&(t.sizes=e.sizes),e.type&&(t.type=e.type),i.push({tag:"link",attrs:t,injectTo:"head"})}else if(u.url)i.push({tag:"link",attrs:{rel:"icon",href:u.url},injectTo:"head"});else{const e=u.base||"/",t=e.endsWith("/")?`${e}favicon.ico`:`${e}/favicon.ico`;i.push({tag:"link",attrs:{rel:"icon",href:t},injectTo:"head"})}return i}class h extends a{getDefaultOptions(){return{base:"/"}}validateOptions(){this.validator.field("base").string().field("url").string().field("link").string().field("icons").array(),this.options?.copyOptions&&(this.validator.field("copyOptions").object(),new g(this.options.copyOptions).field("sourceDir").required().string().field("targetDir").required().string().field("overwrite").boolean().field("recursive").boolean().validate()),this.validator.validate()}getPluginName(){return"favicon-manager"}getIconTagDescriptors(){if(!this.options.enabled)return this.logger.info("\u63D2\u4EF6\u5DF2\u7981\u7528\uFF0C\u8DF3\u8FC7\u56FE\u6807\u6CE8\u5165"),[];const i=F(this.options);return i.length>0&&this.logger.success(`\u6210\u529F\u6CE8\u5165 ${i.length} \u4E2A\u56FE\u6807\u6807\u7B7E\u5230 HTML \u6587\u4EF6`),i}injectCustomLinkTag(i){if(!this.options.enabled||!this.options.link)return i;const e=this.options.link,t=p(i,"</head>",e);return t.injected?(this.logger.success("\u6210\u529F\u6CE8\u5165\u81EA\u5B9A\u4E49\u56FE\u6807\u6807\u7B7E\u5230 HTML \u6587\u4EF6"),this.logger.info(` - ${e}`),t.html):(this.logger.warn("\u672A\u627E\u5230 </head> \u6807\u7B7E\uFF0C\u8DF3\u8FC7\u56FE\u6807\u6CE8\u5165"),i)}async copyFiles(){if(!this.options.enabled){this.logger.info("\u63D2\u4EF6\u5DF2\u7981\u7528\uFF0C\u8DF3\u8FC7\u6587\u4EF6\u590D\u5236");return}const{copyOptions:i}=this.options;if(!i)return;const{sourceDir:e,targetDir:t,overwrite:s=!0,recursive:o=!0}=i;await c(e);const r=await l(e,t,{recursive:o,overwrite:s,incremental:!0});this.logger.success(`\u56FE\u6807\u6587\u4EF6\u590D\u5236\u6210\u529F\uFF1A\u4ECE ${e} \u5230 ${t}`,`\u590D\u5236\u4E86 ${r.copiedFiles} \u4E2A\u6587\u4EF6\uFF0C\u8DF3\u8FC7\u4E86 ${r.skippedFiles} \u4E2A\u6587\u4EF6\uFF0C\u8017\u65F6 ${r.executionTime}ms`)}addPluginHooks(i){i.transformIndexHtml={order:"pre",handler:e=>{if(this.options.link)return this.injectCustomLinkTag(e);const t=this.getIconTagDescriptors();return t.length>0?{html:e,tags:t}:e}},i.writeBundle=async()=>{await this.safeExecute(()=>this.copyFiles(),"\u56FE\u6807\u6587\u4EF6\u590D\u5236")}}}const f=n(h,u=>typeof u=="string"?{base:u}:u||{});export{f as faviconManager};
1
+ import{createPluginFactory as n,BasePlugin as a}from"../../factory/index.mjs";import{checkSourceExists as c,copySourceToTarget as l}from"../../common/fs/index.mjs";import{V as g}from"../../shared/vite-plugin.DcExl6jd.mjs";import{injectBeforeTag as p}from"../../common/html/index.mjs";import"../../logger/index.mjs";import"../../common/object/index.mjs";import"fs";import"path";import"../../shared/vite-plugin.BCuhU1au.mjs";import"../../common/script/index.mjs";function F(u){const i=[];if(u.link)return[];if(u.icons&&u.icons.length>0)for(const e of u.icons){const t={rel:e.rel,href:e.href};e.sizes&&(t.sizes=e.sizes),e.type&&(t.type=e.type),i.push({tag:"link",attrs:t,injectTo:"head"})}else if(u.url)i.push({tag:"link",attrs:{rel:"icon",href:u.url},injectTo:"head"});else{const e=u.base||"/",t=e.endsWith("/")?`${e}favicon.ico`:`${e}/favicon.ico`;i.push({tag:"link",attrs:{rel:"icon",href:t},injectTo:"head"})}return i}class h extends a{getDefaultOptions(){return{base:"/"}}validateOptions(){this.validator.field("base").string().field("url").string().field("link").string().field("icons").array(),this.options?.copyOptions&&(this.validator.field("copyOptions").object(),new g(this.options.copyOptions).field("sourceDir").required().string().field("targetDir").required().string().field("overwrite").boolean().field("recursive").boolean().validate()),this.validator.validate()}getPluginName(){return"favicon-manager"}getIconTagDescriptors(){if(!this.options.enabled)return this.logger.info("\u63D2\u4EF6\u5DF2\u7981\u7528\uFF0C\u8DF3\u8FC7\u56FE\u6807\u6CE8\u5165"),[];const i=F(this.options);return i.length>0&&this.logger.success(`\u6210\u529F\u6CE8\u5165 ${i.length} \u4E2A\u56FE\u6807\u6807\u7B7E\u5230 HTML \u6587\u4EF6`),i}injectCustomLinkTag(i){if(!this.options.enabled||!this.options.link)return i;const e=this.options.link,t=p(i,"</head>",e);return t.injected?(this.logger.success("\u6210\u529F\u6CE8\u5165\u81EA\u5B9A\u4E49\u56FE\u6807\u6807\u7B7E\u5230 HTML \u6587\u4EF6"),this.logger.info(` - ${e}`),t.html):(this.logger.warn("\u672A\u627E\u5230 </head> \u6807\u7B7E\uFF0C\u8DF3\u8FC7\u56FE\u6807\u6CE8\u5165"),i)}async copyFiles(){if(!this.options.enabled){this.logger.info("\u63D2\u4EF6\u5DF2\u7981\u7528\uFF0C\u8DF3\u8FC7\u6587\u4EF6\u590D\u5236");return}const{copyOptions:i}=this.options;if(!i)return;const{sourceDir:e,targetDir:t,overwrite:o=!0,recursive:s=!0}=i;await c(e);const r=await l(e,t,{recursive:s,overwrite:o,incremental:!0});this.logger.success(`\u56FE\u6807\u6587\u4EF6\u590D\u5236\u6210\u529F\uFF1A\u4ECE ${e} \u5230 ${t}`,`\u590D\u5236\u4E86 ${r.copiedFiles} \u4E2A\u6587\u4EF6\uFF0C\u8DF3\u8FC7\u4E86 ${r.skippedFiles} \u4E2A\u6587\u4EF6\uFF0C\u8017\u65F6 ${r.executionTime}ms`)}addPluginHooks(i){i.transformIndexHtml={order:"pre",handler:e=>{if(this.options.link)return this.injectCustomLinkTag(e);const t=this.getIconTagDescriptors();return t.length>0?{html:e,tags:t}:e}},i.writeBundle=async()=>{await this.safeExecute(()=>this.copyFiles(),"\u56FE\u6807\u6587\u4EF6\u590D\u5236")}}}const f=n(h,u=>typeof u=="string"?{base:u}:u||{});export{f as faviconManager};
@@ -5,37 +5,47 @@ import '../../shared/vite-plugin.DRRlWY8P.cjs';
5
5
 
6
6
  /**
7
7
  * 路由元信息
8
+ *
9
+ * @interface RouteMeta
10
+ * @description 路由附加的元数据,用于页面导航守卫、标题设置等场景。
11
+ * 支持通过索引签名扩展自定义字段。
8
12
  */
9
13
  interface RouteMeta {
10
- /** 页面标题 */
14
+ /** 页面标题,对应 pages.json 中的 navigationBarTitleText */
11
15
  title?: string;
12
- /** 是否为TabBar页面 */
16
+ /** 是否为 TabBar 页面,由插件自动从 tabBar 配置推断 */
13
17
  isTab?: boolean;
14
- /** 是否需要登录 */
18
+ /** 是否需要登录才能访问 */
15
19
  requireAuth?: boolean;
16
20
  /** 自定义扩展字段 */
17
21
  [key: string]: unknown;
18
22
  }
19
23
  /**
20
24
  * 路由配置项
25
+ *
26
+ * @interface RouteConfig
27
+ * @description 单条路由的完整配置,包含路径、名称和元信息。
21
28
  */
22
29
  interface RouteConfig {
23
- /** 路由路径 */
30
+ /** 路由路径,以 `/` 开头 */
24
31
  path: string;
25
- /** 路由名称(用于命名路由导航) */
32
+ /** 路由名称(用于命名路由导航),根据 nameStrategy 自动生成 */
26
33
  name?: string;
27
34
  /** 路由元信息 */
28
35
  meta?: RouteMeta;
29
36
  }
30
37
  /**
31
38
  * uni-app pages.json 中的页面配置项
39
+ *
40
+ * @interface UniAppPageConfig
41
+ * @description 对应 pages.json 中 `pages` 数组里的单个页面对象。
32
42
  */
33
43
  interface UniAppPageConfig {
34
- /** 页面路径 */
44
+ /** 页面路径,相对于 pages.json 所在目录 */
35
45
  path: string;
36
- /** 页面样式 */
46
+ /** 页面样式配置 */
37
47
  style?: {
38
- /** 导航栏标题 */
48
+ /** 导航栏标题文本 */
39
49
  navigationBarTitleText?: string;
40
50
  /** 是否需要登录 */
41
51
  requireAuth?: boolean;
@@ -47,15 +57,18 @@ interface UniAppPageConfig {
47
57
  }
48
58
  /**
49
59
  * uni-app pages.json 中的 tabBar 配置
60
+ *
61
+ * @interface UniAppTabBarConfig
62
+ * @description 对应 pages.json 中的 `tabBar` 字段,定义底部标签栏的页面列表和图标。
50
63
  */
51
64
  interface UniAppTabBarConfig {
52
- /** tabBar 列表 */
65
+ /** tabBar 页面列表 */
53
66
  list?: Array<{
54
67
  /** 页面路径 */
55
68
  pagePath: string;
56
- /** 文字 */
69
+ /** 标签文字 */
57
70
  text?: string;
58
- /** 图标路径 */
71
+ /** 未选中图标路径 */
59
72
  iconPath?: string;
60
73
  /** 选中图标路径 */
61
74
  selectedIconPath?: string;
@@ -65,32 +78,66 @@ interface UniAppTabBarConfig {
65
78
  }
66
79
  /**
67
80
  * uni-app pages.json 结构
81
+ *
82
+ * @interface UniAppPagesJson
83
+ * @description 完整的 pages.json 文件结构,包含主包页面、子包、tabBar 和全局样式。
68
84
  */
69
85
  interface UniAppPagesJson {
70
- /** 页面列表 */
86
+ /** 主包页面列表 */
71
87
  pages: UniAppPageConfig[];
72
- /** 子包 */
88
+ /** 子包(分包)配置列表 */
73
89
  subPackages?: Array<{
90
+ /** 子包根路径 */
74
91
  root: string;
92
+ /** 子包页面列表 */
75
93
  pages: UniAppPageConfig[];
76
94
  }>;
77
95
  /** tabBar 配置 */
78
96
  tabBar?: UniAppTabBarConfig;
79
- /** 全局样式 */
97
+ /** 全局样式配置 */
80
98
  globalStyle?: Record<string, unknown>;
81
99
  /** 其他属性 */
82
100
  [key: string]: unknown;
83
101
  }
84
102
  /**
85
103
  * 输出文件格式类型
104
+ *
105
+ * @description 支持的输出文件格式:
106
+ * - `ts`: TypeScript 文件
107
+ * - `js`: JavaScript 文件
86
108
  */
87
109
  type OutputFormat = 'ts' | 'js';
88
110
  /**
89
111
  * 路由名称生成策略
112
+ *
113
+ * @description 定义路由名称的生成方式:
114
+ * - `path`: 使用原始路径(斜杠替换为下划线)
115
+ * - `camelCase`: 驼峰命名(默认)
116
+ * - `pascalCase`: 帕斯卡命名
117
+ * - `custom`: 自定义生成函数
90
118
  */
91
119
  type NameStrategy = 'path' | 'camelCase' | 'pascalCase' | 'custom';
92
120
  /**
93
121
  * 生成路由配置插件选项
122
+ *
123
+ * @interface GenerateRouterOptions
124
+ * @extends {BasePluginOptions}
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * generateRouter({
129
+ * pagesJsonPath: 'src/pages.json',
130
+ * outputPath: 'src/router.config.ts',
131
+ * outputFormat: 'ts',
132
+ * nameStrategy: 'camelCase',
133
+ * includeSubPackages: true,
134
+ * watch: true,
135
+ * metaMapping: {
136
+ * navigationBarTitleText: 'title',
137
+ * requireAuth: 'requireAuth'
138
+ * }
139
+ * })
140
+ * ```
94
141
  */
95
142
  interface GenerateRouterOptions extends BasePluginOptions {
96
143
  /**
@@ -5,37 +5,47 @@ import '../../shared/vite-plugin.DRRlWY8P.mjs';
5
5
 
6
6
  /**
7
7
  * 路由元信息
8
+ *
9
+ * @interface RouteMeta
10
+ * @description 路由附加的元数据,用于页面导航守卫、标题设置等场景。
11
+ * 支持通过索引签名扩展自定义字段。
8
12
  */
9
13
  interface RouteMeta {
10
- /** 页面标题 */
14
+ /** 页面标题,对应 pages.json 中的 navigationBarTitleText */
11
15
  title?: string;
12
- /** 是否为TabBar页面 */
16
+ /** 是否为 TabBar 页面,由插件自动从 tabBar 配置推断 */
13
17
  isTab?: boolean;
14
- /** 是否需要登录 */
18
+ /** 是否需要登录才能访问 */
15
19
  requireAuth?: boolean;
16
20
  /** 自定义扩展字段 */
17
21
  [key: string]: unknown;
18
22
  }
19
23
  /**
20
24
  * 路由配置项
25
+ *
26
+ * @interface RouteConfig
27
+ * @description 单条路由的完整配置,包含路径、名称和元信息。
21
28
  */
22
29
  interface RouteConfig {
23
- /** 路由路径 */
30
+ /** 路由路径,以 `/` 开头 */
24
31
  path: string;
25
- /** 路由名称(用于命名路由导航) */
32
+ /** 路由名称(用于命名路由导航),根据 nameStrategy 自动生成 */
26
33
  name?: string;
27
34
  /** 路由元信息 */
28
35
  meta?: RouteMeta;
29
36
  }
30
37
  /**
31
38
  * uni-app pages.json 中的页面配置项
39
+ *
40
+ * @interface UniAppPageConfig
41
+ * @description 对应 pages.json 中 `pages` 数组里的单个页面对象。
32
42
  */
33
43
  interface UniAppPageConfig {
34
- /** 页面路径 */
44
+ /** 页面路径,相对于 pages.json 所在目录 */
35
45
  path: string;
36
- /** 页面样式 */
46
+ /** 页面样式配置 */
37
47
  style?: {
38
- /** 导航栏标题 */
48
+ /** 导航栏标题文本 */
39
49
  navigationBarTitleText?: string;
40
50
  /** 是否需要登录 */
41
51
  requireAuth?: boolean;
@@ -47,15 +57,18 @@ interface UniAppPageConfig {
47
57
  }
48
58
  /**
49
59
  * uni-app pages.json 中的 tabBar 配置
60
+ *
61
+ * @interface UniAppTabBarConfig
62
+ * @description 对应 pages.json 中的 `tabBar` 字段,定义底部标签栏的页面列表和图标。
50
63
  */
51
64
  interface UniAppTabBarConfig {
52
- /** tabBar 列表 */
65
+ /** tabBar 页面列表 */
53
66
  list?: Array<{
54
67
  /** 页面路径 */
55
68
  pagePath: string;
56
- /** 文字 */
69
+ /** 标签文字 */
57
70
  text?: string;
58
- /** 图标路径 */
71
+ /** 未选中图标路径 */
59
72
  iconPath?: string;
60
73
  /** 选中图标路径 */
61
74
  selectedIconPath?: string;
@@ -65,32 +78,66 @@ interface UniAppTabBarConfig {
65
78
  }
66
79
  /**
67
80
  * uni-app pages.json 结构
81
+ *
82
+ * @interface UniAppPagesJson
83
+ * @description 完整的 pages.json 文件结构,包含主包页面、子包、tabBar 和全局样式。
68
84
  */
69
85
  interface UniAppPagesJson {
70
- /** 页面列表 */
86
+ /** 主包页面列表 */
71
87
  pages: UniAppPageConfig[];
72
- /** 子包 */
88
+ /** 子包(分包)配置列表 */
73
89
  subPackages?: Array<{
90
+ /** 子包根路径 */
74
91
  root: string;
92
+ /** 子包页面列表 */
75
93
  pages: UniAppPageConfig[];
76
94
  }>;
77
95
  /** tabBar 配置 */
78
96
  tabBar?: UniAppTabBarConfig;
79
- /** 全局样式 */
97
+ /** 全局样式配置 */
80
98
  globalStyle?: Record<string, unknown>;
81
99
  /** 其他属性 */
82
100
  [key: string]: unknown;
83
101
  }
84
102
  /**
85
103
  * 输出文件格式类型
104
+ *
105
+ * @description 支持的输出文件格式:
106
+ * - `ts`: TypeScript 文件
107
+ * - `js`: JavaScript 文件
86
108
  */
87
109
  type OutputFormat = 'ts' | 'js';
88
110
  /**
89
111
  * 路由名称生成策略
112
+ *
113
+ * @description 定义路由名称的生成方式:
114
+ * - `path`: 使用原始路径(斜杠替换为下划线)
115
+ * - `camelCase`: 驼峰命名(默认)
116
+ * - `pascalCase`: 帕斯卡命名
117
+ * - `custom`: 自定义生成函数
90
118
  */
91
119
  type NameStrategy = 'path' | 'camelCase' | 'pascalCase' | 'custom';
92
120
  /**
93
121
  * 生成路由配置插件选项
122
+ *
123
+ * @interface GenerateRouterOptions
124
+ * @extends {BasePluginOptions}
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * generateRouter({
129
+ * pagesJsonPath: 'src/pages.json',
130
+ * outputPath: 'src/router.config.ts',
131
+ * outputFormat: 'ts',
132
+ * nameStrategy: 'camelCase',
133
+ * includeSubPackages: true,
134
+ * watch: true,
135
+ * metaMapping: {
136
+ * navigationBarTitleText: 'title',
137
+ * requireAuth: 'requireAuth'
138
+ * }
139
+ * })
140
+ * ```
94
141
  */
95
142
  interface GenerateRouterOptions extends BasePluginOptions {
96
143
  /**
@@ -5,37 +5,47 @@ import '../../shared/vite-plugin.DRRlWY8P.js';
5
5
 
6
6
  /**
7
7
  * 路由元信息
8
+ *
9
+ * @interface RouteMeta
10
+ * @description 路由附加的元数据,用于页面导航守卫、标题设置等场景。
11
+ * 支持通过索引签名扩展自定义字段。
8
12
  */
9
13
  interface RouteMeta {
10
- /** 页面标题 */
14
+ /** 页面标题,对应 pages.json 中的 navigationBarTitleText */
11
15
  title?: string;
12
- /** 是否为TabBar页面 */
16
+ /** 是否为 TabBar 页面,由插件自动从 tabBar 配置推断 */
13
17
  isTab?: boolean;
14
- /** 是否需要登录 */
18
+ /** 是否需要登录才能访问 */
15
19
  requireAuth?: boolean;
16
20
  /** 自定义扩展字段 */
17
21
  [key: string]: unknown;
18
22
  }
19
23
  /**
20
24
  * 路由配置项
25
+ *
26
+ * @interface RouteConfig
27
+ * @description 单条路由的完整配置,包含路径、名称和元信息。
21
28
  */
22
29
  interface RouteConfig {
23
- /** 路由路径 */
30
+ /** 路由路径,以 `/` 开头 */
24
31
  path: string;
25
- /** 路由名称(用于命名路由导航) */
32
+ /** 路由名称(用于命名路由导航),根据 nameStrategy 自动生成 */
26
33
  name?: string;
27
34
  /** 路由元信息 */
28
35
  meta?: RouteMeta;
29
36
  }
30
37
  /**
31
38
  * uni-app pages.json 中的页面配置项
39
+ *
40
+ * @interface UniAppPageConfig
41
+ * @description 对应 pages.json 中 `pages` 数组里的单个页面对象。
32
42
  */
33
43
  interface UniAppPageConfig {
34
- /** 页面路径 */
44
+ /** 页面路径,相对于 pages.json 所在目录 */
35
45
  path: string;
36
- /** 页面样式 */
46
+ /** 页面样式配置 */
37
47
  style?: {
38
- /** 导航栏标题 */
48
+ /** 导航栏标题文本 */
39
49
  navigationBarTitleText?: string;
40
50
  /** 是否需要登录 */
41
51
  requireAuth?: boolean;
@@ -47,15 +57,18 @@ interface UniAppPageConfig {
47
57
  }
48
58
  /**
49
59
  * uni-app pages.json 中的 tabBar 配置
60
+ *
61
+ * @interface UniAppTabBarConfig
62
+ * @description 对应 pages.json 中的 `tabBar` 字段,定义底部标签栏的页面列表和图标。
50
63
  */
51
64
  interface UniAppTabBarConfig {
52
- /** tabBar 列表 */
65
+ /** tabBar 页面列表 */
53
66
  list?: Array<{
54
67
  /** 页面路径 */
55
68
  pagePath: string;
56
- /** 文字 */
69
+ /** 标签文字 */
57
70
  text?: string;
58
- /** 图标路径 */
71
+ /** 未选中图标路径 */
59
72
  iconPath?: string;
60
73
  /** 选中图标路径 */
61
74
  selectedIconPath?: string;
@@ -65,32 +78,66 @@ interface UniAppTabBarConfig {
65
78
  }
66
79
  /**
67
80
  * uni-app pages.json 结构
81
+ *
82
+ * @interface UniAppPagesJson
83
+ * @description 完整的 pages.json 文件结构,包含主包页面、子包、tabBar 和全局样式。
68
84
  */
69
85
  interface UniAppPagesJson {
70
- /** 页面列表 */
86
+ /** 主包页面列表 */
71
87
  pages: UniAppPageConfig[];
72
- /** 子包 */
88
+ /** 子包(分包)配置列表 */
73
89
  subPackages?: Array<{
90
+ /** 子包根路径 */
74
91
  root: string;
92
+ /** 子包页面列表 */
75
93
  pages: UniAppPageConfig[];
76
94
  }>;
77
95
  /** tabBar 配置 */
78
96
  tabBar?: UniAppTabBarConfig;
79
- /** 全局样式 */
97
+ /** 全局样式配置 */
80
98
  globalStyle?: Record<string, unknown>;
81
99
  /** 其他属性 */
82
100
  [key: string]: unknown;
83
101
  }
84
102
  /**
85
103
  * 输出文件格式类型
104
+ *
105
+ * @description 支持的输出文件格式:
106
+ * - `ts`: TypeScript 文件
107
+ * - `js`: JavaScript 文件
86
108
  */
87
109
  type OutputFormat = 'ts' | 'js';
88
110
  /**
89
111
  * 路由名称生成策略
112
+ *
113
+ * @description 定义路由名称的生成方式:
114
+ * - `path`: 使用原始路径(斜杠替换为下划线)
115
+ * - `camelCase`: 驼峰命名(默认)
116
+ * - `pascalCase`: 帕斯卡命名
117
+ * - `custom`: 自定义生成函数
90
118
  */
91
119
  type NameStrategy = 'path' | 'camelCase' | 'pascalCase' | 'custom';
92
120
  /**
93
121
  * 生成路由配置插件选项
122
+ *
123
+ * @interface GenerateRouterOptions
124
+ * @extends {BasePluginOptions}
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * generateRouter({
129
+ * pagesJsonPath: 'src/pages.json',
130
+ * outputPath: 'src/router.config.ts',
131
+ * outputFormat: 'ts',
132
+ * nameStrategy: 'camelCase',
133
+ * includeSubPackages: true,
134
+ * watch: true,
135
+ * metaMapping: {
136
+ * navigationBarTitleText: 'title',
137
+ * requireAuth: 'requireAuth'
138
+ * }
139
+ * })
140
+ * ```
94
141
  */
95
142
  interface GenerateRouterOptions extends BasePluginOptions {
96
143
  /**
@@ -46,6 +46,18 @@ interface VersionInfo {
46
46
  * 自动生成版本号插件的配置选项接口
47
47
  *
48
48
  * @interface GenerateVersionOptions
49
+ * @extends {BasePluginOptions}
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * generateVersion({
54
+ * format: 'semver',
55
+ * semverBase: '2.0.0',
56
+ * outputType: 'both',
57
+ * prefix: 'v',
58
+ * extra: { environment: 'production' }
59
+ * })
60
+ * ```
49
61
  */
50
62
  interface GenerateVersionOptions extends BasePluginOptions {
51
63
  /**
@@ -46,6 +46,18 @@ interface VersionInfo {
46
46
  * 自动生成版本号插件的配置选项接口
47
47
  *
48
48
  * @interface GenerateVersionOptions
49
+ * @extends {BasePluginOptions}
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * generateVersion({
54
+ * format: 'semver',
55
+ * semverBase: '2.0.0',
56
+ * outputType: 'both',
57
+ * prefix: 'v',
58
+ * extra: { environment: 'production' }
59
+ * })
60
+ * ```
49
61
  */
50
62
  interface GenerateVersionOptions extends BasePluginOptions {
51
63
  /**