@ysgroup/ui 0.1.33 → 0.1.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ysgroup/ui",
3
- "version": "0.1.33",
3
+ "version": "0.1.35",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -38,58 +38,20 @@ function submit() {
38
38
  <img v-if="logoUrl" :src="logoUrl" class="ys-login__logo" alt="logo" />
39
39
  <p v-if="hint" class="ys-login__hint">{{ hint }}</p>
40
40
  <h2 v-else class="ys-login__title">{{ appTitle }}</h2>
41
- <div
42
- v-if="restoring"
43
- class="ys-login__pending"
44
- role="status"
45
- aria-live="polite"
46
- aria-busy="true"
47
- >
41
+ <div v-if="restoring" class="ys-login__pending" role="status" aria-live="polite" aria-busy="true">
48
42
  <el-icon class="is-loading" :size="20"><Loading /></el-icon>
49
43
  <span>正在安全进入{{ appTitle }}</span>
50
44
  </div>
51
45
  <template v-else>
52
- <el-form
53
- :disabled="loading"
54
- :aria-busy="!!loading"
55
- @submit.prevent="submit"
56
- >
46
+ <el-form :disabled="loading" :aria-busy="!!loading" @submit.prevent="submit">
57
47
  <el-form-item>
58
- <el-input
59
- v-model="username"
60
- placeholder="用户名"
61
- aria-label="用户名"
62
- autocomplete="username"
63
- size="large"
64
- />
48
+ <el-input v-model="username" placeholder="用户名" aria-label="用户名" autocomplete="username" size="large" />
65
49
  </el-form-item>
66
50
  <el-form-item>
67
- <el-input
68
- v-model="password"
69
- type="password"
70
- placeholder="密码"
71
- aria-label="密码"
72
- autocomplete="current-password"
73
- size="large"
74
- show-password
75
- />
51
+ <el-input v-model="password" type="password" placeholder="密码" aria-label="密码" autocomplete="current-password" size="large" show-password />
76
52
  </el-form-item>
77
- <el-alert
78
- v-if="validationError || error"
79
- :title="validationError || error || ''"
80
- type="error"
81
- :closable="false"
82
- show-icon
83
- />
84
- <el-button
85
- type="primary"
86
- size="large"
87
- native-type="submit"
88
- :loading="loading"
89
- class="ys-login__submit"
90
- >
91
- 登录
92
- </el-button>
53
+ <el-alert v-if="validationError || error" :title="validationError || error || ''" type="error" :closable="false" show-icon />
54
+ <el-button type="primary" size="large" native-type="submit" :loading="loading" class="ys-login__submit"> 登录 </el-button>
93
55
  </el-form>
94
56
  </template>
95
57
  </div>
@@ -1,12 +1,19 @@
1
1
  <script setup lang="ts">
2
2
  import { CaretBottom, CaretRight } from "@element-plus/icons-vue";
3
3
 
4
- export type YsSideMenuChild = { key: string; title: string };
4
+ export type YsSideMenuChild = { key: string; title: string; badge?: number };
5
5
  export type YsSideMenuItem = {
6
6
  key: string;
7
7
  title: string;
8
+ badge?: number;
8
9
  children?: YsSideMenuChild[];
9
10
  };
11
+
12
+ function badgeText(count: number | undefined): string {
13
+ const value = Number(count || 0);
14
+ if (value <= 0) return "";
15
+ return value > 99 ? "99+" : String(value);
16
+ }
10
17
  defineProps<{ items: YsSideMenuItem[]; active: string; openKeys: string[] }>();
11
18
  const emit = defineEmits<{ navigate: [key: string]; toggle: [key: string] }>();
12
19
  </script>
@@ -30,9 +37,20 @@ const emit = defineEmits<{ navigate: [key: string]; toggle: [key: string] }>();
30
37
  :aria-current="
31
38
  !item.children?.length && item.key === active ? 'page' : undefined
32
39
  "
40
+ :aria-label="
41
+ badgeText(item.badge)
42
+ ? `${item.title},${item.badge} 条待处理`
43
+ : item.title
44
+ "
33
45
  @click="emit('navigate', item.key)"
34
46
  >
35
- {{ item.title }}
47
+ <span class="ys-side-menu__label">{{ item.title }}</span>
48
+ <span
49
+ v-if="badgeText(item.badge)"
50
+ class="ys-side-menu__badge"
51
+ aria-hidden="true"
52
+ >{{ badgeText(item.badge) }}</span
53
+ >
36
54
  </button>
37
55
  <button
38
56
  v-if="item.children?.length"
@@ -61,9 +79,14 @@ const emit = defineEmits<{ navigate: [key: string]; toggle: [key: string] }>();
61
79
  :aria-current="child.key === active ? 'page' : undefined"
62
80
  @click="emit('navigate', child.key)"
63
81
  >
64
- <span class="ys-side-menu__marker" aria-hidden="true" />{{
65
- child.title
66
- }}
82
+ <span class="ys-side-menu__marker" aria-hidden="true" />
83
+ <span class="ys-side-menu__label">{{ child.title }}</span>
84
+ <span
85
+ v-if="badgeText(child.badge)"
86
+ class="ys-side-menu__badge"
87
+ aria-hidden="true"
88
+ >{{ badgeText(child.badge) }}</span
89
+ >
67
90
  </button>
68
91
  </div>
69
92
  </div>
@@ -100,13 +123,41 @@ const emit = defineEmits<{ navigate: [key: string]; toggle: [key: string] }>();
100
123
  cursor: pointer;
101
124
  }
