@ysgroup/ui 0.1.60 → 0.1.62
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 +6 -6
- package/src/components/YsAppToolbar.vue +18 -9
- package/src/components/YsCalendar.vue +176 -15
- package/src/components/YsCalendarDayCard.vue +53 -4
- package/src/components/YsCardList.vue +247 -0
- package/src/components/YsCrudTable.vue +25 -1
- package/src/components/YsFilePreview.vue +3 -2
- package/src/components/YsPageHeader.vue +9 -3
- package/src/components/YsPageLayout.vue +237 -27
- package/src/components/YsRowActionMenu.vue +13 -0
- package/src/components/YsSettingsCenterDialog.vue +2 -1
- package/src/components/YsSideMenu.vue +13 -0
- package/src/components/YsTablePagination.vue +12 -1
- package/src/components/YsTableToolbar.vue +46 -1
- package/src/index.ts +12 -0
- package/src/viewport.ts +52 -0
|
@@ -281,6 +281,19 @@ function select(action: YsRowAction) {
|
|
|
281
281
|
margin: 3px 4px;
|
|
282
282
|
background: var(--ys-color-border);
|
|
283
283
|
}
|
|
284
|
+
/* 触屏:齿轮 40px 见方,菜单项 44px 高、14px 字,手指点得准。 */
|
|
285
|
+
@media (pointer: coarse) {
|
|
286
|
+
.ys-row-action__trigger {
|
|
287
|
+
width: 40px;
|
|
288
|
+
height: 40px;
|
|
289
|
+
}
|
|
290
|
+
.ys-row-action__item,
|
|
291
|
+
.ys-row-action__menu :deep(.ys-row-action-menu__item) {
|
|
292
|
+
min-height: 44px;
|
|
293
|
+
padding: 10px 12px;
|
|
294
|
+
font-size: 14px;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
284
297
|
:global(.ys-action-popover.el-popover.el-popper) {
|
|
285
298
|
padding: 7px;
|
|
286
299
|
border-color: color-mix(in srgb, var(--ys-color-primary) 18%, var(--ys-color-border));
|
|
@@ -287,7 +287,8 @@ defineExpose({
|
|
|
287
287
|
.ys-settings-dialog {
|
|
288
288
|
max-width: calc(100vw - 24px);
|
|
289
289
|
}
|
|
290
|
-
|
|
290
|
+
/* 手机:左侧页签改成顶部横排,内容占满宽度。 */
|
|
291
|
+
@media (max-width: 767px) {
|
|
291
292
|
.ys-settings-dialog .el-tabs--left {
|
|
292
293
|
display: flex;
|
|
293
294
|
flex-direction: column;
|
|
@@ -211,4 +211,17 @@ const emit = defineEmits<{ navigate: [key: string]; toggle: [key: string] }>();
|
|
|
211
211
|
.ys-side-menu__child.is-current .ys-side-menu__marker {
|
|
212
212
|
background: var(--ys-color-primary);
|
|
213
213
|
}
|
|
214
|
+
/* 手机(抽屉里):每行至少 44px、字号 15px,手指点得准;展开箭头也放大到 44px。 */
|
|
215
|
+
@media (max-width: 767px) {
|
|
216
|
+
.ys-side-menu__main,
|
|
217
|
+
.ys-side-menu__child {
|
|
218
|
+
min-height: 44px;
|
|
219
|
+
font-size: 15px;
|
|
220
|
+
}
|
|
221
|
+
.ys-side-menu__toggle {
|
|
222
|
+
width: 44px;
|
|
223
|
+
height: 44px;
|
|
224
|
+
margin-right: 0;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
214
227
|
</style>
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { useYsMobile } from "../viewport";
|
|
3
|
+
|
|
2
4
|
defineProps<{
|
|
3
5
|
total: number;
|
|
4
6
|
currentPage: number;
|
|
@@ -11,6 +13,8 @@ const emit = defineEmits<{
|
|
|
11
13
|
}>();
|
|
12
14
|
|
|
13
15
|
const PAGE_SIZES = [20, 50, 100];
|
|
16
|
+
/** 手机:不放每页条数,页码最多 5 个、按钮 32px,一行放得下「共 N 条 ‹ 1 2 3 4 5 ›」。 */
|
|
17
|
+
const mobile = useYsMobile();
|
|
14
18
|
|
|
15
19
|
function updatePageSize(value: number): void {
|
|
16
20
|
emit("update:pageSize", value);
|
|
@@ -25,8 +29,10 @@ function updatePageSize(value: number): void {
|
|
|
25
29
|
:page-size="pageSize"
|
|
26
30
|
:page-sizes="PAGE_SIZES"
|
|
27
31
|
:total="total"
|
|
28
|
-
layout="total, sizes, prev, pager, next"
|
|
32
|
+
:layout="mobile ? 'total, prev, pager, next' : 'total, sizes, prev, pager, next'"
|
|
33
|
+
:pager-count="mobile ? 5 : 7"
|
|
29
34
|
class="ys-table-pagination"
|
|
35
|
+
:class="{ 'is-mobile': mobile }"
|
|
30
36
|
@update:current-page="emit('update:currentPage', $event)"
|
|
31
37
|
@update:page-size="updatePageSize"
|
|
32
38
|
/>
|
|
@@ -37,4 +43,9 @@ function updatePageSize(value: number): void {
|
|
|
37
43
|
margin-top: 12px;
|
|
38
44
|
justify-content: flex-end;
|
|
39
45
|
}
|
|
46
|
+
.ys-table-pagination.is-mobile {
|
|
47
|
+
justify-content: center;
|
|
48
|
+
flex-wrap: wrap;
|
|
49
|
+
row-gap: 8px;
|
|
50
|
+
}
|
|
40
51
|
</style>
|
|
@@ -21,7 +21,7 @@ const emit = defineEmits<{
|
|
|
21
21
|
<!-- 检索区从左到右固定为:搜索框 → 下拉框 → 复选框;主操作放 #actions 在最右。 -->
|
|
22
22
|
<slot />
|
|
23
23
|
<div class="ys-table-toolbar__spacer" />
|
|
24
|
-
<slot name="actions"
|
|
24
|
+
<div v-if="$slots.actions" class="ys-table-toolbar__actions"><slot name="actions" /></div>
|
|
25
25
|
</div>
|
|
26
26
|
</template>
|
|
27
27
|
|
|
@@ -43,4 +43,49 @@ const emit = defineEmits<{
|
|
|
43
43
|
.ys-table-toolbar__spacer {
|
|
44
44
|
flex: 1;
|
|
45
45
|
}
|
|
46
|
+
.ys-table-toolbar__actions {
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-wrap: wrap;
|
|
49
|
+
align-items: center;
|
|
50
|
+
gap: 8px;
|
|
51
|
+
}
|
|
52
|
+
.ys-table-toolbar__actions :deep(.el-button + .el-button) {
|
|
53
|
+
margin-left: 0;
|
|
54
|
+
}
|
|
55
|
+
/*
|
|
56
|
+
* 手机:第一行是搜索框(占满剩余宽度)和主操作,下拉框两个一行、各占一半,勾选框排在最后自动换行。
|
|
57
|
+
* 业务页给下拉框写的固定宽度(如 width: 180px)在这里统一放开,不用每页再写一遍窄屏样式。
|
|
58
|
+
*/
|
|
59
|
+
@media (max-width: 767px) {
|
|
60
|
+
.ys-table-toolbar {
|
|
61
|
+
gap: 8px;
|
|
62
|
+
}
|
|
63
|
+
.ys-table-toolbar__search {
|
|
64
|
+
order: -2;
|
|
65
|
+
flex: 1 1 0;
|
|
66
|
+
width: auto;
|
|
67
|
+
min-width: 0;
|
|
68
|
+
}
|
|
69
|
+
.ys-table-toolbar__actions {
|
|
70
|
+
order: -1;
|
|
71
|
+
flex-wrap: nowrap;
|
|
72
|
+
}
|
|
73
|
+
.ys-table-toolbar__spacer {
|
|
74
|
+
display: none;
|
|
75
|
+
}
|
|
76
|
+
.ys-table-toolbar > :deep(.el-select),
|
|
77
|
+
.ys-table-toolbar > :deep(.ys-select),
|
|
78
|
+
.ys-table-toolbar > :deep(.el-tree-select),
|
|
79
|
+
.ys-table-toolbar > :deep(.el-date-editor),
|
|
80
|
+
.ys-table-toolbar > :deep(.el-input),
|
|
81
|
+
.ys-table-toolbar > :deep(.ys-segmented) {
|
|
82
|
+
flex: 1 1 calc(50% - 4px);
|
|
83
|
+
width: auto !important;
|
|
84
|
+
min-width: 0;
|
|
85
|
+
max-width: 100%;
|
|
86
|
+
}
|
|
87
|
+
.ys-table-toolbar :deep(.el-checkbox) {
|
|
88
|
+
height: 32px;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
46
91
|
</style>
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,18 @@ export type {
|
|
|
11
11
|
} from "./components/YsCalendar.vue";
|
|
12
12
|
export { default as YsCalendarDayCard } from "./components/YsCalendarDayCard.vue";
|
|
13
13
|
export { default as YsTablePagination } from "./components/YsTablePagination.vue";
|
|
14
|
+
export { default as YsCardList } from "./components/YsCardList.vue";
|
|
15
|
+
export type { YsCardField } from "./components/YsCardList.vue";
|
|
16
|
+
// 移动端断点:手机 ≤767px、窄屏 ≤1023px、触屏(不能悬停);CSS 和脚本用同一个断点。
|
|
17
|
+
export {
|
|
18
|
+
YS_MOBILE_QUERY,
|
|
19
|
+
YS_NARROW_QUERY,
|
|
20
|
+
YS_TOUCH_QUERY,
|
|
21
|
+
useYsMobile,
|
|
22
|
+
useYsNarrow,
|
|
23
|
+
useYsTouch,
|
|
24
|
+
ysIsMobile,
|
|
25
|
+
} from "./viewport";
|
|
14
26
|
export { default as YsRowActionMenu } from "./components/YsRowActionMenu.vue";
|
|
15
27
|
export type { YsRowAction } from "./components/YsRowActionMenu.vue";
|
|
16
28
|
export { default as YsFormDialog } from "./components/YsFormDialog.vue";
|
package/src/viewport.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 移动端断点:全平台只有一个,宽度不超过 767px 就是手机(竖屏手机、横屏小手机)。
|
|
3
|
+
* 768px 及以上(平板、桌面)仍是桌面布局;768~1023px 只把侧栏默认收起。
|
|
4
|
+
*
|
|
5
|
+
* - CSS 里写 `@media (max-width: 767px)`,脚本里用 useYsMobile(),两边是同一个断点,不另写 640、600、720 这类数字。
|
|
6
|
+
* - 「触屏」和「窄屏」是两回事:悬停才出现的内容看 YS_TOUCH_QUERY(没有悬停能力的设备),排版看 YS_MOBILE_QUERY。
|
|
7
|
+
* - 整个页面共用一个 matchMedia 监听,组件里随便调用,不会每次都新建监听。
|
|
8
|
+
*/
|
|
9
|
+
import { readonly, ref, type Ref } from "vue";
|
|
10
|
+
|
|
11
|
+
/** 手机:宽度不超过 767px。 */
|
|
12
|
+
export const YS_MOBILE_QUERY = "(max-width: 767px)";
|
|
13
|
+
/** 窄屏(手机和竖屏平板):宽度不超过 1023px,侧栏默认收起。 */
|
|
14
|
+
export const YS_NARROW_QUERY = "(max-width: 1023px)";
|
|
15
|
+
/** 触屏:主要指针不能悬停(手机、平板),悬停菜单改成点击打开。 */
|
|
16
|
+
export const YS_TOUCH_QUERY = "(hover: none)";
|
|
17
|
+
|
|
18
|
+
type Watched = { state: Ref<boolean>; list: MediaQueryList | null };
|
|
19
|
+
const cache = new Map<string, Watched>();
|
|
20
|
+
|
|
21
|
+
function watchQuery(query: string): Watched {
|
|
22
|
+
const found = cache.get(query);
|
|
23
|
+
if (found) return found;
|
|
24
|
+
const list = typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia(query) : null;
|
|
25
|
+
const state = ref(list?.matches ?? false);
|
|
26
|
+
list?.addEventListener?.("change", (event) => {
|
|
27
|
+
state.value = event.matches;
|
|
28
|
+
});
|
|
29
|
+
const watched = { state, list };
|
|
30
|
+
cache.set(query, watched);
|
|
31
|
+
return watched;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** 当前是不是手机(宽度不超过 767px),随窗口宽度变化。 */
|
|
35
|
+
export function useYsMobile(): Readonly<Ref<boolean>> {
|
|
36
|
+
return readonly(watchQuery(YS_MOBILE_QUERY).state);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** 当前是不是窄屏(宽度不超过 1023px),侧栏据此默认收起。 */
|
|
40
|
+
export function useYsNarrow(): Readonly<Ref<boolean>> {
|
|
41
|
+
return readonly(watchQuery(YS_NARROW_QUERY).state);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** 当前主要指针能不能悬停;不能悬停(触屏)时悬停才出现的菜单要改成点击。 */
|
|
45
|
+
export function useYsTouch(): Readonly<Ref<boolean>> {
|
|
46
|
+
return readonly(watchQuery(YS_TOUCH_QUERY).state);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** 不在组件里时直接读一次(如路由守卫)。 */
|
|
50
|
+
export function ysIsMobile(): boolean {
|
|
51
|
+
return watchQuery(YS_MOBILE_QUERY).state.value;
|
|
52
|
+
}
|