rhjy-ui 0.2.4 → 0.2.6

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,92 +1,121 @@
1
- # rhjy-ui
2
-
3
- `rhjy-ui` is a Vue 3 and Element Plus business UI component library. The first release contains a configurable data-center suite for displaying asynchronous import, export, generation and other background tasks.
4
-
5
- ## Install
6
-
7
- ```bash
8
- pnpm add rhjy-ui vue element-plus @element-plus/icons-vue
9
- ```
10
-
11
- Import the package stylesheet once in the application entrypoint:
12
-
13
- ```ts
14
- import 'rhjy-ui/style.css'
15
- ```
16
-
17
- ## Responsive Info Grid
18
-
19
- Responsive Info Grid arranges title-content pairs in a configurable grid and switches column counts at the 1200px and 768px breakpoints.
20
-
21
- ```vue
22
- <script setup lang="ts">
23
- import {
24
- RhResponsiveInfoGrid,
25
- RhResponsiveInfoGridItem,
26
- } from 'rhjy-ui'
27
- </script>
28
-
29
- <template>
30
- <RhResponsiveInfoGrid>
31
- <RhResponsiveInfoGridItem title="Project: " content="Smart Campus" />
32
- <RhResponsiveInfoGridItem title="Owner: " content="Operations Team" />
33
- <RhResponsiveInfoGridItem title="Devices: " :content="128" />
34
- <RhResponsiveInfoGridItem title="Summary: " content="All systems operational" :span="2" />
35
- </RhResponsiveInfoGrid>
36
- </template>
37
- ```
38
-
1
+ # rhjy-ui
2
+
3
+ `rhjy-ui` is a Vue 3 and Element Plus business UI component library. The first release contains a configurable data-center suite for displaying asynchronous import, export, generation and other background tasks.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add rhjy-ui vue element-plus @element-plus/icons-vue
9
+ ```
10
+
11
+ Import the package stylesheet once in the application entrypoint:
12
+
13
+ ```ts
14
+ import 'rhjy-ui/style.css'
15
+ ```
16
+
17
+ ## Responsive Info Grid
18
+
19
+ Responsive Info Grid arranges title-content pairs in a configurable grid and switches column counts at the 1200px and 768px breakpoints.
20
+
21
+ ```vue
22
+ <script setup lang="ts">
23
+ import {
24
+ RhResponsiveInfoGrid,
25
+ RhResponsiveInfoGridItem,
26
+ } from 'rhjy-ui'
27
+ </script>
28
+
29
+ <template>
30
+ <RhResponsiveInfoGrid>
31
+ <RhResponsiveInfoGridItem title="Project: " content="Smart Campus" />
32
+ <RhResponsiveInfoGridItem title="Owner: " content="Operations Team" />
33
+ <RhResponsiveInfoGridItem title="Devices: " :content="128" />
34
+ <RhResponsiveInfoGridItem title="Summary: " content="All systems operational" :span="2" />
35
+ </RhResponsiveInfoGrid>
36
+ </template>
37
+ ```
38
+
39
39
  See the [Responsive Info Grid component README](https://unpkg.com/rhjy-ui@0.2.2/src/responsive-info-grid/README.md) for subpath imports, the complete props and slots reference, responsive behavior, and more examples.
40
-
41
- ## Data center panel
42
-
43
- `rhjy-ui` never receives an API URL. Each application supplies a `loadTasks` function and converts its own response into the standard task model.
44
-
45
- ```vue
46
- <script setup lang="ts">
47
- import { RhDataCenter } from 'rhjy-ui'
48
- import type {
49
- RhDataCenterCategory,
50
- RhDataCenterLoadTasks,
51
- } from 'rhjy-ui/data-center'
52
-
53
- const categories: RhDataCenterCategory[] = [
54
- { key: 'all', label: '全部任务' },
55
- { key: 'generate', label: '数据生成' },
56
- { key: 'import', label: '数据导入' },
57
- { key: 'export', label: '数据导出' },
58
- ]
59
-
60
- const loadTasks: RhDataCenterLoadTasks = async ({ category }) => {
61
- const response = await requestTaskList({
62
- taskType: category.key === 'all' ? undefined : category.key,
63
- })
64
-
65
- return {
66
- items: response.list,
67
- total: response.total,
68
- }
69
- }
70
-
71
- const handleTaskAction = ({ action, task }) => {
72
- if (action === 'download') {
73
- window.open(task.raw.fileUrl)
74
- }
75
- }
76
- </script>
77
-
78
- <template>
40
+
41
+ ## Data center panel
42
+
43
+ `rhjy-ui` never receives an API URL. Each application supplies a `loadTasks` function and converts its own response into the standard task model.
44
+
45
+ ```vue
46
+ <script setup lang="ts">
47
+ import { RhDataCenter } from 'rhjy-ui'
48
+ import type {
49
+ RhDataCenterCategory,
50
+ RhDataCenterLoadTasks,
51
+ } from 'rhjy-ui/data-center'
52
+
53
+ const categories: RhDataCenterCategory[] = [
54
+ { key: 'all', label: '全部任务' },
55
+ { key: 'generate', label: '数据生成' },
56
+ { key: 'import', label: '数据导入' },
57
+ { key: 'export', label: '数据导出' },
58
+ ]
59
+
60
+ const loadTasks: RhDataCenterLoadTasks = async ({ category }) => {
61
+ const response = await requestTaskList({
62
+ taskType: category.key === 'all' ? undefined : category.key,
63
+ })
64
+
65
+ return {
66
+ items: response.list,
67
+ total: response.total,
68
+ }
69
+ }
70
+
71
+ const handleTaskAction = ({ action, task }) => {
72
+ if (action === 'download') {
73
+ window.open(task.raw.fileUrl)
74
+ }
75
+ }
76
+ </script>
77
+
78
+ <template>
79
79
  <RhDataCenter
80
80
  :categories="categories"
81
81
  :load-tasks="loadTasks"
82
82
  sidebar-width="160px"
83
83
  @task-action="handleTaskAction"
84
84
  />
85
- </template>
86
- ```
87
-
85
+ </template>
86
+ ```
87
+
88
88
  The “全部任务” rule is application-owned. It may omit `taskType`, pass a fixed value, or combine multiple requests without changing the component.
89
89
 
90
+ ### Reuse the business adapter
91
+
92
+ When multiple applications use the same data-center protocol, use `createRhDataCenterAdapter` to share response conversion, status messages, sorting, counts, and default download actions. The application still injects its own API functions; the package never receives an API URL.
93
+
94
+ ```ts
95
+ import {
96
+ createRhDataCenterAdapter,
97
+ type RhDataCenterCategory,
98
+ } from 'rhjy-ui/data-center'
99
+ import { clickDownloadBtByTaskId, getMyTaskList } from '@/services/dataCenter'
100
+
101
+ const categories: RhDataCenterCategory[] = [
102
+ { key: 'all', label: '全部任务', query: { taskType: 0 } },
103
+ { key: 2, label: '数据导入', query: { taskType: 2 } },
104
+ { key: 3, label: '数据导出', query: { taskType: 3 } },
105
+ ]
106
+
107
+ const { loadTasks, handleTaskAction } = createRhDataCenterAdapter({
108
+ api: {
109
+ getTaskList: getMyTaskList,
110
+ downloadTask: ({ taskId }) => clickDownloadBtByTaskId({ taskId }),
111
+ },
112
+ categories,
113
+ taskKind: { import: [2], export: [3] },
114
+ })
115
+ ```
116
+
117
+ Use `parseResponse` when the application response wrapper or success rule differs. Use `mapTask` or `resolveActions` for an application-specific field or operation without changing the shared adapter. `RhDataCenter` remains responsible for polling; the adapter handles one query and one task action at a time.
118
+
90
119
  Use `sidebar-width` with a number or CSS size string to adjust the data type panel width. Its default value is `124px`.
91
120
 
92
121
  Category counts are optional and application-owned. Set `show-category-count` to `false` to hide every category count, or pass `category-counts` to display values before individual categories are loaded:
@@ -101,49 +130,132 @@ Category counts are optional and application-owned. Set `show-category-count` to
101
130
  ```
