@ysgroup/ui 0.1.62 → 0.1.64
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 +3 -3
- package/src/components/YsCalendar.vue +16 -20
- package/src/components/YsCalendarDayCard.vue +6 -6
- package/src/components/YsHandleTag.vue +43 -0
- package/src/index.ts +12 -0
- package/src/pendingNotice.ts +133 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ysgroup/ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.64",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@ysgroup/contracts": "^0.1.
|
|
29
|
-
"@ysgroup/core": "^0.1.
|
|
28
|
+
"@ysgroup/contracts": "^0.1.55",
|
|
29
|
+
"@ysgroup/core": "^0.1.35",
|
|
30
30
|
"@ysgroup/theme": "^0.3.4",
|
|
31
31
|
"docx-preview": "^0.4.1"
|
|
32
32
|
}
|
|
@@ -722,22 +722,22 @@ function goToday() {
|
|
|
722
722
|
/* 底色:不支持相对颜色的浏览器用混色兜底 */
|
|
723
723
|
--cal-open-bg: color-mix(
|
|
724
724
|
in srgb,
|
|
725
|
-
var(--ys-color-success)
|
|
725
|
+
var(--ys-color-success) 12%,
|
|
726
726
|
var(--ys-color-bg-elevated)
|
|
727
727
|
);
|
|
728
728
|
--cal-open-hover: color-mix(
|
|
729
729
|
in srgb,
|
|
730
|
-
var(--ys-color-success)
|
|
730
|
+
var(--ys-color-success) 18%,
|
|
731
731
|
var(--ys-color-bg-elevated)
|
|
732
732
|
);
|
|
733
733
|
--cal-holiday-bg: color-mix(
|
|
734
734
|
in srgb,
|
|
735
|
-
var(--ys-color-warning)
|
|
735
|
+
var(--ys-color-warning) 12%,
|
|
736
736
|
var(--ys-color-bg-elevated)
|
|
737
737
|
);
|
|
738
738
|
--cal-holiday-hover: color-mix(
|
|
739
739
|
in srgb,
|
|
740
|
-
var(--ys-color-warning)
|
|
740
|
+
var(--ys-color-warning) 18%,
|
|
741
741
|
var(--ys-color-bg-elevated)
|
|
742
742
|
);
|
|
743
743
|
display: flex;
|
|
@@ -745,19 +745,19 @@ function goToday() {
|
|
|
745
745
|
gap: 8px;
|
|
746
746
|
min-width: 0;
|
|
747
747
|
}
|
|
748
|
-
/*
|
|
748
|
+
/* 支持相对颜色时,底色固定亮度和饱和度:和休息日(白底/深底)一眼分得开的绿和橙,饱和度仍克制、不刺眼 */
|
|
749
749
|
@supports (color: oklch(from red l c h)) {
|
|
750
750
|
.ys-calendar {
|
|
751
|
-
--cal-open-bg: oklch(from var(--ys-color-success) 0.
|
|
752
|
-
--cal-open-hover: oklch(from var(--ys-color-success) 0.
|
|
753
|
-
--cal-holiday-bg: oklch(from var(--ys-color-warning) 0.
|
|
754
|
-
--cal-holiday-hover: oklch(from var(--ys-color-warning) 0.
|
|
751
|
+
--cal-open-bg: oklch(from var(--ys-color-success) 0.952 0.05 h);
|
|
752
|
+
--cal-open-hover: oklch(from var(--ys-color-success) 0.926 0.068 h);
|
|
753
|
+
--cal-holiday-bg: oklch(from var(--ys-color-warning) 0.955 0.045 h);
|
|
754
|
+
--cal-holiday-hover: oklch(from var(--ys-color-warning) 0.93 0.062 h);
|
|
755
755
|
}
|
|
756
756
|
html[data-theme="dark"] .ys-calendar {
|
|
757
|
-
--cal-open-bg: oklch(from var(--ys-color-success) 0.
|
|
758
|
-
--cal-open-hover: oklch(from var(--ys-color-success) 0.
|
|
759
|
-
--cal-holiday-bg: oklch(from var(--ys-color-warning) 0.
|
|
760
|
-
--cal-holiday-hover: oklch(from var(--ys-color-warning) 0.
|
|
757
|
+
--cal-open-bg: oklch(from var(--ys-color-success) 0.31 0.07 h);
|
|
758
|
+
--cal-open-hover: oklch(from var(--ys-color-success) 0.35 0.085 h);
|
|
759
|
+
--cal-holiday-bg: oklch(from var(--ys-color-warning) 0.31 0.06 h);
|
|
760
|
+
--cal-holiday-hover: oklch(from var(--ys-color-warning) 0.35 0.075 h);
|
|
761
761
|
}
|
|
762
762
|
}
|
|
763
763
|
.ys-calendar__head {
|
|
@@ -777,12 +777,8 @@ function goToday() {
|
|
|
777
777
|
font-size: 18px;
|
|
778
778
|
}
|
|
779
779
|
.ys-calendar__nav :deep(.el-date-editor.ys-calendar__month) {
|
|
780
|
-
width:
|
|
781
|
-
|
|
782
|
-
.ys-calendar.is-small
|
|
783
|
-
.ys-calendar__nav
|
|
784
|
-
:deep(.el-date-editor.ys-calendar__month) {
|
|
785
|
-
width: 112px;
|
|
780
|
+
width: 144px;
|
|
781
|
+
min-width: 128px;
|
|
786
782
|
}
|
|
787
783
|
.ys-calendar__summary {
|
|
788
784
|
display: flex;
|
|
@@ -1261,7 +1257,7 @@ function goToday() {
|
|
|
1261
1257
|
flex: 1 1 100%;
|
|
1262
1258
|
}
|
|
1263
1259
|
.ys-calendar.is-mobile .ys-calendar__nav :deep(.el-date-editor.ys-calendar__month) {
|
|
1264
|
-
flex: 1;
|
|
1260
|
+
flex: 1 0 128px;
|
|
1265
1261
|
width: auto;
|
|
1266
1262
|
}
|
|
1267
1263
|
.ys-calendar.is-mobile .ys-calendar__arrow {
|
|
@@ -339,12 +339,12 @@ const dayEvents = computed(() =>
|
|
|
339
339
|
);
|
|
340
340
|
--open-bg: color-mix(
|
|
341
341
|
in srgb,
|
|
342
|
-
var(--ys-color-success)
|
|
342
|
+
var(--ys-color-success) 12%,
|
|
343
343
|
var(--ys-color-bg-elevated)
|
|
344
344
|
);
|
|
345
345
|
--holiday-bg: color-mix(
|
|
346
346
|
in srgb,
|
|
347
|
-
var(--ys-color-warning)
|
|
347
|
+
var(--ys-color-warning) 12%,
|
|
348
348
|
var(--ys-color-bg-elevated)
|
|
349
349
|
);
|
|
350
350
|
display: flex;
|
|
@@ -358,12 +358,12 @@ const dayEvents = computed(() =>
|
|
|
358
358
|
/* 和月历同一套底色:固定亮度和饱和度,不发灰也不刺眼 */
|
|
359
359
|
@supports (color: oklch(from red l c h)) {
|
|
360
360
|
.ys-day-card {
|
|
361
|
-
--open-bg: oklch(from var(--ys-color-success) 0.
|
|
362
|
-
--holiday-bg: oklch(from var(--ys-color-warning) 0.
|
|
361
|
+
--open-bg: oklch(from var(--ys-color-success) 0.952 0.05 h);
|
|
362
|
+
--holiday-bg: oklch(from var(--ys-color-warning) 0.955 0.045 h);
|
|
363
363
|
}
|
|
364
364
|
html[data-theme="dark"] .ys-day-card {
|
|
365
|
-
--open-bg: oklch(from var(--ys-color-success) 0.
|
|
366
|
-
--holiday-bg: oklch(from var(--ys-color-warning) 0.
|
|
365
|
+
--open-bg: oklch(from var(--ys-color-success) 0.31 0.07 h);
|
|
366
|
+
--holiday-bg: oklch(from var(--ys-color-warning) 0.31 0.06 h);
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
369
|
.ys-day-card.is-workday,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* 处理状态标签:消息的「处理状态」与未读、已读互相独立。
|
|
4
|
+
* - pending 待处理:红色,计入数字角标;
|
|
5
|
+
* - done 已处理:灰色,不必再关注;
|
|
6
|
+
* - none 纯通知:不显示,只有未读、已读。
|
|
7
|
+
*/
|
|
8
|
+
import { computed } from "vue";
|
|
9
|
+
|
|
10
|
+
export type YsHandleState = "none" | "pending" | "done";
|
|
11
|
+
|
|
12
|
+
const props = withDefaults(defineProps<{ state?: YsHandleState | string | null }>(), { state: "none" });
|
|
13
|
+
|
|
14
|
+
const label = computed(() => (props.state === "pending" ? "待处理" : props.state === "done" ? "已处理" : ""));
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<span v-if="label" class="ys-handle-tag" :class="`is-${state}`">{{ label }}</span>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<style scoped>
|
|
22
|
+
.ys-handle-tag {
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
flex: none;
|
|
25
|
+
align-items: center;
|
|
26
|
+
padding: 0 6px;
|
|
27
|
+
border: 1px solid transparent;
|
|
28
|
+
border-radius: var(--ys-radius-s);
|
|
29
|
+
font-size: 12px;
|
|
30
|
+
font-weight: 600;
|
|
31
|
+
line-height: 18px;
|
|
32
|
+
white-space: nowrap;
|
|
33
|
+
}
|
|
34
|
+
.ys-handle-tag.is-pending {
|
|
35
|
+
border-color: color-mix(in srgb, var(--ys-color-danger) 45%, transparent);
|
|
36
|
+
color: var(--ys-color-danger);
|
|
37
|
+
background: color-mix(in srgb, var(--ys-color-danger) 10%, transparent);
|
|
38
|
+
}
|
|
39
|
+
.ys-handle-tag.is-done {
|
|
40
|
+
color: var(--ys-color-text-3);
|
|
41
|
+
background: color-mix(in srgb, var(--ys-color-text-3) 12%, transparent);
|
|
42
|
+
}
|
|
43
|
+
</style>
|
package/src/index.ts
CHANGED
|
@@ -56,6 +56,18 @@ export { ysMultiItems, ysMultiText, YS_MULTI_SEPARATOR } from "./multiValue";
|
|
|
56
56
|
export { default as YsBoolMark } from "./components/YsBoolMark.vue";
|
|
57
57
|
export { default as YsSegmented } from "./components/YsSegmented.vue";
|
|
58
58
|
export { default as YsCountBadge } from "./components/YsCountBadge.vue";
|
|
59
|
+
export { default as YsHandleTag } from "./components/YsHandleTag.vue";
|
|
60
|
+
export type { YsHandleState } from "./components/YsHandleTag.vue";
|
|
61
|
+
export {
|
|
62
|
+
groupYsPendingNotices,
|
|
63
|
+
queueYsPending,
|
|
64
|
+
setYsPendingPopup,
|
|
65
|
+
showYsPending,
|
|
66
|
+
ysPendingLoginSummary,
|
|
67
|
+
ysPendingPopupOn,
|
|
68
|
+
ysTopNotification,
|
|
69
|
+
} from "./pendingNotice";
|
|
70
|
+
export type { YsPendingNotice } from "./pendingNotice";
|
|
59
71
|
export { default as YsFilePreview } from "./components/YsFilePreview.vue";
|
|
60
72
|
// 文件规范:上传队列、拖入与粘贴、文件标签(服务端规则在 ys_base.media)。
|
|
61
73
|
export { default as YsFileNotes } from "./components/YsFileNotes.vue";
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 右上角待处理提示(全平台统一,来自 Auth 的 todo_notice 做法):
|
|
3
|
+
* - 服务端只推标题、摘要和跳转链接,不带敏感正文;
|
|
4
|
+
* - 1.5 秒内到达的同类提示合成一张(groupYsPendingNotices,纯函数);
|
|
5
|
+
* - 同一账号开了几个标签页时,只在正在看的那个弹(BroadcastChannel 认领);
|
|
6
|
+
* - 带「去处理」「稍后」;警示图标用 --ys-color-attention(橙黄),不用 warning(偏棕黄);
|
|
7
|
+
* - 「新事项弹出提示」开关存本机浏览器,各系统的设置页调用 setYsPendingPopup。
|
|
8
|
+
*/
|
|
9
|
+
import { h, ref } from "vue";
|
|
10
|
+
import { ElButton, ElNotification, type NotificationOptions } from "element-plus";
|
|
11
|
+
|
|
12
|
+
/** 由公共外壳提供实际顶栏位置,兼容移动端安全区。 */
|
|
13
|
+
export function ysTopNotification(options: NotificationOptions) {
|
|
14
|
+
const top = typeof document === "undefined" ? 0 : (document.querySelector(".ys-layout__top")?.getBoundingClientRect().bottom ?? 0);
|
|
15
|
+
return ElNotification({ ...options, position: "top-right", offset: Math.max(0, Math.ceil(top)) });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface YsPendingNotice {
|
|
19
|
+
kind: string;
|
|
20
|
+
title: string;
|
|
21
|
+
summary?: string;
|
|
22
|
+
link: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const STORAGE_KEY = "ys-pending-popup";
|
|
26
|
+
const MERGE_MS = 1500;
|
|
27
|
+
const CLAIM_MS = 5000;
|
|
28
|
+
|
|
29
|
+
function readOn(): boolean {
|
|
30
|
+
try {
|
|
31
|
+
return localStorage.getItem(STORAGE_KEY) !== "off";
|
|
32
|
+
} catch {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** 是否弹出待处理提示(本机浏览器设置,默认开)。 */
|
|
38
|
+
export const ysPendingPopupOn = ref(readOn());
|
|
39
|
+
|
|
40
|
+
export function setYsPendingPopup(on: boolean): void {
|
|
41
|
+
ysPendingPopupOn.value = on;
|
|
42
|
+
try {
|
|
43
|
+
localStorage.setItem(STORAGE_KEY, on ? "on" : "off");
|
|
44
|
+
} catch {
|
|
45
|
+
/* 存不下不影响本次使用 */
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** 短时间内到达的提示按 kind 分组:一组只有一条原样弹,多条合成「标题等 N 件」。 */
|
|
50
|
+
export function groupYsPendingNotices(items: YsPendingNotice[]): YsPendingNotice[] {
|
|
51
|
+
const groups = new Map<string, YsPendingNotice[]>();
|
|
52
|
+
for (const item of items) {
|
|
53
|
+
const list = groups.get(item.kind) ?? [];
|
|
54
|
+
list.push(item);
|
|
55
|
+
groups.set(item.kind, list);
|
|
56
|
+
}
|
|
57
|
+
return [...groups.values()].map((list) => {
|
|
58
|
+
const first = list[0]!;
|
|
59
|
+
if (list.length === 1) return first;
|
|
60
|
+
return { kind: first.kind, title: `${first.title}等 ${list.length} 件`, summary: "点「去处理」一并查看", link: first.link };
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const channel = typeof BroadcastChannel === "undefined" ? null : new BroadcastChannel("ys-pending-notice");
|
|
65
|
+
const claimed = new Map<string, number>();
|
|
66
|
+
channel?.addEventListener("message", (event) => {
|
|
67
|
+
const key = String((event.data as { key?: string })?.key ?? "");
|
|
68
|
+
if (key) claimed.set(key, Date.now());
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
function claim(key: string): boolean {
|
|
72
|
+
const at = claimed.get(key);
|
|
73
|
+
if (at && Date.now() - at < CLAIM_MS) return false;
|
|
74
|
+
claimed.set(key, Date.now());
|
|
75
|
+
channel?.postMessage({ key });
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function warnIcon() {
|
|
80
|
+
return h("svg", { viewBox: "0 0 24 24", width: 20, height: 20, "aria-hidden": "true", style: "color: var(--ys-color-attention)" }, [
|
|
81
|
+
h("path", { fill: "currentColor", d: "M12 2 1 21h22L12 2zm1 15h-2v-2h2v2zm0-4h-2V9h2v4z" }),
|
|
82
|
+
]);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** 立即弹一张;页面不在前台、开关关闭、或别的标签页已经弹了就不弹。go 由各系统传入(通常是 router.push)。 */
|
|
86
|
+
export function showYsPending(go: (link: string) => void, notice: YsPendingNotice): void {
|
|
87
|
+
if (!ysPendingPopupOn.value || document.visibilityState !== "visible") return;
|
|
88
|
+
if (!claim(`${notice.kind}:${notice.title}:${notice.summary ?? ""}`)) return;
|
|
89
|
+
const card = ysTopNotification({
|
|
90
|
+
customClass: "ys-pending-notice",
|
|
91
|
+
icon: warnIcon,
|
|
92
|
+
title: notice.title,
|
|
93
|
+
duration: 0,
|
|
94
|
+
message: h("div", [
|
|
95
|
+
notice.summary ? h("p", { style: "margin: 0 0 8px" }, notice.summary) : null,
|
|
96
|
+
h("div", { style: "display: flex; gap: 8px" }, [
|
|
97
|
+
h(
|
|
98
|
+
ElButton,
|
|
99
|
+
{
|
|
100
|
+
type: "primary",
|
|
101
|
+
size: "small",
|
|
102
|
+
onClick: () => {
|
|
103
|
+
card.close();
|
|
104
|
+
go(notice.link);
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
() => "去处理",
|
|
108
|
+
),
|
|
109
|
+
h(ElButton, { size: "small", onClick: () => card.close() }, () => "稍后"),
|
|
110
|
+
]),
|
|
111
|
+
]),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
let buffer: YsPendingNotice[] = [];
|
|
116
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
117
|
+
|
|
118
|
+
/** 收到一条提示:攒 1.5 秒再弹,期间同类的合成一张。 */
|
|
119
|
+
export function queueYsPending(go: (link: string) => void, notice: YsPendingNotice): void {
|
|
120
|
+
buffer.push(notice);
|
|
121
|
+
clearTimeout(timer);
|
|
122
|
+
timer = setTimeout(() => {
|
|
123
|
+
const items = groupYsPendingNotices(buffer);
|
|
124
|
+
buffer = [];
|
|
125
|
+
items.forEach((item) => showYsPending(go, item));
|
|
126
|
+
}, MERGE_MS);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** 登录后汇总一次:有待处理时返回一张汇总卡片,没有返回 null。 */
|
|
130
|
+
export function ysPendingLoginSummary(count: number, link: string): YsPendingNotice | null {
|
|
131
|
+
if (!Number.isFinite(count) || count <= 0) return null;
|
|
132
|
+
return { kind: "login", title: `你有 ${count} 件待处理的事`, summary: "点「去处理」查看", link };
|
|
133
|
+
}
|