quick-admin-vue3-core
Version:
以快(计算机执行效率、开发效率)为核心的后台管理系统开发模板
153 lines (152 loc) • 5.05 kB
JavaScript
import { defineComponent as D, useSlots as F, ref as f, resolveComponent as g, createElementBlock as y, openBlock as s, renderSlot as U, createCommentVNode as k, unref as e, Fragment as E, createVNode as C, createElementVNode as b, createBlock as p, normalizeClass as N, withCtx as T, toDisplayString as q, isRef as G, createTextVNode as H } from "vue";
import { v as J, c as K, d as L, e as O } from "./index-D-KS7NhM.js";
import { _ as Q } from "./_plugin-vue_export-helper-CHgC5LLL.js";
const W = ["data-default"], X = { class: "f-0 ml-h" }, Y = ["muted", "controls"], Z = ["src"], x = ["src"], ee = /* @__PURE__ */ D({
__name: "BaseAudio",
props: {
src: {},
showProgress: { type: Boolean, default: !0 },
default: { type: Boolean, default: !0 },
controls: { type: Boolean }
},
setup(oe, { expose: P }) {
const $ = F(), n = f(null), r = f(!1), c = f(0), d = f(!1), i = f("00:00/00:00"), u = f(!0);
function z(o) {
const { currentTime: t, duration: a } = n.value;
i.value = `${l(t)}/${l(a)}`, u.value = !a;
}
function I(o) {
const { currentTime: t, duration: a } = n.value;
i.value = `${l(t)}/${l(a)}`, c.value = t / a * 100;
}
function M() {
r.value = !1, i.value = `00:00/${l(n.value.duration)}`;
}
function R(o) {
const { duration: t } = n.value;
n.value.currentTime = t * (o / 100), m();
}
function A(o) {
const { duration: t } = n.value, a = t * (o / 100);
i.value = `${l(a)}/${l(t)}`, v();
}
function B() {
r.value ? v() : m();
}
function h() {
u.value || (d.value = !d.value);
}
function l(o) {
o = Math.round(o);
const t = Math.floor(o / 60), a = o % 60;
return [t, a].map((_) => (_ < 10 ? "0" : "") + _).join(":");
}
function m() {
u.value || (r.value = !0, n.value.play());
}
function v() {
u.value || (r.value = !1, n.value.pause());
}
return P({
playing: r,
progress: c,
timeStr: i,
muted: d,
play: m,
pause: v,
audioCtx: n,
toggleMuted: h,
formatTime: l
}), (o, t) => {
var V, w;
const a = g("el-icon"), S = g("el-slider"), _ = g("el-tooltip");
return s(), y("div", {
class: "base-audio f-sb-c",
"data-default": !o.controls && !$.default
}, [
$.content ? U(o.$slots, "content", {
key: 0,
playing: e(r),
muted: e(d),
currentTime: ((V = e(n)) == null ? void 0 : V.currentTime) || 0,
duration: ((w = e(n)) == null ? void 0 : w.duration) || 0,
timeStr: e(i),
progress: e(c),
play: m,
pause: v,
togglePlaying: B,
toggleMuted: h,
formatTime: l
}, void 0, !0) : (s(), y(E, { key: 1 }, [
o.controls ? k("", !0) : (s(), y(E, { key: 0 }, [
C(a, {
onClick: B,
size: "20",
class: N(["f-0 btn", { disabled: e(u) }])
}, {
default: T(() => [
e(r) ? (s(), p(e(J), { key: 0 })) : (s(), p(e(K), { key: 1 }))
]),
_: 1
}, 8, ["class"]),
b("time", X, q(e(i)), 1),
o.showProgress ? (s(), p(S, {
key: 0,
onChange: R,
onInput: A,
modelValue: e(c),
"onUpdate:modelValue": t[0] || (t[0] = (j) => G(c) ? c.value = j : null),
"show-tooltip": !1,
disabled: e(u),
class: "f-1 ml-o"
}, null, 8, ["modelValue", "disabled"])) : k("", !0),
C(_, {
content: e(d) ? "取消静音" : "静音",
"show-after": 400,
disabled: e(u)
}, {
default: T(() => [
C(a, {
onClick: h,
size: "20",
class: N(["btn f-0 ml-h", { disabled: e(u) }])
}, {
default: T(() => [
e(d) ? (s(), p(e(L), { key: 0 })) : (s(), p(e(O), { key: 1 }))
]),
_: 1
}, 8, ["class"])
]),
_: 1
}, 8, ["content", "disabled"])
], 64))
], 64)),
o.src ? (s(), y("audio", {
key: 2,
class: "audio",
muted: e(d),
controls: o.controls,
hidden: "",
onCanplay: z,
onTimeupdate: I,
onEnded: M,
ref_key: "audioRef",
ref: n
}, [
b("source", {
src: o.src,
type: "audio/mpeg"
}, null, 8, Z),
b("source", {
src: o.src,
type: "audio/ogg"
}, null, 8, x),
t[1] || (t[1] = H(" 您的浏览器不支持音频播放 "))
], 40, Y)) : k("", !0)
], 8, W);
};
}
}), le = /* @__PURE__ */ Q(ee, [["__scopeId", "data-v-9651f851"]]);
export {
le as default
};