102
131
 
103
132
  When counts are enabled, the component uses `categoryCounts`, then a loaded result's `counts`, and finally the category result's `total`.
104
-
105
- ## Task tip flow
106
-
107
- Use `useRhDataCenter` after a page successfully creates a background task:
108
-
109
- ```vue
110
- <script setup lang="ts">
111
- import { RhDataCenterTip, useRhDataCenter } from 'rhjy-ui'
112
-
113
- const { tipVisible, tipConfig, showTip } = useRhDataCenter()
114
-
115
- const startExport = async () => {
116
- const result = await createExportTask()
117
- showTip({
118
- type: 'export',
119
- minutes: Number(result.minutes),
120
- title: '导出文件生成中,大概需要',
121
- content: '现在你可关闭弹框,去做其他事情了。',
122
- })
123
- }
124
- </script>
125
-
126
- <template>
127
- <RhDataCenterTip v-model="tipVisible" v-bind="tipConfig" />
128
- </template>
129
- ```
130
-
131
- ## Standard task model
132
-
133
- The adapter returns `id`, `categoryKey`, `title`, `createdAt`, `progress`, and one of `waiting`, `processing`, `success`, or `failed`. Optional `tag`, `message`, `actions`, and `raw` provide display and application action context.
134
-
135
- ## Styling
136
-
137
- Override CSS variables at the application root when needed:
138
-
139
- ```css
140
- :root {
141
- --rh-ui-data-center-primary: #00828a;
142
- --rh-ui-data-center-panel-width: 606px;
143
- --rh-ui-data-center-panel-height: 500px;
144
- }
145
- ```
146
-
147
- ## Releases
148
-
133
+
134
+ When the backend provides a separate count endpoint, configure it on the shared adapter. The count request runs in parallel with each task-list refresh, so the sidebar stays synchronized with polling without moving API details into `RhDataCenter`:
135
+
136
+ ```ts
137
+ const { loadTasks, handleTaskAction } = createRhDataCenterAdapter<
138
+ RawTask,
139
+ TaskQuery,
140
+ TaskListResponse,
141
+ TaskCountResponse
142
+ >({
143
+ api: {
144
+ getTaskList: requestTaskList,
145
+ getTaskCounts: () => requestTaskCounts({ taskType: 0 }),
146
+ },
147
+ categories,
148
+ parseResponse: (response) => response.data.list,
149
+ parseCounts: (response) => ({
150
+ all: response.data.totalTaskCount,
151
+ import: response.data.taskCountList.find((item) => item.taskType === 2)?.taskCount ?? 0,
152
+ }),
153
+ })
154
+ ```
155
+
156
+ `parseCounts` converts the shared backend response into category keys. If the count request or parser fails, the adapter keeps the task list available and falls back to `resolveCounts` or the loaded result totals.
157
+
158
+ Task tags read `raw.taskTypeName` by default. When an API uses another field name, pass `task-tag-field` without changing the task adapter:
159
+
160
+ ```vue
161
+ <RhDataCenter
162
+ :categories="categories"
163
+ :load-tasks="loadTasks"
164
+ task-tag-field="taskTypeName"
165
+ />
166
+ ```
167
+
168
+ ## Task tip flow
169
+
170
+ Use `useRhDataCenter` after a page successfully creates a background task:
171
+
172
+ ```vue
173
+ <script setup lang="ts">
174
+ import { RhDataCenterTip, useRhDataCenter } from 'rhjy-ui'
175
+
176
+ const { tipVisible, tipConfig, showTip } = useRhDataCenter()
177
+
178
+ const startExport = async () => {
179
+ const result = await createExportTask()
180
+ showTip({
181
+ type: 'export',
182
+ minutes: Number(result.minutes),
183
+ title: '导出文件生成中,大概需要',
184
+ content: '现在你可关闭弹框,去做其他事情了。',
185
+ })
186
+ }
187
+ </script>
188
+
189
+ <template>
190
+ <RhDataCenterTip v-model="tipVisible" v-bind="tipConfig" />
191
+ </template>
192
+ ```
193
+
194
+ `RhDataCenterTip` 默认使用简化引导动画;需要使用带数据处理中心图片、手势和方向切换的引导时,可传入 `guideVariant="normal"` 或 `guideVariant="super"`。
195
+
196
+ ## Standard task model
197
+
198
+ The adapter returns `id`, `categoryKey`, `title`, `createdAt`, `progress`, and one of `waiting`, `processing`, `success`, or `failed`. Optional `tag`, `message`, `actions`, and `raw` provide display and application action context.
199
+
200
+ For completed tasks with rejected records, pass the normalized `failCount` field. The task item keeps the completed progress bar, shows `失败记录(xx条)` in red, and hides the normal completion message when the count is zero. The application still supplies the failure-record action and handles its download event.
201
+
202
+ For processing tasks, pass `taskSeconds` to show `总时长约X分XX秒` instead of the default processing message. If `taskSeconds` is omitted, the provided `message` is displayed.
203
+
204
+ ## Styling
205
+
206
+ Override CSS variables at the application root when needed:
207
+
208
+ ```css
209
+ :root {
210
+ --rh-ui-data-center-primary: #00828a;
211
+ --rh-ui-data-center-panel-width: 606px;
212
+ --rh-ui-data-center-panel-height: 500px;
213
+ }
214
+ ```
215
+
216
+ ## Build and publish
217
+
218
+ After changing the source code or component assets, run the package script in the `rh-ui` directory to regenerate `dist`:
219
+
220
+ ```bash
221
+ cd D:\workfile\sass-workspace\packages\rh-ui
222
+ npm run package
223
+ ```
224
+
225
+ The workspace equivalent is:
226
+
227
+ ```bash
228
+ pnpm --filter rhjy-ui package
229
+ ```
230
+
231
+ Before publishing, increment the package version without creating a Git tag:
232
+
233
+ ```bash
234
+ npm run version:patch
235
+ ```
236
+
237
+ Use `npm run version:minor` only for a backward-compatible feature release. You can inspect the files that will be published with:
238
+
239
+ ```bash
240
+ npm pack --dry-run
241
+ ```
242
+
243
+ After confirming the tarball contents, publish the public package:
244
+
245
+ ```bash
246
+ npm login --registry=https://registry.npmjs.org --auth-type=web
247
+ npm publish --access public --registry=https://registry.npmjs.org
248
+ ```
249
+
250
+ If the account uses two-factor authentication, npm opens the browser authentication flow. After publishing, synchronize the school admin project from this package directory:
251
+
252
+ ```bash
253
+ cd D:\workfile\sass-workspace\packages\rh-ui
254
+ npm run sync:wise-school-admin
255
+ ```
256
+
257
+ The script installs the latest public `rhjy-ui` release with an exact version and synchronizes `D:\workfile\wise-school-admin\package.json` and `package-lock.json`. It is intended for the fixed local workspace path; add another explicit `sync:<project>` script when a new application needs this workflow.
258
+
259
+ ## Releases
260
+
149
261
  The package is published with compiled `dist` output. Consumers should use an explicit version such as `rhjy-ui@0.2.2`; application-specific API adapters remain in the consuming project.
