@ezuikit/player-theme 0.0.1-beta.1 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
- * @ezuikit/player-theme v0.0.1-beta.1
3
- * Copyright (c) 2025-10-17 Ezviz-OpenBiz
2
+ * @ezuikit/player-theme v1.0.0-beta.1
3
+ * Copyright (c) 2025-10-27 Ezviz-OpenBiz
4
4
  * Released under the MIT License.
5
5
  */
6
6
  (function (global, factory) {
@@ -980,7 +980,7 @@
980
980
  return Poster;
981
981
  }(Control);
982
982
 
983
- var Icons = {
983
+ var Icons$1 = {
984
984
  /** 播放 */ play: '<svg width="1em" height="1em" viewBox="0 0 24 24" fill="currentColor" focusable="false" aria-hidden="true" data-icon="play">\n <rect x="6.5" y="5.5" rx="1.25" width="2.5" height="13"/>\n <rect x="15" y="5.5" rx="1.25" width="2.5" height="13"/>\n </svg>',
985
985
  /** 暂停 */ pause: '<svg width="1em" height="1em" viewBox="0 0 24 24" fill="currentColor" focusable="false" aria-hidden="true" data-icon="pause"> <path d="M17.5 13.66L9.1 19.26C7.78 20.14 6 19.19 6 17.59L6 6.4C6 4.8 7.78 3.85 9.1 4.73L17.5 10.33C18.69 11.12 18.69 12.87 17.5 13.66Z" /></svg>',
986
986
  /** 音量 */ volume: function(prefix) {
@@ -1046,131 +1046,131 @@
1046
1046
  var IconComponents = {
1047
1047
  /** 播放 */ play: function(attr) {
1048
1048
  if (attr === void 0) attr = {};
1049
- return createIcon(Icons.play, 'play', attr);
1049
+ return createIcon(Icons$1.play, 'play', attr);
1050
1050
  },
1051
1051
  /** 暂停 */ pause: function(attr) {
1052
1052
  if (attr === void 0) attr = {};
1053
- return createIcon(Icons.pause, 'pause', attr);
1053
+ return createIcon(Icons$1.pause, 'pause', attr);
1054
1054
  },
1055
1055
  volume: function(attr) {
1056
1056
  if (attr === void 0) attr = {};
1057
- return createIcon(Icons.volume(PREFIX_CLASS), 'volume', attr);
1057
+ return createIcon(Icons$1.volume(PREFIX_CLASS), 'volume', attr);
1058
1058
  },
1059
1059
  mobileFullscreen: function(attr) {
1060
1060
  if (attr === void 0) attr = {};
1061
- return createIcon(Icons.mobileFullscreen, 'mobile-fullscreen', attr);
1061
+ return createIcon(Icons$1.mobileFullscreen, 'mobile-fullscreen', attr);
1062
1062
  },
1063
1063
  exitFullscreen: function(attr) {
1064
1064
  if (attr === void 0) attr = {};
1065
- return createIcon(Icons.exitFullscreen, 'exit-fullscreen', attr);
1065
+ return createIcon(Icons$1.exitFullscreen, 'exit-fullscreen', attr);
1066
1066
  },
1067
1067
  fullscreen: function(attr) {
1068
1068
  if (attr === void 0) attr = {};
1069
- return createIcon(Icons.fullscreen, 'fullscreen', attr);
1069
+ return createIcon(Icons$1.fullscreen, 'fullscreen', attr);
1070
1070
  },
1071
1071
  exitGlobalFullscreen: function(attr) {
1072
1072
  if (attr === void 0) attr = {};
1073
- return createIcon(Icons.exitGlobalFullscreen, 'exit-global-fullscreen', attr);
1073
+ return createIcon(Icons$1.exitGlobalFullscreen, 'exit-global-fullscreen', attr);
1074
1074
  },
1075
1075
  globalFullscreen: function(attr) {
1076
1076
  if (attr === void 0) attr = {};
1077
- return createIcon(Icons.globalFullscreen, 'global-fullscreen', attr);
1077
+ return createIcon(Icons$1.globalFullscreen, 'global-fullscreen', attr);
1078
1078
  },
1079
1079
  capturePicture: function(attr) {
1080
1080
  if (attr === void 0) attr = {};
1081
- return createIcon(Icons.capturePicture, 'capture-picture', attr);
1081
+ return createIcon(Icons$1.capturePicture, 'capture-picture', attr);
1082
1082
  },
1083
1083
  ptz: function(attr) {
1084
1084
  if (attr === void 0) attr = {};
1085
- return createIcon(Icons.ptz, 'ptz', attr);
1085
+ return createIcon(Icons$1.ptz, 'ptz', attr);
1086
1086
  },
1087
1087
  record: function(attr) {
1088
1088
  if (attr === void 0) attr = {};
1089
- return createIcon(Icons.record, 'record', attr);
1089
+ return createIcon(Icons$1.record, 'record', attr);
1090
1090
  },
1091
1091
  recordCircle: function(attr) {
1092
1092
  if (attr === void 0) attr = {};
1093
- return createIcon(Icons.recordCircle, 'record-circle', attr);
1093
+ return createIcon(Icons$1.recordCircle, 'record-circle', attr);
1094
1094
  },
1095
1095
  talk: function(attr) {
1096
1096
  if (attr === void 0) attr = {};
1097
- return createIcon(Icons.talk, 'talk', attr);
1097
+ return createIcon(Icons$1.talk, 'talk', attr);
1098
1098
  },
1099
1099
  talkGrowth: function(attr) {
1100
1100
  if (attr === void 0) attr = {};
1101
- return createIcon(Icons.talkGrowth(PREFIX_CLASS), 'talk-growth', attr);
1101
+ return createIcon(Icons$1.talkGrowth(PREFIX_CLASS), 'talk-growth', attr);
1102
1102
  },
1103
1103
  zoom: function(attr) {
1104
1104
  if (attr === void 0) attr = {};
1105
- return createIcon(Icons.zoom, 'zoom', attr);
1105
+ return createIcon(Icons$1.zoom, 'zoom', attr);
1106
1106
  },
1107
1107
  more: function(attr) {
1108
1108
  if (attr === void 0) attr = {};
1109
- return createIcon(Icons.more, 'more', attr);
1109
+ return createIcon(Icons$1.more, 'more', attr);
1110
1110
  },
1111
1111
  moreDot: function(attr) {
1112
1112
  if (attr === void 0) attr = {};
1113
- return createIcon(Icons.moreDot, 'more-dot', attr);
1113
+ return createIcon(Icons$1.moreDot, 'more-dot', attr);
1114
1114
  },
1115
1115
  minusCircle: function(attr) {
1116
1116
  if (attr === void 0) attr = {};
1117
- return createIcon(Icons.minusCircle, 'minus-circle', attr);
1117
+ return createIcon(Icons$1.minusCircle, 'minus-circle', attr);
1118
1118
  },
1119
1119
  plusCircle: function(attr) {
1120
1120
  if (attr === void 0) attr = {};
1121
- return createIcon(Icons.plusCircle, 'plus-circle', attr);
1121
+ return createIcon(Icons$1.plusCircle, 'plus-circle', attr);
1122
1122
  },
1123
1123
  sdk: function(attr) {
1124
1124
  if (attr === void 0) attr = {};
1125
- return createIcon(Icons.sdk, 'sdk', attr);
1125
+ return createIcon(Icons$1.sdk, 'sdk', attr);
1126
1126
  },
1127
1127
  cloudRec: function(attr) {
1128
1128
  if (attr === void 0) attr = {};
1129
- return createIcon(Icons.cloudRec, 'cloud-rec', attr);
1129
+ return createIcon(Icons$1.cloudRec, 'cloud-rec', attr);
1130
1130
  },
1131
1131
  cloudRecord: function(attr) {
1132
1132
  if (attr === void 0) attr = {};
1133
- return createIcon(Icons.cloudRecord, 'cloud-record', attr);
1133
+ return createIcon(Icons$1.cloudRecord, 'cloud-record', attr);
1134
1134
  },
1135
1135
  error: function(attr) {
1136
1136
  if (attr === void 0) attr = {};
1137
- return createIcon(Icons.error, 'error', attr);
1137
+ return createIcon(Icons$1.error, 'error', attr);
1138
1138
  },
1139
1139
  info: function(attr) {
1140
1140
  if (attr === void 0) attr = {};
1141
- return createIcon(Icons.info, 'info', attr);
1141
+ return createIcon(Icons$1.info, 'info', attr);
1142
1142
  },
1143
1143
  close: function(attr) {
1144
1144
  if (attr === void 0) attr = {};
1145
- return createIcon(Icons.close, 'close', attr);
1145
+ return createIcon(Icons$1.close, 'close', attr);
1146
1146
  },
1147
1147
  closeCircleOutLined: function(attr) {
1148
1148
  if (attr === void 0) attr = {};
1149
- return createIcon(Icons.closeCircleOutLined, 'close-circle', attr);
1149
+ return createIcon(Icons$1.closeCircleOutLined, 'close-circle', attr);
1150
1150
  },
1151
1151
  warnCircleOutLined: function(attr) {
1152
1152
  if (attr === void 0) attr = {};
1153
- return createIcon(Icons.warnCircleOutLined, 'warn-circle', attr);
1153
+ return createIcon(Icons$1.warnCircleOutLined, 'warn-circle', attr);
1154
1154
  },
1155
1155
  infoCircleOutLined: function(attr) {
1156
1156
  if (attr === void 0) attr = {};
1157
- return createIcon(Icons.infoCircleOutLined, 'info-circle', attr);
1157
+ return createIcon(Icons$1.infoCircleOutLined, 'info-circle', attr);
1158
1158
  },
1159
1159
  date: function(attr) {
1160
1160
  if (attr === void 0) attr = {};
1161
- return createIcon(Icons.date, 'date', attr);
1161
+ return createIcon(Icons$1.date, 'date', attr);
1162
1162
  },
1163
1163
  filter: function(attr) {
1164
1164
  if (attr === void 0) attr = {};
1165
- return createIcon(Icons.filter, 'filter', attr);
1165
+ return createIcon(Icons$1.filter, 'filter', attr);
1166
1166
  },
1167
1167
  add: function(attr) {
1168
1168
  if (attr === void 0) attr = {};
1169
- return createIcon(Icons.add, 'add', attr);
1169
+ return createIcon(Icons$1.add, 'add', attr);
1170
1170
  },
1171
1171
  reduce: function(attr) {
1172
1172
  if (attr === void 0) attr = {};
1173
- return createIcon(Icons.reduce, 'reduce', attr);
1173
+ return createIcon(Icons$1.reduce, 'reduce', attr);
1174
1174
  }
1175
1175
  };
1176
1176
 
@@ -1463,16 +1463,18 @@
1463
1463
  }(Control);
1464
1464
 
1465
1465
  /*
1466
- * @skax/picker v0.1.1
1467
- * Copyright (c) 2025-08-31 ShineShao <xiaoshaoqq@gmail.com>
1466
+ * @skax/picker v1.0.2
1467
+ * Copyright (c) 2025-10-26 ShineShao <xiaoshaoqq@gmail.com>
1468
1468
  * Released under the MIT License.
1469
1469
  */
1470
- let Provider$1 = class Provider {
1470
+ /**
1471
+ * PickerProvider
1472
+ */ class PickerProvider {
1471
1473
  static getInstance() {
1472
- if (!Provider.instance) {
1473
- Provider.instance = new Provider();
1474
+ if (!PickerProvider.instance) {
1475
+ PickerProvider.instance = new PickerProvider();
1474
1476
  }
1475
- return Provider.instance;
1477
+ return PickerProvider.instance;
1476
1478
  }
1477
1479
  add(picker) {
1478
1480
  this.pickers.push(picker);
@@ -1487,7 +1489,8 @@
1487
1489
  }
1488
1490
  closeOther(e) {
1489
1491
  for (const p of this.pickers){
1490
- if (p && !(e.target === p.$container || p.$container.contains(e.target) || e.target === p.$wrapperContent || p.$wrapperContent.contains(e.target))) {
1492
+ var _p_$container_contains, _p_$container, _p_$wrapperContent_contains, _p_$wrapperContent;
1493
+ if (p && !(e.target === p.$container || ((_p_$container = p.$container) == null ? void 0 : (_p_$container_contains = _p_$container.contains) == null ? void 0 : _p_$container_contains.call(_p_$container, e.target)) || e.target === p.$wrapperContent || ((_p_$wrapperContent = p.$wrapperContent) == null ? void 0 : (_p_$wrapperContent_contains = _p_$wrapperContent.contains) == null ? void 0 : _p_$wrapperContent_contains.call(_p_$wrapperContent, e.target)))) {
1491
1494
  p.open = false;
1492
1495
  }
1493
1496
  }
@@ -1496,14 +1499,14 @@
1496
1499
  this.pickers = [];
1497
1500
  // Private constructor to prevent instantiation
1498
1501
  }
1499
- };
1500
- const provider = Provider$1.getInstance();
1502
+ }
1503
+ const pickerProvider = PickerProvider.getInstance();
1501
1504
 
1502
1505
  /**
1503
- * picker 弹窗位置
1506
+ * picker 位置
1504
1507
  * @public
1505
1508
  */ // eslint-disable-next-line @typescript-eslint/naming-convention
1506
- const Picker_Placement = [
1509
+ const PICKER_PLACEMENT = [
1507
1510
  "top",
1508
1511
  "tl",
1509
1512
  "tr",
@@ -1514,7 +1517,9 @@
1514
1517
  /**
1515
1518
  * 默认样式前缀
1516
1519
  */ const PICKER_PREFIX_CLS = "epicker";
1517
- const DEFAULT_PICKER_OPTIONS = {
1520
+ /**
1521
+ * Picker 默认值
1522
+ */ const DEFAULT_PICKER_OPTIONS = {
1518
1523
  getPopupContainer: ()=>document.body,
1519
1524
  wrapClassName: "",
1520
1525
  open: false,
@@ -1538,17 +1543,18 @@
1538
1543
  *
1539
1544
  * @example
1540
1545
  * ```ts
1546
+ * import "@skax/picker/dist/style/css";
1541
1547
  * import Picker from '@skax/picker';
1542
- * const picker = new Picker({
1543
- * container: document.getElementById('picker-container'),
1548
+ * const picker = new Picker(document.getElementById('picker-container'),
1549
+ * {
1544
1550
  * placement: 'bottom',
1545
- * content: '<div>选择内容</div>',
1551
+ * content: '<div>选择内容</div>', // or () => '<div>选择内容</div>'
1546
1552
  * trigger: 'click',
1547
1553
  * isMobile: false,
1548
1554
  * });
1549
1555
  * picker.open = true; // 打开弹窗
1550
1556
  * picker.setPlacement('top'); // 设置弹窗位置
1551
- * picker.innerHTML('<div>新内容</div>'); // 设置弹窗内容
1557
+ * picker.innerHTML('<div>新内容</div>'); // 设置弹窗内容(会覆盖之前的内容)
1552
1558
  * picker.destroy(); // 销毁弹窗
1553
1559
  * ```
1554
1560
  */ class Picker {
@@ -1652,9 +1658,11 @@
1652
1658
  }
1653
1659
  set disabled(disabled) {
1654
1660
  if (disabled) {
1655
- this.$container.classList.add(`${PICKER_PREFIX_CLS}-disabled`);
1661
+ var _this_$container_classList_add, _this_$container_classList, _this_$container;
1662
+ (_this_$container = this.$container) == null ? void 0 : (_this_$container_classList = _this_$container.classList) == null ? void 0 : (_this_$container_classList_add = _this_$container_classList.add) == null ? void 0 : _this_$container_classList_add.call(_this_$container_classList, `${PICKER_PREFIX_CLS}-disabled`);
1656
1663
  } else {
1657
- this.$container.classList.remove(`${PICKER_PREFIX_CLS}-disabled`);
1664
+ var _this_$container_classList_remove, _this_$container_classList1, _this_$container1;
1665
+ (_this_$container1 = this.$container) == null ? void 0 : (_this_$container_classList1 = _this_$container1.classList) == null ? void 0 : (_this_$container_classList_remove = _this_$container_classList1.remove) == null ? void 0 : _this_$container_classList_remove.call(_this_$container_classList1, `${PICKER_PREFIX_CLS}-disabled`);
1658
1666
  }
1659
1667
  this._disabled = disabled;
1660
1668
  }
@@ -1674,7 +1682,7 @@
1674
1682
  if (this._disabled) {
1675
1683
  return;
1676
1684
  }
1677
- if (Picker_Placement.includes(placement)) {
1685
+ if (PICKER_PLACEMENT.includes(placement)) {
1678
1686
  this._options.placement = placement;
1679
1687
  } else {
1680
1688
  console.warn(`${placement} is not a valid placement`);
@@ -1690,10 +1698,10 @@
1690
1698
  */ destroy() {
1691
1699
  this._animationTimerClear();
1692
1700
  this._removeHtml();
1693
- provider.remove(this);
1701
+ pickerProvider.remove(this);
1694
1702
  }
1695
1703
  /**
1696
- * 设置内容
1704
+ * 设置内容(会覆盖之前内容)
1697
1705
  * @param html - html 字符串内容
1698
1706
  * @example
1699
1707
  * ```ts
@@ -1725,17 +1733,19 @@
1725
1733
  /**
1726
1734
  * 移除html
1727
1735
  */ _removeHtml() {
1728
- var _this_$popupContainer;
1736
+ var _this_$container_removeEventListener, _this_$container, _this_$popupContainer;
1729
1737
  // eslint-disable-next-line @typescript-eslint/unbound-method
1730
1738
  this.$wrapperContent.removeEventListener("click", this._onContentClick);
1731
- this.$container.removeEventListener("click", this._onContentClick);
1739
+ (_this_$container = this.$container) == null ? void 0 : (_this_$container_removeEventListener = _this_$container.removeEventListener) == null ? void 0 : _this_$container_removeEventListener.call(_this_$container, "click", this._onContentClick);
1732
1740
  if (this._options.trigger === "click") {
1733
- this.$container.removeEventListener("click", this._onShow);
1741
+ var _this_$container_removeEventListener1, _this_$container1;
1742
+ (_this_$container1 = this.$container) == null ? void 0 : (_this_$container_removeEventListener1 = _this_$container1.removeEventListener) == null ? void 0 : _this_$container_removeEventListener1.call(_this_$container1, "click", this._onShow);
1734
1743
  }
1735
1744
  if (this._options.trigger === "hover") {
1736
- this.$container.removeEventListener("mouseenter", this._onShow);
1737
- this.$container.removeEventListener("mouseover", this._onShow);
1738
- this.$container.removeEventListener("mouseleave", this._onHide);
1745
+ var _this_$container_removeEventListener2, _this_$container2, _this_$container_removeEventListener3, _this_$container3, _this_$container_removeEventListener4, _this_$container4;
1746
+ (_this_$container2 = this.$container) == null ? void 0 : (_this_$container_removeEventListener2 = _this_$container2.removeEventListener) == null ? void 0 : _this_$container_removeEventListener2.call(_this_$container2, "mouseenter", this._onShow);
1747
+ (_this_$container3 = this.$container) == null ? void 0 : (_this_$container_removeEventListener3 = _this_$container3.removeEventListener) == null ? void 0 : _this_$container_removeEventListener3.call(_this_$container3, "mouseover", this._onShow);
1748
+ (_this_$container4 = this.$container) == null ? void 0 : (_this_$container_removeEventListener4 = _this_$container4.removeEventListener) == null ? void 0 : _this_$container_removeEventListener4.call(_this_$container4, "mouseleave", this._onHide);
1739
1749
  // prettier-ignore
1740
1750
  this.$wrapperContent.removeEventListener("mouseenter", this._onWrapperShow);
1741
1751
  this.$wrapperContent.removeEventListener("mouseleave", this._onHide);
@@ -1755,16 +1765,18 @@
1755
1765
  this._$mask.removeEventListener("click", this._onHide);
1756
1766
  (_this_$wrapperContent = this.$wrapperContent) == null ? void 0 : _this_$wrapperContent.removeChild(this._$mask);
1757
1767
  }
1768
+ if (this._options.isMobile) document.body.classList.remove(`${PICKER_PREFIX_CLS}-body-noscroll`);
1758
1769
  (_this_$popupContainer = this.$popupContainer) == null ? void 0 : _this_$popupContainer.removeChild(this.$wrapperContent);
1759
1770
  this.$wrapperContent.innerHTML = "";
1760
1771
  }
1761
1772
  /**
1762
1773
  * 现实位置
1763
1774
  */ _setPlacement() {
1764
- if (!this._open || this._options.isMobile) {
1775
+ var _this_$container_getBoundingClientRect, _this_$container;
1776
+ if (!this._open || this._options.isMobile || !this.$container) {
1765
1777
  return;
1766
1778
  }
1767
- const $containerRect = this.$container.getBoundingClientRect();
1779
+ const $containerRect = (_this_$container = this.$container) == null ? void 0 : (_this_$container_getBoundingClientRect = _this_$container.getBoundingClientRect) == null ? void 0 : _this_$container_getBoundingClientRect.call(_this_$container);
1768
1780
  const $wrapperContentRect = this.$wrapperContent.getBoundingClientRect();
1769
1781
  const $popupContainerRect = this.$popupContainer.getBoundingClientRect();
1770
1782
  // 容器的坐标 - 挂载的容器的坐标差
@@ -1837,8 +1849,10 @@
1837
1849
  this.$body = document.createElement("div");
1838
1850
  this.$body.classList.add(`${PICKER_PREFIX_CLS}-body`);
1839
1851
  this.$wrapperContent.appendChild(this.$body);
1840
- if (this._options.content) {
1852
+ if (typeof this._options.content === "string") {
1841
1853
  this.innerHTML(this._options.content);
1854
+ } else if (typeof this._options.content === "function") {
1855
+ this.innerHTML(this._options.content == null ? void 0 : this._options.content.call(this._options));
1842
1856
  }
1843
1857
  if (typeof this._options.wrapClassName === "string") {
1844
1858
  try {
@@ -1850,17 +1864,20 @@
1850
1864
  /**
1851
1865
  * 绑定事件
1852
1866
  */ _eventListener() {
1867
+ var _this_$container_addEventListener, _this_$container;
1853
1868
  // eslint-disable-next-line @typescript-eslint/unbound-method
1854
1869
  this.$wrapperContent.addEventListener("click", this._onContentClick);
1855
- this.$container.addEventListener("click", this._onContentClick);
1870
+ (_this_$container = this.$container) == null ? void 0 : (_this_$container_addEventListener = _this_$container.addEventListener) == null ? void 0 : _this_$container_addEventListener.call(_this_$container, "click", this._onContentClick);
1856
1871
  //
1857
1872
  if (this._options.trigger === "click") {
1858
- this.$container.addEventListener("click", this._onShow);
1873
+ var _this_$container_addEventListener1, _this_$container1;
1874
+ (_this_$container1 = this.$container) == null ? void 0 : (_this_$container_addEventListener1 = _this_$container1.addEventListener) == null ? void 0 : _this_$container_addEventListener1.call(_this_$container1, "click", this._onShow);
1859
1875
  }
1860
1876
  if (this._options.trigger === "hover") {
1861
- this.$container.addEventListener("mouseenter", this._onShow);
1862
- this.$container.addEventListener("mouseover", this._onShow);
1863
- this.$container.addEventListener("mouseleave", this._onHide);
1877
+ var _this_$container_addEventListener2, _this_$container2, _this_$container_addEventListener3, _this_$container3, _this_$container_addEventListener4, _this_$container4;
1878
+ (_this_$container2 = this.$container) == null ? void 0 : (_this_$container_addEventListener2 = _this_$container2.addEventListener) == null ? void 0 : _this_$container_addEventListener2.call(_this_$container2, "mouseenter", this._onShow);
1879
+ (_this_$container3 = this.$container) == null ? void 0 : (_this_$container_addEventListener3 = _this_$container3.addEventListener) == null ? void 0 : _this_$container_addEventListener3.call(_this_$container3, "mouseover", this._onShow);
1880
+ (_this_$container4 = this.$container) == null ? void 0 : (_this_$container_addEventListener4 = _this_$container4.addEventListener) == null ? void 0 : _this_$container_addEventListener4.call(_this_$container4, "mouseleave", this._onHide);
1864
1881
  this.$wrapperContent.addEventListener("mouseenter", this._onWrapperShow);
1865
1882
  this.$wrapperContent.addEventListener("mouseleave", this._onHide);
1866
1883
  }
@@ -1883,7 +1900,7 @@
1883
1900
  * @param e - 内容点击事件
1884
1901
  */ _onContentClick(e) {
1885
1902
  e.stopPropagation();
1886
- provider.closeOther(e);
1903
+ pickerProvider.closeOther(e);
1887
1904
  }
1888
1905
  /**
1889
1906
  * 显示事件
@@ -1912,12 +1929,13 @@
1912
1929
  * document 点击事件
1913
1930
  * @param event - 鼠标点击事件
1914
1931
  */ _onDocumentClick(event) {
1915
- if (!(this.$wrapperContent.contains(event.target) || this.$wrapperContent === event.target || this.$container.contains(event.target) || this.$container === event.target)) {
1932
+ var _this_$container;
1933
+ if (!(this.$wrapperContent.contains(event.target) || this.$wrapperContent === event.target || ((_this_$container = this.$container) == null ? void 0 : _this_$container.contains(event.target)) || this.$container === event.target)) {
1916
1934
  if (this._disabled) return;
1917
1935
  this._onHide();
1918
1936
  }
1919
1937
  }
1920
- constructor(options){
1938
+ constructor(container, options){
1921
1939
  var _this_$popupContainer;
1922
1940
  /** 是否打开 */ this._open = false;
1923
1941
  this._OpenChange = false;
@@ -1930,15 +1948,9 @@
1930
1948
  if (this._options.isMobile) {
1931
1949
  this._options.trigger = "click";
1932
1950
  }
1933
- provider.add(this);
1934
- if (typeof this._options.container === "function") {
1935
- this.$container = this._options.container();
1936
- } else {
1937
- this.$container = this._options.container;
1938
- }
1939
- if (!this.$container) {
1940
- throw new Error("container is required!");
1941
- }
1951
+ pickerProvider.add(this);
1952
+ if (typeof container === "function") this.$container = container();
1953
+ else this.$container = container;
1942
1954
  this.$wrapperContent = document.createElement("div");
1943
1955
  this._initContentStyle();
1944
1956
  (_this_$popupContainer = this.$popupContainer) == null ? void 0 : _this_$popupContainer.appendChild(this.$wrapperContent);
@@ -1957,7 +1969,7 @@
1957
1969
  * ```ts
1958
1970
  * Picker.VERSION; // 输出版本号
1959
1971
  * ```
1960
- */ Picker.VERSION = "0.1.1";
1972
+ */ Picker.VERSION = "1.0.2";
1961
1973
 
1962
1974
  /*
1963
1975
  * delegate.js v3.2.0
@@ -2838,8 +2850,7 @@
2838
2850
  // 轻应用私有暂时不支持调节音量
2839
2851
  if (!(Utils.isMobile || _this._options.PLAY_TYPE === 'ezopen')) {
2840
2852
  var _this__options_props4, _this__options_props5;
2841
- _this.picker = new Picker({
2842
- container: _this.$container,
2853
+ _this.picker = new Picker(_this.$container, {
2843
2854
  getPopupContainer: function() {
2844
2855
  return _this.$container;
2845
2856
  },
@@ -3939,7 +3950,7 @@
3939
3950
  */
3940
3951
  const LoggerStyle={info:"",log:"background: #4096ff; color: #FFF;",warn:"background: yellow; color: #FFF;",error:"background: red; color: #FFF;"};class LoggerCls{setOptions(options){var _this__options_level;this._options=Object.assign({},this._options,options),this._levelNum=this._matchLevel(null!=(_this__options_level=this._options.level)?_this__options_level:"INFO"),this.info=this._loggerFactory("info",this._levelNum>=3),this.log=this._loggerFactory("log",this._levelNum>=2),this.warn=this._loggerFactory("warn",this._levelNum>=1),this.error=this._loggerFactory("error",this._levelNum>=0);}_matchLevel(level){let logLevel=3;switch(level){case "INFO":logLevel=3;break;case "LOG":logLevel=2;break;case "WARN":logLevel=1;break;case "ERROR":logLevel=0;}return logLevel}_loggerFactory(type,bool){const fn=console[type];if(bool&&fn){const args0=this._options.name?`%c[${this._options.name}]%c %c[${type.toUpperCase()}]`:`%c[${type.toUpperCase()}]`,color=[this._options.name?"background: green;color: #fff":null,this._options.name?"":null,LoggerStyle[type]].filter((color=>null!=color));return fn.bind(console,args0,...color)}return LoggerCls.noop}getOptions(){return this._options}getVersion(){return "1.1.0"}constructor(){let options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._options={level:"INFO",showTime:false},this._levelNum=3,this.info=this._loggerFactory("info",this._levelNum>=3),this.log=this._loggerFactory("log",this._levelNum>=2),this.warn=this._loggerFactory("warn",this._levelNum>=1),this.error=this._loggerFactory("error",this._levelNum>=0),this.setOptions(options);}}function fillTen(num){return (num=+num)<10&&(num=`0${num}`),num+""}LoggerCls.noop=()=>{},LoggerCls.VERSION="1.1.0";const list=["info","log","warn","error"];function Logger(options){const logger=new LoggerCls(options);return new Proxy(logger,{get(target,prop){if(list.includes(prop)){var _target__options;if(null==(_target__options=target._options)?void 0:_target__options.showTime){const time=function(){const now=new Date(Date.now()),year=now.getFullYear(),month=now.getMonth()+1,day=now.getDate(),hour=now.getHours(),min=now.getMinutes(),sec=now.getSeconds(),ms=now.getMilliseconds();return `${year}/${fillTen(month)}/${fillTen(day)} ${fillTen(hour)}:${fillTen(min)}:${fillTen(sec)}:${ms}`}();return target[prop].bind(console,`[${time}]`)}return target[prop].bind(console)}return Reflect.get(target,prop)}})}
3941
3952
 
3942
- var zh = {
3953
+ var zh$1 = {
3943
3954
  391001: '取流地址或端口非法',
3944
3955
  395000: '服务内部异常,请稍后重试',
3945
3956
  395400: '预览取流参数异常',
@@ -4209,7 +4220,7 @@
4209
4220
  };
4210
4221
 
4211
4222
  // 不要出现多层的的数据, 数据铺平
4212
- var en = {
4223
+ var en$1 = {
4213
4224
  391001: 'Illegal streaming address or port',
4214
4225
  395000: 'Internal service exception, please try again later',
4215
4226
  395400: 'Preview streaming parameter exception',
@@ -5128,8 +5139,7 @@
5128
5139
  }) : IconComponents.moreDot({
5129
5140
  title: (_this_locale1 = this.locale) == null ? void 0 : _this_locale1.BTN_MORE
5130
5141
  });
5131
- this.picker = new Picker({
5132
- container: this.$container,
5142
+ this.picker = new Picker(this.$container, {
5133
5143
  getPopupContainer: function() {
5134
5144
  return _this.$container;
5135
5145
  },
@@ -9132,8 +9142,7 @@
9132
9142
  }
9133
9143
  var _this__options_fieldNames_value;
9134
9144
  var valueKey = (_this__options_fieldNames_value = (_this__options_fieldNames = _this._options.fieldNames) == null ? void 0 : _this__options_fieldNames.value) != null ? _this__options_fieldNames_value : 'value';
9135
- _this._picker = new Picker({
9136
- container: _this.$container,
9145
+ _this._picker = new Picker(_this.$container, {
9137
9146
  // 由于某些原因, 移动端强制渲染在 body 上
9138
9147
  getPopupContainer: function() {
9139
9148
  return Utils.isMobile ? options.rootContainer : _this.$container;
@@ -9416,16 +9425,14 @@
9416
9425
  controlType: 'button',
9417
9426
  classNameSuffix: 'definition',
9418
9427
  renderLabel: function(label, item, list) {
9419
- var _list_;
9420
9428
  if ((item == null ? void 0 : item.level) === 'auto') {
9421
9429
  var _options_locales_options_language;
9422
- var realItem = list.find(function(it) {
9430
+ var realIitem = list.find(function(it) {
9423
9431
  return it.level === _assert_this_initialized$1(_this)._level;
9424
9432
  });
9425
- return "<span>" + (options == null ? void 0 : (_options_locales_options_language = options.locales[options.language]) == null ? void 0 : _options_locales_options_language.VIDEO_LEVEL_AUTO) + "(" + ((realItem == null ? void 0 : realItem.name) || '') + ")</span>";
9433
+ return "<span>" + (options == null ? void 0 : (_options_locales_options_language = options.locales[options.language]) == null ? void 0 : _options_locales_options_language.VIDEO_LEVEL_AUTO) + "(" + ((realIitem == null ? void 0 : realIitem.name) || '') + ")</span>";
9426
9434
  }
9427
- // 如果 label 不存在,则不显示label,直接显示list的第一个label, 一般自定义清晰度列表可能会出现
9428
- return "<span>" + (label || ((_list_ = list[0]) == null ? void 0 : _list_.name) || '') + "</span>";
9435
+ return "<span>" + label + "</span>";
9429
9436
  },
9430
9437
  onChange: function(value, item) {
9431
9438
  var _options_onChange;
@@ -9452,10 +9459,10 @@
9452
9459
  _this._level = realLevel + '';
9453
9460
  if (l === 'auto') {
9454
9461
  var _options_locales_options_language;
9455
- var realItem = _this.list.find(function(it) {
9462
+ var realIitem = _this.list.find(function(it) {
9456
9463
  return it.level === _this._level;
9457
9464
  });
9458
- _this.$container.querySelector("." + PREFIX_CLASS + "-select-btn").innerHTML = "\n <span>" + (options == null ? void 0 : (_options_locales_options_language = options.locales[options.language]) == null ? void 0 : _options_locales_options_language.VIDEO_LEVEL_AUTO) + "(" + ((realItem == null ? void 0 : realItem.name) || '') + ")</span>\n ";
9465
+ _this.$container.querySelector("." + PREFIX_CLASS + "-select-btn").innerHTML = "\n <span>" + (options == null ? void 0 : (_options_locales_options_language = options.locales[options.language]) == null ? void 0 : _options_locales_options_language.VIDEO_LEVEL_AUTO) + "(" + ((realIitem == null ? void 0 : realIitem.name) || '') + ")</span>\n ";
9459
9466
  } else {
9460
9467
  if (_this.value !== _this._level + '') _this.value = _this._level + '';
9461
9468
  }
@@ -10079,606 +10086,268 @@
10079
10086
  }(Control);
10080
10087
 
10081
10088
  /*
10082
- * @ezuikit/control-time-line v0.0.1
10083
- * Copyright (c) 2025-09-21 Ezviz-OpenBiz
10089
+ * @ezuikit/control-time-line v1.0.0-beta.2
10090
+ * Copyright (c) 2025-10-27 Ezviz-OpenBiz
10084
10091
  * Released under the MIT License.
10085
10092
  */
10086
-
10087
- const BASE_TIME_LINE_DEFAULT_OPTIONS = {
10088
- language: 'zh',
10089
- records: [],
10090
- onChange: ()=>{},
10091
- onDragStart: ()=>{},
10092
- onDragging: ()=>{},
10093
- onDragEnd: ()=>{}
10094
- };
10095
- class BaseTimeLine {
10096
- get current() {
10097
- return this._current;
10098
- }
10099
- /**
10093
+ var zh={title:"包含{{len}}段录像",foldTitle:"{{len}}个录像"};var en={title:"Includes {{len}} {{unit}}",foldTitle:"{{len}} {{unit}}"};const BASE_TIME_LINE_DEFAULT_OPTIONS={current:new Date,language:"zh",timeSections:[],readOnly:false,className:"",timeWidth:0,width:"100%",
10094
+ // --------------------只支持初始化时,不支持动态变更 (不做对象冻结)--------------------
10095
+ timePointColor:"#1890ff",timeTextColor:"#FFF",timeScaleColor:"#FFF",timeSectionColor:"rgba(24, 144, 255, 0.5)",timeAxisBgColor:"#000",
10096
+ onChange:()=>{},onDragStart:()=>{},onDragging:()=>{},onDragEnd:()=>{},onDestroy:()=>{}};
10097
+ /**
10098
+ * 时间轴基类
10099
+ * @internal
10100
+ */class BaseTimeLine{
10101
+ /**
10102
+ * 当前时间
10103
+ */
10104
+ get current(){return this._current}
10105
+ /**
10106
+ * 当前时间
10107
+ */set current(current){this._current=current;}set readOnly(readOnly){if(this._readOnly!==readOnly){this._readOnly=readOnly;this.$container.style.cursor=readOnly?"not-allowed":"pointer";}}
10108
+ /**
10109
+ * 只读状态
10110
+ */get readOnly(){return this._readOnly}
10111
+ /**
10112
+ *
10113
+ */get timeSections(){return this._timeSections}
10114
+ /**
10115
+ * 设置只读或取消只读, 推荐使用 timeLine.readOnly = false
10116
+ * @param readOnly - 只读或取消只读
10117
+ * @returns
10118
+ */setReadOnly(readOnly){this.readOnly=readOnly;}
10119
+ /**
10100
10120
  * 更新当前时间
10101
10121
  * @param time 能转成时间的值, 如 时间对象 Date, 时间戳,时间戳字符串
10102
- */ update(current) {}
10103
- updateRecords(records) {
10104
- if (records) {
10105
- this.records = records;
10106
- }
10107
- }
10108
- resize(width, height) {}
10109
- /**
10122
+ */update(current){this._current=current;}
10123
+ /**
10124
+ * 更新时间片段
10125
+ * @param timeSections 片段数据
10126
+ */updateTimeSections(timeSections){if(timeSections&&Array.isArray(timeSections))this._timeSections=timeSections;}
10127
+ /**
10128
+ * 获取 TimeLine 的宽度
10129
+ * @returns
10130
+ */get width(){return this._width}
10131
+ /**
10132
+ * 获取 TimeLine 的高度
10133
+ */get height(){return this._height}
10134
+ /**
10135
+ * 重置尺寸
10136
+ */resize(width,height){this._resize(width,height);}_resize(width,height){let cssText="";if(/\d/.test(width+""))cssText+=`width: ${width}px;`;else if(width)cssText+=`width: ${width};`;if(/\d/.test(height+""))cssText+=`height: ${height}px;`;else if(height)cssText+=`height: ${height};`;if(this.$container)this.$container.style.cssText+=cssText;this._width=Math.floor(this.$container.clientWidth);this._height=Math.floor(this.$container.clientHeight);}get timeWidth(){return this._timeWidth}
10137
+ /**
10110
10138
  * 改变时间轴刻度
10111
- */ changeScale(timelag) {}
10112
- setReadOnly(readOnly) {}
10113
- destroy() {
10114
- this._current = undefined;
10115
- }
10116
- constructor(container, options){
10117
- this.records = [];
10118
- this.$container = container;
10119
- this.options = deepmerge(BASE_TIME_LINE_DEFAULT_OPTIONS, options, {
10120
- clone: false
10121
- });
10122
- }
10123
- }
10124
-
10125
- function toDate(time) {
10126
- let date = null;
10127
- if (typeof time === 'string' && time.includes(':')) {
10128
- date = new Date(time);
10129
- } else if ((typeof time === 'string' || typeof time === 'number') && /\d/.test(time + '') && (time + '').length === 10) {
10130
- date = new Date(+time * 1000);
10131
- } else if ((typeof time === 'string' || typeof time === 'number') && /\d/.test(time + '') && (time + '').length === 13) {
10132
- date = new Date(+time);
10133
- } else if (time instanceof Date) {
10134
- date = time;
10135
- }
10136
- return date;
10137
- }
10139
+ * 移动端间距: 0:1分钟,1:10分钟,2:半小时,3:1小时,4:2小时, 5:4小时
10140
+ * PC间距:
10141
+ * @param timeWidth 时间轴刻度
10142
+ */setTimeWidth(timeWidth){if([0,1,2,3,4,5].includes(timeWidth))this._timeWidth=timeWidth;}
10138
10143
  /**
10139
- *
10140
- * @param time
10141
- * @returns
10142
- */ function formatDateToHHmmss(time) {
10143
- const date = toDate(time);
10144
- if (date) {
10145
- const h = date.getHours(); // 返回日期中的小时数(0到23)
10146
- const m = date.getMinutes(); // 返回日期中的分钟数(0到59)
10147
- const s = date.getSeconds(); // 返回日期中的秒数(0到59)
10148
- return (h > 9 ? h : '0' + h) + ':' + (m > 9 ? m : '0' + m) + ':' + (s > 9 ? s : '0' + s);
10149
- }
10150
- return '00:00:00';
10151
- }
10152
- function subTime(time) {
10153
- if (+time < 10) {
10154
- return '0' + time;
10155
- } else {
10156
- return time;
10157
- }
10158
- }
10159
- function tranTime(time, fmt = 'YYYY-MM-DD HH:mm:ss') {
10160
- const newDate = toDate(time);
10161
- if (newDate) {
10162
- if (fmt === 'YYYY-MM-DD') {
10163
- return newDate.getFullYear() + '-' + subTime(newDate.getMonth() + 1) + '-' + subTime(newDate.getDate());
10164
- } else if (fmt === 'HH:mm:ss') {
10165
- return subTime(newDate.getHours()) + ':' + subTime(newDate.getMinutes()) + ':' + subTime(newDate.getSeconds());
10166
- }
10167
- // prettier-ignore
10168
- return newDate.getFullYear() + "-" + subTime(newDate.getMonth() + 1) + "-" + subTime(newDate.getDate()) + " " + subTime(newDate.getHours()) + ":" + subTime(newDate.getMinutes()) + ":" + subTime(newDate.getSeconds());
10169
- }
10170
- return '';
10171
- }
10144
+ * 销毁
10145
+ */destroy(){
10146
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
10147
+ this._current=null;this.options.onDestroy==null?void 0:this.options.onDestroy.call(this.options);this._timeSections=[];this._readOnly=false;this._destroyed=true;}constructor(container,options){this._current=new Date;
10148
+ /** 只读 */this._readOnly=false;this._width=0;this._height=0;this._destroyed=false;this._timeWidth=0;
10149
+ /** 片段列表 */this._timeSections=[];this.$container=container;this.options=deepmerge(BASE_TIME_LINE_DEFAULT_OPTIONS,options,{clone:false});if(this.options.timeSections&&Array.isArray(this.options.timeSections))this._timeSections=this.options.timeSections;if(this.options.readOnly)this.readOnly=this.options.readOnly;if(this.options.className)this.$container.classList.add(this.options.className);if(this.options.current&&this.options.current instanceof Date)this._current=this.options.current||new Date;
10150
+ // prettier-ignore
10151
+ this.i18n=new I18n(deepmerge({zh:zh,en:en},this.options.locales||{},{clone:false}),{defaultLocale:this.options.language||"zh"});this._timeWidth=this.options.timeWidth||0;this._resize(this.options.width||"100%",this.options.height);}}
10152
+ /**
10153
+ * 时间轴工具类
10154
+ */class TimeLineUtil{
10155
+ /**
10156
+ * 时间转成日期
10157
+ * @param time 时间 (秒, 毫秒, 日期字符串, Date)
10158
+ * @returns 日期
10159
+ */
10160
+ static toDate(time){let date=null;if(typeof time==="string"&&time.includes(":"))date=new Date(time);else if((typeof time==="string"||typeof time==="number")&&/\d/.test(time+"")&&(time+"").length===10)date=new Date(+time*1e3);else if((typeof time==="string"||typeof time==="number")&&/\d/.test(time+"")&&(time+"").length===13)date=new Date(+time);else if(time instanceof Date)date=time;return date}
10161
+ /**
10162
+ * 时间转成 HH:mm:ss
10163
+ * @param time 时间
10164
+ * @returns
10165
+ */static formatDateToHHmmss(time){const date=TimeLineUtil.toDate(time);if(date){const h=date.getHours();// 返回日期中的小时数(0到23)
10166
+ const m=date.getMinutes();// 返回日期中的分钟数(0到59)
10167
+ const s=date.getSeconds();// 返回日期中的秒数(0到59)
10168
+ return (h>9?h:"0"+h)+":"+(m>9?m:"0"+m)+":"+(s>9?s:"0"+s)}return "00:00:00"}
10169
+ /**
10170
+ * 十位补充 0
10171
+ * @param m 数字
10172
+ * @returns 十位补充 0后的结果字符串
10173
+ */static subTime(m){return +m>9?m+"":"0"+m}
10174
+ /**
10175
+ * 格式化时间, 支持 'YYYY-MM-DD','YYYY-MM-DD HH:mm:ss', 'HH:mm:ss'
10176
+ * @param time 时间
10177
+ * @param fmt 时间格式
10178
+ * @returns
10179
+ */static tranTime(time,fmt="YYYY-MM-DD HH:mm:ss"){const newDate=TimeLineUtil.toDate(time);if(newDate){if(fmt==="YYYY-MM-DD")return newDate.getFullYear()+"-"+TimeLineUtil.subTime(newDate.getMonth()+1)+"-"+TimeLineUtil.subTime(newDate.getDate());else if(fmt==="HH:mm:ss")return TimeLineUtil.subTime(newDate.getHours())+":"+TimeLineUtil.subTime(newDate.getMinutes())+":"+TimeLineUtil.subTime(newDate.getSeconds());else if(fmt==="HH")return TimeLineUtil.subTime(newDate.getHours());else if(fmt==="mm:ss")return TimeLineUtil.subTime(newDate.getMinutes())+":"+TimeLineUtil.subTime(newDate.getSeconds());else if(fmt==="HH:mm")return TimeLineUtil.subTime(newDate.getHours())+":"+TimeLineUtil.subTime(newDate.getMinutes());else if(fmt==="YYYYMMDDTHHmmssZ")return newDate.getFullYear()+""+TimeLineUtil.subTime(newDate.getMonth()+1)+TimeLineUtil.subTime(newDate.getDate())+"T"+TimeLineUtil.subTime(newDate.getHours())+TimeLineUtil.subTime(newDate.getMinutes())+TimeLineUtil.subTime(newDate.getSeconds())+"Z";
10180
+ // prettier-ignore
10181
+ return newDate.getFullYear()+"-"+TimeLineUtil.subTime(newDate.getMonth()+1)+"-"+TimeLineUtil.subTime(newDate.getDate())+" "+TimeLineUtil.subTime(newDate.getHours())+":"+TimeLineUtil.subTime(newDate.getMinutes())+":"+TimeLineUtil.subTime(newDate.getSeconds())}return ""}
10182
+ /**
10183
+ * 时间转成秒
10184
+ * @param time
10185
+ * @returns
10186
+ */static timeToSecond(time){const e=time.split(":");const h=Number(e[0]);const m=Number(e[1]);const s=Number(e[2]);return h*60*60+m*60+(s||0)}
10187
+ /**
10188
+ * 分钟转成 HH:mm
10189
+ * @param minute
10190
+ * @returns
10191
+ */static minuteToTime(minute){const hour=Math.floor(minute/60);const m=minute%60;return (hour>9?hour:"0"+hour)+":"+(m>9?m:"0"+m)}
10192
+ /**
10193
+ * 时间转成分钟
10194
+ * @param time
10195
+ * @returns
10196
+ */static timeToMinute(time){const e=time.split(":");const h=Number(e[0]);const m=Number(e[1]);
10197
+ // const s = Number(e[2]);
10198
+ return h*60+m}
10199
+ /**
10200
+ * @description 判读两个区间是否重叠
10201
+ * @param {number} a_start 一个区间的开始
10202
+ * @param {number} a_end 一个区间的结束
10203
+ * @param {number} b_start 另一个区间的开始
10204
+ * @param {number} b_end 另一个区间的结束
10205
+ * @returns {boolean}
10206
+ */static isOverlap(a_start,a_end,b_start,b_end){return Math.max(a_start,b_start)<=Math.min(a_end,b_end)}static tranTimeToString(start,end){var _TimeLineUtil_toDate,_TimeLineUtil_toDate1;const secondNum=Math.floor(((_TimeLineUtil_toDate=TimeLineUtil.toDate(end))==null?void 0:_TimeLineUtil_toDate.getTime())-((_TimeLineUtil_toDate1=TimeLineUtil.toDate(start))==null?void 0:_TimeLineUtil_toDate1.getTime()))/1e3;const second=secondNum%60;const minute=Math.floor(secondNum/60);return `${minute>0?TimeLineUtil.subTime(minute)+"'":""}${TimeLineUtil.subTime(second)}''`}}const Icons={tip:`<svg viewBox="0 0 57 24" fill="currentColor" width="1em" height="1em" focusable="false" aria-hidden="true" data-icon="tip">\n <path class="ez-time-line-icon-tip" fill-rule="evenodd" d="m4,0l44,0c2.2091,0 4,1.7909 4,4l0,3.8218l4.9399,3.3572c0.5839,0.3968 0.5839,1.2574 0,1.6542l-4.9399,3.3572l0,3.8096c0,2.2091 -1.7909,4 -4,4l-44,0c-2.2091,0 -4,-1.7909 -4,-4l0,-16c0,-2.2091 1.7909,-4 4,-4z"/>\n </svg>`,plus:`\n <svg viewBox="0 0 16 16" fill="currentColor" width="1em" height="1em" focusable="false" aria-hidden="true" data-icon="plus">\n <path d="M0 0L10.6667 0" stroke="rgb(44,44,44)" stroke-linecap="round" stroke-width="1.5" transform="matrix(0,1,-1,0,8,2.66663)"/>\n <path d="M2.66669 8L13.3334 8" stroke="rgb(44,44,44)" stroke-linecap="round" stroke-width="1.5"/>\n </svg>\n `,minus:`\n <svg viewBox="0 0 16 16" fill="currentColor" width="1em" height="1em" focusable="false" aria-hidden="true" data-icon="minus">\n <path d="M2.66669 8L13.3334 8" stroke="rgb(44,44,44)" stroke-linecap="round" stroke-width="1.5"/>\n </svg>\n `,close:`\n <svg viewBox="0 0 24 24" fill="none" width="1em" height="1em" stroke="currentColor" focusable="false" aria-hidden="true" data-icon="close">\n\t <path d="M0 0L15.9998 0" stroke-linecap="round" stroke-width="1.5" transform="matrix(0.707099,0.707114,-0.707114,0.707099,6.34277,6.34326)" />\n\t\t <path d="M0 0L15.9998 0" stroke-linecap="round" stroke-width="1.5" transform="matrix(0.707099,-0.707114,0.707114,0.707099,6.34277,17.6567)" />\n </svg>\n `,pause:`<svg viewBox="0 0 20 20" fill="currentColor" width="1em" height="1em" focusable="false" aria-hidden="true" data-icon="pause">\n\t\t <path d="M9.43914 2.47881L13.4688 8.4912C14.3594 9.81998 13.4071 11.6047 11.8074 11.6047L3.74811 11.6047C2.14849 11.6047 1.19616 9.81998 2.08675 8.4912L6.11641 2.47881C6.90863 1.2968 8.64693 1.2968 9.43914 2.47881Z" fill-rule="evenodd" transform="matrix(0,1,-1,0,16.5781,2.22229)" />\n </svg>\n `};
10207
+ /**
10208
+ * 时间刻度宽度 [刻度间隔秒数s, 刻度间隔宽度px, 长刻度间隔短刻度个数, 说明]
10209
+ * 需要满足 (24 * 60 * 60) % ([0] * [2]) = 0, 这样 0 点刻度才能正确显示
10210
+ */
10211
+ /**
10212
+ * 时间刻度宽度, 需要满足 (24 * 60 * 60) % ([0] * [2]) = 0
10213
+ */const TIME_WIDTH=[[1,10,10,"单位 1秒"],[60,20,5,"单位 1分钟"],[600,20,6,"单位 10分钟"],[3600,30,6,"单位 1小时"],[14400,40,2,"单位 4小时"],[43200,80,2,"单位 12小时"]];
10214
+ /**
10215
+ * 时间刻度宽度, 需要满足 (24 * 60 * 60) % ([0] * [2]) = 0
10216
+ * // * 0: 1分钟,
10217
+ // * 1: 10分钟
10218
+ // * 2: 半小时
10219
+ // * 3: 1小时
10220
+ // * 4: 2小时
10221
+ // * 5: 4小时
10222
+ */const MOBILE_TIME_WIDTH=[[1,10,10,"单位 1分钟"],[10,20,5,"单位 10分钟"],[30,20,6,"单位 30分钟"],[60,30,6,"单位 1小时"],[120,40,2,"单位 2小时"],[240,80,2,"单位 4小时"]];
10223
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */ /* eslint-disable eqeqeq */ /* eslint-disable no-unneeded-ternary */ /* eslint-disable @typescript-eslint/no-this-alias */ /* eslint-disable @typescript-eslint/prefer-includes */function _extends$1$1(){_extends$1$1=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)if(Object.prototype.hasOwnProperty.call(source,key))target[key]=source[key];}return target};return _extends$1$1.apply(this,arguments)}
10224
+ /**
10225
+ * 时间轴样式类前缀
10226
+ */const MOBILE_TIMELINE_PREFIX="ez-time-line";const MOBILE_TIME_LINE_DEFAULT_OPTIONS=Object.assign({},BASE_TIME_LINE_DEFAULT_OPTIONS,{height:400,width:"100%",timeWidth:0,readOnly:false,timePointColor:"#648FFC",timeTextColor:"#666666",timeScaleColor:"transparent",timeSectionColor:"#369FFF",timeAxisBgColor:"#BDCDFF",
10227
+ /** 当前时间背景颜色 */currentTimeBgColor:"#648FFC",
10228
+ /** 当前时间颜色 */currentTimeColor:"#FFFFFF",showTimeWidthBtn:true});class MobileTimeLine extends BaseTimeLine{
10172
10229
  /**
10173
- * @description 判读两个区间是否重叠
10174
- * @param {number} a_start 一个区间的开始
10175
- * @param {number} a_end 一个区间的结束
10176
- * @param {number} b_start 另一个区间的开始
10177
- * @param {number} b_end 另一个区间的结束
10178
- * @returns {boolean}
10179
- */ function isOverlap(a_start, a_end, b_start, b_end) {
10180
- return Math.max(a_start, b_start) <= Math.min(a_end, b_end);
10181
- }
10182
-
10183
- /* eslint-disable @typescript-eslint/no-non-null-assertion */ /* eslint-disable eqeqeq */ /* eslint-disable no-unneeded-ternary */ /* eslint-disable @typescript-eslint/no-this-alias */ /* eslint-disable @typescript-eslint/prefer-includes */ function _extends$5() {
10184
- _extends$5 = Object.assign || function(target) {
10185
- for(var i = 1; i < arguments.length; i++){
10186
- var source = arguments[i];
10187
- for(var key in source){
10188
- if (Object.prototype.hasOwnProperty.call(source, key)) {
10189
- target[key] = source[key];
10190
- }
10191
- }
10192
- }
10193
- return target;
10194
- };
10195
- return _extends$5.apply(this, arguments);
10196
- }
10197
- const PREFIX = 'ez-time-line';
10198
- /**
10199
- * 0: 1分钟,
10200
- * 1: 10分钟
10201
- * 2: 半小时
10202
- * 3: 1小时
10203
- * 4: 2小时
10204
- */ const scaleEnum = {
10205
- 0: 1,
10206
- 1: 10,
10207
- 2: 30,
10208
- 3: 60,
10209
- 4: 120
10210
- };
10211
- const MOBILE_TIME_LINE_DEFAULT_OPTIONS = Object.assign({}, BASE_TIME_LINE_DEFAULT_OPTIONS, {
10212
- // height: 400,
10213
- scale: 0,
10214
- readOnly: false
10215
- });
10216
- let TimeLine$1 = class TimeLine extends BaseTimeLine {
10217
- /**
10218
10230
  * 更新状态
10219
10231
  * @param obj
10220
- */ setState(obj) {
10221
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
10222
- Object.keys(obj).forEach((key)=>{
10223
- this.state[key] = obj[key];
10224
- if (key === 'scrollTop' && this._$itemList) {
10225
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
10226
- this._$itemContainer.scrollTo(0, obj[key]);
10227
- }
10228
- if (key === 'current' && this._$currentTime) {
10229
- this._$currentTime.querySelector(`.${PREFIX}-current-value`).innerHTML = obj[key];
10230
- }
10231
- });
10232
- }
10233
- /**
10232
+ */
10233
+ setState(obj){
10234
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
10235
+ Object.keys(obj).forEach(key=>{this.state[key]=obj[key];if(key==="scrollTop"&&this._$itemList)
10236
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
10237
+ this._$itemContainer.scrollTo(0,obj[key]);if(key==="current"&&this._$currentTime&&obj[key]){var _this_timeSections_;this._$currentTime.querySelector(`.${MOBILE_TIMELINE_PREFIX}-current-value`).innerHTML=obj[key];console.log("current",obj[key]);this.current=new Date(TimeLineUtil.tranTime((_this_timeSections_=this.timeSections[0])==null?void 0:_this_timeSections_.endTime,"YYYY-MM-DD")+" "+obj[key]);}});}
10238
+ /**
10234
10239
  * 设置只读或取消只读
10235
10240
  * @param readOnly - 只读或取消只读
10236
10241
  * @returns
10237
- */ setReadOnly(readOnly) {
10238
- this._readOnly = readOnly;
10239
- if (this._$itemList) this._$itemContainer.style.overflowY = readOnly ? 'hidden' : 'scroll';
10240
- }
10241
- /**
10242
+ */setReadOnly(readOnly){super.setReadOnly(readOnly);if(this._$itemList)this._$itemContainer.style.overflowY=readOnly?"hidden":"scroll";}
10243
+ /**
10242
10244
  * 改变时间轴刻度
10243
10245
  * 0: 1分钟,
10244
10246
  * 1: 10分钟
10245
10247
  * 2: 半小时
10246
10248
  * 3: 1小时
10247
10249
  * 4: 2小时
10248
- * @param value 120: 2小时, 60:1小时, 30:半小时,10:10分钟,1:1分钟
10249
- */ changeScale(scale) {
10250
- if (scaleEnum[scale]) {
10251
- this._scale = scale;
10252
- this._matchTimeDot();
10253
- }
10254
- }
10255
- get scale() {
10256
- return this._scale;
10257
- }
10258
- /**
10250
+ * @param timeWidth // 120: 2小时, 60:1小时, 30:半小时,10:10分钟,1:1分钟
10251
+ */setTimeWidth(timeWidth){if(MOBILE_TIME_WIDTH[timeWidth]){super.setTimeWidth(timeWidth);this._matchTimeDot();}else console.warn(`scale ${timeWidth} not exist!`);}
10252
+ /**
10259
10253
  * 获取真实时间刻度(时间单位 分钟)
10260
- */ get _scaleWidth() {
10261
- return scaleEnum[this._scale] || scaleEnum[0];
10262
- }
10263
- updateRecords(records, defaultIndex) {
10264
- const list = records.map((record)=>{
10265
- return _extends$5({}, record, {
10266
- startTime: formatDateToHHmmss(record.startTime),
10267
- endTime: formatDateToHHmmss(record.endTime)
10268
- });
10269
- });
10270
- if (list.length > 0) {
10271
- if (typeof defaultIndex === 'undefined') {
10272
- defaultIndex = list.length - 1;
10273
- }
10274
- // 若current不为0,则不重置current,避免拖动后时间轴回弹
10275
- const { current } = this.state;
10276
- this.setState({
10277
- availTimeLine: list,
10278
- start: list[defaultIndex].startTime,
10279
- end: list[defaultIndex].endTime,
10280
- current: current === 0 ? list[defaultIndex].startTime : current
10281
- });
10282
- this._matchRecTimeDot();
10283
- this._primaryOffsetH();
10284
- } else {
10285
- this.setState({
10286
- availTimeLine: []
10287
- });
10288
- this._matchRecTimeDot();
10289
- }
10290
- }
10291
- _matchTimeDot() {
10292
- const { end } = this.state;
10293
- const scaleWidth = this._scaleWidth;
10294
- const timeArr = [];
10295
- // 时间转分钟
10296
- let minute = this._timeToMinute(end);
10297
- minute = Math.floor(minute / scaleWidth) * scaleWidth;
10298
- for(let i = minute; i >= 0;){
10299
- let marginTop = 0;
10300
- let marginBottom = 0;
10301
- // 视频片段
10302
- if (i == minute) marginTop = 70;
10303
- if (i == 0) {
10304
- const height = this.$container.clientHeight;
10305
- marginBottom = height - 70;
10306
- }
10307
- const time = this._minuteToTime(i);
10308
- timeArr.push({
10309
- id: i,
10310
- current: time,
10311
- label: 'a' + i,
10312
- marginTop,
10313
- marginBottom,
10314
- recArr: []
10315
- });
10316
- i = i - scaleWidth;
10317
- }
10318
- this.setState({
10319
- timeArr
10320
- });
10321
- this._renderDateLine();
10322
- }
10323
- _matchRecTimeDot() {
10324
- const { start, end, availTimeLine, timeArr } = this.state;
10325
- const scaleWidth = this._scaleWidth;
10326
- const len = availTimeLine.length;
10327
- if (len === 0) {
10328
- for(let j = 0; j < timeArr.length; j++){
10329
- timeArr[j].recArr = [];
10330
- }
10331
- } else {
10332
- for(let k = 0; k < timeArr.length; k++){
10333
- timeArr[k].recArr = [];
10334
- }
10335
- for(let i = 0; i < len; i++){
10336
- const temp = availTimeLine[i];
10337
- const st = this._timeToSecond(temp.startTime);
10338
- const et = this._timeToSecond(temp.endTime);
10339
- // console.log('st: ', st, 'et:', et);
10340
- let stAvailPercent = 0;
10341
- let etAvailPercent = 0;
10342
- const stMinute = Math.floor(st / (scaleWidth * 60)) * scaleWidth;
10343
- stAvailPercent = (st - stMinute * 60) / scaleWidth;
10344
- const etMinute = Math.floor(et / (scaleWidth * 60)) * scaleWidth;
10345
- etAvailPercent = (et - etMinute * 60) / scaleWidth;
10346
- for(let j = 0; j < timeArr.length; j++){
10347
- if (timeArr[j].id == stMinute && timeArr[j].id == etMinute) {
10348
- const height = etAvailPercent - stAvailPercent;
10349
- const top = 60 - etAvailPercent;
10350
- timeArr[j].recArr.push({
10351
- height,
10352
- top
10353
- });
10354
- } else {
10355
- if (timeArr[j].id == stMinute) {
10356
- timeArr[j].recArr.push({
10357
- height: 60 - stAvailPercent,
10358
- top: 0
10359
- });
10360
- } else if (timeArr[j].id == etMinute) {
10361
- timeArr[j].recArr.push({
10362
- height: etAvailPercent,
10363
- top: 60 - etAvailPercent
10364
- });
10365
- } else if (timeArr[j].id > stMinute && timeArr[j].id < etMinute) {
10366
- timeArr[j].recArr.push({
10367
- height: 60,
10368
- top: 0
10369
- });
10370
- }
10371
- }
10372
- }
10373
- }
10374
- }
10375
- this.setState({
10376
- timeArr
10377
- });
10378
- this._renderDateLine();
10379
- }
10380
- _renderDateLine() {
10381
- const { timeArr } = this.state;
10382
- const container = this._$itemList;
10383
- container.innerHTML = '';
10384
- timeArr.forEach((item, index)=>{
10385
- const timeItemDOM = document.createElement('div');
10386
- timeItemDOM.setAttribute('class', PREFIX + '-time-scale-area');
10387
- timeItemDOM.style.cssText = `margin-top: ${item.marginTop}px; margin-bottom: ${item.marginBottom}px; border-right-color: ${item.borderColor};`;
10388
- const scaleDOM = document.createElement('div');
10389
- scaleDOM.setAttribute('class', PREFIX + '-scale');
10390
- let timeItemHtml = `
10391
- <div class="${PREFIX}-time-scale"></div>
10392
- <div class="${PREFIX}-time-scale"></div>
10393
- <div class="${PREFIX}-time-scale"></div>
10394
- <div class="${PREFIX}-time-scale"></div>
10395
- <div class="${PREFIX}-time-scale"></div>
10396
- <div class="${PREFIX}-time-scale" style="width:10px"></div>
10397
- `;
10398
- item.recArr.forEach((i, j)=>{
10399
- timeItemHtml += `<div class="${PREFIX}-time-unavail" style="height: ${i.height}px;background-color:#A8B9ED; top: ${i.top}px"></div>`;
10400
- });
10401
- timeItemHtml += `<div id=${item.label} class="${PREFIX}-time-label"> ${item.current}</div>`;
10402
- timeItemDOM.innerHTML = timeItemHtml;
10403
- container.appendChild(timeItemDOM);
10404
- });
10405
- }
10406
- _primaryOffsetH() {
10407
- const { start, timeArr, current } = this.state;
10408
- const scaleWidth = this._scaleWidth;
10409
- const currentItem = timeArr[0].current;
10410
- const currentTime = this._timeToSecond(currentItem);
10411
- // current不为0时,从当前时间开始计算偏移量,避免拖动时间轴后回弹
10412
- const startSecond = this._timeToSecond(current === 0 ? start : current);
10413
- const offsetS = currentTime - startSecond;
10414
- const offsetH = Math.ceil(offsetS / scaleWidth) + 60; // offsetS / (scaleWidth * 60) * 60
10415
- this.setState({
10416
- scrollTop: offsetH
10417
- });
10418
- }
10419
- _currentOffsetH() {
10420
- const { current, timeArr } = this.state;
10421
- const scale = this._scaleWidth;
10422
- const startItem = timeArr[0].current;
10423
- const startSecond = this._timeToSecond(startItem);
10424
- const currentSecond = this._timeToSecond(current);
10425
- const offsetS = startSecond - currentSecond;
10426
- const offsetH = Math.ceil(offsetS / scale) + 60; // offsetS / (scale * 60) * 60
10427
- this.setState({
10428
- scrollTop: offsetH
10429
- });
10430
- }
10431
- _rectTopToTime(reactTop) {
10432
- const scaleWidth = this._scaleWidth;
10433
- // let rectTop = rect.top; // 获取当前元素距离父元素顶部的高度
10434
- // let reactTop = 0 - rectTop; // 实际偏移高度
10435
- const index = Math.floor(reactTop / 60); // 以分钟为刻度时,每个元素初始高度为60px, 向下取整并除以时刻倍数得出偏移item;
10436
- const offsetH = reactTop - index * 60; // 偏移高度
10437
- let current;
10438
- let offsetSecond;
10439
- if (offsetH == 0) {
10440
- var _this_state_timeArr_;
10441
- current = (_this_state_timeArr_ = this.state.timeArr[index - 1]) == null ? void 0 : _this_state_timeArr_.current;
10442
- offsetSecond = 0;
10443
- } else {
10444
- // 当scaleWidth==120, scaleWidth==60, scaleWidth==30, scaleWidth==10, scaleWidth==1
10445
- const time = this.state.timeArr[index].current;
10446
- const minute = this._timeToMinute(time);
10447
- // 相对于下一元素偏移
10448
- const offsetY = 60 - offsetH;
10449
- const offsetS = offsetY * scaleWidth; // offsetY / 60 * scaleWidth * 60
10450
- const offsetM = Math.floor(offsetS / 60) + minute;
10451
- const second = Math.floor(offsetS / 60) * 60;
10452
- offsetSecond = Math.ceil(offsetS - second); // 保留两位小数
10453
- current = this._minuteToTime(offsetM);
10454
- }
10455
- if (current === undefined || +current.split(':')[0] >= 24 && (+current.split(':')[1] > 0 || offsetSecond > 0)) {
10456
- // 超出 24h 后不允许
10457
- this.update(new Date(`${new Date().getFullYear()}-${subTime(new Date().getMonth() + 1)}-${subTime(new Date().getDate())} 23:59:59`));
10458
- return;
10459
- }
10460
- this.setState({
10461
- current: current + ':' + (offsetSecond > 9 ? offsetSecond : '0' + offsetSecond),
10462
- scrollTop: reactTop
10463
- });
10464
- }
10465
- /**
10254
+ */get _scaleWidth(){return (MOBILE_TIME_WIDTH[this.timeWidth]||MOBILE_TIME_WIDTH[0])[0]}
10255
+ /**
10256
+ * 更新片段数组
10257
+ * @param timeSections
10258
+ * @param defaultIndex
10259
+ */updateTimeSections(timeSections,defaultIndex){super.updateTimeSections(timeSections);const list=timeSections.map(record=>_extends$1$1({},record,{startTime:TimeLineUtil.formatDateToHHmmss(record.startTime),endTime:TimeLineUtil.formatDateToHHmmss(record.endTime)}));if(list.length>0){if(typeof defaultIndex==="undefined")defaultIndex=list.length-1;// 默认选中最后一个片段位置
10260
+ // 若current不为0,则不重置current,避免拖动后时间轴回弹
10261
+ const{current:current}=this.state;this.setState({availTimeLine:list,start:list[defaultIndex].startTime,end:list[defaultIndex].endTime,current:current===0?list[defaultIndex].startTime:current});this._matchTimeDot();this._primaryOffsetH();}else {this.setState({availTimeLine:[]});this._matchTimeDot();}this._renderPickerContent();}
10262
+ /**
10466
10263
  * 更新当前时间
10467
10264
  * @param time 能转成时间的值, 如 时间对象 Date, 时间戳,时间戳字符串
10468
- */ update(time) {
10469
- if (time && !this._isTouchStart) {
10470
- this.setState({
10471
- current: tranTime(time, 'HH:mm:ss')
10472
- });
10473
- this._currentOffsetH();
10474
- }
10475
- }
10476
- destroy() {
10477
- if (this._scrollTimer) {
10478
- clearInterval(this._scrollTimer);
10479
- this._scrollTimer = null;
10480
- }
10481
- this._removeEventListener();
10482
- super.destroy();
10483
- }
10484
- _timeToSecond(time) {
10485
- const e = time.split(':');
10486
- const h = Number(e[0]);
10487
- const m = Number(e[1]);
10488
- const s = Number(e[2]);
10489
- return h * 60 * 60 + m * 60 + (s ? s : 0);
10490
- }
10491
- _minuteToTime(minute) {
10492
- const hour = Math.floor(minute / 60);
10493
- const m = minute % 60;
10494
- return (hour > 9 ? hour : '0' + hour) + ':' + (m > 9 ? m : '0' + m);
10495
- }
10496
- _timeToMinute(time) {
10497
- const e = time.split(':');
10498
- const h = Number(e[0]);
10499
- const m = Number(e[1]);
10500
- // const s = Number(e[2]);
10501
- return h * 60 + m;
10502
- }
10503
- _render() {
10504
- this._$currentTime = document.createElement('div');
10505
- this._$currentTime.classList.add(PREFIX + '-current');
10506
- this._$currentTime.innerHTML = `<div class="${PREFIX}-current-value">00:00:00</div>`;
10507
- this.$container.appendChild(this._$currentTime);
10508
- this._$itemContainer = document.createElement('div');
10509
- this._$itemContainer.classList.add(PREFIX + '-item-container');
10510
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
10511
- if (/\d/.test(this.options.height)) {
10512
- this._$itemContainer.style.cssText += `height: ${this.options.height}px`;
10513
- } else if (typeof this.options.height === 'string') {
10514
- this._$itemContainer.style.cssText += `height: ${this.options.height}`;
10515
- } else {
10516
- const height = this.$container.clientHeight;
10517
- this._$itemContainer.style.cssText += `height: ${height}px`;
10518
- }
10519
- this._$itemList = document.createElement('div');
10520
- this._$itemList.classList.add(PREFIX + '-item');
10521
- this._$itemContainer.appendChild(this._$itemList);
10522
- this.$container.appendChild(this._$itemContainer);
10523
- this._addEventListener();
10524
- }
10525
- _addEventListener() {
10526
- // js安卓、IOS、鸿蒙系统监听开始触摸
10527
- if (this._$itemContainer) {
10528
- // 监听手动滚动时间轴时,停止时间轴滚动,时刻仍然变化
10529
- this._$itemContainer.addEventListener('touchstart', this._touchstart, false);
10530
- // 监听手动滚动时间轴时,停止时间轴滚动,时刻仍然变化
10531
- this._$itemContainer.addEventListener('touchmove', this._touchmove, false);
10532
- // 手动滚动停止,选定时刻自动播放
10533
- this._$itemContainer.addEventListener('touchend', this._touchend, false);
10534
- }
10535
- this._matchTimeDot();
10536
- }
10537
- _removeEventListener() {
10538
- if (this._$itemContainer) {
10539
- // 监听手动滚动时间轴时,停止时间轴滚动,时刻仍然变化
10540
- this._$itemContainer.removeEventListener('touchstart', this._touchstart);
10541
- // 监听手动滚动时间轴时,停止时间轴滚动,时刻仍然变化
10542
- this._$itemContainer.removeEventListener('touchmove', this._touchmove);
10543
- // 手动滚动停止,选定时刻自动播放
10544
- this._$itemContainer.removeEventListener('touchend', this._touchend);
10545
- }
10546
- }
10547
- _touchstart() {
10548
- if (this._readOnly) return false;
10549
- this._isTouchStart = true;
10550
- this.options.onDragStart == null ? void 0 : this.options.onDragStart.call(this.options, this.state.current);
10551
- }
10552
- _touchmove() {
10553
- var _this__$itemContainer;
10554
- if (this._readOnly) return false;
10555
- const reactTop = (_this__$itemContainer = this._$itemContainer) == null ? void 0 : _this__$itemContainer.scrollTop; // 实际偏移高度
10556
- this._rectTopToTime(reactTop);
10557
- this.options.onDragging == null ? void 0 : this.options.onDragging.call(this.options, this.state.current);
10558
- }
10559
- _touchend() {
10560
- if (this._readOnly) return false;
10561
- // 这里有问题, 滚动是利用滚动操作(overflow-y: scroll;)的
10562
- new Promise((resolve, _reject)=>{
10563
- let preTop = -1;
10564
- if (this._scrollTimer) {
10565
- clearInterval(this._scrollTimer);
10566
- this._scrollTimer = null;
10567
- }
10568
- this._scrollTimer = setInterval(()=>{
10569
- var _this__$itemContainer;
10570
- // debugger
10571
- const reactTop = (_this__$itemContainer = this._$itemContainer) == null ? void 0 : _this__$itemContainer.scrollTop; // 实际偏移高度
10572
- if (reactTop !== preTop) {
10573
- preTop = reactTop;
10574
- } else {
10575
- if (this._scrollTimer) {
10576
- clearInterval(this._scrollTimer);
10577
- this._scrollTimer = null;
10578
- }
10579
- this._isTouchStart = false;
10580
- resolve(reactTop);
10581
- }
10582
- }, 100);
10583
- }).then((reactTop)=>{
10584
- this._rectTopToTime(reactTop);
10585
- this.options.onDragEnd == null ? void 0 : this.options.onDragEnd.call(this.options, this.state.current);
10586
- this.options.onChange == null ? void 0 : this.options.onChange.call(this.options, this.state.current);
10587
- });
10588
- }
10589
- constructor(container, options){
10590
- super(container, deepmerge(MOBILE_TIME_LINE_DEFAULT_OPTIONS, options, {
10591
- clone: false
10592
- })), // 禁用拖动轴
10593
- this._readOnly = false, this._isTouchStart = false, this.state = {
10594
- start: '00:00:00',
10595
- end: '24:00:00',
10596
- current: 0,
10597
- timeArr: [],
10598
- availTimeLine: [],
10599
- scrollTop: 0,
10600
- index: 0,
10601
- date: '',
10602
- noTimeLineTxt: ''
10603
- };
10604
- this._scale = this.options.scale || 0;
10605
- this.setReadOnly(!!this.options.readOnly);
10606
- this._touchstart = this._touchstart.bind(this);
10607
- this._touchmove = this._touchmove.bind(this);
10608
- this._touchend = this._touchend.bind(this);
10609
- this._render();
10610
- }
10611
- };
10612
-
10265
+ */update(time){if(time&&!this._isTouchStart){this.setState({current:TimeLineUtil.tranTime(time,"HH:mm:ss")});this._currentOffsetH();}}
10613
10266
  /**
10614
- * 时间刻度宽度 [刻度间隔秒数s, 刻度间隔宽度px, 长刻度间隔短刻度个数, 说明]
10615
- * 需要满足 (24 * 60 * 60) % ([0] * [2]) = 0, 这样 0 点刻度才能正确显示
10616
- */ /**
10617
- * 时间刻度宽度, 需要满足 (24 * 60 * 60) % ([0] * [2]) = 0
10618
- */ const TIME_WIDTH = [
10619
- [
10620
- 1,
10621
- 10,
10622
- 10,
10623
- '单位 1秒'
10624
- ],
10625
- [
10626
- 60,
10627
- 20,
10628
- 5,
10629
- '单位 1分钟'
10630
- ],
10631
- [
10632
- 600,
10633
- 20,
10634
- 6,
10635
- '单位 10分钟'
10636
- ],
10637
- [
10638
- 3600,
10639
- 30,
10640
- 6,
10641
- '单位 1小时'
10642
- ],
10643
- [
10644
- 14400,
10645
- 40,
10646
- 2,
10647
- '单位 4小时'
10648
- ],
10649
- [
10650
- 43200,
10651
- 80,
10652
- 2,
10653
- '单位 12小时'
10654
- ]
10655
- ];
10656
-
10267
+ * 销毁
10268
+ */destroy(){if(this._scrollTimer){clearInterval(this._scrollTimer);this._scrollTimer=null;}if(this._$currentTime){this.$container.removeChild(this._$currentTime);this._$currentTime=null;}if(this._$itemContainer&&this._$itemList){this._$itemContainer.removeChild(this._$itemList);this._$itemList=null;}if(this._$itemContainer){this.$container.removeChild(this._$itemContainer);this._$itemContainer=null;}if(this._$op){this.$container.removeChild(this._$op);this._$op=null;}if(this._picker){this._picker.destroy();this._picker=null;}this._removeEventListener();super.destroy();}
10269
+ /**
10270
+ * 渲染时间轴刻度数组
10271
+ */_matchTimeDot(){const scaleWidth=this._scaleWidth;// 时间单位 分钟
10272
+ const timeArr=[];
10273
+ // 时间转分钟
10274
+ let minute=TimeLineUtil.timeToMinute("24:00:00");minute=Math.floor(minute/scaleWidth)*scaleWidth;for(let i=minute;i>=0;){let marginTop=0;let marginBottom=0;
10275
+ // 视频片段
10276
+ if(i==minute)marginTop=70;if(i==0)marginBottom=this.$container.clientHeight-70;const time=TimeLineUtil.minuteToTime(i);const startSecond=TimeLineUtil.timeToSecond(time+":00");const endSecond=TimeLineUtil.timeToSecond(time+":00")+scaleWidth*60;const coverList=this.timeSections.filter(item=>{const start=TimeLineUtil.timeToSecond(TimeLineUtil.tranTime(item.startTime,"HH:mm:ss"));return start>=startSecond&&start<endSecond});timeArr.push({id:i,current:time,label:"a"+i,marginTop:marginTop,marginBottom:marginBottom,recArr:[],coverArr:coverList});i-=scaleWidth;}this.setState({timeArr:timeArr});this._matchRecTimeDot();}_matchRecTimeDot(){const{availTimeLine:availTimeLine,timeArr:timeArr}=this.state;const scaleWidth=this._scaleWidth;const len=availTimeLine.length;if(len===0)for(let j=0;j<timeArr.length;j++)timeArr[j].recArr=[];else {for(let k=0;k<timeArr.length;k++)timeArr[k].recArr=[];for(let i=0;i<len;i++){const temp=availTimeLine[i];const st=TimeLineUtil.timeToSecond(temp.startTime);// "00:01:00" -> 60 // 秒
10277
+ const et=TimeLineUtil.timeToSecond(temp.endTime);let stAvailPercent=0;let etAvailPercent=0;const stMinute=Math.floor(st/(scaleWidth*60))*scaleWidth;stAvailPercent=(st-stMinute*60)/scaleWidth;const etMinute=Math.floor(et/(scaleWidth*60))*scaleWidth;etAvailPercent=(et-etMinute*60)/scaleWidth;for(let j=0;j<timeArr.length;j++)if(timeArr[j].id==stMinute&&timeArr[j].id==etMinute){const height=etAvailPercent-stAvailPercent;const top=60-etAvailPercent;
10278
+ // prettier-ignore
10279
+ timeArr[j].recArr.push({height:height,top:top});}else if(timeArr[j].id==stMinute)timeArr[j].recArr.push({height:60-stAvailPercent,top:0});else if(timeArr[j].id==etMinute)timeArr[j].recArr.push({height:etAvailPercent,top:60-etAvailPercent});else if(timeArr[j].id>stMinute&&timeArr[j].id<etMinute)timeArr[j].recArr.push({height:60,top:0});}}this.setState({timeArr:timeArr});this._renderDateLine();}_renderDateLine(){const{timeArr:timeArr}=this.state;const container=this._$itemList;container.innerHTML="";timeArr.forEach(item=>{const timeItemDOM=document.createElement("div");timeItemDOM.setAttribute("class",MOBILE_TIMELINE_PREFIX+"-time-scale-area");if(item.marginTop)timeItemDOM.style.cssText+=`margin-top: ${item.marginTop}px;`;if(item.marginBottom)timeItemDOM.style.cssText+=`margin-bottom: ${item.marginBottom}px;`;timeItemDOM.style.cssText+=`border-right-color: ${this.options.timeAxisBgColor||"rgba(189, 205, 255, 1)"};`;const scaleDOM=document.createElement("div");scaleDOM.setAttribute("class",MOBILE_TIMELINE_PREFIX+"-scale");let timeItemHtml=``;if(item.coverArr.length)timeItemHtml+=`\n <div class="${MOBILE_TIMELINE_PREFIX}-time-cover-fold ${item.coverArr.length>1?`${MOBILE_TIMELINE_PREFIX}-time-cover-fold-multiple`:""} " data-start="${item.current}">\n ${item.coverArr.length>1?`<div class="${MOBILE_TIMELINE_PREFIX}-cover-fold-placeholder" style="color: #FFF"></div>`:""}\n <div class="${MOBILE_TIMELINE_PREFIX}-time-cover-fold-img">\n ${item.coverArr[0].coverPic?`<img src="${item.coverArr[0].coverPic}&x=1000" />`:""}\n <span class="${MOBILE_TIMELINE_PREFIX}-time-cover-fold-len">\n ${item.coverArr.length>1?this.i18n.t("foldTitle",{len:item.coverArr.length,unit:"videos"}):`${TimeLineUtil.tranTime(item.coverArr[0].startTime,"HH:mm")}`}\n </span>\n ${item.coverArr.length===1?`<span class="${MOBILE_TIMELINE_PREFIX}-time-cover-fold-time">${TimeLineUtil.tranTimeToString(item.coverArr[0].startTime,item.coverArr[0].endTime)}</span>`:""}\n <span class="${MOBILE_TIMELINE_PREFIX}-time-cover-fold-pause">${Icons.pause}</span>\n </div>\n </div>`;
10280
+ // 六个详细刻度
10281
+ // <div class="${MOBILE_TIMELINE_PREFIX}-time-scale"></div>
10282
+ // <div class="${MOBILE_TIMELINE_PREFIX}-time-scale"></div>
10283
+ // <div class="${MOBILE_TIMELINE_PREFIX}-time-scale"></div>
10284
+ // <div class="${MOBILE_TIMELINE_PREFIX}-time-scale"></div>
10285
+ // <div class="${MOBILE_TIMELINE_PREFIX}-time-scale"></div>
10286
+ // <div class="${MOBILE_TIMELINE_PREFIX}-time-scale" style="width:10px"></div>
10287
+ item.recArr.forEach(i=>{timeItemHtml+=`<div class="${MOBILE_TIMELINE_PREFIX}-time-unavail"\n style="height: ${i.height}px;background-color:${this.options.timeSectionColor||"#369FFF"}; top: ${i.top}px">\n </div>`;});timeItemHtml+=`<div id=${item.label} class="${MOBILE_TIMELINE_PREFIX}-time-label" style="color: ${this.options.timeTextColor||"#666"}">${item.current}</div>`;timeItemDOM.innerHTML=timeItemHtml;container.appendChild(timeItemDOM);});}_primaryOffsetH(){const{start:start,timeArr:timeArr,current:current}=this.state;const scaleWidth=this._scaleWidth;const currentItem=timeArr[0].current;const currentTime=TimeLineUtil.timeToSecond(currentItem);
10288
+ // current不为0时,从当前时间开始计算偏移量,避免拖动时间轴后回弹
10289
+ const startSecond=TimeLineUtil.timeToSecond(current===0?start:current);const offsetS=currentTime-startSecond;const offsetH=Math.ceil(offsetS/scaleWidth)+60;// offsetS / (scaleWidth * 60) * 60
10290
+ this.setState({scrollTop:offsetH});console.log("起始偏移量",offsetH);}_currentOffsetH(){const{current:current,timeArr:timeArr}=this.state;const scale=this._scaleWidth;const startItem=timeArr[0].current;const startSecond=TimeLineUtil.timeToSecond(startItem);const currentSecond=TimeLineUtil.timeToSecond(current);const offsetS=startSecond-currentSecond;const offsetH=Math.ceil(offsetS/scale)+60;// offsetS / (scale * 60) * 60
10291
+ this.setState({scrollTop:offsetH});}_rectTopToTime(reactTop){const scaleWidth=this._scaleWidth;
10292
+ // let rectTop = rect.top; // 获取当前元素距离父元素顶部的高度
10293
+ // let reactTop = 0 - rectTop; // 实际偏移高度
10294
+ const index=Math.floor(reactTop/60);// 以分钟为刻度时,每个元素初始高度为60px, 向下取整并除以时刻倍数得出偏移item;
10295
+ const offsetH=reactTop-index*60;// 偏移高度
10296
+ let current;let offsetSecond;
10297
+ // console.log('index:', index, 'offsetH:', offsetH);
10298
+ if(offsetH==0){var _this_state_timeArr_;current=(_this_state_timeArr_=this.state.timeArr[index-1])==null?void 0:_this_state_timeArr_.current;offsetSecond=0;}else {
10299
+ // 当scaleWidth==120, scaleWidth==60, scaleWidth==30, scaleWidth==10, scaleWidth==1
10300
+ const time=this.state.timeArr[index].current;const minute=TimeLineUtil.timeToMinute(time);
10301
+ // 相对于下一元素偏移
10302
+ const offsetY=60-offsetH;const offsetS=offsetY*scaleWidth;// offsetY / 60 * scaleWidth * 60
10303
+ const offsetM=Math.floor(offsetS/60)+minute;const second=Math.floor(offsetS/60)*60;offsetSecond=Math.ceil(offsetS-second);// 保留两位小数
10304
+ current=TimeLineUtil.minuteToTime(offsetM);}if(current===void 0||+current.split(":")[0]>=24&&(+current.split(":")[1]>0||offsetSecond>0)){
10305
+ // 超出 24h 后不允许
10306
+ this.update(new Date(`${(new Date).getFullYear()}-${TimeLineUtil.subTime((new Date).getMonth()+1)}-${TimeLineUtil.subTime((new Date).getDate())} 23:59:59`));return}this.setState({current:current+":"+(offsetSecond>9?offsetSecond:"0"+offsetSecond),scrollTop:reactTop});}_render(){this._$currentTime=document.createElement("div");this._$currentTime.classList.add(MOBILE_TIMELINE_PREFIX+"-current");this._$currentTime.innerHTML=`<div class="${MOBILE_TIMELINE_PREFIX}-current-content" style="color: ${this.options.currentTimeBgColor||"#648FFC"}">\n <span class="${MOBILE_TIMELINE_PREFIX}-current-tip">${Icons.tip}</span>\n <span class="${MOBILE_TIMELINE_PREFIX}-current-tip-line" style="background-color: ${this.options.timePointColor||"#648FFC"};"></span>\n <div class="${MOBILE_TIMELINE_PREFIX}-current-value" style="color: ${this.options.currentTimeColor||"#FFFFFF"}">00:00:00</div>\n </div>`;this.$container.appendChild(this._$currentTime);this._$itemContainer=document.createElement("div");this._$itemContainer.classList.add(MOBILE_TIMELINE_PREFIX+"-item-container");
10307
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
10308
+ if(/\d/.test(this.options.height))this._$itemContainer.style.cssText+=`height: ${this.options.height}px`;else if(typeof this.options.height==="string")this._$itemContainer.style.cssText+=`height: ${this.options.height}`;else {const height=this.$container.clientHeight;this._$itemContainer.style.cssText+=`height: ${height}px`;}this._$itemList=document.createElement("div");this._$itemList.classList.add(MOBILE_TIMELINE_PREFIX+"-item");this._$itemContainer.appendChild(this._$itemList);this.$container.appendChild(this._$itemContainer);if(this.options.showTimeWidthBtn){
10309
+ // 加减
10310
+ this._$op=document.createElement("div");this._$op.classList.add(MOBILE_TIMELINE_PREFIX+"-op");this._$op.innerHTML=`<span class="${MOBILE_TIMELINE_PREFIX}-op-wrapper">\n <span class="${MOBILE_TIMELINE_PREFIX}-icon-plus">${Icons.plus}</span>\n <span class="${MOBILE_TIMELINE_PREFIX}-icon-minus">${Icons.minus}</span>\n </span>`;this.$container.appendChild(this._$op);}this._picker=new Picker(null,{isMobile:true,wrapClassName:`${MOBILE_TIMELINE_PREFIX}-picker`,onOpenChange:isOpen=>{var _this_options_onPickerOpenChange,_this_options;(_this_options=this.options)==null?void 0:(_this_options_onPickerOpenChange=_this_options.onPickerOpenChange)==null?void 0:_this_options_onPickerOpenChange.call(_this_options,isOpen);}});this._renderPickerContent();this._addEventListener();}_addEventListener(){
10311
+ // js安卓、IOS、鸿蒙系统监听开始触摸
10312
+ if(this._$itemContainer){
10313
+ // console.warn('=== TimeLine HAS_POINTER_EVENT ===', HAS_POINTER_EVENT);
10314
+ // 监听手动滚动时间轴时,停止时间轴滚动,时刻仍然变化
10315
+ this._$itemContainer.addEventListener("touchstart",this._touchstart,false);
10316
+ // 监听手动滚动时间轴时,停止时间轴滚动,时刻仍然变化
10317
+ this._$itemContainer.addEventListener("touchmove",this._touchmove,false);
10318
+ // 手动滚动停止,选定时刻自动播放
10319
+ this._$itemContainer.addEventListener("touchend",this._touchend,false);
10320
+ // prettier-ignore
10321
+ // this._$itemContainer.addEventListener('scroll', this._touchmove, false);
10322
+ }if(this.options.showTimeWidthBtn&&this._$op){var// this._$op.addEventListener('click', this._opClick, false);
10323
+ _this__$op_querySelector,_this__$op_querySelector1;(_this__$op_querySelector=this._$op.querySelector(`.${MOBILE_TIMELINE_PREFIX}-icon-plus`))==null?void 0:_this__$op_querySelector.addEventListener("click",this._plusClick,false);(_this__$op_querySelector1=this._$op.querySelector(`.${MOBILE_TIMELINE_PREFIX}-icon-minus`))==null?void 0:_this__$op_querySelector1.addEventListener("click",this._minusClick,false);}this._matchTimeDot();if(this._picker){this._delegatePickerClose=delegate(this._picker.$body,`.${MOBILE_TIMELINE_PREFIX}-picker-close`,"click",this._onPickerClose,false);this._delegateItemContent=delegate(this._picker.$body,`.${MOBILE_TIMELINE_PREFIX}-picker-item-content`,"click",this._onClickItem,false);this._delegateCoverFold=delegate(this.$container,`.${MOBILE_TIMELINE_PREFIX}-time-cover-fold`,"click",this._onClickCoverFold,false);}}_removeEventListener(){if(this._$itemContainer){
10324
+ // 监听手动滚动时间轴时,停止时间轴滚动,时刻仍然变化
10325
+ this._$itemContainer.removeEventListener("touchstart",this._touchstart);
10326
+ // 监听手动滚动时间轴时,停止时间轴滚动,时刻仍然变化
10327
+ this._$itemContainer.removeEventListener("touchmove",this._touchmove);
10328
+ // 手动滚动停止,选定时刻自动播放
10329
+ this._$itemContainer.removeEventListener("touchend",this._touchend);}if(this.options.showTimeWidthBtn&&this._$op){var _this__$op_querySelector,_this__$op_querySelector1;(_this__$op_querySelector=this._$op.querySelector(`.${MOBILE_TIMELINE_PREFIX}-icon-plus`))==null?void 0:_this__$op_querySelector.removeEventListener("click",this._plusClick);(_this__$op_querySelector1=this._$op.querySelector(`.${MOBILE_TIMELINE_PREFIX}-icon-minus`))==null?void 0:_this__$op_querySelector1.removeEventListener("click",this._minusClick);}if(this._picker){var _this__picker_$body_querySelector,_this__picker_$body;(_this__picker_$body=this._picker.$body)==null?void 0:(_this__picker_$body_querySelector=_this__picker_$body.querySelector(`.${MOBILE_TIMELINE_PREFIX}-picker-close`))==null?void 0:_this__picker_$body_querySelector.removeEventListener("click",this._onPickerClose);if(this._delegateItemContent){this._delegateItemContent.forEach(function(delegation){delegation.destroy();});this._delegateItemContent=null;}if(this._delegatePickerClose){this._delegatePickerClose.forEach(function(delegation){delegation.destroy();});this._delegatePickerClose=null;}if(this._delegateCoverFold){this._delegateCoverFold.forEach(function(delegation){delegation.destroy();});this._delegateCoverFold=null;}}}_plusClick(){const timeWidth=this.timeWidth+1;if(timeWidth>0&&timeWidth<MOBILE_TIME_WIDTH.length)this.setTimeWidth(timeWidth);else console.warn("时间轴刻度宽度不能再加了");}_minusClick(){const timeWidth=this.timeWidth-1;if(timeWidth>=0&&timeWidth<MOBILE_TIME_WIDTH.length)this.setTimeWidth(Math.floor(timeWidth));else console.warn("时间轴刻度宽度不能再减了");}_touchstart(){var _this__$itemContainer;if(this.readOnly)return false;this._isTouchStart=true;this._touchstartTop=(_this__$itemContainer=this._$itemContainer)==null?void 0:_this__$itemContainer.scrollTop;this.options.onDragStart==null?void 0:this.options.onDragStart.call(this.options,this.state.current);}_touchmove(){var _this__$itemContainer;if(this.readOnly)return false;const reactTop=(_this__$itemContainer=this._$itemContainer)==null?void 0:_this__$itemContainer.scrollTop;// 实际偏移高度
10330
+ this._rectTopToTime(reactTop);this.options.onDragging==null?void 0:this.options.onDragging.call(this.options,this.state.current);}_touchend(){if(this.readOnly)return false;
10331
+ // 这里有问题, 滚动是利用滚动操作(overflow-y: scroll;)的
10332
+ new Promise(resolve=>{let preTop=-1;if(this._scrollTimer){clearInterval(this._scrollTimer);this._scrollTimer=null;}this._scrollTimer=setInterval(()=>{var _this__$itemContainer;
10333
+ // debugger
10334
+ const reactTop=(_this__$itemContainer=this._$itemContainer)==null?void 0:_this__$itemContainer.scrollTop;// 实际偏移高度
10335
+ if(reactTop!==preTop){console.log("scrolling",reactTop,preTop);preTop=reactTop;}else {console.log("scroll stop",reactTop,preTop);if(this._scrollTimer){clearInterval(this._scrollTimer);this._scrollTimer=null;}this._isTouchStart=false;resolve(reactTop);}},100);}).then(reactTop=>{var _this__$itemContainer;this._rectTopToTime(reactTop);console.log("页面滚动实际高度",reactTop,this.state.current);this.options.onDragEnd==null?void 0:this.options.onDragEnd.call(this.options,this.state.current);if(this._touchstartTop!==((_this__$itemContainer=this._$itemContainer)==null?void 0:_this__$itemContainer.scrollTop)){this.options.onChange==null?void 0:this.options.onChange.call(this.options,this.state.current);this._touchstartTop=0;}});}_timeSectionsToGroupsByHour(){const obj={};this.timeSections.forEach((item,index)=>{
10336
+ // 移动端仅支持一天
10337
+ // if (TimeLineUtil.tranTime(item.startTime, 'YYYY-MM-DD') !== TimeLineUtil.tranTime(item.endTime, 'YYYY-MM-DD')) {
10338
+ // //
10339
+ // }
10340
+ const hour=TimeLineUtil.tranTime(item.startTime,"HH");if(obj[+hour])obj[+hour].push(_extends$1$1({},item,{_index:index}));else obj[+hour]=[_extends$1$1({},item,{_index:index})];});return obj}
10341
+ /**
10342
+ * 渲染选择器内容
10343
+ */_renderPickerContent(){var _this__picker_innerHTML,_this__picker;const hourGroups=this._timeSectionsToGroupsByHour();(_this__picker=this._picker)==null?void 0:(_this__picker_innerHTML=_this__picker.innerHTML)==null?void 0:_this__picker_innerHTML.call(_this__picker,`<div class="${MOBILE_TIMELINE_PREFIX}-picker-container">\n <div class="${MOBILE_TIMELINE_PREFIX}-picker-header">\n <span class="${MOBILE_TIMELINE_PREFIX}-picker-close">${Icons.close}</span>\n ${this.i18n.t("title",{len:this.timeSections.length,unit:this.timeSections.length>1?"videos":"video"})}\n </div>\n <div class="${MOBILE_TIMELINE_PREFIX}-picker-content">\n <div class="${MOBILE_TIMELINE_PREFIX}-picker-list">\n ${Object.keys(hourGroups).reverse().map(key=>`<div class="${MOBILE_TIMELINE_PREFIX}-picker-item">\n <div class="${MOBILE_TIMELINE_PREFIX}-picker-item-title">${key}:00</div>\n <div class="${MOBILE_TIMELINE_PREFIX}-picker-item-list">\n ${hourGroups[key].map(item=>`<div class="${MOBILE_TIMELINE_PREFIX}-picker-item-content"\n data-start="${TimeLineUtil.tranTime(item.startTime,"YYYYMMDDTHHmmssZ")}"\n data-end="${TimeLineUtil.tranTime(item.endTime,"YYYYMMDDTHHmmssZ")}"\n data-index="${item._index}">\n <span class="${MOBILE_TIMELINE_PREFIX}-picker-item-time">${TimeLineUtil.tranTime(item.startTime,"mm:ss")}</span>\n <span class="${MOBILE_TIMELINE_PREFIX}-picker-item-duration">\n ${TimeLineUtil.tranTimeToString(item.startTime,item.endTime)}\n </span>\n <span class="${MOBILE_TIMELINE_PREFIX}-picker-item-icon-pause">${Icons.pause}</span>\n ${item.coverPic?`<img class="${MOBILE_TIMELINE_PREFIX}-picker-item-cover" src="${item.coverPic}&x=1000"/>`:""}\n </div>`).join("")}\n </div>\n </div>`).join("")}\n </div>\n </div>\n </div>\n </div>`);}_onPickerClose(){if(this._picker)this._picker.open=false;}_onClickItem(e){var _e_target_getAttribute,_e_target;console.log("click item",e);console.log(e.target);console.log(e.delegateTarget);const index=(_e_target=e.target)==null?void 0:(_e_target_getAttribute=_e_target.getAttribute)==null?void 0:_e_target_getAttribute.call(_e_target,"data-index");if(this._picker)this._picker.open=false;this.options.onPickerSelect==null?void 0:this.options.onPickerSelect.call(this.options,this.timeSections[+index]);}_onClickCoverFold(e){e.preventDefault();e.stopPropagation();
10344
+ // const index = (e.target as HTMLDivElement)?.getAttribute?.('data-index') as string;
10345
+ if(this._picker)this._picker.open=true;}constructor(container,options){super(container,deepmerge(MOBILE_TIME_LINE_DEFAULT_OPTIONS,options,{clone:false})),this._isTouchStart=false,this._touchstartTop=0,this.state={start:"00:00:00",end:"24:00:00",current:0,timeArr:[],availTimeLine:[],scrollTop:0,index:0};this._touchstart=this._touchstart.bind(this);this._touchmove=this._touchmove.bind(this);this._touchend=this._touchend.bind(this);this._plusClick=this._plusClick.bind(this);this._minusClick=this._minusClick.bind(this);this._onPickerClose=this._onPickerClose.bind(this);this._onClickItem=this._onClickItem.bind(this);this._onClickCoverFold=this._onClickCoverFold.bind(this);this._render();}}function _extends$5(){_extends$5=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)if(Object.prototype.hasOwnProperty.call(source,key))target[key]=source[key];}return target};return _extends$5.apply(this,arguments)}
10657
10346
  /**
10658
10347
  * 时间轴配置项
10659
- */ const TIMELINE_DEFAULT_OPTIONS = {
10660
- height: 36,
10661
- className: '',
10662
- wrapClassName: '',
10663
- timeSections: [],
10664
- timeWidth: 0,
10665
- currentTime: new Date(new Date().setHours(0, 0, 8, 0)),
10666
- dpr: window.devicePixelRatio || 2,
10667
- wheelSpeed: 0.1,
10668
- readOnly: false,
10669
- scaleOffsetTop: 4,
10670
- showYearMonthDay: true,
10671
- // --------------------只支持初始化时,不支持动态变更 (不做对象冻结)--------------------
10672
- timePointColor: '#1890ff',
10673
- timeTextColor: '#FFF',
10674
- timeScaleColor: '#FFF',
10675
- timeSectionColor: 'rgba(24, 144, 255, 0.5)',
10676
- timeAxisBgColor: '#000',
10677
- onChange: ()=>{},
10678
- onDragEnd: ()=>{},
10679
- onHover: ()=>{},
10680
- onDestroy: ()=>{}
10681
- };
10348
+ */const TIMELINE_DEFAULT_OPTIONS={height:36,dpr:window.devicePixelRatio||2,
10349
+ // wheelSpeed: 0.1,
10350
+ scaleOffsetTop:4,showYearMonthDay:true};
10682
10351
  /**
10683
10352
  * 时间轴控件类, 支持PC/Mobile 拖动和缩放
10684
10353
  * @beta
@@ -10687,253 +10356,97 @@
10687
10356
  * import TimeLine from './TimeLine';
10688
10357
  * const timeLine = new TimeLine(document.getElementById('container'), {})
10689
10358
  * ```
10690
- */ let TimeLine$2 = class TimeLine {
10691
- /**
10359
+ */class TimeLine extends BaseTimeLine{
10360
+ /**
10692
10361
  * 初始化 (canvas)
10693
- */ _init() {
10694
- this._$canvas = document.createElement('canvas');
10695
- this._ctx = this._$canvas.getContext('2d');
10696
- if (this._options.className) {
10697
- this._$canvas.className = this._options.className;
10698
- }
10699
- this._$canvas.style.cssText += 'cursor: pointer;';
10700
- this.width = this._options.width || this.$container.offsetWidth;
10701
- this.height = this._options.height || this.$container.offsetHeight;
10702
- if (this._options.wrapClassName) this.$container.classList.add(this._options.wrapClassName);
10703
- this.$container.appendChild(this._$canvas);
10704
- this._addEventListener();
10705
- this.setReadOnly(this._options.readOnly);
10706
- this._update({
10707
- currentTime: this._options.currentTime,
10708
- timeWidth: this._options.timeWidth,
10709
- timeSections: this._options.timeSections
10710
- });
10711
- }
10712
- /**
10713
- * 获取当前时间
10714
- * @returns
10715
- */ get currentTime() {
10716
- return this._currentTime;
10717
- }
10718
- set currentTime(time) {
10719
- if (!this._isMouseDown && !this._destroyed) {
10720
- this._update({
10721
- currentTime: new Date(time)
10722
- });
10723
- }
10724
- }
10725
- /**
10726
- * 获取 TimeLine 的宽度
10727
- * @returns
10728
- */ get width() {
10729
- return this._width;
10730
- }
10731
- set width(width) {
10732
- if (this._$canvas && width) {
10733
- width = Math.floor(width);
10734
- this._$canvas.width = width * this._options.dpr;
10735
- this._$canvas.style.cssText += `width: ${width}px;`;
10736
- this.$container.style.width = width + 'px';
10737
- this._width = width;
10738
- this._update();
10739
- }
10740
- }
10741
- /**
10742
- * 获取 TimeLine 的高度
10743
- * @returns
10744
- */ get height() {
10745
- return this._height;
10746
- }
10747
- set height(height) {
10748
- height = Math.floor(height);
10749
- if (this._$canvas && height) {
10750
- this._$canvas.height = height * this._options.dpr;
10751
- this._$canvas.style.cssText += `height: ${height}px;`;
10752
- this.$container.style.height = height + 'px';
10753
- this._height = height;
10754
- this._update();
10755
- }
10756
- }
10757
- /**
10758
- * 设置时间轴刻度宽度
10759
- * @param timeWidth - 时间轴刻度宽度 [0, TIME_WIDTH.length - 1]
10760
- * @returns
10761
- */ setTimeWidth(timeWidth) {
10762
- this._update({
10763
- timeWidth
10764
- });
10765
- }
10766
- get scale() {
10767
- return this._timeWidth;
10768
- }
10769
- /**
10362
+ */
10363
+ _init(){this._$canvas=document.createElement("canvas");this._ctx=this._$canvas.getContext("2d");if(!this.readOnly)this._$canvas.style.cssText+="cursor: pointer;";this.$container.appendChild(this._$canvas);this.resize(this.width,this.height);this._update({current:this.current,timeWidth:this.timeWidth,timeSections:this.timeSections});this._addEventListener();}
10364
+ /**
10365
+ * 重置尺寸
10366
+ */resize(width,height){super.resize(width,height);if(this._$canvas&&width){this._$canvas.width=this.width*this.options.dpr;this._$canvas.style.cssText+=`width: ${this.width}px;`;}if(this._$canvas&&height){this._$canvas.height=this.height*this.options.dpr;this._$canvas.style.cssText+=`height: ${this.height}px;`;}this._draw();}
10367
+ /**
10770
10368
  * 设置时间轴刻度宽度
10771
10369
  * @param timeWidth - 时间轴刻度宽度 [0, TIME_WIDTH.length - 1]
10772
10370
  * @returns
10773
- */ changeScale(scale) {
10774
- this.setTimeWidth(scale);
10775
- }
10776
- /**
10371
+ */setTimeWidth(timeWidth){this._update({timeWidth:timeWidth});}
10372
+ /**
10777
10373
  * 设置片段数组
10778
10374
  * @param timeSections - 片段数组
10779
10375
  * @returns
10780
- */ updateRecords(timeSections) {
10781
- this._update({
10782
- timeSections
10783
- });
10784
- }
10785
- /**
10376
+ */updateTimeSections(timeSections){this._update({timeSections:timeSections});}
10377
+ /**
10786
10378
  * 更新当前时间
10787
10379
  * @param time 能转成时间的值, 如 时间对象 Date, 时间戳,时间戳字符串
10788
- */ update(time) {
10789
- if (time && !this._isMouseDown) {
10790
- this._update({
10791
- currentTime: new Date(tranTime(time, 'YYYY-MM-DD HH:mm:ss'))
10792
- });
10793
- }
10794
- }
10795
- /**
10380
+ */update(time){if(time&&!this._isMouseDown)this._update({current:new Date(TimeLineUtil.tranTime(time,"YYYY-MM-DD HH:mm:ss"))});}
10381
+ /**
10796
10382
  * 更新
10797
10383
  * @param options - 更新参数
10798
10384
  * @returns
10799
- */ _update(options) {
10800
- if ((options == null ? void 0 : options.currentTime) && options.currentTime instanceof Date) {
10801
- this._currentTime = options.currentTime;
10802
- }
10803
- if (options == null ? void 0 : options.timeSections) {
10804
- this._timeSections = this._mergeTimeSections(options.timeSections);
10805
- }
10806
- if (typeof (options == null ? void 0 : options.timeWidth) === 'number' && (options == null ? void 0 : options.timeWidth) < TIME_WIDTH.length) {
10807
- this._timeWidth = options == null ? void 0 : options.timeWidth;
10808
- this._timeWidthArray = TIME_WIDTH[Math.floor(this._timeWidth)];
10809
- }
10810
- if (!this._timeWidthArray) {
10811
- // 不存在 默认取第一个
10812
- this._timeWidth = 0;
10813
- this._timeWidthArray = TIME_WIDTH[0];
10814
- }
10815
- if (typeof (options == null ? void 0 : options.timeWidth) === 'number' && this._timeWidthArray) {
10816
- if (this._timeWidthArray[3]) {
10817
- var _this__$canvas;
10818
- (_this__$canvas = this._$canvas) == null ? void 0 : _this__$canvas.setAttribute('data-title', this._timeWidthArray[3]);
10819
- }
10820
- }
10821
- // 清空画布
10822
- if (this._ctx) {
10823
- this._ctx.fillStyle = this._options.timeAxisBgColor;
10824
- // prettier-ignore
10825
- this._ctx.fillRect(0, 0, this._width * this._options.dpr, this._height * this._options.dpr);
10826
- }
10827
- this._draw();
10828
- }
10829
- /**
10830
- * 设置只读或取消只读
10831
- * @param readOnly - 只读或取消只读
10832
- * @returns
10833
- */ setReadOnly(readOnly) {
10834
- this._readOnly = readOnly;
10835
- if (this._$canvas) {
10836
- if (this._readOnly) {
10837
- this._$canvas.style.cursor = 'not-allowed';
10838
- } else {
10839
- this._$canvas.style.cursor = 'pointer';
10840
- }
10841
- }
10842
- }
10843
- /**
10385
+ */_update(options={}){if((options==null?void 0:options.current)&&options.current instanceof Date)this.current=options.current;if(options==null?void 0:options.timeSections)super.updateTimeSections(this._mergeTimeSections(options.timeSections));if(typeof(options==null?void 0:options.timeWidth)==="number"&&(options==null?void 0:options.timeWidth)<TIME_WIDTH.length){super.setTimeWidth(options.timeWidth);this._timeWidthArray=TIME_WIDTH[Math.floor(this.timeWidth)];}if(typeof(options==null?void 0:options.timeWidth)==="number"&&this._timeWidthArray)if(this._timeWidthArray[3]){var _this__$canvas;(_this__$canvas=this._$canvas)==null?void 0:_this__$canvas.setAttribute("data-title",this._timeWidthArray[3]);}
10386
+ // 清空画布
10387
+ if(this._ctx){this._ctx.fillStyle=this.options.timeAxisBgColor;
10388
+ // prettier-ignore
10389
+ this._ctx.fillRect(0,0,this.width*this.options.dpr,this.height*this.options.dpr);}this._draw();}
10390
+ /**
10844
10391
  * 销毁
10845
10392
  * @returns
10846
- */ destroy() {
10847
- this._removeEventListener();
10848
- if (this._$canvas) {
10849
- this.$container.removeChild(this._$canvas);
10850
- this._timeSections = [];
10851
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
10852
- this._$canvas = null;
10853
- }
10854
- this._destroyed = true;
10855
- this._options.onDestroy == null ? void 0 : this._options.onDestroy.call(this._options);
10856
- // if (this._$tip) {
10857
- // this.$container.removeChild(this._$tip);
10858
- // // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
10859
- // this._$tip = null!;
10860
- // }
10861
- }
10862
- // -----------------------------------------------------------------------------------------
10863
- // private
10864
- // -----------------------------------------------------------------------------------------
10865
- /**
10393
+ */destroy(){this._removeEventListener();if(this._$canvas){this.$container.removeChild(this._$canvas);
10394
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
10395
+ this._$canvas=null;}super.destroy();
10396
+ // if (this._$tip) {
10397
+ // this.$container.removeChild(this._$tip);
10398
+ // // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
10399
+ // this._$tip = null!;
10400
+ // }
10401
+ }
10402
+ // -----------------------------------------------------------------------------------------
10403
+ // private
10404
+ // -----------------------------------------------------------------------------------------
10405
+ /**
10866
10406
  * 缩放时间轴 动态减少间距 (没处理 dpr)
10867
10407
  * @returns 刻度间距
10868
- */ get _curScaleSpacing() {
10869
- var _this__timeWidthArray, _this__timeWidthArray1;
10870
- return Math.floor(((_this__timeWidthArray = this._timeWidthArray) == null ? void 0 : _this__timeWidthArray[1]) - ((_this__timeWidthArray1 = this._timeWidthArray) == null ? void 0 : _this__timeWidthArray1[1]) * +(this._timeWidth % 1 / 2).toFixed(2)); // 刻度间距
10871
- }
10872
- /**
10408
+ */
10409
+ get _curScaleSpacing(){var _this__timeWidthArray,_this__timeWidthArray1;return Math.floor(((_this__timeWidthArray=this._timeWidthArray)==null?void 0:_this__timeWidthArray[1])-((_this__timeWidthArray1=this._timeWidthArray)==null?void 0:_this__timeWidthArray1[1])*+(this.timeWidth%1/2).toFixed(2));// 刻度间距
10410
+ }
10411
+ /**
10873
10412
  * 绘制
10874
- */ _draw() {
10875
- this._drawScale();
10876
- this._drawSections();
10877
- }
10878
- /**
10413
+ */_draw(){this._drawSections();this._drawScale();}
10414
+ /**
10879
10415
  * 绘制刻度
10880
- */ _drawScale() {
10881
- const lineWidth = 1 * this._options.dpr;
10882
- /** 中心位置 */ this._centerPositionX = parseInt(this._width * this._options.dpr / 2 + '');
10883
- const centerPosition = {
10884
- x: this._width * this._options.dpr / 2,
10885
- y: this._height * this._options.dpr
10886
- };
10887
- const curScaleTime = Math.floor(this._currentTime.getTime() / 1000); // currentTime 秒
10888
- // 由于时区问题 当前时间戳(秒)处理但前刻度有偏移,所以改成使用当天便宜量, 这样就能保证当天的 0 点刻度能展示
10889
- // prettier-ignore
10890
- const offsetSecond = (curScaleTime - Math.floor(new Date(tranTime(new Date(curScaleTime * 1000), "YYYY-MM-DD") + " 00:00:00").getTime() / 1000)) % this._timeWidthArray[0];
10891
- const padding = this._height * this._options.dpr / 20; // 刻度顶部偏移量 高度的 1/8
10892
- const spacing = this._curScaleSpacing * this._options.dpr;
10893
- // 因为右偏移 右侧靠近中心点的X坐标 减去偏移量
10894
- // prettier-ignore
10895
- const rightLastScaleTimeX = Math.floor(this._centerPositionX + (this._timeWidthArray[0] - offsetSecond) / this._timeWidthArray[0] * spacing);
10896
- let leftLastScaleTime = curScaleTime - offsetSecond;
10897
- let rightLastScaleTime = leftLastScaleTime + this._timeWidthArray[0];
10898
- const leftLastScaleTimeX = rightLastScaleTimeX - spacing;
10899
- // 左扩展刻度
10900
- for(let x = leftLastScaleTimeX; x > 0; x -= spacing){
10901
- // prettier-ignore
10902
- const leftOffsetSecond = leftLastScaleTime - Math.floor(new Date(tranTime(new Date(leftLastScaleTime * 1000), "YYYY-MM-DD") + " 00:00:00").getTime() / 1000);
10903
- // prettier-ignore
10904
- const curScale = leftOffsetSecond % (this._timeWidthArray[0] * this._timeWidthArray[2]);
10905
- if (curScale === 0) {
10906
- // prettier-ignore
10907
- this._drawSolidLine(x, padding, x, padding + (this._options.scaleOffsetTop + 4) * this._options.dpr, lineWidth);
10908
- // prettier-ignore
10909
- this._drawTextString(tranTime(new Date(leftLastScaleTime * 1000)), x, padding + (this._options.scaleOffsetTop + 4 + 4) * this._options.dpr, "center");
10910
- } else {
10911
- this._drawSolidLine(x, padding, x, padding + this._options.scaleOffsetTop * this._options.dpr, lineWidth);
10912
- }
10913
- leftLastScaleTime = leftLastScaleTime - this._timeWidthArray[0];
10914
- }
10915
- // 右扩展刻度
10916
- // prettier-ignore
10917
- for(let x = rightLastScaleTimeX; x <= this._width * this._options.dpr; x += spacing){
10918
- // prettier-ignore
10919
- const rightOffsetSecond = rightLastScaleTime - Math.floor(new Date(tranTime(new Date(rightLastScaleTime * 1000), "YYYY-MM-DD") + " 00:00:00").getTime() / 1000);
10920
- // prettier-ignore
10921
- const curScale = rightOffsetSecond % (this._timeWidthArray[0] * this._timeWidthArray[2]);
10922
- if (curScale === 0) {
10923
- // prettier-ignore
10924
- this._drawSolidLine(x, padding, x, padding + (this._options.scaleOffsetTop + 4) * this._options.dpr, lineWidth);
10925
- // prettier-ignore
10926
- this._drawTextString(tranTime(new Date(rightLastScaleTime * 1000)), x, padding + (this._options.scaleOffsetTop + 4 + 4) * this._options.dpr, "center");
10927
- } else {
10928
- this._drawSolidLine(x, padding, x, padding + this._options.scaleOffsetTop * this._options.dpr, lineWidth);
10929
- }
10930
- rightLastScaleTime = rightLastScaleTime + this._timeWidthArray[0];
10931
- }
10932
- // 当前中心位置(当前时间 currentTime)
10933
- // prettier-ignore
10934
- this._drawSolidLine(centerPosition.x, 0, centerPosition.x, centerPosition.y, lineWidth, this._options.timePointColor);
10935
- }
10936
- /**
10416
+ */_drawScale(){const lineWidth=1*this.options.dpr;
10417
+ /** 中心位置 */this._centerPositionX=parseInt(this.width*this.options.dpr/2+"");const centerPosition={x:this.width*this.options.dpr/2,y:this.height*this.options.dpr};const curScaleTime=Math.floor(this.current.getTime()/1e3);// current 秒
10418
+ // 由于时区问题 当前时间戳(秒)处理但前刻度有偏移,所以改成使用当天便宜量, 这样就能保证当天的 0 点刻度能展示
10419
+ // prettier-ignore
10420
+ const offsetSecond=(curScaleTime-Math.floor(new Date(TimeLineUtil.tranTime(new Date(curScaleTime*1e3),"YYYY-MM-DD")+" 00:00:00").getTime()/1e3))%this._timeWidthArray[0];const padding=this.height*this.options.dpr/20;// 刻度顶部偏移量 高度的 1/8
10421
+ const spacing=this._curScaleSpacing*this.options.dpr;
10422
+ // 因为右偏移 右侧靠近中心点的X坐标 减去偏移量
10423
+ // prettier-ignore
10424
+ const rightLastScaleTimeX=Math.floor(this._centerPositionX+(this._timeWidthArray[0]-offsetSecond)/this._timeWidthArray[0]*spacing);let leftLastScaleTime=curScaleTime-offsetSecond;let rightLastScaleTime=leftLastScaleTime+this._timeWidthArray[0];const leftLastScaleTimeX=rightLastScaleTimeX-spacing;
10425
+ // 左扩展刻度
10426
+ for(let x=leftLastScaleTimeX;x>0;x-=spacing){
10427
+ // prettier-ignore
10428
+ const leftOffsetSecond=leftLastScaleTime-Math.floor(new Date(TimeLineUtil.tranTime(new Date(leftLastScaleTime*1e3),"YYYY-MM-DD")+" 00:00:00").getTime()/1e3);
10429
+ // prettier-ignore
10430
+ const curScale=leftOffsetSecond%(this._timeWidthArray[0]*this._timeWidthArray[2]);if(curScale===0){
10431
+ // prettier-ignore
10432
+ this._drawSolidLine(x,padding,x,padding+(this.options.scaleOffsetTop+4)*this.options.dpr,lineWidth);
10433
+ // prettier-ignore
10434
+ this._drawTextString(TimeLineUtil.tranTime(new Date(leftLastScaleTime*1e3)),x,padding+(this.options.scaleOffsetTop+4+4)*this.options.dpr,"center");}else this._drawSolidLine(x,padding,x,padding+this.options.scaleOffsetTop*this.options.dpr,lineWidth);leftLastScaleTime-=this._timeWidthArray[0];}
10435
+ // 右扩展刻度
10436
+ // prettier-ignore
10437
+ for(let x=rightLastScaleTimeX;x<=this.width*this.options.dpr;x+=spacing){
10438
+ // prettier-ignore
10439
+ const rightOffsetSecond=rightLastScaleTime-Math.floor(new Date(TimeLineUtil.tranTime(new Date(rightLastScaleTime*1e3),"YYYY-MM-DD")+" 00:00:00").getTime()/1e3);
10440
+ // prettier-ignore
10441
+ const curScale=rightOffsetSecond%(this._timeWidthArray[0]*this._timeWidthArray[2]);if(curScale===0){
10442
+ // prettier-ignore
10443
+ this._drawSolidLine(x,padding,x,padding+(this.options.scaleOffsetTop+4)*this.options.dpr,lineWidth);
10444
+ // prettier-ignore
10445
+ this._drawTextString(TimeLineUtil.tranTime(new Date(rightLastScaleTime*1e3)),x,padding+(this.options.scaleOffsetTop+4+4)*this.options.dpr,"center");}else this._drawSolidLine(x,padding,x,padding+this.options.scaleOffsetTop*this.options.dpr,lineWidth);rightLastScaleTime+=this._timeWidthArray[0];}
10446
+ // 当前中心位置(当前时间 current)
10447
+ // prettier-ignore
10448
+ this._drawSolidLine(centerPosition.x,0,centerPosition.x,centerPosition.y,lineWidth,this.options.timePointColor);}
10449
+ /**
10937
10450
  * 绘制线
10938
10451
  * @param startX - 线起点 x 坐标
10939
10452
  * @param startY - 线起点 y 坐标
@@ -10942,409 +10455,211 @@
10942
10455
  * @param lineWidth - 线宽度
10943
10456
  * @param color - 线颜色
10944
10457
  *
10945
- */ // prettier-ignore
10946
- _drawSolidLine(startX, startY, endX, endY, lineWidth, color) {
10947
- if (this._ctx) {
10948
- this._ctx.save();
10949
- this._ctx.strokeStyle = color != null ? color : this._options.timeScaleColor;
10950
- this._ctx.lineWidth = lineWidth;
10951
- this._ctx.beginPath();
10952
- this._ctx.moveTo(startX, startY);
10953
- this._ctx.lineTo(endX, endY);
10954
- this._ctx.stroke();
10955
- this._ctx.restore();
10956
- }
10957
- }
10958
- /**
10458
+ */
10459
+ // prettier-ignore
10460
+ _drawSolidLine(startX,startY,endX,endY,lineWidth,color){if(this._ctx){this._ctx.save();this._ctx.strokeStyle=color!=null?color:this.options.timeScaleColor;this._ctx.lineWidth=lineWidth;this._ctx.beginPath();this._ctx.moveTo(startX,startY);this._ctx.lineTo(endX,endY);this._ctx.stroke();this._ctx.restore();}}
10461
+ /**
10959
10462
  * 绘制刻度文字
10960
10463
  * @param text - 文本
10961
10464
  * @param x - X
10962
10465
  * @param y - Y
10963
10466
  * @param align - 文本对齐方式
10964
- */ _drawTextString(text, x, y, align) {
10965
- if (this._ctx) {
10966
- const timeTexts = text.split(' ');
10967
- this._ctx.font = `${12 * this._options.dpr * 1}px serif`;
10968
- this._ctx.fillStyle = this._options.timeTextColor;
10969
- this._ctx.textAlign = align || 'left';
10970
- if (this._timeWidthArray[0] % 60 === 0) {
10971
- // 仅展示 hh:mm
10972
- timeTexts[1] = timeTexts[1].replace(/:00$/, '');
10973
- }
10974
- this._ctx.fillText(timeTexts[1], x, y + 8 * this._options.dpr);
10975
- // prettier-ignore
10976
- if (this._options.showYearMonthDay && (timeTexts[1] === "00:00:00" || timeTexts[1] === "00:00" || this._timeWidthArray[0] * this._timeWidthArray[2] === 24 * 3600)) {
10977
- // 展示年月日
10978
- this._ctx.textAlign = align || "left";
10979
- this._ctx.fillText(timeTexts[0], x, y + (8 + 10) * this._options.dpr);
10980
- }
10981
- }
10982
- }
10983
- /**
10467
+ */_drawTextString(text,x,y,align){if(this._ctx){const timeTexts=text.split(" ");this._ctx.font=`${12*this.options.dpr*1}px serif`;this._ctx.fillStyle=this.options.timeTextColor;this._ctx.textAlign=align||"left";if(this._timeWidthArray[0]%60===0)
10468
+ // 仅展示 hh:mm
10469
+ timeTexts[1]=timeTexts[1].replace(/:00$/,"");this._ctx.fillText(timeTexts[1],x,y+8*this.options.dpr);
10470
+ // prettier-ignore
10471
+ if(this.options.showYearMonthDay&&(timeTexts[1]==="00:00:00"||timeTexts[1]==="00:00"||this._timeWidthArray[0]*this._timeWidthArray[2]===24*3600)){
10472
+ // 展示年月日
10473
+ this._ctx.textAlign=align||"left";this._ctx.fillText(timeTexts[0],x,y+(8+10)*this.options.dpr);}}}
10474
+ /**
10984
10475
  * 画录像区间
10985
- */ _drawSections() {
10986
- // 绘制蓝色区域
10987
- const timeArr = this._timeSections || [];
10988
- // 根据时间查找当前位置
10989
- for(let i = 0; i < timeArr.length; i++){
10990
- const position = this._findPosition(timeArr[i]);
10991
- // 判断一下绘制区域是否在画布区域, 不在可以不用绘制
10992
- // prettier-ignore
10993
- if (this._ctx && isOverlap(0, this._width * this._options.dpr, position.x1, position.x2)) {
10994
- this._ctx.fillStyle = this._options.timeSectionColor;
10995
- // prettier-ignore
10996
- this._ctx.fillRect(position.x1, 0, position.x2 - position.x1, this._height * this._options.dpr);
10997
- }
10998
- }
10999
- }
11000
- /**
10476
+ */_drawSections(){
10477
+ // 绘制蓝色区域
10478
+ const timeArr=this.timeSections||[];
10479
+ // 根据时间查找当前位置
10480
+ for(let i=0;i<timeArr.length;i++){const position=this._findPosition(timeArr[i]);
10481
+ // 判断一下绘制区域是否在画布区域, 不在可以不用绘制
10482
+ // prettier-ignore
10483
+ if(this._ctx&&TimeLineUtil.isOverlap(0,this.width*this.options.dpr,position.x1,position.x2)){this._ctx.fillStyle=this.options.timeSectionColor;
10484
+ // prettier-ignore
10485
+ this._ctx.fillRect(position.x1,0,position.x2-position.x1,this.height*this.options.dpr);}}}
10486
+ /**
11001
10487
  * 获取时间片段在时间轴中的x1 ,x2坐标 (已做 dpr 处理)
11002
10488
  * @param item - 时间片段
11003
10489
  * @returns {void}
11004
- */ _findPosition(item) {
11005
- // 中间的当前时间 currentTime 为基准, 然后计算时间片段的 x 坐标和 y 坐标
11006
- // prettier-ignore
11007
- const x1 = (parseInt((item.startTime - this._currentTime.getTime()) / 1000 + '', 10) / this._timeWidthArray[0] // 多少个刻度
11008
- * this._curScaleSpacing // 乘刻度宽度
11009
- + this._width / 2) * this._options.dpr;
11010
- const x2 = x1 + parseInt((item.endTime - item.startTime) / 1000 + '', 10) / this._timeWidthArray[0] * this._curScaleSpacing * this._options.dpr;
11011
- return {
11012
- x1,
11013
- x2
11014
- };
11015
- }
11016
- /**
10490
+ */_findPosition(item){
10491
+ // 中间的当前时间 current 为基准, 然后计算时间片段的 x 坐标和 y 坐标
10492
+ // prettier-ignore
10493
+ const x1=(parseInt((item.startTime-this.current.getTime())/1e3+"",10)/this._timeWidthArray[0]*this._curScaleSpacing+this.width/2)*this.options.dpr;const x2=x1+parseInt((item.endTime-item.startTime)/1e3+"",10)/this._timeWidthArray[0]*this._curScaleSpacing*this.options.dpr;return {x1:x1,x2:x2}}
10494
+ /**
11017
10495
  * 合并相邻两个时间区间
11018
10496
  * @param timeSections - 时间区间数组
11019
10497
  *
11020
10498
  * @returns 合并后的时间区间
11021
- */ _mergeTimeSections(timeSections) {
11022
- if (timeSections.length === 0) return timeSections;
11023
- timeSections = timeSections.map((item)=>{
11024
- // 处理秒
11025
- if ((item.startTime + '').length === 10) {
11026
- item.startTime = item.startTime * 1000;
11027
- }
11028
- if ((item.endTime + '').length === 10) {
11029
- item.endTime = item.endTime * 1000;
11030
- }
11031
- return {
11032
- startTime: item.startTime,
11033
- endTime: item.endTime
11034
- };
11035
- });
11036
- const merged = [
11037
- timeSections[0]
11038
- ];
11039
- for(let i = 1; i < timeSections.length; i++){
11040
- const prev = merged[merged.length - 1];
11041
- const curr = timeSections[i];
11042
- // 如果当前区间与上一个区间重叠或相邻(即 prev.end >= curr.start)
11043
- if (prev.endTime >= curr.startTime) {
11044
- // 合并区间
11045
- prev.endTime = Math.max(prev.endTime, curr.endTime);
11046
- } else {
11047
- merged.push(curr);
11048
- }
11049
- }
11050
- return merged;
11051
- }
11052
- // -------------------------------------
11053
- // mouse event
11054
- // -------------------------------------
11055
- /**
10499
+ */_mergeTimeSections(timeSections){if(timeSections.length===0)return timeSections;timeSections=timeSections.map(item=>{
10500
+ // 处理秒
10501
+ if((item.startTime+"").length===10)item.startTime=item.startTime*1e3;if((item.endTime+"").length===10)item.endTime=item.endTime*1e3;return _extends$5({},item,{startTime:item.startTime,endTime:item.endTime})});const merged=[timeSections[0]];for(let i=1;i<timeSections.length;i++){const prev=merged[merged.length-1];const curr=timeSections[i];
10502
+ // 如果当前区间与上一个区间重叠或相邻(即 prev.end >= curr.start)
10503
+ if(prev.endTime>=curr.startTime)
10504
+ // 合并区间
10505
+ prev.endTime=Math.max(prev.endTime,curr.endTime);else merged.push(curr);}return merged}
10506
+ // -------------------------------------
10507
+ // mouse event
10508
+ // -------------------------------------
10509
+ /**
11056
10510
  * 添加事件监听
11057
10511
  * @returns
11058
- */ _addEventListener() {
11059
- if (this._$canvas) {
11060
- // 事件监听
11061
- this._$canvas.addEventListener('mousemove', this._mousemoveFun);
11062
- // prettier-ignore
11063
- this._$canvas.addEventListener("mouseover", this._mouseoverFun);
11064
- // prettier-ignore
11065
- this._$canvas.addEventListener("mouseleave", this._mouseleaveFun);
11066
- // prettier-ignore
11067
- this._$canvas.addEventListener("mousedown", this._mousedownFun);
11068
- // prettier-ignore
11069
- this._$canvas.addEventListener("mouseup", this._mouseUpFun);
11070
- this._$canvas.addEventListener('wheel', this._mousewheelFun);
11071
- // prettier-ignore
11072
- this.$container.addEventListener("wheel", (e)=>{
11073
- e.preventDefault();
11074
- }, {
11075
- passive: false
11076
- });
11077
- this._$canvas.addEventListener('keydown', this._ctrlKeyDownFun);
11078
- this._$canvas.addEventListener('keyup', this._ctrlKeyUpFun);
11079
- // ctrl 键事件
11080
- document.addEventListener('keydown', this._ctrlKeyDownFun, false);
11081
- document.addEventListener('keyup', this._ctrlKeyUpFun, false);
11082
- this._$canvas.addEventListener('touchstart', this._touchstartFun, {
11083
- passive: false
11084
- });
11085
- this._$canvas.addEventListener('touchmove', this._touchmoveFun, {
11086
- passive: false
11087
- });
11088
- this._$canvas.addEventListener('touchend', this._touchendFun, {
11089
- passive: false
11090
- });
11091
- }
11092
- }
11093
- /**
10512
+ */
10513
+ _addEventListener(){if(this._$canvas){
10514
+ // 事件监听
10515
+ this._$canvas.addEventListener("mousemove",this._mousemoveFun);
10516
+ // prettier-ignore
10517
+ this._$canvas.addEventListener("mouseover",this._mouseoverFun);
10518
+ // prettier-ignore
10519
+ this._$canvas.addEventListener("mouseleave",this._mouseleaveFun);
10520
+ // prettier-ignore
10521
+ this._$canvas.addEventListener("mousedown",this._mousedownFun);
10522
+ // prettier-ignore
10523
+ this._$canvas.addEventListener("mouseup",this._mouseUpFun);this._$canvas.addEventListener("wheel",this._mousewheelFun);
10524
+ // prettier-ignore
10525
+ this.$container.addEventListener("wheel",e=>{e.preventDefault();},{passive:false});this._$canvas.addEventListener("keydown",this._ctrlKeyDownFun);this._$canvas.addEventListener("keyup",this._ctrlKeyUpFun);
10526
+ // ctrl 键事件
10527
+ document.addEventListener("keydown",this._ctrlKeyDownFun,false);document.addEventListener("keyup",this._ctrlKeyUpFun,false);this._$canvas.addEventListener("touchstart",this._touchstartFun,{passive:false});this._$canvas.addEventListener("touchmove",this._touchmoveFun,{passive:false});this._$canvas.addEventListener("touchend",this._touchendFun,{passive:false});}}
10528
+ /**
11094
10529
  * 移除事件监听
11095
10530
  * @returns
11096
- */ _removeEventListener() {
11097
- if (this._$canvas) {
11098
- // 事件监听
11099
- this._$canvas.removeEventListener('mousemove', this._mousemoveFun);
11100
- // prettier-ignore
11101
- this._$canvas.removeEventListener("mouseover", this._mouseoverFun);
11102
- // prettier-ignore
11103
- this._$canvas.removeEventListener("mouseleave", this._mouseleaveFun);
11104
- // prettier-ignore
11105
- this._$canvas.removeEventListener("mousedown", this._mousedownFun);
11106
- // prettier-ignore
11107
- this._$canvas.removeEventListener("mouseup", this._mouseUpFun);
11108
- this._$canvas.removeEventListener('wheel', this._mousewheelFun);
11109
- this._$canvas.removeEventListener('keydown', this._ctrlKeyDownFun);
11110
- this._$canvas.removeEventListener('keyup', this._ctrlKeyUpFun);
11111
- // ctrl 键事件
11112
- document.removeEventListener('keydown', this._ctrlKeyDownFun);
11113
- document.removeEventListener('keyup', this._ctrlKeyUpFun);
11114
- // touch
11115
- this._$canvas.removeEventListener('touchstart', this._touchstartFun);
11116
- this._$canvas.removeEventListener('touchmove', this._touchmoveFun);
11117
- this._$canvas.removeEventListener('touchend', this._touchendFun);
11118
- }
11119
- }
11120
- /**
10531
+ */_removeEventListener(){if(this._$canvas){
10532
+ // 事件监听
10533
+ this._$canvas.removeEventListener("mousemove",this._mousemoveFun);
10534
+ // prettier-ignore
10535
+ this._$canvas.removeEventListener("mouseover",this._mouseoverFun);
10536
+ // prettier-ignore
10537
+ this._$canvas.removeEventListener("mouseleave",this._mouseleaveFun);
10538
+ // prettier-ignore
10539
+ this._$canvas.removeEventListener("mousedown",this._mousedownFun);
10540
+ // prettier-ignore
10541
+ this._$canvas.removeEventListener("mouseup",this._mouseUpFun);this._$canvas.removeEventListener("wheel",this._mousewheelFun);this._$canvas.removeEventListener("keydown",this._ctrlKeyDownFun);this._$canvas.removeEventListener("keyup",this._ctrlKeyUpFun);
10542
+ // ctrl 键事件
10543
+ document.removeEventListener("keydown",this._ctrlKeyDownFun);document.removeEventListener("keyup",this._ctrlKeyUpFun);
10544
+ // touch
10545
+ this._$canvas.removeEventListener("touchstart",this._touchstartFun);this._$canvas.removeEventListener("touchmove",this._touchmoveFun);this._$canvas.removeEventListener("touchend",this._touchendFun);}}
10546
+ /**
11121
10547
  * 鼠标按下事件监听
11122
10548
  * @param e - 鼠标事件
11123
10549
  * @returns
11124
- */ _mousedownFun(e) {
11125
- if (this._readOnly) return;
11126
- this._isMouseDown = true;
11127
- this._mousePosition = e.pageX;
11128
- this._oldTime = this._currentTime;
11129
- this._options.onDragStart == null ? void 0 : this._options.onDragStart.call(this._options, this._currentTime);
11130
- }
11131
- /**
10550
+ */_mousedownFun(e){if(this.readOnly)return;this._isMouseDown=true;this._mousePosition=e.pageX;this._oldTime=this.current;this.options.onDragStart==null?void 0:this.options.onDragStart.call(this.options,this.current);}
10551
+ /**
11132
10552
  * 鼠标移入事件监听
11133
10553
  * @returns
11134
- */ _mouseoverFun() {
11135
- if (this._readOnly) return;
11136
- this._isOver = true;
11137
- }
11138
- /**
10554
+ */_mouseoverFun(){if(this.readOnly)return;this._isOver=true;}
10555
+ /**
11139
10556
  * 鼠标离开事件监听
11140
10557
  * @returns
11141
- */ _mouseleaveFun(e) {
11142
- if (this._readOnly) return;
11143
- this._isOver = false;
11144
- this._moveEndOrTouchEndFun(e);
11145
- }
11146
- /**
10558
+ */_mouseleaveFun(e){if(this.readOnly)return;this._isOver=false;this._moveEndOrTouchEndFun(e);}
10559
+ /**
11147
10560
  * 鼠标抬起事件监听
11148
10561
  * @returns
11149
- */ _mouseUpFun(e) {
11150
- this._moveEndOrTouchEndFun(e);
11151
- }
11152
- /**
10562
+ */_mouseUpFun(e){this._moveEndOrTouchEndFun(e);}
10563
+ /**
11153
10564
  * 鼠标移动事件监听
11154
10565
  * @param e - 鼠标事件
11155
10566
  * @returns
11156
- */ _mousemoveFun(e) {
11157
- if (this._readOnly) return;
11158
- if (this._isMouseDown && this._isOver) {
11159
- // 鼠标按下位置和移动位置的偏移量
11160
- this._moveUpdateFun(e.pageX);
11161
- } else {
11162
- const left = parseInt(this.$container.offsetLeft + '', 10);
11163
- this._mousePosition = e.pageX - left;
11164
- this._update(); // 更新画面
11165
- }
11166
- new Date(// prettier-ignore
11167
- this._currentTime.getTime() + parseInt((e.pageX - this._width / 2) / this._curScaleSpacing * this._timeWidthArray[0] + "", 10) * 1000);
11168
- }
11169
- /**
10567
+ */_mousemoveFun(e){if(this.readOnly)return;if(this._isMouseDown&&this._isOver)
10568
+ // 鼠标按下位置和移动位置的偏移量
10569
+ this._moveUpdateFun(e.pageX);else {const left=parseInt(this.$container.offsetLeft+"",10);this._mousePosition=e.pageX-left;this._update();// 更新画面
10570
+ }
10571
+ // const time = new Date(
10572
+ // // prettier-ignore
10573
+ // this.current.getTime() + parseInt(((e.pageX - this.width / 2) / this._curScaleSpacing ) * this._timeWidthArray[0] + "", 10) * 1000,
10574
+ // );
10575
+ }
10576
+ /**
11170
10577
  * 鼠标滚轮滚动
11171
10578
  * @param e - 鼠标滚轮滚动事件
11172
10579
  * @returns
11173
- */ _mousewheelFun(e) {
11174
- e.preventDefault(); // 阻止默认滚动行为
11175
- // eslint-disable-next-line no-useless-return
11176
- if (this._readOnly) return;
11177
- // if (this._isCtrlKeyDown) {
11178
- // const zoom = e.deltaY > 0 ? -this._options.wheelSpeed : this._options.wheelSpeed;
11179
- // this._timeWidth = +(this._timeWidth + zoom).toFixed(2);
11180
- // if (this._timeWidth <= 0) {
11181
- // this._timeWidth = 0;
11182
- // } else if (this._timeWidth >= TIME_WIDTH.length) {
11183
- // this._timeWidth = TIME_WIDTH.length - 0.01;
11184
- // }
11185
- // this._update({
11186
- // timeWidth: Math.floor(this._timeWidth),
11187
- // });
11188
- // }
11189
- }
11190
- /**
10580
+ */_mousewheelFun(e){e.preventDefault();// 阻止默认滚动行为
10581
+ // eslint-disable-next-line no-useless-return
10582
+ if(this.readOnly)return;
10583
+ // if (this._isCtrlKeyDown) {
10584
+ // const zoom = e.deltaY > 0 ? -this.options.wheelSpeed : this.options.wheelSpeed;
10585
+ // this._timeWidth = +(this._timeWidth + zoom).toFixed(2);
10586
+ // if (this._timeWidth <= 0) {
10587
+ // this._timeWidth = 0;
10588
+ // } else if (this._timeWidth >= TIME_WIDTH.length) {
10589
+ // this._timeWidth = TIME_WIDTH.length - 0.01;
10590
+ // }
10591
+ // this._update({
10592
+ // timeWidth: Math.floor(this._timeWidth),
10593
+ // });
10594
+ // }
10595
+ }
10596
+ /**
11191
10597
  * ctrl键按下事件
11192
10598
  * @param e - 键盘按下事件
11193
- */ _ctrlKeyDownFun(e) {
11194
- if (e.ctrlKey || e.key === 'Control') {
11195
- this._isCtrlKeyDown = true;
11196
- }
11197
- }
11198
- /**
10599
+ */_ctrlKeyDownFun(e){if(e.ctrlKey||e.key==="Control"){console.log("Ctrl 键被按下");this._isCtrlKeyDown=true;}}
10600
+ /**
11199
10601
  * ctrl键抬起事件
11200
10602
  * @param e - 键盘按下事件
11201
- */ _ctrlKeyUpFun(e) {
11202
- if (e.ctrlKey || e.key === 'Control') {
11203
- this._isCtrlKeyDown = false;
11204
- }
11205
- }
11206
- // ----------------------------------------------------------------------
11207
- // touch
11208
- // ----------------------------------------------------------------------
11209
- /**
10603
+ */_ctrlKeyUpFun(e){if(e.ctrlKey||e.key==="Control"){console.log("Ctrl 键UP");this._isCtrlKeyDown=false;}}
10604
+ // ----------------------------------------------------------------------
10605
+ // touch
10606
+ // ----------------------------------------------------------------------
10607
+ /**
11210
10608
  * 触摸距离
11211
10609
  * @param touches - 两指触摸点
11212
10610
  * @returns
11213
- */ _getTouchDistance(touches) {
11214
- const [touch1, touch2] = touches;
11215
- const dx = touch2.clientX - touch1.clientX;
11216
- const dy = touch2.clientY - touch1.clientY;
11217
- return Math.sqrt(dx * dx + dy * dy);
11218
- }
11219
- /**
10611
+ */
10612
+ _getTouchDistance(touches){const[touch1,touch2]=touches;const dx=touch2.clientX-touch1.clientX;const dy=touch2.clientY-touch1.clientY;return Math.sqrt(dx*dx+dy*dy)}
10613
+ /**
11220
10614
  * 触摸开始
11221
10615
  * @param e - 触摸事件
11222
10616
  * @returns
11223
- */ _touchstartFun(e) {
11224
- if (this._readOnly) return;
11225
- this._oldTime = this._currentTime;
11226
- this._isOver = true;
11227
- if (e.touches.length === 1) {
11228
- // 单指
11229
- const touch = e.touches[0];
11230
- this._isMouseDown = true;
11231
- this._mousePosition = touch.clientX;
11232
- // this._touchmoveFun(e);
11233
- } else if (e.touches.length === 2) {
11234
- // 双指
11235
- this._lastTouchDist = this._getTouchDistance(e.touches);
11236
- }
11237
- }
11238
- /**
10617
+ */_touchstartFun(e){if(this.readOnly)return;this._oldTime=this.current;this._isOver=true;if(e.touches.length===1){
10618
+ // 单指
10619
+ const touch=e.touches[0];this._isMouseDown=true;this._mousePosition=touch.clientX;
10620
+ // this._touchmoveFun(e);
10621
+ }else if(e.touches.length===2){
10622
+ // 双指
10623
+ this._lastTouchDist=this._getTouchDistance(e.touches);console.warn("_touchstartFun",this._lastTouchDist);}}
10624
+ /**
11239
10625
  * 触摸移动
11240
10626
  * @param e - 触摸事件
11241
10627
  * @returns
11242
- */ _touchmoveFun(e) {
11243
- e.preventDefault(); // 防止页面缩放
11244
- e.stopPropagation();
11245
- if (this._readOnly) return;
11246
- if (e.touches.length === 1) {
11247
- // 单指
11248
- const touch = e.touches[0];
11249
- this._moveUpdateFun(touch.clientX);
11250
- } else if (e.touches.length === 2) {
11251
- // 双指
11252
- const newDist = this._getTouchDistance(e.touches);
11253
- newDist / this._lastTouchDist;
11254
- // scale *= zoom;
11255
- // // 限制缩放范围
11256
- // scale = Math.max(0.5, Math.min(3, scale));
11257
- // img.style.transform = `scale(${scale})`;
11258
- // lastDist = newDist;
11259
- }
11260
- }
11261
- /**
10628
+ */_touchmoveFun(e){e.preventDefault();// 防止页面缩放
10629
+ e.stopPropagation();if(this.readOnly)return;console.warn(e.touches.length);if(e.touches.length===1){
10630
+ // 单指
10631
+ const touch=e.touches[0];this._moveUpdateFun(touch.clientX);}else if(e.touches.length===2){
10632
+ // 双指
10633
+ const newDist=this._getTouchDistance(e.touches);const zoom=newDist/this._lastTouchDist;console.warn("_touchmoveFun",this._lastTouchDist,zoom);
10634
+ // scale *= zoom;
10635
+ // // 限制缩放范围
10636
+ // scale = Math.max(0.5, Math.min(3, scale));
10637
+ // img.style.transform = `scale(${scale})`;
10638
+ // lastDist = newDist;
10639
+ }}
10640
+ /**
11262
10641
  * 触摸结束
11263
10642
  * @param e - 触摸事件
11264
10643
  * @returns
11265
- */ _touchendFun(e) {
11266
- if (this._readOnly) return;
11267
- this._moveEndOrTouchEndFun(e);
11268
- }
11269
- /**
10644
+ */_touchendFun(e){if(this.readOnly)return;this._moveEndOrTouchEndFun(e);}
10645
+ /**
11270
10646
  * 拖动结束
11271
10647
  * @returns
11272
- */ _moveEndOrTouchEndFun(e) {
11273
- if (this._readOnly) return;
11274
- if (this._isMouseDown) {
11275
- this._isMouseDown = false;
11276
- if (this._moved) {
11277
- this._moved = false;
11278
- this._update({
11279
- currentTime: this._currentTime
11280
- });
11281
- this._oldTime = this._currentTime;
11282
- this._options.onDragEnd == null ? void 0 : this._options.onDragEnd.call(this._options, this._currentTime, this._isOver);
11283
- }
11284
- if (this._isOver && Math.abs(this._mousePosition - (e.pageX || e.clientX)) > 5) {
11285
- this._options.onChange == null ? void 0 : this._options.onChange.call(this._options, this._currentTime);
11286
- }
11287
- this._mousePosition = 0;
11288
- this._lastTouchDist = 0;
11289
- }
11290
- }
11291
- /**
10648
+ */_moveEndOrTouchEndFun(e){e.preventDefault();if(this.readOnly)return;if(this._isMouseDown){this._isMouseDown=false;if(this._moved){this._moved=false;this._update({current:this.current});this._oldTime=this.current;this.options.onDragEnd==null?void 0:this.options.onDragEnd.call(this.options,this.current,this._isOver);}if(this._isOver&&Math.abs(this._mousePosition-(e.pageX||0))>5)this.options.onChange==null?void 0:this.options.onChange.call(this.options,this.current);this._mousePosition=0;this._lastTouchDist=0;}}
10649
+ /**
11292
10650
  * 移动更新时间
11293
10651
  * @param x - 移动的x坐标
11294
10652
  * @returns
11295
- */ _moveUpdateFun(x) {
11296
- // 鼠标按下位置和移动位置的偏移量
11297
- const mouseOffset = this._mousePosition - x;
11298
- // fix点击引起mousemove的问题
11299
- if (mouseOffset === 0) return;
11300
- if (this._oldTime) {
11301
- // prettier-ignore
11302
- const currentTime = this._oldTime.getTime() + parseInt(mouseOffset / this._curScaleSpacing * this._timeWidthArray[0] + "", 10) * 1000;
11303
- this._update({
11304
- currentTime: new Date(currentTime)
11305
- });
11306
- this._options.onDragging == null ? void 0 : this._options.onDragging.call(this._options, new Date(currentTime));
11307
- }
11308
- this._moved = true;
11309
- }
11310
- constructor(container, options){
11311
- this._$canvas = null;
11312
- this._ctx = null;
11313
- this._width = 0;
11314
- this._height = 0;
11315
- this._currentTime = new Date(new Date().setHours(0, 0, 0, 0));
11316
- this._timeWidth = 0;
11317
- /** 时间刻度宽度 [刻度间隔秒数s, 刻度间隔宽度px, 长刻度间隔短刻度个数, 中文说明] */ this._timeWidthArray = TIME_WIDTH[0];
11318
- this._centerPositionX = 0;
11319
- this._timeSections = [];
11320
- /** 只读 */ this._readOnly = false;
11321
- // mouse
11322
- this._isMouseDown = false;
11323
- this._mousePosition = 0; // 鼠标在画布中X轴的位置
11324
- this._oldTime = null;
11325
- this._isOver = false;
11326
- this._moved = false;
11327
- this._isCtrlKeyDown = false;
11328
- this._destroyed = false;
11329
- this._lastTouchDist = 0;
11330
- this.$container = container;
11331
- // prettier-ignore
11332
- this._options = Object.assign({}, TIMELINE_DEFAULT_OPTIONS, options);
11333
- this._mousemoveFun = this._mousemoveFun.bind(this);
11334
- this._mouseoverFun = this._mouseoverFun.bind(this);
11335
- this._mouseleaveFun = this._mouseleaveFun.bind(this);
11336
- this._mousedownFun = this._mousedownFun.bind(this);
11337
- this._mouseUpFun = this._mouseUpFun.bind(this);
11338
- this._mousewheelFun = this._mousewheelFun.bind(this);
11339
- this._touchstartFun = this._touchstartFun.bind(this);
11340
- this._touchmoveFun = this._touchmoveFun.bind(this);
11341
- this._touchendFun = this._touchendFun.bind(this);
11342
- this._ctrlKeyDownFun = this._ctrlKeyDownFun.bind(this);
11343
- this._ctrlKeyUpFun = this._ctrlKeyUpFun.bind(this);
11344
- this._init();
11345
- }
11346
- };
11347
- TimeLine$2.TIME_WIDTH = TIME_WIDTH;
10653
+ */_moveUpdateFun(x){
10654
+ // 鼠标按下位置和移动位置的偏移量
10655
+ const mouseOffset=this._mousePosition-x;
10656
+ // fix点击引起mousemove的问题
10657
+ if(mouseOffset===0)return;if(this._oldTime){
10658
+ // prettier-ignore
10659
+ const currentTime=this._oldTime.getTime()+parseInt(mouseOffset/this._curScaleSpacing*this._timeWidthArray[0]+"",10)*1e3;this._update({current:new Date(currentTime)});this.options.onDragging==null?void 0:this.options.onDragging.call(this.options,new Date(currentTime));}this._moved=true;}constructor(container,options){super(container,deepmerge(TIMELINE_DEFAULT_OPTIONS,options,{clone:true})),this._$canvas=null,this._ctx=null,/** 时间刻度宽度 [刻度间隔秒数s, 刻度间隔宽度px, 长刻度间隔短刻度个数, 中文说明] */this._timeWidthArray=TIME_WIDTH[0],this._centerPositionX=0,// mouse
10660
+ this._isMouseDown=false,this._mousePosition=0,this._oldTime=null,this._isOver=false,this._moved=false,this._isCtrlKeyDown=false,this._lastTouchDist=0;this.$container=container;
10661
+ // prettier-ignore
10662
+ console.log("TimeLine dpr",JSON.stringify(this.options));this._mousemoveFun=this._mousemoveFun.bind(this);this._mouseoverFun=this._mouseoverFun.bind(this);this._mouseleaveFun=this._mouseleaveFun.bind(this);this._mousedownFun=this._mousedownFun.bind(this);this._mouseUpFun=this._mouseUpFun.bind(this);this._mousewheelFun=this._mousewheelFun.bind(this);this._touchstartFun=this._touchstartFun.bind(this);this._touchmoveFun=this._touchmoveFun.bind(this);this._touchendFun=this._touchendFun.bind(this);this._ctrlKeyDownFun=this._ctrlKeyDownFun.bind(this);this._ctrlKeyUpFun=this._ctrlKeyUpFun.bind(this);this._init();}}TimeLine.TIME_WIDTH=TIME_WIDTH;
11348
10663
 
11349
10664
  function _extends$4() {
11350
10665
  _extends$4 = Object.assign || function(target) {
@@ -11382,24 +10697,24 @@
11382
10697
  }
11383
10698
  /**
11384
10699
  * 回放时间轴控件
11385
- */ var TimeLine = /*#__PURE__*/ function(Control) {
11386
- _inherits$5(TimeLine, Control);
11387
- function TimeLine(options) {
10700
+ */ var TimeLineControl = /*#__PURE__*/ function(Control) {
10701
+ _inherits$5(TimeLineControl, Control);
10702
+ function TimeLineControl(options) {
11388
10703
  var _this;
11389
10704
  var _this__options_props, _this__options;
11390
10705
  _this = Control.call(this, _extends$4({}, options, {
11391
10706
  tagName: 'div',
11392
10707
  controlType: 'block',
11393
10708
  classNameSuffix: 'time-line'
11394
- })) || this, _this.records = [];
10709
+ })) || this, _this._$add = null, _this._$reduce = null, _this.records = [];
11395
10710
  _this._options = options;
11396
10711
  _this.records = ((_this__options = _this._options) == null ? void 0 : (_this__options_props = _this__options.props) == null ? void 0 : _this__options_props.recordList) || [];
11397
10712
  _this._render();
11398
10713
  _this.on(EVENTS.setAllDayRecTimes, function(records) {
11399
10714
  var // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
11400
- _this_timeLineUtil_updateRecords, _this_timeLineUtil;
10715
+ _this_timeLineUtil_updateTimeSections, _this_timeLineUtil;
11401
10716
  _this.records = records;
11402
- (_this_timeLineUtil = _this.timeLineUtil) == null ? void 0 : (_this_timeLineUtil_updateRecords = _this_timeLineUtil.updateRecords) == null ? void 0 : _this_timeLineUtil_updateRecords.call(_this_timeLineUtil, records);
10717
+ (_this_timeLineUtil = _this.timeLineUtil) == null ? void 0 : (_this_timeLineUtil_updateTimeSections = _this_timeLineUtil.updateTimeSections) == null ? void 0 : _this_timeLineUtil_updateTimeSections.call(_this_timeLineUtil, records);
11403
10718
  });
11404
10719
  _this.on(EVENTS.getOSDTime, function(time) {
11405
10720
  var // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
@@ -11408,60 +10723,72 @@
11408
10723
  });
11409
10724
  return _this;
11410
10725
  }
11411
- var _proto = TimeLine.prototype;
10726
+ var _proto = TimeLineControl.prototype;
11412
10727
  _proto._render = function _render() {
11413
10728
  var _this = this;
11414
- var _this_timeLineUtil_updateRecords, _this_timeLineUtil;
10729
+ var _this_timeLineUtil_updateTimeSections, _this_timeLineUtil;
11415
10730
  var _timeLineOptions = {
11416
10731
  // locale: this._options.locale,
11417
10732
  onChange: function(date) {
11418
10733
  _this._options.onChange == null ? void 0 : _this._options.onChange.call(_this._options, date);
11419
10734
  _this.emit(EVENTS.control.timeLineChange, date);
10735
+ },
10736
+ // 2025-10-27 仅移动端支持
10737
+ onPickerSelect: function(item) {
10738
+ var date = null;
10739
+ try {
10740
+ if ((item.startTime + '').length === 10) date = new Date(item.startTime * 1000);
10741
+ else if ((item.startTime + '').length === 13) date = new Date(item.startTime);
10742
+ else date = new Date(item.startTime);
10743
+ _this._options.onChange == null ? void 0 : _this._options.onChange.call(_this._options, date);
10744
+ _this.emit(EVENTS.control.timeLineChange, date);
10745
+ } catch (error) {
10746
+ }
11420
10747
  }
11421
10748
  };
11422
10749
  if (isMobile$1()) {
11423
- this.timeLineUtil = new TimeLine$1(this.$container, _timeLineOptions);
10750
+ this.timeLineUtil = new MobileTimeLine(this.$container, _timeLineOptions);
11424
10751
  } else {
11425
- this.timeLineUtil = new TimeLine$2(this.$container, _timeLineOptions);
10752
+ this.timeLineUtil = new TimeLine(this.$container, _timeLineOptions);
11426
10753
  this._renderAddReduce();
11427
10754
  }
11428
- (_this_timeLineUtil = this.timeLineUtil) == null ? void 0 : (_this_timeLineUtil_updateRecords = _this_timeLineUtil.updateRecords) == null ? void 0 : _this_timeLineUtil_updateRecords.call(_this_timeLineUtil, this.records);
10755
+ (_this_timeLineUtil = this.timeLineUtil) == null ? void 0 : (_this_timeLineUtil_updateTimeSections = _this_timeLineUtil.updateTimeSections) == null ? void 0 : _this_timeLineUtil_updateTimeSections.call(_this_timeLineUtil, this.records);
11429
10756
  this.timeLineUtil.update(new Date());
11430
10757
  };
11431
10758
  _proto.setWidth = function setWidth(width) {
11432
- if (!isMobile$1()) this.timeLineUtil.width = width;
10759
+ if (!isMobile$1()) this.timeLineUtil.resize(width);
11433
10760
  };
11434
10761
  _proto._renderAddReduce = function _renderAddReduce() {
11435
10762
  var _this = this;
11436
- this.$add = document.createElement('span');
11437
- this.$add.classList.add("" + PREFIX_CLASS + "-time-line-scale-add");
11438
- this.$add.innerHTML = IconComponents.add();
11439
- this.$add.addEventListener('click', function() {
10763
+ this._$add = document.createElement('span');
10764
+ this._$add.classList.add("" + PREFIX_CLASS + "-time-line-scale-add");
10765
+ this._$add.innerHTML = IconComponents.add();
10766
+ this._$add.addEventListener('click', function() {
11440
10767
  if (_this.timeLineUtil) {
11441
- var currentScale = Math.floor(_this.timeLineUtil.scale);
11442
- _this.timeLineUtil.changeScale(currentScale + 1);
10768
+ var currentScale = Math.floor(_this.timeLineUtil.timeWidth);
10769
+ _this.timeLineUtil.setTimeWidth(currentScale + 1);
11443
10770
  }
11444
10771
  });
11445
- this.$reduce = document.createElement('span');
11446
- this.$reduce.classList.add("" + PREFIX_CLASS + "-time-line-scale-sub");
11447
- this.$reduce.innerHTML = IconComponents.reduce();
11448
- this.$reduce.addEventListener('click', function() {
10772
+ this._$reduce = document.createElement('span');
10773
+ this._$reduce.classList.add("" + PREFIX_CLASS + "-time-line-scale-sub");
10774
+ this._$reduce.innerHTML = IconComponents.reduce();
10775
+ this._$reduce.addEventListener('click', function() {
11449
10776
  if (_this.timeLineUtil) {
11450
- var currentScale = Math.floor(_this.timeLineUtil.scale);
11451
- _this.timeLineUtil.changeScale(currentScale - 1);
10777
+ var currentScale = Math.floor(_this.timeLineUtil.timeWidth);
10778
+ _this.timeLineUtil.setTimeWidth(currentScale - 1);
11452
10779
  }
11453
10780
  });
11454
- this.$container.appendChild(this.$add);
11455
- this.$container.appendChild(this.$reduce);
10781
+ this.$container.appendChild(this._$add);
10782
+ this.$container.appendChild(this._$reduce);
11456
10783
  };
11457
10784
  _proto.destroy = function destroy() {
11458
- if (this.$add) {
11459
- this.$add.remove();
11460
- this.$add = null;
10785
+ if (this._$add) {
10786
+ this._$add.remove();
10787
+ this._$add = null;
11461
10788
  }
11462
- if (this.$reduce) {
11463
- this.$reduce.remove();
11464
- this.$reduce = null;
10789
+ if (this._$reduce) {
10790
+ this._$reduce.remove();
10791
+ this._$reduce = null;
11465
10792
  }
11466
10793
  if (this.timeLineUtil) {
11467
10794
  this.timeLineUtil.destroy();
@@ -11475,7 +10802,7 @@
11475
10802
  */ _proto._onControlClick = function _onControlClick(e) {
11476
10803
  this._options.onClick == null ? void 0 : this._options.onClick.call(this._options, e);
11477
10804
  };
11478
- return TimeLine;
10805
+ return TimeLineControl;
11479
10806
  }(Control);
11480
10807
 
11481
10808
  function _extends$3() {
@@ -11565,7 +10892,7 @@
11565
10892
  rec: Rec,
11566
10893
  speed: Speed,
11567
10894
  date: DatePicker,
11568
- timeLine: TimeLine
10895
+ timeLine: TimeLineControl
11569
10896
  };
11570
10897
 
11571
10898
  /* eslint-disable @typescript-eslint/no-non-null-assertion */ function _inherits$3(subClass, superClass) {
@@ -12921,7 +12248,7 @@
12921
12248
  // ==============================================================================================
12922
12249
  /** 初始化配置项 */ _proto._initOptions = function _initOptions(options) {
12923
12250
  if (options === void 0) options = {};
12924
- var _this_options_loggerOptions, _this_options_definitionOptions_list, _this_options_definitionOptions, _this_options_videoLevelList;
12251
+ var _this_options_loggerOptions;
12925
12252
  this.options = deepmerge(THEME_DEFAULT_OPTIONS, options, {
12926
12253
  clone: false
12927
12254
  });
@@ -12935,7 +12262,7 @@
12935
12262
  }
12936
12263
  if (!this.$container) throw new Error('container option is required!');
12937
12264
  if ([
12938
- 'VIDEO',
12265
+ 'VIDOE',
12939
12266
  'CANVAS'
12940
12267
  ].includes(this.$container.tagName)) {
12941
12268
  throw new Error('container node cannot be video or canvas!');
@@ -12946,15 +12273,11 @@
12946
12273
  }));
12947
12274
  this.logger.log(navigator.userAgent || 'unknown');
12948
12275
  this.logger.log('[Theme Version] ', Theme.THEME_VERSION);
12949
- if ('container' in this.options) {
12950
- // JSON 不能序列化dom节点, 不要使用 this.options.container, 请使用 this.container
12951
- delete this.options.container;
12952
- }
12953
12276
  this.logger.log(JSON.stringify(this.options));
12954
12277
  var language = this.options.language || 'zh';
12955
12278
  var locales = deepmerge({
12956
- zh: zh,
12957
- en: en
12279
+ zh: zh$1,
12280
+ en: en$1
12958
12281
  }, this.options.locales || {}, {
12959
12282
  clone: false
12960
12283
  });
@@ -12962,11 +12285,6 @@
12962
12285
  this.i18n = new I18n(locales, {
12963
12286
  defaultLocale: language
12964
12287
  });
12965
- // 默认清晰度列表
12966
- if (((_this_options_definitionOptions = this.options.definitionOptions) == null ? void 0 : (_this_options_definitionOptions_list = _this_options_definitionOptions.list) == null ? void 0 : _this_options_definitionOptions_list.length) > 0 || ((_this_options_videoLevelList = this.options.videoLevelList) == null ? void 0 : _this_options_videoLevelList.length) > 0) {
12967
- var _this_options_definitionOptions1;
12968
- this.videoLevelList = ((_this_options_definitionOptions1 = this.options.definitionOptions) == null ? void 0 : _this_options_definitionOptions1.list) || this.options.videoLevelList;
12969
- }
12970
12288
  };
12971
12289
  /**
12972
12290
  * 初始化设置类名和设置宽高
@@ -13858,10 +13176,10 @@
13858
13176
  /** 所有私有流的模板 @since 0.0.1 */ Theme.TEMPLATES = TEMPLATES;
13859
13177
  /** 事件名称 @since 0.0.1 */ Theme.EVENTS = EVENTS;
13860
13178
  /** 语言包 @since 0.0.1 */ Theme.LOCALES = {
13861
- zh: zh,
13862
- en: en
13179
+ zh: zh$1,
13180
+ en: en$1
13863
13181
  };
13864
- /** 版本号 @since 0.0.1 */ Theme.THEME_VERSION = '0.0.1-beta.1';
13182
+ /** 版本号 @since 0.0.1 */ Theme.THEME_VERSION = '1.0.0-beta.1';
13865
13183
 
13866
13184
  // 不要动这里的代码, 这个出口是为了编译成 umd 规范的文件
13867
13185