chbim-time-axis-v2 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
- **🔍 灵活的缩放控制**:
|
|
26
26
|
- **自定义最小缩放级别**: 支持通过 `minZoomLevel` 属性设置最小缩放层级(分钟、小时、天)。
|
|
27
27
|
|
|
28
|
+
## ⚠️ 注意事项
|
|
29
|
+
|
|
30
|
+
- **初始化数据**: 建议在获取到完整的 `tasks`、`projectStartTime` 和 `projectEndTime` 数据后再渲染组件(使用 `v-if`)。如果在组件挂载后再异步填充数据,可能会导致 `handleTaskEnter` 等事件在初始化阶段被重复触发。
|
|
31
|
+
|
|
28
32
|
## 📦 安装
|
|
29
33
|
|
|
30
34
|
```bash
|
|
@@ -322,6 +326,7 @@ roamController.start();
|
|
|
322
326
|
| `toggleMaximize` | - | 切换最大化模式 |
|
|
323
327
|
| `toggleMinimize` | - | 切换最小化模式 |
|
|
324
328
|
| `getSnapshot` | - | 获取当前时间点的快照(包含当前时间、活跃任务、块、瞬时点和分组) |
|
|
329
|
+
| `handleResetView`| - | 自动调整视图范围以适应任务列表。如果没有任务,则尝试适应项目起止时间;如果也没有,则以当前时间为中心。 |
|
|
325
330
|
|
|
326
331
|
### Slots (插槽)
|
|
327
332
|
|
|
@@ -13371,9 +13371,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
13371
13371
|
};
|
|
13372
13372
|
return filterCollapsed(tasksWithComputedData.value);
|
|
13373
13373
|
});
|
|
13374
|
-
const
|
|
13375
|
-
if (tasks.length === 0)
|
|
13376
|
-
return { minTime: 0, maxTime: 0 };
|
|
13374
|
+
const calculateTasksRange = (tasks) => {
|
|
13377
13375
|
let minTime = Number.MAX_SAFE_INTEGER;
|
|
13378
13376
|
let maxTime = Number.MIN_SAFE_INTEGER;
|
|
13379
13377
|
const checkTask = (t) => {
|
|
@@ -13408,6 +13406,37 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
13408
13406
|
t.children.forEach(checkTask);
|
|
13409
13407
|
};
|
|
13410
13408
|
tasks.forEach(checkTask);
|
|
13409
|
+
return { minTime, maxTime };
|
|
13410
|
+
};
|
|
13411
|
+
const autoFitView = () => {
|
|
13412
|
+
let minTime = Number.MAX_SAFE_INTEGER;
|
|
13413
|
+
let maxTime = Number.MIN_SAFE_INTEGER;
|
|
13414
|
+
let source = "";
|
|
13415
|
+
if (processedTasks.value.length > 0) {
|
|
13416
|
+
const range = calculateTasksRange(processedTasks.value);
|
|
13417
|
+
if (range.minTime <= range.maxTime && range.minTime !== Number.MAX_SAFE_INTEGER) {
|
|
13418
|
+
minTime = range.minTime;
|
|
13419
|
+
maxTime = range.maxTime;
|
|
13420
|
+
source = "tasks";
|
|
13421
|
+
}
|
|
13422
|
+
}
|
|
13423
|
+
if (source === "" && props.projectStartTime && props.projectEndTime) {
|
|
13424
|
+
const pStart = dayjs(props.projectStartTime).valueOf();
|
|
13425
|
+
const pEnd = dayjs(props.projectEndTime).valueOf();
|
|
13426
|
+
if (!isNaN(pStart) && !isNaN(pEnd) && pStart <= pEnd) {
|
|
13427
|
+
minTime = pStart;
|
|
13428
|
+
maxTime = pEnd;
|
|
13429
|
+
source = "project";
|
|
13430
|
+
}
|
|
13431
|
+
}
|
|
13432
|
+
if (source === "") {
|
|
13433
|
+
const now = dayjs(currentTime.value).valueOf();
|
|
13434
|
+
if (!isNaN(now)) {
|
|
13435
|
+
minTime = dayjs(now).subtract(15, "day").valueOf();
|
|
13436
|
+
maxTime = dayjs(now).add(15, "day").valueOf();
|
|
13437
|
+
source = "clock";
|
|
13438
|
+
}
|
|
13439
|
+
}
|
|
13411
13440
|
if (minTime <= maxTime && minTime !== Number.MAX_SAFE_INTEGER) {
|
|
13412
13441
|
let duration = maxTime - minTime;
|
|
13413
13442
|
if (duration === 0) {
|
|
@@ -13423,24 +13452,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
13423
13452
|
timelineRef.value.setScrollLeft(0);
|
|
13424
13453
|
}
|
|
13425
13454
|
}, 100);
|
|
13455
|
+
return { minTime, maxTime };
|
|
13426
13456
|
}
|
|
13427
|
-
return { minTime, maxTime };
|
|
13457
|
+
return { minTime: 0, maxTime: 0 };
|
|
13428
13458
|
};
|
|
13429
|
-
const initialized = ref(false);
|
|
13430
|
-
watch(
|
|
13431
|
-
() => processedTasks.value,
|
|
13432
|
-
(newTasks) => {
|
|
13433
|
-
if (newTasks.length > 0 && !initialized.value) {
|
|
13434
|
-
fitToTasks(newTasks);
|
|
13435
|
-
initialized.value = true;
|
|
13436
|
-
}
|
|
13437
|
-
},
|
|
13438
|
-
{ deep: true, immediate: true }
|
|
13439
|
-
);
|
|
13440
13459
|
onMounted(() => {
|
|
13441
|
-
if (props.tasks.length
|
|
13442
|
-
|
|
13443
|
-
|
|
13460
|
+
if (props.tasks.length === 0) {
|
|
13461
|
+
console.warn(
|
|
13462
|
+
"%c[CesiumGantt] 性能提示:\n建议在渲染组件前已获取所有必要资源(如 tasks, projectStartTime, projectEndTime)。\n推荐做法: 使用 v-if 控制组件渲染,直到数据准备就绪。\n风险: 数据逐步加载可能导致 handleTaskEnter 等事件在初始化阶段被重复或意外触发。",
|
|
13463
|
+
"color: #e6a23c; font-weight: bold;"
|
|
13464
|
+
);
|
|
13444
13465
|
}
|
|
13445
13466
|
window.addEventListener("click", closeContextMenu);
|
|
13446
13467
|
window.addEventListener("click", closeBuiltinMenu);
|
|
@@ -13518,7 +13539,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
13518
13539
|
}
|
|
13519
13540
|
};
|
|
13520
13541
|
const handleResetView = () => {
|
|
13521
|
-
const { minTime, maxTime } =
|
|
13542
|
+
const { minTime, maxTime } = autoFitView();
|
|
13522
13543
|
if (minTime !== Number.MAX_SAFE_INTEGER && minTime !== 0 && minTime <= maxTime) {
|
|
13523
13544
|
if (timelineRef.value) {
|
|
13524
13545
|
const { clientWidth } = timelineRef.value.getScrollState();
|
|
@@ -13786,7 +13807,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
13786
13807
|
__expose({
|
|
13787
13808
|
toggleMaximize,
|
|
13788
13809
|
toggleMinimize,
|
|
13789
|
-
getSnapshot
|
|
13810
|
+
getSnapshot,
|
|
13811
|
+
handleResetView
|
|
13790
13812
|
});
|
|
13791
13813
|
return (_ctx, _cache) => {
|
|
13792
13814
|
return openBlock(), createElementBlock("div", {
|
|
@@ -14004,8 +14026,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
14004
14026
|
};
|
|
14005
14027
|
}
|
|
14006
14028
|
});
|
|
14007
|
-
const
|
|
14008
|
-
const CesiumGantt = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
14029
|
+
const CesiumGantt_vue_vue_type_style_index_0_scoped_ca04f53e_lang = "";
|
|
14030
|
+
const CesiumGantt = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-ca04f53e"]]);
|
|
14009
14031
|
class ViewportRoam {
|
|
14010
14032
|
constructor(viewer, data, intervals) {
|
|
14011
14033
|
__publicField(this, "viewer");
|