@leeguoo/pwtk-network-debugger 1.2.26 β†’ 1.2.28

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.esm.js CHANGED
@@ -7506,6 +7506,12 @@ const styles = `
7506
7506
  color: #000;
7507
7507
  }
7508
7508
 
7509
+ .debugger-icon {
7510
+ width: 16px;
7511
+ height: 16px;
7512
+ vertical-align: middle;
7513
+ }
7514
+
7509
7515
  .debugger-content {
7510
7516
  height: calc(100% - 40px);
7511
7517
  overflow: hidden;
@@ -7957,6 +7963,24 @@ const styles = `
7957
7963
  height: 12px;
7958
7964
  cursor: sw-resize;
7959
7965
  }
7966
+
7967
+ .debugger-reopen-btn {
7968
+ position: fixed;
7969
+ z-index: 999999;
7970
+ background: #4CAF50;
7971
+ color: #000;
7972
+ border: none;
7973
+ padding: 8px 10px;
7974
+ border-radius: 16px;
7975
+ font-weight: bold;
7976
+ font-size: 12px;
7977
+ box-shadow: 0 4px 12px rgba(0,0,0,0.25);
7978
+ cursor: pointer;
7979
+ }
7980
+
7981
+ .debugger-reopen-btn:hover {
7982
+ filter: brightness(0.95);
7983
+ }
7960
7984
  `;
7961
7985
  async function createShareLink(requestData) {
7962
7986
  try {
@@ -8069,6 +8093,7 @@ const _DebugPanel = class _DebugPanel {
8069
8093
  this.isDragging = false;
8070
8094
  this.isResizing = false;
8071
8095
  this.dragStart = { x: 0, y: 0 };
8096
+ this.resizeTimeout = null;
8072
8097
  this.currentTab = "network";
8073
8098
  this.consoleHistory = [];
8074
8099
  this.requestsCache = [];
@@ -8104,11 +8129,11 @@ const _DebugPanel = class _DebugPanel {
8104
8129
  <div class="debugger-header">
8105
8130
  <div class="debugger-title">πŸ”“ ${this.config.minimized ? "PWTK" : "PWTK 解密小ε·₯ε…·"} <span style="font-size: 10px; opacity: 0.7;">by Leo</span></div>
8106
8131
  <div class="debugger-controls">
8107
- ${!this.config.minimized ? '<button class="debugger-btn" data-action="clear" title="ζΈ…η©Ί">πŸ—‘οΈ</button>' : ""}
8108
- ${!this.config.minimized ? '<button class="debugger-btn" data-action="export" title="ε―Όε‡Ί">πŸ’Ύ</button>' : ""}
8109
- <button class="debugger-btn" data-action="minimize" title="${this.config.minimized ? "展开" : "ζœ€ε°εŒ–"}">${this.config.minimized ? "πŸ“–" : "πŸ“•"}</button>
8110
- ${!this.config.minimized ? '<button class="debugger-btn" data-action="fullscreen" title="全屏">β›Ά</button>' : ""}
8111
- <button class="debugger-btn" data-action="close" title="ε…³ι—­">βœ•</button>
8132
+ ${!this.config.minimized ? '<button class="debugger-btn" data-action="clear" title="ζΈ…η©Ί"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg></button>' : ""}
8133
+ ${!this.config.minimized ? '<button class="debugger-btn" data-action="export" title="ε―Όε‡Ί"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/></svg></button>' : ""}
8134
+ <button class="debugger-btn" data-action="minimize" title="${this.config.minimized ? "展开" : "ζœ€ε°εŒ–"}"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="${this.config.minimized ? "M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z" : "M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"}"/></svg></button>
8135
+ ${!this.config.minimized ? '<button class="debugger-btn" data-action="fullscreen" title="全屏"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/></svg></button>' : ""}
8136
+ <button class="debugger-btn" data-action="close" title="ε…³ι—­"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg></button>
8112
8137
  </div>
8113
8138
  </div>
8114
8139
  <div class="debugger-content">
@@ -8186,8 +8211,14 @@ const _DebugPanel = class _DebugPanel {
8186
8211
  this.startDrag(e);
8187
8212
  });
8188
8213
  controls.addEventListener("click", (e) => {
8189
- const target = e.target;
8190
- const action = target.dataset.action;
8214
+ e.stopPropagation();
8215
+ let target = e.target;
8216
+ while (target && target !== controls) {
8217
+ if (target.dataset?.action) break;
8218
+ target = target.parentElement;
8219
+ }
8220
+ const action = target?.dataset?.action;
8221
+ if (!action) return;
8191
8222
  switch (action) {
8192
8223
  case "clear":
8193
8224
  this.clearRequests();
@@ -8237,6 +8268,7 @@ const _DebugPanel = class _DebugPanel {
8237
8268
  });
8238
8269
  document.addEventListener("mousemove", this.handleMouseMove.bind(this));
8239
8270
  document.addEventListener("mouseup", this.handleMouseUp.bind(this));
8271
+ window.addEventListener("resize", this.handleWindowResize.bind(this));
8240
8272
  }
8241
8273
  startListening() {
8242
8274
  this.interceptor.addListener((request) => {
@@ -8489,17 +8521,23 @@ Created by Leo (@leeguoo)`);
8489
8521
  header.innerHTML = `
8490
8522
  <div class="debugger-title">πŸ”“ ${this.config.minimized ? "PWTK" : "PWTK 解密小ε·₯ε…·"} <span style="font-size: 10px; opacity: 0.7;">by Leo</span></div>
8491
8523
  <div class="debugger-controls">
8492
- ${!this.config.minimized ? '<button class="debugger-btn" data-action="clear" title="ζΈ…η©Ί">πŸ—‘οΈ</button>' : ""}
8493
- ${!this.config.minimized ? '<button class="debugger-btn" data-action="export" title="ε―Όε‡Ί">πŸ’Ύ</button>' : ""}
8494
- <button class="debugger-btn" data-action="minimize" title="${this.config.minimized ? "展开" : "ζœ€ε°εŒ–"}">${this.config.minimized ? "πŸ“–" : "πŸ“•"}</button>
8495
- ${!this.config.minimized ? '<button class="debugger-btn" data-action="fullscreen" title="全屏">β›Ά</button>' : ""}
8496
- <button class="debugger-btn" data-action="close" title="ε…³ι—­">βœ•</button>
8524
+ ${!this.config.minimized ? '<button class="debugger-btn" data-action="clear" title="ζΈ…η©Ί"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg></button>' : ""}
8525
+ ${!this.config.minimized ? '<button class="debugger-btn" data-action="export" title="ε―Όε‡Ί"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/></svg></button>' : ""}
8526
+ <button class="debugger-btn" data-action="minimize" title="${this.config.minimized ? "展开" : "ζœ€ε°εŒ–"}"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="${this.config.minimized ? "M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z" : "M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"}"/></svg></button>
8527
+ ${!this.config.minimized ? '<button class="debugger-btn" data-action="fullscreen" title="全屏"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/></svg></button>' : ""}
8528
+ <button class="debugger-btn" data-action="close" title="ε…³ι—­"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg></button>
8497
8529
  </div>
8498
8530
  `;
