vue3-time-playbar 0.1.2 → 0.1.4
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/core/TimeTimeline.vue.d.ts +1 -0
- package/core/index.test.d.ts +1 -0
- package/core/index.vue.d.ts +20 -1
- package/package.json +1 -1
- package/style.css +1 -1
- package/vue3-time-playbar.mjs +351 -320
- package/vue3-time-playbar.umd.cjs +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/core/index.vue.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TimeInput, TickLabelMode, FormatTooltipFn, TimeChangePayload } from './types';
|
|
2
|
+
/***********************Props 与事件*********************/
|
|
2
3
|
interface Props {
|
|
3
4
|
modelValue?: TimeInput;
|
|
4
5
|
startTime: TimeInput;
|
|
@@ -14,6 +15,14 @@ interface Props {
|
|
|
14
15
|
tickLabelMode?: TickLabelMode;
|
|
15
16
|
formatTooltip?: FormatTooltipFn;
|
|
16
17
|
}
|
|
18
|
+
/***********************播放控制*********************/
|
|
19
|
+
declare function togglePlay(): void;
|
|
20
|
+
declare function play(): void;
|
|
21
|
+
declare function pause(): void;
|
|
22
|
+
declare function handlePrev(): void;
|
|
23
|
+
declare function handleNext(): void;
|
|
24
|
+
/** 跳转到指定时间 */
|
|
25
|
+
declare function seekTo(time: TimeInput): void;
|
|
17
26
|
declare function __VLS_template(): {
|
|
18
27
|
attrs: Partial<{}>;
|
|
19
28
|
slots: {
|
|
@@ -27,7 +36,17 @@ declare function __VLS_template(): {
|
|
|
27
36
|
rootEl: HTMLDivElement;
|
|
28
37
|
};
|
|
29
38
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
30
|
-
declare const __VLS_component: import('vue').DefineComponent<Props, {
|
|
39
|
+
declare const __VLS_component: import('vue').DefineComponent<Props, {
|
|
40
|
+
play: typeof play;
|
|
41
|
+
pause: typeof pause;
|
|
42
|
+
togglePlay: typeof togglePlay;
|
|
43
|
+
prev: typeof handlePrev;
|
|
44
|
+
next: typeof handleNext;
|
|
45
|
+
seekTo: typeof seekTo;
|
|
46
|
+
isPlaying: import('vue').Ref<boolean, boolean>;
|
|
47
|
+
currentTime: import('vue').Ref<number, number>;
|
|
48
|
+
speedMultiplier: import('vue').Ref<number, number>;
|
|
49
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
31
50
|
"update:modelValue": (value: number) => any;
|
|
32
51
|
change: (payload: TimeChangePayload) => any;
|
|
33
52
|
}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{
|
package/package.json
CHANGED
package/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.player-controls[data-v-55e12a8d]{display:flex;align-items:center}.player-controls .btn-group[data-v-55e12a8d]{display:flex;align-items:center;gap:6px}.player-controls .control-btn[data-v-55e12a8d]{background:#ffffff1a;border:1px solid rgba(255,255,255,.15);border-radius:50%;width:32px;height:32px;display:flex;align-items:center;justify-content:center;color:#fffc;cursor:pointer;transition:background .2s,border-color .2s,transform .15s}.player-controls .control-btn[data-v-55e12a8d]:hover{background:#fff3;border-color:#fff6;color:#fff;transform:scale(1.08)}.player-controls .control-btn[data-v-55e12a8d]:active{transform:scale(.95)}.player-controls .control-btn svg[data-v-55e12a8d]{width:14px;height:14px}.player-controls .control-btn.play-btn[data-v-55e12a8d]{width:40px;height:40px;background:#409eff;border-color:transparent;color:#fff}.player-controls .control-btn.play-btn[data-v-55e12a8d]:hover{background:#66b1ff}.player-controls .control-btn.play-btn svg[data-v-55e12a8d]{width:16px;height:16px}.time-timeline[data-v-
|
|
1
|
+
.player-controls[data-v-55e12a8d]{display:flex;align-items:center}.player-controls .btn-group[data-v-55e12a8d]{display:flex;align-items:center;gap:6px}.player-controls .control-btn[data-v-55e12a8d]{background:#ffffff1a;border:1px solid rgba(255,255,255,.15);border-radius:50%;width:32px;height:32px;display:flex;align-items:center;justify-content:center;color:#fffc;cursor:pointer;transition:background .2s,border-color .2s,transform .15s}.player-controls .control-btn[data-v-55e12a8d]:hover{background:#fff3;border-color:#fff6;color:#fff;transform:scale(1.08)}.player-controls .control-btn[data-v-55e12a8d]:active{transform:scale(.95)}.player-controls .control-btn svg[data-v-55e12a8d]{width:14px;height:14px}.player-controls .control-btn.play-btn[data-v-55e12a8d]{width:40px;height:40px;background:#409eff;border-color:transparent;color:#fff}.player-controls .control-btn.play-btn[data-v-55e12a8d]:hover{background:#66b1ff}.player-controls .control-btn.play-btn svg[data-v-55e12a8d]{width:16px;height:16px}.time-timeline[data-v-0f78dcee]{position:relative;width:100%;height:52px;cursor:pointer}.time-timeline .handle-group[data-v-0f78dcee]{position:absolute;left:0;top:0;width:0;height:100%;z-index:20;pointer-events:none;transition:transform .2s ease-out;will-change:transform}.time-timeline .handle-group.dragging[data-v-0f78dcee]{transition:none}.time-timeline .handle-group .floating-tooltip[data-v-0f78dcee]{position:absolute;top:-33px;left:0;transform:translate(-50%);background:#409eff;color:#fff;padding:5px 10px;border-radius:50px;font-size:14px;font-weight:500;white-space:nowrap;box-shadow:0 2px 6px #0000004d;pointer-events:auto;cursor:grab}.time-timeline .handle-group .floating-tooltip[data-v-0f78dcee]:active{cursor:grabbing}.time-timeline .handle-group .floating-tooltip[data-v-0f78dcee]:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);border:4px solid transparent;border-top-color:#409eff}.time-timeline .handle-group .handle-visual[data-v-0f78dcee]{position:absolute;top:10px;left:0;transform:translate(-50%,-50%);width:8px;height:8px;background:#fff;border-radius:50%;border:2px solid #409eff;box-shadow:0 0 0 3px #409eff40}.time-timeline .scroll-container[data-v-0f78dcee]{width:100%;height:100%;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}.time-timeline .scroll-container[data-v-0f78dcee]::-webkit-scrollbar{display:none}.time-timeline .timeline-inner[data-v-0f78dcee]{position:relative;min-width:100%;height:100%}.time-timeline .track-bg[data-v-0f78dcee]{position:absolute;top:8px;height:4px;background:#ffffff2e;border-radius:2px}.time-timeline .track-active[data-v-0f78dcee]{position:absolute;top:8px;height:4px;background:#409eff;border-radius:2px;pointer-events:none;transition:width .15s ease-out;z-index:2}.time-timeline .ticks-container[data-v-0f78dcee]{position:absolute;top:0;bottom:0;pointer-events:none}.time-timeline .tick-item[data-v-0f78dcee]{position:absolute;top:0;transform:translate(-50%);display:flex;flex-direction:column;align-items:center}.time-timeline .tick-item .tick-mark[data-v-0f78dcee]{margin-top:14px;width:1px;height:5px;background:#ffffff59;flex-shrink:0}.time-timeline .tick-item .tick-label[data-v-0f78dcee]{margin-top:2px;font-size:11px;color:#fff9;line-height:1}.time-timeline .tick-item .day-label[data-v-0f78dcee]{margin-top:3px;font-size:11px;font-weight:600;color:#ffffffe6;white-space:nowrap;line-height:1}.time-timeline .tick-item.is-day-boundary .tick-mark[data-v-0f78dcee]{margin-top:14px;width:2px;height:18px;background:#fffc}.speed-selector[data-v-30c5e152]{flex-shrink:0;margin-left:10px;padding-left:10px;border-left:1px solid rgba(255,255,255,.12);position:relative}.speed-selector .speed-trigger[data-v-30c5e152]{display:inline-flex;align-items:center;gap:4px;min-width:36px;height:28px;padding:0 8px;background:#ffffff1a;border:1px solid rgba(255,255,255,.15);border-radius:4px;color:#fffc;font-size:13px;font-weight:500;cursor:pointer;transition:background .2s,border-color .2s,color .2s}.speed-selector .speed-trigger[data-v-30c5e152]:hover{background:#fff3;border-color:#fff6;color:#fff}.speed-selector .speed-trigger .arrow-icon[data-v-30c5e152]{width:10px;height:10px;transition:transform .2s}.speed-selector .speed-trigger .arrow-icon.open[data-v-30c5e152]{transform:rotate(180deg)}.speed-selector .speed-dropdown[data-v-30c5e152]{position:absolute;left:16px;min-width:56px;background:#083082f2;border:1px solid rgba(255,255,255,.2);border-radius:4px;padding:4px 0;box-shadow:0 4px 12px #0006;z-index:30}.speed-selector .speed-dropdown.is-up[data-v-30c5e152]{bottom:calc(100% + 6px)}.speed-selector .speed-dropdown.is-down[data-v-30c5e152]{top:calc(100% + 6px)}.speed-selector .speed-dropdown .speed-option[data-v-30c5e152]{padding:6px 12px;font-size:13px;color:#ffffffb3;cursor:pointer;text-align:center;transition:background .15s,color .15s}.speed-selector .speed-dropdown .speed-option[data-v-30c5e152]:hover{background:#ffffff26;color:#fff}.speed-selector .speed-dropdown .speed-option.active[data-v-30c5e152]{color:#409eff;font-weight:600}.dropdown-up-enter-active[data-v-30c5e152],.dropdown-up-leave-active[data-v-30c5e152]{transition:opacity .15s,transform .15s}.dropdown-up-enter-from[data-v-30c5e152],.dropdown-up-leave-to[data-v-30c5e152]{opacity:0;transform:translateY(4px)}.dropdown-down-enter-active[data-v-30c5e152],.dropdown-down-leave-active[data-v-30c5e152]{transition:opacity .15s,transform .15s}.dropdown-down-enter-from[data-v-30c5e152],.dropdown-down-leave-to[data-v-30c5e152]{opacity:0;transform:translateY(-4px)}.g-time-player[data-v-55b5dfa2]{display:flex;align-items:center;width:100%;height:72px;filter:drop-shadow(rgba(0,0,0,.8) 0px 0px 2px);background:#083082aa;box-shadow:0 0 16px #0193fa99 inset;border-radius:4px;padding:0 24px;box-sizing:border-box;color:#fff;-webkit-user-select:none;user-select:none;box-shadow:0 4px 20px #00000059}.g-time-player .controls-wrapper[data-v-55b5dfa2]{flex-shrink:0;margin-right:10px;border-right:1px solid rgba(255,255,255,.12);padding-right:10px}.g-time-player .timeline-wrapper[data-v-55b5dfa2]{flex:1;min-width:0;height:100%;display:flex;align-items:center;overflow:visible;position:relative}
|
package/vue3-time-playbar.mjs
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as ne, openBlock as b, createElementBlock as $, createElementVNode as u, renderSlot as X, useTemplateRef as fe, ref as V, computed as f, watch as B, onMounted as Te, nextTick as me, onUnmounted as ye, withDirectives as Ie, normalizeStyle as W, normalizeClass as U, withModifiers as pe, toDisplayString as j, vShow as _e, Fragment as xe, renderList as we, createCommentVNode as ge, createVNode as ee, Transition as Be, withCtx as te, createSlots as He } from "vue";
|
|
2
|
+
const Ne = { class: "player-controls" }, Ae = { class: "btn-group" }, We = ["title"], Fe = {
|
|
3
3
|
key: 0,
|
|
4
4
|
viewBox: "0 0 24 24",
|
|
5
5
|
fill: "currentColor",
|
|
6
6
|
stroke: "none"
|
|
7
|
-
},
|
|
7
|
+
}, Xe = {
|
|
8
8
|
key: 1,
|
|
9
9
|
viewBox: "0 0 24 24",
|
|
10
10
|
fill: "currentColor",
|
|
11
11
|
stroke: "none"
|
|
12
|
-
},
|
|
12
|
+
}, ze = /* @__PURE__ */ ne({
|
|
13
13
|
__name: "PlayerControls",
|
|
14
14
|
props: {
|
|
15
15
|
isPlaying: { type: Boolean }
|
|
16
16
|
},
|
|
17
17
|
emits: ["toggle-play", "prev", "next"],
|
|
18
18
|
setup(e) {
|
|
19
|
-
return (
|
|
20
|
-
u("div",
|
|
19
|
+
return (n, a) => (b(), $("div", Ne, [
|
|
20
|
+
u("div", Ae, [
|
|
21
21
|
u("button", {
|
|
22
22
|
class: "control-btn",
|
|
23
|
-
onClick:
|
|
23
|
+
onClick: a[0] || (a[0] = (t) => n.$emit("prev")),
|
|
24
24
|
title: "上一时刻"
|
|
25
25
|
}, [
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
X(n.$slots, "prev", {}, () => [
|
|
27
|
+
a[3] || (a[3] = u("svg", {
|
|
28
28
|
viewBox: "0 0 24 24",
|
|
29
29
|
fill: "none",
|
|
30
30
|
stroke: "currentColor",
|
|
@@ -44,11 +44,11 @@ const _e = { class: "player-controls" }, Be = { class: "btn-group" }, He = ["tit
|
|
|
44
44
|
]),
|
|
45
45
|
u("button", {
|
|
46
46
|
class: "control-btn play-btn",
|
|
47
|
-
onClick:
|
|
47
|
+
onClick: a[1] || (a[1] = (t) => n.$emit("toggle-play")),
|
|
48
48
|
title: e.isPlaying ? "暂停" : "播放"
|
|
49
49
|
}, [
|
|
50
|
-
|
|
51
|
-
e.isPlaying ? (
|
|
50
|
+
X(n.$slots, "play", { isPlaying: e.isPlaying }, () => [
|
|
51
|
+
e.isPlaying ? (b(), $("svg", Xe, [...a[5] || (a[5] = [
|
|
52
52
|
u("rect", {
|
|
53
53
|
x: "6",
|
|
54
54
|
y: "4",
|
|
@@ -63,18 +63,18 @@ const _e = { class: "player-controls" }, Be = { class: "btn-group" }, He = ["tit
|
|
|
63
63
|
height: "16",
|
|
64
64
|
rx: "1"
|
|
65
65
|
}, null, -1)
|
|
66
|
-
])])) : (
|
|
66
|
+
])])) : (b(), $("svg", Fe, [...a[4] || (a[4] = [
|
|
67
67
|
u("polygon", { points: "5 3 19 12 5 21 5 3" }, null, -1)
|
|
68
68
|
])]))
|
|
69
69
|
], !0)
|
|
70
|
-
], 8,
|
|
70
|
+
], 8, We),
|
|
71
71
|
u("button", {
|
|
72
72
|
class: "control-btn",
|
|
73
|
-
onClick:
|
|
73
|
+
onClick: a[2] || (a[2] = (t) => n.$emit("next")),
|
|
74
74
|
title: "下一时刻"
|
|
75
75
|
}, [
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
X(n.$slots, "next", {}, () => [
|
|
77
|
+
a[6] || (a[6] = u("svg", {
|
|
78
78
|
viewBox: "0 0 24 24",
|
|
79
79
|
fill: "none",
|
|
80
80
|
stroke: "currentColor",
|
|
@@ -95,90 +95,90 @@ const _e = { class: "player-controls" }, Be = { class: "btn-group" }, He = ["tit
|
|
|
95
95
|
])
|
|
96
96
|
]));
|
|
97
97
|
}
|
|
98
|
-
}),
|
|
99
|
-
const
|
|
100
|
-
for (const [t,
|
|
101
|
-
|
|
102
|
-
return
|
|
103
|
-
},
|
|
104
|
-
function
|
|
98
|
+
}), le = (e, n) => {
|
|
99
|
+
const a = e.__vccOpts || e;
|
|
100
|
+
for (const [t, d] of n)
|
|
101
|
+
a[t] = d;
|
|
102
|
+
return a;
|
|
103
|
+
}, Oe = /* @__PURE__ */ le(ze, [["__scopeId", "data-v-55e12a8d"]]), Ge = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
|
|
104
|
+
function x(e) {
|
|
105
105
|
if (typeof e == "number") return e;
|
|
106
106
|
if (e instanceof Date) return e.getTime();
|
|
107
|
-
const
|
|
108
|
-
return Number.isNaN(
|
|
107
|
+
const n = Date.parse(e);
|
|
108
|
+
return Number.isNaN(n) ? (console.warn(`[GTimePlayer] 无法解析时间: "${e}"`), 0) : n;
|
|
109
109
|
}
|
|
110
|
-
function K(e,
|
|
111
|
-
return String(e).padStart(
|
|
110
|
+
function K(e, n = 2) {
|
|
111
|
+
return String(e).padStart(n, "0");
|
|
112
112
|
}
|
|
113
|
-
function
|
|
113
|
+
function Ue(e) {
|
|
114
114
|
return new Date(e).getHours();
|
|
115
115
|
}
|
|
116
|
-
function
|
|
116
|
+
function je(e) {
|
|
117
117
|
return new Date(e).getDay();
|
|
118
118
|
}
|
|
119
|
-
function
|
|
120
|
-
return
|
|
119
|
+
function be(e) {
|
|
120
|
+
return Ge[je(e)] ?? "";
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function Ke(e) {
|
|
123
123
|
return K(new Date(e).getHours());
|
|
124
124
|
}
|
|
125
|
-
function
|
|
126
|
-
const
|
|
127
|
-
return `${
|
|
125
|
+
function $e(e) {
|
|
126
|
+
const n = new Date(e);
|
|
127
|
+
return `${n.getMonth() + 1}月${n.getDate()}日`;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
130
|
-
const
|
|
131
|
-
return `${K(
|
|
129
|
+
function Ye(e) {
|
|
130
|
+
const n = new Date(e);
|
|
131
|
+
return `${K(n.getHours())}:${K(n.getMinutes())}`;
|
|
132
132
|
}
|
|
133
|
-
function
|
|
134
|
-
return `${
|
|
133
|
+
function qe(e) {
|
|
134
|
+
return `${$e(e)} ${be(e)} ${Ye(e)}`;
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
const
|
|
138
|
-
return `${
|
|
136
|
+
function ke(e) {
|
|
137
|
+
const n = new Date(e);
|
|
138
|
+
return `${n.getFullYear()}${K(n.getMonth() + 1)}${K(n.getDate())}`;
|
|
139
139
|
}
|
|
140
|
-
function
|
|
141
|
-
return `${
|
|
140
|
+
function Je(e) {
|
|
141
|
+
return `${$e(e)} ${be(e)}`;
|
|
142
142
|
}
|
|
143
|
-
function
|
|
144
|
-
return e +
|
|
143
|
+
function F(e, n) {
|
|
144
|
+
return e + n * 36e5;
|
|
145
145
|
}
|
|
146
|
-
function
|
|
147
|
-
return (
|
|
146
|
+
function mt(e, n) {
|
|
147
|
+
return (x(n) - x(e)) / 36e5;
|
|
148
148
|
}
|
|
149
|
-
function
|
|
150
|
-
const
|
|
151
|
-
return
|
|
149
|
+
function Qe(e) {
|
|
150
|
+
const n = new Date(e);
|
|
151
|
+
return n.setHours(24, 0, 0, 0), n.getTime();
|
|
152
152
|
}
|
|
153
|
-
function
|
|
153
|
+
function Le(e, n) {
|
|
154
154
|
if (e.length === 0) return -1;
|
|
155
155
|
if (e.length === 1) return 0;
|
|
156
|
-
let
|
|
157
|
-
if (
|
|
158
|
-
if (
|
|
159
|
-
for (;
|
|
160
|
-
const
|
|
161
|
-
if (
|
|
162
|
-
|
|
156
|
+
let a = 0, t = e.length - 1;
|
|
157
|
+
if (n <= e[a]) return a;
|
|
158
|
+
if (n >= e[t]) return t;
|
|
159
|
+
for (; a <= t; ) {
|
|
160
|
+
const d = a + t >>> 1, p = e[d];
|
|
161
|
+
if (p === n) return d;
|
|
162
|
+
p < n ? a = d + 1 : t = d - 1;
|
|
163
163
|
}
|
|
164
|
-
return
|
|
164
|
+
return a >= e.length ? t : t < 0 || Math.abs(e[a] - n) < Math.abs(e[t] - n) ? a : t;
|
|
165
165
|
}
|
|
166
|
-
function
|
|
167
|
-
let
|
|
168
|
-
for (;
|
|
169
|
-
const
|
|
170
|
-
if (
|
|
171
|
-
|
|
166
|
+
function pt(e, n) {
|
|
167
|
+
let a = 0, t = e.length - 1;
|
|
168
|
+
for (; a <= t; ) {
|
|
169
|
+
const d = a + t >>> 1, p = e[d];
|
|
170
|
+
if (p === n) return d;
|
|
171
|
+
p < n ? a = d + 1 : t = d - 1;
|
|
172
172
|
}
|
|
173
173
|
return -1;
|
|
174
174
|
}
|
|
175
|
-
const
|
|
175
|
+
const Ze = {
|
|
176
176
|
key: 0,
|
|
177
177
|
class: "tick-label"
|
|
178
|
-
},
|
|
178
|
+
}, et = {
|
|
179
179
|
key: 1,
|
|
180
180
|
class: "day-label"
|
|
181
|
-
},
|
|
181
|
+
}, tt = 35, nt = 35, lt = /* @__PURE__ */ ne({
|
|
182
182
|
__name: "TimeTimeline",
|
|
183
183
|
props: {
|
|
184
184
|
modelValue: {},
|
|
@@ -190,225 +190,228 @@ const Qe = {
|
|
|
190
190
|
formatTooltip: {}
|
|
191
191
|
},
|
|
192
192
|
emits: ["update:modelValue", "change", "playing-pause"],
|
|
193
|
-
setup(e, { emit:
|
|
194
|
-
const
|
|
195
|
-
let
|
|
196
|
-
const
|
|
197
|
-
const
|
|
198
|
-
if (
|
|
199
|
-
const
|
|
200
|
-
let m =
|
|
201
|
-
for (; m <=
|
|
202
|
-
const
|
|
203
|
-
let
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
-
else if (
|
|
207
|
-
const
|
|
208
|
-
(
|
|
193
|
+
setup(e, { emit: n }) {
|
|
194
|
+
const a = [2, 8, 14, 20], t = e, d = n, p = fe("timelineRef"), c = fe("scrollRef"), z = fe("innerRef"), w = V(0), P = V(0), i = V(0);
|
|
195
|
+
let y = !1, g = 0, T = !1, S = !1, R = null;
|
|
196
|
+
const L = V(!1), H = f(() => {
|
|
197
|
+
const o = x(t.startTime), s = x(t.endTime), r = s - o;
|
|
198
|
+
if (r <= 0) return [];
|
|
199
|
+
const D = [];
|
|
200
|
+
let m = o;
|
|
201
|
+
for (; m <= s; ) {
|
|
202
|
+
const E = (m - o) / r * 100, C = Ue(m), _ = D.length === 0, ce = ke(m), de = _ ? null : ke(D[D.length - 1].time), Z = !_ && de !== ce || _ && C === 0;
|
|
203
|
+
let N = !1;
|
|
204
|
+
if (C === 0)
|
|
205
|
+
N = !0;
|
|
206
|
+
else if (_) {
|
|
207
|
+
const A = Qe(m);
|
|
208
|
+
(F(m, t.interval) > A || s < A) && (N = !0);
|
|
209
209
|
}
|
|
210
|
-
const
|
|
211
|
-
|
|
210
|
+
const ve = C === 0 && N ? !1 : t.tickLabelMode === "all" || a.includes(C);
|
|
211
|
+
D.push({
|
|
212
212
|
time: m,
|
|
213
|
-
percent:
|
|
214
|
-
label:
|
|
215
|
-
showLabel:
|
|
216
|
-
dayLabel:
|
|
217
|
-
showDayLabel:
|
|
218
|
-
isDayBoundary:
|
|
219
|
-
}), m =
|
|
213
|
+
percent: E,
|
|
214
|
+
label: Ke(m),
|
|
215
|
+
showLabel: ve,
|
|
216
|
+
dayLabel: Je(m),
|
|
217
|
+
showDayLabel: N,
|
|
218
|
+
isDayBoundary: Z
|
|
219
|
+
}), m = F(m, t.interval);
|
|
220
220
|
}
|
|
221
|
-
return
|
|
222
|
-
}),
|
|
223
|
-
const
|
|
224
|
-
return
|
|
225
|
-
}),
|
|
226
|
-
left:
|
|
227
|
-
width:
|
|
228
|
-
})),
|
|
229
|
-
left:
|
|
230
|
-
width:
|
|
231
|
-
})),
|
|
232
|
-
const
|
|
233
|
-
return
|
|
234
|
-
}),
|
|
235
|
-
left:
|
|
236
|
-
width:
|
|
237
|
-
})),
|
|
238
|
-
const
|
|
239
|
-
return t.formatTooltip ? t.formatTooltip(
|
|
240
|
-
}),
|
|
241
|
-
transform: `translateX(${
|
|
221
|
+
return D;
|
|
222
|
+
}), oe = f(() => H.value.map((o) => o.time)), ae = f(() => t.minTickSpacing !== void 0 ? t.minTickSpacing : t.tickLabelMode === "major" ? 5 : 15), Y = f(() => {
|
|
223
|
+
const o = H.value.length;
|
|
224
|
+
return o < 2 ? w.value || 0 : (o - 1) * ae.value;
|
|
225
|
+
}), I = f(() => Y.value > w.value && w.value > 0), M = f(() => I.value ? tt : nt), h = f(() => I.value ? Y.value : Math.max(0, w.value - M.value * 2)), O = f(() => h.value + M.value * 2), q = f(() => w.value && I.value ? O.value + "px" : "100%"), J = f(() => ({
|
|
226
|
+
left: M.value + "px",
|
|
227
|
+
width: h.value + "px"
|
|
228
|
+
})), ie = f(() => ({
|
|
229
|
+
left: M.value + "px",
|
|
230
|
+
width: h.value + "px"
|
|
231
|
+
})), l = f(() => {
|
|
232
|
+
const o = x(t.startTime), s = x(t.endTime), r = x(t.modelValue);
|
|
233
|
+
return r <= o ? 0 : r >= s ? 100 : (r - o) / (s - o) * 100;
|
|
234
|
+
}), v = f(() => ({
|
|
235
|
+
left: M.value + "px",
|
|
236
|
+
width: l.value / 100 * h.value + "px"
|
|
237
|
+
})), k = f(() => {
|
|
238
|
+
const o = x(t.modelValue);
|
|
239
|
+
return t.formatTooltip ? t.formatTooltip(o) : qe(o);
|
|
240
|
+
}), re = f(() => M.value + l.value / 100 * h.value - i.value), De = f(() => re.value > -50 && re.value < w.value + 50), Me = f(() => ({
|
|
241
|
+
transform: `translateX(${re.value}px)`
|
|
242
242
|
}));
|
|
243
|
-
function
|
|
244
|
-
|
|
243
|
+
function Q() {
|
|
244
|
+
g && (cancelAnimationFrame(g), g = 0), T = !1;
|
|
245
|
+
}
|
|
246
|
+
function Se() {
|
|
247
|
+
c.value && (P.value = c.value.scrollLeft, T || (i.value = c.value.scrollLeft));
|
|
245
248
|
}
|
|
246
|
-
function
|
|
247
|
-
!
|
|
249
|
+
function Ce(o) {
|
|
250
|
+
!c.value || !I.value || (c.value.scrollLeft += o.deltaY || o.deltaX);
|
|
248
251
|
}
|
|
249
|
-
function
|
|
250
|
-
if (!
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
const
|
|
254
|
-
if (
|
|
255
|
-
|
|
252
|
+
function G(o = !1) {
|
|
253
|
+
if (!I.value || !c.value || y) return;
|
|
254
|
+
const s = M.value + l.value / 100 * h.value, r = w.value, D = O.value - r, m = Math.max(0, Math.min(s - r / 2, D));
|
|
255
|
+
i.value = m;
|
|
256
|
+
const E = c.value;
|
|
257
|
+
if (o || Math.abs(E.scrollLeft - m) < 1) {
|
|
258
|
+
E.scrollLeft = m, P.value = m;
|
|
256
259
|
return;
|
|
257
260
|
}
|
|
258
|
-
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
const
|
|
262
|
-
function
|
|
263
|
-
const
|
|
264
|
-
|
|
261
|
+
Q();
|
|
262
|
+
const C = E.scrollLeft, _ = m - C;
|
|
263
|
+
T = !0;
|
|
264
|
+
const ce = 200, de = performance.now();
|
|
265
|
+
function Z(N) {
|
|
266
|
+
const ve = N - de, A = Math.min(ve / ce, 1), he = 1 - (1 - A) * (1 - A);
|
|
267
|
+
E.scrollLeft = C + _ * he, P.value = E.scrollLeft, A < 1 ? g = requestAnimationFrame(Z) : (g = 0, T = !1);
|
|
265
268
|
}
|
|
266
|
-
|
|
269
|
+
g = requestAnimationFrame(Z);
|
|
267
270
|
}
|
|
268
|
-
|
|
269
|
-
function
|
|
270
|
-
if (!
|
|
271
|
-
const
|
|
272
|
-
return
|
|
271
|
+
B(l, () => G()), B(w, () => G());
|
|
272
|
+
function se(o) {
|
|
273
|
+
if (!c.value) return x(t.startTime);
|
|
274
|
+
const s = c.value.getBoundingClientRect(), r = c.value.scrollLeft, m = o.clientX - s.left + r - M.value, E = Math.max(0, Math.min(m, h.value)), C = x(t.startTime), _ = x(t.endTime);
|
|
275
|
+
return C + (_ - C) * (E / (h.value || 1));
|
|
273
276
|
}
|
|
274
|
-
function
|
|
275
|
-
const
|
|
276
|
-
if (
|
|
277
|
-
const
|
|
278
|
-
return { time: r
|
|
277
|
+
function Ve(o) {
|
|
278
|
+
const s = oe.value;
|
|
279
|
+
if (s.length === 0) return { time: o, index: -1 };
|
|
280
|
+
const r = Le(s, o);
|
|
281
|
+
return { time: s[r] ?? o, index: r };
|
|
279
282
|
}
|
|
280
|
-
function
|
|
281
|
-
const { time:
|
|
282
|
-
|
|
283
|
+
function ue(o) {
|
|
284
|
+
const { time: s, index: r } = Ve(o);
|
|
285
|
+
s !== x(t.modelValue) && (d("update:modelValue", s), d("change", s, r));
|
|
283
286
|
}
|
|
284
|
-
function
|
|
285
|
-
if (
|
|
286
|
-
|
|
287
|
+
function Pe(o) {
|
|
288
|
+
if (S) {
|
|
289
|
+
S = !1;
|
|
287
290
|
return;
|
|
288
291
|
}
|
|
289
|
-
|
|
292
|
+
ue(se(o));
|
|
290
293
|
}
|
|
291
|
-
function
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
const
|
|
295
|
-
Math.abs(m.clientX -
|
|
296
|
-
},
|
|
297
|
-
|
|
294
|
+
function Ee(o) {
|
|
295
|
+
const s = o.clientX;
|
|
296
|
+
S = !1, y = !0, Q(), d("playing-pause");
|
|
297
|
+
const r = (m) => {
|
|
298
|
+
Math.abs(m.clientX - s) > 3 && (S = !0), ue(se(m));
|
|
299
|
+
}, D = () => {
|
|
300
|
+
y = !1, document.removeEventListener("mousemove", r), document.removeEventListener("mouseup", D), me(() => G());
|
|
298
301
|
};
|
|
299
|
-
document.addEventListener("mousemove",
|
|
302
|
+
document.addEventListener("mousemove", r), document.addEventListener("mouseup", D);
|
|
300
303
|
}
|
|
301
|
-
function
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
},
|
|
306
|
-
|
|
304
|
+
function Re(o) {
|
|
305
|
+
y = !0, Q(), S = !1, L.value = !0, document.body.style.cursor = "grabbing", d("playing-pause");
|
|
306
|
+
const s = (D) => {
|
|
307
|
+
S = !0, ue(se(D));
|
|
308
|
+
}, r = () => {
|
|
309
|
+
y = !1, L.value = !1, document.body.style.cursor = "", document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", r), me(() => G());
|
|
307
310
|
};
|
|
308
|
-
document.addEventListener("mousemove",
|
|
311
|
+
document.addEventListener("mousemove", s), document.addEventListener("mouseup", r);
|
|
309
312
|
}
|
|
310
|
-
return
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}),
|
|
314
|
-
}),
|
|
315
|
-
|
|
316
|
-
}), (
|
|
313
|
+
return Te(() => {
|
|
314
|
+
c.value && (w.value = c.value.clientWidth, R = new ResizeObserver((o) => {
|
|
315
|
+
o[0] && (w.value = o[0].contentRect.width);
|
|
316
|
+
}), R.observe(c.value)), me(() => G());
|
|
317
|
+
}), ye(() => {
|
|
318
|
+
Q(), R == null || R.disconnect();
|
|
319
|
+
}), (o, s) => (b(), $("div", {
|
|
317
320
|
class: "time-timeline",
|
|
318
321
|
ref_key: "timelineRef",
|
|
319
|
-
ref:
|
|
322
|
+
ref: p
|
|
320
323
|
}, [
|
|
321
|
-
|
|
322
|
-
class:
|
|
323
|
-
style:
|
|
324
|
+
Ie(u("div", {
|
|
325
|
+
class: U(["handle-group", { dragging: L.value }]),
|
|
326
|
+
style: W(Me.value)
|
|
324
327
|
}, [
|
|
325
328
|
u("div", {
|
|
326
329
|
class: "floating-tooltip",
|
|
327
|
-
onMousedown:
|
|
328
|
-
},
|
|
329
|
-
|
|
330
|
+
onMousedown: pe(Re, ["prevent", "stop"])
|
|
331
|
+
}, j(k.value), 33),
|
|
332
|
+
s[0] || (s[0] = u("div", { class: "handle-visual" }, null, -1))
|
|
330
333
|
], 6), [
|
|
331
|
-
[
|
|
334
|
+
[_e, De.value]
|
|
332
335
|
]),
|
|
333
336
|
u("div", {
|
|
334
337
|
class: "scroll-container",
|
|
335
338
|
ref_key: "scrollRef",
|
|
336
|
-
ref:
|
|
337
|
-
onScroll:
|
|
338
|
-
onWheel:
|
|
339
|
+
ref: c,
|
|
340
|
+
onScroll: Se,
|
|
341
|
+
onWheel: pe(Ce, ["prevent"])
|
|
339
342
|
}, [
|
|
340
343
|
u("div", {
|
|
341
344
|
class: "timeline-inner",
|
|
342
345
|
ref_key: "innerRef",
|
|
343
|
-
ref:
|
|
344
|
-
style:
|
|
345
|
-
onMousedown:
|
|
346
|
-
onClick:
|
|
346
|
+
ref: z,
|
|
347
|
+
style: W({ width: q.value }),
|
|
348
|
+
onMousedown: pe(Ee, ["prevent"]),
|
|
349
|
+
onClick: Pe
|
|
347
350
|
}, [
|
|
348
351
|
u("div", {
|
|
349
352
|
class: "track-bg",
|
|
350
|
-
style:
|
|
353
|
+
style: W(J.value)
|
|
351
354
|
}, null, 4),
|
|
352
355
|
u("div", {
|
|
353
356
|
class: "track-active",
|
|
354
|
-
style:
|
|
357
|
+
style: W(v.value)
|
|
355
358
|
}, null, 4),
|
|
356
359
|
u("div", {
|
|
357
360
|
class: "ticks-container",
|
|
358
|
-
style:
|
|
361
|
+
style: W(ie.value)
|
|
359
362
|
}, [
|
|
360
|
-
(
|
|
361
|
-
key:
|
|
362
|
-
class:
|
|
363
|
-
style:
|
|
363
|
+
(b(!0), $(xe, null, we(H.value, (r) => (b(), $("div", {
|
|
364
|
+
key: r.time,
|
|
365
|
+
class: U(["tick-item", { "is-day-boundary": r.isDayBoundary }]),
|
|
366
|
+
style: W({ left: r.percent + "%" })
|
|
364
367
|
}, [
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
+
s[1] || (s[1] = u("div", { class: "tick-mark" }, null, -1)),
|
|
369
|
+
r.showLabel ? (b(), $("div", Ze, j(r.label), 1)) : ge("", !0),
|
|
370
|
+
r.showDayLabel ? (b(), $("div", et, j(r.dayLabel), 1)) : ge("", !0)
|
|
368
371
|
], 6))), 128))
|
|
369
372
|
], 4)
|
|
370
373
|
], 36)
|
|
371
374
|
], 544)
|
|
372
375
|
], 512));
|
|
373
376
|
}
|
|
374
|
-
}),
|
|
377
|
+
}), ot = /* @__PURE__ */ le(lt, [["__scopeId", "data-v-0f78dcee"]]), at = { class: "speed-value" }, it = ["onClick"], rt = /* @__PURE__ */ ne({
|
|
375
378
|
__name: "SpeedSelector",
|
|
376
379
|
props: {
|
|
377
380
|
modelValue: {},
|
|
378
381
|
options: {}
|
|
379
382
|
},
|
|
380
383
|
emits: ["update:modelValue"],
|
|
381
|
-
setup(e, { emit:
|
|
382
|
-
const
|
|
383
|
-
function
|
|
384
|
-
if (!
|
|
385
|
-
const
|
|
386
|
-
|
|
384
|
+
setup(e, { emit: n }) {
|
|
385
|
+
const a = n, t = V(!1), d = V(!0), p = V(null);
|
|
386
|
+
function c() {
|
|
387
|
+
if (!p.value) return;
|
|
388
|
+
const i = p.value.getBoundingClientRect(), y = i.top, g = window.innerHeight - i.bottom;
|
|
389
|
+
d.value = y >= g;
|
|
387
390
|
}
|
|
388
|
-
function
|
|
389
|
-
t.value ||
|
|
391
|
+
function z() {
|
|
392
|
+
t.value || c(), t.value = !t.value;
|
|
390
393
|
}
|
|
391
|
-
function w(
|
|
392
|
-
|
|
394
|
+
function w(i) {
|
|
395
|
+
a("update:modelValue", i), t.value = !1;
|
|
393
396
|
}
|
|
394
|
-
function
|
|
395
|
-
|
|
397
|
+
function P(i) {
|
|
398
|
+
p.value && !p.value.contains(i.target) && (t.value = !1);
|
|
396
399
|
}
|
|
397
|
-
return
|
|
400
|
+
return Te(() => document.addEventListener("mousedown", P)), ye(() => document.removeEventListener("mousedown", P)), (i, y) => (b(), $("div", {
|
|
398
401
|
class: "speed-selector",
|
|
399
402
|
ref_key: "selectorRef",
|
|
400
|
-
ref:
|
|
403
|
+
ref: p
|
|
401
404
|
}, [
|
|
402
405
|
u("div", {
|
|
403
406
|
class: "speed-trigger",
|
|
404
|
-
onClick:
|
|
407
|
+
onClick: z
|
|
405
408
|
}, [
|
|
406
|
-
u("span",
|
|
407
|
-
(
|
|
408
|
-
class:
|
|
409
|
+
u("span", at, j(e.modelValue) + "x", 1),
|
|
410
|
+
(b(), $("svg", {
|
|
411
|
+
class: U(["arrow-icon", { open: t.value }]),
|
|
409
412
|
viewBox: "0 0 12 12",
|
|
410
413
|
fill: "currentColor"
|
|
411
|
-
}, [...
|
|
414
|
+
}, [...y[0] || (y[0] = [
|
|
412
415
|
u("path", {
|
|
413
416
|
d: "M2.5 4.5L6 8L9.5 4.5",
|
|
414
417
|
stroke: "currentColor",
|
|
@@ -419,26 +422,26 @@ const Qe = {
|
|
|
419
422
|
}, null, -1)
|
|
420
423
|
])], 2))
|
|
421
424
|
]),
|
|
422
|
-
|
|
423
|
-
name:
|
|
425
|
+
ee(Be, {
|
|
426
|
+
name: d.value ? "dropdown-up" : "dropdown-down"
|
|
424
427
|
}, {
|
|
425
|
-
default:
|
|
426
|
-
t.value ? (
|
|
428
|
+
default: te(() => [
|
|
429
|
+
t.value ? (b(), $("div", {
|
|
427
430
|
key: 0,
|
|
428
|
-
class:
|
|
431
|
+
class: U(["speed-dropdown", d.value ? "is-up" : "is-down"])
|
|
429
432
|
}, [
|
|
430
|
-
(
|
|
431
|
-
key:
|
|
432
|
-
class:
|
|
433
|
-
onClick: (
|
|
434
|
-
},
|
|
435
|
-
], 2)) :
|
|
433
|
+
(b(!0), $(xe, null, we(e.options, (g) => (b(), $("div", {
|
|
434
|
+
key: g,
|
|
435
|
+
class: U(["speed-option", { active: g === e.modelValue }]),
|
|
436
|
+
onClick: (T) => w(g)
|
|
437
|
+
}, j(g) + "x ", 11, it))), 128))
|
|
438
|
+
], 2)) : ge("", !0)
|
|
436
439
|
]),
|
|
437
440
|
_: 1
|
|
438
441
|
}, 8, ["name"])
|
|
439
442
|
], 512));
|
|
440
443
|
}
|
|
441
|
-
}), st = /* @__PURE__ */
|
|
444
|
+
}), st = /* @__PURE__ */ le(rt, [["__scopeId", "data-v-30c5e152"]]), ut = { class: "g-time-player" }, ct = { class: "controls-wrapper" }, dt = { class: "timeline-wrapper" }, vt = /* @__PURE__ */ ne({
|
|
442
445
|
__name: "index",
|
|
443
446
|
props: {
|
|
444
447
|
modelValue: {},
|
|
@@ -453,138 +456,166 @@ const Qe = {
|
|
|
453
456
|
formatTooltip: {}
|
|
454
457
|
},
|
|
455
458
|
emits: ["update:modelValue", "change"],
|
|
456
|
-
setup(e, { emit:
|
|
457
|
-
const
|
|
459
|
+
setup(e, { expose: n, emit: a }) {
|
|
460
|
+
const t = e, d = a, p = f(() => x(t.startTime)), c = f(() => x(t.endTime)), z = f(() => p.value), w = f(() => c.value), P = f(() => {
|
|
458
461
|
const l = [];
|
|
459
|
-
let
|
|
460
|
-
for (;
|
|
461
|
-
l.push(
|
|
462
|
+
let v = p.value;
|
|
463
|
+
for (; v <= c.value; )
|
|
464
|
+
l.push(v), v = F(v, t.interval);
|
|
462
465
|
return l;
|
|
463
|
-
}),
|
|
464
|
-
let
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
|
|
466
|
+
}), i = V(H(t.modelValue ?? t.startTime)), y = V(!1), g = V(t.speed);
|
|
467
|
+
let T = null, S = i.value;
|
|
468
|
+
const R = f(() => t.playInterval / g.value);
|
|
469
|
+
B(() => t.speed, (l) => {
|
|
470
|
+
g.value = l;
|
|
468
471
|
});
|
|
469
|
-
function
|
|
470
|
-
|
|
471
|
-
return y >= 0 ? y : 0;
|
|
472
|
+
function L(l) {
|
|
473
|
+
return Math.max(p.value, Math.min(l, c.value));
|
|
472
474
|
}
|
|
473
|
-
function
|
|
474
|
-
|
|
475
|
+
function H(l) {
|
|
476
|
+
return L(x(l));
|
|
475
477
|
}
|
|
476
|
-
function
|
|
477
|
-
|
|
478
|
+
function oe(l) {
|
|
479
|
+
const v = P.value;
|
|
480
|
+
if (!v.length) return -1;
|
|
481
|
+
const k = Le(v, L(l));
|
|
482
|
+
return Math.max(0, Math.min(k, v.length - 1));
|
|
478
483
|
}
|
|
479
|
-
|
|
480
|
-
()
|
|
484
|
+
function ae(l, v) {
|
|
485
|
+
const k = L(l);
|
|
486
|
+
k !== S && (S = k, d("update:modelValue", k), d("change", { time: k, index: oe(k) }));
|
|
487
|
+
}
|
|
488
|
+
function Y(l, v) {
|
|
489
|
+
const k = L(l);
|
|
490
|
+
d("change", { time: k, index: Math.max(0, Math.min(v, P.value.length - 1)) });
|
|
491
|
+
}
|
|
492
|
+
B(
|
|
493
|
+
() => t.modelValue,
|
|
481
494
|
(l) => {
|
|
482
|
-
l !== void 0 && !
|
|
495
|
+
l !== void 0 && !y.value && (i.value = H(l));
|
|
483
496
|
}
|
|
484
|
-
),
|
|
485
|
-
|
|
486
|
-
}),
|
|
487
|
-
|
|
488
|
-
}),
|
|
489
|
-
|
|
497
|
+
), B(p, () => {
|
|
498
|
+
h(), i.value = p.value, S = i.value;
|
|
499
|
+
}), B(c, (l) => {
|
|
500
|
+
i.value > l && (i.value = l, h());
|
|
501
|
+
}), B(i, (l) => {
|
|
502
|
+
const v = L(l);
|
|
503
|
+
if (v !== l) {
|
|
504
|
+
i.value = v;
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
ae(v), v >= c.value && h();
|
|
490
508
|
});
|
|
491
|
-
function
|
|
492
|
-
|
|
509
|
+
function I() {
|
|
510
|
+
y.value ? h() : M();
|
|
493
511
|
}
|
|
494
|
-
function
|
|
495
|
-
|
|
512
|
+
function M() {
|
|
513
|
+
i.value >= c.value && (i.value = p.value), y.value = !0, T && clearInterval(T), T = setInterval(O, R.value);
|
|
496
514
|
}
|
|
497
|
-
function
|
|
498
|
-
|
|
515
|
+
function h() {
|
|
516
|
+
y.value = !1, T && (clearInterval(T), T = null);
|
|
499
517
|
}
|
|
500
|
-
|
|
501
|
-
|
|
518
|
+
B(R, (l) => {
|
|
519
|
+
y.value && (T && clearInterval(T), T = setInterval(O, l));
|
|
502
520
|
});
|
|
503
|
-
function
|
|
504
|
-
const l =
|
|
505
|
-
if (l >
|
|
506
|
-
|
|
521
|
+
function O() {
|
|
522
|
+
const l = F(i.value, t.interval);
|
|
523
|
+
if (l > c.value) {
|
|
524
|
+
i.value = L(c.value), h();
|
|
507
525
|
return;
|
|
508
526
|
}
|
|
509
|
-
|
|
527
|
+
i.value = L(l);
|
|
528
|
+
}
|
|
529
|
+
function q() {
|
|
530
|
+
const l = F(i.value, -t.interval);
|
|
531
|
+
i.value = L(l);
|
|
510
532
|
}
|
|
511
|
-
function
|
|
512
|
-
const l =
|
|
513
|
-
|
|
533
|
+
function J() {
|
|
534
|
+
const l = F(i.value, t.interval);
|
|
535
|
+
i.value = L(l);
|
|
514
536
|
}
|
|
515
|
-
function
|
|
516
|
-
|
|
517
|
-
v.value = l > d.value ? d.value : l;
|
|
537
|
+
function ie(l) {
|
|
538
|
+
i.value = H(l);
|
|
518
539
|
}
|
|
519
|
-
return
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
540
|
+
return n({
|
|
541
|
+
play: M,
|
|
542
|
+
pause: h,
|
|
543
|
+
togglePlay: I,
|
|
544
|
+
prev: q,
|
|
545
|
+
next: J,
|
|
546
|
+
seekTo: ie,
|
|
547
|
+
isPlaying: y,
|
|
548
|
+
currentTime: i,
|
|
549
|
+
speedMultiplier: g
|
|
550
|
+
}), ye(() => h()), (l, v) => (b(), $("div", ut, [
|
|
551
|
+
u("div", ct, [
|
|
552
|
+
ee(Oe, {
|
|
553
|
+
"is-playing": y.value,
|
|
554
|
+
onTogglePlay: I,
|
|
555
|
+
onPrev: q,
|
|
556
|
+
onNext: J
|
|
557
|
+
}, He({ _: 2 }, [
|
|
527
558
|
l.$slots.prev ? {
|
|
528
559
|
name: "prev",
|
|
529
|
-
fn:
|
|
530
|
-
|
|
560
|
+
fn: te(() => [
|
|
561
|
+
X(l.$slots, "prev", {}, void 0, !0)
|
|
531
562
|
]),
|
|
532
563
|
key: "0"
|
|
533
564
|
} : void 0,
|
|
534
565
|
l.$slots.play ? {
|
|
535
566
|
name: "play",
|
|
536
|
-
fn:
|
|
537
|
-
|
|
567
|
+
fn: te(({ isPlaying: k }) => [
|
|
568
|
+
X(l.$slots, "play", { isPlaying: k }, void 0, !0)
|
|
538
569
|
]),
|
|
539
570
|
key: "1"
|
|
540
571
|
} : void 0,
|
|
541
572
|
l.$slots.next ? {
|
|
542
573
|
name: "next",
|
|
543
|
-
fn:
|
|
544
|
-
|
|
574
|
+
fn: te(() => [
|
|
575
|
+
X(l.$slots, "next", {}, void 0, !0)
|
|
545
576
|
]),
|
|
546
577
|
key: "2"
|
|
547
578
|
} : void 0
|
|
548
579
|
]), 1032, ["is-playing"])
|
|
549
580
|
]),
|
|
550
|
-
u("div",
|
|
551
|
-
|
|
552
|
-
modelValue:
|
|
553
|
-
"onUpdate:modelValue":
|
|
554
|
-
"start-time":
|
|
555
|
-
"end-time":
|
|
581
|
+
u("div", dt, [
|
|
582
|
+
ee(ot, {
|
|
583
|
+
modelValue: i.value,
|
|
584
|
+
"onUpdate:modelValue": v[0] || (v[0] = (k) => i.value = k),
|
|
585
|
+
"start-time": z.value,
|
|
586
|
+
"end-time": w.value,
|
|
556
587
|
interval: e.interval,
|
|
557
588
|
"min-tick-spacing": e.minTickSpacing,
|
|
558
589
|
"tick-label-mode": e.tickLabelMode,
|
|
559
590
|
"format-tooltip": e.formatTooltip,
|
|
560
|
-
onPlayingPause:
|
|
561
|
-
onChange:
|
|
591
|
+
onPlayingPause: h,
|
|
592
|
+
onChange: Y
|
|
562
593
|
}, null, 8, ["modelValue", "start-time", "end-time", "interval", "min-tick-spacing", "tick-label-mode", "format-tooltip"])
|
|
563
594
|
]),
|
|
564
|
-
|
|
565
|
-
modelValue:
|
|
566
|
-
"onUpdate:modelValue":
|
|
595
|
+
ee(st, {
|
|
596
|
+
modelValue: g.value,
|
|
597
|
+
"onUpdate:modelValue": v[1] || (v[1] = (k) => g.value = k),
|
|
567
598
|
options: e.speedOptions
|
|
568
599
|
}, null, 8, ["modelValue", "options"])
|
|
569
600
|
]));
|
|
570
601
|
}
|
|
571
|
-
}),
|
|
602
|
+
}), gt = /* @__PURE__ */ le(vt, [["__scopeId", "data-v-55b5dfa2"]]);
|
|
572
603
|
export {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
604
|
+
F as addHours,
|
|
605
|
+
gt as default,
|
|
606
|
+
qe as defaultTooltipFormat,
|
|
607
|
+
mt as diffHours,
|
|
608
|
+
Le as findNearestTickIndex,
|
|
609
|
+
pt as findTickIndex,
|
|
610
|
+
Je as formatDayLabel,
|
|
611
|
+
Ke as formatHH,
|
|
612
|
+
Ye as formatHHmm,
|
|
613
|
+
$e as formatMD,
|
|
614
|
+
ke as getDateKey,
|
|
615
|
+
je as getDayOfWeek,
|
|
616
|
+
Ue as getHour,
|
|
617
|
+
Qe as getNextMidnight,
|
|
618
|
+
be as getWeekdayShort,
|
|
619
|
+
x as toTimestamp,
|
|
620
|
+
gt as vue3TimePlaybar
|
|
590
621
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(u,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(u=typeof globalThis<"u"?globalThis:u||self,e(u.Vue3TimePlaybar={},u.Vue))})(this,(function(u,e){"use strict";const ue={class:"player-controls"},me={class:"btn-group"},fe=["title"],pe={key:0,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none"},ge={key:1,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none"},ye=e.defineComponent({__name:"PlayerControls",props:{isPlaying:{type:Boolean}},emits:["toggle-play","prev","next"],setup(t){return(a,o)=>(e.openBlock(),e.createElementBlock("div",ue,[e.createElementVNode("div",me,[e.createElementVNode("button",{class:"control-btn",onClick:o[0]||(o[0]=n=>a.$emit("prev")),title:"上一时刻"},[e.renderSlot(a.$slots,"prev",{},()=>[o[3]||(o[3]=e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("polygon",{points:"19 20 9 12 19 4 19 20"}),e.createElementVNode("line",{x1:"5",y1:"19",x2:"5",y2:"5"})],-1))],!0)]),e.createElementVNode("button",{class:"control-btn play-btn",onClick:o[1]||(o[1]=n=>a.$emit("toggle-play")),title:t.isPlaying?"暂停":"播放"},[e.renderSlot(a.$slots,"play",{isPlaying:t.isPlaying},()=>[t.isPlaying?(e.openBlock(),e.createElementBlock("svg",ge,[...o[5]||(o[5]=[e.createElementVNode("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"},null,-1),e.createElementVNode("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",pe,[...o[4]||(o[4]=[e.createElementVNode("polygon",{points:"5 3 19 12 5 21 5 3"},null,-1)])]))],!0)],8,fe),e.createElementVNode("button",{class:"control-btn",onClick:o[2]||(o[2]=n=>a.$emit("next")),title:"下一时刻"},[e.renderSlot(a.$slots,"next",{},()=>[o[6]||(o[6]=e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("polygon",{points:"5 4 15 12 5 20 5 4"}),e.createElementVNode("line",{x1:"19",y1:"5",x2:"19",y2:"19"})],-1))],!0)])])]))}}),A=(t,a)=>{const o=t.__vccOpts||t;for(const[n,s]of a)o[n]=s;return o},he=A(ye,[["__scopeId","data-v-55e12a8d"]]),ke=["周日","周一","周二","周三","周四","周五","周六"];function k(t){if(typeof t=="number")return t;if(t instanceof Date)return t.getTime();const a=Date.parse(t);return Number.isNaN(a)?(console.warn(`[GTimePlayer] 无法解析时间: "${t}"`),0):a}function _(t,a=2){return String(t).padStart(a,"0")}function ee(t){return new Date(t).getHours()}function te(t){return new Date(t).getDay()}function U(t){return ke[te(t)]??""}function ne(t){return _(new Date(t).getHours())}function X(t){const a=new Date(t);return`${a.getMonth()+1}月${a.getDate()}日`}function oe(t){const a=new Date(t);return`${_(a.getHours())}:${_(a.getMinutes())}`}function le(t){return`${X(t)} ${U(t)} ${oe(t)}`}function G(t){const a=new Date(t);return`${a.getFullYear()}${_(a.getMonth()+1)}${_(a.getDate())}`}function ae(t){return`${X(t)} ${U(t)}`}function x(t,a){return t+a*36e5}function ve(t,a){return(k(a)-k(t))/36e5}function re(t){const a=new Date(t);return a.setHours(24,0,0,0),a.getTime()}function ie(t,a){if(t.length===0)return-1;if(t.length===1)return 0;let o=0,n=t.length-1;if(a<=t[o])return o;if(a>=t[n])return n;for(;o<=n;){const s=o+n>>>1,m=t[s];if(m===a)return s;m<a?o=s+1:n=s-1}return o>=t.length?n:n<0||Math.abs(t[o]-a)<Math.abs(t[n]-a)?o:n}function se(t,a){let o=0,n=t.length-1;for(;o<=n;){const s=o+n>>>1,m=t[s];if(m===a)return s;m<a?o=s+1:n=s-1}return-1}const we={key:0,class:"tick-label"},Te={key:1,class:"day-label"},Ve=35,Ee=35,be=A(e.defineComponent({__name:"TimeTimeline",props:{modelValue:{},startTime:{},endTime:{},interval:{},minTickSpacing:{},tickLabelMode:{default:"all"},formatTooltip:{}},emits:["update:modelValue","change","playing-pause"],setup(t,{emit:a}){const o=[2,8,14,20],n=t,s=a,m=e.ref(null),g=e.ref(null),H=e.ref(null),w=e.ref(0),f=e.ref(0),y=e.ref(0);let v=!1,d=0,$=!1,N=!1,B=null;const I=e.ref(!1),R=e.computed(()=>{const r=k(n.startTime),c=k(n.endTime),i=c-r;if(i<=0)return[];const T=[];let p=r;for(;p<=c;){const S=(p-r)/i*100,E=ee(p),D=T.length===0,J=G(p),Q=D?null:G(T[T.length-1].time),O=!D&&Q!==J||D&&E===0;let M=!1;if(E===0)M=!0;else if(D){const P=re(p);(x(p,n.interval)>P||c<P)&&(M=!0)}const Z=E===0&&M?!1:n.tickLabelMode==="all"||o.includes(E);T.push({time:p,percent:S,label:ne(p),showLabel:Z,dayLabel:ae(p),showDayLabel:M,isDayBoundary:O}),p=x(p,n.interval)}return T}),j=e.computed(()=>R.value.map(r=>r.time)),b=e.computed(()=>n.minTickSpacing!==void 0?n.minTickSpacing:n.tickLabelMode==="major"?5:15),z=e.computed(()=>{const r=R.value.length;return r<2?w.value||0:(r-1)*b.value}),C=e.computed(()=>z.value>w.value&&w.value>0),V=e.computed(()=>C.value?Ve:Ee),l=e.computed(()=>C.value?z.value:Math.max(0,w.value-V.value*2)),h=e.computed(()=>l.value+V.value*2),L=e.computed(()=>w.value&&C.value?h.value+"px":"100%"),Ce=e.computed(()=>({left:V.value+"px",width:l.value+"px"})),Le=e.computed(()=>({left:V.value+"px",width:l.value+"px"})),F=e.computed(()=>{const r=k(n.startTime),c=k(n.endTime),i=k(n.modelValue);return i<=r?0:i>=c?100:(i-r)/(c-r)*100}),Me=e.computed(()=>({left:V.value+"px",width:F.value/100*l.value+"px"})),Pe=e.computed(()=>{const r=k(n.modelValue);return n.formatTooltip?n.formatTooltip(r):le(r)}),K=e.computed(()=>V.value+F.value/100*l.value-y.value),_e=e.computed(()=>K.value>-50&&K.value<w.value+50),He=e.computed(()=>({transform:`translateX(${K.value}px)`}));function Ie(){g.value&&(f.value=g.value.scrollLeft,$||(y.value=g.value.scrollLeft))}function Re(r){!g.value||!C.value||(g.value.scrollLeft+=r.deltaY||r.deltaX)}function W(r=!1){if(!C.value||!g.value||v)return;const c=V.value+F.value/100*l.value,i=w.value,T=h.value-i,p=Math.max(0,Math.min(c-i/2,T));y.value=p;const S=g.value;if(r||Math.abs(S.scrollLeft-p)<1){S.scrollLeft=p,f.value=p;return}d&&cancelAnimationFrame(d);const E=S.scrollLeft,D=p-E;$=!0;const J=200,Q=performance.now();function O(M){const Z=M-Q,P=Math.min(Z/J,1),de=1-(1-P)*(1-P);S.scrollLeft=E+D*de,f.value=S.scrollLeft,P<1?d=requestAnimationFrame(O):(d=0,$=!1)}d=requestAnimationFrame(O)}e.watch(F,()=>W()),e.watch(w,()=>W());function q(r){if(!g.value)return k(n.startTime);const c=g.value.getBoundingClientRect(),i=g.value.scrollLeft,p=r.clientX-c.left+i-V.value,S=Math.max(0,Math.min(p,l.value)),E=k(n.startTime),D=k(n.endTime);return E+(D-E)*(S/(l.value||1))}function ze(r){const c=j.value;if(c.length===0)return{time:r,index:-1};const i=ie(c,r);return{time:c[i]??r,index:i}}function Y(r){const{time:c,index:i}=ze(r);c!==k(n.modelValue)&&(s("update:modelValue",c),s("change",c,i))}function We(r){if(N){N=!1;return}Y(q(r))}function Ae(r){const c=r.clientX;N=!1,v=!0,s("playing-pause");const i=p=>{Math.abs(p.clientX-c)>3&&(N=!0),Y(q(p))},T=()=>{v=!1,document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",T),e.nextTick(()=>W())};document.addEventListener("mousemove",i),document.addEventListener("mouseup",T)}function Fe(r){v=!0,N=!1,I.value=!0,document.body.style.cursor="grabbing",s("playing-pause");const c=T=>{N=!0,Y(q(T))},i=()=>{v=!1,I.value=!1,document.body.style.cursor="",document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",i),e.nextTick(()=>W())};document.addEventListener("mousemove",c),document.addEventListener("mouseup",i)}return e.onMounted(()=>{g.value&&(w.value=g.value.clientWidth,B=new ResizeObserver(r=>{r[0]&&(w.value=r[0].contentRect.width)}),B.observe(g.value)),e.nextTick(()=>W())}),e.onUnmounted(()=>{d&&cancelAnimationFrame(d),B==null||B.disconnect()}),(r,c)=>(e.openBlock(),e.createElementBlock("div",{class:"time-timeline",ref_key:"timelineRef",ref:m},[e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(["handle-group",{dragging:I.value}]),style:e.normalizeStyle(He.value)},[e.createElementVNode("div",{class:"floating-tooltip",onMousedown:e.withModifiers(Fe,["prevent","stop"])},e.toDisplayString(Pe.value),33),c[0]||(c[0]=e.createElementVNode("div",{class:"handle-visual"},null,-1))],6),[[e.vShow,_e.value]]),e.createElementVNode("div",{class:"scroll-container",ref_key:"scrollRef",ref:g,onScroll:Ie,onWheel:e.withModifiers(Re,["prevent"])},[e.createElementVNode("div",{class:"timeline-inner",ref_key:"innerRef",ref:H,style:e.normalizeStyle({width:L.value}),onMousedown:e.withModifiers(Ae,["prevent"]),onClick:We},[e.createElementVNode("div",{class:"track-bg",style:e.normalizeStyle(Ce.value)},null,4),e.createElementVNode("div",{class:"track-active",style:e.normalizeStyle(Me.value)},null,4),e.createElementVNode("div",{class:"ticks-container",style:e.normalizeStyle(Le.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(R.value,i=>(e.openBlock(),e.createElementBlock("div",{key:i.time,class:e.normalizeClass(["tick-item",{"is-day-boundary":i.isDayBoundary}]),style:e.normalizeStyle({left:i.percent+"%"})},[c[1]||(c[1]=e.createElementVNode("div",{class:"tick-mark"},null,-1)),i.showLabel?(e.openBlock(),e.createElementBlock("div",we,e.toDisplayString(i.label),1)):e.createCommentVNode("",!0),i.showDayLabel?(e.openBlock(),e.createElementBlock("div",Te,e.toDisplayString(i.dayLabel),1)):e.createCommentVNode("",!0)],6))),128))],4)],36)],544)],512))}}),[["__scopeId","data-v-d7d9fd3b"]]),Se={class:"speed-value"},Ne=["onClick"],De=A(e.defineComponent({__name:"SpeedSelector",props:{modelValue:{},options:{}},emits:["update:modelValue"],setup(t,{emit:a}){const o=a,n=e.ref(!1),s=e.ref(!0),m=e.ref(null);function g(){if(!m.value)return;const y=m.value.getBoundingClientRect(),v=y.top,d=window.innerHeight-y.bottom;s.value=v>=d}function H(){n.value||g(),n.value=!n.value}function w(y){o("update:modelValue",y),n.value=!1}function f(y){m.value&&!m.value.contains(y.target)&&(n.value=!1)}return e.onMounted(()=>document.addEventListener("mousedown",f)),e.onUnmounted(()=>document.removeEventListener("mousedown",f)),(y,v)=>(e.openBlock(),e.createElementBlock("div",{class:"speed-selector",ref_key:"selectorRef",ref:m},[e.createElementVNode("div",{class:"speed-trigger",onClick:H},[e.createElementVNode("span",Se,e.toDisplayString(t.modelValue)+"x",1),(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(["arrow-icon",{open:n.value}]),viewBox:"0 0 12 12",fill:"currentColor"},[...v[0]||(v[0]=[e.createElementVNode("path",{d:"M2.5 4.5L6 8L9.5 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])],2))]),e.createVNode(e.Transition,{name:s.value?"dropdown-up":"dropdown-down"},{default:e.withCtx(()=>[n.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["speed-dropdown",s.value?"is-up":"is-down"])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.options,d=>(e.openBlock(),e.createElementBlock("div",{key:d,class:e.normalizeClass(["speed-option",{active:d===t.modelValue}]),onClick:$=>w(d)},e.toDisplayString(d)+"x ",11,Ne))),128))],2)):e.createCommentVNode("",!0)]),_:1},8,["name"])],512))}}),[["__scopeId","data-v-30c5e152"]]),xe={class:"g-time-player"},$e={class:"controls-wrapper"},Be={class:"timeline-wrapper"},ce=A(e.defineComponent({__name:"index",props:{modelValue:{},startTime:{},endTime:{},interval:{default:1},playInterval:{default:1e3},speed:{default:1},speedOptions:{default:()=>[.5,1,2,3]},minTickSpacing:{},tickLabelMode:{default:"all"},formatTooltip:{}},emits:["update:modelValue","change"],setup(t,{emit:a}){const o=t,n=a,s=e.computed(()=>k(o.startTime)),m=e.computed(()=>k(o.endTime)),g=e.computed(()=>s.value),H=e.computed(()=>m.value),w=e.computed(()=>{const l=[];let h=s.value;for(;h<=m.value;)l.push(h),h=x(h,o.interval);return l}),f=e.ref(k(o.modelValue??o.startTime)),y=e.ref(!1),v=e.ref(o.speed);let d=null;const $=e.computed(()=>o.playInterval/v.value);e.watch(()=>o.speed,l=>{v.value=l});function N(l){const h=se(w.value,l);return h>=0?h:0}function B(l,h){n("update:modelValue",l),n("change",{time:l,index:N(l)})}function I(l,h){n("change",{time:l,index:h})}e.watch(()=>o.modelValue,l=>{l!==void 0&&!y.value&&(f.value=k(l))}),e.watch(s,()=>{b(),f.value=s.value}),e.watch(m,l=>{f.value>l&&(f.value=l,b())}),e.watch(f,l=>{B(l),l>=m.value&&b()});function R(){y.value?b():j()}function j(){f.value>=m.value&&(f.value=s.value),y.value=!0,d&&clearInterval(d),d=setInterval(z,$.value)}function b(){y.value=!1,d&&(clearInterval(d),d=null)}e.watch($,l=>{y.value&&(d&&clearInterval(d),d=setInterval(z,l))});function z(){const l=x(f.value,o.interval);if(l>m.value){f.value=m.value,b();return}f.value=l}function C(){const l=x(f.value,-o.interval);f.value=l<s.value?s.value:l}function V(){const l=x(f.value,o.interval);f.value=l>m.value?m.value:l}return e.onUnmounted(()=>b()),(l,h)=>(e.openBlock(),e.createElementBlock("div",xe,[e.createElementVNode("div",$e,[e.createVNode(he,{"is-playing":y.value,onTogglePlay:R,onPrev:C,onNext:V},e.createSlots({_:2},[l.$slots.prev?{name:"prev",fn:e.withCtx(()=>[e.renderSlot(l.$slots,"prev",{},void 0,!0)]),key:"0"}:void 0,l.$slots.play?{name:"play",fn:e.withCtx(({isPlaying:L})=>[e.renderSlot(l.$slots,"play",{isPlaying:L},void 0,!0)]),key:"1"}:void 0,l.$slots.next?{name:"next",fn:e.withCtx(()=>[e.renderSlot(l.$slots,"next",{},void 0,!0)]),key:"2"}:void 0]),1032,["is-playing"])]),e.createElementVNode("div",Be,[e.createVNode(be,{modelValue:f.value,"onUpdate:modelValue":h[0]||(h[0]=L=>f.value=L),"start-time":g.value,"end-time":H.value,interval:t.interval,"min-tick-spacing":t.minTickSpacing,"tick-label-mode":t.tickLabelMode,"format-tooltip":t.formatTooltip,onPlayingPause:b,onChange:I},null,8,["modelValue","start-time","end-time","interval","min-tick-spacing","tick-label-mode","format-tooltip"])]),e.createVNode(De,{modelValue:v.value,"onUpdate:modelValue":h[1]||(h[1]=L=>v.value=L),options:t.speedOptions},null,8,["modelValue","options"])]))}}),[["__scopeId","data-v-6dfd5ab6"]]);u.addHours=x,u.default=ce,u.defaultTooltipFormat=le,u.diffHours=ve,u.findNearestTickIndex=ie,u.findTickIndex=se,u.formatDayLabel=ae,u.formatHH=ne,u.formatHHmm=oe,u.formatMD=X,u.getDateKey=G,u.getDayOfWeek=te,u.getHour=ee,u.getNextMidnight=re,u.getWeekdayShort=U,u.toTimestamp=k,u.vue3TimePlaybar=ce,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
1
|
+
(function(m,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(m=typeof globalThis<"u"?globalThis:m||self,e(m.Vue3TimePlaybar={},m.Vue))})(this,(function(m,e){"use strict";const ge={class:"player-controls"},ye={class:"btn-group"},he=["title"],ve={key:0,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none"},ke={key:1,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none"},Te=e.defineComponent({__name:"PlayerControls",props:{isPlaying:{type:Boolean}},emits:["toggle-play","prev","next"],setup(t){return(o,i)=>(e.openBlock(),e.createElementBlock("div",ge,[e.createElementVNode("div",ye,[e.createElementVNode("button",{class:"control-btn",onClick:i[0]||(i[0]=n=>o.$emit("prev")),title:"上一时刻"},[e.renderSlot(o.$slots,"prev",{},()=>[i[3]||(i[3]=e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("polygon",{points:"19 20 9 12 19 4 19 20"}),e.createElementVNode("line",{x1:"5",y1:"19",x2:"5",y2:"5"})],-1))],!0)]),e.createElementVNode("button",{class:"control-btn play-btn",onClick:i[1]||(i[1]=n=>o.$emit("toggle-play")),title:t.isPlaying?"暂停":"播放"},[e.renderSlot(o.$slots,"play",{isPlaying:t.isPlaying},()=>[t.isPlaying?(e.openBlock(),e.createElementBlock("svg",ke,[...i[5]||(i[5]=[e.createElementVNode("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"},null,-1),e.createElementVNode("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",ve,[...i[4]||(i[4]=[e.createElementVNode("polygon",{points:"5 3 19 12 5 21 5 3"},null,-1)])]))],!0)],8,he),e.createElementVNode("button",{class:"control-btn",onClick:i[2]||(i[2]=n=>o.$emit("next")),title:"下一时刻"},[e.renderSlot(o.$slots,"next",{},()=>[i[6]||(i[6]=e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("polygon",{points:"5 4 15 12 5 20 5 4"}),e.createElementVNode("line",{x1:"19",y1:"5",x2:"19",y2:"19"})],-1))],!0)])])]))}}),A=(t,o)=>{const i=t.__vccOpts||t;for(const[n,u]of o)i[n]=u;return i},we=A(Te,[["__scopeId","data-v-55e12a8d"]]),Ve=["周日","周一","周二","周三","周四","周五","周六"];function T(t){if(typeof t=="number")return t;if(t instanceof Date)return t.getTime();const o=Date.parse(t);return Number.isNaN(o)?(console.warn(`[GTimePlayer] 无法解析时间: "${t}"`),0):o}function R(t,o=2){return String(t).padStart(o,"0")}function ie(t){return new Date(t).getHours()}function re(t){return new Date(t).getDay()}function j(t){return Ve[re(t)]??""}function se(t){return R(new Date(t).getHours())}function K(t){const o=new Date(t);return`${o.getMonth()+1}月${o.getDate()}日`}function ce(t){const o=new Date(t);return`${R(o.getHours())}:${R(o.getMinutes())}`}function de(t){return`${K(t)} ${j(t)} ${ce(t)}`}function q(t){const o=new Date(t);return`${o.getFullYear()}${R(o.getMonth()+1)}${R(o.getDate())}`}function ue(t){return`${K(t)} ${j(t)}`}function L(t,o){return t+o*36e5}function Ee(t,o){return(T(o)-T(t))/36e5}function me(t){const o=new Date(t);return o.setHours(24,0,0,0),o.getTime()}function Y(t,o){if(t.length===0)return-1;if(t.length===1)return 0;let i=0,n=t.length-1;if(o<=t[i])return i;if(o>=t[n])return n;for(;i<=n;){const u=i+n>>>1,g=t[u];if(g===o)return u;g<o?i=u+1:n=u-1}return i>=t.length?n:n<0||Math.abs(t[i]-o)<Math.abs(t[n]-o)?i:n}function Se(t,o){let i=0,n=t.length-1;for(;i<=n;){const u=i+n>>>1,g=t[u];if(g===o)return u;g<o?i=u+1:n=u-1}return-1}const be={key:0,class:"tick-label"},xe={key:1,class:"day-label"},Ne=35,De=35,Me=A(e.defineComponent({__name:"TimeTimeline",props:{modelValue:{},startTime:{},endTime:{},interval:{},minTickSpacing:{},tickLabelMode:{default:"all"},formatTooltip:{}},emits:["update:modelValue","change","playing-pause"],setup(t,{emit:o}){const i=[2,8,14,20],n=t,u=o,g=e.useTemplateRef("timelineRef"),d=e.useTemplateRef("scrollRef"),I=e.useTemplateRef("innerRef"),V=e.ref(0),D=e.ref(0),r=e.ref(0);let h=!1,y=0,w=!1,x=!1,$=null;const E=e.ref(!1),P=e.computed(()=>{const a=T(n.startTime),c=T(n.endTime),s=c-a;if(s<=0)return[];const S=[];let p=a;for(;p<=c;){const M=(p-a)/s*100,N=ie(p),C=S.length===0,oe=q(p),le=C?null:q(S[S.length-1].time),G=!C&&le!==oe||C&&N===0;let _=!1;if(N===0)_=!0;else if(C){const H=me(p);(L(p,n.interval)>H||c<H)&&(_=!0)}const ae=N===0&&_?!1:n.tickLabelMode==="all"||i.includes(N);S.push({time:p,percent:M,label:se(p),showLabel:ae,dayLabel:ue(p),showDayLabel:_,isDayBoundary:G}),p=L(p,n.interval)}return S}),J=e.computed(()=>P.value.map(a=>a.time)),Q=e.computed(()=>n.minTickSpacing!==void 0?n.minTickSpacing:n.tickLabelMode==="major"?5:15),F=e.computed(()=>{const a=P.value.length;return a<2?V.value||0:(a-1)*Q.value}),B=e.computed(()=>F.value>V.value&&V.value>0),b=e.computed(()=>B.value?Ne:De),v=e.computed(()=>B.value?F.value:Math.max(0,V.value-b.value*2)),z=e.computed(()=>v.value+b.value*2),O=e.computed(()=>V.value&&B.value?z.value+"px":"100%"),U=e.computed(()=>({left:b.value+"px",width:v.value+"px"})),Z=e.computed(()=>({left:b.value+"px",width:v.value+"px"})),l=e.computed(()=>{const a=T(n.startTime),c=T(n.endTime),s=T(n.modelValue);return s<=a?0:s>=c?100:(s-a)/(c-a)*100}),f=e.computed(()=>({left:b.value+"px",width:l.value/100*v.value+"px"})),k=e.computed(()=>{const a=T(n.modelValue);return n.formatTooltip?n.formatTooltip(a):de(a)}),ee=e.computed(()=>b.value+l.value/100*v.value-r.value),He=e.computed(()=>ee.value>-50&&ee.value<V.value+50),Re=e.computed(()=>({transform:`translateX(${ee.value}px)`}));function X(){y&&(cancelAnimationFrame(y),y=0),w=!1}function Ie(){d.value&&(D.value=d.value.scrollLeft,w||(r.value=d.value.scrollLeft))}function ze(a){!d.value||!B.value||(d.value.scrollLeft+=a.deltaY||a.deltaX)}function W(a=!1){if(!B.value||!d.value||h)return;const c=b.value+l.value/100*v.value,s=V.value,S=z.value-s,p=Math.max(0,Math.min(c-s/2,S));r.value=p;const M=d.value;if(a||Math.abs(M.scrollLeft-p)<1){M.scrollLeft=p,D.value=p;return}X();const N=M.scrollLeft,C=p-N;w=!0;const oe=200,le=performance.now();function G(_){const ae=_-le,H=Math.min(ae/oe,1),pe=1-(1-H)*(1-H);M.scrollLeft=N+C*pe,D.value=M.scrollLeft,H<1?y=requestAnimationFrame(G):(y=0,w=!1)}y=requestAnimationFrame(G)}e.watch(l,()=>W()),e.watch(V,()=>W());function te(a){if(!d.value)return T(n.startTime);const c=d.value.getBoundingClientRect(),s=d.value.scrollLeft,p=a.clientX-c.left+s-b.value,M=Math.max(0,Math.min(p,v.value)),N=T(n.startTime),C=T(n.endTime);return N+(C-N)*(M/(v.value||1))}function We(a){const c=J.value;if(c.length===0)return{time:a,index:-1};const s=Y(c,a);return{time:c[s]??a,index:s}}function ne(a){const{time:c,index:s}=We(a);c!==T(n.modelValue)&&(u("update:modelValue",c),u("change",c,s))}function Ae(a){if(x){x=!1;return}ne(te(a))}function Fe(a){const c=a.clientX;x=!1,h=!0,X(),u("playing-pause");const s=p=>{Math.abs(p.clientX-c)>3&&(x=!0),ne(te(p))},S=()=>{h=!1,document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",S),e.nextTick(()=>W())};document.addEventListener("mousemove",s),document.addEventListener("mouseup",S)}function Oe(a){h=!0,X(),x=!1,E.value=!0,document.body.style.cursor="grabbing",u("playing-pause");const c=S=>{x=!0,ne(te(S))},s=()=>{h=!1,E.value=!1,document.body.style.cursor="",document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",s),e.nextTick(()=>W())};document.addEventListener("mousemove",c),document.addEventListener("mouseup",s)}return e.onMounted(()=>{d.value&&(V.value=d.value.clientWidth,$=new ResizeObserver(a=>{a[0]&&(V.value=a[0].contentRect.width)}),$.observe(d.value)),e.nextTick(()=>W())}),e.onUnmounted(()=>{X(),$==null||$.disconnect()}),(a,c)=>(e.openBlock(),e.createElementBlock("div",{class:"time-timeline",ref_key:"timelineRef",ref:g},[e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(["handle-group",{dragging:E.value}]),style:e.normalizeStyle(Re.value)},[e.createElementVNode("div",{class:"floating-tooltip",onMousedown:e.withModifiers(Oe,["prevent","stop"])},e.toDisplayString(k.value),33),c[0]||(c[0]=e.createElementVNode("div",{class:"handle-visual"},null,-1))],6),[[e.vShow,He.value]]),e.createElementVNode("div",{class:"scroll-container",ref_key:"scrollRef",ref:d,onScroll:Ie,onWheel:e.withModifiers(ze,["prevent"])},[e.createElementVNode("div",{class:"timeline-inner",ref_key:"innerRef",ref:I,style:e.normalizeStyle({width:O.value}),onMousedown:e.withModifiers(Fe,["prevent"]),onClick:Ae},[e.createElementVNode("div",{class:"track-bg",style:e.normalizeStyle(U.value)},null,4),e.createElementVNode("div",{class:"track-active",style:e.normalizeStyle(f.value)},null,4),e.createElementVNode("div",{class:"ticks-container",style:e.normalizeStyle(Z.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(P.value,s=>(e.openBlock(),e.createElementBlock("div",{key:s.time,class:e.normalizeClass(["tick-item",{"is-day-boundary":s.isDayBoundary}]),style:e.normalizeStyle({left:s.percent+"%"})},[c[1]||(c[1]=e.createElementVNode("div",{class:"tick-mark"},null,-1)),s.showLabel?(e.openBlock(),e.createElementBlock("div",be,e.toDisplayString(s.label),1)):e.createCommentVNode("",!0),s.showDayLabel?(e.openBlock(),e.createElementBlock("div",xe,e.toDisplayString(s.dayLabel),1)):e.createCommentVNode("",!0)],6))),128))],4)],36)],544)],512))}}),[["__scopeId","data-v-0f78dcee"]]),$e={class:"speed-value"},Be=["onClick"],Ce=A(e.defineComponent({__name:"SpeedSelector",props:{modelValue:{},options:{}},emits:["update:modelValue"],setup(t,{emit:o}){const i=o,n=e.ref(!1),u=e.ref(!0),g=e.ref(null);function d(){if(!g.value)return;const r=g.value.getBoundingClientRect(),h=r.top,y=window.innerHeight-r.bottom;u.value=h>=y}function I(){n.value||d(),n.value=!n.value}function V(r){i("update:modelValue",r),n.value=!1}function D(r){g.value&&!g.value.contains(r.target)&&(n.value=!1)}return e.onMounted(()=>document.addEventListener("mousedown",D)),e.onUnmounted(()=>document.removeEventListener("mousedown",D)),(r,h)=>(e.openBlock(),e.createElementBlock("div",{class:"speed-selector",ref_key:"selectorRef",ref:g},[e.createElementVNode("div",{class:"speed-trigger",onClick:I},[e.createElementVNode("span",$e,e.toDisplayString(t.modelValue)+"x",1),(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(["arrow-icon",{open:n.value}]),viewBox:"0 0 12 12",fill:"currentColor"},[...h[0]||(h[0]=[e.createElementVNode("path",{d:"M2.5 4.5L6 8L9.5 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])],2))]),e.createVNode(e.Transition,{name:u.value?"dropdown-up":"dropdown-down"},{default:e.withCtx(()=>[n.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["speed-dropdown",u.value?"is-up":"is-down"])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.options,y=>(e.openBlock(),e.createElementBlock("div",{key:y,class:e.normalizeClass(["speed-option",{active:y===t.modelValue}]),onClick:w=>V(y)},e.toDisplayString(y)+"x ",11,Be))),128))],2)):e.createCommentVNode("",!0)]),_:1},8,["name"])],512))}}),[["__scopeId","data-v-30c5e152"]]),Le={class:"g-time-player"},Pe={class:"controls-wrapper"},_e={class:"timeline-wrapper"},fe=A(e.defineComponent({__name:"index",props:{modelValue:{},startTime:{},endTime:{},interval:{default:1},playInterval:{default:1e3},speed:{default:1},speedOptions:{default:()=>[.5,1,2,3]},minTickSpacing:{},tickLabelMode:{default:"all"},formatTooltip:{}},emits:["update:modelValue","change"],setup(t,{expose:o,emit:i}){const n=t,u=i,g=e.computed(()=>T(n.startTime)),d=e.computed(()=>T(n.endTime)),I=e.computed(()=>g.value),V=e.computed(()=>d.value),D=e.computed(()=>{const l=[];let f=g.value;for(;f<=d.value;)l.push(f),f=L(f,n.interval);return l}),r=e.ref(P(n.modelValue??n.startTime)),h=e.ref(!1),y=e.ref(n.speed);let w=null,x=r.value;const $=e.computed(()=>n.playInterval/y.value);e.watch(()=>n.speed,l=>{y.value=l});function E(l){return Math.max(g.value,Math.min(l,d.value))}function P(l){return E(T(l))}function J(l){const f=D.value;if(!f.length)return-1;const k=Y(f,E(l));return Math.max(0,Math.min(k,f.length-1))}function Q(l,f){const k=E(l);k!==x&&(x=k,u("update:modelValue",k),u("change",{time:k,index:J(k)}))}function F(l,f){const k=E(l);u("change",{time:k,index:Math.max(0,Math.min(f,D.value.length-1))})}e.watch(()=>n.modelValue,l=>{l!==void 0&&!h.value&&(r.value=P(l))}),e.watch(g,()=>{v(),r.value=g.value,x=r.value}),e.watch(d,l=>{r.value>l&&(r.value=l,v())}),e.watch(r,l=>{const f=E(l);if(f!==l){r.value=f;return}Q(f),f>=d.value&&v()});function B(){h.value?v():b()}function b(){r.value>=d.value&&(r.value=g.value),h.value=!0,w&&clearInterval(w),w=setInterval(z,$.value)}function v(){h.value=!1,w&&(clearInterval(w),w=null)}e.watch($,l=>{h.value&&(w&&clearInterval(w),w=setInterval(z,l))});function z(){const l=L(r.value,n.interval);if(l>d.value){r.value=E(d.value),v();return}r.value=E(l)}function O(){const l=L(r.value,-n.interval);r.value=E(l)}function U(){const l=L(r.value,n.interval);r.value=E(l)}function Z(l){r.value=P(l)}return o({play:b,pause:v,togglePlay:B,prev:O,next:U,seekTo:Z,isPlaying:h,currentTime:r,speedMultiplier:y}),e.onUnmounted(()=>v()),(l,f)=>(e.openBlock(),e.createElementBlock("div",Le,[e.createElementVNode("div",Pe,[e.createVNode(we,{"is-playing":h.value,onTogglePlay:B,onPrev:O,onNext:U},e.createSlots({_:2},[l.$slots.prev?{name:"prev",fn:e.withCtx(()=>[e.renderSlot(l.$slots,"prev",{},void 0,!0)]),key:"0"}:void 0,l.$slots.play?{name:"play",fn:e.withCtx(({isPlaying:k})=>[e.renderSlot(l.$slots,"play",{isPlaying:k},void 0,!0)]),key:"1"}:void 0,l.$slots.next?{name:"next",fn:e.withCtx(()=>[e.renderSlot(l.$slots,"next",{},void 0,!0)]),key:"2"}:void 0]),1032,["is-playing"])]),e.createElementVNode("div",_e,[e.createVNode(Me,{modelValue:r.value,"onUpdate:modelValue":f[0]||(f[0]=k=>r.value=k),"start-time":I.value,"end-time":V.value,interval:t.interval,"min-tick-spacing":t.minTickSpacing,"tick-label-mode":t.tickLabelMode,"format-tooltip":t.formatTooltip,onPlayingPause:v,onChange:F},null,8,["modelValue","start-time","end-time","interval","min-tick-spacing","tick-label-mode","format-tooltip"])]),e.createVNode(Ce,{modelValue:y.value,"onUpdate:modelValue":f[1]||(f[1]=k=>y.value=k),options:t.speedOptions},null,8,["modelValue","options"])]))}}),[["__scopeId","data-v-55b5dfa2"]]);m.addHours=L,m.default=fe,m.defaultTooltipFormat=de,m.diffHours=Ee,m.findNearestTickIndex=Y,m.findTickIndex=Se,m.formatDayLabel=ue,m.formatHH=se,m.formatHHmm=ce,m.formatMD=K,m.getDateKey=q,m.getDayOfWeek=re,m.getHour=ie,m.getNextMidnight=me,m.getWeekdayShort=j,m.toTimestamp=T,m.vue3TimePlaybar=fe,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|