@campus-admin/ui 1.0.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/LICENSE +21 -0
- package/README.md +367 -0
- package/dist/atom/attendance-badge/index.d.ts +5 -0
- package/dist/atom/attendance-badge/src/attendance-badge.vue.d.ts +13 -0
- package/dist/atom/attendance-badge/src/core.d.ts +11 -0
- package/dist/atom/avatar/index.d.ts +3 -0
- package/dist/atom/avatar/src/avatar.vue.d.ts +14 -0
- package/dist/atom/button/index.d.ts +3 -0
- package/dist/atom/button/src/button.vue.d.ts +40 -0
- package/dist/atom/checkbox/index.d.ts +3 -0
- package/dist/atom/checkbox/src/checkbox.vue.d.ts +24 -0
- package/dist/atom/icon/index.d.ts +3 -0
- package/dist/atom/icon/src/icon.vue.d.ts +27 -0
- package/dist/atom/index.d.ts +444 -0
- package/dist/atom/input/index.d.ts +3 -0
- package/dist/atom/input/src/input.vue.d.ts +43 -0
- package/dist/atom/progress/index.d.ts +4 -0
- package/dist/atom/progress/src/core.d.ts +9 -0
- package/dist/atom/progress/src/progress.vue.d.ts +19 -0
- package/dist/atom/select/index.d.ts +5 -0
- package/dist/atom/select/src/core.d.ts +9 -0
- package/dist/atom/select/src/select.vue.d.ts +22 -0
- package/dist/atom/slogan/index.d.ts +3 -0
- package/dist/atom/slogan/src/slogan.vue.d.ts +9 -0
- package/dist/atom/switch/index.d.ts +3 -0
- package/dist/atom/switch/src/switch.vue.d.ts +16 -0
- package/dist/atom/tag/index.d.ts +3 -0
- package/dist/atom/tag/src/tag.vue.d.ts +31 -0
- package/dist/atom/textarea/index.d.ts +3 -0
- package/dist/atom/textarea/src/textarea.vue.d.ts +19 -0
- package/dist/base/breadcrumb/index.d.ts +4 -0
- package/dist/base/breadcrumb/src/breadcrumb.vue.d.ts +29 -0
- package/dist/base/class-tree/index.d.ts +5 -0
- package/dist/base/class-tree/src/class-tree.vue.d.ts +29 -0
- package/dist/base/class-tree/src/core.d.ts +30 -0
- package/dist/base/copyright/index.d.ts +3 -0
- package/dist/base/copyright/src/copyright.vue.d.ts +25 -0
- package/dist/base/drawer/index.d.ts +3 -0
- package/dist/base/drawer/src/drawer.vue.d.ts +36 -0
- package/dist/base/empty/index.d.ts +3 -0
- package/dist/base/empty/src/empty.vue.d.ts +20 -0
- package/dist/base/index.d.ts +651 -0
- package/dist/base/menu/core.d.ts +34 -0
- package/dist/base/menu/index.d.ts +13 -0
- package/dist/base/menu/side-menu/index.d.ts +5 -0
- package/dist/base/menu/side-menu/src/side-menu.vue.d.ts +59 -0
- package/dist/base/modal/index.d.ts +4 -0
- package/dist/base/modal/src/core.d.ts +8 -0
- package/dist/base/modal/src/modal.vue.d.ts +46 -0
- package/dist/base/page-header/index.d.ts +3 -0
- package/dist/base/page-header/src/page-header.vue.d.ts +27 -0
- package/dist/base/pagination/index.d.ts +5 -0
- package/dist/base/pagination/src/core.d.ts +11 -0
- package/dist/base/pagination/src/pagination.vue.d.ts +26 -0
- package/dist/base/search-form/index.d.ts +3 -0
- package/dist/base/search-form/src/search-form.vue.d.ts +34 -0
- package/dist/base/skeleton/index.d.ts +3 -0
- package/dist/base/skeleton/src/skeleton.vue.d.ts +11 -0
- package/dist/base/statistic/index.d.ts +3 -0
- package/dist/base/statistic/src/statistic.vue.d.ts +16 -0
- package/dist/base/table/index.d.ts +5 -0
- package/dist/base/table/src/core.d.ts +25 -0
- package/dist/base/table/src/table.vue.d.ts +44 -0
- package/dist/base/toast/index.d.ts +5 -0
- package/dist/base/toast/src/store.d.ts +56 -0
- package/dist/base/toast/src/toast-container.vue.d.ts +3 -0
- package/dist/campus-ui.css +2 -0
- package/dist/campus-ui.js +2229 -0
- package/dist/campus-ui.umd.cjs +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/namespace.d.ts +16 -0
- package/dist/core/theme.d.ts +49 -0
- package/dist/feature/daily-agenda/index.d.ts +5 -0
- package/dist/feature/daily-agenda/src/core.d.ts +25 -0
- package/dist/feature/daily-agenda/src/daily-agenda.vue.d.ts +12 -0
- package/dist/feature/daily-agenda/src/data.d.ts +3 -0
- package/dist/feature/index.d.ts +61 -0
- package/dist/feature/student-picker/index.d.ts +5 -0
- package/dist/feature/student-picker/src/core.d.ts +19 -0
- package/dist/feature/student-picker/src/student-picker.vue.d.ts +26 -0
- package/dist/feature/weekly-timetable/index.d.ts +6 -0
- package/dist/feature/weekly-timetable/src/core.d.ts +33 -0
- package/dist/feature/weekly-timetable/src/data.d.ts +3 -0
- package/dist/feature/weekly-timetable/src/weekly-timetable.vue.d.ts +7 -0
- package/dist/index.d.ts +1110 -0
- package/package.json +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 UnionSchool
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
# @campus-admin/ui
|
|
2
|
+
|
|
3
|
+
面向智慧校园后台管理场景的 Vue 3 组件库,共 27 个组件,分**原子 / 基础 / 功能**三层。
|
|
4
|
+
|
|
5
|
+
组件只负责渲染,**不访问接口、不读全局状态**:数据通过 Props 传入,
|
|
6
|
+
用户操作通过 Events 抛出。
|
|
7
|
+
|
|
8
|
+
主题支持**明暗两套配色**与**运行时品牌换色**:一行代码切换暗色,一行代码把主色换成学校品牌色。
|
|
9
|
+
|
|
10
|
+
## 安装
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pnpm add @campus-admin/ui
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
通常不需要单独安装——[`@campus-admin/core`](../core) 已包含它。
|
|
17
|
+
|
|
18
|
+
依赖:`vue@^3.5.42`、`@lucide/vue@^1.44.0`(均为 peerDependency)。
|
|
19
|
+
|
|
20
|
+
## 两种引入方式
|
|
21
|
+
|
|
22
|
+
### 按需引入(推荐)
|
|
23
|
+
|
|
24
|
+
```vue
|
|
25
|
+
<script setup lang="ts">
|
|
26
|
+
import { CaButton, CaTable, toast } from '@campus-admin/ui'
|
|
27
|
+
import type { TableColumn } from '@campus-admin/ui'
|
|
28
|
+
import '@campus-admin/ui/style.css'
|
|
29
|
+
</script>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 全局注册
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { createApp } from 'vue'
|
|
36
|
+
import CampusUI from '@campus-admin/ui'
|
|
37
|
+
import '@campus-admin/ui/style.css'
|
|
38
|
+
|
|
39
|
+
createApp(App).use(CampusUI).mount('#app')
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
注册后模板里直接写 `<CaButton>`,无需 import。
|
|
43
|
+
|
|
44
|
+
## 组件清单
|
|
45
|
+
|
|
46
|
+
**原子(`src/atom`)** —— 元素级,不占版面,多为其他组件的零件
|
|
47
|
+
|
|
48
|
+
| 组件 | 用途 |
|
|
49
|
+
| --- | --- |
|
|
50
|
+
| `CaButton` | 操作按钮 |
|
|
51
|
+
| `CaIcon` | 单色图标容器 |
|
|
52
|
+
| `CaTag` | 状态/分类标记 |
|
|
53
|
+
| `CaAvatar` | 用户/学生头像 |
|
|
54
|
+
| `CaInput` | 单行文本 |
|
|
55
|
+
| `CaTextarea` | 多行文本 |
|
|
56
|
+
| `CaSelect` | 下拉选择 |
|
|
57
|
+
| `CaCheckbox` | 勾选 / 半选 |
|
|
58
|
+
| `CaSwitch` | 开关 |
|
|
59
|
+
| `CaProgress` | 进度条 / 环形进度 |
|
|
60
|
+
| `CaAttendanceBadge` | 考勤状态标签 |
|
|
61
|
+
|
|
62
|
+
**基础(`src/base`)** —— 区域级,可直接放进页面布局,与业务无关
|
|
63
|
+
|
|
64
|
+
| 组件 | 用途 |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| `CaTable` | 数据表格(泛型 + 排序) |
|
|
67
|
+
| `CaPagination` | 分页 |
|
|
68
|
+
| `CaStatistic` | 指标数值 |
|
|
69
|
+
| `CaModal` | 对话框 |
|
|
70
|
+
| `CaDrawer` | 抽屉 |
|
|
71
|
+
| `CaEmpty` | 空状态 |
|
|
72
|
+
| `CaSkeleton` | 骨架屏 |
|
|
73
|
+
| `CaToastContainer` + `toast` | 轻提示(挂载式) |
|
|
74
|
+
| `CaBreadcrumb` | 面包屑 |
|
|
75
|
+
| `CaSideMenu` | 侧边多级菜单 |
|
|
76
|
+
| `CaPageHeader` | 页面标题栏 |
|
|
77
|
+
| `CaSearchForm` | 查询表单 |
|
|
78
|
+
| `CaClassTree` | 年级班级树 |
|
|
79
|
+
|
|
80
|
+
**功能(`src/feature`)** —— 多个组件组合起来完成一件事,不区分角色
|
|
81
|
+
|
|
82
|
+
| 组件 | 用途 |
|
|
83
|
+
| --- | --- |
|
|
84
|
+
| `CaStudentPicker` | 学生选择器 |
|
|
85
|
+
| `CaWeeklyTimetable` | 课程表 |
|
|
86
|
+
| `CaDailyAgenda` | 日程安排 |
|
|
87
|
+
|
|
88
|
+
每个组件的 `.vue` 文件顶部都有使用说明(用法、Props、事件、插槽),
|
|
89
|
+
各层的判据与目录约定见 `src/atom/README.md`、`src/base/README.md`、`src/feature/README.md`。
|
|
90
|
+
|
|
91
|
+
## 快速示例
|
|
92
|
+
|
|
93
|
+
### 数据表格
|
|
94
|
+
|
|
95
|
+
```vue
|
|
96
|
+
<script setup lang="ts">
|
|
97
|
+
import { ref } from 'vue'
|
|
98
|
+
import { CaPagination, CaTable } from '@campus-admin/ui'
|
|
99
|
+
import type { TableColumn } from '@campus-admin/ui'
|
|
100
|
+
|
|
101
|
+
interface StudentRow {
|
|
102
|
+
id: string
|
|
103
|
+
name: string
|
|
104
|
+
className: string
|
|
105
|
+
balance: number
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const columns: TableColumn<StudentRow>[] = [
|
|
109
|
+
{ key: 'name', title: '姓名' },
|
|
110
|
+
{ key: 'className', title: '班级' },
|
|
111
|
+
{ key: 'balance', title: '余额', numeric: true, sortable: true },
|
|
112
|
+
]
|
|
113
|
+
|
|
114
|
+
const rows = ref<StudentRow[]>([])
|
|
115
|
+
const total = ref(0)
|
|
116
|
+
const page = ref(1)
|
|
117
|
+
</script>
|
|
118
|
+
|
|
119
|
+
<template>
|
|
120
|
+
<CaTable :columns="columns" :data="rows" row-key="id" stripe>
|
|
121
|
+
<!-- 单元格插槽命名为 cell-<列 key>,参数是 row / index / column -->
|
|
122
|
+
<template #cell-name="{ row }">
|
|
123
|
+
<CaAvatar :name="row.name" size="small" />
|
|
124
|
+
<b>{{ row.name }}</b>
|
|
125
|
+
</template>
|
|
126
|
+
</CaTable>
|
|
127
|
+
|
|
128
|
+
<CaPagination v-model:current="page" :total="total" />
|
|
129
|
+
</template>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
要点:
|
|
133
|
+
|
|
134
|
+
- `columns` 是普通数组,可来自后端下发
|
|
135
|
+
- `rowKey` 必须是稳定字段或函数,不要用数组下标
|
|
136
|
+
- 单元格插槽名为 `cell-<列 key>`;泛型会跟着 `columns` 推导,`row` 自动获得具体字段类型
|
|
137
|
+
- **排序有两种模式**:不传 `sort-key` / `sort-order` 时组件内部排序(点击表头按 升序 → 降序 → 取消 循环);
|
|
138
|
+
传入这两个 prop 且监听 `sort` 事件时用于服务端排序
|
|
139
|
+
|
|
140
|
+
### 多级侧边菜单
|
|
141
|
+
|
|
142
|
+
```vue
|
|
143
|
+
<script setup lang="ts">
|
|
144
|
+
import { CaSideMenu } from '@campus-admin/ui'
|
|
145
|
+
import type { SideMenuItem } from '@campus-admin/ui'
|
|
146
|
+
|
|
147
|
+
const items: SideMenuItem[] = [
|
|
148
|
+
{ label: '学校概况', icon: LayoutDashboard, children: [
|
|
149
|
+
{ label: '我的首页', value: '/home' },
|
|
150
|
+
{ label: '学生管理', value: '/students' },
|
|
151
|
+
] },
|
|
152
|
+
{ label: '教学教务', icon: BookOpen, children: [
|
|
153
|
+
{ label: '课程管理', children: [
|
|
154
|
+
{ label: '课程表', value: '/teach/course/schedule' },
|
|
155
|
+
] },
|
|
156
|
+
] },
|
|
157
|
+
]
|
|
158
|
+
|
|
159
|
+
function go(item: SideMenuItem) {
|
|
160
|
+
if (item.value) router.push(item.value)
|
|
161
|
+
}
|
|
162
|
+
</script>
|
|
163
|
+
|
|
164
|
+
<template>
|
|
165
|
+
<CaSideMenu :items="items" :model-value="route.path" :indent="2" :indent-step="32" @select="go" />
|
|
166
|
+
</template>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**菜单组件不认识路由**:`value` 是业务数据,跳转由使用方决定。
|
|
170
|
+
这样同一组件也能用于小程序或纯链接场景。
|
|
171
|
+
|
|
172
|
+
### 轻提示
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import { toast } from '@campus-admin/ui'
|
|
176
|
+
|
|
177
|
+
toast.success('保存成功')
|
|
178
|
+
toast.error('保存失败', '请检查网络')
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
挂载式用法:在模板里放一个 `<CaToastContainer />`。
|
|
182
|
+
如果用 `@campus-admin/core`,推荐改用全局的 `ca.toast()`(见下方"与 ca 的关系")。
|
|
183
|
+
|
|
184
|
+
## 与 ca 的关系
|
|
185
|
+
|
|
186
|
+
`@campus-admin/core` 提供全局命令式 API `ca`,与本库的 `toast` **共用同一份消息队列**:
|
|
187
|
+
|
|
188
|
+
```js
|
|
189
|
+
ca.toast('保存成功') // 与 toast.success('保存成功') 等效
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
本库的 `toast` 保留了描述文案等扩展能力;`ca.toast` 更简洁,适合在任意 JS 里调用。
|
|
193
|
+
|
|
194
|
+
## 主题与样式
|
|
195
|
+
|
|
196
|
+
### 引入样式
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
import '@campus-admin/ui/style.css'
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### 明暗主题
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
import { setTheme } from '@campus-admin/ui'
|
|
206
|
+
|
|
207
|
+
setTheme('dark') // 暗色
|
|
208
|
+
setTheme('light') // 亮色
|
|
209
|
+
setTheme('auto') // 跟随系统,系统切换时自动更新
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
`setTheme` 只是在 `<html>` 上写 `data-ca-theme`,配色由 Token 决定,
|
|
213
|
+
组件样式不区分主题。也可以不用 JS,直接写 `<html data-ca-theme="dark">`。
|
|
214
|
+
|
|
215
|
+
### 品牌换色(运行时)
|
|
216
|
+
|
|
217
|
+
学校品牌色不是蓝色时,只给一个主色,其余色阶自动推导:
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
import { setPrimaryColor, resetPrimaryColor } from '@campus-admin/ui'
|
|
221
|
+
|
|
222
|
+
setPrimaryColor('#7c4dff') // 紫色品牌
|
|
223
|
+
resetPrimaryColor() // 恢复默认蓝色
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
会自动生成并写入以下变量:`--ca-color-primary`、`-hover`、`-active`、`-soft`、`-text`、`-contrast`。
|
|
227
|
+
推导规则是:
|
|
228
|
+
|
|
229
|
+
- 亮色下 hover / active 变深,暗色下变亮;
|
|
230
|
+
- `-soft` 浅底跟随当前主题(亮色混合白、暗色混合深色卡片底);
|
|
231
|
+
- `-text` 用于浅底上的文字,品牌色过浅时自动加深(暗色下自动提亮)以满足对比度;
|
|
232
|
+
- `-contrast` 是主色实心背景上的文字色,浅色品牌(如黄色)自动切换成深色文字。
|
|
233
|
+
|
|
234
|
+
因此按钮、标签、菜单选中态、表格悬停、课表色块都会一起跟着变,不需要逐个组件配置。
|
|
235
|
+
|
|
236
|
+
### 覆盖 Token(更细粒度的换肤)
|
|
237
|
+
|
|
238
|
+
所有视觉都走 CSS 变量,改变量即可换肤,**不要写深层选择器覆盖**:
|
|
239
|
+
|
|
240
|
+
```css
|
|
241
|
+
:root {
|
|
242
|
+
--ca-color-primary: #1f6fe0; /* 主色(等价于 setPrimaryColor) */
|
|
243
|
+
--ca-color-success: #2fae85;
|
|
244
|
+
--ca-radius-md: 6px;
|
|
245
|
+
--ca-control-height-md: 32px; /* 控件高度,可用于调整信息密度 */
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Token 分三层,完整清单见 `src/styles/token.css`:
|
|
250
|
+
|
|
251
|
+
```text
|
|
252
|
+
基础色 palette --ca-color-blue-500、--ca-space-4、--ca-radius-md
|
|
253
|
+
品牌与语义色 --ca-color-primary-soft、--ca-color-success-text、--ca-text-secondary、--ca-surface-card
|
|
254
|
+
文字层级 --ca-text-primary、--ca-text-regular、--ca-text-secondary、--ca-text-placeholder、--ca-text-menu
|
|
255
|
+
主题覆盖 :root[data-ca-theme='dark'] 覆盖语义与中性色
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
层级 Token 同样可覆盖:`--ca-z-index-modal`、`--ca-z-index-message`。
|
|
259
|
+
|
|
260
|
+
### 国际化
|
|
261
|
+
|
|
262
|
+
组件库内置 zh-CN / en-US 两套词条,不需要额外安装 i18n 库。单独使用 `@campus-admin/ui` 时,
|
|
263
|
+
在入口建一个语言实例并注入应用:
|
|
264
|
+
|
|
265
|
+
```ts
|
|
266
|
+
import { CampusUI, createLocale, installLocale } from '@campus-admin/ui'
|
|
267
|
+
import { createApp } from 'vue'
|
|
268
|
+
|
|
269
|
+
const app = createApp(App)
|
|
270
|
+
const locale = createLocale({
|
|
271
|
+
locale: 'zh-CN',
|
|
272
|
+
// 业务词条放在自己的根键下,ca 是组件库保留的命名空间
|
|
273
|
+
messages: { 'zh-CN': zhCN, 'en-US': enUS },
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
app.use(CampusUI) // 已自带一份默认语言实例,可省略下一行
|
|
277
|
+
installLocale(app, locale)
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
取词与切换:
|
|
281
|
+
|
|
282
|
+
```ts
|
|
283
|
+
import { setLocale, useLocale } from '@campus-admin/ui'
|
|
284
|
+
|
|
285
|
+
const { t, te } = useLocale() // 组件内取词
|
|
286
|
+
t('ca.pagination.total', { total: 12 }) // 共 12 条
|
|
287
|
+
|
|
288
|
+
setLocale('en-US') // 非 setup 场景
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
日期与数字格式化走内置的 `Intl` 封装,不要自己拼中文:
|
|
292
|
+
|
|
293
|
+
```ts
|
|
294
|
+
import { formatDay, formatMonth, formatNumber, weekdayLabels } from '@campus-admin/ui'
|
|
295
|
+
|
|
296
|
+
formatMonth(new Date(2026, 8, 11), 'en-US') // September 2026
|
|
297
|
+
weekdayLabels('zh-CN') // ['周一', ...]
|
|
298
|
+
formatNumber(3286, 'en-US') // 3,286
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
已经用 vue-i18n 的项目不要再装第二个实例,把内置词条合并进自己的实例即可:
|
|
302
|
+
|
|
303
|
+
```ts
|
|
304
|
+
import { caMessages } from '@campus-admin/ui'
|
|
305
|
+
|
|
306
|
+
i18n.global.mergeLocaleMessage('zh-CN', caMessages['zh-CN'])
|
|
307
|
+
i18n.global.mergeLocaleMessage('en-US', caMessages['en-US'])
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
完整约定(命名空间、覆盖组件文案、后端文案对接、加语言)见
|
|
311
|
+
[Campus Admin 国际化使用指南](../../docs/Campus-Admin-国际化使用指南.md)。
|
|
312
|
+
|
|
313
|
+
### 类名约定
|
|
314
|
+
|
|
315
|
+
```text
|
|
316
|
+
块 .ca-button
|
|
317
|
+
元素 .ca-button__icon
|
|
318
|
+
修饰符 .ca-button--primary
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
组件样式是统一 `ca-` 前缀的 BEM 类名,**只有 Token 是稳定的公共契约**,类名不作为 API。
|
|
322
|
+
业务侧换肤请覆盖变量,不要写深层选择器。
|
|
323
|
+
|
|
324
|
+
## 开发约定
|
|
325
|
+
|
|
326
|
+
三层目录结构(`atom` / `base` / `feature`),每个组件目录结构统一:
|
|
327
|
+
|
|
328
|
+
```text
|
|
329
|
+
src/<层>/<组件名>/
|
|
330
|
+
├── src/core.ts 纯逻辑,不依赖 Vue(可单测)
|
|
331
|
+
├── src/data.ts 演示数据(可选)
|
|
332
|
+
├── src/<组件名>.vue 只做渲染
|
|
333
|
+
├── style/index.css 样式,由 .vue 通过 `<style src="../style/index.css">` 引入
|
|
334
|
+
└── index.ts 导出 Ca 前缀组件与公开类型
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
新增组件只需要改两处:组件自己的目录 + 所属层的 `index.ts`(加入命名导出与注册表)。
|
|
338
|
+
顶层 `builtInComponents` 由三层合并,`@campus-admin/core` 会自动纳入全局注册表。
|
|
339
|
+
|
|
340
|
+
## 设计要求
|
|
341
|
+
|
|
342
|
+
- **组件不访问接口**。数据用 Props 传入,操作通过 Events 抛出。
|
|
343
|
+
- **不写死颜色**。任何颜色都必须来自 `--ca-*` Token,否则暗色主题与品牌换色会失效。
|
|
344
|
+
- 主色实心背景上的文字用 `--ca-color-primary-contrast`,保证浅色品牌色下仍可读。
|
|
345
|
+
- 所有 ID 使用字符串,避免后端大整数在 JavaScript 中丢失精度。
|
|
346
|
+
- 覆盖默认、Hover、Focus、Disabled、Loading、Empty、Error 等状态。
|
|
347
|
+
- 弹层类组件需处理 Esc 关闭、焦点锁定、关闭后焦点恢复。
|
|
348
|
+
- 组件卸载时清理事件、计时器、Observer。
|
|
349
|
+
|
|
350
|
+
## 相关包
|
|
351
|
+
|
|
352
|
+
| 包 | 关系 |
|
|
353
|
+
| --- | --- |
|
|
354
|
+
| [`@campus-admin/locale`](../locale) | 被本包依赖,组件通过它取词与格式化 |
|
|
355
|
+
| [`@campus-admin/core`](../core) | 依赖本包并统一出口 |
|
|
356
|
+
|
|
357
|
+
## 版权
|
|
358
|
+
|
|
359
|
+
使用本项目时请保留版权信息(MIT 许可要求随副本保留版权声明):
|
|
360
|
+
|
|
361
|
+
- 保留包内的 `LICENSE` 文件与版权声明;
|
|
362
|
+
- 保留页面页脚中的「Powered By 众校通 ®」与联系方式(示例用 `Copyright` 组件统一渲染);
|
|
363
|
+
- 二次分发或修改后的版本,请在显著位置保留同样的版权声明。
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
Powered By 众校通 ®
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AttendanceStatus } from './core';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
status?: AttendanceStatus | string;
|
|
4
|
+
/** 显示打卡时间等补充信息 */
|
|
5
|
+
time?: string;
|
|
6
|
+
size?: 'small' | 'medium';
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
9
|
+
status: AttendanceStatus | string;
|
|
10
|
+
size: "small" | "medium";
|
|
11
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type AttendanceStatus = 'normal' | 'late' | 'leave' | 'absent' | 'early' | 'unknown';
|
|
2
|
+
export interface AttendanceMeta {
|
|
3
|
+
/** 默认语言文案,组件不用它渲染,只作兜底 */
|
|
4
|
+
label: string;
|
|
5
|
+
/** 词条键:ca.attendance.<status> */
|
|
6
|
+
labelKey: string;
|
|
7
|
+
tone: 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'neutral';
|
|
8
|
+
}
|
|
9
|
+
export declare function attendanceMeta(status: AttendanceStatus | string): AttendanceMeta;
|
|
10
|
+
/** 班级维度汇总:用于“今日到校率”这类统计展示 */
|
|
11
|
+
export declare function attendanceRate(counts: Partial<Record<AttendanceStatus, number>>, total: number): number;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
/** 图片地址 */
|
|
3
|
+
src?: string;
|
|
4
|
+
/** 没有图片时展示的文字,通常取姓名首字 */
|
|
5
|
+
name?: string;
|
|
6
|
+
size?: 'small' | 'medium' | 'large';
|
|
7
|
+
shape?: 'circle' | 'square';
|
|
8
|
+
};
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
10
|
+
size: "small" | "medium" | "large";
|
|
11
|
+
shape: "circle" | "square";
|
|
12
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
|
+
declare const _default: typeof __VLS_export;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ComponentSize, ComponentTone } from '@/core/namespace';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** 语义色调 */
|
|
4
|
+
type?: ComponentTone;
|
|
5
|
+
/** 视觉形态:实心 / 描边 / 文字 */
|
|
6
|
+
variant?: 'solid' | 'outline' | 'text';
|
|
7
|
+
size?: ComponentSize;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
/** 占满父级宽度 */
|
|
11
|
+
block?: boolean;
|
|
12
|
+
/** 仅图标按钮,需要额外提供 aria-label */
|
|
13
|
+
iconOnly?: boolean;
|
|
14
|
+
/** 原生 button type */
|
|
15
|
+
nativeType?: 'button' | 'submit' | 'reset';
|
|
16
|
+
};
|
|
17
|
+
declare var __VLS_1: {}, __VLS_3: {};
|
|
18
|
+
type __VLS_Slots = {} & {
|
|
19
|
+
icon?: (props: typeof __VLS_1) => any;
|
|
20
|
+
} & {
|
|
21
|
+
default?: (props: typeof __VLS_3) => any;
|
|
22
|
+
};
|
|
23
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
24
|
+
click: (event: MouseEvent) => any;
|
|
25
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
26
|
+
onClick?: ((event: MouseEvent) => any) | undefined;
|
|
27
|
+
}>, {
|
|
28
|
+
size: ComponentSize;
|
|
29
|
+
type: ComponentTone;
|
|
30
|
+
variant: "solid" | "outline" | "text";
|
|
31
|
+
nativeType: "button" | "submit" | "reset";
|
|
32
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
33
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
34
|
+
declare const _default: typeof __VLS_export;
|
|
35
|
+
export default _default;
|
|
36
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
37
|
+
new (): {
|
|
38
|
+
$slots: S;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
modelValue?: boolean | 'indeterminate';
|
|
3
|
+
label?: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
};
|
|
6
|
+
declare var __VLS_11: {};
|
|
7
|
+
type __VLS_Slots = {} & {
|
|
8
|
+
default?: (props: typeof __VLS_11) => any;
|
|
9
|
+
};
|
|
10
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
11
|
+
"update:modelValue": (value: boolean) => any;
|
|
12
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
13
|
+
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
14
|
+
}>, {
|
|
15
|
+
modelValue: boolean | "indeterminate";
|
|
16
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
17
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
18
|
+
declare const _default: typeof __VLS_export;
|
|
19
|
+
export default _default;
|
|
20
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
21
|
+
new (): {
|
|
22
|
+
$slots: S;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Component } from 'vue';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Lucide 图标组件 */
|
|
4
|
+
icon?: Component;
|
|
5
|
+
/** 图标尺寸(px) */
|
|
6
|
+
size?: number;
|
|
7
|
+
/** 颜色,默认继承父级 currentColor */
|
|
8
|
+
color?: string;
|
|
9
|
+
/** 仅装饰用途时设为 true,屏幕阅读器会忽略 */
|
|
10
|
+
decorative?: boolean;
|
|
11
|
+
};
|
|
12
|
+
declare var __VLS_6: {};
|
|
13
|
+
type __VLS_Slots = {} & {
|
|
14
|
+
default?: (props: typeof __VLS_6) => any;
|
|
15
|
+
};
|
|
16
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
17
|
+
size: number;
|
|
18
|
+
decorative: boolean;
|
|
19
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
20
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
21
|
+
declare const _default: typeof __VLS_export;
|
|
22
|
+
export default _default;
|
|
23
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
24
|
+
new (): {
|
|
25
|
+
$slots: S;
|
|
26
|
+
};
|
|
27
|
+
};
|