hrp-ui-base 1.4.4 → 1.4.5

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/README.md CHANGED
@@ -1,163 +1,51 @@
1
1
  # hrp-ui-base
2
2
 
3
- `hrp-ui-base` 是从 `ui-hrp-main` monorepo 中拆出的前端公共基础包,包含公共 Vue 组件、通用工具方法和基础样式。
4
-
5
- ## 安装
6
-
7
- ```bash
8
- npm i hrp-ui-base
9
- ```
10
-
11
- 如果业务项目尚未安装以下 peer 依赖,需要一并安装:
12
-
13
- ```bash
14
- npm i vue element-plus vant
15
- ```
16
-
17
- ## 全局注册组件
18
-
19
- ```ts
20
- import { createApp } from "vue";
21
- import ElementPlus from "element-plus";
22
- import HrpUiBase from "hrp-ui-base";
23
- import "element-plus/dist/index.css";
24
- import "hrp-ui-base/styles/main.css";
25
- import App from "./App.vue";
26
-
27
- const app = createApp(App);
28
-
29
- app.use(ElementPlus);
30
- app.use(HrpUiBase);
31
- app.mount("#app");
32
- ```
33
-
34
- 注册后可直接使用:
35
-
36
- ```vue
37
- <template>
38
- <AnnexUpload page-id="demo-page" />
39
- <ListSearchContent />
40
- </template>
41
- ```
42
-
43
- ## 按需引用组件
44
-
45
- ```vue
46
- <script setup lang="ts">
47
- import { AnnexUpload, AnnexImgUpload, ListSearchContent } from "hrp-ui-base";
48
- import "hrp-ui-base/styles/main.css";
49
- </script>
50
- ```
51
-
52
- 也可以从组件入口引用:
53
-
54
- ```ts
55
- import { AnnexUpload } from "hrp-ui-base/components";
56
- ```
57
-
58
- ## 引用工具方法
59
-
60
- ```ts
61
- import { HttpUtil, Throttle, getFileType, ddWindowOpen } from "hrp-ui-base";
62
- ```
63
-
64
- 也可以引用独立工具文件:
65
-
66
- ```ts
67
- import HttpUtil from "hrp-ui-base/utils/HttpUtil";
68
- import { IsPc, IsPhone } from "hrp-ui-base/utils/get-env";
69
- ```
70
-
71
- ## 业务 API 引用规则
72
-
73
- 业务 API 不从 `hrp-ui-base` 引用。各业务项目需要在自身 `src/api` 下维护 Controller、VO/BO 类型,并通过 `@/api/...` 引用:
74
-
75
- ```ts
76
- import HomeController from "@/api/bms/home/HomeController";
77
- import type HomeMenu from "@/api/bms/home/bo/HomeMenu";
78
- ```
79
-
80
- `ui-base/src/api` 仅保留公共组件自身运行需要的少量内部 API,例如附件上传、列表配置、权限和字典配置,不作为业务项目的 API 入口。
81
-
82
- ## 路由相关工具注入
83
-
84
- `exitLogin` 和 `router-utils` 已从业务项目的 `@/router`、store 中解耦。业务项目需要使用这些能力时,在入口处注入运行时上下文:
85
-
86
- ```ts
87
- import router from "@/router";
88
- import store from "@/stores/routeStore";
89
- import { funcRoleStore } from "@/stores/funcRole";
90
- import { setExitLoginRouter, setRouterUtilsContext } from "hrp-ui-base";
91
-
92
- setExitLoginRouter(router);
93
- setRouterUtilsContext({
94
- router,
95
- routeStoreList: funcRoleStore(store),
96
- });
97
- ```
98
-
99
- ## 从旧 workspace 包迁移
100
-
101
- 旧写法:
102
-
103
- ```ts
104
- import { ListSearchContent } from "custom-components";
105
- import { HttpUtil } from "custom-utils";
106
- ```
107
-
108
- 新写法:
109
-
110
- ```ts
111
- import { ListSearchContent, HttpUtil } from "hrp-ui-base";
112
- import HomeController from "@/api/bms/home/HomeController";
113
- ```
114
-
115
- 如果业务项目暂时不能一次性替换所有旧导入,可以先在 Vite 和 TypeScript 中做兼容别名:
116
-
117
- ```ts
118
- // vite.config.ts
119
- resolve: {
120
- alias: {
121
- "custom-components": "hrp-ui-base",
122
- "custom-utils": "hrp-ui-base",
123
- },
124
- }
125
- ```
126
-
127
- ```json
128
- // tsconfig.json
129
- {
130
- "compilerOptions": {
131
- "paths": {
132
- "custom-components": ["node_modules/hrp-ui-base/src/index.ts"],
133
- "custom-utils": ["node_modules/hrp-ui-base/src/index.ts"],
134
- "custom-utils/*": ["node_modules/hrp-ui-base/src/*"]
135
- }
136
- }
137
- }
138
- ```
139
-
140
- ## 本地开发与发布
141
-
142
- ```bash
143
- cd ui-base
144
- npm install
145
- npm run build
146
- npm publish
147
- ```
148
-
149
- 发布后业务项目即可通过 `npm i hrp-ui-base` 安装。
150
-
151
- ## 目录说明
152
-
153
- ```text
154
- ui-base/
155
- ├── src/components # 公共 Vue 组件
156
- ├── src/styles # 公共样式
157
- ├── src/utils # 通用工具方法
158
- ├── src/api # 公共组件内部使用的少量 API
159
- ├── src/assets # 公共静态资源
160
- ├── src/index.ts # 统一入口
161
- ├── src/components.ts
162
- └── src/utils.ts
163
- ```
3
+ ## 项目定位
4
+ `hrp-ui-base` 是各拆分业务系统共同依赖的前端公共能力包,用来承接主仓原 `custom-components`、`custom-utils` 中可复用的组件、布局、请求、权限、样式和工具能力。该包本身不是业务应用,不直接对应某一个后端服务。
5
+
6
+ ## 对接后端服务
7
+ - 无独立业务后端。
8
+ - 包内保留少量公共接口封装和类型,供业务系统复用:`bms`、`hrms`、`notice`、`work-order-pc`、`common`。
9
+ - 请求能力由 `HttpUtil`、业务系统运行时 token、代理和后端网关共同决定。
10
+
11
+ ## 提供的公共组件
12
+ - `CustomButton`:统一按钮封装。
13
+ - `CustonSwitch`:统一开关封装。
14
+ - `AnnexUpload`:通用附件上传。
15
+ - `AnnexImgUpload`:图片附件上传。
16
+ - `AnnexUploadWeijian`:卫健场景附件上传。
17
+ - `ListSearchContent`:列表页筛选/查询区域容器。
18
+ - `BaseLayout`:基础页面布局。
19
+ - `LayoutContainer`:业务系统主布局,整合菜单、页签、头部、消息、审批、导出中心、主题和字号配置。
20
+ - `SysHeader`、`SysHeaderLeft`、`SysHeaderRight`、`SysHeaderTabs`:系统头部与页签组件。
21
+ - `SideMenu`、`SideMenuSonList`:侧边菜单与子菜单列表。
22
+ - `MessageNotificationDrawer`:消息通知抽屉。
23
+ - `ApprovalCenterDrawer`:审批中心抽屉。
24
+ - `ExportCenterDrawer`:导出中心抽屉。
25
+ - `PersonalizationGuideDialog`:个性化引导弹窗。
26
+ - 布局子组件:暗黑模式、字号、菜单位置、下载、待办、消息、头像等 Header 功能块。
27
+
28
+ ## 提供的公共工具能力
29
+ - 请求与登录:`HttpUtil`、`exitLogin`、`setExitLoginRouter`。
30
+ - 权限与路由:`isHavePermit`、`getPagePermit`、`toNoPermitPage`、路由/路径工具。
31
+ - 表格与主题:`tableHeaderCellStyle`、`tableFontCellStyle`、日夜模式样式配置。
32
+ - 文件与下载:`download`、文件类型判断、钉钉打开/下载相关工具。
33
+ - 交互工具:`Throttle`、`Debounce`、`debounceleading`、WebSocket 封装。
34
+ - 数据工具:字典、字符串、校验、格式化、过滤、树/列表转换等。
35
+ - 公共类型:`ResponseBean`、`ResponseBeanList`、`ResponseBeanTablePage`、`TableQueryCriteriaVO`、`FileBaseInfo`。
36
+
37
+ ## 使用方式
38
+ - 全局安装:`app.use(HrpUiBase)`。
39
+ - 按需引用:`import { LayoutContainer, ListSearchContent, HttpUtil } from "hrp-ui-base"`。
40
+ - 包入口:`src/index.ts` 同时导出组件、API 类型/控制器和工具函数。
41
+
42
+ ## 技术说明
43
+ - 包名:`hrp-ui-base`,当前版本:`1.4.4`。
44
+ - 技术栈:Vue 3、TypeScript、Vite library mode。
45
+ - 构建:`pnpm build`;类型检查:`pnpm typecheck`。
46
+ - 组件样式入口在 `src/styles/main.css`,业务系统更新版本后需要重新安装依赖并构建验证。
47
+
48
+ ## 维护注意
49
+ - 新增公共组件时,需要在 `src/components.ts` 中注册、导出并补充 Vue 全局组件声明。
50
+ - 新增工具时,需要在 `src/utils.ts` 统一导出。
51
+ - 影响登录、401、消息通知、审批中心、菜单跳转等能力时,需要在 entry 和主要拆分系统中回归验证。