@@ -35,6 +35,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
35
35
  width?: string | number;
36
36
  panelHeight?: string | number;
37
37
  sidebarWidth?: string | number;
38
+ taskTagField?: string;
38
39
  panelRight?: string | number;
39
40
  pollInterval?: number;
40
41
  refreshOnOpen?: boolean;
@@ -49,6 +50,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
49
50
  width: number;
50
51
  panelHeight: number;
51
52
  sidebarWidth: number;
53
+ taskTagField: string;
52
54
  panelRight: number;
53
55
  pollInterval: number;
54
56
  refreshOnOpen: boolean;
@@ -71,6 +73,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
71
73
  width?: string | number;
72
74
  panelHeight?: string | number;
73
75
  sidebarWidth?: string | number;
76
+ taskTagField?: string;
74
77
  panelRight?: string | number;
75
78
  pollInterval?: number;
76
79
  refreshOnOpen?: boolean;
@@ -85,6 +88,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
85
88
  width: number;
86
89
  panelHeight: number;
87
90
  sidebarWidth: number;
91
+ taskTagField: string;
88
92
  panelRight: number;
89
93
  pollInterval: number;
90
94
  refreshOnOpen: boolean;
@@ -103,6 +107,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
103
107
  label: string;
104
108
  width: string | number;
