@robot-admin/naive-ui-components 0.14.3 → 0.16.0
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/CHANGELOG.md +35 -0
- package/README.md +130 -741
- package/README_EN.md +137 -678
- package/dist/C_ActionBar.css +57 -58
- package/dist/C_ActionBar2.cjs +1 -1
- package/dist/C_ActionBar2.js +1 -1
- package/dist/C_AntV.css +232 -238
- package/dist/C_AntV2.cjs +2 -2
- package/dist/C_AntV2.js +2 -2
- package/dist/C_AudioPlayer.css +9 -9
- package/dist/C_AvatarGroup.css +5 -6
- package/dist/C_Barcode.css +1 -1
- package/dist/C_Breadcrumb.css +15 -18
- package/dist/C_Breadcrumb2.cjs +1 -1
- package/dist/C_Breadcrumb2.js +1 -1
- package/dist/C_Captcha.css +46 -49
- package/dist/C_Captcha2.cjs +1 -1
- package/dist/C_Captcha2.js +1 -1
- package/dist/C_Cascade.css +5 -6
- package/dist/C_Chat.css +8 -8
- package/dist/C_City.css +2 -2
- package/dist/C_Code.css +9 -9
- package/dist/C_CollapsePanel.css +9 -9
- package/dist/C_ContextMenu.css +31 -31
- package/dist/C_Cron.css +271 -274
- package/dist/C_Date.css +1 -1
- package/dist/C_Draggable.css +10 -11
- package/dist/C_Editor.css +2 -2
- package/dist/C_FilePreview.css +423 -423
- package/dist/C_Form.base.css +608 -602
- package/dist/C_Form.cjs +1 -1
- package/dist/C_Form.css +610 -604
- package/dist/C_Form.d.cts +2 -2
- package/dist/C_Form.d.ts +2 -2
- package/dist/C_Form.js +1 -1
- package/dist/C_FormModal.cjs +1 -1
- package/dist/C_FormModal.css +12 -17
- package/dist/C_FormModal.js +1 -1
- package/dist/C_FormModal2.cjs +1 -1
- package/dist/C_FormModal2.js +1 -1
- package/dist/C_FormSearch.css +53 -55
- package/dist/C_FormSearch2.cjs +1 -1
- package/dist/C_FormSearch2.js +1 -1
- package/dist/C_FormulaEditor.css +204 -205
- package/dist/C_FullCalendar.css +13 -15
- package/dist/C_FullCalendar2.cjs +1 -1
- package/dist/C_FullCalendar2.js +1 -1
- package/dist/C_GlobalSearch.css +11 -12
- package/dist/C_Guide.css +10 -10
- package/dist/C_Icon.css +7 -8
- package/dist/C_ImageCropper.css +69 -69
- package/dist/C_Language.css +8 -8
- package/dist/C_Loading.css +22 -25
- package/dist/C_Loading2.cjs +1 -1
- package/dist/C_Loading2.js +1 -1
- package/dist/C_Login.css +130 -135
- package/dist/C_Login2.cjs +1 -1
- package/dist/C_Login2.js +1 -1
- package/dist/C_Map.css +22 -23
- package/dist/C_Markdown.css +6 -7
- package/dist/C_Menu.css +2 -5
- package/dist/C_Menu2.cjs +1 -1
- package/dist/C_Menu2.js +1 -1
- package/dist/C_NotificationCenter.css +316 -281
- package/dist/C_NotificationCenter.d.cts +2 -2
- package/dist/C_NotificationCenter.d.ts +2 -2
- package/dist/C_NotificationCenter2.cjs +1 -1
- package/dist/C_NotificationCenter2.js +1 -1
- package/dist/C_OrgChart.css +8 -8
- package/dist/C_PageLoading.css +34 -39
- package/dist/C_QRCode.css +5 -6
- package/dist/C_Signature.css +5 -6
- package/dist/C_Skeleton.css +2 -2
- package/dist/C_SplitPane.css +2 -2
- package/dist/C_Steps.css +5 -6
- package/dist/C_Table.base.css +1090 -879
- package/dist/C_Table.cjs +1 -1
- package/dist/C_Table.css +1096 -885
- package/dist/C_Table.d.cts +1 -1
- package/dist/C_Table.d.ts +1 -1
- package/dist/C_Table.js +1 -1
- package/dist/C_Tabs.css +5 -6
- package/dist/C_TagsView.css +60 -63
- package/dist/C_TagsView2.cjs +1 -1
- package/dist/C_TagsView2.js +1 -1
- package/dist/C_Theme.css +7 -8
- package/dist/C_Time.css +1 -1
- package/dist/C_Timeline.css +8 -8
- package/dist/C_Transfer.css +10 -11
- package/dist/C_Tree.css +16 -17
- package/dist/C_Upload.css +156 -157
- package/dist/C_VideoPlayer.css +267 -267
- package/dist/C_VtableGantt.css +2 -2
- package/dist/C_WaterFall.css +2 -2
- package/dist/C_WorkFlow.css +466 -470
- package/dist/C_WorkFlow2.cjs +1 -1
- package/dist/C_WorkFlow2.js +1 -1
- package/dist/Card.cjs +1 -0
- package/dist/Card.js +1 -0
- package/dist/Custom.cjs +1 -0
- package/dist/Custom.js +1 -0
- package/dist/Dynamic.cjs +1 -0
- package/dist/Dynamic.js +1 -0
- package/dist/Steps.cjs +1 -0
- package/dist/Steps.js +1 -0
- package/dist/Tabs.cjs +1 -0
- package/dist/Tabs.js +1 -0
- package/dist/cascader.cjs +1 -0
- package/dist/cascader.js +1 -0
- package/dist/color-picker.cjs +1 -0
- package/dist/color-picker.js +1 -0
- package/dist/constants3.d.cts +71 -117
- package/dist/constants3.d.ts +71 -117
- package/dist/constants4.d.cts +3 -3
- package/dist/constants4.d.ts +3 -3
- package/dist/constants5.d.cts +2 -2
- package/dist/constants5.d.ts +2 -2
- package/dist/context.cjs +1 -0
- package/dist/context.js +1 -0
- package/dist/contracts.d.cts +24 -0
- package/dist/contracts.d.ts +24 -0
- package/dist/createPageLoading.cjs +1 -1
- package/dist/createPageLoading.js +1 -1
- package/dist/data.cjs +1 -1
- package/dist/data.d.cts +9 -9
- package/dist/data.d.ts +9 -9
- package/dist/data.js +1 -1
- package/dist/date-picker.cjs +1 -0
- package/dist/date-picker.js +1 -0
- package/dist/feedback.cjs +1 -0
- package/dist/feedback.js +1 -0
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +1 -1
- package/dist/index.vue.d.cts +5 -5
- package/dist/index.vue.d.ts +5 -5
- package/dist/index10.vue.d.cts +5 -5
- package/dist/index10.vue.d.ts +3 -3
- package/dist/index11.vue.d.cts +3 -3
- package/dist/index11.vue.d.ts +2 -2
- package/dist/index12.vue.d.cts +2 -2
- package/dist/index12.vue.d.ts +1 -1
- package/dist/index13.vue.d.cts +1 -1
- package/dist/index14.vue.d.ts +9 -9
- package/dist/index15.vue.d.cts +9 -9
- package/dist/index15.vue.d.ts +1 -1
- package/dist/index16.vue.d.cts +1 -1
- package/dist/index18.vue.d.ts +4 -4
- package/dist/index19.vue.d.cts +4 -4
- package/dist/index19.vue.d.ts +2 -9
- package/dist/index2.vue.d.cts +2 -2
- package/dist/index2.vue.d.ts +2 -2
- package/dist/index20.vue.d.cts +1 -1
- package/dist/index20.vue.d.ts +1 -1
- package/dist/index21.vue.d.cts +2 -2
- package/dist/index21.vue.d.ts +2 -2
- package/dist/index22.vue.d.cts +1 -1
- package/dist/index22.vue.d.ts +1 -1
- package/dist/index23.vue.d.cts +1 -1
- package/dist/index23.vue.d.ts +1 -1
- package/dist/index25.vue.d.cts +4 -4
- package/dist/index25.vue.d.ts +4 -4
- package/dist/index26.vue.d.cts +1 -1
- package/dist/index26.vue.d.ts +1 -1
- package/dist/index27.vue.d.cts +5 -5
- package/dist/index27.vue.d.ts +5 -5
- package/dist/index28.vue.d.cts +3 -3
- package/dist/index28.vue.d.ts +3 -3
- package/dist/index3.vue.d.cts +3 -3
- package/dist/index3.vue.d.ts +3 -3
- package/dist/index4.vue.d.cts +2 -9
- package/dist/index6.vue.d.ts +4 -4
- package/dist/index7.vue.d.cts +4 -4
- package/dist/index8.vue.d.ts +3 -3
- package/dist/index9.vue.d.cts +3 -3
- package/dist/index9.vue.d.ts +5 -5
- package/dist/mapUtils.d.cts +5 -5
- package/dist/mapUtils.d.ts +5 -5
- package/dist/presets.d.cts +8 -2
- package/dist/presets.d.ts +8 -2
- package/dist/rate.cjs +1 -0
- package/dist/rate.js +1 -0
- package/dist/slider.cjs +1 -0
- package/dist/slider.js +1 -0
- package/dist/style.css +10725 -10722
- package/dist/time-picker.cjs +1 -0
- package/dist/time-picker.js +1 -0
- package/dist/upload.cjs +1 -0
- package/dist/upload.js +1 -0
- package/dist/useActionTask.cjs +1 -0
- package/dist/useActionTask.js +1 -0
- package/dist/useCalendarEvents.d.cts +2 -2
- package/dist/useCalendarEvents.d.ts +2 -2
- package/dist/useCollapsePanel.d.cts +5 -5
- package/dist/useCollapsePanel.d.ts +5 -5
- package/dist/useComponentLocale.cjs +1 -0
- package/dist/useComponentLocale.js +1 -0
- package/dist/useCropperCore.d.cts +8 -8
- package/dist/useCropperCore.d.ts +8 -8
- package/dist/useDraggableLayout.d.cts +9 -9
- package/dist/useDraggableLayout.d.ts +9 -9
- package/dist/useDynamicFormState.cjs +1 -0
- package/dist/useDynamicFormState.d.cts +64 -40
- package/dist/useDynamicFormState.d.ts +64 -40
- package/dist/useDynamicFormState.js +1 -0
- package/dist/useEdgeInteraction.d.cts +2 -2
- package/dist/useEdgeInteraction.d.ts +2 -2
- package/dist/useQRCode.d.cts +2 -2
- package/dist/useQRCode.d.ts +2 -2
- package/dist/useSearchState.d.cts +14 -724
- package/dist/useSearchState.d.ts +14 -833
- package/dist/useSignatureHistory.d.cts +3 -3
- package/dist/useSignatureHistory.d.ts +3 -3
- package/dist/useSplitResize.d.cts +5 -5
- package/dist/useSplitResize.d.ts +5 -5
- package/dist/useTableQuery.cjs +3 -3
- package/dist/useTableQuery.d.cts +66 -33
- package/dist/useTableQuery.d.ts +66 -33
- package/dist/useTableQuery.js +3 -3
- package/dist/useTimeSelection.d.cts +2 -2
- package/dist/useTimeSelection.d.ts +2 -2
- package/dist/useTreeOperations.d.cts +7 -7
- package/dist/useTreeOperations.d.ts +7 -7
- package/dist/useWorkflowValidation.d.cts +5 -5
- package/dist/useWorkflowValidation.d.ts +5 -5
- package/dist/verification.d.cts +1 -1
- package/dist/verification.d.ts +1 -1
- package/docs/architecture.en.md +83 -0
- package/docs/architecture.md +83 -0
- package/docs/assets/README.md +47 -0
- package/docs/assets/naive-ui-components-banner.png +0 -0
- package/docs/assets/naive-ui-components-banner.svg +69 -0
- package/docs/assets/naive-ui-components-logo.png +0 -0
- package/docs/assets/naive-ui-components-logo.svg +22 -0
- package/docs/components.en.md +118 -0
- package/docs/components.md +118 -0
- package/docs/engineering.en.md +132 -0
- package/docs/engineering.md +133 -0
- package/docs/guides/notification-center.md +95 -0
- package/docs/guides/usage.en.md +638 -0
- package/docs/guides/usage.md +699 -0
- package/docs/performance-0.15.0.md +20 -0
- package/docs/security-scan-2026-10-06.md +11 -0
- package/docs/security-scan-2026-10-18.md +16 -0
- package/package.json +29 -11
- package/dist/C_Form2.cjs +0 -1
- package/dist/C_Form2.js +0 -1
- package/dist/config.cjs +0 -1
- package/dist/config.d.cts +0 -33
- package/dist/config.d.ts +0 -33
- package/dist/config.js +0 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
[← English README](../README_EN.md) · [中文](./engineering.md)
|
|
2
|
+
|
|
3
|
+
# Development and build
|
|
4
|
+
|
|
5
|
+
## Build Architecture
|
|
6
|
+
|
|
7
|
+
### Six-stage Build Pipeline
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
bun run build
|
|
11
|
+
├── 1. tsdown → Multi-entry bundling (55 components ESM/CJS/DTS)
|
|
12
|
+
├── 2. sass CLI → Compile the shared-variable entry → global-scss.css
|
|
13
|
+
├── 3. merge-css.js → Merge Vue-compiled SFC CSS + global variables → style.css
|
|
14
|
+
├── 4. gen-exports.js → Auto-generate package.json exports map
|
|
15
|
+
├── 5. check:dist → Validate root, subpath, SSR, and DTS public exports
|
|
16
|
+
└── 6. check:size → Enforce full/base CSS and package-size budgets
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Key Technical Details
|
|
20
|
+
|
|
21
|
+
- **Build engine**: [tsdown](https://github.com/rolldown/tsdown) (Rolldown-based), 55 component entries plus the root entry and resolver
|
|
22
|
+
- **SCSS processing**: Custom `scssTransformPlugin` compiles SFC SCSS within the Rolldown pipeline; standalone Sass CLI only compiles the shared-variable entry
|
|
23
|
+
- **CSS merging**: Post-build merges Vue scoped-compiled per-chunk CSS with shared variables into a single `style.css`, avoiding duplicate styles and leaked raw `:deep()` selectors
|
|
24
|
+
- **Type exports**: Unified `export *` barrel pattern with auto-generated `.d.ts`
|
|
25
|
+
- **Subpath exports**: `gen-exports.js` auto-scans `dist/` and writes the `exports` field in `package.json`
|
|
26
|
+
- **Export conflict detection**: `check-export-conflicts.js` ensures no naming collisions between components
|
|
27
|
+
- **Artifact entry validation**: `check-dist-entries.js` prevents internal chunks from replacing root declarations and verifies component utility subpath types
|
|
28
|
+
- **Package contract validation**: blocks Naive UI internal type paths, hidden optional installs, and plugin console side effects
|
|
29
|
+
- **Size budgets**: `check-size-budget.js` prevents accidental growth of global, C_Form/C_Table, and total dist output
|
|
30
|
+
- **Consumer budgets**: `check-consumer-size.js` builds four minimal Vite applications, sums gzip bytes along the emitted static JS import graph, and rejects eager editor, spreadsheet, screenshot, or print dependencies.
|
|
31
|
+
|
|
32
|
+
### Build Output
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
dist/
|
|
36
|
+
├── index.js / index.cjs / index.d.ts # Main entry
|
|
37
|
+
├── C_Form.js / C_Form.cjs / C_Form.d.ts # Subpath entries (55 components)
|
|
38
|
+
├── C_Form.base.css / C_Form.css # Base/full style tiers
|
|
39
|
+
├── C_Table.base.css / C_Table.css # Base/full style tiers
|
|
40
|
+
├── style.css # Merged full styles
|
|
41
|
+
└── [chunk].js # Shared code chunks
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Development
|
|
45
|
+
|
|
46
|
+
The environment baseline is Node.js 20.19.0+ and Bun 1.3.14. `.node-version`, `packageManager`, `engines`, and the frozen lockfile keep local and CI installs aligned.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
bun install --frozen-lockfile # Install exactly from the lockfile
|
|
50
|
+
bun run dev # Dev mode (SCSS watch + tsdown watch)
|
|
51
|
+
bun run build # Full build
|
|
52
|
+
bun run build:scss # Compile global SCSS only
|
|
53
|
+
bun run build:css # Merge fresh tsdown CSS chunks; safely skips a finalized dist
|
|
54
|
+
bun run build:exports # Generate exports map only
|
|
55
|
+
bun run check:exports # Check export naming conflicts
|
|
56
|
+
bun run check:dist # Validate built JS / DTS public entries
|
|
57
|
+
bun run check:consumer-contracts # Tarball consumer types and optional peer boundaries
|
|
58
|
+
bun run check:package # Validate dependencies, exports, and public source boundaries
|
|
59
|
+
bun run check:quality # Prevent any, console, and type-suppression debt regressions
|
|
60
|
+
bun run check:audit # Audit direct and transitive dependency vulnerabilities
|
|
61
|
+
bun run check:size # Enforce publish artifact size budgets
|
|
62
|
+
bun run check:consumer-size # Check initial consumer bundles after building
|
|
63
|
+
bun run type-check # TypeScript type checking
|
|
64
|
+
bun run test # Run Bun unit tests
|
|
65
|
+
bun run lint:check # Oxlint + ESLint (check only)
|
|
66
|
+
bun run lint:eslint # Audit the existing ESLint rule backlog
|
|
67
|
+
bun run verify # Type, test, export, and build verification
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Consumer budgets include Vue and Naive UI. The four applications are independent measurements and cannot be added to estimate one application's size. `C_Form/base` renders one input; `C_Table/base` renders one row and column. The other cases render one search input and one action button. Base CSS excludes the built-in rich-text editor styles. Dynamic JS is built and checked but excluded from initial bytes; using those features still loads it. This check measures transfer size, not browser interaction performance. Both `verify` and the pre-publish lifecycle include this gate.
|
|
71
|
+
|
|
72
|
+
### Project Structure
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
naive-ui-components/
|
|
76
|
+
├── src/
|
|
77
|
+
│ ├── index.ts # Library entry (global registration + export * barrel)
|
|
78
|
+
│ ├── styles/
|
|
79
|
+
│ │ ├── variables.scss # CSS variables (--c-*)
|
|
80
|
+
│ │ └── global.scss # Auto-generated shared-variable entry
|
|
81
|
+
│ ├── components/
|
|
82
|
+
│ │ └── C_[Name]/
|
|
83
|
+
│ │ ├── index.vue # Main component file
|
|
84
|
+
│ │ ├── index.ts # Barrel export
|
|
85
|
+
│ │ ├── index.scss # Component styles
|
|
86
|
+
│ │ ├── types.ts # Type definitions
|
|
87
|
+
│ │ ├── constants.ts # Constants
|
|
88
|
+
│ │ ├── data.ts # Static data
|
|
89
|
+
│ │ ├── composables/ # Composable functions
|
|
90
|
+
│ │ ├── components/ # Sub-components
|
|
91
|
+
│ │ └── layouts/ # Layout variants (C_Form/C_AntV)
|
|
92
|
+
│ ├── plugins/ # highlight.js and other plugins
|
|
93
|
+
│ └── utils/ # Utility functions
|
|
94
|
+
├── scripts/
|
|
95
|
+
│ ├── gen-global-scss.js # Generate global.scss (shared variables only)
|
|
96
|
+
│ ├── watch-global-scss.js # Dev mode SCSS watcher
|
|
97
|
+
│ ├── merge-css.js # Merge CSS artifacts
|
|
98
|
+
│ ├── gen-exports.js # Auto-generate package.json exports
|
|
99
|
+
│ └── check-export-conflicts.js # Export naming conflict detection
|
|
100
|
+
├── types/
|
|
101
|
+
│ └── env.d.ts # .vue / .scss module declarations
|
|
102
|
+
├── tsdown.config.ts # Build config (multi-entry + SCSS plugin + Vue plugin)
|
|
103
|
+
└── tsconfig.json
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Adding a New Component
|
|
107
|
+
|
|
108
|
+
1. Create `src/components/C_NewComponent/` directory
|
|
109
|
+
2. Write `index.vue`, `index.ts` (barrel), `types.ts`
|
|
110
|
+
3. Add `export * from './components/C_NewComponent'` in `src/index.ts`
|
|
111
|
+
4. Add the component import and registration to the `components` array in `src/index.ts`
|
|
112
|
+
5. Add the name to `componentNames` in `src/resolver.ts`
|
|
113
|
+
6. Run `bun run verify` — build scripts will auto-generate subpath entries and exports mapping
|
|
114
|
+
|
|
115
|
+
### Publishing
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
bun run changeset # Record changes and release level
|
|
119
|
+
bun run version # Update package version and CHANGELOG
|
|
120
|
+
bun run verify # Run all pre-publish checks
|
|
121
|
+
bun run release # Publish pending Changesets releases
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The official local Changesets changelog generator uses commit IDs and change summaries; `bun run version` does not require a GitHub token. npm authentication is still required for publishing. On Windows, if `bun run release` stalls while npm repeats `prepublishOnly`, first confirm `bun run verify` succeeds, then publish from PowerShell with `$env:npm_config_ignore_scripts='true'; bun run release`. This skips only the repeated lifecycle check, not the prerequisite verification.
|
|
125
|
+
|
|
126
|
+
## Documentation assets
|
|
127
|
+
|
|
128
|
+
Brand sources and exported PNGs are in [`assets/`](./assets/). See the [asset guide](./assets/README.md) for colors, logo usage and export instructions.
|
|
129
|
+
|
|
130
|
+
## Architecture boundaries
|
|
131
|
+
|
|
132
|
+
See [architecture and isolation](./architecture.en.md) for dependency direction, app-level ownership and future Element Plus adaptation.
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
[← 项目首页](../README.md) · [English](./engineering.en.md)
|
|
2
|
+
|
|
3
|
+
# 开发与构建
|
|
4
|
+
|
|
5
|
+
## 构建架构
|
|
6
|
+
|
|
7
|
+
### 六阶段构建流水线
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
bun run build
|
|
11
|
+
├── 1. tsdown → 多入口打包(55 组件 ESM/CJS/DTS)
|
|
12
|
+
├── 2. sass CLI → 编译共享变量入口 → global-scss.css
|
|
13
|
+
├── 3. merge-css.js → 合并 Vue 编译后的 SFC CSS + 全局变量 → style.css
|
|
14
|
+
├── 4. gen-exports.js → 自动生成 package.json exports 映射
|
|
15
|
+
├── 5. check:dist → 校验根入口、子路径、SSR 及 DTS 公共导出
|
|
16
|
+
└── 6. check:size → 校验全量/基础样式与发布包体积预算
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### 技术要点
|
|
20
|
+
|
|
21
|
+
- **构建引擎**:[tsdown](https://github.com/rolldown/tsdown)(基于 Rolldown),55 个组件入口,加主入口与 Resolver
|
|
22
|
+
- **SCSS 处理**:自定义 `scssTransformPlugin` 在 Rolldown 管线内编译 SFC SCSS,独立 Sass CLI 仅编译共享变量入口
|
|
23
|
+
- **CSS 合并**:构建后将 Vue 已完成 scoped 转换的 per-chunk CSS 与共享变量合并为单一 `style.css`,避免重复样式和原始 `:deep()` 选择器泄漏
|
|
24
|
+
- **类型导出**:统一 `export *` barrel 模式,自动生成完整 `.d.ts`
|
|
25
|
+
- **子路径导出**:`gen-exports.js` 自动扫描 `dist/` 并写入 `package.json` 的 `exports` 字段
|
|
26
|
+
- **导出冲突检测**:`check-export-conflicts.js` 确保组件间无命名冲突
|
|
27
|
+
- **产物入口校验**:`check-dist-entries.js` 防止内部 chunk 覆盖根声明,并保证组件工具的子路径类型完整
|
|
28
|
+
- **包契约校验**:禁止 Naive UI 内部类型路径、隐式可选依赖和插件控制台副作用
|
|
29
|
+
- **体积预算**:`check-size-budget.js` 阻止全量样式、C_Form/C_Table 样式和 dist 总量意外膨胀
|
|
30
|
+
- **消费端预算**:`check-consumer-size.js` 用 Vite 构建四个最小消费应用,沿实际静态导入图累计首屏 JS gzip;同时检查编辑器、Excel、截图和打印依赖没有进入首屏。
|
|
31
|
+
|
|
32
|
+
### 输出产物
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
dist/
|
|
36
|
+
├── index.js / index.cjs / index.d.ts # 主入口
|
|
37
|
+
├── C_Form.js / C_Form.cjs / C_Form.d.ts # 子路径入口(55 组件)
|
|
38
|
+
├── C_Form.base.css / C_Form.css # 基础/完整样式层级
|
|
39
|
+
├── C_Table.base.css / C_Table.css # 基础/完整样式层级
|
|
40
|
+
├── style.css # 合并后的全量样式
|
|
41
|
+
├── images/ # Leaflet Marker/图层控件资源
|
|
42
|
+
└── [chunk].js # 共享代码块
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## 开发
|
|
46
|
+
|
|
47
|
+
环境基线为 Node.js 20.19.0+ 与 Bun 1.3.14;仓库通过 `.node-version`、`packageManager`、`engines` 和冻结锁文件保持本地/CI 一致。
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
bun install --frozen-lockfile # 严格按锁文件安装依赖
|
|
51
|
+
bun run dev # 开发模式(SCSS watch + tsdown watch)
|
|
52
|
+
bun run build # 完整构建
|
|
53
|
+
bun run build:scss # 仅编译全局 SCSS
|
|
54
|
+
bun run build:css # 合并 tsdown 刚生成的 CSS chunk;已完成的 dist 会安全跳过
|
|
55
|
+
bun run build:exports # 仅生成 exports 映射
|
|
56
|
+
bun run check:exports # 检测导出命名冲突
|
|
57
|
+
bun run check:dist # 校验构建后的 JS / DTS 公共入口
|
|
58
|
+
bun run check:consumer-contracts # 真实打包消费者类型与可选 peer 边界
|
|
59
|
+
bun run check:package # 校验依赖、导出和源码公共边界
|
|
60
|
+
bun run check:quality # 防止 any、console 与类型抑制债务反弹
|
|
61
|
+
bun run check:audit # 审计直接与传递依赖漏洞
|
|
62
|
+
bun run check:size # 校验发布产物体积预算
|
|
63
|
+
bun run check:consumer-size # 构建后检查常用组件的消费端首屏预算
|
|
64
|
+
bun run type-check # TypeScript 类型检查
|
|
65
|
+
bun run test # 运行 Bun 单元测试
|
|
66
|
+
bun run lint:check # Oxlint + ESLint(只检查)
|
|
67
|
+
bun run lint:eslint # ESLint 存量规则审计
|
|
68
|
+
bun run verify # 类型、测试、导出和构建全量验证
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
消费端预算包含 Vue 和 Naive UI,四个独立场景分别测量,不能相加当作同一应用的体积。`C_Form/base` 为单输入字段,`C_Table/base` 为单列单行展示表格;另外测量一个输入查询和一个操作按钮。基础样式排除内置富文本编辑器样式。动态 JS 会完成构建检查,但不计入首屏;使用对应字段或功能时仍会加载。此检查衡量传输体积,不替代真实浏览器的交互性能测量。`verify` 和发布前生命周期均包含该门禁。
|
|
72
|
+
|
|
73
|
+
### 项目结构
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
naive-ui-components/
|
|
77
|
+
├── src/
|
|
78
|
+
│ ├── index.ts # 库入口(全量注册 + export * barrel)
|
|
79
|
+
│ ├── styles/
|
|
80
|
+
│ │ ├── variables.scss # CSS 变量 (--c-*)
|
|
81
|
+
│ │ └── global.scss # 自动生成的共享变量入口
|
|
82
|
+
│ ├── components/
|
|
83
|
+
│ │ └── C_[Name]/
|
|
84
|
+
│ │ ├── index.vue # 组件主文件
|
|
85
|
+
│ │ ├── index.ts # Barrel 导出
|
|
86
|
+
│ │ ├── index.scss # 组件样式
|
|
87
|
+
│ │ ├── types.ts # 类型定义
|
|
88
|
+
│ │ ├── constants.ts # 常量
|
|
89
|
+
│ │ ├── data.ts # 静态数据
|
|
90
|
+
│ │ ├── composables/ # 组合式函数
|
|
91
|
+
│ │ ├── components/ # 子组件
|
|
92
|
+
│ │ └── layouts/ # 布局变体(C_Form/C_AntV)
|
|
93
|
+
│ ├── plugins/ # highlight.js 等插件
|
|
94
|
+
│ └── utils/ # 工具函数
|
|
95
|
+
├── scripts/
|
|
96
|
+
│ ├── gen-global-scss.js # 生成 global.scss(仅共享变量)
|
|
97
|
+
│ ├── watch-global-scss.js # 开发模式 SCSS 监听
|
|
98
|
+
│ ├── merge-css.js # 合并 CSS 产物
|
|
99
|
+
│ ├── gen-exports.js # 自动生成 package.json exports
|
|
100
|
+
│ └── check-export-conflicts.js # 导出命名冲突检测
|
|
101
|
+
├── types/
|
|
102
|
+
│ └── env.d.ts # .vue / .scss 模块声明
|
|
103
|
+
├── tsdown.config.ts # 构建配置(多入口 + SCSS 插件 + Vue 插件)
|
|
104
|
+
└── tsconfig.json
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 添加新组件
|
|
108
|
+
|
|
109
|
+
1. 创建 `src/components/C_NewComponent/` 目录
|
|
110
|
+
2. 编写 `index.vue`、`index.ts`(barrel)、`types.ts`
|
|
111
|
+
3. 在 `src/index.ts` 中添加 `export * from './components/C_NewComponent'`
|
|
112
|
+
4. 在 `src/index.ts` 中导入组件并加入 `components` 注册数组
|
|
113
|
+
5. 在 `src/resolver.ts` 的 `componentNames` 中登记名称
|
|
114
|
+
6. 运行 `bun run verify`—构建脚本会自动生成子路径入口和 exports 映射
|
|
115
|
+
|
|
116
|
+
### 发布
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
bun run changeset # 记录变更及版本级别
|
|
120
|
+
bun run version # 更新版本号与 CHANGELOG
|
|
121
|
+
bun run verify # 发布前完整验证
|
|
122
|
+
bun run release # 发布 Changesets 中待发布版本
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
变更日志使用 Changesets 官方本地生成器,根据 Changeset 与 Git 提交生成,无需额外 `GITHUB_TOKEN`。npm 发布仍需要有效的发布账号认证,凭据不得写入仓库。Windows 下如果 `bun run release` 在 npm 的 `prepublishOnly` 重复验证阶段停滞,可先单独确认 `bun run verify` 成功,再在 PowerShell 中用 `$env:npm_config_ignore_scripts='true'; bun run release` 发布;该设置仅跳过已手动完成的重复生命周期验证,不应省略前一步。
|
|
126
|
+
|
|
127
|
+
## 文档资源
|
|
128
|
+
|
|
129
|
+
品牌源文件与 PNG 导出位于 [`assets/`](./assets/),配色、Logo 使用及导出方式见[资源说明](./assets/README.md)。
|
|
130
|
+
|
|
131
|
+
## 架构边界
|
|
132
|
+
|
|
133
|
+
依赖方向、应用所有权与后续 Element Plus 适配要求见[架构与隔离](./architecture.md)。
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# 通知中心:演示、远程接口与共享数据源
|
|
2
|
+
|
|
3
|
+
`C_NotificationCenter` 提供顶部入口、分类列表、详情与消息操作。业务路由、用户/公司身份、待办办理和后端投递由应用负责;组件不读取业务 Store,不绑定具体后台。
|
|
4
|
+
|
|
5
|
+
## 保留开箱演示
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<C_NotificationCenter
|
|
9
|
+
data-mode="demo"
|
|
10
|
+
storage-key="my-app:notifications:demo"
|
|
11
|
+
/>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
未指定 `dataMode` 时,配置 `fetchNotifications` 会进入远程模式,否则保持演示兼容行为。显式 `demo` 使用内置消息,已读、删除、清空即时持久化到自己的 storage key;刷新和重挂不会恢复已经清空的消息。需要重置演示时由应用删除该 key,其他应用存储不会被修改。
|
|
15
|
+
|
|
16
|
+
演示模式不调用远程适配器,不启动远程轮询。消息推送配置仍需显式提供,组件不会连接任何演示服务器。
|
|
17
|
+
|
|
18
|
+
## 对接远程查询与命令
|
|
19
|
+
|
|
20
|
+
```vue
|
|
21
|
+
<C_NotificationCenter
|
|
22
|
+
data-mode="remote"
|
|
23
|
+
:fetch-notifications="fetchInbox"
|
|
24
|
+
:mark-as-read="markRead"
|
|
25
|
+
:mark-all-read="markAllRead"
|
|
26
|
+
:delete-notification="deleteInboxItems"
|
|
27
|
+
:clear-notifications="clearInbox"
|
|
28
|
+
:on-error="reportNotificationError"
|
|
29
|
+
@view-all="router.push('/message-center')"
|
|
30
|
+
/>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`fetchInbox({ category, page, pageSize })` 返回:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
{
|
|
37
|
+
list: NotificationMessage[],
|
|
38
|
+
total: number, // 当前查询条件的总条数
|
|
39
|
+
unreadCount: number, // 全局未读总数,不是当前页或当前分类的数量
|
|
40
|
+
unreadByCategory?: { system?: number, business?: number, alarm?: number }
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
分类统计未返回时保持未知,UI 隐藏对应数字,不能用当前页推算完整统计。分页合并按消息 ID 去重,并更新服务端返回的同 ID 记录。分页失败保留已加载数据和当前页,重试继续失败的目标页。
|
|
45
|
+
|
|
46
|
+
远程模式缺少查询或操作适配器会显示错误并拒绝该操作,绝不会回退到演示数据或伪装成功。异步命令必须在对应适配器内返回 Promise;`read`、`delete`、`allRead` 仅通知正常点击命令的成功完成。错误区的“重试”会重放最近失败的命令;重试不会补发原点击的成功事件,业务状态应以共享数据源或服务端结果为准。
|
|
47
|
+
|
|
48
|
+
读、删命令使用操作日志叠加状态。旧请求失败只撤销自己的影响,不会覆盖后续成功操作,也不会用旧整表快照抹掉刷新或实时新增的消息。批量已读和清空需要后端定义作用范围、截止时间与权限;涉及跨页或复杂业务筛选时,建议使用下方应用控制器协调接口与服务端统计对账。
|
|
49
|
+
|
|
50
|
+
没有服务端快照版本或事件游标时,前端无法判断一次统计响应是否已包含仍在途中的批量命令。应用适配器应发送明确截止时间/版本,成功后重新查询权威统计;查询和推送也应采用同一服务端版本规则。组件的操作日志用于避免本地请求回滚互相覆盖,不代表对服务器全量状态的交付或一致性保证。跨页已知记录索引仅额外保留最近 256 条,当前可见记录与进行中操作记录按需保留。
|
|
51
|
+
|
|
52
|
+
## 顶部与完整消息中心共用应用状态
|
|
53
|
+
|
|
54
|
+
`controller?: NotificationCenterController` 是可选的公开协议,所有状态为 Ref 或 computed Ref。传入后,组件不再创建内部 core,不额外请求、轮询或建连,也不会在卸载时销毁应用数据源。
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { useNotificationCore } from '@robot-admin/naive-ui-components'
|
|
58
|
+
|
|
59
|
+
// 在应用拥有的 setup/effectScope 中创建;Store 的身份隔离和退出清理由应用管理。
|
|
60
|
+
const controller = useNotificationCore({
|
|
61
|
+
dataMode: 'remote',
|
|
62
|
+
fetchNotifications: fetchInbox,
|
|
63
|
+
markAsRead: markRead,
|
|
64
|
+
pollingInterval: 60_000,
|
|
65
|
+
})
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```vue
|
|
69
|
+
<C_NotificationCenter :controller="controller" @view-all="openMessageCenter" />
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
自定义应用 Store 也可以直接实现该接口。列表、统计和操作可投影共享 Store;`activeCategory`、`selectedMessage`、`popoverVisible` 可在顶部桥接对象中独立保存,避免完整页面的筛选改变顶部列表。请传递保留 Ref 的普通对象,避免用会自动解包 Ref 的深层 reactive 对象包裹整个控制器。
|
|
73
|
+
|
|
74
|
+
控制器包含 `error`、`busy`、`pendingIds`、`clearError()`,以及可选 `retry()`。若自定义控制器未提供 retry,错误区重试会刷新列表。独立 `useNotificationCore` 另外返回 `initialize()`/`dispose()`;需要手动初始化时设 `autoStart: false`。Vue 组件挂载后自动初始化,普通 effectScope 内会立即初始化,作用域停止会清理资源。切换 dataMode/storageKey 会清理旧作用域数据并重新初始化;远程用户/公司切换仍应由应用替换控制器或销毁旧作用域,并按身份取消请求。
|
|
75
|
+
|
|
76
|
+
## WebSocket 的可选增强
|
|
77
|
+
|
|
78
|
+
支持:
|
|
79
|
+
|
|
80
|
+
- `new_message`:完整 NotificationMessage;按 ID 去重,校验消息结构。
|
|
81
|
+
- `read_sync`:完整消息数组;同步其中消息 ID 的已读状态。
|
|
82
|
+
- `count_update`:`{ unreadCount, unreadByCategory? }`;校准权威未读统计,不重复扣减之前已发出的乐观命令。
|
|
83
|
+
|
|
84
|
+
自动重连使用有上限的退避,旧 socket 的迟到事件会被忽略。再次连接成功后远程 core 重新查询列表和统计。可选 `heartbeatTimeout` 启用 pong 超时检测;默认 0 保持既有仅发送心跳的兼容行为。
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
const wsConfig = {
|
|
88
|
+
url: 'wss://your-service.example/notifications',
|
|
89
|
+
heartbeatInterval: 30_000,
|
|
90
|
+
heartbeatTimeout: 10_000,
|
|
91
|
+
getToken: () => currentAccessToken(),
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
桌面通知权限仅在应用调用 `requestDesktopPermission()` 的用户手势中申请。连接、轮询和缓存都不代表服务端保证交付:事件游标、历史补偿、跨设备一致性、幂等写入、审计与投递重试需要后端协议支持。应用也应在恢复可见、重新登录或切换公司时补刷,并对消息业务目标重新校验权限。
|