@ysgroup/ui 0.1.13 → 0.1.15

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.13",
3
+ "version": "0.1.15",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -79,7 +79,6 @@ const dialogOpen = ref(false);
79
79
  const editing = ref<Record<string, unknown> | null>(null);
80
80
  const currentPage = ref(1);
81
81
  const pageSize = ref(20);
82
- const PAGE_SIZES = [20, 50, 100];
83
82
 
84
83
  const allSpecs = computed<FieldSpec[]>(() => (FIELD_SPECS as unknown as Record<string, FieldSpec[]>)[props.table] ?? []);
85
84
 
@@ -122,8 +121,6 @@ const paged = computed(() => {
122
121
  return filtered.value.slice(start, start + pageSize.value);
123
122
  });
124
123
 
125
- const showPagination = computed(() => filtered.value.length > 20);
126
-
127
124
  function display(row: Record<string, unknown>, f: FieldSpec): string {
128
125
  const v = props.rowDisplay ? props.rowDisplay(row, f.key, row[f.key]) : row[f.key];
129
126
  if (f.widget === "switch") return v ? "是" : "否";
@@ -187,15 +184,10 @@ function onSubmit(payload: Record<string, unknown>) {
187
184
  </el-table-column>
188
185
  </el-table>
189
186
 
190
- <el-pagination
191
- v-if="showPagination"
187
+ <YsTablePagination
192
188
  v-model:current-page="currentPage"
193
189
  v-model:page-size="pageSize"
194
- :page-sizes="PAGE_SIZES"
195
190
  :total="filtered.length"
196
- layout="total, sizes, prev, pager, next"
197
- class="ys-crud__pagination"
198
- @size-change="currentPage = 1"
199
191
  />
200
192
 
201
193
  <YsFormDialog v-if="!externalEditor" v-model="dialogOpen" :table="table" :record="editing" :hidden="hiddenInForm" :saving="saving" @submit="onSubmit" />
@@ -211,8 +203,4 @@ function onSubmit(payload: Record<string, unknown>) {
211
203
  .ys-crud__spacer {
212
204
  flex: 1;
213
205
  }
214
- .ys-crud__pagination {
215
- margin-top: 12px;
216
- justify-content: flex-end;
217
- }
218
206
  </style>
@@ -4,6 +4,7 @@ import { computed, reactive, ref, watch } from "vue";
4
4
 
5
5
  const props = defineProps<{
6
6
  modelValue: boolean;
7
+ authenticated: boolean;
7
8
  role?: string;
8
9
  username?: string;
9
10
  passwordManagementUrl?: string;
@@ -21,12 +22,10 @@ const submitting = ref(false);
21
22
  const PASSWORD_REQUIREMENT = "密码须至少包含 8 个字符,并同时包含大写字母、小写字母和数字。";
22
23
 
23
24
  const canChangePassword = computed(() => props.role !== "Root" && props.username?.trim().toLowerCase() !== "root");
25
+ const visible = computed(() => props.modelValue && props.authenticated);
24
26
 
25
27
  function isStrongPassword(password: string): boolean {
26
- return password.length >= 8
27
- && /[A-Z]/.test(password)
28
- && /[a-z]/.test(password)
29
- && /\d/.test(password);
28
+ return password.length >= 8 && /[A-Z]/.test(password) && /[a-z]/.test(password) && /\d/.test(password);
30
29
  }
31
30
 
32
31
  function reset() {
@@ -38,12 +37,16 @@ function reset() {
38
37
  }
39
38
 
40
39
  watch(
41
- () => props.modelValue,
42
- (open) => {
43
- if (!open) reset();
40
+ () => props.authenticated,
41
+ (authenticated) => {
42
+ if (!authenticated && props.modelValue) emit("update:modelValue", false);
44
43
  },
45
44
  );
46
45
 
46
+ watch(visible, (open) => {
47
+ if (!open) reset();
48
+ });
49
+
47
50
  function close() {
48
51
  if (submitting.value) return;
49
52
  emit("update:modelValue", false);
@@ -82,14 +85,14 @@ defineExpose({
82
85
 
83
86
  <template>
84
87
  <el-dialog
85
- :model-value="modelValue"
88
+ :model-value="visible"
86
89
  title="设置中心"
87
90
  width="560px"
88
91
  destroy-on-close
89
92
  :close-on-click-modal="!submitting"
90
93
  :close-on-press-escape="!submitting"
91
94
  :show-close="!submitting"
92
- @update:model-value="emit('update:modelValue', $event)"
95
+ @update:model-value="emit('update:modelValue', $event && authenticated)"
93
96
  >
94
97
  <el-tabs v-model="active" tab-position="left" class="ys-settings">
95
98
  <el-tab-pane label="账号安全" name="security">
@@ -0,0 +1,40 @@
1
+ <script setup lang="ts">
2
+ defineProps<{
3
+ total: number;
4
+ currentPage: number;
5
+ pageSize: number;
6
+ }>();
7
+
8
+ const emit = defineEmits<{
9
+ "update:currentPage": [value: number];
10
+ "update:pageSize": [value: number];
11
+ }>();
12
+
13
+ const PAGE_SIZES = [20, 50, 100];
14
+
15
+ function updatePageSize(value: number): void {
16
+ emit("update:pageSize", value);
17
+ emit("update:currentPage", 1);
18
+ }
19
+ </script>
20
+
21
+ <template>
22
+ <el-pagination
23
+ v-if="total > 20"
24
+ :current-page="currentPage"
25
+ :page-size="pageSize"
26
+ :page-sizes="PAGE_SIZES"
27
+ :total="total"
28
+ layout="total, sizes, prev, pager, next"
29
+ class="ys-table-pagination"
30
+ @update:current-page="emit('update:currentPage', $event)"
31
+ @update:page-size="updatePageSize"
32
+ />
33
+ </template>
34
+
35
+ <style scoped>
36
+ .ys-table-pagination {
37
+ margin-top: 12px;
38
+ justify-content: flex-end;
39
+ }
40
+ </style>
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /* @ysgroup/ui —— 平台组件库(基于 Element Plus 封装,令牌来自 @ysgroup/theme)。 */
2
2
 
3
3
  export { default as YsCrudTable } from "./components/YsCrudTable.vue";
4
+ export { default as YsTablePagination } from "./components/YsTablePagination.vue";
4
5
  export { default as YsRowActionMenu } from "./components/YsRowActionMenu.vue";
5
6
  export type { YsRowAction } from "./components/YsRowActionMenu.vue";
6
7
  export { default as YsFormDialog } from "./components/YsFormDialog.vue";