102
125
  .ys-side-menu__main {
126
+ display: flex;
127
+ align-items: center;
128
+ justify-content: space-between;
129
+ gap: 8px;
103
130
  flex: 1;
104
131
  min-width: 0;
105
- padding: 9px 4px 9px 14px;
132
+ padding: 9px 12px 9px 14px;
106
133
  border-radius: var(--ys-radius-m);
107
134
  color: var(--ys-color-text-2);
108
135
  text-align: left;
109
136
  }
137
+ .ys-side-menu__label {
138
+ min-width: 0;
139
+ overflow: hidden;
140
+ text-overflow: ellipsis;
141
+ white-space: nowrap;
142
+ }
143
+ .ys-side-menu__badge {
144
+ flex: none;
145
+ min-width: 20px;
146
+ height: 20px;
147
+ box-sizing: border-box;
148
+ padding: 0 5px;
149
+ border-radius: 10px;
150
+ background: var(--ys-color-danger);
151
+ color: var(--ys-color-bg-elevated);
152
+ font-size: 11px;
153
+ font-weight: 600;
154
+ line-height: 20px;
155
+ text-align: center;
156
+ }
157
+ .ys-side-menu__row.is-current .ys-side-menu__badge {
158
+ background: var(--ys-color-bg-elevated);
159
+ color: var(--ys-color-primary);
160
+ }
110
161
  .ys-side-menu__row.is-current .ys-side-menu__main {
111
162
  color: var(--ys-color-bg-elevated);
112
163
  font-weight: 600;
@@ -151,6 +202,7 @@ const emit = defineEmits<{ navigate: [key: string]; toggle: [key: string] }>();
151
202
  .ys-side-menu__child {
152
203
  display: flex;
153
204
  align-items: center;
205
+ justify-content: space-between;
154
206
  gap: 8px;
155
207
  width: 100%;
156
208
  padding: 7px 12px 7px 8px;
@@ -158,6 +210,10 @@ const emit = defineEmits<{ navigate: [key: string]; toggle: [key: string] }>();
158
210
  color: var(--ys-color-text-2);
159
211
  text-align: left;
160
212
  }
213
+ .ys-side-menu__child.is-current .ys-side-menu__badge {
214
+ background: var(--ys-color-primary);
215
+ color: var(--ys-color-bg-elevated);
216
+ }
161
217
  .ys-side-menu__child:hover {
162
218
  background: var(--ys-color-bg-hover);
163
219
  color: var(--ys-color-text-1);