105
109
  sidebarWidth: string | number;
110
+ taskTagField: string;
106
111
  showCategoryCount: boolean;
107
112
  modelValue: boolean;
108
113
  panelHeight: string | number;
@@ -26,6 +26,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
26
26
  loadTasks: RhDataCenterLoadTasks;
27
27
  activeCategoryKey?: string | number;
28
28
  sidebarWidth?: string | number;
29
+ taskTagField?: string;
29
30
  closeable?: boolean;
30
31
  showTotal?: boolean;
31
32
  showCategoryCount?: boolean;
@@ -34,6 +35,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
34
35
  }>, {
35
36
  activeCategoryKey: any;
36
37
  sidebarWidth: number;
38
+ taskTagField: string;
37
39
  closeable: boolean;
38
40
  showTotal: boolean;
39
41
  showCategoryCount: boolean;
@@ -50,6 +52,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
50
52
  loadTasks: RhDataCenterLoadTasks;
51
53
  activeCategoryKey?: string | number;
52
54
  sidebarWidth?: string | number;
55
+ taskTagField?: string;
53
56
  closeable?: boolean;
54
57
  showTotal?: boolean;
55
58
  showCategoryCount?: boolean;
@@ -58,6 +61,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
58
61
  }>, {
59
62
  activeCategoryKey: any;
60
63
  sidebarWidth: number;
64
+ taskTagField: string;
61
65
  closeable: boolean;
62
66
  showTotal: boolean;
63
67
  showCategoryCount: boolean;
@@ -70,6 +74,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
70
74
  }>, {
71
75
  activeCategoryKey: string | number;
72
76
  sidebarWidth: string | number;
77
+ taskTagField: string;
73
78
  closeable: boolean;
74
79
  showTotal: boolean;
75
80
  showCategoryCount: boolean;
@@ -1,3 +1,5 @@
1
+ import { RhDataCenterTipGuideVariant } from './types';
2
+
1
3
  declare function __VLS_template(): {
2
4
  extra?(_: {}): any;
3
5
  };
@@ -9,6 +11,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
9
11
  content?: string;
10
12
  width?: string | number;
11
13
  showGuideAnimation?: boolean;
14
+ guideVariant?: RhDataCenterTipGuideVariant;
12
15
  }>, {
13
16
  modelValue: boolean;
14
17
  minutes: any;
@@ -17,6 +20,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
17
20
  content: string;
18
21
  width: string;
19
22
  showGuideAnimation: boolean;
23
+ guideVariant: string;
20
24
  }>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