8499
8531
  const controls = header.querySelector(".debugger-controls");
8500
8532
  controls.addEventListener("click", (e) => {
8501
- const target = e.target;
8502
- const action = target.dataset.action;
8533
+ e.stopPropagation();
8534
+ let target = e.target;
8535
+ while (target && target !== controls) {
8536
+ if (target.dataset?.action) break;
8537
+ target = target.parentElement;
8538
+ }
8539
+ const action = target?.dataset?.action;
8540
+ if (!action) return;
8503
8541
  switch (action) {
8504
8542
  case "clear":
8505
8543
  this.clearRequests();
@@ -8701,16 +8739,147 @@ Created by Leo (@leeguoo)`);
8701
8739
  this.isResizing = false;
8702
8740
  delete this.container.dataset.resizeDirection;
8703
8741
  }
8742
+ handleWindowResize() {
8743
+ if (this.resizeTimeout) {
8744
+ clearTimeout(this.resizeTimeout);
8745
+ }
8746
+ this.resizeTimeout = window.setTimeout(() => {
8747
+ this.adjustPositionForWindowResize();
8748
+ }, 100);
8749
+ }
8750
+ adjustPositionForWindowResize() {
8751
+ const rect = this.container.getBoundingClientRect();
8752
+ const windowWidth = window.innerWidth;
8753
+ const windowHeight = window.innerHeight;
8754
+ let needsAdjustment = false;
8755
+ let newLeft = rect.left;
8756
+ let newTop = rect.top;
8757
+ let newWidth = rect.width;
8758
+ let newHeight = rect.height;
8759
+ if (rect.right > windowWidth) {
8760
+ newLeft = windowWidth - rect.width;
8761
+ needsAdjustment = true;
8762
+ }
8763
+ if (rect.bottom > windowHeight) {
8764
+ newTop = windowHeight - rect.height;
8765
+ needsAdjustment = true;
8766
+ }
8767
+ if (newLeft < 0) {
8768
+ newLeft = 0;
8769
+ needsAdjustment = true;
8770
+ }
8771
+ if (newTop < 0) {
8772
+ newTop = 0;
8773
+ needsAdjustment = true;
8774
+ }
8775
+ if (rect.width > windowWidth) {
8776
+ newWidth = windowWidth - 20;
8777
+ newLeft = 10;
8778
+ needsAdjustment = true;
8779
+ }
8780
+ if (rect.height > windowHeight) {
8781
+ newHeight = windowHeight - 20;
8782
+ newTop = 10;
8783
+ needsAdjustment = true;
8784
+ }
8785
+ if (needsAdjustment) {
8786
+ this.container.style.left = `${newLeft}px`;
8787
+ this.container.style.top = `${newTop}px`;
8788
+ this.container.style.right = "auto";
8789
+ this.container.style.bottom = "auto";
8790
+ if (rect.width > windowWidth || rect.height > windowHeight) {
8791
+ this.container.style.width = `${newWidth}px`;
8792
+ this.container.style.height = `${newHeight}px`;
8793
+ }
8794
+ this.savePosition();
8795
+ }
8796
+ }
8704
8797
  show() {
8705
8798
  this.container.style.display = "block";
8799
+ this.removeReopenButton();
8706
8800
  }
8707
8801
  hide() {
8708
8802
  this.container.style.display = "none";
8803
+ this.createReopenButton();
8804
+ }
8805
+ createReopenButton() {
8806
+ if (document.getElementById("network-debugger-reopen-btn")) return;
8807
+ const btn = document.createElement("button");
8808
+ btn.id = "network-debugger-reopen-btn";
8809
+ btn.className = "debugger-reopen-btn";
8810
+ btn.title = "打开调试青板 (ε―ζ‹–εŠ¨)";
8811
+ btn.textContent = "PWTK";
8812
+ const pos = this.config.position || "bottom-right";
8813
+ if (pos.includes("bottom")) {
8814
+ btn.style.bottom = "20px";
8815
+ } else {
8816
+ btn.style.top = "20px";
8817
+ }
8818
+ if (pos.includes("right")) {
8819
+ btn.style.right = "20px";
8820
+ } else {
8821
+ btn.style.left = "20px";
8822
+ }
8823
+ let isDragging = false;
8824
+ let dragStart = { x: 0, y: 0 };
8825
+ let clickTimer = null;
8826
+ btn.addEventListener("mousedown", (e) => {
8827
+ if (e.button === 0) {
8828
+ isDragging = false;
8829
+ dragStart = { x: e.clientX, y: e.clientY };
8830
+ btn.style.transition = "none";
8831
+ clickTimer = window.setTimeout(() => {
8832
+ isDragging = true;
8833
+ btn.style.cursor = "grabbing";
8834
+ }, 150);
8835
+ e.preventDefault();
8836
+ }
8837
+ });
8838
+ const handleMouseMove = (e) => {
8839
+ if (!isDragging) return;
8840
+ const deltaX = e.clientX - dragStart.x;
8841
+ const deltaY = e.clientY - dragStart.y;
8842
+ const rect = btn.getBoundingClientRect();
8843
+ const newLeft = rect.left + deltaX;
8844
+ const newTop = rect.top + deltaY;
8845
+ const maxX = window.innerWidth - rect.width;
8846
+ const maxY = window.innerHeight - rect.height;
8847
+ const clampedX = Math.max(0, Math.min(maxX, newLeft));
8848
+ const clampedY = Math.max(0, Math.min(maxY, newTop));
8849
+ btn.style.position = "fixed";
8850
+ btn.style.left = `${clampedX}px`;
8851
+ btn.style.top = `${clampedY}px`;
8852
+ btn.style.right = "auto";
8853
+ btn.style.bottom = "auto";
8854
+ dragStart = { x: e.clientX, y: e.clientY };
8855
+ };
8856
+ const handleMouseUp = () => {
8857
+ if (clickTimer) {
8858
+ clearTimeout(clickTimer);
8859
+ clickTimer = null;
8860
+ }
8861
+ if (isDragging) {
8862
+ isDragging = false;
8863
+ btn.style.cursor = "pointer";
8864
+ btn.style.transition = "all 0.3s ease";
8865
+ } else {
8866
+ this.show();
8867
+ }
8868
+ };
8869
+ document.addEventListener("mousemove", handleMouseMove);
8870
+ document.addEventListener("mouseup", handleMouseUp);
8871
+ btn.style.cursor = "pointer";
8872
+ document.body.appendChild(btn);
8873
+ }
8874
+ removeReopenButton() {
8875
+ const btn = document.getElementById("network-debugger-reopen-btn");
8876
+ if (btn) btn.remove();
8709
8877
  }
8710
8878
  destroy() {
8711
8879
  this.container.remove();
8712
8880
  const styles2 = document.getElementById("network-debugger-styles");
8713
8881
  if (styles2) styles2.remove();
8882
+ this.removeReopenButton();
8714
8883
  }
8715
8884
  // ========== localStorage 方法 ==========
8716
8885
  /**
@@ -8863,7 +9032,7 @@ class NetworkDebugger {
8863
9032
  this.initialized = true;
8864
9033
  logger.consoleDirect(`
8865
9034
  ╔════════════════════════════════════════╗
8866
- β•‘ πŸ”“ PWTK 解密小ε·₯ε…· v1.2.20 β•‘
9035
+ β•‘ πŸ”“ PWTK 解密小ε·₯ε…· v1.2.28 β•‘
8867
9036
  β•‘ Created by Leo (@leeguoo) β•‘
8868
9037
  β•‘ ζŠ€ζœ―ζ”―ζŒ: 请联系 Leo β•‘
8869
9038
  β•‘ εˆ†δΊ«ζœεŠ‘: curl.bwg.leeguoo.com β•‘