@opendesign-plus-test/plugins 0.0.1-rc.5 → 0.0.1-rc.7
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/dist/analytics/index.js +4 -1947
- package/dist/analytics/plugin.d.ts +0 -7
- package/dist/external-link-guard/adapters/dom.d.ts +2 -0
- package/dist/external-link-guard/adapters/window.d.ts +2 -0
- package/dist/external-link-guard/core/check.d.ts +12 -0
- package/dist/external-link-guard/core/confirm.d.ts +2 -0
- package/dist/external-link-guard/core/types.d.ts +23 -0
- package/dist/external-link-guard/index.d.ts +3 -0
- package/dist/external-link-guard/plugin.d.ts +4 -0
- package/dist/external-link-guard/ui/createConfirm.d.ts +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +265 -27
- package/dist/plugin-lvjNLBe-.js +1942 -0
- package/package.json +1 -1
- package/dist/analytics/injectionSymbol.d.ts +0 -10
|
@@ -47,11 +47,4 @@ type ConfigOptions = {
|
|
|
47
47
|
onPageView?: (from: string, to: string) => Record<string, any> | void;
|
|
48
48
|
};
|
|
49
49
|
export declare const initOpenDesignAnalytics: (app: App, options: ConfigOptions) => void;
|
|
50
|
-
export declare const useOpenAnalytics: () => {
|
|
51
|
-
oaInstance?: OpenAnalytics | null;
|
|
52
|
-
enable: () => void;
|
|
53
|
-
disable: () => void;
|
|
54
|
-
oaReport: typeof oaReport;
|
|
55
|
-
reportPV: () => void;
|
|
56
|
-
};
|
|
57
50
|
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface ExternalLinkGuardOptions {
|
|
2
|
+
/**
|
|
3
|
+
* 白名单域名(支持通配符 * 和 *.example.com)
|
|
4
|
+
* 默认为空数组(即无白名单)
|
|
5
|
+
*/
|
|
6
|
+
whitelist?: string[];
|
|
7
|
+
/**
|
|
8
|
+
* 自定义提示消息(默认为原生 confirm 提示)
|
|
9
|
+
*/
|
|
10
|
+
message?: string;
|
|
11
|
+
/**
|
|
12
|
+
* 是否显示自定义弹窗
|
|
13
|
+
*/
|
|
14
|
+
showCustomConfirm?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* 语言
|
|
17
|
+
*/
|
|
18
|
+
lang?: 'zh' | 'en';
|
|
19
|
+
/**
|
|
20
|
+
* 社区名称
|
|
21
|
+
*/
|
|
22
|
+
community?: string;
|
|
23
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { i as B, o as K, v as z } from "./plugin-lvjNLBe-.js";
|
|
2
|
+
const g = {}, L = `
|
|
2
3
|
(function () {
|
|
3
4
|
function getCookie(key) {
|
|
4
5
|
const name = encodeURIComponent(key) + '=';
|
|
@@ -24,49 +25,286 @@ const r = {}, k = `
|
|
|
24
25
|
}
|
|
25
26
|
})();
|
|
26
27
|
`.trim();
|
|
27
|
-
function
|
|
28
|
+
function R(e) {
|
|
28
29
|
const {
|
|
29
|
-
cookieKey:
|
|
30
|
-
lightValue:
|
|
31
|
-
darkValue:
|
|
32
|
-
attribute:
|
|
33
|
-
attributeLightValue:
|
|
34
|
-
attributeDarkValue:
|
|
35
|
-
classLightValue:
|
|
36
|
-
classDarkValue:
|
|
37
|
-
filename:
|
|
38
|
-
} =
|
|
39
|
-
let
|
|
30
|
+
cookieKey: n,
|
|
31
|
+
lightValue: t = "light",
|
|
32
|
+
darkValue: r = "dark",
|
|
33
|
+
attribute: o = "data-o-theme",
|
|
34
|
+
attributeLightValue: s = t,
|
|
35
|
+
attributeDarkValue: p = r,
|
|
36
|
+
classLightValue: x = t,
|
|
37
|
+
classDarkValue: k = r,
|
|
38
|
+
filename: l = "check-theme.js"
|
|
39
|
+
} = e, m = L.replace(/\$COOKIE_KEY/g, n).replace(/\$LIGHT_VALUE/g, t).replace(/\$DARK_VALUE/g, r).replace(/\$CLASS_LIGHT_VALUE/g, x).replace(/\$CLASS_DARK_VALUE/g, k).replace(/\$ATTRIBUTE_NAME/g, o).replace(/\$ATTRIBUTE_LIGHT_VALUE/g, s).replace(/\$ATTRIBUTE_DARK_VALUE/g, p);
|
|
40
|
+
let c = "", f = !1, d = "", u = !1;
|
|
40
41
|
return {
|
|
41
42
|
name: "vite-check-theme-plugin",
|
|
42
43
|
enforce: "pre",
|
|
43
|
-
configResolved(
|
|
44
|
-
if (
|
|
44
|
+
configResolved(a) {
|
|
45
|
+
if (c = a.base, f = a.command === "serve", d = a.build.outDir, u = !!a.vitepress, !u || !Array.isArray(a.vitepress.site.head))
|
|
45
46
|
return;
|
|
46
|
-
const
|
|
47
|
-
var
|
|
48
|
-
return
|
|
47
|
+
const w = a.vitepress.site.head.find((h) => {
|
|
48
|
+
var y, E;
|
|
49
|
+
return h[0] === "script" && ((E = (y = h[1]) == null ? void 0 : y.src) == null ? void 0 : E.startsWith(`${c}${l}`));
|
|
49
50
|
});
|
|
50
|
-
|
|
51
|
+
w ? w[1].src = `${c}${l}?t=${(/* @__PURE__ */ new Date()).getTime()}` : a.vitepress.site.head.push([
|
|
51
52
|
"script",
|
|
52
53
|
{
|
|
53
|
-
src: `${
|
|
54
|
+
src: `${c}${l}?t=${(/* @__PURE__ */ new Date()).getTime()}`
|
|
54
55
|
}
|
|
55
56
|
]);
|
|
56
57
|
},
|
|
57
58
|
generateBundle() {
|
|
58
|
-
|
|
59
|
+
f || g.existsSync(g.join(d, l)) || (g.existsSync(d) || g.mkdirSync(d, { recursive: !0 }), g.writeFileSync(g.join(d, l), m, "utf-8"));
|
|
59
60
|
},
|
|
60
|
-
configureServer(
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
configureServer(a) {
|
|
62
|
+
a.middlewares.use(`${c}${l}`, (w, h) => {
|
|
63
|
+
h.setHeader("Content-Type", "application/javascript"), h.end(m);
|
|
63
64
|
});
|
|
64
65
|
},
|
|
65
|
-
transformIndexHtml(
|
|
66
|
-
return
|
|
66
|
+
transformIndexHtml(a) {
|
|
67
|
+
return u ? a : a.replace("</head>", `<script src="${c}${l}?t=${(/* @__PURE__ */ new Date()).getTime()}"><\/script></head>`);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function b(e) {
|
|
72
|
+
let n;
|
|
73
|
+
try {
|
|
74
|
+
n = new URL(e, window.location.href);
|
|
75
|
+
} catch {
|
|
76
|
+
return !1;
|
|
77
|
+
}
|
|
78
|
+
return /^https?:$/.test(n.protocol) ? n.hostname !== window.location.hostname : !1;
|
|
79
|
+
}
|
|
80
|
+
function A(e, n = []) {
|
|
81
|
+
return n.some((t) => {
|
|
82
|
+
if (t === "*") return !0;
|
|
83
|
+
if (t.startsWith("*.")) {
|
|
84
|
+
const r = t.slice(2);
|
|
85
|
+
return e === r || e.endsWith(`.${r}`);
|
|
86
|
+
}
|
|
87
|
+
return e === t || e.endsWith(`.${t}`);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
const T = {
|
|
91
|
+
zh: {
|
|
92
|
+
title: "即将跳转到外部网站",
|
|
93
|
+
message: (e) => `您将要访问的链接不属于${e},请关注您的账号安全。`,
|
|
94
|
+
cancel: "取消",
|
|
95
|
+
confirm: "继续前往"
|
|
96
|
+
},
|
|
97
|
+
en: {
|
|
98
|
+
title: "You will be redirected to an external website",
|
|
99
|
+
message: (e) => `The link you are about to visit does not belong to ${e}. Please ensure the security of your account.`,
|
|
100
|
+
cancel: "Cancel",
|
|
101
|
+
confirm: "Continue"
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
let i = null, v = !1;
|
|
105
|
+
function C(e, n, t) {
|
|
106
|
+
const r = T[e];
|
|
107
|
+
return new Promise((o) => {
|
|
108
|
+
if (v) {
|
|
109
|
+
o(!1);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
v = !0, _(), i || (i = document.createElement("div"), i.className = "elg-mask", i.innerHTML = `
|
|
113
|
+
<div class="elg-modal">
|
|
114
|
+
<div class="elg-title"></div>
|
|
115
|
+
<div class="elg-content">
|
|
116
|
+
<div class="elg-message"></div>
|
|
117
|
+
<div class="elg-url"></div>
|
|
118
|
+
</div>
|
|
119
|
+
|
|
120
|
+
<div class="elg-actions">
|
|
121
|
+
<button class="elg-btn elg-confirm">${r.confirm}</button>
|
|
122
|
+
<button class="elg-btn elg-cancel">${r.cancel}</button>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
`, document.body.appendChild(i));
|
|
126
|
+
const s = i.querySelector(".elg-title"), p = i.querySelector(".elg-message"), x = i.querySelector(".elg-url"), k = i.querySelector(".elg-cancel"), l = i.querySelector(".elg-confirm");
|
|
127
|
+
s.textContent = r.title, p.textContent = r.message(t), x.textContent = n, i.style.display = "flex";
|
|
128
|
+
const m = (u) => {
|
|
129
|
+
i && (i.style.display = "none", i.removeEventListener("click", d), k.removeEventListener("click", c), l.removeEventListener("click", f), v = !1, o(u));
|
|
130
|
+
}, c = () => m(!1), f = () => m(!0), d = (u) => {
|
|
131
|
+
u.target === i && m(!1);
|
|
132
|
+
};
|
|
133
|
+
i.addEventListener("click", d), k.addEventListener("click", c), l.addEventListener("click", f);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function _() {
|
|
137
|
+
if (document.getElementById("elg-confirm-style"))
|
|
138
|
+
return;
|
|
139
|
+
const e = document.createElement("style");
|
|
140
|
+
e.id = "elg-confirm-style", e.textContent = `
|
|
141
|
+
:root {
|
|
142
|
+
--elg-primary: var(--o-color-primary1);
|
|
143
|
+
--elg-text: var(--o-color-info1);
|
|
144
|
+
--elg-mask: rgba(0,0,0,.45);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.elg-mask {
|
|
148
|
+
position: fixed;
|
|
149
|
+
inset: 0;
|
|
150
|
+
display: none;
|
|
151
|
+
align-items: center;
|
|
152
|
+
justify-content: center;
|
|
153
|
+
background: var(--elg-mask);
|
|
154
|
+
z-index: 9999;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.elg-modal {
|
|
158
|
+
min-width: 272px;
|
|
159
|
+
background: var(--o-color-fill2);
|
|
160
|
+
border-radius: 8px;
|
|
161
|
+
padding: 32px;
|
|
162
|
+
color: var(--elg-text);
|
|
163
|
+
margin: 24px;
|
|
164
|
+
box-shadow: 0p 3px 8px rgba(111, 111, 117, .08)
|
|
165
|
+
word-break: break-word;
|
|
166
|
+
|
|
167
|
+
@media (max-width: 840px) {
|
|
168
|
+
padding: 24px;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@media (max-width: 600px) {
|
|
172
|
+
padding: 16px;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.elg-title {
|
|
177
|
+
font-size: 24px;
|
|
178
|
+
line-height: 32px;
|
|
179
|
+
font-weight: 500;
|
|
180
|
+
text-align: center;
|
|
181
|
+
margin-bottom: 24px;
|
|
182
|
+
|
|
183
|
+
@media (max-width: 1440px) {
|
|
184
|
+
font-size: 20px;
|
|
185
|
+
line-height: 28px;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@media (max-width: 1200px) {
|
|
189
|
+
font-size: 18px;
|
|
190
|
+
line-height: 26px;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.elg-content{
|
|
195
|
+
max-width: 600px;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.elg-url,.elg-message {
|
|
199
|
+
font-size: 18px;
|
|
200
|
+
line-height: 26px;
|
|
201
|
+
word-break: break-all;
|
|
202
|
+
|
|
203
|
+
@media (max-width: 1440px) {
|
|
204
|
+
font-size: 16px;
|
|
205
|
+
line-height: 24px;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
@media (max-width: 1200px) {
|
|
209
|
+
font-size: 14px;
|
|
210
|
+
line-height: 22px;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.elg-url{
|
|
215
|
+
color: var(--o-color-info2);
|
|
216
|
+
margin-top: 24px;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.elg-actions {
|
|
220
|
+
display: flex;
|
|
221
|
+
justify-content: center;
|
|
222
|
+
gap: 12px;
|
|
223
|
+
margin-top: 24px;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.elg-btn {
|
|
227
|
+
min-width: 80px;
|
|
228
|
+
height: 40px;
|
|
229
|
+
border-radius: 20px;
|
|
230
|
+
padding: 0 23px;
|
|
231
|
+
border: none;
|
|
232
|
+
cursor: pointer;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.elg-cancel {
|
|
236
|
+
background-color: transparent;
|
|
237
|
+
border: 1px solid var(--elg-primary);
|
|
238
|
+
color: var(--elg-primary);
|
|
239
|
+
&:hover{
|
|
240
|
+
background: var(--elg-primary);
|
|
241
|
+
color: #fff;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.elg-confirm {
|
|
246
|
+
background: var(--elg-primary);
|
|
247
|
+
color: #fff;
|
|
248
|
+
&:hover{
|
|
249
|
+
background: rgba(81, 119, 202)
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
`, document.head.appendChild(e);
|
|
253
|
+
}
|
|
254
|
+
async function $(e, n) {
|
|
255
|
+
if (n.showCustomConfirm)
|
|
256
|
+
return C(n.lang || "zh", e, n.community || "");
|
|
257
|
+
const t = n.message ?? `即将离开本站,前往第三方网站:
|
|
258
|
+
|
|
259
|
+
${e}`;
|
|
260
|
+
return Promise.resolve(window.confirm(t));
|
|
261
|
+
}
|
|
262
|
+
function U(e) {
|
|
263
|
+
document.addEventListener(
|
|
264
|
+
"click",
|
|
265
|
+
async (n) => {
|
|
266
|
+
const t = n.target;
|
|
267
|
+
if (!t)
|
|
268
|
+
return;
|
|
269
|
+
const r = t.closest("a[href]");
|
|
270
|
+
if (!r)
|
|
271
|
+
return;
|
|
272
|
+
const o = r.getAttribute("href");
|
|
273
|
+
if (!o || o.startsWith("#") || !b(o))
|
|
274
|
+
return;
|
|
275
|
+
const s = new URL(o, window.location.href);
|
|
276
|
+
if (A(s.hostname, e.whitelist))
|
|
277
|
+
return;
|
|
278
|
+
n.preventDefault(), await $(s.href, e) && ((r.getAttribute("target") || "_self") === "_blank" ? window.open(s.href, "_blank", "noopener,noreferrer") : window.location.href = s.href);
|
|
279
|
+
},
|
|
280
|
+
!0
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
function S(e) {
|
|
284
|
+
const n = window.open;
|
|
285
|
+
window.open = async function(t, ...r) {
|
|
286
|
+
if (t) {
|
|
287
|
+
const o = t.toString();
|
|
288
|
+
if (b(o)) {
|
|
289
|
+
const s = new URL(o, window.location.href);
|
|
290
|
+
if (!A(s.hostname, e.whitelist) && !await $(s.href, e))
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return n.call(window, t, ...r);
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
function I(e = {}) {
|
|
298
|
+
return {
|
|
299
|
+
install() {
|
|
300
|
+
U(e), S(e);
|
|
67
301
|
}
|
|
68
302
|
};
|
|
69
303
|
}
|
|
70
304
|
export {
|
|
71
|
-
|
|
305
|
+
R as CheckThemePlugin,
|
|
306
|
+
I as createExternalLinkGuard,
|
|
307
|
+
B as initOpenDesignAnalytics,
|
|
308
|
+
K as oaReport,
|
|
309
|
+
z as vAnalytics
|
|
72
310
|
};
|