21
25
  "update:modelValue": (value: boolean) => void;
22
26
  close: () => void;
@@ -28,6 +32,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
28
32
  content?: string;
29
33
  width?: string | number;
30
34
  showGuideAnimation?: boolean;
35
+ guideVariant?: RhDataCenterTipGuideVariant;
31
36
  }>, {
32
37
  modelValue: boolean;
33
38
  minutes: any;
@@ -36,6 +41,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
36
41
  content: string;
37
42
  width: string;
38
43
  showGuideAnimation: boolean;
44
+ guideVariant: string;
39
45
  }>>> & Readonly<{
40
46
  onClose?: () => any;
41
47
  "onUpdate:modelValue"?: (value: boolean) => any;
@@ -47,6 +53,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
47
53
  modelValue: boolean;
48
54
  minutes: number;
49
55
  showGuideAnimation: boolean;
56
+ guideVariant: RhDataCenterTipGuideVariant;
50
57
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
51
58
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
52
59
  export default _default;
@@ -0,0 +1,3 @@
1
+ import { RhDataCenterAdapterOptions, RhDataCenterAdapterResult } from './types';
2
+
3
+ export declare const createRhDataCenterAdapter: <RawTask extends object, Query = Record<string, unknown>, Response = unknown, CountResponse = unknown>(options: RhDataCenterAdapterOptions<RawTask, Query, Response, CountResponse>) => RhDataCenterAdapterResult;
@@ -5,8 +5,19 @@ export declare const RH_DATA_CENTER_TASK_STATUS: {
5
5
  readonly Failed: "failed";
6
6
  };
7
7
  export declare const RH_DATA_CENTER_DEFAULT_LABEL = "\u6570\u636E\u5904\u7406\u4E2D\u5FC3";
8
- export declare const RH_DATA_CENTER_DEFAULT_WIDTH = 606;
8
+ export declare const RH_DATA_CENTER_DEFAULT_WIDTH = 715;
9
9
  export declare const RH_DATA_CENTER_DEFAULT_HEIGHT = 500;
10
- export declare const RH_DATA_CENTER_DEFAULT_SIDEBAR_WIDTH = 124;
10
+ export declare const RH_DATA_CENTER_DEFAULT_SIDEBAR_WIDTH = 160;
11
11
  export declare const RH_DATA_CENTER_DEFAULT_POLL_INTERVAL = 1000;
12
- export declare const RH_DATA_CENTER_RECENT_DAYS_TEXT = "-\u6B64\u5904\u4EC5\u5C55\u793A\u8FD115\u5929\u5185\u7684\u6570\u636E-";
12
+ export declare const RH_DATA_CENTER_RECENT_DAYS_TEXT = "\u4EC5\u5C55\u793A\u8FD115\u5929\u5185\u7684\u6570\u636E";
13
+ export declare const DOWNLOAD_ACTION = "download";
14
+ export declare const DOWNLOAD_FAILURE_ACTION = "downloadFailure";
15
+ export declare const RH_DATA_CENTER_ACTION: {
16
+ readonly Download: "download";
17
+ readonly DownloadFailure: "downloadFailure";
18
+ };
19
+ export declare const RH_DATA_CENTER_ACTION_LABEL: {
20
+ readonly Download: "下载文件";
21
+ readonly Redownload: "重新下载文件";
22
+ readonly DownloadFailure: "下载失败记录";
23
+ };