tour-guide-coach 1.0.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/LICENSE +21 -0
- package/README.md +301 -0
- package/dist/TourOverlay.vue.d.ts +2 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +397 -0
- package/dist/store.d.ts +21 -0
- package/dist/style.css +1 -0
- package/package.json +48 -0
- package/src/TourOverlay.vue +239 -0
- package/src/configs/demo-form.ts +82 -0
- package/src/index.ts +14 -0
- package/src/store.ts +270 -0
- package/src/types.ts +79 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import { shallowReactive as tt, defineComponent as et, watch as nt, onBeforeUnmount as lt, computed as d, openBlock as r, createBlock as ot, Teleport as it, unref as c, createElementBlock as u, createElementVNode as s, normalizeStyle as x, createCommentVNode as v, toDisplayString as p, createTextVNode as at } from "vue";
|
|
2
|
+
const st = 150, rt = 12e3, l = tt({
|
|
3
|
+
active: !1,
|
|
4
|
+
config: null,
|
|
5
|
+
stepIndex: 0,
|
|
6
|
+
totalSteps: 0,
|
|
7
|
+
highlightRect: null,
|
|
8
|
+
targetEl: null,
|
|
9
|
+
gatePass: !0,
|
|
10
|
+
waitingTarget: !1,
|
|
11
|
+
waitTimedOut: !1
|
|
12
|
+
});
|
|
13
|
+
let W = null, S = null, _ = null, m = null, O = null, $ = null, C = null, T = null, L = null, E = null;
|
|
14
|
+
function q() {
|
|
15
|
+
var t;
|
|
16
|
+
return ((t = l.config) == null ? void 0 : t.steps[l.stepIndex]) ?? null;
|
|
17
|
+
}
|
|
18
|
+
function ct() {
|
|
19
|
+
return q();
|
|
20
|
+
}
|
|
21
|
+
function zt(t, n, i) {
|
|
22
|
+
l.active && B(), l.config = t, l.stepIndex = 0, l.totalSteps = t.steps.length, l.gatePass = !0, W = i ?? null, S = n ?? null, l.active = !0, U();
|
|
23
|
+
}
|
|
24
|
+
function B() {
|
|
25
|
+
V(), l.active = !1, l.config = null, l.highlightRect = null, l.targetEl = null, S = null, W = null;
|
|
26
|
+
}
|
|
27
|
+
function G() {
|
|
28
|
+
V(), l.active = !1, l.highlightRect = null, l.targetEl = null;
|
|
29
|
+
const t = W;
|
|
30
|
+
S = null, W = null, t == null || t();
|
|
31
|
+
}
|
|
32
|
+
function k() {
|
|
33
|
+
V();
|
|
34
|
+
const t = l.config;
|
|
35
|
+
if (t) {
|
|
36
|
+
if (l.stepIndex >= t.steps.length - 1) {
|
|
37
|
+
G();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
l.stepIndex += 1, U();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function ut() {
|
|
44
|
+
k();
|
|
45
|
+
}
|
|
46
|
+
function U() {
|
|
47
|
+
var i;
|
|
48
|
+
const t = q();
|
|
49
|
+
if (!t) {
|
|
50
|
+
G();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
E = t, l.gatePass = !t.gate, l.waitingTarget = !0, l.waitTimedOut = !1, l.highlightRect = null, l.targetEl = null;
|
|
54
|
+
const n = (i = t.beforeEnter) == null ? void 0 : i.call(t);
|
|
55
|
+
n instanceof Promise ? n.then(() => H(t)) : requestAnimationFrame(() => H(t));
|
|
56
|
+
}
|
|
57
|
+
function H(t) {
|
|
58
|
+
if (t.trigger === "auto") {
|
|
59
|
+
l.waitingTarget = !1, gt(t);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (t.trigger === "wait-dom") {
|
|
63
|
+
j(t);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const n = I(t.target);
|
|
67
|
+
if (n) {
|
|
68
|
+
N(n, t);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
J(t.target, () => {
|
|
72
|
+
const i = I(t.target);
|
|
73
|
+
N(i, t);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function I(t) {
|
|
77
|
+
if (S) {
|
|
78
|
+
const n = S(t);
|
|
79
|
+
if (n) return n;
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
return document.querySelector(t);
|
|
83
|
+
} catch {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function N(t, n) {
|
|
88
|
+
if (!t) {
|
|
89
|
+
l.waitTimedOut = !0;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
l.waitingTarget = !1, l.waitTimedOut = !1, l.targetEl = t, P(t), ft(t, n), pt(n), dt(t);
|
|
93
|
+
}
|
|
94
|
+
function P(t) {
|
|
95
|
+
const n = t.getBoundingClientRect(), i = 6;
|
|
96
|
+
let o = {
|
|
97
|
+
top: n.top - i,
|
|
98
|
+
left: n.left - i,
|
|
99
|
+
width: n.width + i * 2,
|
|
100
|
+
height: n.height + i * 2
|
|
101
|
+
};
|
|
102
|
+
const g = E == null ? void 0 : E.expandSelector;
|
|
103
|
+
if (g) {
|
|
104
|
+
const w = document.querySelectorAll(g);
|
|
105
|
+
let R = null;
|
|
106
|
+
for (const h of w)
|
|
107
|
+
if (h.offsetHeight > 0) {
|
|
108
|
+
R = h;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
if (R) {
|
|
112
|
+
const h = R.getBoundingClientRect(), M = Math.min(o.top, h.top - i), y = Math.min(o.left, h.left - i), A = Math.max(o.left + o.width, h.right + i), D = Math.max(o.top + o.height, h.bottom + i);
|
|
113
|
+
o = { top: M, left: y, width: A - y, height: D - M };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
l.highlightRect = o;
|
|
117
|
+
}
|
|
118
|
+
function dt(t) {
|
|
119
|
+
K(), T = () => P(t), window.addEventListener("scroll", T, !0), window.addEventListener("resize", T), C = new ResizeObserver(() => P(t)), C.observe(t), (E == null ? void 0 : E.expandSelector) && (L = new MutationObserver(() => P(t)), L.observe(document.body, { childList: !0, subtree: !0, attributes: !0, attributeFilter: ["style", "class"] }));
|
|
120
|
+
}
|
|
121
|
+
function K() {
|
|
122
|
+
T && (window.removeEventListener("scroll", T, !0), window.removeEventListener("resize", T)), T = null, C == null || C.disconnect(), C = null, L == null || L.disconnect(), L = null;
|
|
123
|
+
}
|
|
124
|
+
function ft(t, n) {
|
|
125
|
+
if (n.trigger === "click") {
|
|
126
|
+
const i = () => {
|
|
127
|
+
t.removeEventListener("click", i);
|
|
128
|
+
const o = n.clickDelay ?? 350;
|
|
129
|
+
n.afterClickWait ? j({ waitForElement: n.afterClickWait, clickDelay: o }) : $ = setTimeout(() => k(), o);
|
|
130
|
+
};
|
|
131
|
+
t.addEventListener("click", i);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function pt(t) {
|
|
135
|
+
if (!t.gate) {
|
|
136
|
+
l.gatePass = !0;
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const n = (i) => I(i);
|
|
140
|
+
l.gatePass = t.gate(n), !l.gatePass && (_ = setInterval(() => {
|
|
141
|
+
t.gate(n) && (l.gatePass = !0, _ && (clearInterval(_), _ = null));
|
|
142
|
+
}, st));
|
|
143
|
+
}
|
|
144
|
+
function j(t) {
|
|
145
|
+
const n = t.waitForElement;
|
|
146
|
+
if (!n) {
|
|
147
|
+
k();
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (I(n)) {
|
|
151
|
+
$ = setTimeout(() => k(), t.clickDelay ?? 300);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
J(n, () => {
|
|
155
|
+
$ = setTimeout(() => k(), t.clickDelay ?? 300);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function J(t, n) {
|
|
159
|
+
let i = !1;
|
|
160
|
+
const o = () => {
|
|
161
|
+
i || (i = !0, m == null || m.disconnect(), m = null, n());
|
|
162
|
+
};
|
|
163
|
+
m = new MutationObserver(() => {
|
|
164
|
+
I(t) && o();
|
|
165
|
+
}), m.observe(document.body, { childList: !0, subtree: !0 }), O = setTimeout(o, rt);
|
|
166
|
+
}
|
|
167
|
+
function gt(t) {
|
|
168
|
+
$ = setTimeout(() => k(), t.autoDelay ?? 600);
|
|
169
|
+
}
|
|
170
|
+
function V() {
|
|
171
|
+
K(), _ && (clearInterval(_), _ = null), m && (m.disconnect(), m = null), O && (clearTimeout(O), O = null), $ && (clearTimeout($), $ = null);
|
|
172
|
+
}
|
|
173
|
+
const ht = {
|
|
174
|
+
key: 0,
|
|
175
|
+
class: "tour-root"
|
|
176
|
+
}, vt = { class: "tp-head" }, mt = {
|
|
177
|
+
key: 0,
|
|
178
|
+
class: "tp-required"
|
|
179
|
+
}, wt = { class: "tp-title" }, xt = { class: "tp-of" }, kt = { class: "tp-content" }, yt = {
|
|
180
|
+
key: 0,
|
|
181
|
+
class: "tp-tip"
|
|
182
|
+
}, bt = {
|
|
183
|
+
key: 1,
|
|
184
|
+
class: "tp-warn"
|
|
185
|
+
}, _t = { class: "tp-foot" }, Tt = {
|
|
186
|
+
key: 0,
|
|
187
|
+
class: "tp-click-hint"
|
|
188
|
+
}, $t = {
|
|
189
|
+
key: 1,
|
|
190
|
+
class: "tp-btns"
|
|
191
|
+
}, Et = {
|
|
192
|
+
key: 2,
|
|
193
|
+
class: "tp-gate"
|
|
194
|
+
}, Ct = {
|
|
195
|
+
key: 2,
|
|
196
|
+
class: "tour-waiting"
|
|
197
|
+
}, Lt = {
|
|
198
|
+
key: 0,
|
|
199
|
+
class: "tg-spin",
|
|
200
|
+
viewBox: "0 0 1024 1024",
|
|
201
|
+
width: "28",
|
|
202
|
+
height: "28",
|
|
203
|
+
fill: "currentColor"
|
|
204
|
+
}, Rt = {
|
|
205
|
+
key: 1,
|
|
206
|
+
viewBox: "0 0 1024 1024",
|
|
207
|
+
width: "28",
|
|
208
|
+
height: "28",
|
|
209
|
+
fill: "#e6a23c"
|
|
210
|
+
}, St = /* @__PURE__ */ et({
|
|
211
|
+
__name: "TourOverlay",
|
|
212
|
+
setup(t) {
|
|
213
|
+
const n = l;
|
|
214
|
+
function i(e) {
|
|
215
|
+
e.key === "Escape" && n.active && B();
|
|
216
|
+
}
|
|
217
|
+
nt(() => n.active, (e) => {
|
|
218
|
+
e ? window.addEventListener("keydown", i) : window.removeEventListener("keydown", i);
|
|
219
|
+
}), lt(() => window.removeEventListener("keydown", i));
|
|
220
|
+
const o = d(() => ct()), g = d(() => n.highlightRect), w = d(() => {
|
|
221
|
+
var e, a;
|
|
222
|
+
return ((e = o.value) == null ? void 0 : e.accent) ?? ((a = n.config) == null ? void 0 : a.accent) ?? "#409eff";
|
|
223
|
+
}), R = d(() => n.stepIndex >= n.totalSteps - 1), h = d(() => {
|
|
224
|
+
const e = o.value;
|
|
225
|
+
return e ? !e.gate && e.trigger === "manual" : !1;
|
|
226
|
+
});
|
|
227
|
+
function M() {
|
|
228
|
+
const e = g.value;
|
|
229
|
+
return e ? {
|
|
230
|
+
top: { left: 0, top: 0, width: "100vw", height: `${Math.max(e.top, 0)}px` },
|
|
231
|
+
bottom: { left: 0, top: `${e.top + e.height}px`, width: "100vw", height: `calc(100vh - ${e.top + e.height}px)` },
|
|
232
|
+
left: { left: 0, top: `${e.top}px`, width: `${Math.max(e.left, 0)}px`, height: `${e.height}px` },
|
|
233
|
+
right: { left: `${e.left + e.width}px`, top: `${e.top}px`, width: `calc(100vw - ${e.left + e.width}px)`, height: `${e.height}px` }
|
|
234
|
+
} : null;
|
|
235
|
+
}
|
|
236
|
+
const y = d(M), A = d(() => {
|
|
237
|
+
var e;
|
|
238
|
+
return ((e = y.value) == null ? void 0 : e.top) ?? { display: "none" };
|
|
239
|
+
}), D = d(() => {
|
|
240
|
+
var e;
|
|
241
|
+
return ((e = y.value) == null ? void 0 : e.bottom) ?? { display: "none" };
|
|
242
|
+
}), Q = d(() => {
|
|
243
|
+
var e;
|
|
244
|
+
return ((e = y.value) == null ? void 0 : e.left) ?? { display: "none" };
|
|
245
|
+
}), X = d(() => {
|
|
246
|
+
var e;
|
|
247
|
+
return ((e = y.value) == null ? void 0 : e.right) ?? { display: "none" };
|
|
248
|
+
}), Y = d(() => {
|
|
249
|
+
const e = g.value;
|
|
250
|
+
return e ? {
|
|
251
|
+
position: "fixed",
|
|
252
|
+
top: `${e.top}px`,
|
|
253
|
+
left: `${e.left}px`,
|
|
254
|
+
width: `${e.width}px`,
|
|
255
|
+
height: `${e.height}px`,
|
|
256
|
+
borderRadius: "8px",
|
|
257
|
+
border: `2px solid ${w.value}`,
|
|
258
|
+
boxShadow: `0 0 0 3px ${w.value}33, 0 0 20px ${w.value}44`,
|
|
259
|
+
pointerEvents: "none",
|
|
260
|
+
transition: "all 0.35s cubic-bezier(0.4,0,0.2,1)"
|
|
261
|
+
} : { display: "none" };
|
|
262
|
+
}), Z = d(() => {
|
|
263
|
+
var F;
|
|
264
|
+
const e = g.value;
|
|
265
|
+
if (!e) return { position: "fixed", top: "50%", left: "50%", transform: "translate(-50%,-50%)" };
|
|
266
|
+
const a = ((F = o.value) == null ? void 0 : F.placement) ?? "bottom", b = 14, f = { position: "fixed", zIndex: 100002 };
|
|
267
|
+
switch (a) {
|
|
268
|
+
case "top":
|
|
269
|
+
return { ...f, left: `${e.left}px`, bottom: `calc(100vh - ${e.top - b}px)`, maxWidth: "420px" };
|
|
270
|
+
case "bottom":
|
|
271
|
+
return { ...f, left: `${e.left}px`, top: `${e.top + e.height + b}px`, maxWidth: "420px" };
|
|
272
|
+
case "left":
|
|
273
|
+
return { ...f, right: `calc(100vw - ${e.left - b}px)`, top: `${e.top}px`, maxWidth: "360px" };
|
|
274
|
+
case "right":
|
|
275
|
+
return { ...f, left: `${e.left + e.width + b}px`, top: `${e.top}px`, maxWidth: "360px" };
|
|
276
|
+
default:
|
|
277
|
+
return { ...f, top: "50%", left: "50%", transform: "translate(-50%,-50%)", maxWidth: "480px" };
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
function z() {
|
|
281
|
+
}
|
|
282
|
+
return (e, a) => {
|
|
283
|
+
var b;
|
|
284
|
+
return r(), ot(it, { to: "body" }, [
|
|
285
|
+
c(n).active ? (r(), u("div", ht, [
|
|
286
|
+
s("div", {
|
|
287
|
+
class: "tour-mask",
|
|
288
|
+
style: x(A.value),
|
|
289
|
+
onClick: z
|
|
290
|
+
}, null, 4),
|
|
291
|
+
s("div", {
|
|
292
|
+
class: "tour-mask",
|
|
293
|
+
style: x(D.value),
|
|
294
|
+
onClick: z
|
|
295
|
+
}, null, 4),
|
|
296
|
+
s("div", {
|
|
297
|
+
class: "tour-mask",
|
|
298
|
+
style: x(Q.value),
|
|
299
|
+
onClick: z
|
|
300
|
+
}, null, 4),
|
|
301
|
+
s("div", {
|
|
302
|
+
class: "tour-mask",
|
|
303
|
+
style: x(X.value),
|
|
304
|
+
onClick: z
|
|
305
|
+
}, null, 4),
|
|
306
|
+
g.value ? (r(), u("div", {
|
|
307
|
+
key: 0,
|
|
308
|
+
class: "tour-highlight",
|
|
309
|
+
style: x(Y.value)
|
|
310
|
+
}, null, 4)) : v("", !0),
|
|
311
|
+
o.value && !c(n).waitingTarget ? (r(), u("div", {
|
|
312
|
+
key: 1,
|
|
313
|
+
class: "tour-popover",
|
|
314
|
+
style: x(Z.value)
|
|
315
|
+
}, [
|
|
316
|
+
s("div", vt, [
|
|
317
|
+
s("span", {
|
|
318
|
+
class: "tp-step-no",
|
|
319
|
+
style: x({ background: w.value })
|
|
320
|
+
}, p(c(n).stepIndex + 1), 5),
|
|
321
|
+
o.value.gate ? (r(), u("span", mt, "*")) : v("", !0),
|
|
322
|
+
s("span", wt, p(o.value.title), 1),
|
|
323
|
+
s("span", xt, "第 " + p(c(n).stepIndex + 1) + " / " + p(c(n).totalSteps) + " 步", 1)
|
|
324
|
+
]),
|
|
325
|
+
s("p", kt, p(o.value.content), 1),
|
|
326
|
+
o.value.tip ? (r(), u("div", yt, "💡 " + p(o.value.tip), 1)) : v("", !0),
|
|
327
|
+
o.value.warn ? (r(), u("div", bt, "⚠️ " + p(o.value.warn), 1)) : v("", !0),
|
|
328
|
+
s("div", _t, [
|
|
329
|
+
s("button", {
|
|
330
|
+
class: "tg-btn tg-btn--link tg-btn--sm",
|
|
331
|
+
onClick: a[0] || (a[0] = (f) => c(B)())
|
|
332
|
+
}, "退出引导"),
|
|
333
|
+
o.value.trigger === "click" ? (r(), u("span", Tt, " 👆 请点击高亮区域 ")) : c(n).gatePass ? (r(), u("span", $t, [
|
|
334
|
+
h.value ? (r(), u("button", {
|
|
335
|
+
key: 0,
|
|
336
|
+
class: "tg-btn tg-btn--sm",
|
|
337
|
+
onClick: a[1] || (a[1] = (f) => c(ut)())
|
|
338
|
+
}, "跳过此步")) : v("", !0),
|
|
339
|
+
s("button", {
|
|
340
|
+
class: "tg-btn tg-btn--primary tg-btn--sm",
|
|
341
|
+
style: x({ background: w.value, borderColor: w.value }),
|
|
342
|
+
onClick: a[2] || (a[2] = (f) => c(k)())
|
|
343
|
+
}, p(R.value ? "完成" : "下一步"), 5)
|
|
344
|
+
])) : (r(), u("span", Et, [
|
|
345
|
+
a[5] || (a[5] = s("svg", {
|
|
346
|
+
class: "tp-gate-icon",
|
|
347
|
+
viewBox: "0 0 1024 1024",
|
|
348
|
+
width: "14",
|
|
349
|
+
height: "14",
|
|
350
|
+
fill: "currentColor"
|
|
351
|
+
}, [
|
|
352
|
+
s("path", { d: "M512 160a96 96 0 0 1 96 96v64H416v-64a96 96 0 0 1 96-96zm0-64a160 160 0 0 0-160 160v64h-32a64 64 0 0 0-64 64v384a64 64 0 0 0 64 64h384a64 64 0 0 0 64-64V384a64 64 0 0 0-64-64h-32v-64A160 160 0 0 0 512 96zM320 448h384v320H320V448z" })
|
|
353
|
+
], -1)),
|
|
354
|
+
at(" " + p(o.value.gateHint || "请先完成本步操作"), 1)
|
|
355
|
+
]))
|
|
356
|
+
])
|
|
357
|
+
], 4)) : v("", !0),
|
|
358
|
+
c(n).waitingTarget ? (r(), u("div", Ct, [
|
|
359
|
+
c(n).waitTimedOut ? (r(), u("svg", Rt, [...a[7] || (a[7] = [
|
|
360
|
+
s("path", { d: "M512 64L64 896h896L512 64zm0 192l288 576H224l288-576zm-32 224v128h64V480h-64zm0 160v64h64v-64h-64z" }, null, -1)
|
|
361
|
+
])])) : (r(), u("svg", Lt, [...a[6] || (a[6] = [
|
|
362
|
+
s("path", {
|
|
363
|
+
d: "M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 64a384 384 0 1 0 0 768 384 384 0 0 0 0-768z",
|
|
364
|
+
opacity: ".25"
|
|
365
|
+
}, null, -1),
|
|
366
|
+
s("path", { d: "M512 64a448 448 0 0 1 448 448h-64A384 384 0 0 0 512 128V64z" }, null, -1)
|
|
367
|
+
])])),
|
|
368
|
+
s("p", null, p(c(n).waitTimedOut ? "未找到目标元素,可能是页面状态不符" : ((b = o.value) == null ? void 0 : b.content) ?? "等待页面加载..."), 1),
|
|
369
|
+
c(n).waitTimedOut ? (r(), u("button", {
|
|
370
|
+
key: 2,
|
|
371
|
+
class: "tg-btn tg-btn--warning tg-btn--sm",
|
|
372
|
+
onClick: a[3] || (a[3] = (f) => c(k)())
|
|
373
|
+
}, "跳过此步")) : v("", !0),
|
|
374
|
+
s("button", {
|
|
375
|
+
class: "tg-btn tg-btn--sm",
|
|
376
|
+
onClick: a[4] || (a[4] = (f) => c(B)())
|
|
377
|
+
}, "退出引导")
|
|
378
|
+
])) : v("", !0)
|
|
379
|
+
])) : v("", !0)
|
|
380
|
+
]);
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
}), It = (t, n) => {
|
|
384
|
+
const i = t.__vccOpts || t;
|
|
385
|
+
for (const [o, g] of n)
|
|
386
|
+
i[o] = g;
|
|
387
|
+
return i;
|
|
388
|
+
}, Ot = /* @__PURE__ */ It(St, [["__scopeId", "data-v-9602901d"]]);
|
|
389
|
+
export {
|
|
390
|
+
Ot as TourOverlay,
|
|
391
|
+
B as abort,
|
|
392
|
+
G as complete,
|
|
393
|
+
k as next,
|
|
394
|
+
ut as skip,
|
|
395
|
+
zt as startTour,
|
|
396
|
+
l as tourState
|
|
397
|
+
};
|
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TourConfig, TourStep, HighlightRect } from './types';
|
|
2
|
+
/** 元素解析器:宿主页面提供,把 target 名解析为 DOM 元素 */
|
|
3
|
+
export type TargetResolver = (target: string) => HTMLElement | null;
|
|
4
|
+
export declare const tourState: import('vue').ShallowReactive<{
|
|
5
|
+
active: boolean;
|
|
6
|
+
config: TourConfig | null;
|
|
7
|
+
stepIndex: number;
|
|
8
|
+
totalSteps: number;
|
|
9
|
+
highlightRect: HighlightRect | null;
|
|
10
|
+
targetEl: HTMLElement | null;
|
|
11
|
+
gatePass: boolean;
|
|
12
|
+
waitingTarget: boolean;
|
|
13
|
+
waitTimedOut: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
/** 获取当前步骤(供组件使用) */
|
|
16
|
+
export declare function currentStep(): TourStep | null;
|
|
17
|
+
export declare function startTour(tour: TourConfig, resolver?: TargetResolver, done?: () => void): void;
|
|
18
|
+
export declare function abort(): void;
|
|
19
|
+
export declare function complete(): void;
|
|
20
|
+
export declare function next(): void;
|
|
21
|
+
export declare function skip(): void;
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.tour-root[data-v-9602901d]{--tg-primary: var(--el-color-primary, #409eff);--tg-success: var(--el-color-success, #67c23a);--tg-warning: var(--el-color-warning, #e6a23c);--tg-danger: var(--el-color-danger, #f56c6c);--tg-text-1: var(--el-text-color-primary, #303133);--tg-text-2: var(--el-text-color-regular, #606266);--tg-text-3: var(--el-text-color-secondary, #909399);--tg-border: var(--el-border-color-lighter, #ebeef5);--tg-fill-light: var(--el-fill-color-light, #f5f7fa);--tg-radius: var(--el-border-radius-base, 4px);position:fixed;top:0;right:0;bottom:0;left:0;z-index:100000;pointer-events:none;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,sans-serif}.tour-mask[data-v-9602901d]{position:fixed;background:#0000008c;transition:all .35s cubic-bezier(.4,0,.2,1);cursor:not-allowed;pointer-events:auto}.tour-highlight[data-v-9602901d]{z-index:100001}.tg-btn[data-v-9602901d]{display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--tg-border);border-radius:var(--tg-radius);background:#fff;color:var(--tg-text-2);font-size:14px;font-weight:500;line-height:1;padding:8px 15px;cursor:pointer;transition:color .2s,border-color .2s,background .2s;outline:none;white-space:nowrap;-webkit-user-select:none;user-select:none}.tg-btn[data-v-9602901d]:hover{color:var(--tg-primary);border-color:var(--tg-primary);background:#ecf5ff}.tg-btn--sm[data-v-9602901d]{padding:5px 11px;font-size:12px}.tg-btn--primary[data-v-9602901d]{background:var(--tg-primary);border-color:var(--tg-primary);color:#fff}.tg-btn--primary[data-v-9602901d]:hover{opacity:.85;background:var(--tg-primary);color:#fff}.tg-btn--warning[data-v-9602901d]{background:var(--tg-warning);border-color:var(--tg-warning);color:#fff}.tg-btn--warning[data-v-9602901d]:hover{opacity:.85;background:var(--tg-warning);color:#fff}.tg-btn--link[data-v-9602901d]{border:none;background:none;padding:4px 6px;color:var(--tg-text-3)}.tg-btn--link[data-v-9602901d]:hover{color:var(--tg-primary);background:none}.tour-popover[data-v-9602901d]{z-index:100002;background:#fff;border-radius:12px;padding:20px 24px;box-shadow:0 8px 40px #0000001f,0 2px 8px #0000000f;animation:tp-in-9602901d .3s ease;pointer-events:auto;min-width:280px;max-width:420px}@keyframes tp-in-9602901d{0%{opacity:0;transform:translateY(6px) scale(.97)}to{opacity:1;transform:translateY(0) scale(1)}}.tp-head[data-v-9602901d]{display:flex;align-items:center;gap:10px;margin-bottom:12px}.tp-step-no[data-v-9602901d]{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:50%;color:#fff;font-size:14px;font-weight:700;flex-shrink:0}.tp-required[data-v-9602901d]{color:var(--tg-danger);font-size:20px;font-weight:700;line-height:1}.tp-title[data-v-9602901d]{font-size:16px;font-weight:700;color:var(--tg-text-1)}.tp-of[data-v-9602901d]{font-size:13px;color:var(--tg-text-3);margin-left:auto;font-variant-numeric:tabular-nums}.tp-content[data-v-9602901d]{margin:0 0 14px;font-size:14px;line-height:1.8;color:var(--tg-text-2);white-space:pre-line}.tp-tip[data-v-9602901d]{font-size:13px;color:#529b2e;background:#f0f9eb;padding:8px 12px;border-radius:6px;margin-bottom:10px;border-left:3px solid #67c23a}.tp-warn[data-v-9602901d]{font-size:13px;color:#b88230;background:#fdf6ec;padding:8px 12px;border-radius:6px;margin-bottom:10px;border-left:3px solid #e6a23c}.tp-foot[data-v-9602901d]{display:flex;align-items:center;justify-content:space-between;padding-top:14px;border-top:1px solid var(--tg-border)}.tp-btns[data-v-9602901d]{display:flex;gap:10px}.tp-gate[data-v-9602901d]{display:inline-flex;align-items:center;gap:5px;font-size:13px;color:var(--tg-warning);font-weight:500}.tp-gate-icon[data-v-9602901d]{flex-shrink:0}.tp-click-hint[data-v-9602901d]{font-size:14px;color:var(--tg-primary);font-weight:500;animation:pulse-hint-9602901d 1.5s ease-in-out infinite}@keyframes pulse-hint-9602901d{0%,to{opacity:1}50%{opacity:.5}}.tour-waiting[data-v-9602901d]{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);z-index:100002;background:#fff;padding:32px 40px;border-radius:12px;box-shadow:0 8px 32px #00000026;text-align:center;pointer-events:auto;display:flex;flex-direction:column;align-items:center;gap:8px}.tour-waiting p[data-v-9602901d]{margin:4px 0 8px;font-size:14px;color:var(--tg-text-2)}.tg-spin[data-v-9602901d]{animation:tg-rotate-9602901d 1s linear infinite}@keyframes tg-rotate-9602901d{0%{transform:rotate(0)}to{transform:rotate(360deg)}}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tour-guide-coach",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "轻量级交互式漫游引导引擎(Vue 3,零外部依赖,Element Plus 风格)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./configs/*": "./src/configs/*.ts"
|
|
16
|
+
},
|
|
17
|
+
"files": ["dist", "src"],
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"vue": "^3.4"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@element-plus/icons-vue": "^2.3.1",
|
|
23
|
+
"@vitejs/plugin-vue": "^5.0",
|
|
24
|
+
"element-plus": "^2.7.5",
|
|
25
|
+
"typescript": "^5.4",
|
|
26
|
+
"vite": "^5.2",
|
|
27
|
+
"vite-plugin-dts": "^5.1.1",
|
|
28
|
+
"vue": "^3.4.27",
|
|
29
|
+
"vue-tsc": "^2.0"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"dev": "cd demo && vite",
|
|
33
|
+
"build": "vite build --config vite.lib.config.ts",
|
|
34
|
+
"build:demo": "cd demo && vite build",
|
|
35
|
+
"typecheck": "vue-tsc --noEmit",
|
|
36
|
+
"prepublishOnly": "npm run build"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"vue",
|
|
40
|
+
"tour",
|
|
41
|
+
"guide",
|
|
42
|
+
"onboarding",
|
|
43
|
+
"interactive-tutorial",
|
|
44
|
+
"driver",
|
|
45
|
+
"spotlight"
|
|
46
|
+
],
|
|
47
|
+
"license": "MIT"
|
|
48
|
+
}
|