vite-plugin-refresh-guard 0.2.2 → 0.3.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/CHANGELOG.md +13 -0
- package/README.en.md +63 -9
- package/README.md +63 -4
- package/SKILL.md +2 -1
- package/dist/{chunk-ULA5FWKW.js → chunk-CGDGH2ML.js} +35 -2
- package/dist/chunk-JLHX4WLS.js +67 -0
- package/dist/client.d.ts +8 -0
- package/dist/core/changelog.d.ts +34 -0
- package/dist/core/checker.d.ts +12 -1
- package/dist/core/types.d.ts +60 -2
- package/dist/index.d.ts +20 -11
- package/dist/index.js +29 -10
- package/dist/react/UpdateCard.d.ts +8 -0
- package/dist/react/UpdateCard.js +275 -0
- package/dist/react/useVersionCheck.d.ts +6 -2
- package/dist/react/useVersionCheck.js +16 -1
- package/dist/vue/UpdateCard.vue +356 -0
- package/dist/vue/useVersionCheck.d.ts +6 -2
- package/dist/vue/useVersionCheck.js +16 -1
- package/package.json +7 -2
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractBulletPoints
|
|
3
|
+
} from "../chunk-JLHX4WLS.js";
|
|
4
|
+
|
|
5
|
+
// src/react/UpdateCard.tsx
|
|
6
|
+
import { useState, useEffect } from "react";
|
|
7
|
+
import { createPortal } from "react-dom";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
function UpdateCard({
|
|
10
|
+
visible = true,
|
|
11
|
+
version = null,
|
|
12
|
+
date = null,
|
|
13
|
+
content = null,
|
|
14
|
+
bulletPoints,
|
|
15
|
+
maxBullets = 4,
|
|
16
|
+
title = "\u2728 \u65B0\u7248\u672C\u4E0A\u7EBF",
|
|
17
|
+
viewMoreUrl = "",
|
|
18
|
+
viewMoreText = "\u67E5\u770B\u5B8C\u6574\u66F4\u65B0\u65E5\u5FD7",
|
|
19
|
+
refreshText = "\u7ACB\u5373\u5237\u65B0",
|
|
20
|
+
closable = true,
|
|
21
|
+
layout = "floating",
|
|
22
|
+
dark = false,
|
|
23
|
+
onRefresh,
|
|
24
|
+
onViewMore,
|
|
25
|
+
onClose
|
|
26
|
+
}) {
|
|
27
|
+
const [dismissed, setDismissed] = useState(false);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
setDismissed(false);
|
|
30
|
+
}, [version]);
|
|
31
|
+
if (!visible || dismissed) return null;
|
|
32
|
+
const bullets = bulletPoints && bulletPoints.length > 0 ? bulletPoints : content ? extractBulletPoints(content) : [];
|
|
33
|
+
const displayedBullets = bullets.slice(0, maxBullets);
|
|
34
|
+
const remainingCount = Math.max(0, bullets.length - maxBullets);
|
|
35
|
+
const handleClose = () => {
|
|
36
|
+
setDismissed(true);
|
|
37
|
+
onClose?.();
|
|
38
|
+
};
|
|
39
|
+
const handleViewMore = (e) => {
|
|
40
|
+
onViewMore?.();
|
|
41
|
+
if (!viewMoreUrl) {
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const cardStyle = {
|
|
46
|
+
...styles.card,
|
|
47
|
+
...dark ? styles.cardDark : {}
|
|
48
|
+
};
|
|
49
|
+
const cardContent = /* @__PURE__ */ jsx(
|
|
50
|
+
"div",
|
|
51
|
+
{
|
|
52
|
+
style: layout === "floating" ? styles.wrapperFloating : styles.wrapperInline,
|
|
53
|
+
role: "region",
|
|
54
|
+
"aria-label": "\u65B0\u7248\u672C\u66F4\u65B0\u901A\u77E5",
|
|
55
|
+
children: /* @__PURE__ */ jsxs("div", { style: cardStyle, children: [
|
|
56
|
+
/* @__PURE__ */ jsxs("div", { style: styles.header, children: [
|
|
57
|
+
/* @__PURE__ */ jsxs("div", { style: styles.titleGroup, children: [
|
|
58
|
+
/* @__PURE__ */ jsx("span", { style: styles.title, children: title }),
|
|
59
|
+
version && /* @__PURE__ */ jsx("span", { style: dark ? { ...styles.badge, ...styles.badgeDark } : styles.badge, children: version }),
|
|
60
|
+
date && /* @__PURE__ */ jsx("span", { style: styles.date, children: date })
|
|
61
|
+
] }),
|
|
62
|
+
closable && /* @__PURE__ */ jsx(
|
|
63
|
+
"button",
|
|
64
|
+
{
|
|
65
|
+
type: "button",
|
|
66
|
+
style: styles.closeBtn,
|
|
67
|
+
"aria-label": "\u5173\u95ED\u66F4\u65B0\u63D0\u793A",
|
|
68
|
+
onClick: handleClose,
|
|
69
|
+
children: "\u2715"
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
] }),
|
|
73
|
+
/* @__PURE__ */ jsxs("div", { style: styles.body, children: [
|
|
74
|
+
displayedBullets.length > 0 ? /* @__PURE__ */ jsx("ul", { style: styles.list, children: displayedBullets.map((b, i) => /* @__PURE__ */ jsxs("li", { style: styles.listItem, children: [
|
|
75
|
+
/* @__PURE__ */ jsx("span", { style: styles.bulletDot, "aria-hidden": "true", children: "\u2022" }),
|
|
76
|
+
/* @__PURE__ */ jsx("span", { style: dark ? { ...styles.bulletText, ...styles.bulletTextDark } : styles.bulletText, children: b })
|
|
77
|
+
] }, i)) }) : content ? /* @__PURE__ */ jsx("p", { style: dark ? { ...styles.fallbackText, ...styles.fallbackTextDark } : styles.fallbackText, children: content }) : /* @__PURE__ */ jsx("p", { style: dark ? { ...styles.fallbackText, ...styles.fallbackTextDark } : styles.fallbackText, children: "\u7CFB\u7EDF\u5DF2\u90E8\u7F72\u65B0\u7248\u672C\uFF0C\u5237\u65B0\u9875\u9762\u5373\u53EF\u4F7F\u7528\u6700\u65B0\u529F\u80FD\u4E0E\u4F18\u5316\u3002" }),
|
|
78
|
+
remainingCount > 0 && /* @__PURE__ */ jsxs("div", { style: styles.remaining, children: [
|
|
79
|
+
"\u8FD8\u6709 ",
|
|
80
|
+
remainingCount,
|
|
81
|
+
" \u9879\u66F4\u65B0\u6539\u8FDB"
|
|
82
|
+
] })
|
|
83
|
+
] }),
|
|
84
|
+
/* @__PURE__ */ jsxs("div", { style: dark ? { ...styles.footer, ...styles.footerDark } : styles.footer, children: [
|
|
85
|
+
viewMoreUrl || onViewMore ? /* @__PURE__ */ jsxs(
|
|
86
|
+
"a",
|
|
87
|
+
{
|
|
88
|
+
href: viewMoreUrl || "javascript:void(0)",
|
|
89
|
+
style: styles.link,
|
|
90
|
+
onClick: handleViewMore,
|
|
91
|
+
children: [
|
|
92
|
+
viewMoreText,
|
|
93
|
+
" \u2192"
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
) : /* @__PURE__ */ jsx("span", { style: { flex: 1 } }),
|
|
97
|
+
/* @__PURE__ */ jsx(
|
|
98
|
+
"button",
|
|
99
|
+
{
|
|
100
|
+
type: "button",
|
|
101
|
+
style: styles.refreshBtn,
|
|
102
|
+
onClick: onRefresh,
|
|
103
|
+
children: refreshText
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
] })
|
|
107
|
+
] })
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
if (layout === "floating" && typeof document !== "undefined") {
|
|
111
|
+
return createPortal(cardContent, document.body);
|
|
112
|
+
}
|
|
113
|
+
return cardContent;
|
|
114
|
+
}
|
|
115
|
+
var styles = {
|
|
116
|
+
wrapperFloating: {
|
|
117
|
+
position: "fixed",
|
|
118
|
+
right: 20,
|
|
119
|
+
bottom: 20,
|
|
120
|
+
zIndex: 9998,
|
|
121
|
+
width: 360,
|
|
122
|
+
maxWidth: "calc(100vw - 32px)",
|
|
123
|
+
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif"
|
|
124
|
+
},
|
|
125
|
+
wrapperInline: {
|
|
126
|
+
position: "relative",
|
|
127
|
+
width: "100%",
|
|
128
|
+
margin: "12px 0",
|
|
129
|
+
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif"
|
|
130
|
+
},
|
|
131
|
+
card: {
|
|
132
|
+
padding: "16px 18px",
|
|
133
|
+
borderRadius: "var(--rg-radius, 14px)",
|
|
134
|
+
background: "var(--rg-card-bg, #ffffff)",
|
|
135
|
+
color: "var(--rg-card-fg, #111827)",
|
|
136
|
+
border: "1px solid var(--rg-card-border, #e5e7eb)",
|
|
137
|
+
boxShadow: "var(--rg-card-shadow, 0 10px 30px -4px rgba(0,0,0,0.12), 0 4px 10px -2px rgba(0,0,0,0.05))"
|
|
138
|
+
},
|
|
139
|
+
cardDark: {
|
|
140
|
+
background: "var(--rg-card-bg-dark, #1f2937)",
|
|
141
|
+
color: "var(--rg-card-fg-dark, #f9fafb)",
|
|
142
|
+
borderColor: "var(--rg-card-border-dark, #374151)",
|
|
143
|
+
boxShadow: "0 10px 30px -4px rgba(0,0,0,0.4)"
|
|
144
|
+
},
|
|
145
|
+
header: {
|
|
146
|
+
display: "flex",
|
|
147
|
+
alignItems: "center",
|
|
148
|
+
justifyContent: "space-between",
|
|
149
|
+
marginBottom: 12
|
|
150
|
+
},
|
|
151
|
+
titleGroup: {
|
|
152
|
+
display: "flex",
|
|
153
|
+
alignItems: "center",
|
|
154
|
+
gap: 8,
|
|
155
|
+
flexWrap: "wrap"
|
|
156
|
+
},
|
|
157
|
+
title: {
|
|
158
|
+
fontSize: 14.5,
|
|
159
|
+
fontWeight: 700,
|
|
160
|
+
letterSpacing: "-0.01em",
|
|
161
|
+
color: "inherit"
|
|
162
|
+
},
|
|
163
|
+
badge: {
|
|
164
|
+
display: "inline-flex",
|
|
165
|
+
alignItems: "center",
|
|
166
|
+
padding: "2px 7px",
|
|
167
|
+
borderRadius: 9999,
|
|
168
|
+
fontSize: 11,
|
|
169
|
+
fontWeight: 600,
|
|
170
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
|
|
171
|
+
background: "var(--rg-badge-bg, rgba(37,99,235,0.1))",
|
|
172
|
+
color: "var(--rg-badge-fg, #2563eb)"
|
|
173
|
+
},
|
|
174
|
+
badgeDark: {
|
|
175
|
+
background: "rgba(59,130,246,0.2)",
|
|
176
|
+
color: "#60a5fa"
|
|
177
|
+
},
|
|
178
|
+
date: {
|
|
179
|
+
fontSize: 11.5,
|
|
180
|
+
color: "var(--rg-muted-fg, #6b7280)"
|
|
181
|
+
},
|
|
182
|
+
closeBtn: {
|
|
183
|
+
display: "inline-flex",
|
|
184
|
+
alignItems: "center",
|
|
185
|
+
justifyContent: "center",
|
|
186
|
+
width: 22,
|
|
187
|
+
height: 22,
|
|
188
|
+
padding: 0,
|
|
189
|
+
border: "none",
|
|
190
|
+
borderRadius: 6,
|
|
191
|
+
background: "transparent",
|
|
192
|
+
color: "var(--rg-muted-fg, #9ca3af)",
|
|
193
|
+
fontSize: 13,
|
|
194
|
+
cursor: "pointer"
|
|
195
|
+
},
|
|
196
|
+
body: {
|
|
197
|
+
marginBottom: 14
|
|
198
|
+
},
|
|
199
|
+
list: {
|
|
200
|
+
margin: 0,
|
|
201
|
+
padding: 0,
|
|
202
|
+
listStyle: "none",
|
|
203
|
+
display: "flex",
|
|
204
|
+
flexDirection: "column",
|
|
205
|
+
gap: 6
|
|
206
|
+
},
|
|
207
|
+
listItem: {
|
|
208
|
+
display: "flex",
|
|
209
|
+
alignItems: "flex-start",
|
|
210
|
+
gap: 6,
|
|
211
|
+
fontSize: 13,
|
|
212
|
+
lineHeight: 1.5
|
|
213
|
+
},
|
|
214
|
+
bulletDot: {
|
|
215
|
+
flexShrink: 0,
|
|
216
|
+
fontSize: 14,
|
|
217
|
+
lineHeight: 1.4,
|
|
218
|
+
color: "var(--rg-accent, #2563eb)"
|
|
219
|
+
},
|
|
220
|
+
bulletText: {
|
|
221
|
+
flex: 1,
|
|
222
|
+
wordBreak: "break-word",
|
|
223
|
+
color: "var(--rg-body-fg, #374151)"
|
|
224
|
+
},
|
|
225
|
+
bulletTextDark: {
|
|
226
|
+
color: "var(--rg-body-fg-dark, #d1d5db)"
|
|
227
|
+
},
|
|
228
|
+
fallbackText: {
|
|
229
|
+
margin: 0,
|
|
230
|
+
fontSize: 13,
|
|
231
|
+
lineHeight: 1.55,
|
|
232
|
+
color: "var(--rg-body-fg, #4b5563)"
|
|
233
|
+
},
|
|
234
|
+
fallbackTextDark: {
|
|
235
|
+
color: "var(--rg-body-fg-dark, #d1d5db)"
|
|
236
|
+
},
|
|
237
|
+
remaining: {
|
|
238
|
+
marginTop: 6,
|
|
239
|
+
paddingLeft: 12,
|
|
240
|
+
fontSize: 11.5,
|
|
241
|
+
color: "var(--rg-muted-fg, #6b7280)"
|
|
242
|
+
},
|
|
243
|
+
footer: {
|
|
244
|
+
display: "flex",
|
|
245
|
+
alignItems: "center",
|
|
246
|
+
justifyContent: "space-between",
|
|
247
|
+
gap: 12,
|
|
248
|
+
paddingTop: 10,
|
|
249
|
+
borderTop: "1px solid var(--rg-card-border, #f3f4f6)"
|
|
250
|
+
},
|
|
251
|
+
footerDark: {
|
|
252
|
+
borderTopColor: "#374151"
|
|
253
|
+
},
|
|
254
|
+
link: {
|
|
255
|
+
fontSize: 12.5,
|
|
256
|
+
fontWeight: 500,
|
|
257
|
+
color: "var(--rg-accent, #2563eb)",
|
|
258
|
+
textDecoration: "none",
|
|
259
|
+
cursor: "pointer"
|
|
260
|
+
},
|
|
261
|
+
refreshBtn: {
|
|
262
|
+
padding: "6px 14px",
|
|
263
|
+
border: "none",
|
|
264
|
+
borderRadius: "var(--rg-btn-radius, 8px)",
|
|
265
|
+
background: "var(--rg-accent, #2563eb)",
|
|
266
|
+
color: "var(--rg-accent-fg, #ffffff)",
|
|
267
|
+
fontSize: 12.5,
|
|
268
|
+
fontWeight: 600,
|
|
269
|
+
cursor: "pointer",
|
|
270
|
+
whiteSpace: "nowrap"
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
export {
|
|
274
|
+
UpdateCard
|
|
275
|
+
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { UpdateChecker } from '../core/checker';
|
|
2
|
-
import type { VersionCheckerOptions, VersionInfo } from '../core/types';
|
|
1
|
+
import { UpdateChecker, fetchChangelog, parseChangelog, extractBulletPoints } from '../core/checker';
|
|
2
|
+
import type { VersionCheckerOptions, VersionInfo, ParsedChangelog, ChangelogVersionEntry, UpdateCardProps } from '../core/types';
|
|
3
|
+
export { fetchChangelog, parseChangelog, extractBulletPoints };
|
|
4
|
+
export type { VersionCheckerOptions, VersionInfo, ParsedChangelog, ChangelogVersionEntry, UpdateCardProps, };
|
|
3
5
|
/**
|
|
4
6
|
* React hook wrapping the framework-agnostic UpdateChecker. Mounts/unmounts the checker with
|
|
5
7
|
* the component's lifecycle automatically.
|
|
@@ -9,9 +11,11 @@ import type { VersionCheckerOptions, VersionInfo } from '../core/types';
|
|
|
9
11
|
export declare function useVersionCheck(currentVersion: string, options?: VersionCheckerOptions): {
|
|
10
12
|
hasUpdate: boolean;
|
|
11
13
|
latestInfo: VersionInfo | null;
|
|
14
|
+
changelog: ParsedChangelog | null;
|
|
12
15
|
mode: import("../core/types").UpdateMode;
|
|
13
16
|
applyUpdate: () => void;
|
|
14
17
|
checkNow: () => Promise<boolean>;
|
|
18
|
+
fetchChangelog: (url?: string) => Promise<ParsedChangelog>;
|
|
15
19
|
/** Feed a vite-plugin-pwa `onNeedRefresh` (or any other out-of-band) signal into the same mode logic. */
|
|
16
20
|
notifyExternalUpdate: (info?: VersionInfo) => void;
|
|
17
21
|
checker: UpdateChecker;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UpdateChecker
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-CGDGH2ML.js";
|
|
4
|
+
import {
|
|
5
|
+
extractBulletPoints,
|
|
6
|
+
fetchChangelog,
|
|
7
|
+
parseChangelog
|
|
8
|
+
} from "../chunk-JLHX4WLS.js";
|
|
4
9
|
|
|
5
10
|
// src/react/useVersionCheck.ts
|
|
6
11
|
import { useEffect, useRef, useState } from "react";
|
|
7
12
|
function useVersionCheck(currentVersion, options = {}) {
|
|
8
13
|
const [hasUpdate, setHasUpdate] = useState(false);
|
|
9
14
|
const [latestInfo, setLatestInfo] = useState(null);
|
|
15
|
+
const [changelog, setChangelog] = useState(null);
|
|
10
16
|
const checkerRef = useRef(null);
|
|
11
17
|
if (!checkerRef.current) {
|
|
12
18
|
checkerRef.current = new UpdateChecker(currentVersion, options);
|
|
@@ -17,24 +23,33 @@ function useVersionCheck(currentVersion, options = {}) {
|
|
|
17
23
|
setHasUpdate(true);
|
|
18
24
|
setLatestInfo(info);
|
|
19
25
|
});
|
|
26
|
+
const offChangelog = checker2.on("changelog-loaded", (parsed) => {
|
|
27
|
+
setChangelog(parsed);
|
|
28
|
+
});
|
|
20
29
|
checker2.start();
|
|
21
30
|
return () => {
|
|
22
31
|
checker2.stop();
|
|
23
32
|
off();
|
|
33
|
+
offChangelog();
|
|
24
34
|
};
|
|
25
35
|
}, []);
|
|
26
36
|
const checker = checkerRef.current;
|
|
27
37
|
return {
|
|
28
38
|
hasUpdate,
|
|
29
39
|
latestInfo,
|
|
40
|
+
changelog,
|
|
30
41
|
mode: options.mode ?? "toast-auto",
|
|
31
42
|
applyUpdate: () => checker.applyUpdate(),
|
|
32
43
|
checkNow: () => checker.checkNow(),
|
|
44
|
+
fetchChangelog: (url) => checker.fetchChangelog(url),
|
|
33
45
|
/** Feed a vite-plugin-pwa `onNeedRefresh` (or any other out-of-band) signal into the same mode logic. */
|
|
34
46
|
notifyExternalUpdate: (info) => checker.notifyExternalUpdate(info),
|
|
35
47
|
checker
|
|
36
48
|
};
|
|
37
49
|
}
|
|
38
50
|
export {
|
|
51
|
+
extractBulletPoints,
|
|
52
|
+
fetchChangelog,
|
|
53
|
+
parseChangelog,
|
|
39
54
|
useVersionCheck
|
|
40
55
|
};
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref, watch } from 'vue'
|
|
3
|
+
import { extractBulletPoints } from '../core/changelog'
|
|
4
|
+
import type { UpdateCardProps } from '../core/types'
|
|
5
|
+
|
|
6
|
+
const props = withDefaults(defineProps<UpdateCardProps>(), {
|
|
7
|
+
visible: true,
|
|
8
|
+
version: null,
|
|
9
|
+
date: null,
|
|
10
|
+
content: null,
|
|
11
|
+
bulletPoints: undefined,
|
|
12
|
+
maxBullets: 4,
|
|
13
|
+
title: '✨ 新版本上线',
|
|
14
|
+
viewMoreUrl: '',
|
|
15
|
+
viewMoreText: '查看完整更新日志',
|
|
16
|
+
refreshText: '立即刷新',
|
|
17
|
+
closable: true,
|
|
18
|
+
layout: 'floating',
|
|
19
|
+
dark: null,
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const emit = defineEmits<{
|
|
23
|
+
refresh: []
|
|
24
|
+
viewMore: []
|
|
25
|
+
close: []
|
|
26
|
+
}>()
|
|
27
|
+
|
|
28
|
+
const dismissed = ref(false)
|
|
29
|
+
|
|
30
|
+
// 当版本发生变化时,重置关闭状态
|
|
31
|
+
watch(() => props.version, () => {
|
|
32
|
+
dismissed.value = false
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const isShown = computed(() => props.visible && !dismissed.value)
|
|
36
|
+
|
|
37
|
+
const bullets = computed(() => {
|
|
38
|
+
if (props.bulletPoints && props.bulletPoints.length > 0) {
|
|
39
|
+
return props.bulletPoints
|
|
40
|
+
}
|
|
41
|
+
if (props.content) {
|
|
42
|
+
return extractBulletPoints(props.content)
|
|
43
|
+
}
|
|
44
|
+
return []
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const displayedBullets = computed(() => bullets.value.slice(0, props.maxBullets))
|
|
48
|
+
const remainingCount = computed(() => Math.max(0, bullets.value.length - props.maxBullets))
|
|
49
|
+
|
|
50
|
+
function handleClose() {
|
|
51
|
+
dismissed.value = true
|
|
52
|
+
emit('close')
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function handleViewMore(e: Event) {
|
|
56
|
+
emit('viewMore')
|
|
57
|
+
if (!props.viewMoreUrl) {
|
|
58
|
+
e.preventDefault()
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<template>
|
|
64
|
+
<component :is="layout === 'floating' ? 'Teleport' : 'div'" :to="layout === 'floating' ? 'body' : undefined">
|
|
65
|
+
<div
|
|
66
|
+
v-if="isShown"
|
|
67
|
+
class="rg-card-wrapper"
|
|
68
|
+
:class="[
|
|
69
|
+
layout === 'floating' ? 'rg-card-floating' : 'rg-card-inline',
|
|
70
|
+
{ 'rg-dark': dark === true, 'rg-light': dark === false }
|
|
71
|
+
]"
|
|
72
|
+
role="region"
|
|
73
|
+
aria-label="新版本更新通知"
|
|
74
|
+
>
|
|
75
|
+
<div class="rg-card">
|
|
76
|
+
<!-- 头部区域 -->
|
|
77
|
+
<div class="rg-card-header">
|
|
78
|
+
<div class="rg-card-title-group">
|
|
79
|
+
<span class="rg-card-title">{{ title }}</span>
|
|
80
|
+
<span v-if="version" class="rg-card-badge">{{ version }}</span>
|
|
81
|
+
<span v-if="date" class="rg-card-date">{{ date }}</span>
|
|
82
|
+
</div>
|
|
83
|
+
<button
|
|
84
|
+
v-if="closable"
|
|
85
|
+
type="button"
|
|
86
|
+
class="rg-card-close"
|
|
87
|
+
aria-label="关闭更新提示"
|
|
88
|
+
@click="handleClose"
|
|
89
|
+
>
|
|
90
|
+
✕
|
|
91
|
+
</button>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<!-- 正文要点列表 -->
|
|
95
|
+
<div class="rg-card-body">
|
|
96
|
+
<ul v-if="displayedBullets.length > 0" class="rg-bullet-list">
|
|
97
|
+
<li v-for="(b, i) in displayedBullets" :key="i" class="rg-bullet-item">
|
|
98
|
+
<span class="rg-bullet-dot" aria-hidden="true">•</span>
|
|
99
|
+
<span class="rg-bullet-text">{{ b }}</span>
|
|
100
|
+
</li>
|
|
101
|
+
</ul>
|
|
102
|
+
<p v-else-if="content" class="rg-card-fallback-text">{{ content }}</p>
|
|
103
|
+
<p v-else class="rg-card-fallback-text">系统已部署新版本,刷新页面即可使用最新功能与优化。</p>
|
|
104
|
+
|
|
105
|
+
<div v-if="remainingCount > 0" class="rg-remaining-note">
|
|
106
|
+
<span>还有 {{ remainingCount }} 项更新改进</span>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<!-- 底部操作栏 -->
|
|
111
|
+
<div class="rg-card-footer">
|
|
112
|
+
<a
|
|
113
|
+
v-if="viewMoreUrl || $attrs.onViewMore"
|
|
114
|
+
:href="viewMoreUrl || 'javascript:void(0)'"
|
|
115
|
+
class="rg-card-link"
|
|
116
|
+
@click="handleViewMore"
|
|
117
|
+
>
|
|
118
|
+
{{ viewMoreText }} →
|
|
119
|
+
</a>
|
|
120
|
+
<span v-else class="rg-card-spacer" />
|
|
121
|
+
|
|
122
|
+
<button
|
|
123
|
+
type="button"
|
|
124
|
+
class="rg-card-refresh-btn"
|
|
125
|
+
@click="emit('refresh')"
|
|
126
|
+
>
|
|
127
|
+
{{ refreshText }}
|
|
128
|
+
</button>
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
</component>
|
|
133
|
+
</template>
|
|
134
|
+
|
|
135
|
+
<style scoped>
|
|
136
|
+
.rg-card-wrapper {
|
|
137
|
+
box-sizing: border-box;
|
|
138
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.rg-card-floating {
|
|
142
|
+
position: fixed;
|
|
143
|
+
right: 20px;
|
|
144
|
+
bottom: 20px;
|
|
145
|
+
z-index: 9998;
|
|
146
|
+
width: 360px;
|
|
147
|
+
max-width: calc(100vw - 32px);
|
|
148
|
+
animation: rg-slide-up 0.28s cubic-bezier(0.16, 1, 0.3, 1);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.rg-card-inline {
|
|
152
|
+
position: relative;
|
|
153
|
+
width: 100%;
|
|
154
|
+
margin: 12px 0;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
@keyframes rg-slide-up {
|
|
158
|
+
from {
|
|
159
|
+
opacity: 0;
|
|
160
|
+
transform: translateY(16px) scale(0.97);
|
|
161
|
+
}
|
|
162
|
+
to {
|
|
163
|
+
opacity: 1;
|
|
164
|
+
transform: translateY(0) scale(1);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.rg-card {
|
|
169
|
+
padding: 16px 18px;
|
|
170
|
+
border-radius: var(--rg-radius, 14px);
|
|
171
|
+
background: var(--rg-card-bg, #ffffff);
|
|
172
|
+
color: var(--rg-card-fg, #111827);
|
|
173
|
+
border: 1px solid var(--rg-card-border, #e5e7eb);
|
|
174
|
+
box-shadow: var(--rg-card-shadow, 0 10px 30px -4px rgba(0, 0, 0, 0.12), 0 4px 10px -2px rgba(0, 0, 0, 0.05));
|
|
175
|
+
backdrop-filter: blur(8px);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.rg-card-header {
|
|
179
|
+
display: flex;
|
|
180
|
+
align-items: center;
|
|
181
|
+
justify-content: space-between;
|
|
182
|
+
margin-bottom: 12px;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.rg-card-title-group {
|
|
186
|
+
display: flex;
|
|
187
|
+
align-items: center;
|
|
188
|
+
gap: 8px;
|
|
189
|
+
flex-wrap: wrap;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.rg-card-title {
|
|
193
|
+
font-size: 14.5px;
|
|
194
|
+
font-weight: 700;
|
|
195
|
+
letter-spacing: -0.01em;
|
|
196
|
+
color: inherit;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.rg-card-badge {
|
|
200
|
+
display: inline-flex;
|
|
201
|
+
align-items: center;
|
|
202
|
+
padding: 2px 7px;
|
|
203
|
+
border-radius: 9999px;
|
|
204
|
+
font-size: 11px;
|
|
205
|
+
font-weight: 600;
|
|
206
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
207
|
+
background: var(--rg-badge-bg, rgba(37, 99, 235, 0.1));
|
|
208
|
+
color: var(--rg-badge-fg, #2563eb);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.rg-card-date {
|
|
212
|
+
font-size: 11.5px;
|
|
213
|
+
color: var(--rg-muted-fg, #6b7280);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.rg-card-close {
|
|
217
|
+
display: inline-flex;
|
|
218
|
+
align-items: center;
|
|
219
|
+
justify-content: center;
|
|
220
|
+
width: 22px;
|
|
221
|
+
height: 22px;
|
|
222
|
+
padding: 0;
|
|
223
|
+
border: none;
|
|
224
|
+
border-radius: 6px;
|
|
225
|
+
background: transparent;
|
|
226
|
+
color: var(--rg-muted-fg, #9ca3af);
|
|
227
|
+
font-size: 13px;
|
|
228
|
+
cursor: pointer;
|
|
229
|
+
transition: all 0.15s ease;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.rg-card-close:hover {
|
|
233
|
+
background: var(--rg-hover-bg, rgba(0, 0, 0, 0.06));
|
|
234
|
+
color: var(--rg-card-fg, #111827);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.rg-card-body {
|
|
238
|
+
margin-bottom: 14px;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.rg-bullet-list {
|
|
242
|
+
margin: 0;
|
|
243
|
+
padding: 0;
|
|
244
|
+
list-style: none;
|
|
245
|
+
display: flex;
|
|
246
|
+
flex-direction: column;
|
|
247
|
+
gap: 6px;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.rg-bullet-item {
|
|
251
|
+
display: flex;
|
|
252
|
+
align-items: flex-start;
|
|
253
|
+
gap: 6px;
|
|
254
|
+
font-size: 13px;
|
|
255
|
+
line-height: 1.5;
|
|
256
|
+
color: var(--rg-body-fg, #374151);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.rg-bullet-dot {
|
|
260
|
+
flex-shrink: 0;
|
|
261
|
+
font-size: 14px;
|
|
262
|
+
line-height: 1.4;
|
|
263
|
+
color: var(--rg-accent, #2563eb);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.rg-bullet-text {
|
|
267
|
+
flex: 1;
|
|
268
|
+
word-break: break-word;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.rg-card-fallback-text {
|
|
272
|
+
margin: 0;
|
|
273
|
+
font-size: 13px;
|
|
274
|
+
line-height: 1.55;
|
|
275
|
+
color: var(--rg-body-fg, #4b5563);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.rg-remaining-note {
|
|
279
|
+
margin-top: 6px;
|
|
280
|
+
padding-left: 12px;
|
|
281
|
+
font-size: 11.5px;
|
|
282
|
+
color: var(--rg-muted-fg, #6b7280);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.rg-card-footer {
|
|
286
|
+
display: flex;
|
|
287
|
+
align-items: center;
|
|
288
|
+
justify-content: space-between;
|
|
289
|
+
gap: 12px;
|
|
290
|
+
padding-top: 10px;
|
|
291
|
+
border-top: 1px solid var(--rg-card-border, #f3f4f6);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.rg-card-spacer {
|
|
295
|
+
flex: 1;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.rg-card-link {
|
|
299
|
+
font-size: 12.5px;
|
|
300
|
+
font-weight: 500;
|
|
301
|
+
color: var(--rg-accent, #2563eb);
|
|
302
|
+
text-decoration: none;
|
|
303
|
+
transition: opacity 0.15s ease;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.rg-card-link:hover {
|
|
307
|
+
opacity: 0.82;
|
|
308
|
+
text-decoration: underline;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.rg-card-refresh-btn {
|
|
312
|
+
padding: 6px 14px;
|
|
313
|
+
border: none;
|
|
314
|
+
border-radius: var(--rg-btn-radius, 8px);
|
|
315
|
+
background: var(--rg-accent, #2563eb);
|
|
316
|
+
color: var(--rg-accent-fg, #ffffff);
|
|
317
|
+
font-size: 12.5px;
|
|
318
|
+
font-weight: 600;
|
|
319
|
+
cursor: pointer;
|
|
320
|
+
transition: all 0.15s ease;
|
|
321
|
+
white-space: nowrap;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
.rg-card-refresh-btn:hover {
|
|
325
|
+
filter: brightness(0.92);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.rg-card-refresh-btn:active {
|
|
329
|
+
transform: scale(0.98);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/* 深色模式适配 */
|
|
333
|
+
.rg-card-wrapper.rg-dark .rg-card {
|
|
334
|
+
background: var(--rg-card-bg-dark, #1f2937);
|
|
335
|
+
color: var(--rg-card-fg-dark, #f9fafb);
|
|
336
|
+
border-color: var(--rg-card-border-dark, #374151);
|
|
337
|
+
box-shadow: 0 10px 30px -4px rgba(0, 0, 0, 0.4);
|
|
338
|
+
}
|
|
339
|
+
.rg-card-wrapper.rg-dark .rg-bullet-item { color: var(--rg-body-fg-dark, #d1d5db); }
|
|
340
|
+
.rg-card-wrapper.rg-dark .rg-card-badge { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
|
|
341
|
+
.rg-card-wrapper.rg-dark .rg-card-footer { border-color: #374151; }
|
|
342
|
+
.rg-card-wrapper.rg-dark .rg-card-close:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
|
|
343
|
+
|
|
344
|
+
@media (prefers-color-scheme: dark) {
|
|
345
|
+
.rg-card-wrapper:not(.rg-light) .rg-card {
|
|
346
|
+
background: var(--rg-card-bg-dark, #1f2937);
|
|
347
|
+
color: var(--rg-card-fg-dark, #f9fafb);
|
|
348
|
+
border-color: var(--rg-card-border-dark, #374151);
|
|
349
|
+
box-shadow: 0 10px 30px -4px rgba(0, 0, 0, 0.4);
|
|
350
|
+
}
|
|
351
|
+
.rg-card-wrapper:not(.rg-light) .rg-bullet-item { color: var(--rg-body-fg-dark, #d1d5db); }
|
|
352
|
+
.rg-card-wrapper:not(.rg-light) .rg-card-badge { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
|
|
353
|
+
.rg-card-wrapper:not(.rg-light) .rg-card-footer { border-color: #374151; }
|
|
354
|
+
.rg-card-wrapper:not(.rg-light) .rg-card-close:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
|
|
355
|
+
}
|
|
356
|
+
</style>
|