@leeguoo/pwtk-network-debugger 1.2.23 → 1.2.25

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
@@ -7414,10 +7414,10 @@ const styles = `
7414
7414
  }
7415
7415
 
7416
7416
  #network-debugger-panel.minimized {
7417
- height: 40px !important;
7417
+ height: 30px !important;
7418
7418
  overflow: hidden;
7419
- width: auto !important;
7420
- min-width: 200px;
7419
+ width: 120px !important;
7420
+ max-width: 120px !important;
7421
7421
  }
7422
7422
 
7423
7423
  #network-debugger-panel.minimized .debugger-content {
@@ -7862,6 +7862,13 @@ const styles = `
7862
7862
  left: 10px !important;
7863
7863
  right: auto !important;
7864
7864
  }
7865
+
7866
+ /* 最小化时不应用全宽,保持小尺寸 */
7867
+ #network-debugger-panel.minimized {
7868
+ width: 120px !important;
7869
+ max-width: 120px !important;
7870
+ height: 30px !important;
7871
+ }
7865
7872
  }
7866
7873
 
7867
7874
  ::-webkit-scrollbar {
@@ -7976,7 +7983,7 @@ async function createShareLink(requestData) {
7976
7983
  decryptedResponse: requestData.decryptedResponse,
7977
7984
  error: requestData.error,
7978
7985
  creator: "PWTK Network Debugger by Leo (@leeguoo)",
7979
- version: "1.2.23"
7986
+ version: "1.2.25"
7980
7987
  }
7981
7988
  };
7982
7989
  const originalFetch = window.__originalFetch || window.fetch;
@@ -8057,7 +8064,7 @@ function formatAsCurl(requestData) {
8057
8064
  }
8058
8065
  return curl;
8059
8066
  }
8060
- class DebugPanel {
8067
+ const _DebugPanel = class _DebugPanel {
8061
8068
  constructor(interceptor, config = {}) {
8062
8069
  this.isDragging = false;
8063
8070
  this.isResizing = false;
@@ -8066,17 +8073,22 @@ class DebugPanel {
8066
8073
  this.consoleHistory = [];
8067
8074
  this.requestsCache = [];
8068
8075
  this.interceptor = interceptor;
8076
+ const savedConfig = this.loadConfig();
8069
8077
  this.config = {
8070
8078
  position: "bottom-right",
8071
8079
  theme: "dark",
8072
8080
  minimized: false,
8073
8081
  showConsole: true,
8082
+ ...savedConfig,
8083
+ // 先应用保存的配置
8074
8084
  ...config
8085
+ // 再应用传入的配置(优先级最高)
8075
8086
  };
8076
8087
  this.createPanel();
8077
8088
  this.bindEvents();
8078
8089
  this.startListening();
8079
8090
  logger.setPanel(this);
8091
+ this.loadPosition();
8080
8092
  }
8081
8093
  createPanel() {
8082
8094
  if (!document.getElementById("network-debugger-styles")) {
@@ -8507,6 +8519,7 @@ Created by Leo (@leeguoo)`);
8507
8519
  }
8508
8520
  });
8509
8521
  }
8522
+ this.saveConfig();
8510
8523
  }
8511
8524
  toggleFullscreen() {
8512
8525
  this.container.classList.toggle("fullscreen");
@@ -8680,6 +8693,9 @@ Created by Leo (@leeguoo)`);
8680
8693
  handleMouseUp() {
8681
8694
  if (this.isDragging || this.isResizing) {
8682
8695
  this.container.style.transition = "all 0.3s ease";
8696
+ if (this.isDragging) {
8697
+ this.savePosition();
8698
+ }
8683
8699
  }
8684
8700
  this.isDragging = false;
8685
8701
  this.isResizing = false;
@@ -8696,7 +8712,89 @@ Created by Leo (@leeguoo)`);
8696
8712
  const styles2 = document.getElementById("network-debugger-styles");
8697
8713
  if (styles2) styles2.remove();
8698
8714
  }
8699
- }
8715
+ // ========== localStorage 方法 ==========
8716
+ /**
8717
+ * 从 localStorage 加载配置
8718
+ */
8719
+ loadConfig() {
8720
+ try {
8721
+ const saved = localStorage.getItem(_DebugPanel.STORAGE_KEY);
8722
+ if (saved) {
8723
+ const config = JSON.parse(saved);
8724
+ logger.debug("加载保存的配置:", config);
8725
+ return config;
8726
+ }
8727
+ } catch (error) {
8728
+ logger.error("加载配置失败:", error);
8729
+ }
8730
+ return {};
8731
+ }
8732
+ /**
8733
+ * 保存配置到 localStorage
8734
+ */
8735
+ saveConfig() {
8736
+ try {
8737
+ const configToSave = {
8738
+ position: this.config.position,
8739
+ theme: this.config.theme,
8740
+ minimized: this.config.minimized,
8741
+ showConsole: this.config.showConsole
8742
+ };
8743
+ localStorage.setItem(_DebugPanel.STORAGE_KEY, JSON.stringify(configToSave));
8744
+ logger.debug("配置已保存:", configToSave);
8745
+ } catch (error) {
8746
+ logger.error("保存配置失败:", error);
8747
+ }
8748
+ }
8749
+ /**
8750
+ * 加载保存的位置
8751
+ */
8752
+ loadPosition() {
8753
+ try {
8754
+ const positionKey = `${_DebugPanel.STORAGE_KEY}-position`;
8755
+ const saved = localStorage.getItem(positionKey);
8756
+ if (saved) {
8757
+ const position = JSON.parse(saved);
8758
+ if (position.left !== void 0) {
8759
+ this.container.style.left = position.left + "px";
8760
+ }
8761
+ if (position.top !== void 0) {
8762
+ this.container.style.top = position.top + "px";
8763
+ }
8764
+ if (position.right !== void 0) {
8765
+ this.container.style.right = position.right + "px";
8766
+ }
8767
+ if (position.bottom !== void 0) {
8768
+ this.container.style.bottom = position.bottom + "px";
8769
+ }
8770
+ logger.debug("加载保存的位置:", position);
8771
+ }
8772
+ } catch (error) {
8773
+ logger.error("加载位置失败:", error);
8774
+ }
8775
+ }
8776
+ /**
8777
+ * 保存当前位置
8778
+ */
8779
+ savePosition() {
8780
+ try {
8781
+ const positionKey = `${_DebugPanel.STORAGE_KEY}-position`;
8782
+ const rect = this.container.getBoundingClientRect();
8783
+ const position = {
8784
+ left: rect.left,
8785
+ top: rect.top,
8786
+ right: window.innerWidth - rect.right,
8787
+ bottom: window.innerHeight - rect.bottom
8788
+ };
8789
+ localStorage.setItem(positionKey, JSON.stringify(position));
8790
+ logger.debug("位置已保存:", position);
8791
+ } catch (error) {
8792
+ logger.error("保存位置失败:", error);
8793
+ }
8794
+ }
8795
+ };
8796
+ _DebugPanel.STORAGE_KEY = "pwtk-debugger-config";
8797
+ let DebugPanel = _DebugPanel;
8700
8798
  class NetworkDebugger {
8701
8799
  constructor() {
8702
8800
  this.interceptor = null;