@w-run/wdesign-ui 1.0.0 → 1.1.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/README.md +208 -127
- package/dist/index.d.ts +1010 -80
- package/dist/parts/WdAffix.js +159 -0
- package/dist/parts/WdAiMessage.js +277 -0
- package/dist/parts/WdAlert.js +92 -0
- package/dist/parts/WdAnchor.js +159 -0
- package/dist/parts/WdAudioPlayer.js +1024 -0
- package/dist/parts/WdAvatar.js +6 -0
- package/dist/parts/WdAvatarGroup.js +46 -0
- package/dist/parts/WdBacktop.js +120 -0
- package/dist/parts/WdBadge.js +61 -0
- package/dist/parts/WdBento.js +40 -0
- package/dist/parts/WdBentoItem.js +43 -0
- package/dist/parts/WdBottomSheet.js +263 -0
- package/dist/parts/WdBreadcrumb.js +64 -0
- package/dist/parts/WdButton.js +94 -0
- package/dist/parts/WdCalendar.js +11 -0
- package/dist/parts/WdCard.js +113 -0
- package/dist/parts/WdCarousel.js +365 -0
- package/dist/parts/WdCascader.js +386 -0
- package/dist/parts/WdCheckbox.js +81 -0
- package/dist/parts/WdCollapse.js +135 -0
- package/dist/parts/WdColorPicker.js +592 -0
- package/dist/parts/WdCommand.js +357 -0
- package/dist/parts/WdContainer.js +37 -0
- package/dist/parts/WdCountdown.js +163 -0
- package/dist/parts/WdDanmaku.js +6 -0
- package/dist/parts/WdDatePicker.js +169 -0
- package/dist/parts/WdDateTimePicker.js +162 -0
- package/dist/parts/WdDescriptions.js +146 -0
- package/dist/parts/WdDivider.js +64 -0
- package/dist/parts/WdDrawer.js +176 -0
- package/dist/parts/WdDropdown.js +140 -0
- package/dist/parts/WdEmpty.js +79 -0
- package/dist/parts/WdExplorer.js +336 -0
- package/dist/parts/WdFileList.js +177 -0
- package/dist/parts/WdForm.js +111 -0
- package/dist/parts/WdFormItem.js +156 -0
- package/dist/parts/WdGrid.js +40 -0
- package/dist/parts/WdGroup.js +68 -0
- package/dist/parts/WdImagePreview.js +274 -0
- package/dist/parts/WdInput.js +10 -0
- package/dist/parts/WdInputNumber.js +253 -0
- package/dist/parts/WdListItem.js +60 -0
- package/dist/parts/WdLoading.js +128 -0
- package/dist/parts/WdMarkdown.js +172 -0
- package/dist/parts/WdMarquee.js +80 -0
- package/dist/parts/WdMasonry.js +40 -0
- package/dist/parts/WdMediaCard.js +302 -0
- package/dist/parts/WdMentions.js +277 -0
- package/dist/parts/WdModal.js +149 -0
- package/dist/parts/WdNav.js +311 -0
- package/dist/parts/WdNotification.js +112 -0
- package/dist/parts/WdOtp.js +107 -0
- package/dist/parts/WdPagination.js +252 -0
- package/dist/parts/WdPopconfirm.js +214 -0
- package/dist/parts/WdPopover.js +203 -0
- package/dist/parts/WdPostItem.js +84 -0
- package/dist/parts/WdProgress.js +48 -0
- package/dist/parts/WdProgressRing.js +101 -0
- package/dist/parts/WdPullRefresh.js +167 -0
- package/dist/parts/WdQRCode.js +1909 -0
- package/dist/parts/WdRadioGroup.js +95 -0
- package/dist/parts/WdRate.js +128 -0
- package/dist/parts/WdResult.js +86 -0
- package/dist/parts/WdScrollbar.js +186 -0
- package/dist/parts/WdSegmented.js +11 -0
- package/dist/parts/WdSelect.js +465 -0
- package/dist/parts/WdSkeleton.js +69 -0
- package/dist/parts/WdSlider.js +100 -0
- package/dist/parts/WdSortableList.js +291 -0
- package/dist/parts/WdSpace.js +46 -0
- package/dist/parts/WdSparkline.js +148 -0
- package/dist/parts/WdSpinner.js +6 -0
- package/dist/parts/WdSplitter.js +183 -0
- package/dist/parts/WdStatBar.js +202 -0
- package/dist/parts/WdStatistic.js +131 -0
- package/dist/parts/WdSteps.js +110 -0
- package/dist/parts/WdSwitch.js +63 -0
- package/dist/parts/WdTabBar.js +84 -0
- package/dist/parts/WdTable.js +589 -0
- package/dist/parts/WdTabs.js +219 -0
- package/dist/parts/WdTag.js +6 -0
- package/dist/parts/WdTagInput.js +181 -0
- package/dist/parts/WdTimePicker.js +12 -0
- package/dist/parts/WdTimeline.js +145 -0
- package/dist/parts/WdTooltip.js +108 -0
- package/dist/parts/WdTour.js +264 -0
- package/dist/parts/WdTransfer.js +446 -0
- package/dist/parts/WdTree.js +322 -0
- package/dist/parts/WdUpload.js +309 -0
- package/dist/parts/WdVideoPlayer.js +1006 -0
- package/dist/parts/WdVirtualList.js +169 -0
- package/dist/parts/WdWatermark.js +150 -0
- package/dist/parts/chunk-3LVE72ZK.js +361 -0
- package/dist/parts/chunk-5HYOQ52I.js +101 -0
- package/dist/parts/chunk-7M3MUL3B.js +275 -0
- package/dist/parts/chunk-AOTJ63HN.js +15 -0
- package/dist/parts/chunk-AXEF2U2A.js +41 -0
- package/dist/parts/chunk-CY3QOSFP.js +645 -0
- package/dist/parts/chunk-G7NN4A6J.js +40 -0
- package/dist/parts/chunk-HAKYCUAR.js +9 -0
- package/dist/parts/chunk-JDE4AHBR.js +160 -0
- package/dist/parts/chunk-LT3NTWIT.js +117 -0
- package/dist/parts/chunk-OGHYFT7B.js +387 -0
- package/dist/parts/chunk-Q34U2HES.js +261 -0
- package/dist/parts/chunk-RLSVPJHM.js +10 -0
- package/dist/parts/chunk-U2CDKD2T.js +30 -0
- package/dist/parts/chunk-UYUNYHZD.js +40 -0
- package/dist/parts/chunk-VUJL2HGD.js +23 -0
- package/dist/parts/chunk-WCFG5KNT.js +51 -0
- package/dist/parts/chunk-WDDAALPI.js +42 -0
- package/dist/parts/chunk-WFXLDBP2.js +149 -0
- package/dist/style/affix.css +566 -0
- package/dist/style/ai-msg.css +572 -13
- package/dist/style/alert.css +577 -5
- package/dist/style/anchor.css +630 -0
- package/dist/style/audio.css +658 -67
- package/dist/style/avatar.css +575 -12
- package/dist/style/backtop.css +625 -0
- package/dist/style/badge.css +595 -11
- package/dist/style/bento.css +763 -0
- package/dist/style/bottom-sheet.css +776 -0
- package/dist/style/breadcrumb.css +579 -4
- package/dist/style/button.css +631 -36
- package/dist/style/calendar.css +1512 -0
- package/dist/style/card.css +683 -6
- package/dist/style/carousel.css +573 -4
- package/dist/style/cascader.css +862 -0
- package/dist/style/checkbox.css +584 -7
- package/dist/style/chevron.css +543 -1
- package/dist/style/collapse.css +586 -7
- package/dist/style/colorpicker.css +876 -0
- package/dist/style/command.css +572 -13
- package/dist/style/container.css +543 -0
- package/dist/style/countdown.css +722 -0
- package/dist/style/danmaku.css +644 -0
- package/dist/style/datepicker.css +606 -128
- package/dist/style/datetime-picker.css +714 -0
- package/dist/style/descriptions.css +604 -11
- package/dist/style/divider.css +544 -2
- package/dist/style/dot.css +556 -1
- package/dist/style/drawer.css +609 -11
- package/dist/style/dropdown.css +565 -3
- package/dist/style/empty.css +624 -3
- package/dist/style/explorer.css +632 -24
- package/dist/style/file-list.css +577 -5
- package/dist/style/flip.css +600 -0
- package/dist/style/form.css +550 -8
- package/dist/style/grid.css +614 -0
- package/dist/style/group.css +560 -16
- package/dist/style/icon-btn.css +570 -4
- package/dist/style/image-preview.css +652 -8
- package/dist/style/input-number.css +680 -0
- package/dist/style/input.css +571 -8
- package/dist/style/list.css +553 -4
- package/dist/style/loading.css +667 -0
- package/dist/style/markdown.css +592 -20
- package/dist/style/marquee.css +678 -0
- package/dist/style/masonry.css +614 -0
- package/dist/style/media-card.css +1229 -0
- package/dist/style/mentions.css +690 -0
- package/dist/style/modal.css +626 -15
- package/dist/style/nav.css +1046 -0
- package/dist/style/notification.css +556 -7
- package/dist/style/otp.css +567 -7
- package/dist/style/pagination.css +571 -11
- package/dist/style/popconfirm.css +568 -10
- package/dist/style/popover.css +645 -15
- package/dist/style/post-item.css +548 -6
- package/dist/style/progress-ring.css +640 -0
- package/dist/style/progress.css +543 -1
- package/dist/style/pull-refresh.css +637 -0
- package/dist/style/qrcode.css +613 -0
- package/dist/style/radio.css +584 -5
- package/dist/style/rate.css +594 -1
- package/dist/style/result.css +546 -3
- package/dist/style/scroll-reveal.css +613 -0
- package/dist/style/scrollbar.css +644 -0
- package/dist/style/segmented-picker.css +573 -14
- package/dist/style/segmented.css +711 -7
- package/dist/style/select.css +682 -26
- package/dist/style/skeleton.css +559 -0
- package/dist/style/slider.css +565 -4
- package/dist/style/sortable.css +593 -7
- package/dist/style/space.css +543 -0
- package/dist/style/sparkline.css +606 -0
- package/dist/style/spinner.css +559 -0
- package/dist/style/splitter.css +711 -0
- package/dist/style/stat-bar.css +767 -0
- package/dist/style/statistic.css +552 -7
- package/dist/style/steps.css +633 -9
- package/dist/style/switch.css +585 -4
- package/dist/style/tab-bar.css +647 -0
- package/dist/style/table.css +886 -36
- package/dist/style/tabs.css +599 -10
- package/dist/style/tag-input.css +710 -0
- package/dist/style/tag.css +603 -18
- package/dist/style/time-picker.css +749 -0
- package/dist/style/timeline.css +575 -14
- package/dist/style/toast.css +567 -6
- package/dist/style/tooltip.css +564 -5
- package/dist/style/tour.css +683 -0
- package/dist/style/transfer.css +858 -0
- package/dist/style/tree.css +613 -16
- package/dist/style/typography.css +884 -3
- package/dist/style/upload.css +602 -13
- package/dist/style/vlist.css +543 -1
- package/dist/style/vplayer.css +799 -57
- package/dist/style/watermark.css +570 -0
- package/dist/wdesign-ui.css +18055 -7262
- package/dist/wdesign-ui.esm.js +8976 -5044
- package/package.json +99 -13
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// .lib-build/overlay-stack.ts
|
|
2
|
+
import { onBeforeUnmount, ref, watch } from "vue";
|
|
3
|
+
var stack = [];
|
|
4
|
+
var seq = 0;
|
|
5
|
+
var overlayDepth = ref(0);
|
|
6
|
+
var BASE_Z = 1e3;
|
|
7
|
+
var zSeq = 0;
|
|
8
|
+
function nextZIndex() {
|
|
9
|
+
if (stack.length === 0) zSeq = 0;
|
|
10
|
+
return BASE_Z + ++zSeq * 10;
|
|
11
|
+
}
|
|
12
|
+
function topOverlay() {
|
|
13
|
+
return stack[stack.length - 1];
|
|
14
|
+
}
|
|
15
|
+
function isTopOverlay(id) {
|
|
16
|
+
const t = topOverlay();
|
|
17
|
+
return !!t && t.id === id;
|
|
18
|
+
}
|
|
19
|
+
function pushOverlay(entry) {
|
|
20
|
+
const id = ++seq;
|
|
21
|
+
stack.push({ ...entry, id });
|
|
22
|
+
overlayDepth.value = stack.length;
|
|
23
|
+
return id;
|
|
24
|
+
}
|
|
25
|
+
function removeOverlay(id) {
|
|
26
|
+
const i = stack.findIndex((e) => e.id === id);
|
|
27
|
+
const removed = i >= 0 ? stack[i] : void 0;
|
|
28
|
+
if (i >= 0) stack.splice(i, 1);
|
|
29
|
+
overlayDepth.value = stack.length;
|
|
30
|
+
const to = removed?.restoreTo;
|
|
31
|
+
if (!to) return;
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
if (!to.isConnected || typeof to.focus !== "function") return;
|
|
34
|
+
if (to.hasAttribute("disabled")) return;
|
|
35
|
+
if (to.getAttribute("aria-hidden") === "true") return;
|
|
36
|
+
const rect = to.getBoundingClientRect();
|
|
37
|
+
if (rect.width === 0 && rect.height === 0) return;
|
|
38
|
+
const active = document.activeElement;
|
|
39
|
+
const anchorEl = removed?.panel.value;
|
|
40
|
+
const focusElsewhere = !!(active && active !== document.body && !(anchorEl && anchorEl.contains(active)) && !active.closest('.wd-datepicker__panel, .wd-select__menu, .wd-dropdown__menu, .wd-popover__panel, [class*="__panel"], [class*="__menu"]'));
|
|
41
|
+
if (focusElsewhere) return;
|
|
42
|
+
to.focus({ preventScroll: true });
|
|
43
|
+
}, 0);
|
|
44
|
+
}
|
|
45
|
+
function useOverlayLayer(open, panel, onEsc) {
|
|
46
|
+
installOverlayKeyboard();
|
|
47
|
+
let myId = null;
|
|
48
|
+
watch(
|
|
49
|
+
open,
|
|
50
|
+
(v) => {
|
|
51
|
+
if (v) {
|
|
52
|
+
const active = document.activeElement;
|
|
53
|
+
myId = pushOverlay({
|
|
54
|
+
panel,
|
|
55
|
+
restoreTo: active && active !== document.body ? active : null,
|
|
56
|
+
onEscape: onEsc
|
|
57
|
+
});
|
|
58
|
+
} else if (myId !== null) {
|
|
59
|
+
removeOverlay(myId);
|
|
60
|
+
myId = null;
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{ immediate: true }
|
|
64
|
+
);
|
|
65
|
+
onBeforeUnmount(() => {
|
|
66
|
+
if (myId !== null) {
|
|
67
|
+
removeOverlay(myId);
|
|
68
|
+
myId = null;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return {
|
|
72
|
+
/** 本层是否在栈顶(需要响应键盘时先判断它) */
|
|
73
|
+
isTop: () => myId === null ? false : isTopOverlay(myId)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
var installed = false;
|
|
77
|
+
function installOverlayKeyboard() {
|
|
78
|
+
if (installed || typeof document === "undefined") return;
|
|
79
|
+
installed = true;
|
|
80
|
+
document.addEventListener(
|
|
81
|
+
"keydown",
|
|
82
|
+
(e) => {
|
|
83
|
+
const top = topOverlay();
|
|
84
|
+
if (!top) return;
|
|
85
|
+
if (e.key === "Escape") {
|
|
86
|
+
const handled = top.onEscape?.();
|
|
87
|
+
if (handled !== false) {
|
|
88
|
+
e.stopPropagation();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
true
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export {
|
|
97
|
+
nextZIndex,
|
|
98
|
+
topOverlay,
|
|
99
|
+
useOverlayLayer,
|
|
100
|
+
installOverlayKeyboard
|
|
101
|
+
};
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
// .lib-build/WdDanmaku.ts
|
|
2
|
+
import { defineComponent as _defineComponent } from "vue";
|
|
3
|
+
import { createCommentVNode as _createCommentVNode, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, toDisplayString as _toDisplayString, normalizeStyle as _normalizeStyle } from "vue";
|
|
4
|
+
import { computed, onBeforeUnmount, ref, watch } from "vue";
|
|
5
|
+
|
|
6
|
+
// .lib-build/danmaku-source.ts
|
|
7
|
+
function decToHex(dec) {
|
|
8
|
+
const n = Math.max(0, Math.min(16777215, dec | 0));
|
|
9
|
+
return "#" + n.toString(16).padStart(6, "0").toUpperCase();
|
|
10
|
+
}
|
|
11
|
+
function parseBiliXml(xml) {
|
|
12
|
+
const out = [];
|
|
13
|
+
const re = /<d\s+p="([^"]*)"[^>]*>([\s\S]*?)<\/d>/g;
|
|
14
|
+
let m;
|
|
15
|
+
while ((m = re.exec(xml)) !== null) {
|
|
16
|
+
const attrs = m[1].split(",");
|
|
17
|
+
const text = unescapeHtml(m[2]).trim();
|
|
18
|
+
if (!text) continue;
|
|
19
|
+
const time = parseFloat(attrs[0]);
|
|
20
|
+
if (!isFinite(time)) continue;
|
|
21
|
+
const modeNum = parseInt(attrs[1], 10);
|
|
22
|
+
const colorDec = parseInt(attrs[3], 10);
|
|
23
|
+
let mode = "scroll";
|
|
24
|
+
if (modeNum === 4) mode = "bottom";
|
|
25
|
+
else if (modeNum === 5) mode = "top";
|
|
26
|
+
out.push({
|
|
27
|
+
time,
|
|
28
|
+
text,
|
|
29
|
+
mode,
|
|
30
|
+
// 白色(16777215)是默认值,不显式设置省一次属性
|
|
31
|
+
color: isFinite(colorDec) && colorDec !== 16777215 ? decToHex(colorDec) : void 0
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return out.sort((a, b) => a.time - b.time);
|
|
35
|
+
}
|
|
36
|
+
function unescapeHtml(s) {
|
|
37
|
+
return s.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
38
|
+
}
|
|
39
|
+
function parseJson(json) {
|
|
40
|
+
if (!Array.isArray(json)) return [];
|
|
41
|
+
const out = [];
|
|
42
|
+
for (const raw of json) {
|
|
43
|
+
if (!raw || typeof raw !== "object") continue;
|
|
44
|
+
const o = raw;
|
|
45
|
+
const time = Number(o.time ?? o.t ?? o.start ?? o.stime);
|
|
46
|
+
const text = String(o.text ?? o.content ?? o.body ?? "").trim();
|
|
47
|
+
if (!isFinite(time) || !text) continue;
|
|
48
|
+
const modeRaw = o.mode;
|
|
49
|
+
const mode = modeRaw === "top" || modeRaw === 5 ? "top" : modeRaw === "bottom" || modeRaw === 4 ? "bottom" : "scroll";
|
|
50
|
+
out.push({
|
|
51
|
+
time,
|
|
52
|
+
text,
|
|
53
|
+
mode,
|
|
54
|
+
color: typeof o.color === "string" ? o.color : void 0
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return out.sort((a, b) => a.time - b.time);
|
|
58
|
+
}
|
|
59
|
+
function parseText(text) {
|
|
60
|
+
const out = [];
|
|
61
|
+
for (const line of text.split(/\r?\n/)) {
|
|
62
|
+
const t = line.trim();
|
|
63
|
+
if (!t || t.startsWith("#")) continue;
|
|
64
|
+
const parts = t.split(",");
|
|
65
|
+
if (parts.length < 2) continue;
|
|
66
|
+
const time = parseFloat(parts[0]);
|
|
67
|
+
if (!isFinite(time)) continue;
|
|
68
|
+
const rest = parts.slice(1).join(",").trim();
|
|
69
|
+
if (!rest) continue;
|
|
70
|
+
const modePart = (parts[1] || "").trim().toLowerCase();
|
|
71
|
+
const colorPart = (parts[2] || "").trim();
|
|
72
|
+
const textStart = rest.startsWith(modePart) || rest.startsWith(colorPart) ? rest.replace(/^[^,]*,?/, "").replace(/^[^,]*,?/, "") : rest;
|
|
73
|
+
out.push({
|
|
74
|
+
time,
|
|
75
|
+
text: textStart.trim() || rest,
|
|
76
|
+
mode: modePart === "top" ? "top" : modePart === "bottom" ? "bottom" : "scroll",
|
|
77
|
+
color: /^#[0-9a-f]{3,8}$/i.test(colorPart) ? colorPart : void 0
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return out.sort((a, b) => a.time - b.time);
|
|
81
|
+
}
|
|
82
|
+
function parseDanmaku(input) {
|
|
83
|
+
if (Array.isArray(input)) return parseJson(input);
|
|
84
|
+
if (typeof input !== "string") return [];
|
|
85
|
+
const s = input.trim();
|
|
86
|
+
if (!s) return [];
|
|
87
|
+
if (s.includes("<d p=") || s.startsWith("<?xml") || s.startsWith("<i>")) {
|
|
88
|
+
return parseBiliXml(s);
|
|
89
|
+
}
|
|
90
|
+
if (s.startsWith("[") || s.startsWith("{")) {
|
|
91
|
+
try {
|
|
92
|
+
return parseJson(JSON.parse(s));
|
|
93
|
+
} catch {
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return parseText(s);
|
|
97
|
+
}
|
|
98
|
+
async function loadDanmaku(url) {
|
|
99
|
+
const res = await fetch(url);
|
|
100
|
+
if (!res.ok) throw new Error(`\u5F39\u5E55\u52A0\u8F7D\u5931\u8D25\uFF1AHTTP ${res.status}`);
|
|
101
|
+
const text = await res.text();
|
|
102
|
+
return parseDanmaku(text);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// .lib-build/WdDanmaku.ts
|
|
106
|
+
var WINDOW = 8;
|
|
107
|
+
var WdDanmaku_default = /* @__PURE__ */ _defineComponent({
|
|
108
|
+
...{ name: "WdDanmaku" },
|
|
109
|
+
__name: "WdDanmaku",
|
|
110
|
+
props: {
|
|
111
|
+
items: { type: Array, required: false, default: () => [] },
|
|
112
|
+
src: { type: String, required: false, default: "" },
|
|
113
|
+
raw: { type: String, required: false, default: "" },
|
|
114
|
+
current: { type: Number, required: false, default: 0 },
|
|
115
|
+
visible: { type: Boolean, required: false, default: true },
|
|
116
|
+
paused: { type: Boolean, required: false, default: false },
|
|
117
|
+
speed: { type: Number, required: false, default: 120 },
|
|
118
|
+
rows: { type: Number, required: false, default: 6 },
|
|
119
|
+
fontSize: { type: Number, required: false, default: 15 },
|
|
120
|
+
opacity: { type: Number, required: false, default: 1 }
|
|
121
|
+
},
|
|
122
|
+
emits: ["error"],
|
|
123
|
+
setup(__props, { emit: __emit }) {
|
|
124
|
+
const props = __props;
|
|
125
|
+
const emit = __emit;
|
|
126
|
+
const loaded = ref([]);
|
|
127
|
+
const loadError = ref("");
|
|
128
|
+
const loading = ref(false);
|
|
129
|
+
const resolved = computed(() => {
|
|
130
|
+
if (props.items.length) return props.items;
|
|
131
|
+
if (props.raw) return parseDanmaku(props.raw);
|
|
132
|
+
return loaded.value;
|
|
133
|
+
});
|
|
134
|
+
watch(
|
|
135
|
+
() => props.src,
|
|
136
|
+
async (url) => {
|
|
137
|
+
loaded.value = [];
|
|
138
|
+
loadError.value = "";
|
|
139
|
+
if (!url) return;
|
|
140
|
+
loading.value = true;
|
|
141
|
+
try {
|
|
142
|
+
loaded.value = await loadDanmaku(url);
|
|
143
|
+
} catch (e) {
|
|
144
|
+
loadError.value = e instanceof Error ? e.message : String(e);
|
|
145
|
+
emit("error", loadError.value);
|
|
146
|
+
} finally {
|
|
147
|
+
loading.value = false;
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
{ immediate: true }
|
|
151
|
+
);
|
|
152
|
+
const active = computed(() => {
|
|
153
|
+
if (!props.visible) return [];
|
|
154
|
+
const t = props.current;
|
|
155
|
+
return resolved.value.map((it, i) => ({ ...it, _i: i })).filter((it) => it.time <= t && it.time > t - WINDOW).map((it) => ({
|
|
156
|
+
...it,
|
|
157
|
+
/** 已经飞过的百分比,用于让中途进入的弹幕从正确位置开始 */
|
|
158
|
+
progress: (t - it.time) / WINDOW
|
|
159
|
+
}));
|
|
160
|
+
});
|
|
161
|
+
const assigned = computed(() => {
|
|
162
|
+
return active.value.map((it, i) => ({
|
|
163
|
+
...it,
|
|
164
|
+
row: it.mode === "top" ? 0 : it.mode === "bottom" ? props.rows - 1 : i % props.rows
|
|
165
|
+
}));
|
|
166
|
+
});
|
|
167
|
+
const fixedTop = computed(() => assigned.value.filter((d) => d.mode === "top").slice(0, 2));
|
|
168
|
+
const fixedBottom = computed(() => assigned.value.filter((d) => d.mode === "bottom").slice(0, 2));
|
|
169
|
+
const layerStyle = computed(() => ({
|
|
170
|
+
"--dm-font": props.fontSize + "px",
|
|
171
|
+
"--dm-opacity": String(props.opacity),
|
|
172
|
+
"--dm-rows": String(props.rows),
|
|
173
|
+
/*
|
|
174
|
+
* 暂停时用 animation-play-state: paused 让所有弹幕**原地定格**。
|
|
175
|
+
* ⚠️ 不能用"暂停就不渲染" —— 那会让弹幕瞬间消失,
|
|
176
|
+
* 恢复播放又从窗口外重新飞入,观感是"闪一下然后重来"。
|
|
177
|
+
*/
|
|
178
|
+
"--dm-play-state": props.paused ? "paused" : "running"
|
|
179
|
+
}));
|
|
180
|
+
function itemStyle(d) {
|
|
181
|
+
return {
|
|
182
|
+
top: `calc(var(--dm-row-h) * ${d.row} + 6px)`,
|
|
183
|
+
color: d.color || "#fff",
|
|
184
|
+
// 负 delay 让"已开始"的弹幕从中间位置继续,而不是从头飞
|
|
185
|
+
animationDelay: `-${d.progress * 8}s`
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
const root = ref(null);
|
|
189
|
+
watch(() => props.visible, () => {
|
|
190
|
+
});
|
|
191
|
+
onBeforeUnmount(() => {
|
|
192
|
+
});
|
|
193
|
+
return (_ctx, _cache) => {
|
|
194
|
+
return __props.visible && resolved.value.length ? (_openBlock(), _createElementBlock(
|
|
195
|
+
"div",
|
|
196
|
+
{
|
|
197
|
+
key: 0,
|
|
198
|
+
ref_key: "root",
|
|
199
|
+
ref: root,
|
|
200
|
+
class: "wd-danmaku",
|
|
201
|
+
style: _normalizeStyle(layerStyle.value),
|
|
202
|
+
"aria-hidden": "true"
|
|
203
|
+
},
|
|
204
|
+
[
|
|
205
|
+
_createCommentVNode(" \u6EDA\u52A8\u5F39\u5E55 "),
|
|
206
|
+
(_openBlock(true), _createElementBlock(
|
|
207
|
+
_Fragment,
|
|
208
|
+
null,
|
|
209
|
+
_renderList(assigned.value.filter((x) => !x.mode || x.mode === "scroll"), (d) => {
|
|
210
|
+
return _openBlock(), _createElementBlock(
|
|
211
|
+
"div",
|
|
212
|
+
{
|
|
213
|
+
key: d._i,
|
|
214
|
+
class: "wd-danmaku__item",
|
|
215
|
+
style: _normalizeStyle(itemStyle(d))
|
|
216
|
+
},
|
|
217
|
+
_toDisplayString(d.text),
|
|
218
|
+
5
|
|
219
|
+
/* TEXT, STYLE */
|
|
220
|
+
);
|
|
221
|
+
}),
|
|
222
|
+
128
|
|
223
|
+
/* KEYED_FRAGMENT */
|
|
224
|
+
)),
|
|
225
|
+
_createCommentVNode(" \u9876\u90E8\u56FA\u5B9A "),
|
|
226
|
+
(_openBlock(true), _createElementBlock(
|
|
227
|
+
_Fragment,
|
|
228
|
+
null,
|
|
229
|
+
_renderList(fixedTop.value, (d, i) => {
|
|
230
|
+
return _openBlock(), _createElementBlock(
|
|
231
|
+
"div",
|
|
232
|
+
{
|
|
233
|
+
key: "t" + d._i,
|
|
234
|
+
class: "wd-danmaku__item wd-danmaku__item--fixed",
|
|
235
|
+
style: _normalizeStyle({ top: i * 30 + 6 + "px", color: d.color || "#fff" })
|
|
236
|
+
},
|
|
237
|
+
_toDisplayString(d.text),
|
|
238
|
+
5
|
|
239
|
+
/* TEXT, STYLE */
|
|
240
|
+
);
|
|
241
|
+
}),
|
|
242
|
+
128
|
|
243
|
+
/* KEYED_FRAGMENT */
|
|
244
|
+
)),
|
|
245
|
+
_createCommentVNode(" \u5E95\u90E8\u56FA\u5B9A "),
|
|
246
|
+
(_openBlock(true), _createElementBlock(
|
|
247
|
+
_Fragment,
|
|
248
|
+
null,
|
|
249
|
+
_renderList(fixedBottom.value, (d, i) => {
|
|
250
|
+
return _openBlock(), _createElementBlock(
|
|
251
|
+
"div",
|
|
252
|
+
{
|
|
253
|
+
key: "b" + d._i,
|
|
254
|
+
class: "wd-danmaku__item wd-danmaku__item--fixed",
|
|
255
|
+
style: _normalizeStyle({ bottom: i * 30 + 6 + "px", color: d.color || "#fff" })
|
|
256
|
+
},
|
|
257
|
+
_toDisplayString(d.text),
|
|
258
|
+
5
|
|
259
|
+
/* TEXT, STYLE */
|
|
260
|
+
);
|
|
261
|
+
}),
|
|
262
|
+
128
|
|
263
|
+
/* KEYED_FRAGMENT */
|
|
264
|
+
))
|
|
265
|
+
],
|
|
266
|
+
4
|
|
267
|
+
/* STYLE */
|
|
268
|
+
)) : _createCommentVNode("v-if", true);
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
export {
|
|
274
|
+
WdDanmaku_default
|
|
275
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// .lib-build/time.ts
|
|
2
|
+
function formatDuration(seconds, forceHours = false) {
|
|
3
|
+
if (!Number.isFinite(seconds) || seconds < 0) seconds = 0;
|
|
4
|
+
const total = Math.floor(seconds);
|
|
5
|
+
const h = Math.floor(total / 3600);
|
|
6
|
+
const m = Math.floor(total % 3600 / 60);
|
|
7
|
+
const s = total % 60;
|
|
8
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
9
|
+
if (h > 0 || forceHours) return `${h}:${pad(m)}:${pad(s)}`;
|
|
10
|
+
return `${m}:${pad(s)}`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
formatDuration
|
|
15
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// .lib-build/WdTag.ts
|
|
2
|
+
import { defineComponent as _defineComponent } from "vue";
|
|
3
|
+
import { openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, renderSlot as _renderSlot, normalizeClass as _normalizeClass } from "vue";
|
|
4
|
+
var _hoisted_1 = {
|
|
5
|
+
key: 0,
|
|
6
|
+
class: "wd-tag__dot"
|
|
7
|
+
};
|
|
8
|
+
var WdTag_default = /* @__PURE__ */ _defineComponent({
|
|
9
|
+
...{ name: "WdTag" },
|
|
10
|
+
__name: "WdTag",
|
|
11
|
+
props: {
|
|
12
|
+
variant: { type: String, required: false, default: "tint" },
|
|
13
|
+
size: { type: String, required: false },
|
|
14
|
+
dot: { type: Boolean, required: false, default: false },
|
|
15
|
+
plain: { type: Boolean, required: false, default: false }
|
|
16
|
+
},
|
|
17
|
+
setup(__props) {
|
|
18
|
+
return (_ctx, _cache) => {
|
|
19
|
+
return _openBlock(), _createElementBlock(
|
|
20
|
+
"span",
|
|
21
|
+
{
|
|
22
|
+
class: _normalizeClass(["wd-tag", [
|
|
23
|
+
`wd-tag--${__props.variant}`,
|
|
24
|
+
{ "wd-tag--lg": __props.size === "lg", "wd-tag--sm": __props.size === "sm", "wd-tag--plain": __props.plain }
|
|
25
|
+
]]),
|
|
26
|
+
"data-wd-hover": ""
|
|
27
|
+
},
|
|
28
|
+
[
|
|
29
|
+
__props.dot ? (_openBlock(), _createElementBlock("i", _hoisted_1)) : _createCommentVNode("v-if", true),
|
|
30
|
+
_renderSlot(_ctx.$slots, "default")
|
|
31
|
+
],
|
|
32
|
+
2
|
|
33
|
+
/* CLASS */
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
WdTag_default
|
|
41
|
+
};
|